Xen Test Framework
Macros | Typedefs | Enumerations | Functions | Variables
cpuid.h File Reference
#include <xtf/types.h>
#include <xtf/numbers.h>
#include <xen/arch-x86/cpufeatureset.h>
+ Include dependency graph for cpuid.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define vendor_is_intel   vendor_is(X86_VENDOR_INTEL)
 
#define vendor_is_amd   vendor_is(X86_VENDOR_AMD)
 
#define cpufeat_word(idx)   ((idx) / 32)
 
#define cpufeat_bit(idx)   ((idx) % 32)
 
#define cpufeat_mask(idx)   (_AC(1, U) << cpufeat_bit(idx))
 
#define FEATURESET_1d   cpufeat_word(X86_FEATURE_FPU)
 
#define FEATURESET_1c   cpufeat_word(X86_FEATURE_SSE3)
 
#define FEATURESET_e1d   cpufeat_word(X86_FEATURE_SYSCALL)
 
#define FEATURESET_e1c   cpufeat_word(X86_FEATURE_LAHF_LM)
 
#define FEATURESET_Da1   cpufeat_word(X86_FEATURE_XSAVEOPT)
 
#define FEATURESET_7b0   cpufeat_word(X86_FEATURE_FSGSBASE)
 
#define FEATURESET_7c0   cpufeat_word(X86_FEATURE_PREFETCHWT1)
 
#define FEATURESET_e7d   cpufeat_word(X86_FEATURE_ITSC)
 
#define FEATURESET_e8b   cpufeat_word(X86_FEATURE_CLZERO)
 
#define FEATURESET_7d0   cpufeat_word(X86_FEATURE_RTM_ALWAYS_ABORT)
 
#define FSCAPINTS   (FEATURESET_7d0 + 1)
 
#define cpu_has_fpu   cpu_has(X86_FEATURE_FPU)
 
#define cpu_has_vme   cpu_has(X86_FEATURE_VME)
 
#define cpu_has_de   cpu_has(X86_FEATURE_DE)
 
#define cpu_has_pse   cpu_has(X86_FEATURE_PSE)
 
#define cpu_has_tsc   cpu_has(X86_FEATURE_TSC)
 
#define cpu_has_pae   cpu_has(X86_FEATURE_PAE)
 
#define cpu_has_mce   cpu_has(X86_FEATURE_MCE)
 
#define cpu_has_pge   cpu_has(X86_FEATURE_PGE)
 
#define cpu_has_mca   cpu_has(X86_FEATURE_MCA)
 
#define cpu_has_pat   cpu_has(X86_FEATURE_PAT)
 
#define cpu_has_pse36   cpu_has(X86_FEATURE_PSE36)
 
#define cpu_has_ds   cpu_has(X86_FEATURE_DS)
 
#define cpu_has_mmx   cpu_has(X86_FEATURE_MMX)
 
#define cpu_has_fxsr   cpu_has(X86_FEATURE_FXSR)
 
#define cpu_has_sse   cpu_has(X86_FEATURE_SSE)
 
#define cpu_has_sse2   cpu_has(X86_FEATURE_SSE2)
 
#define cpu_has_vmx   cpu_has(X86_FEATURE_VMX)
 
#define cpu_has_smx   cpu_has(X86_FEATURE_SMX)
 
#define cpu_has_pcid   cpu_has(X86_FEATURE_PCID)
 
#define cpu_has_x2apic   cpu_has(X86_FEATURE_X2APIC)
 
#define cpu_has_xsave   cpu_has(X86_FEATURE_XSAVE)
 
#define cpu_has_avx   cpu_has(X86_FEATURE_AVX)
 
#define cpu_has_syscall   cpu_has(X86_FEATURE_SYSCALL)
 
#define cpu_has_nx   cpu_has(X86_FEATURE_NX)
 
#define cpu_has_page1gb   cpu_has(X86_FEATURE_PAGE1GB)
 
#define cpu_has_lm   cpu_has(X86_FEATURE_LM)
 
