[PATCH 08/10] hw/core/eif: Move definitions to header

Alexander Graf posted 10 patches 1 month, 3 weeks ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Alexander Graf <graf@amazon.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Dorjoy Chowdhury <dorjoychy111@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>, Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
[PATCH 08/10] hw/core/eif: Move definitions to header
Posted by Alexander Graf 1 month, 3 weeks ago
In follow-up patches we need some EIF file definitions that are
currently in the eif.c file, but want to access them from a separate
device. Move them into the header instead.

Signed-off-by: Alexander Graf <graf@amazon.com>
---
 hw/core/eif.c | 38 --------------------------------------
 hw/core/eif.h | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/hw/core/eif.c b/hw/core/eif.c
index 513caec6b4..96f1d76578 100644
--- a/hw/core/eif.c
+++ b/hw/core/eif.c
@@ -18,44 +18,6 @@
 
 #include "hw/core/eif.h"
 
-#define MAX_SECTIONS 32
-
-/* members are ordered according to field order in .eif file */
-typedef struct EifHeader {
-    uint8_t  magic[4]; /* must be .eif in ascii i.e., [46, 101, 105, 102] */
-    uint16_t version;
-    uint16_t flags;
-    uint64_t default_memory;
-    uint64_t default_cpus;
-    uint16_t reserved;
-    uint16_t section_cnt;
-    uint64_t section_offsets[MAX_SECTIONS];
-    uint64_t section_sizes[MAX_SECTIONS];
-    uint32_t unused;
-    uint32_t eif_crc32;
-} QEMU_PACKED EifHeader;
-
-/* members are ordered according to field order in .eif file */
-typedef struct EifSectionHeader {
-    /*
-     * 0 = invalid, 1 = kernel, 2 = cmdline, 3 = ramdisk, 4 = signature,
-     * 5 = metadata
-     */
-    uint16_t section_type;
-    uint16_t flags;
-    uint64_t section_size;
-} QEMU_PACKED EifSectionHeader;
-
-enum EifSectionTypes {
-    EIF_SECTION_INVALID = 0,
-    EIF_SECTION_KERNEL = 1,
-    EIF_SECTION_CMDLINE = 2,
-    EIF_SECTION_RAMDISK = 3,
-    EIF_SECTION_SIGNATURE = 4,
-    EIF_SECTION_METADATA = 5,
-    EIF_SECTION_MAX = 6,
-};
-
 static const char *section_type_to_string(uint16_t type)
 {
     const char *str;
diff --git a/hw/core/eif.h b/hw/core/eif.h
index fed3cb5514..a3412377a9 100644
--- a/hw/core/eif.h
+++ b/hw/core/eif.h
@@ -11,6 +11,44 @@
 #ifndef HW_CORE_EIF_H
 #define HW_CORE_EIF_H
 
+#define MAX_SECTIONS 32
+
+/* members are ordered according to field order in .eif file */
+typedef struct EifHeader {
+    uint8_t  magic[4]; /* must be .eif in ascii i.e., [46, 101, 105, 102] */
+    uint16_t version;
+    uint16_t flags;
+    uint64_t default_memory;
+    uint64_t default_cpus;
+    uint16_t reserved;
+    uint16_t section_cnt;
+    uint64_t section_offsets[MAX_SECTIONS];
+    uint64_t section_sizes[MAX_SECTIONS];
+    uint32_t unused;
+    uint32_t eif_crc32;
+} QEMU_PACKED EifHeader;
+
+/* members are ordered according to field order in .eif file */
+typedef struct EifSectionHeader {
+    /*
+     * 0 = invalid, 1 = kernel, 2 = cmdline, 3 = ramdisk, 4 = signature,
+     * 5 = metadata
+     */
+    uint16_t section_type;
+    uint16_t flags;
+    uint64_t section_size;
+} QEMU_PACKED EifSectionHeader;
+
+enum EifSectionTypes {
+    EIF_SECTION_INVALID = 0,
+    EIF_SECTION_KERNEL = 1,
+    EIF_SECTION_CMDLINE = 2,
+    EIF_SECTION_RAMDISK = 3,
+    EIF_SECTION_SIGNATURE = 4,
+    EIF_SECTION_METADATA = 5,
+    EIF_SECTION_MAX = 6,
+};
+
 bool read_eif_file(const char *eif_path, const char *machine_initrd,
                    char **kernel_path, char **initrd_path,
                    char **kernel_cmdline, uint8_t *image_sha384,
-- 
2.47.1




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Re: [PATCH 08/10] hw/core/eif: Move definitions to header
Posted by Dorjoy Chowdhury 1 month, 3 weeks ago
On Wed, Feb 18, 2026 at 7:53 AM Alexander Graf <graf@amazon.com> wrote:
>
> In follow-up patches we need some EIF file definitions that are
> currently in the eif.c file, but want to access them from a separate
> device. Move them into the header instead.
>
> Signed-off-by: Alexander Graf <graf@amazon.com>
> ---
>  hw/core/eif.c | 38 --------------------------------------
>  hw/core/eif.h | 38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 38 insertions(+), 38 deletions(-)

Reviewed-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>

Regards,
Dorjoy

>
> diff --git a/hw/core/eif.c b/hw/core/eif.c
> index 513caec6b4..96f1d76578 100644
> --- a/hw/core/eif.c
> +++ b/hw/core/eif.c
> @@ -18,44 +18,6 @@
>
>  #include "hw/core/eif.h"
>
> -#define MAX_SECTIONS 32
> -
> -/* members are ordered according to field order in .eif file */
> -typedef struct EifHeader {
> -    uint8_t  magic[4]; /* must be .eif in ascii i.e., [46, 101, 105, 102] */
> -    uint16_t version;
> -    uint16_t flags;
> -    uint64_t default_memory;
> -    uint64_t default_cpus;
> -    uint16_t reserved;
> -    uint16_t section_cnt;
> -    uint64_t section_offsets[MAX_SECTIONS];
> -    uint64_t section_sizes[MAX_SECTIONS];
> -    uint32_t unused;
> -    uint32_t eif_crc32;
> -} QEMU_PACKED EifHeader;
> -
> -/* members are ordered according to field order in .eif file */
> -typedef struct EifSectionHeader {
> -    /*
> -     * 0 = invalid, 1 = kernel, 2 = cmdline, 3 = ramdisk, 4 = signature,
> -     * 5 = metadata
> -     */
> -    uint16_t section_type;
> -    uint16_t flags;
> -    uint64_t section_size;
> -} QEMU_PACKED EifSectionHeader;
> -
> -enum EifSectionTypes {
> -    EIF_SECTION_INVALID = 0,
> -    EIF_SECTION_KERNEL = 1,
> -    EIF_SECTION_CMDLINE = 2,
> -    EIF_SECTION_RAMDISK = 3,
> -    EIF_SECTION_SIGNATURE = 4,
> -    EIF_SECTION_METADATA = 5,
> -    EIF_SECTION_MAX = 6,
> -};
> -
>  static const char *section_type_to_string(uint16_t type)
>  {
>      const char *str;
> diff --git a/hw/core/eif.h b/hw/core/eif.h
> index fed3cb5514..a3412377a9 100644
> --- a/hw/core/eif.h
> +++ b/hw/core/eif.h
> @@ -11,6 +11,44 @@
>  #ifndef HW_CORE_EIF_H
>  #define HW_CORE_EIF_H
>
> +#define MAX_SECTIONS 32
> +
> +/* members are ordered according to field order in .eif file */
> +typedef struct EifHeader {
> +    uint8_t  magic[4]; /* must be .eif in ascii i.e., [46, 101, 105, 102] */
> +    uint16_t version;
> +    uint16_t flags;
> +    uint64_t default_memory;
> +    uint64_t default_cpus;
> +    uint16_t reserved;
> +    uint16_t section_cnt;
> +    uint64_t section_offsets[MAX_SECTIONS];
> +    uint64_t section_sizes[MAX_SECTIONS];
> +    uint32_t unused;
> +    uint32_t eif_crc32;
> +} QEMU_PACKED EifHeader;
> +
> +/* members are ordered according to field order in .eif file */
> +typedef struct EifSectionHeader {
> +    /*
> +     * 0 = invalid, 1 = kernel, 2 = cmdline, 3 = ramdisk, 4 = signature,
> +     * 5 = metadata
> +     */
> +    uint16_t section_type;
> +    uint16_t flags;
> +    uint64_t section_size;
> +} QEMU_PACKED EifSectionHeader;
> +
> +enum EifSectionTypes {
> +    EIF_SECTION_INVALID = 0,
> +    EIF_SECTION_KERNEL = 1,
> +    EIF_SECTION_CMDLINE = 2,
> +    EIF_SECTION_RAMDISK = 3,
> +    EIF_SECTION_SIGNATURE = 4,
> +    EIF_SECTION_METADATA = 5,
> +    EIF_SECTION_MAX = 6,
> +};
> +
>  bool read_eif_file(const char *eif_path, const char *machine_initrd,
>                     char **kernel_path, char **initrd_path,
>                     char **kernel_cmdline, uint8_t *image_sha384,
> --
> 2.47.1
>
>
>
>
> Amazon Web Services Development Center Germany GmbH
> Tamara-Danz-Str. 13
> 10243 Berlin
> Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
> Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
> Sitz: Berlin
> Ust-ID: DE 365 538 597
>