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

Lucas De Marchi lucas.demarchi at intel.com
Mon Aug 26 15:26:54 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.

v2 (Gustavo):
- Use the cparser.add_type(..., replace=True) for overriding types

Acked-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Reviewed-by: Gustavo Sousa <gustavo.sousa at intel.com>
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 a4b9414f2..8fcb2961a 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.add_type("u8", "uint8_t", replace=True)
+        cparser.add_type("u16", "uint16_t", replace=True)
+        cparser.add_type("u32", "uint32_t", replace=True)
+        cparser.add_type("u64", "uint64_t", replace=True)
         cparser.load(CDEF)
 
         magic = cparser.magic(f).data
-- 
2.43.0



More information about the igt-dev mailing list