#define cpu_has_svm   cpu_has(X86_FEATURE_SVM)
 
#define cpu_has_dbext   cpu_has(X86_FEATURE_DBEXT)
 
#define cpu_has_fsgsbase   cpu_has(X86_FEATURE_FSGSBASE)
 
#define cpu_has_hle   cpu_has(X86_FEATURE_HLE)
 
#define cpu_has_smep   cpu_has(X86_FEATURE_SMEP)
 
#define cpu_has_rtm   cpu_has(X86_FEATURE_RTM)
 
#define cpu_has_smap   cpu_has(X86_FEATURE_SMAP)
 
#define cpu_has_umip   cpu_has(X86_FEATURE_UMIP)
 
#define cpu_has_pku   cpu_has(X86_FEATURE_PKU)
 
#define cpu_has_rtm_always_abort   cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)
 

Typedefs

typedef void(* cpuid_fn_t) (uint32_t leaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
 
typedef void(* cpuid_count_fn_t) (uint32_t leaf, uint32_t subleaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
 

Enumerations

enum  x86_vendor { X86_VENDOR_UNKNOWN , X86_VENDOR_INTEL , X86_VENDOR_AMD }
 

Functions

static bool vendor_is (enum x86_vendor v)
 
static bool cpu_has (unsigned int feature)
 

Variables

enum x86_vendor x86_vendor
 
unsigned int max_leaf
 
unsigned int max_extd_leaf
 
unsigned int x86_family
 
unsigned int x86_model
 
unsigned int x86_stepping
 
unsigned int maxphysaddr
 
unsigned int maxvirtaddr
 
uint32_t x86_features [FSCAPINTS]
 

Macro Definition Documentation

◆ vendor_is_intel

#define vendor_is_intel   vendor_is(X86_VENDOR_INTEL)

Definition at line 33 of file cpuid.h.

◆ vendor_is_amd

#define vendor_is_amd   vendor_is(X86_VENDOR_AMD)

Definition at line 34 of file cpuid.h.

◆ cpufeat_word

#define cpufeat_word (   idx)    ((idx) / 32)

Definition at line 37 of file cpuid.h.

◆ cpufeat_bit

#define cpufeat_bit (   idx)    ((idx) % 32)

Definition at line 38 of file cpuid.h.

◆ cpufeat_mask

#define cpufeat_mask (   idx)    (_AC(1, U) << cpufeat_bit(idx))

Definition at line 39 of file cpuid.h.

◆ FEATURESET_1d

#define FEATURESET_1d   cpufeat_word(X86_FEATURE_FPU)

Definition at line 41 of file cpuid.h.

◆ FEATURESET_1c

#define FEATURESET_1c   cpufeat_word(X86_FEATURE_SSE3)

Definition at line 42 of file cpuid.h.

◆ FEATURESET_e1d

#define FEATURESET_e1d   cpufeat_word(X86_FEATURE_SYSCALL)

Definition at line 43 of file cpuid.h.

◆ FEATURESET_e1c

#define FEATURESET_e1c   cpufeat_word(X86_FEATURE_LAHF_LM)

Definition at line 44 of file cpuid.h.

◆ FEATURESET_Da1

#define FEATURESET_Da1   cpufeat_word(X86_FEATURE_XSAVEOPT)

Definition at line 45 of file cpuid.h.

◆ FEATURESET_7b0

#define FEATURESET_7b0   cpufeat_word(X86_FEATURE_FSGSBASE)

Definition at line 46 of file cpuid.h.

◆ FEATURESET_7c0

#define FEATURESET_7c0   cpufeat_word(X86_FEATURE_PREFETCHWT1)

Definition at line 47 of file cpuid.h.

◆ FEATURESET_e7d

#define FEATURESET_e7d   cpufeat_word(X86_FEATURE_ITSC)

Definition at line 48 of file cpuid.h.

◆ FEATURESET_e8b

#define FEATURESET_e8b   cpufeat_word(X86_FEATURE_CLZERO)

Definition at line 49 of file cpuid.h.

◆ FEATURESET_7d0

#define FEATURESET_7d0   cpufeat_word(X86_FEATURE_RTM_ALWAYS_ABORT)

Definition at line 50 of file cpuid.h.

◆ FSCAPINTS

#define FSCAPINTS   (FEATURESET_7d0 + 1)

Definition at line 52 of file cpuid.h.

◆ cpu_has_fpu

#define cpu_has_fpu   cpu_has(X86_FEATURE_FPU)

Definition at line 61 of file cpuid.h.

◆ cpu_has_vme

#define cpu_has_vme   cpu_has(X86_FEATURE_VME)

Definition at line 62 of file cpuid.h.

◆ cpu_has_de

#define cpu_has_de   cpu_has(X86_FEATURE_DE)

Definition at line 63 of file cpuid.h.

◆ cpu_has_pse

#define cpu_has_pse   cpu_has(X86_FEATURE_PSE)

Definition at line 64 of file cpuid.h.

◆ cpu_has_tsc

#define cpu_has_tsc   cpu_has(X86_FEATURE_TSC)

Definition at line 65 of file cpuid.h.

◆ cpu_has_pae

#define cpu_has_pae   cpu_has(X86_FEATURE_PAE)

Definition at line 66 of file cpuid.h.

◆ cpu_has_mce

#define cpu_has_mce   cpu_has(X86_FEATURE_MCE)

Definition at line 67 of file cpuid.h.

◆ cpu_has_pge

#define cpu_has_pge   cpu_has(X86_FEATURE_PGE)

Definition at line 68 of file cpuid.h.

◆ cpu_has_mca

#define cpu_has_mca   cpu_has(X86_FEATURE_MCA)

Definition at line 69 of file cpuid.h.

◆ cpu_has_pat

#define cpu_has_pat   cpu_has(X86_FEATURE_PAT)

Definition at line 70 of file cpuid.h.

◆ cpu_has_pse36

#define cpu_has_pse36   cpu_has(X86_FEATURE_PSE36)

Definition at line 71 of file cpuid.h.

◆ cpu_has_ds

#define cpu_has_ds   cpu_has(X86_FEATURE_DS)

Definition at line 72 of file cpuid.h.

◆ cpu_has_mmx

#define cpu_has_mmx   cpu_has(X86_FEATURE_MMX)

Definition at line 73 of file cpuid.h.

◆ cpu_has_fxsr

#define cpu_has_fxsr   cpu_has(X86_FEATURE_FXSR)

Definition at line 74 of file cpuid.h.

◆ cpu_has_sse

#define cpu_has_sse   cpu_has(X86_FEATURE_SSE)

Definition at line 76 of file cpuid.h.

◆ cpu_has_sse2

#define cpu_has_sse2   cpu_has(X86_FEATURE_SSE2)

Definition at line 77 of file cpuid.h.

◆ cpu_has_vmx

#define cpu_has_vmx   cpu_has(X86_FEATURE_VMX)

Definition at line 78 of file cpuid.h.

◆ cpu_has_smx

#define cpu_has_smx   cpu_has(X86_FEATURE_SMX)

Definition at line 79 of file cpuid.h.

◆ cpu_has_pcid

#define cpu_has_pcid   cpu_has(X86_FEATURE_PCID)

Definition at line 80 of file cpuid.h.

◆ cpu_has_x2apic

#define cpu_has_x2apic   cpu_has(X86_FEATURE_X2APIC)

Definition at line 81 of file cpuid.h.

◆ cpu_has_xsave

#define cpu_has_xsave   cpu_has(X86_FEATURE_XSAVE)

Definition at line 82 of file cpuid.h.

◆ cpu_has_avx

#define cpu_has_avx   cpu_has(X86_FEATURE_AVX)

Definition at line 83 of file cpuid.h.

◆ cpu_has_syscall

#define cpu_has_syscall   cpu_has(X86_FEATURE_SYSCALL)

Definition at line 85 of file cpuid.h.

◆ cpu_has_nx

#define cpu_has_nx   cpu_has(X86_FEATURE_NX)

Definition at line 86 of file cpuid.h.

◆ cpu_has_page1gb

#define cpu_has_page1gb   cpu_has(X86_FEATURE_PAGE1GB)

Definition at line 87 of file cpuid.h.

◆ cpu_has_lm

#define cpu_has_lm   cpu_has(X86_FEATURE_LM)

Definition at line 88 of file cpuid.h.

◆ cpu_has_svm

#define cpu_has_svm   cpu_has(X86_FEATURE_SVM)

Definition at line 90 of file cpuid.h.

◆ cpu_has_dbext

#define cpu_has_dbext   cpu_has(X86_FEATURE_DBEXT)

Definition at line 91 of file cpuid.h.

◆ cpu_has_fsgsbase

#define cpu_has_fsgsbase   cpu_has(X86_FEATURE_FSGSBASE)

Definition at line 93 of file cpuid.h.

◆ cpu_has_hle

#define cpu_has_hle   cpu_has(X86_FEATURE_HLE)

Definition at line 94 of file cpuid.h.

◆ cpu_has_smep

#define cpu_has_smep   cpu_has(X86_FEATURE_SMEP)

Definition at line 95 of file cpuid.h.

◆ cpu_has_rtm

#define cpu_has_rtm   cpu_has(X86_FEATURE_RTM)

Definition at line 96 of file cpuid.h.

◆ cpu_has_smap

#define cpu_has_smap   cpu_has(X86_FEATURE_SMAP)

Definition at line 97 of file cpuid.h.

◆ cpu_has_umip

#define cpu_has_umip   cpu_has(X86_FEATURE_UMIP)

Definition at line 99 of file cpuid.h.

◆ cpu_has_pku

#define cpu_has_pku   cpu_has(X86_FEATURE_PKU)

Definition at line 100 of file cpuid.h.

◆ cpu_has_rtm_always_abort

#define cpu_has_rtm_always_abort   cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)

Definition at line 102 of file cpuid.h.

Typedef Documentation

◆ cpuid_fn_t

typedef void(* cpuid_fn_t) (uint32_t leaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)

Definition at line 9 of file cpuid.h.

◆ cpuid_count_fn_t

typedef void(* cpuid_count_fn_t) (uint32_t leaf, uint32_t subleaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)

Definition at line 12 of file cpuid.h.

Enumeration Type Documentation

◆ x86_vendor

enum x86_vendor
Enumerator
X86_VENDOR_UNKNOWN 
X86_VENDOR_INTEL 
X86_VENDOR_AMD 

Definition at line 16 of file cpuid.h.

Function Documentation

◆ vendor_is()

static bool vendor_is ( enum x86_vendor  v)
inlinestatic

Definition at line 28 of file cpuid.h.

◆ cpu_has()

static bool cpu_has ( unsigned int  feature)
inlinestatic

Definition at line 56 of file cpuid.h.

Variable Documentation

◆ x86_vendor

enum x86_vendor x86_vendor
extern

Definition at line 25 of file setup.c.

◆ max_leaf

unsigned int max_leaf
extern

Definition at line 26 of file setup.c.

◆ max_extd_leaf

unsigned int max_extd_leaf

Definition at line 24 of file cpuid.h.

◆ x86_family

unsigned int x86_family
extern

Definition at line 27 of file setup.c.

◆ x86_model

unsigned int x86_model

Definition at line 25 of file cpuid.h.

◆ x86_stepping

unsigned int x86_stepping

Definition at line 25 of file cpuid.h.

◆ maxphysaddr

unsigned int maxphysaddr
extern

Definition at line 28 of file setup.c.

◆ maxvirtaddr

unsigned int maxvirtaddr

Definition at line 26 of file cpuid.h.

◆ x86_features

uint32_t x86_features[FSCAPINTS]
extern

Definition at line 24 of file setup.c.