From: Don Slutz <Don@CloudSwitch.com>
To: qemu-devel@nongnu.orgqemu-devel@nongnu.org
Cc: Don Slutz <Don@CloudSwitch.com>
Subject: [Qemu-devel] [PATCH] hw: Add VMware's GETHZ command.
Date: Fri, 31 Aug 2012 11:30:00 -0400 [thread overview]
Message-ID: <1346427000-9496-1-git-send-email-Don@CloudSwitch.com> (raw)
This is known is linux as VMWARE_PORT_CMD_GETHZ.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
hw/vmport.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/hw/vmport.c b/hw/vmport.c
index a4f52ee..37dbf91 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -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;
}
--
1.7.1
next reply other threads:[~2012-08-31 15:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-31 15:30 Don Slutz [this message]
2012-08-31 16:22 ` [Qemu-devel] [PATCH] hw: Add VMware's GETHZ command Jan Kiszka
2012-08-31 16:57 ` Don Slutz
2012-08-31 17:00 ` Jan Kiszka
2012-08-31 17:20 ` [Qemu-devel] [PATCH v2] " Don Slutz
2012-08-31 17:27 ` Jan Kiszka
2012-09-05 20:24 ` Don Slutz
2012-09-17 14:31 ` [Qemu-devel] PING " Don Slutz
2012-09-17 19:33 ` Anthony Liguori
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=1346427000-9496-1-git-send-email-Don@CloudSwitch.com \
--to=don@cloudswitch.com \
--cc=qemu-devel@nongnu.orgqemu-devel \
/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 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).