Patchwork [v2] hw: Add VMware's GETHZ command.

login
register
mail settings
Submitter Don Slutz
Date Aug. 31, 2012, 5:20 p.m.
Message ID <1346433623-12549-1-git-send-email-Don@CloudSwitch.com>
Download mbox | patch
Permalink /patch/180998/
State New
Headers show

Comments

Don Slutz - Aug. 31, 2012, 5:20 p.m.
This is known is linux as VMWARE_PORT_CMD_GETHZ.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
 hw/vmport.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
Jan Kiszka - Aug. 31, 2012, 5:27 p.m.
On 2012-08-31 19:20, Don Slutz wrote:
> This is known is linux as VMWARE_PORT_CMD_GETHZ.
> 
> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
> ---
>  hw/vmport.c |   23 ++++++++++++++++++++++-
>  1 files changed, 22 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/vmport.c b/hw/vmport.c
> index a4f52ee..e856255 100644
> --- a/hw/vmport.c
> +++ b/hw/vmport.c
> @@ -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;
>  }
>  
> 

Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Don Slutz - Sept. 5, 2012, 8:24 p.m.
On 08/31/12 13:27, Jan Kiszka wrote:
> On 2012-08-31 19:20, Don Slutz wrote:
>> This is known is linux as VMWARE_PORT_CMD_GETHZ.
>>
>> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
>> ---
>>   hw/vmport.c |   23 ++++++++++++++++++++++-
>>   1 files changed, 22 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/vmport.c b/hw/vmport.c
>> index a4f52ee..e856255 100644
>> --- a/hw/vmport.c
>> +++ b/hw/vmport.c
>> @@ -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;
>>   }
>>   
>>
> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
>
Any thing else I need to do to get this into 1.3?
    -Don Slutz
Don Slutz - Sept. 17, 2012, 2:31 p.m.
On 09/05/12 16:24, Don Slutz wrote:
> On 08/31/12 13:27, Jan Kiszka wrote:
>> On 2012-08-31 19:20, Don Slutz wrote:
>>> This is known is linux as VMWARE_PORT_CMD_GETHZ.
>>>
>>> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
>>> ---
>>>   hw/vmport.c |   23 ++++++++++++++++++++++-
>>>   1 files changed, 22 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/hw/vmport.c b/hw/vmport.c
>>> index a4f52ee..e856255 100644
>>> --- a/hw/vmport.c
>>> +++ b/hw/vmport.c
>>> @@ -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;
>>>   }
>>>
>> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
>>
> Any thing else I need to do to get this into 1.3?
>    -Don Slutz
>
Ping.
   -Don Slutz
Anthony Liguori - Sept. 17, 2012, 7:33 p.m.
Don Slutz <Don@CloudSwitch.Com> writes:

> On 09/05/12 16:24, Don Slutz wrote:
>> On 08/31/12 13:27, Jan Kiszka wrote:
>>> On 2012-08-31 19:20, Don Slutz wrote:
>>>> This is known is linux as VMWARE_PORT_CMD_GETHZ.
>>>>
>>>> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
>>>> ---
>>>>   hw/vmport.c |   23 ++++++++++++++++++++++-
>>>>   1 files changed, 22 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/hw/vmport.c b/hw/vmport.c
>>>> index a4f52ee..e856255 100644
>>>> --- a/hw/vmport.c
>>>> +++ b/hw/vmport.c
>>>> @@ -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;
>>>>   }
>>>>
>>> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>
>> 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

>    -Don Slutz

Patch

diff --git a/hw/vmport.c b/hw/vmport.c
index a4f52ee..e856255 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -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;
 }