From patchwork Fri Aug 31 15:30:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 180994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 536652C036D for ; Sat, 1 Sep 2012 01:31:32 +1000 (EST) Received: from localhost ([::1]:60419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7TBx-00044g-SE for incoming@patchwork.ozlabs.org; Fri, 31 Aug 2012 11:31:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7TBn-00044X-Qa for qemu-devel@nongnu.org; Fri, 31 Aug 2012 11:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7TBe-0007jM-Dl for qemu-devel@nongnu.org; Fri, 31 Aug 2012 11:31:19 -0400 Received: from hub021-nj-4.exch021.serverdata.net ([206.225.164.219]:56942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7TBe-0007hz-9Z for qemu-devel@nongnu.org; Fri, 31 Aug 2012 11:31:10 -0400 Received: from localhost.localdomain (131.239.15.22) by east.exch021.serverdata.net (10.240.4.40) with Microsoft SMTP Server (TLS) id 14.2.309.2; Fri, 31 Aug 2012 08:30:07 -0700 From: Don Slutz To: , Date: Fri, 31 Aug 2012 11:30:00 -0400 Message-ID: <1346427000-9496-1-git-send-email-Don@CloudSwitch.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) X-Received-From: 206.225.164.219 Cc: Don Slutz Subject: [Qemu-devel] [PATCH] hw: Add VMware's GETHZ command. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is known is linux as VMWARE_PORT_CMD_GETHZ. Signed-off-by: Don Slutz --- 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; }