SMBIOS: Build full type 3 table
PATCH 8/10 SMBIOS: Build full type 3 table
Build smbios type 3 (system enclosure) table, and make it available to the bios via fw_cfg.
Signed-off-by Gabriel Somlo <[email protected]>
--- hw/i386/smbios.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
hw/i386/smbios.c +64 -0
@@ -61,6 +61,10 @@ static struct {const char *manufacturer, *product, *version, *serial, *asset, *location; } type2; +static struct { +const char *manufacturer, *version, *serial, *asset; +} type3; +static QemuOptsList qemu_smbios_opts = { .name ="smbios" , .head =QTAILQ_HEAD_INITIALIZER (qemu_smbios_opts.head),
@@ -177,6 +181,31 @@ static const QemuOptDesc qemu_smbios_type2_opts[] = { {/* end of list */ } }; +static const QemuOptDesc qemu_smbios_type3_opts[] = { + { + .name ="type" , + .type =QEMU_OPT_NUMBER , + .help ="SMBIOS element type" , + },{ + .name ="manufacturer" , + .type =QEMU_OPT_STRING , + .help ="manufacturer name" , + },{ + .name ="version" , + .type =QEMU_OPT_STRING , + .help ="version number" , + },{ + .name ="serial" , + .type =QEMU_OPT_STRING , + .help ="serial number" , + },{ + .name ="asset" , + .type =QEMU_OPT_STRING , + .help ="asset tag number" , + }, + {/* end of list */ } +}; +static void smbios_register_config (void ) {qemu_add_opts (&qemu_smbios_opts);
@@ -350,6 +379,27 @@ static void smbios_build_type_2_table(void)SMBIOS_BUILD_TABLE_POST ; } +static void smbios_build_type_3_table (void ) +{ +SMBIOS_BUILD_TABLE_PRE (3 ,0x300 , true);/* required */ + +SMBIOS_TABLE_SET_STR (3 , manufacturer_str, type3.manufacturer); + t->type =0x01 ;/* Other */ +SMBIOS_TABLE_SET_STR (3 , version_str, type3.version); +SMBIOS_TABLE_SET_STR (3 , serial_number_str, type3.serial); +SMBIOS_TABLE_SET_STR (3 , asset_tag_number_str, type3.asset); + t->boot_up_state =0x03 ;/* Safe */ + t->power_supply_state =0x03 ;/* Safe */ + t->thermal_state =0x03 ;/* Safe */ + t->security_status =0x02 ;/* Unknown */ + t->oem_defined =0 ; + t->height =0 ; + t->number_of_power_cords =0 ; + t->contained_element_count =0 ; + +SMBIOS_BUILD_TABLE_POST ; +} +#define SMBIOS_SET_DEFAULT (field, value) \ if (!field) { \ field = value; \
@@ -368,6 +418,8 @@ void smbios_set_defaults(const char *manufacturer,SMBIOS_SET_DEFAULT (type2.manufacturer, manufacturer);SMBIOS_SET_DEFAULT (type2.product, product);SMBIOS_SET_DEFAULT (type2.version, version); +SMBIOS_SET_DEFAULT (type3.manufacturer, manufacturer); +SMBIOS_SET_DEFAULT (type3.version, version); }uint8_t *smbios_get_table (size_t *length)
@@ -376,6 +428,7 @@ uint8_t *smbios_get_table(size_t *length)smbios_build_type_0_table ();smbios_build_type_1_table ();smbios_build_type_2_table (); +smbios_build_type_3_table ();smbios_validate_table (); smbios_immutable = true; }
@@ -522,6 +575,17 @@ void smbios_entry_add(QemuOpts *opts)save_opt (&type2.asset, opts,"asset" );save_opt (&type2.location, opts,"location" );return ; +case 3 : +qemu_opts_validate (opts, qemu_smbios_type3_opts, &local_err); +if (local_err) { +error_report ("%s" ,error_get_pretty (local_err)); +exit (1 ); + } +save_opt (&type3.manufacturer, opts,"manufacturer" ); +save_opt (&type3.version, opts,"version" ); +save_opt (&type3.serial, opts,"serial" ); +save_opt (&type3.asset, opts,"asset" ); +return ;default :error_report ("Don't know how to build fields for SMBIOS type %ld" , type);
Signature · 1 line
1.8.1.4