You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cpu.h 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef I386_BITS_CPU_H
  2. #define I386_BITS_CPU_H
  3. /* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
  4. #define X86_FEATURE_FPU 0 /* Onboard FPU */
  5. #define X86_FEATURE_VME 1 /* Virtual Mode Extensions */
  6. #define X86_FEATURE_DE 2 /* Debugging Extensions */
  7. #define X86_FEATURE_PSE 3 /* Page Size Extensions */
  8. #define X86_FEATURE_TSC 4 /* Time Stamp Counter */
  9. #define X86_FEATURE_MSR 5 /* Model-Specific Registers, RDMSR, WRMSR */
  10. #define X86_FEATURE_PAE 6 /* Physical Address Extensions */
  11. #define X86_FEATURE_MCE 7 /* Machine Check Architecture */
  12. #define X86_FEATURE_CX8 8 /* CMPXCHG8 instruction */
  13. #define X86_FEATURE_APIC 9 /* Onboard APIC */
  14. #define X86_FEATURE_SEP 11 /* SYSENTER/SYSEXIT */
  15. #define X86_FEATURE_MTRR 12 /* Memory Type Range Registers */
  16. #define X86_FEATURE_PGE 13 /* Page Global Enable */
  17. #define X86_FEATURE_MCA 14 /* Machine Check Architecture */
  18. #define X86_FEATURE_CMOV 15 /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
  19. #define X86_FEATURE_PAT 16 /* Page Attribute Table */
  20. #define X86_FEATURE_PSE36 17 /* 36-bit PSEs */
  21. #define X86_FEATURE_PN 18 /* Processor serial number */
  22. #define X86_FEATURE_CLFLSH 19 /* Supports the CLFLUSH instruction */
  23. #define X86_FEATURE_DTES 21 /* Debug Trace Store */
  24. #define X86_FEATURE_ACPI 22 /* ACPI via MSR */
  25. #define X86_FEATURE_MMX 23 /* Multimedia Extensions */
  26. #define X86_FEATURE_FXSR 24 /* FXSAVE and FXRSTOR instructions (fast save and restore */
  27. /* of FPU context), and CR4.OSFXSR available */
  28. #define X86_FEATURE_XMM 25 /* Streaming SIMD Extensions */
  29. #define X86_FEATURE_XMM2 26 /* Streaming SIMD Extensions-2 */
  30. #define X86_FEATURE_SELFSNOOP 27 /* CPU self snoop */
  31. #define X86_FEATURE_HT 28 /* Hyper-Threading */
  32. #define X86_FEATURE_ACC 29 /* Automatic clock control */
  33. #define X86_FEATURE_IA64 30 /* IA-64 processor */
  34. /* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
  35. /* Don't duplicate feature flags which are redundant with Intel! */
  36. #define X86_FEATURE_SYSCALL 11 /* SYSCALL/SYSRET */
  37. #define X86_FEATURE_MMXEXT 22 /* AMD MMX extensions */
  38. #define X86_FEATURE_LM 29 /* Long Mode (x86-64) */
  39. #define X86_FEATURE_3DNOWEXT 30 /* AMD 3DNow! extensions */
  40. #define X86_FEATURE_3DNOW 31 /* 3DNow! */
  41. /** x86 CPU information */
  42. struct cpuinfo_x86 {
  43. /** CPU features */
  44. unsigned int features;
  45. /** 64-bit CPU features */
  46. unsigned int amd_features;
  47. };
  48. /*
  49. * EFLAGS bits
  50. */
  51. #define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
  52. #define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
  53. #define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
  54. #define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
  55. #define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
  56. #define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
  57. #define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
  58. #define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
  59. #define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
  60. #define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
  61. #define X86_EFLAGS_NT 0x00004000 /* Nested Task */
  62. #define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
  63. #define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
  64. #define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
  65. #define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
  66. #define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
  67. #define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
  68. /*
  69. * Generic CPUID function
  70. */
  71. static inline __attribute__ (( always_inline )) void
  72. cpuid ( int op, unsigned int *eax, unsigned int *ebx,
  73. unsigned int *ecx, unsigned int *edx ) {
  74. __asm__ ( "cpuid" :
  75. "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
  76. : "0" ( op ) );
  77. }
  78. extern void get_cpuinfo ( struct cpuinfo_x86 *cpu );
  79. #endif /* I386_BITS_CPU_H */