verify_cpu.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #include <asm/msr.h>
  6. verify_cpu:
  7. pushfl # Save caller passed flags
  8. pushl $0 # Kill any dangerous flags
  9. popfl
  10. #if CONFIG_X86_MINIMUM_CPU_MODEL >= 4
  11. pushfl
  12. pop %eax
  13. orl $(1<<18),%eax # try setting AC
  14. push %eax
  15. popfl
  16. pushfl
  17. popl %eax
  18. testl $(1<<18),%eax
  19. jz bad
  20. #endif
  21. #if REQUIRED_MASK1 != 0
  22. pushfl # standard way to check for cpuid
  23. popl %eax
  24. movl %eax,%ebx
  25. xorl $0x200000,%eax
  26. pushl %eax
  27. popfl
  28. pushfl
  29. popl %eax
  30. cmpl %eax,%ebx
  31. pushfl # standard way to check for cpuid
  32. popl %eax
  33. movl %eax,%ebx
  34. xorl $0x200000,%eax
  35. pushl %eax
  36. popfl
  37. pushfl
  38. popl %eax
  39. cmpl %eax,%ebx
  40. jz bad # REQUIRED_MASK1 != 0 requires CPUID
  41. movl $0x0,%eax # See if cpuid 1 is implemented
  42. cpuid
  43. cmpl $0x1,%eax
  44. jb bad # no cpuid 1
  45. #if REQUIRED_MASK1 & NEED_CMPXCHG64
  46. /* Some VIA C3s need magic MSRs to enable CX64. Do this here */
  47. cmpl $0x746e6543,%ebx # Cent
  48. jne 1f
  49. cmpl $0x48727561,%edx # aurH
  50. jne 1f
  51. cmpl $0x736c7561,%ecx # auls
  52. jne 1f
  53. movl $1,%eax # check model
  54. cpuid
  55. movl %eax,%ebx
  56. shr $8,%ebx
  57. andl $0xf,%ebx
  58. cmp $6,%ebx # check family == 6
  59. jne 1f
  60. shr $4,%eax
  61. andl $0xf,%eax
  62. cmpl $6,%eax # check model >= 6
  63. jb 1f
  64. # assume models >= 6 all support this MSR
  65. movl $MSR_VIA_FCR,%ecx
  66. rdmsr
  67. orl $((1<<1)|(1<<7)),%eax # enable CMPXCHG64 and PGE
  68. wrmsr
  69. 1:
  70. #endif
  71. movl $0x1,%eax # Does the cpu have what it takes
  72. cpuid
  73. #if CONFIG_X86_MINIMUM_CPU_MODEL > 4
  74. #error add proper model checking here
  75. #endif
  76. andl $REQUIRED_MASK1,%edx
  77. xorl $REQUIRED_MASK1,%edx
  78. jnz bad
  79. #endif /* REQUIRED_MASK1 */
  80. popfl
  81. xor %eax,%eax
  82. ret
  83. bad:
  84. popfl
  85. movl $1,%eax
  86. ret