All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Pass trusted NIC to OS through SMBIOS
Date: Sun, 18 Jan 2009 18:05:37 +0200	[thread overview]
Message-ID: <20090118160537.GI11299@redhat.com> (raw)

Signed-off-by: Gleb Natapov <gleb@redhat.com>
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	other threads:[~2009-01-18 16:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090118160537.GI11299@redhat.com \
    --to=gleb@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.