[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [QEMU v5 PATCH 07/18] SMBIOS: Build full type 3 table
From: |
Gabriel L. Somlo |
Subject: |
[Qemu-devel] [QEMU v5 PATCH 07/18] SMBIOS: Build full type 3 table |
Date: |
Fri, 11 Apr 2014 12:11:47 -0400 |
Build smbios type 3 (system enclosure) table, and make it available
to the bios via fw_cfg. For initial compatibility with SeaBIOS, use
"Bochs" as the default manufacturer string, and leave version unset.
Signed-off-by: Gabriel Somlo <address@hidden>
---
hw/i386/smbios.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 4584774..47f7b0d 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -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; \
@@ -358,6 +408,7 @@ static void smbios_build_type_2_table(void)
void smbios_set_defaults(const char *manufacturer,
const char *product, const char *version)
{
+ const char *manufacturer_compat = "Bochs"; /* SeaBIOS compatibility */
smbios_have_defaults = true;
SMBIOS_SET_DEFAULT(type0.vendor, manufacturer);
SMBIOS_SET_DEFAULT(type0.version, version);
@@ -368,6 +419,10 @@ 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_compat);
+ /* not set in SeaBIOS
+ SMBIOS_SET_DEFAULT(type3.version, version);
+ */
}
uint8_t *smbios_get_table(size_t *length)
@@ -376,6 +431,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 +578,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);
--
1.9.0
- [Qemu-devel] [QEMU v5 PATCH 00/18] SMBIOS: build full tables in QEMU, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 01/18] SMBIOS: Rename smbios_set_type1_defaults() for more general use, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 02/18] SMBIOS: Use macro to set smbios defaults, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 03/18] SMBIOS: Use bitmaps to check for smbios table collisions, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 04/18] SMBIOS: Add code to build full smbios tables; build type 2 table, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 05/18] SMBIOS: Build full tables for types 0 and 1, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 06/18] SMBIOS: Remove unused code for passing individual fields to bios, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 07/18] SMBIOS: Build full type 3 table,
Gabriel L. Somlo <=
- [Qemu-devel] [QEMU v5 PATCH 09/18] SMBIOS: Build full smbios memory tables (type 16, 17, 19, and 20), Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 10/18] SMBIOS: Build full tables for type 32 and 127, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 08/18] SMBIOS: Build full type 4 tables, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 11/18] SMBIOS: Update all table definitions to smbios spec v2.3, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 13/18] SMBIOS: Stop including type 20 tables, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 12/18] SMBIOS: Remove SeaBIOS compatibility quirks, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 14/18] SMBIOS: Use e820 memory map to generate type 19 tables, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 15/18] SMBIOS: Update type 3 definition to smbios spec v2.7, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 18/18] SMBIOS: Generate complete smbios tables, including entry point, Gabriel L. Somlo, 2014/04/11
- [Qemu-devel] [QEMU v5 PATCH 16/18] SMBIOS: Update type 4 definition to smbios spec v2.6, Gabriel L. Somlo, 2014/04/11