From: Ben Gras Date: Thu, 14 May 2009 15:55:28 +0000 (+0000) Subject: C CPUID interface. X-Git-Tag: v3.1.4~31 X-Git-Url: http://zhaoyanbai.com/repos/man.ddns-confgen.html?a=commitdiff_plain;h=143422fa0a7735c72c8ddd25ec0197c8ea305df5;p=minix.git C CPUID interface. --- diff --git a/lib/i386/misc/Makefile.in b/lib/i386/misc/Makefile.in index 511524f08..3b139e97e 100644 --- a/lib/i386/misc/Makefile.in +++ b/lib/i386/misc/Makefile.in @@ -5,6 +5,7 @@ CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" LIBRARIES=libc libc_FILES=" \ + _cpuid.s \ alloca.s \ get_bp.s \ getprocessor.s \ diff --git a/lib/i386/misc/_cpuid.s b/lib/i386/misc/_cpuid.s new file mode 100755 index 000000000..6ca569a30 --- /dev/null +++ b/lib/i386/misc/_cpuid.s @@ -0,0 +1,44 @@ +! _cpuid() - interface to cpuid instruction + +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text + +! int _cpuid(u32_t eax, u32_t *eax, u32_t *ebx, u32_t *ecx, u32_t *edx); +! 0 for OK, nonzero for unsupported + +.define __cpuid + +__cpuid: + push ebp + + mov ebp, esp + + ! save work registers + push eax + push ebx + push ecx + push edx + + ! set eax parameter to cpuid and execute cpuid + mov eax, 24(esp) + .data1 0x0F, 0xA2 ! CPUID + + ! store results in pointer arguments + mov ebp, 28(esp) + mov (ebp), eax + mov ebp, 32(esp) + mov (ebp), ebx + mov ebp, 36(esp) + mov (ebp), ecx + mov ebp, 40(esp) + mov (ebp), edx + + ! restore registers + pop edx + pop ecx + pop ebx + pop eax + + pop ebp + + ret