Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Gustavo Sousa <gustavo.sousa@intel.com>,
	Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH i-g-t v2 4/6] tools/intel-gfx-fw-info: Override kernel types
Date: Tue, 20 Aug 2024 16:29:26 -0700	[thread overview]
Message-ID: <20240820232928.458248-5-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20240820232928.458248-1-lucas.demarchi@intel.com>

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@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


  parent reply	other threads:[~2024-08-20 23:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20 23:29 [PATCH i-g-t v2 0/6] Parse GSC-based HuC firmware layout Lucas De Marchi
2024-08-20 23:29 ` [PATCH i-g-t v2 1/6] tools/intel-gfx-fw-info: Re-format with black Lucas De Marchi
2024-08-21 11:29   ` Kamil Konieczny
2024-08-21 12:35     ` Lucas De Marchi
2024-08-21 17:11       ` Kamil Konieczny
2024-08-21 16:46   ` Gustavo Sousa
2024-08-20 23:29 ` [PATCH i-g-t v2 2/6] tools/intel-gfx-fw-info: Annotate abstract method Lucas De Marchi
2024-08-21 16:47   ` Gustavo Sousa
2024-08-20 23:29 ` [PATCH i-g-t v2 3/6] tools/intel-gfx-fw-info: Embed fw decoding Lucas De Marchi
2024-08-21 17:06   ` Gustavo Sousa
2024-08-21 18:17     ` Lucas De Marchi
2024-08-20 23:29 ` Lucas De Marchi [this message]
2024-08-21 17:18   ` [PATCH i-g-t v2 4/6] tools/intel-gfx-fw-info: Override kernel types Gustavo Sousa
2024-08-21 18:37     ` Lucas De Marchi
2024-08-20 23:29 ` [PATCH i-g-t v2 5/6] tools/intel-gfx-fw-info: Add proper HuC parser Lucas De Marchi
2024-08-20 23:29 ` [PATCH i-g-t v2 6/6] tools/intel-gfx-fw-info: do not use bare 'except' Lucas De Marchi
2024-08-21 17:19   ` Gustavo Sousa
2024-08-20 23:54 ` ✓ CI.xeBAT: success for Parse GSC-based HuC firmware layout (rev2) Patchwork
2024-08-21  0:11 ` ✓ Fi.CI.BAT: " Patchwork
2024-08-21  3:24 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-08-21  7:57 ` ✓ CI.xeFULL: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240820232928.458248-5-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=gustavo.sousa@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox