verify_cpu.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. verify_cpu:
  6. pushfl # Save caller passed flags
  7. pushl $0 # Kill any dangerous flags
  8. popfl
  9. #if CONFIG_X86_MINIMUM_CPU_MODEL >= 4
  10. pushfl
  11. pop %eax
  12. orl $(1<<18),%eax # try setting AC
  13. push %eax
  14. popfl
  15. pushfl
  16. popl %eax
  17. testl $(1<<18),%eax
  18. jz bad
  19. #endif
  20. #if REQUIRED_MASK1 != 0
  21. pushfl # standard way to check for cpuid
  22. popl %eax
  23. movl %eax,%ebx
  24. xorl $0x200000,%eax
  25. pushl %eax
  26. popfl
  27. pushfl
  28. popl %eax
  29. cmpl %eax,%ebx
  30. pushfl # standard way to check for cpuid
  31. popl %eax
  32. movl %eax,%ebx
  33. xorl $0x200000,%eax
  34. pushl %eax
  35. popfl
  36. pushfl
  37. popl %eax
  38. cmpl %eax,%ebx
  39. jz bad # REQUIRED_MASK1 != 0 requires CPUID
  40. movl $0x0,%eax # See if cpuid 1 is implemented
  41. cpuid
  42. cmpl $0x1,%eax
  43. jb bad # no cpuid 1
  44. movl $0x1,%eax # Does the cpu have what it takes
  45. cpuid
  46. #if CONFIG_X86_MINIMUM_CPU_MODEL > 4
  47. #error add proper model checking here
  48. #endif
  49. andl $REQUIRED_MASK1,%edx
  50. xorl $REQUIRED_MASK1,%edx
  51. jnz bad
  52. #endif /* REQUIRED_MASK1 */
  53. popfl
  54. xor %eax,%eax
  55. ret
  56. bad:
  57. popfl
  58. movl $1,%eax
  59. ret