Received: from eggs.gnu.org ([2001:4830:134:3::10]:38646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAlIR-0007h1-Uo for qemu-devel@nongnu.org; Tue, 04 Feb 2014 14:04:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAlIM-0007wv-Cd for qemu-devel@nongnu.org; Tue, 04 Feb 2014 14:04:35 -0500 Received: from mail-qc0-x232.google.com ([2607:f8b0:400d:c01::232]:43530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAlIM-0007w0-9f for qemu-devel@nongnu.org; Tue, 04 Feb 2014 14:04:30 -0500 Received: by mail-qc0-f178.google.com with SMTP id m20so14645014qcx.9 for ; Tue, 04 Feb 2014 11:04:29 -0800 (PST) Date: Tue, 4 Feb 2014 14:03:31 -0500 From: "Gabriel L. Somlo" Message-ID: <20140204190331.GT29329@ERROL.INI.CMU.EDU> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH 2/2] SMBIOS: Add Type 2 (Baseboard) struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: seabios@seabios.org Cc: qemu-devel@nongnu.org, agraf@suse.de OS X (10.7/Lion and 10.8/MountainLion) guests crash during boot if a Type 2 (Baseboard) structure is not found in the SMBIOS table. Signed-off-by: Gabriel Somlo --- src/fw/smbios.c | 36 ++++++++++++++++++++++++++++++++++++ src/std/smbios.h | 16 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/fw/smbios.c b/src/fw/smbios.c index b2d7f14..5b76468 100644 --- a/src/fw/smbios.c +++ b/src/fw/smbios.c @@ -251,6 +251,41 @@ smbios_init_type_1(void *start) return end; } +/* Type 2 -- Base Board */ +static void * +smbios_init_type_2(void *start) +{ + struct smbios_type_2 *p = (struct smbios_type_2 *)start; + char *end = (char *)start + sizeof(struct smbios_type_2); + size_t size; + int str_index = 0; + + p->header.type = 2; + p->header.length = sizeof(struct smbios_type_2); + p->header.handle = 0x200; + + load_str_field_with_default(2, manufacturer_str, BUILD_APPNAME); + load_str_field_or_skip(2, product_str); + load_str_field_or_skip(2, version_str); + load_str_field_or_skip(2, serial_number_str); + load_str_field_or_skip(2, asset_tag_number_str); + load_str_field_or_skip(2, location_str); + + set_field_with_default(2, feature_flags, 0x01); /* Motherboard */ + set_field_with_default(2, chassis_handle, 0x300); /* T3 System Enclosure */ + set_field_with_default(2, board_type, 0x0a); /* Motherboard */ + set_field_with_default(2, contained_element_count, 0); + + *end = 0; + end++; + if (!str_index) { + *end = 0; + end++; + } + + return end; +} + /* Type 3 -- System Enclosure */ static void * smbios_init_type_3(void *start) @@ -546,6 +581,7 @@ smbios_setup(void) add_struct(0, p); add_struct(1, p); + add_struct(2, p); add_struct(3, p); int cpu_num; diff --git a/src/std/smbios.h b/src/std/smbios.h index ba0e95d..86a4c57 100644 --- a/src/std/smbios.h +++ b/src/std/smbios.h @@ -59,6 +59,22 @@ struct smbios_type_1 { u8 family_str; } PACKED; +/* SMBIOS type 2 - Base Board */ +struct smbios_type_2 { + struct smbios_structure_header header; + u8 manufacturer_str; + u8 product_str; + u8 version_str; + u8 serial_number_str; + u8 asset_tag_number_str; + u8 feature_flags; + u8 location_str; + u16 chassis_handle; + u8 board_type; + u8 contained_element_count; + // contained elements follow +} PACKED; + /* SMBIOS type 3 - System Enclosure (v2.3) */ struct smbios_type_3 { struct smbios_structure_header header; -- 1.8.1.4