Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cpuid.h 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _IPXE_CPUID_H
  2. #define _IPXE_CPUID_H
  3. /** @file
  4. *
  5. * x86 CPU feature detection
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. /** An x86 CPU feature register set */
  11. struct x86_feature_registers {
  12. /** Features returned via %ecx */
  13. uint32_t ecx;
  14. /** Features returned via %edx */
  15. uint32_t edx;
  16. };
  17. /** x86 CPU features */
  18. struct x86_features {
  19. /** Intel-defined features (%eax=0x00000001) */
  20. struct x86_feature_registers intel;
  21. /** AMD-defined features (%eax=0x80000001) */
  22. struct x86_feature_registers amd;
  23. };
  24. /** CPUID support flag */
  25. #define CPUID_FLAG 0x00200000UL
  26. /** CPUID extended function */
  27. #define CPUID_EXTENDED 0x80000000UL
  28. /** Get vendor ID and largest standard function */
  29. #define CPUID_VENDOR_ID 0x00000000UL
  30. /** Get standard features */
  31. #define CPUID_FEATURES 0x00000001UL
  32. /** Hypervisor is present */
  33. #define CPUID_FEATURES_INTEL_ECX_HYPERVISOR 0x80000000UL
  34. /** Get largest extended function */
  35. #define CPUID_AMD_MAX_FN 0x80000000UL
  36. /** Extended function existence check */
  37. #define CPUID_AMD_CHECK 0x80000000UL
  38. /** Extended function existence check mask */
  39. #define CPUID_AMD_CHECK_MASK 0xffff0000UL
  40. /** Get extended features */
  41. #define CPUID_AMD_FEATURES 0x80000001UL
  42. /** Get CPU model */
  43. #define CPUID_MODEL 0x80000002UL
  44. /** Get APM information */
  45. #define CPUID_APM 0x80000007UL
  46. /** Invariant TSC */
  47. #define CPUID_APM_EDX_TSC_INVARIANT 0x00000100UL
  48. /**
  49. * Issue CPUID instruction
  50. *
  51. * @v function CPUID function (input via %eax)
  52. * @v subfunction CPUID subfunction (input via %ecx)
  53. * @v eax Output via %eax
  54. * @v ebx Output via %ebx
  55. * @v ecx Output via %ecx
  56. * @v edx Output via %edx
  57. */
  58. static inline __attribute__ (( always_inline )) void
  59. cpuid ( uint32_t function, uint32_t subfunction, uint32_t *eax, uint32_t *ebx,
  60. uint32_t *ecx, uint32_t *edx ) {
  61. __asm__ ( "cpuid"
  62. : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
  63. : "0" ( function ), "2" ( subfunction ) );
  64. }
  65. extern int cpuid_supported ( uint32_t function );
  66. extern void x86_features ( struct x86_features *features );
  67. #endif /* _IPXE_CPUID_H */