kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] read UUID from qemu
@ 2008-10-12 13:46 Gleb Natapov
  2008-10-16  9:51 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2008-10-12 13:46 UTC (permalink / raw)
  To: avi; +Cc: kvm

Similar patch was sent to bochs devel list, but I propose to apply this
patch now rather than waiting for bochs developers to apply it and then
merger.

---

Add support for new FW configuration channel to the BIOS.
Read UUID from QEMU using this channel.

Signed-off-by: Gleb Natapov <gleb@redhat.com>

diff --git a/bios/rombios32.c b/bios/rombios32.c
index 921e202..a91b155 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -444,31 +444,51 @@ void wrmsr_smp(uint32_t index, uint64_t val)
     p->ecx = 0;
 }
 
-void uuid_probe(void)
-{
 #ifdef BX_QEMU
-    uint32_t eax, ebx, ecx, edx;
+#define QEMU_CFG_CTL_PORT 0x510
+#define QEMU_CFG_DATA_PORT 0x511
+#define QEMU_CFG_SIGNATURE  0x00
+#define QEMU_CFG_ID         0x01
+#define QEMU_CFG_UUID       0x02
+
+int qemu_cfg_port;
+
+void qemu_cfg_select(int f)
+{
+    outw(QEMU_CFG_CTL_PORT, f);
+}
 
-    // check if backdoor port exists
-    asm volatile ("outl %%eax, %%dx"
-        : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
-        : "a" (0x564d5868), "b" (0), "c" (0xa), "d" (0x5658));
-    if (ebx == 0x564d5868) {
-        uint32_t *uuid_ptr = (uint32_t *)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;
-    } else
+int qemu_cfg_port_probe()
+{
+    char *sig = "QEMU";
+    int i;
+
+    qemu_cfg_select(QEMU_CFG_SIGNATURE);
+
+    for (i = 0; i < 4; i++)
+        if (inb(QEMU_CFG_DATA_PORT) != sig[i])
+            return 0;
+
+    return 1;
+}
+
+void qemu_cfg_read(uint8_t *buf, int len)
+{
+    while (len--)
+        *(buf++) = inb(QEMU_CFG_DATA_PORT);
+}
 #endif
-    {
-        // UUID not set
-        memset(bios_uuid, 0, 16);
+
+void uuid_probe(void)
+{
+#ifdef BX_QEMU
+    if(qemu_cfg_port) {
+        qemu_cfg_select(QEMU_CFG_UUID);
+        qemu_cfg_read(bios_uuid, 16);
+        return;
     }
+#endif
+    memset(bios_uuid, 0, 16);
 }
 
 void cpu_probe(void)
@@ -2085,6 +2105,10 @@ void rombios32_init(void)
 
     init_smp_msrs();
 
+#ifdef BX_QEMU
+    qemu_cfg_port = qemu_cfg_port_probe();
+#endif
+
     ram_probe();
 
     cpu_probe();
--
			Gleb.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] read UUID from qemu
  2008-10-12 13:46 [PATCH] read UUID from qemu Gleb Natapov
@ 2008-10-16  9:51 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-10-16  9:51 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm

Gleb Natapov wrote:
> Similar patch was sent to bochs devel list, but I propose to apply this
> patch now rather than waiting for bochs developers to apply it and then
> merger.
>
> ---
>
> Add support for new FW configuration channel to the BIOS.
> Read UUID from QEMU using this channel.
>
>   

Applied, thanks.   btw, '---' works the other way around (confusingly).

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-16  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-12 13:46 [PATCH] read UUID from qemu Gleb Natapov
2008-10-16  9:51 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).