From e97c8971a58e1036b60e3dd9d70af3f346e7f279 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Sep 2012 11:30:54 -0700 Subject: [PATCH] cpu.x86: Some calls to CPUID take a parameter in ECX. Add cpuid-extended to allow these. --- basis/cpu/x86/32/32.factor | 7 ++++--- basis/cpu/x86/64/64.factor | 7 ++++--- basis/cpu/x86/features/features.factor | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 4c9680f0ba..cd532d34e2 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -230,13 +230,14 @@ M: x86.32 flatten-struct-type M: x86.32 struct-return-on-stack? os linux? not ; -M: x86.32 (cpuid) ( n regs -- ) - void { uint void* } cdecl [ +M: x86.32 (cpuid) ( eax ecx regs -- ) + void { uint uint void* } cdecl [ ! Save ds-reg, rs-reg EDI PUSH EAX ESP 4 [+] MOV + ECX ESP 8 [+] MOV CPUID - EDI ESP 8 [+] MOV + EDI ESP 12 [+] MOV EDI [] EAX MOV EDI 4 [+] EBX MOV EDI 8 [+] ECX MOV diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 8270dc758c..dc83164b06 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -131,10 +131,11 @@ M: x86.64 float-on-stack? f ; M: x86.64 struct-return-on-stack? f ; -M: x86.64 (cpuid) ( n regs -- ) - void { uint void* } cdecl [ +M: x86.64 (cpuid) ( rax rcx regs -- ) + void { uint uint void* } cdecl [ RAX param-reg-0 MOV - RSI param-reg-1 MOV + RCX param-reg-1 MOV + RSI param-reg-2 MOV CPUID RSI [] EAX MOV RSI 4 [+] EBX MOV diff --git a/basis/cpu/x86/features/features.factor b/basis/cpu/x86/features/features.factor index 0206d0431a..84fe129a3f 100644 --- a/basis/cpu/x86/features/features.factor +++ b/basis/cpu/x86/features/features.factor @@ -85,11 +85,14 @@ MEMO: sse-version ( -- n ) : sse4.1? ( -- ? ) sse-version 41 >= ; : sse4.2? ( -- ? ) sse-version 42 >= ; -HOOK: (cpuid) cpu ( n regs -- ) +HOOK: (cpuid) cpu ( rax rcx regs -- ) -: cpuid ( n -- 4array ) + +: cpuid-extended ( rax rcx -- 4array ) 4 [ (cpuid) ] keep >array ; +: cpuid ( rax -- 4array ) 0 cpuid-extended ; + : cpu-stepping ( -- n ) 1 cpuid first 4 bits ; : cpu-model ( -- n ) 1 cpuid first -4 shift 4 bits ; : cpu-family ( -- n ) 1 cpuid first -8 shift 4 bits ;