Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Npibs-0005YG-Iq for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:39:32 -0500 Received: from [199.232.76.173] (port=45888 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Npibq-0005XI-Bc for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:39:30 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Npibo-0001RZ-6z for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:39:29 -0500 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:9078 helo=TX2EHSOBE006.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1Npibn-0001Qt-LD for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:39:27 -0500 From: Andre Przywara Date: Thu, 11 Mar 2010 14:38:58 +0100 Message-ID: <1268314747-11111-5-git-send-email-andre.przywara@amd.com> In-Reply-To: <1268314747-11111-1-git-send-email-andre.przywara@amd.com> References: <1268314747-11111-1-git-send-email-andre.przywara@amd.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 04/13] x86/cpuid: moved host_cpuid function and remove prototype List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: Andre Przywara , qemu-devel@nongnu.org, aurelien@aurel32.net 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 --- target-i386/cpuid.c | 71 ++++++++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 37 deletions(-) diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index 1bceb4b..fa36942 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -92,8 +92,40 @@ typedef struct model_features_t { int check_cpuid = 0; int enforce_cpuid = 0; -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 +} #define iswhite(c) ((c) && ((c) <= ' ' || '~' < (c))) @@ -896,41 +928,6 @@ void x86_cpudef_setup(void) #endif } -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