Andi Kleen | c7f81c9 | 2007-05-02 19:27:20 +0200 | [diff] [blame] | 1 | /* Check if CPU has some minimum CPUID bits |
| 2 | This runs in 16bit mode so that the caller can still use the BIOS |
| 3 | to output errors on the screen */ |
| 4 | #include <asm/cpufeature.h> |
| 5 | |
| 6 | verify_cpu: |
| 7 | pushfl # Save caller passed flags |
| 8 | pushl $0 # Kill any dangerous flags |
| 9 | popfl |
| 10 | |
| 11 | #if CONFIG_X86_MINIMUM_CPU_MODEL >= 4 |
| 12 | pushfl |
Andi Kleen | fd0581b | 2007-05-11 11:23:18 +0200 | [diff] [blame] | 13 | pop %eax |
| 14 | orl $(1<<18),%eax # try setting AC |
| 15 | push %eax |
Andi Kleen | c7f81c9 | 2007-05-02 19:27:20 +0200 | [diff] [blame] | 16 | popfl |
| 17 | pushfl |
| 18 | popl %eax |
| 19 | testl $(1<<18),%eax |
| 20 | jz bad |
| 21 | #endif |
| 22 | #if REQUIRED_MASK1 != 0 |
| 23 | pushfl # standard way to check for cpuid |
| 24 | popl %eax |
| 25 | movl %eax,%ebx |
| 26 | xorl $0x200000,%eax |
| 27 | pushl %eax |
| 28 | popfl |
| 29 | pushfl |
| 30 | popl %eax |
| 31 | cmpl %eax,%ebx |
| 32 | pushfl # standard way to check for cpuid |
| 33 | popl %eax |
| 34 | movl %eax,%ebx |
| 35 | xorl $0x200000,%eax |
| 36 | pushl %eax |
| 37 | popfl |
| 38 | pushfl |
| 39 | popl %eax |
| 40 | cmpl %eax,%ebx |
| 41 | jz bad # REQUIRED_MASK1 != 0 requires CPUID |
| 42 | |
| 43 | movl $0x0,%eax # See if cpuid 1 is implemented |
| 44 | cpuid |
| 45 | cmpl $0x1,%eax |
| 46 | jb bad # no cpuid 1 |
| 47 | |
| 48 | movl $0x1,%eax # Does the cpu have what it takes |
| 49 | cpuid |
| 50 | |
| 51 | #if CONFIG_X86_MINIMUM_CPU_MODEL > 4 |
| 52 | #error add proper model checking here |
| 53 | #endif |
| 54 | |
| 55 | andl $REQUIRED_MASK1,%edx |
| 56 | xorl $REQUIRED_MASK1,%edx |
| 57 | jnz bad |
| 58 | #endif /* REQUIRED_MASK1 */ |
| 59 | |
| 60 | popfl |
| 61 | xor %eax,%eax |
| 62 | ret |
| 63 | |
| 64 | bad: |
| 65 | popfl |
| 66 | movl $1,%eax |
| 67 | ret |