processor.h 1.8 KB

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