Skip to contentSkip to conversation

hw: Add VMware's GETHZ command.

PATCH Superseded Don Slutz 3 participants 9 messages Aug 31, 2012 – Sep 17, 2012

lore
Share & tools
lore

Don Slutz

author
#0 lore raw

PATCH 1/1 hw: Add VMware's GETHZ command.

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
 hw/vmport.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
hw/vmport.c +21 -1
index a4f52ee..37dbf91 100644
@@ -26,13 +26,15 @@
 #include "pc.h"
 #include "kvm.h"
 #include "qdev.h"
+#include "qemu-timer.h"
 
 //#define VMPORT_DEBUG
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
 #define VMPORT_MAGIC   0x564D5868
 
 typedef struct _VMPortState
@@ -102,6 +104,23 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
     return ram_size;
 }
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = (uint32_t)get_ticks_per_sec();
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;
+    } else
+        return env->regs[R_EAX];
+}
+
 /* vmmouse helpers */
 void vmmouse_get_data(uint32_t *data)
 {
@@ -141,6 +160,7 @@ static int vmport_initfn(ISADevice *dev)
     /* 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_GETHZ, vmport_cmd_get_hz, NULL);
     return 0;
 }
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 12 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
 hw/vmport.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
hw/vmport.c +0 -0
index a4f52ee..37dbf91 100644

hw/vmport.c line 29

Quoted 4 lines
hw/vmport.c +1 -0
@@ -26,13 +26,15 @@
 #include "pc.h"
 #include "kvm.h"
 #include "qdev.h"
+#include "qemu-timer.h"

Won't be needed, see below.

Quoted 15 lines
hw/vmport.c +2 -1
 //#define VMPORT_DEBUG
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
 #define VMPORT_MAGIC   0x564D5868
 
 typedef struct _VMPortState
@@ -102,6 +104,23 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
     return ram_size;
 }

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 115

Quoted 10 lines
hw/vmport.c +9 -0
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = (uint32_t)get_ticks_per_sec();

So this is 1MHz. That happens to be what we return in get_ticks_per_sec(), but I don't see the logical relation between both. Better set a constant, none of our APIC emulations will change it.

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 119

Quoted 4 lines
hw/vmport.c +4 -0
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;

EDX is unused by GETHZ? Just wondering if there is spec.

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 121

Quoted 2 lines
hw/vmport.c +2 -0
+    } else
+        return env->regs[R_EAX];

Use checkpatch.pl, please.

Quoted 7 lines
hw/vmport.c +2 -0
+}
+
 /* vmmouse helpers */
 void vmmouse_get_data(uint32_t *data)
 {

hw/vmport.c static int vmport_initfn(ISADevice *dev) · line 166

Quoted 7 lines
hw/vmport.c +1 -0
@@ -141,6 +160,7 @@ static int vmport_initfn(ISADevice *dev)
     /* 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_GETHZ, vmport_cmd_get_hz, NULL);
     return 0;
 }
 

Looks good otherwise.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
author
#2 lore raw
Quoted 48 lines · Jan Kiszka
Quoted 12 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
  hw/vmport.c |   22 +++++++++++++++++++++-
  1 files changed, 21 insertions(+), 1 deletions(-)
hw/vmport.c +0 -0
index a4f52ee..37dbf91 100644

hw/vmport.c line 29

Quoted 4 lines
hw/vmport.c +1 -0
@@ -26,13 +26,15 @@
  #include "pc.h"
  #include "kvm.h"
  #include "qdev.h"
+#include "qemu-timer.h"

Won't be needed, see below.

Quoted 15 lines
hw/vmport.c +2 -1
  //#define VMPORT_DEBUG
 
  #define VMPORT_CMD_GETVERSION 0x0a
  #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
  #define VMPORT_MAGIC   0x564D5868
 
  typedef struct _VMPortState
@@ -102,6 +104,23 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
      return ram_size;
  }

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 115

Quoted 10 lines
hw/vmport.c +9 -0
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = (uint32_t)get_ticks_per_sec();

So this is 1MHz. That happens to be what we return in get_ticks_per_sec(), but I don't see the logical relation between both. Better set a constant, none of our APIC emulations will change it.

Quoted 5 lines

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 119

Quoted 4 lines
hw/vmport.c +4 -0
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;

EDX is unused by GETHZ? Just wondering if there is spec.

I have not been able to find a SPEC. Testing on real VMware systems showed that EDX is not changed. And the linux kernel ignored EDX output.

Quoted 4 lines

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 121

Quoted 3 lines
hw/vmport.c +2 -0
+    } else
+        return env->regs[R_EAX];

Use checkpatch.pl, please.

I did:

    don-760:~/tmp/qemu>./scripts/checkpatch.pl 

outgoing/0001-hw-Add-VMware-s-GETHZ-command.patch
total: 0 errors, 0 warnings, 46 lines checked

outgoing/0001-hw-Add-VMware-s-GETHZ-command.patch has no obvious
style problems and is ready for submission.
Will fix.

Quoted 19 lines
Quoted 8 lines
hw/vmport.c +2 -0
+}
+
  /* vmmouse helpers */
  void vmmouse_get_data(uint32_t *data)
  {

hw/vmport.c static int vmport_initfn(ISADevice *dev) · line 166

Quoted 7 lines
hw/vmport.c +1 -0
@@ -141,6 +160,7 @@ static int vmport_initfn(ISADevice *dev)
      /* 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_GETHZ, vmport_cmd_get_hz, NULL);
      return 0;
  }
 

Looks good otherwise.

Jan

#3 lore raw
Quoted 59 lines · Don Slutz
Quoted 48 lines · Jan Kiszka
Quoted 12 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
  hw/vmport.c |   22 +++++++++++++++++++++-
  1 files changed, 21 insertions(+), 1 deletions(-)
hw/vmport.c +0 -0
index a4f52ee..37dbf91 100644

hw/vmport.c line 29

Quoted 4 lines
hw/vmport.c +1 -0
@@ -26,13 +26,15 @@
  #include "pc.h"
  #include "kvm.h"
  #include "qdev.h"
+#include "qemu-timer.h"

Won't be needed, see below.

Quoted 15 lines
hw/vmport.c +2 -1
  //#define VMPORT_DEBUG
 
  #define VMPORT_CMD_GETVERSION 0x0a
  #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
  #define VMPORT_MAGIC   0x564D5868
 
  typedef struct _VMPortState
@@ -102,6 +104,23 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
      return ram_size;
  }

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 115

Quoted 10 lines
hw/vmport.c +9 -0
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = (uint32_t)get_ticks_per_sec();

So this is 1MHz. That happens to be what we return in get_ticks_per_sec(), but I don't see the logical relation between both. Better set a constant, none of our APIC emulations will change it.

Quoted 5 lines

hw/vmport.c static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) · line 119

Quoted 4 lines
hw/vmport.c +4 -0
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;

EDX is unused by GETHZ? Just wondering if there is spec.

I have not been able to find a SPEC. Testing on real VMware systems showed that EDX is not changed. And the linux kernel ignored EDX output.

Quoted 3 lines
Quoted 3 lines
hw/vmport.c +2 -0
+    } else
+        return env->regs[R_EAX];
Quoted 8 lines
Quoted 1 line

Use checkpatch.pl, please.

I did:

     don-760:~/tmp/qemu>./scripts/checkpatch.pl 

outgoing/0001-hw-Add-VMware-s-GETHZ-command.patch
total: 0 errors, 0 warnings, 46 lines checked

outgoing/0001-hw-Add-VMware-s-GETHZ-command.patch has no obvious
style problems and is ready for submission.

Hmm, sorry. Someone has to fix our checker...

Jan

Quoted 21 lines

Will fix.

Quoted 19 lines
Quoted 8 lines
hw/vmport.c +2 -0
+}
+
  /* vmmouse helpers */
  void vmmouse_get_data(uint32_t *data)
  {

hw/vmport.c static int vmport_initfn(ISADevice *dev) · line 166

Quoted 7 lines
hw/vmport.c +1 -0
@@ -141,6 +160,7 @@ static int vmport_initfn(ISADevice *dev)
      /* 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_GETHZ, vmport_cmd_get_hz, NULL);
      return 0;
  }
 

Looks good otherwise.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
author
#4 lore raw

PATCH v2 1/1 hw: Add VMware's GETHZ command.

In reply to Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
 hw/vmport.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
hw/vmport.c +22 -1
index a4f52ee..e856255 100644
@@ -31,8 +31,9 @@
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
 #define VMPORT_MAGIC   0x564D5868
 
 typedef struct _VMPortState
@@ -102,6 +103,25 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
     return ram_size;
 }
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+    const uint32_t apicHz = 1000000000L;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = apicHz;
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;
+    } else {
+        return env->regs[R_EAX];
+    }
+}
+
 /* vmmouse helpers */
 void vmmouse_get_data(uint32_t *data)
 {
@@ -141,6 +161,7 @@ static int vmport_initfn(ISADevice *dev)
     /* 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_GETHZ, vmport_cmd_get_hz, NULL);
     return 0;
 }
 
Signature · 1 line
1.7.1
Reviewed-by on v2 1/1
#5 lore raw
Quoted 50 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
 hw/vmport.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
hw/vmport.c +21 -1
index a4f52ee..e856255 100644
@@ -31,8 +31,9 @@
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
 #define VMPORT_MAGIC   0x564D5868
 
 typedef struct _VMPortState
@@ -102,6 +103,25 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
     return ram_size;
 }
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+    const uint32_t apicHz = 1000000000L;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = apicHz;
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;
+    } else {
+        return env->regs[R_EAX];
+    }
+}
+
 /* vmmouse helpers */
 void vmmouse_get_data(uint32_t *data)
 {

hw/vmport.c static int vmport_initfn(ISADevice *dev) · line 167

Quoted 7 lines
hw/vmport.c +1 -0
@@ -141,6 +161,7 @@ static int vmport_initfn(ISADevice *dev)
     /* 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_GETHZ, vmport_cmd_get_hz, NULL);
     return 0;
 }
 
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
author
#6 lore raw
Quoted 51 lines · Jan Kiszka
Quoted 50 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
  hw/vmport.c |   23 ++++++++++++++++++++++-
  1 files changed, 22 insertions(+), 1 deletions(-)
hw/vmport.c +21 -1
index a4f52ee..e856255 100644
@@ -31,8 +31,9 @@
 
  #define VMPORT_CMD_GETVERSION 0x0a
  #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
 
-#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
  #define VMPORT_MAGIC   0x564D5868
 
  typedef struct _VMPortState
@@ -102,6 +103,25 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
      return ram_size;
  }
 
+static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+    const uint32_t apicHz = 1000000000L;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = apicHz;
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;
+    } else {
+        return env->regs[R_EAX];
+    }
+}
+
  /* vmmouse helpers */
  void vmmouse_get_data(uint32_t *data)
  {
@@ -141,6 +161,7 @@ static int vmport_initfn(ISADevice *dev)
      /* Register some generic port commands */
Quoted 9 lines

hw/vmport.c static int vmport_initfn(ISADevice *dev) · line 167

Quoted 7 lines
hw/vmport.c +1 -0
      vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);
      vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL);
+    vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL);
      return 0;
  }
 

Any thing else I need to do to get this into 1.3?
-Don Slutz

author
#7 lore raw

[Qemu-devel] PING Re: [PATCH v2] hw: Add VMware's GETHZ command.

Quoted 59 lines · Don Slutz
Quoted 49 lines · Jan Kiszka
Quoted 48 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
  hw/vmport.c |   23 ++++++++++++++++++++++-
  1 files changed, 22 insertions(+), 1 deletions(-)
hw/vmport.c +20 -0
index a4f52ee..e856255 100644
@@ -31,8 +31,9 @@
    #define VMPORT_CMD_GETVERSION 0x0a
  #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
  -#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
  #define VMPORT_MAGIC   0x564D5868
    typedef struct _VMPortState
@@ -102,6 +103,25 @@ static uint32_t vmport_cmd_ram_size(void 
 *opaque, uint32_t addr)
      return ram_size;
  }
  +static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+    const uint32_t apicHz = 1000000000L;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = apicHz;
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;
+    } else {
+        return env->regs[R_EAX];
+    }
+}
+
  /* vmmouse helpers */
  void vmmouse_get_data(uint32_t *data)
  {
@@ -141,6 +161,7 @@ static int vmport_initfn(ISADevice *dev)
      /* Register some generic port commands */
      vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, 
Quoted 9 lines
Quoted 7 lines
hw/vmport.c +1 -0
 NULL);
      vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, 
 NULL);
