qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface.


From: Gleb Natapov
Subject: [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface.
Date: Thu, 05 Jun 2008 11:35:56 +0300
User-agent: StGIT/0.14.2

Answer BOCHS BIOS query about UUID.

Signed-off-by: Gleb Natapov <address@hidden>
---

 hw/vmport.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/hw/vmport.c b/hw/vmport.c
index ebfa921..5d32288 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -26,8 +26,16 @@
 #include "pc.h"
 #include "sysemu.h"
 
+#ifdef CONFIG_UUID
+#include <uuid/uuid.h>
+extern uuid_t qemu_uuid;
+#else
+static uint8_t qemu_uuid[16];
+#endif
+
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETBIOSUUID 0x13
 
 #define VMPORT_ENTRIES 0x2c
 #define VMPORT_MAGIC   0x564D5868
@@ -93,6 +101,26 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t 
addr)
     return ram_size;
 }
 
+static inline uint32_t uuid2reg(const unsigned char *uuid, uint32_t idx)
+{
+    int i;
+    uint32_t reg = 0;
+
+    for (i = 0; i < 4; i++)
+        reg |= (uuid[(idx*4) + i] << (i*8));
+
+    return reg;
+}
+
+static uint32_t vmport_cmd_bios_uuid(void *opaque, uint32_t addr)
+{
+    CPUState *env = cpu_single_env;
+    env->regs[R_EBX] = uuid2reg(qemu_uuid, 1);
+    env->regs[R_ECX] = uuid2reg(qemu_uuid, 2);
+    env->regs[R_EDX] = uuid2reg(qemu_uuid, 3);
+    return uuid2reg(qemu_uuid, 0);
+}
+
 void vmport_init(void)
 {
     register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &port_state);
@@ -101,4 +129,5 @@ void vmport_init(void)
     /* Register some generic port commands */
     vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);
     vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL);
+    vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_bios_uuid, NULL);
 }





reply via email to

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