processor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __ASM_X86_PROCESSOR_H
  2. #define __ASM_X86_PROCESSOR_H
  3. static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
  4. unsigned int *ecx, unsigned int *edx)
  5. {
  6. /* ecx is often an input as well as an output. */
  7. __asm__("cpuid"
  8. : "=a" (*eax),
  9. "=b" (*ebx),
  10. "=c" (*ecx),
  11. "=d" (*edx)
  12. : "0" (*eax), "2" (*ecx));
  13. }
  14. #ifdef CONFIG_X86_32
  15. # include "processor_32.h"
  16. #else
  17. # include "processor_64.h"
  18. #endif
  19. #ifndef CONFIG_PARAVIRT
  20. #define __cpuid native_cpuid
  21. #endif
  22. /*
  23. * Generic CPUID function
  24. * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
  25. * resulting in stale register contents being returned.
  26. */
  27. static inline void cpuid(unsigned int op,
  28. unsigned int *eax, unsigned int *ebx,
  29. unsigned int *ecx, unsigned int *edx)
  30. {
  31. *eax = op;
  32. *ecx = 0;
  33. __cpuid(eax, ebx, ecx, edx);
  34. }
  35. /* Some CPUID calls want 'count' to be placed in ecx */
  36. static inline void cpuid_count(unsigned int op, int count,
  37. unsigned int *eax, unsigned int *ebx,
  38. unsigned int *ecx, unsigned int *edx)
  39. {
  40. *eax = op;
  41. *ecx = count;
  42. __cpuid(eax, ebx, ecx, edx);
  43. }
  44. /*
  45. * CPUID functions returning a single datum
  46. */
  47. static inline unsigned int cpuid_eax(unsigned int op)
  48. {
  49. unsigned int eax, ebx, ecx, edx;
  50. cpuid(op, &eax, &ebx, &ecx, &edx);
  51. return eax;
  52. }
  53. static inline unsigned int cpuid_ebx(unsigned int op)
  54. {
  55. unsigned int eax, ebx, ecx, edx;
  56. cpuid(op, &eax, &ebx, &ecx, &edx);
  57. return ebx;
  58. }
  59. static inline unsigned int cpuid_ecx(unsigned int op)
  60. {
  61. unsigned int eax, ebx, ecx, edx;
  62. cpuid(op, &eax, &ebx, &ecx, &edx);
  63. return ecx;
  64. }
  65. static inline unsigned int cpuid_edx(unsigned int op)
  66. {
  67. unsigned int eax, ebx, ecx, edx;
  68. cpuid(op, &eax, &ebx, &ecx, &edx);
  69. return edx;
  70. }
  71. #endif