+    vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL);
      return 0;
  }
Quoted 3 lines

Any thing else I need to do to get this into 1.3?
-Don Slutz

Ping.
-Don Slutz

#8 lore raw

Re: [Qemu-devel] PING Re: [PATCH v2] hw: Add VMware's GETHZ command.

Quoted 60 lines · Don Slutz
Quoted 59 lines · Don Slutz
Quoted 58 lines · Jan Kiszka
Quoted 53 lines · Don Slutz

This is known is linux as VMWARE_PORT_CMD_GETHZ.

---
  hw/vmport.c |   23 ++++++++++++++++++++++-
  1 files changed, 22 insertions(+), 1 deletions(-)
hw/vmport.c +21 -0
index a4f52ee..e856255 100644
@@ -31,8 +31,9 @@
    #define VMPORT_CMD_GETVERSION 0x0a
  #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETHZ      0x2d
  -#define VMPORT_ENTRIES 0x2c
+#define VMPORT_ENTRIES 0x2e
  #define VMPORT_MAGIC   0x564D5868
    typedef struct _VMPortState
@@ -102,6 +103,25 @@ static uint32_t vmport_cmd_ram_size(void 
 *opaque, uint32_t addr)
      return ram_size;
  }
  +static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
+{
+    CPUX86State *env = cpu_single_env;
+    uint64_t value;
+    const uint32_t apicHz = 1000000000L;
+
+    value = (uint64_t)env->tsc_khz * 1000;
+    if (value) {
+        /* apic-frequency (bus speed) */
+        env->regs[R_ECX] = apicHz;
+        /* High part of tsc-frequency */
+        env->regs[R_EBX] = (uint32_t)(value >> 32);
+        /* Low part of tsc-frequency */
+        return (uint32_t)value;
+    } else {
+        return env->regs[R_EAX];
+    }
+}
+
  /* vmmouse helpers */
  void vmmouse_get_data(uint32_t *data)
  {
@@ -141,6 +161,7 @@ static int vmport_initfn(ISADevice *dev)
      /* 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_GETHZ, vmport_cmd_get_hz, NULL);
      return 0;
Quoted 2 lines
  }
Quoted 4 lines
Quoted 3 lines

Any thing else I need to do to get this into 1.3?
-Don Slutz

Ping.

Please top post new patches in the future. Otherwise they are easily lost.

Regards,

Anthony Liguori

Quoted 1 line

-Don Slutz