From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LOaBH-0003cG-Gt for qemu-devel@nongnu.org; Sun, 18 Jan 2009 11:07:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LOaBF-0003c4-Nl for qemu-devel@nongnu.org; Sun, 18 Jan 2009 11:07:22 -0500 Received: from [199.232.76.173] (port=53711 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOaBF-0003c1-Fu for qemu-devel@nongnu.org; Sun, 18 Jan 2009 11:07:21 -0500 Received: from mx2.redhat.com ([66.187.237.31]:38005) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LOaBE-0007PR-R7 for qemu-devel@nongnu.org; Sun, 18 Jan 2009 11:07:21 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n0IG7Kum021883 for ; Sun, 18 Jan 2009 11:07:20 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n0IG7IZY026499 for ; Sun, 18 Jan 2009 11:07:19 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n0IG7IXd012576 for ; Sun, 18 Jan 2009 11:07:18 -0500 Date: Sun, 18 Jan 2009 18:05:37 +0200 From: Gleb Natapov Message-ID: <20090118160537.GI11299@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] Pass trusted NIC to OS through SMBIOS Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Gleb Natapov diff --git a/bios/rombios32.c b/bios/rombios32.c index 944d2e7..d55d252 100644 --- a/bios/rombios32.c +++ b/bios/rombios32.c @@ -413,6 +413,7 @@ unsigned long bios_table_end_addr; #define QEMU_CFG_SIGNATURE 0x00 #define QEMU_CFG_ID 0x01 #define QEMU_CFG_UUID 0x02 +#define QEMU_CFG_TRUSTED_NIC 0x07 int qemu_cfg_port; @@ -440,6 +441,19 @@ void qemu_cfg_read(uint8_t *buf, int len) while (len--) *(buf++) = inb(QEMU_CFG_DATA_PORT); } + +int qemu_cfg_read_string(uint8_t *buf, int len) +{ + int c = 0; + while (c < len) { + buf[c] = inb(QEMU_CFG_DATA_PORT); + if (!buf[c]) + break; + c++; + } + + return c; +} #endif void uuid_probe(void) @@ -1708,6 +1722,13 @@ struct smbios_type_4 { uint16_t l3_cache_handle; } __attribute__((__packed__)); +/* SMBIOS type 11 - OEM Strings + */ +struct smbios_type_11 { + struct smbios_structure_header header; + uint8_t count; +} __attribute__((__packed__)); + /* SMBIOS type 16 - Physical Memory Array * Associated with one type 17 (Memory Device). */ @@ -1944,6 +1965,34 @@ smbios_type_4_init(void *start, unsigned int cpu_number) return start+7; } +/* Type 11 -- OEM Strings */ +static void * +smbios_type_11_init(void *start) +{ +#ifdef BX_QEMU + struct smbios_type_11 *p = (struct smbios_type_11*)start; + int len; + + p->header.type = 11; + p->header.length = sizeof(struct smbios_type_11); + p->header.handle = 0x500; + p->count = 1; + start += sizeof (struct smbios_type_11); + memcpy(start, "Trusted NIC ", 12); + start += 12; + qemu_cfg_select(QEMU_CFG_TRUSTED_NIC); + len = qemu_cfg_read_string(start, 100); + if (len == 0) + return p; + start += (len + 1); + *((uint8_t *)start) = 0; + + return start + 1; +#else + return start; +#endif +} + /* Type 16 -- Physical Memory Array */ static void * smbios_type_16_init(void *start, uint32_t memsize) @@ -2106,6 +2155,7 @@ void smbios_init(void) add_struct(smbios_type_3_init(p)); for (cpu_num = 1; cpu_num <= smp_cpus; cpu_num++) add_struct(smbios_type_4_init(p, cpu_num)); + add_struct(smbios_type_11_init(p)); add_struct(smbios_type_16_init(p, memsize)); add_struct(smbios_type_17_init(p, memsize)); add_struct(smbios_type_19_init(p, memsize)); -- Gleb.