Patchwork [03/13] cpuid: moved host_cpuid function and remove prototype

login
register
mail settings
Submitter Andre Przywara
Date Feb. 2, 2010, 10:08 a.m.
Message ID <1265105301-3455-4-git-send-email-andre.przywara@amd.com>
Download mbox | patch
Permalink /patch/44273/
State New
Headers show

Comments

Andre Przywara - Feb. 2, 2010, 10:08 a.m.
the host_cpuid function was located at the end of the file and had
a prototype before it's first use. Move it up and remove the
prototype.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 target-i386/cpuid.c |   70 ++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 36 deletions(-)
Aurelien Jarno - March 6, 2010, 6:26 p.m.
On Tue, Feb 02, 2010 at 11:08:11AM +0100, Andre Przywara wrote:
> the host_cpuid function was located at the end of the file and had
> a prototype before it's first use. Move it up and remove the
> prototype.
> 
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>

Acked-by: Aurelien Jarno <aurelien@aurel32.net>

> ---
>  target-i386/cpuid.c |   70 ++++++++++++++++++++++++--------------------------
>  1 files changed, 34 insertions(+), 36 deletions(-)
> 
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 0a17020..cc080f4 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -338,8 +338,40 @@ static x86_def_t x86_defs[] = {
>      },
>  };
>  
> -static void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax,
> -                               uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
> +static void host_cpuid(uint32_t function, uint32_t count,
> +                       uint32_t *eax, uint32_t *ebx,
> +                       uint32_t *ecx, uint32_t *edx)
> +{
> +#if defined(CONFIG_KVM)
> +    uint32_t vec[4];
> +
> +#ifdef __x86_64__
> +    asm volatile("cpuid"
> +                 : "=a"(vec[0]), "=b"(vec[1]),
> +                   "=c"(vec[2]), "=d"(vec[3])
> +                 : "0"(function), "c"(count) : "cc");
> +#else
> +    asm volatile("pusha \n\t"
> +                 "cpuid \n\t"
> +                 "mov %%eax, 0(%2) \n\t"
> +                 "mov %%ebx, 4(%2) \n\t"
> +                 "mov %%ecx, 8(%2) \n\t"
> +                 "mov %%edx, 12(%2) \n\t"
> +                 "popa"
> +                 : : "a"(function), "c"(count), "S"(vec)
> +                 : "memory", "cc");
> +#endif
> +
> +    if (eax)
> +	*eax = vec[0];
> +    if (ebx)
> +	*ebx = vec[1];
> +    if (ecx)
> +	*ecx = vec[2];
> +    if (edx)
> +	*edx = vec[3];
> +#endif
> +}
>  
>  static int cpu_x86_fill_model_id(char *str)
>  {
> @@ -578,40 +610,6 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
>      return 0;
>  }
>  
> -static void host_cpuid(uint32_t function, uint32_t count,
> -                       uint32_t *eax, uint32_t *ebx,
> -                       uint32_t *ecx, uint32_t *edx)
> -{
> -#if defined(CONFIG_KVM)
> -    uint32_t vec[4];
> -
> -#ifdef __x86_64__
> -    asm volatile("cpuid"
> -                 : "=a"(vec[0]), "=b"(vec[1]),
> -                   "=c"(vec[2]), "=d"(vec[3])
> -                 : "0"(function), "c"(count) : "cc");
> -#else
> -    asm volatile("pusha \n\t"
> -                 "cpuid \n\t"
> -                 "mov %%eax, 0(%2) \n\t"
> -                 "mov %%ebx, 4(%2) \n\t"
> -                 "mov %%ecx, 8(%2) \n\t"
> -                 "mov %%edx, 12(%2) \n\t"
> -                 "popa"
> -                 : : "a"(function), "c"(count), "S"(vec)
> -                 : "memory", "cc");
> -#endif
> -
> -    if (eax)
> -	*eax = vec[0];
> -    if (ebx)
> -	*ebx = vec[1];
> -    if (ecx)
> -	*ecx = vec[2];
> -    if (edx)
> -	*edx = vec[3];
> -#endif
> -}
>  
>  static void get_cpuid_vendor(CPUX86State *env, uint32_t *ebx,
>                               uint32_t *ecx, uint32_t *edx)
> -- 
> 1.6.4
> 
> 
> 
> 
>

Patch

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 0a17020..cc080f4 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -338,8 +338,40 @@  static x86_def_t x86_defs[] = {
     },
 };
 
-static void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax,
-                               uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
+static void host_cpuid(uint32_t function, uint32_t count,
+                       uint32_t *eax, uint32_t *ebx,
+                       uint32_t *ecx, uint32_t *edx)
+{
+#if defined(CONFIG_KVM)
+    uint32_t vec[4];
+
+#ifdef __x86_64__
+    asm volatile("cpuid"
+                 : "=a"(vec[0]), "=b"(vec[1]),
+                   "=c"(vec[2]), "=d"(vec[3])
+                 : "0"(function), "c"(count) : "cc");
+#else
+    asm volatile("pusha \n\t"
+                 "cpuid \n\t"
+                 "mov %%eax, 0(%2) \n\t"
+                 "mov %%ebx, 4(%2) \n\t"
+                 "mov %%ecx, 8(%2) \n\t"
+                 "mov %%edx, 12(%2) \n\t"
+                 "popa"
+                 : : "a"(function), "c"(count), "S"(vec)
+                 : "memory", "cc");
+#endif
+
+    if (eax)
+	*eax = vec[0];
+    if (ebx)
+	*ebx = vec[1];
+    if (ecx)
+	*ecx = vec[2];
+    if (edx)
+	*edx = vec[3];
+#endif
+}
 
 static int cpu_x86_fill_model_id(char *str)
 {
@@ -578,40 +610,6 @@  int cpu_x86_register (CPUX86State *env, const char *cpu_model)
     return 0;
 }
 
-static void host_cpuid(uint32_t function, uint32_t count,
-                       uint32_t *eax, uint32_t *ebx,
-                       uint32_t *ecx, uint32_t *edx)
-{
-#if defined(CONFIG_KVM)
-    uint32_t vec[4];
-
-#ifdef __x86_64__
-    asm volatile("cpuid"
-                 : "=a"(vec[0]), "=b"(vec[1]),
-                   "=c"(vec[2]), "=d"(vec[3])
-                 : "0"(function), "c"(count) : "cc");
-#else
-    asm volatile("pusha \n\t"
-                 "cpuid \n\t"
-                 "mov %%eax, 0(%2) \n\t"
-                 "mov %%ebx, 4(%2) \n\t"
-                 "mov %%ecx, 8(%2) \n\t"
-                 "mov %%edx, 12(%2) \n\t"
-                 "popa"
-                 : : "a"(function), "c"(count), "S"(vec)
-                 : "memory", "cc");
-#endif
-
-    if (eax)
-	*eax = vec[0];
-    if (ebx)
-	*ebx = vec[1];
-    if (ecx)
-	*ecx = vec[2];
-    if (edx)
-	*edx = vec[3];
-#endif
-}
 
 static void get_cpuid_vendor(CPUX86State *env, uint32_t *ebx,
                              uint32_t *ecx, uint32_t *edx)