Re: [PATCH v2 10/20] smbios: rename/expose structures/bitmaps used by both legacy and modern code
On Tue, 5 Mar 2024, Igor Mammedov wrote: > As a preparation to move legacy handling into a separate file, > add prefix 'smbios_' to type0/type1/have_binfile_bitmap/have_fields_bitmap > and expose them in smbios.h so that they can be reused in > legacy and modern code. > > Doing it as a separate patch to avoid rename cluttering follow-up > patch which will move legacy code into a separate file. > I checked that after application of this patch in the patcset, QEMU build goes through fine. Therefore, > Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha > --- > include/hw/firmware/smbios.h | 16 + > hw/smbios/smbios.c | 113 --- > 2 files changed, 69 insertions(+), 60 deletions(-) > > diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h > index 1fbff3c55f..bea5c3f1b1 100644 > --- a/include/hw/firmware/smbios.h > +++ b/include/hw/firmware/smbios.h > @@ -2,6 +2,7 @@ > #define QEMU_SMBIOS_H > > #include "qapi/qapi-types-machine.h" > +#include "qemu/bitmap.h" > > /* > * SMBIOS Support > @@ -16,8 +17,23 @@ > * > */ > > +typedef struct { > +const char *vendor, *version, *date; > +bool have_major_minor, uefi; > +uint8_t major, minor; > +} smbios_type0_t; > +extern smbios_type0_t smbios_type0; > + > +typedef struct { > +const char *manufacturer, *product, *version, *serial, *sku, *family; > +/* uuid is in qemu_uuid */ > +} smbios_type1_t; > +extern smbios_type1_t smbios_type1; > > #define SMBIOS_MAX_TYPE 127 > +extern DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); > +extern DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); > + > #define offsetofend(TYPE, MEMBER) \ > (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) > > diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c > index 01180bd82c..86cf66b5ce 100644 > --- a/hw/smbios/smbios.c > +++ b/hw/smbios/smbios.c > @@ -78,19 +78,11 @@ static int smbios_type4_count = 0; > static bool smbios_have_defaults; > static uint32_t smbios_cpuid_version, smbios_cpuid_features; > > -static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1); > -static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1); > +DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); > +DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); > > -static struct { > -const char *vendor, *version, *date; > -bool have_major_minor, uefi; > -uint8_t major, minor; > -} type0; > - > -static struct { > -const char *manufacturer, *product, *version, *serial, *sku, *family; > -/* uuid is in qemu_uuid */ > -} type1; > +smbios_type0_t smbios_type0; > +smbios_type1_t smbios_type1; > > static struct { > const char *manufacturer, *product, *version, *serial, *asset, *location; > @@ -536,36 +528,36 @@ static void smbios_maybe_add_str(int type, int offset, > const char *data) > static void smbios_build_type_0_fields(void) > { > smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str), > - type0.vendor); > + smbios_type0.vendor); > smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_str), > - type0.version); > + smbios_type0.version); > smbios_maybe_add_str(0, offsetof(struct smbios_type_0, > bios_release_date_str), > - type0.date); > -if (type0.have_major_minor) { > + smbios_type0.date); > +if (smbios_type0.have_major_minor) { > smbios_add_field(0, offsetof(struct smbios_type_0, > system_bios_major_release), > - , 1); > + _type0.major, 1); > smbios_add_field(0, offsetof(struct smbios_type_0, > system_bios_minor_release), > - , 1); > + _type0.minor, 1); > } > } > > static void smbios_build_type_1_fields(void) > { > smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_str), > - type1.manufacturer); > + smbios_type1.manufacturer); > smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_str), > - type1.product); > + smbios_type1.product); > smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str), > - type1.version); > + smbios_type1.version); > smbios_maybe_add_str(1, offsetof(struct smbios_type_1, > serial_number_str), > - type1.serial); > + smbios_type1.serial); > smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str), > - type1.sku); > + smbios_type1.sku); >
[PATCH v2 10/20] smbios: rename/expose structures/bitmaps used by both legacy and modern code
As a preparation to move legacy handling into a separate file, add prefix 'smbios_' to type0/type1/have_binfile_bitmap/have_fields_bitmap and expose them in smbios.h so that they can be reused in legacy and modern code. Doing it as a separate patch to avoid rename cluttering follow-up patch which will move legacy code into a separate file. Signed-off-by: Igor Mammedov --- include/hw/firmware/smbios.h | 16 + hw/smbios/smbios.c | 113 --- 2 files changed, 69 insertions(+), 60 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 1fbff3c55f..bea5c3f1b1 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -2,6 +2,7 @@ #define QEMU_SMBIOS_H #include "qapi/qapi-types-machine.h" +#include "qemu/bitmap.h" /* * SMBIOS Support @@ -16,8 +17,23 @@ * */ +typedef struct { +const char *vendor, *version, *date; +bool have_major_minor, uefi; +uint8_t major, minor; +} smbios_type0_t; +extern smbios_type0_t smbios_type0; + +typedef struct { +const char *manufacturer, *product, *version, *serial, *sku, *family; +/* uuid is in qemu_uuid */ +} smbios_type1_t; +extern smbios_type1_t smbios_type1; #define SMBIOS_MAX_TYPE 127 +extern DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); +extern DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); + #define offsetofend(TYPE, MEMBER) \ (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 01180bd82c..86cf66b5ce 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -78,19 +78,11 @@ static int smbios_type4_count = 0; static bool smbios_have_defaults; static uint32_t smbios_cpuid_version, smbios_cpuid_features; -static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1); -static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1); +DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); +DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); -static struct { -const char *vendor, *version, *date; -bool have_major_minor, uefi; -uint8_t major, minor; -} type0; - -static struct { -const char *manufacturer, *product, *version, *serial, *sku, *family; -/* uuid is in qemu_uuid */ -} type1; +smbios_type0_t smbios_type0; +smbios_type1_t smbios_type1; static struct { const char *manufacturer, *product, *version, *serial, *asset, *location; @@ -536,36 +528,36 @@ static void smbios_maybe_add_str(int type, int offset, const char *data) static void smbios_build_type_0_fields(void) { smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str), - type0.vendor); + smbios_type0.vendor); smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_str), - type0.version); + smbios_type0.version); smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_release_date_str), - type0.date); -if (type0.have_major_minor) { + smbios_type0.date); +if (smbios_type0.have_major_minor) { smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_major_release), - , 1); + _type0.major, 1); smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_minor_release), - , 1); + _type0.minor, 1); } } static void smbios_build_type_1_fields(void) { smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_str), - type1.manufacturer); + smbios_type1.manufacturer); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_str), - type1.product); + smbios_type1.product); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str), - type1.version); + smbios_type1.version); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_str), - type1.serial); + smbios_type1.serial); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str), - type1.sku); + smbios_type1.sku); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str), - type1.family); + smbios_type1.family); if (qemu_uuid_set) { /* We don't encode the UUID in the "wire format" here because this * function is for legacy mode and needs to keep the guest ABI, and @@ -583,14 +575,14 @@ uint8_t *smbios_get_table_legacy(size_t *length) size_t