@samitouri / QOSamiQemu / commits / 73f84b622f

hw/core/eif: Move definitions to header

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> Reviewed-by: Dorjoy Chowdhury <dorjoychy111@gmail.com> Link: https://lore.kernel.org/r/20260225220807.33092-10-graf@amazon.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Alexander Graf committed Feb 25, 2026 at 22:08 UTC 73f84b622f0dace9741dd9d1ae908b2e84f00281
2 files changed +38 -38
hw/core/eif.c
-38
@@ -18,44 +18,6 @@
18
19 #include "hw/core/eif.h"
20
21 -#define MAX_SECTIONS 32
22 -
23 -/* members are ordered according to field order in .eif file */
24 -typedef struct EifHeader {
25 - uint8_t magic[4]; /* must be .eif in ascii i.e., [46, 101, 105, 102] */
26 - uint16_t version;
27 - uint16_t flags;
28 - uint64_t default_memory;
29 - uint64_t default_cpus;
30 - uint16_t reserved;
31 - uint16_t section_cnt;
32 - uint64_t section_offsets[MAX_SECTIONS];
33 - uint64_t section_sizes[MAX_SECTIONS];
34 - uint32_t unused;
35 - uint32_t eif_crc32;
36 -} QEMU_PACKED EifHeader;
37 -
38 -/* members are ordered according to field order in .eif file */
39 -typedef struct EifSectionHeader {
40 - /*
41 - * 0 = invalid, 1 = kernel, 2 = cmdline, 3 = ramdisk, 4 = signature,
42 - * 5 = metadata
43 - */
44 - uint16_t section_type;
45 - uint16_t flags;
46 - uint64_t section_size;
47 -} QEMU_PACKED EifSectionHeader;
48 -
49 -enum EifSectionTypes {
50 - EIF_SECTION_INVALID = 0,
51 - EIF_SECTION_KERNEL = 1,
52 - EIF_SECTION_CMDLINE = 2,
53 - EIF_SECTION_RAMDISK = 3,
54 - EIF_SECTION_SIGNATURE = 4,
55 - EIF_SECTION_METADATA = 5,
56 - EIF_SECTION_MAX = 6,
57 -};
58 -
21 static const char *section_type_to_string(uint16_t type)
22 {
23 const char *str;
hw/core/eif.h
+38
@@ -11,6 +11,44 @@
11 #ifndef HW_CORE_EIF_H
12 #define HW_CORE_EIF_H
13
14 +#define MAX_SECTIONS 32
15 +
16 +/* members are ordered according to field order in .eif file */
17 +typedef struct EifHeader {
18 + uint8_t magic[4]; /* must be .eif in ascii i.e., [46, 101, 105, 102] */
19 + uint16_t version;
20 + uint16_t flags;
21 + uint64_t default_memory;
22 + uint64_t default_cpus;
23 + uint16_t reserved;
24 + uint16_t section_cnt;
25 + uint64_t section_offsets[MAX_SECTIONS];
26 + uint64_t section_sizes[MAX_SECTIONS];
27 + uint32_t unused;
28 + uint32_t eif_crc32;
29 +} QEMU_PACKED EifHeader;
30 +
31 +/* members are ordered according to field order in .eif file */
32 +typedef struct EifSectionHeader {
33 + /*
34 + * 0 = invalid, 1 = kernel, 2 = cmdline, 3 = ramdisk, 4 = signature,
35 + * 5 = metadata
36 + */
37 + uint16_t section_type;
38 + uint16_t flags;
39 + uint64_t section_size;
40 +} QEMU_PACKED EifSectionHeader;
41 +
42 +enum EifSectionTypes {
43 + EIF_SECTION_INVALID = 0,
44 + EIF_SECTION_KERNEL = 1,
45 + EIF_SECTION_CMDLINE = 2,
46 + EIF_SECTION_RAMDISK = 3,
47 + EIF_SECTION_SIGNATURE = 4,
48 + EIF_SECTION_METADATA = 5,
49 + EIF_SECTION_MAX = 6,
50 +};
51 +
52 bool read_eif_file(const char *eif_path, const char *machine_initrd,
53 char **kernel_path, char **initrd_path,
54 char **kernel_cmdline, uint8_t *image_sha384,