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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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
  52. * @v eax Output via %eax
  53. * @v ebx Output via %ebx
  54. * @v ecx Output via %ecx
  55. * @v edx Output via %edx
  56. */
  57. static inline __attribute__ (( always_inline )) void
  58. cpuid ( uint32_t function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
  59. uint32_t *edx ) {
  60. __asm__ ( "cpuid"
  61. : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
  62. : "0" ( function ) );
  63. }
  64. extern int cpuid_supported ( uint32_t function );
  65. extern void x86_features ( struct x86_features *features );
  66. #endif /* _IPXE_CPUID_H */