attempted fix for asm in oskit cpuid.c
spooq
spoooq at gmail.com
Mon Apr 10 19:36:23 CEST 2006
Hello list,
I tried to fix some errors in cpuid.c ... wouldnt rely on it, my asms
not very good and I havent tested it beyond seeing that it compiles.
Basically it just makes the asm respect gcc using the ebx as a pic
reg. Not sure about the \n\t stuff, it made it work tho.
--- virgin_code/oskit/libkern/x86/cpuid.c 2006-04-02
15:41:55.000000000 +0000
+++ cpuid.c 2006-04-10 17:14:57.000000000 +0000
@@ -39,12 +39,17 @@
unsigned i;
cicount++;
- asm volatile("cpuid"
+ asm volatile(
+ "movl %%ebx, %%edi\n\t"
+ "cpuid\n\t"
+ "movl %1, %%ebx\n\t"
+ "movl %%edi, %%ebx\n\t"
: "=a" (ci[0]),
- "=b" (ci[1]),
+ "=r" (ci[1]),
"=c" (ci[2]),
"=d" (ci[3])
- : "a" (2));
+ : "a" (2)
+ : "edi");
for (i = 0; i < 4; i++)
{
@@ -90,21 +95,29 @@
* CPUID is supported, so use it.
* First get the vendor ID string.
*/
- asm volatile("cpuid"
+ asm volatile(
+ "movl %%ebx, %%edi\n\t"
+ "cpuid\n\t"
+ "movl %1, %%ebx\n\t"
+ "movl %%edi, %%ebx\n\t"
: "=a" (highest_val),
- "=b" (*((int*)(out_id->vendor_id+0))),
+ "=r" (*((int*)(out_id->vendor_id+0))),
"=d" (*((int*)(out_id->vendor_id+4))),
"=c" (*((int*)(out_id->vendor_id+8)))
- : "a" (0));
+ : "a" (0)
+ : "edi");
/* Now the feature information. */
if (highest_val >= 1)
{
- asm volatile("cpuid"
- : "=a" (*((int*)out_id)),
- "=d" (out_id->feature_flags)
- : "a" (1)
- : "ebx", "ecx");
+ asm volatile(
+ "movl %%ebx, %%edi\n\t"
+ "cpuid\n\t"
+ "movl %%edi, %%ebx\n\t"
+ : "=a" (*((int*)out_id)),
+ "=d" (out_id->feature_flags)
+ : "a" (1)
+ : "ecx","edi");
}
/* Cache and TLB information. */
--
spooq
More information about the l4-hackers
mailing list