[PATCH i-g-t 3/4] tools/intel-gfx-fw-info: Override kernel types
Lucas De Marchi
lucas.demarchi at intel.com
Mon Aug 19 19:55:59 UTC 2024
Previously we were defining u32 type as part of the string we are
loading. However in order to use other types like u8 and u16 in upcoming
changes, it would be better to have them all defined in a single place.
We can't create a typedef like done with u32 because cstruct already
defines a few types for convenience. However it's very surprising it's
defining e.g. u8 as a 64-bit variable.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
tools/intel-gfx-fw-info | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/intel-gfx-fw-info b/tools/intel-gfx-fw-info
index a2518aa0e..85f99b75a 100755
--- a/tools/intel-gfx-fw-info
+++ b/tools/intel-gfx-fw-info
@@ -23,8 +23,6 @@ import typing
# dumpstruct(): give it a name
CDEF = """
-typedef uint32 u32;
-
struct uc_css_header {
u32 module_type;
/*
@@ -120,6 +118,13 @@ class Fw(abc.ABC):
@classmethod
def create(cls, f):
cparser = cstruct.cstruct()
+ # cstruct defines some "convenience types" that are not very convenient
+ # when parsing a kernel header - e.g. we don't want u16 to be parsed as
+ # uint128
+ cparser.typedefs["u8"] = "uint8_t";
+ cparser.typedefs["u16"] = "uint16_t";
+ cparser.typedefs["u32"] = "uint32_t";
+ cparser.typedefs["u64"] = "uint64_t";
cparser.load(CDEF)
magic = cparser.magic(f).data
--
2.43.0
More information about the igt-dev
mailing list