Received: from eggs.gnu.org ([2001:4830:134:3::10]:37158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMU6C-0003cH-FA for qemu-devel@nongnu.org; Sat, 08 Mar 2014 22:08:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMU66-0007A3-SJ for qemu-devel@nongnu.org; Sat, 08 Mar 2014 22:08:24 -0500 Received: from mail-qg0-x22c.google.com ([2607:f8b0:400d:c04::22c]:52873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMU66-00079z-Oa for qemu-devel@nongnu.org; Sat, 08 Mar 2014 22:08:18 -0500 Received: by mail-qg0-f44.google.com with SMTP id a108so16583711qge.3 for ; Sat, 08 Mar 2014 19:08:18 -0800 (PST) Date: Sat, 8 Mar 2014 22:05:17 -0500 From: "Gabriel L. Somlo" Message-ID: <20140309030516.GD17184@ERROL.INI.CMU.EDU> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5318AAA0.1090301@redhat.com> Subject: [Qemu-devel] [PATCH 6/7] SMBIOS: Build full tables for types 0 and 1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kevin@koconnor.net, lersek@redhat.com, kraxel@redhat.com, agraf@suse.de If defaults are set by piix or q35, or fields are given on the command line, build full smbios tables for types 0 and 1 instead of sending individual fields to the BIOS via fw_cfg. Signed-off-by: Gabriel Somlo --- hw/i386/smbios.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index 9679e06..e7df372 100644 --- a/hw/i386/smbios.c +++ b/hw/i386/smbios.c @@ -352,6 +352,62 @@ static void smbios_build_type_1_fields(void) } } +static void smbios_build_type_0_table(void) +{ + SMBIOS_BUILD_TABLE_PRE(0, 0x000, true); /* required */ + + SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor); + SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version); + + t->bios_starting_address_segment = 0xE800; /* hardcoded in SeaBIOS */ + + SMBIOS_TABLE_SET_STR(0, bios_release_date_str, type0.date); + + t->bios_rom_size = 0; /* hardcoded in SeaBIOS with FIXME comment */ + + /* BIOS characteristics not supported */ + memset(t->bios_characteristics, 0, 8); + t->bios_characteristics[0] = 0x08; + + /* Enable targeted content distribution (needed for SVVP, per SeaBIOS) */ + t->bios_characteristics_extension_bytes[0] = 0; + t->bios_characteristics_extension_bytes[1] = 4; + + if (type0.have_major_minor) { + t->system_bios_major_release = type0.major; + t->system_bios_minor_release = type0.minor; + } else { + t->system_bios_major_release = 0; + t->system_bios_minor_release = 0; + } + + /* hardcoded in SeaBIOS */ + t->embedded_controller_major_release = 0xFF; + t->embedded_controller_minor_release = 0xFF; + + SMBIOS_BUILD_TABLE_POST; +} + +static void smbios_build_type_1_table(void) +{ + SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */ + + SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer); + SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product); + SMBIOS_TABLE_SET_STR(1, version_str, type1.version); + SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial); + if (qemu_uuid_set) { + memcpy(t->uuid, qemu_uuid, 16); + } else { + memset(t->uuid, 0, 16); + } + t->wake_up_type = 0x06; /* power switch */ + SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku); + SMBIOS_TABLE_SET_STR(1, family_str, type1.family); + + SMBIOS_BUILD_TABLE_POST; +} + static void smbios_build_type_2_table(void) { SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */ @@ -379,6 +435,9 @@ void smbios_set_defaults(const char *manufacturer, const char *product, const char *version) { smbios_build_tables = true; + SMBIOS_SET_DEFAULT(type0.vendor, manufacturer); + SMBIOS_SET_DEFAULT(type0.version, version); + SMBIOS_SET_DEFAULT(type0.date, "01/01/2014"); SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer); SMBIOS_SET_DEFAULT(type1.product, product); SMBIOS_SET_DEFAULT(type1.version, version); @@ -390,9 +449,13 @@ void smbios_set_defaults(const char *manufacturer, uint8_t *smbios_get_table(size_t *length) { if (!smbios_immutable) { + smbios_build_type_0_table(); + smbios_build_type_1_table(); smbios_build_type_2_table(); +if (false) { /* shut up gcc until we remove deprecated code */ smbios_build_type_0_fields(); smbios_build_type_1_fields(); +} smbios_validate_table(); smbios_immutable = true; } -- 1.8.1.4