[PATCH i-g-t v2 4/6] tools/intel-gfx-fw-info: Override kernel types

Lucas De Marchi lucas.demarchi at intel.com
Tue Aug 20 23:29:26 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 0f1da8bff..57d6f935b 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