i386 Vmi processor header
In-Reply-To: <[email protected]>
Quoted 50 lines · Zachary Amsden
Index:
linux-2.6.16-rc5/include/asm-i386/mach-vmi/mach_processor.h
===================================================================include/asm-i386/mach-vmi/mach_processor.h 2006-03-10 13:03:35.000000000 -0800 renamed from include/asm-i386/mach-vmi/mach_processor.h 2006-03-10 13:03:35.000000000 -0800 +45
-0@@ -0,0 +1,137 @@ +/* + * Copyright (C) 2005, VMware, Inc. + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Send feedback to [email protected] + * + */ + + +#ifndef _MACH_PROCESSOR_H +#define _MACH_PROCESSOR_H + +#include <vmi.h> + +static inline void vmi_cpuid(const int op, int *eax, int *ebx, int *ecx, int *edx) +{ + vmi_wrap_call( + CPUID, "cpuid", + XCONC("=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)), + 1, "a" (op), + VMI_CLOBBER(FOUR_RETURNS)); +} + +/* + * Generic CPUID function + */ +static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx) +{ + vmi_cpuid(op, eax, ebx, ecx, edx);
include/asm-i386/mach-vmi/mach_processor.h 2006-03-10 13:03:35.000000000 -0800 line 55
Quoted 10 lines
include/asm-i386/mach-vmi/mach_processor.h 2006-03-10 13:03:35.000000000 -0800 renamed from include/asm-i386/mach-vmi/mach_processor.h 2006-03-10 13:03:35.000000000 -0800 +10
-0+} + + +/* Some CPUID calls want 'count' to be placed in ecx */ +static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, + int *edx) +{ + asm volatile(""::"c"(count)); + vmi_cpuid(op, eax, ebx, ecx, edx); +}
You can't assume those last two statements will stay together.
Quoted 5 lines
From the gcc 4.0.2 info file:
<...> you can't expect a sequence of volatile
asm' instructions to remain perfectly consecutive. If you want consecutive output, use a singleasm'.
Maybe you could make vmi_cpuid always take a 'count' param, then just make cpuid do:
vmi_cpuid(op, 0, eax, ebx, ecx, edx);
and cpuid_count do:
vmi_cpuid(op, count, eax, ebx, ecx, edx);
(And sorry about trimming the cc: but I'm reading from a digest and that list is too long to enter manually.)
Signature · 2 lines
Chuck "Penguins don't come from next door, they come from the Antarctic!"
Quoted 13 lines · Chuck Ebbert
Review
Quoted 9 lines
(quoted diff) +7
-0+/* Some CPUID calls want 'count' to be placed in ecx */ +static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, + int *edx) +{ + asm volatile(""::"c"(count)); + vmi_cpuid(op, eax, ebx, ecx, edx); +}You can't assume those last two statements will stay together.
Quoted 1 line
From the gcc 4.0.2 info file:
I know. I've abused this a bit. When we originally wrote the cpuid call, there were no ecx dependencies on cpuid. Never got around to fixing it properly.
Quoted 6 lines
Quoted 5 lines
<...> you can't expect a sequence of volatile
asm' instructions to remain perfectly consecutive. If you want consecutive output, use a singleasm'.
Quoted 9 lines
Maybe you could make
vmi_cpuidalways take a 'count' param, then just make cpuid do:vmi_cpuid(op, 0, eax, ebx, ecx, edx);and
cpuid_countdo:vmi_cpuid(op, count, eax, ebx, ecx, edx);
That is the proper fix. I'll put that in the next round.
Quoted 4 lines
(And sorry about trimming the cc: but I'm reading from a digest and that list is too long to enter manually.)
N.P.
Thanks for looking at my code,
Zach