Add new QEMU code to access UUID.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 25 Oct 2008 19:43:46 +0000 (15:43 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 25 Oct 2008 19:43:46 +0000 (15:43 -0400)
This is based on a patch committed to bochs bios.

src/ioport.h
src/smbios.c

index 0db987ce8f843f35dfaba017aa5e195a818eb6ea..196fe531a9a26650d2bd580e1e01ac76cdae320c 100644 (file)
@@ -42,6 +42,8 @@
 #define PORT_PCI_CMD           0x0cf8
 #define PORT_PCI_DATA          0x0cfc
 #define PORT_BIOS_DEBUG        0x0402
+#define PORT_QEMU_CFG_CTL      0x0510
+#define PORT_QEMU_CFG_DATA     0x0511
 #define PORT_BIOS_APM          0x8900
 
 // PORT_KBD_CTRLB bitdefs
index 53e6e195cf30d5de304834853baf779aeeb68fb8..22d94114b8537f17331f2be894828199f129c4e4 100644 (file)
  * UUID probe
  ****************************************************************/
 
+#define QEMU_CFG_SIGNATURE  0x00
+#define QEMU_CFG_ID         0x01
+#define QEMU_CFG_UUID       0x02
+
+static void
+qemu_cfg_read(u8 *buf, u16 f, int len)
+{
+    outw(f, PORT_QEMU_CFG_CTL);
+    while (len--)
+        *(buf++) = inb(PORT_QEMU_CFG_DATA);
+}
+
+static int
+qemu_cfg_port_probe()
+{
+    u8 sig[4] = "QEMU";
+    u8 buf[4];
+    qemu_cfg_read(buf, QEMU_CFG_SIGNATURE, 4);
+    return *(u32*)buf == *(u32*)sig;
+}
+
 static void
 uuid_probe(u8 *bios_uuid)
 {
@@ -24,24 +45,11 @@ uuid_probe(u8 *bios_uuid)
         return;
     if (CONFIG_COREBOOT)
         return;
-
-    // check if backdoor port exists
-    u32 eax, ebx, ecx, edx;
-    asm volatile ("outl %%eax, %%dx"
-                  : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
-                  : "a" (0x564d5868), "b" (0), "c" (0xa), "d" (0x5658));
-    if (ebx != 0x564d5868)
+    if (! qemu_cfg_port_probe())
+        // Feature not available
         return;
 
-    u32 *uuid_ptr = (u32 *)bios_uuid;
-    // get uuid
-    asm volatile ("outl %%eax, %%dx"
-                  : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
-                  : "a" (0x564d5868), "c" (0x13), "d" (0x5658));
-    uuid_ptr[0] = eax;
-    uuid_ptr[1] = ebx;
-    uuid_ptr[2] = ecx;
-    uuid_ptr[3] = edx;
+    qemu_cfg_read(bios_uuid, QEMU_CFG_UUID, 16);
 }