qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Pass trusted NIC to OS through SMBIOS


From: Gleb Natapov
Subject: [Qemu-devel] [PATCH] Pass trusted NIC to OS through SMBIOS
Date: Sun, 18 Jan 2009 18:05:37 +0200

Signed-off-by: Gleb Natapov <address@hidden>
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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]