From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7Uli-0003rU-Hq for qemu-devel@nongnu.org; Fri, 31 Aug 2012 13:12:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7Ulh-000616-EZ for qemu-devel@nongnu.org; Fri, 31 Aug 2012 13:12:30 -0400 Received: from thoth.sbs.de ([192.35.17.2]:27339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7Ulh-00060A-4E for qemu-devel@nongnu.org; Fri, 31 Aug 2012 13:12:29 -0400 Message-ID: <5040ED92.4010601@siemens.com> Date: Fri, 31 Aug 2012 19:00:02 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1346427000-9496-1-git-send-email-Don@CloudSwitch.com> <5040E4D9.3020202@siemens.com> <5040ED07.3050306@CloudSwitch.Com> In-Reply-To: <5040ED07.3050306@CloudSwitch.Com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw: Add VMware's GETHZ command. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Don Slutz Cc: "qemu-devel@nongnu.org" On 2012-08-31 18:57, Don Slutz wrote: > On 08/31/12 12:22, Jan Kiszka wrote: >> On 2012-08-31 17:30, Don Slutz wrote: >>> 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" >> Won't be needed, see below. >> >>> >>> //#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(); >> 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. >> >>> + /* 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. >> >>> + } 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. Hmm, sorry. Someone has to fix our checker... Jan > Will fix. >> >>> +} >>> + >>> /* 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; >>> } >>> >>> >> Looks good otherwise. >> >> Jan >> > -- Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux