xref: /freebsd/sys/compat/linuxkpi/common/include/asm/cpufeature.h (revision 1b10e191f341111fad7be32ead11484dfd09b800)
1 /* Public domain. */
2 
3 #ifndef _LINUXKPI_ASM_CPUFEATURE_H
4 #define _LINUXKPI_ASM_CPUFEATURE_H
5 
6 #if defined(__amd64__) || defined(__i386__)
7 
8 #include <sys/types.h>
9 #include <machine/md_var.h>
10 
11 #define	X86_FEATURE_CLFLUSH	1
12 #define	X86_FEATURE_XMM4_1	2
13 #define	X86_FEATURE_PAT		3
14 #define	X86_FEATURE_HYPERVISOR	4
15 
16 static inline bool
17 static_cpu_has(uint16_t f)
18 {
19 	switch (f) {
20 	case X86_FEATURE_CLFLUSH:
21 		return ((cpu_feature & CPUID_CLFSH) != 0);
22 	case X86_FEATURE_XMM4_1:
23 		return ((cpu_feature2 & CPUID2_SSE41) != 0);
24 	case X86_FEATURE_PAT:
25 		return ((cpu_feature & CPUID_PAT) != 0);
26 	case X86_FEATURE_HYPERVISOR:
27 		return ((cpu_feature2 & CPUID2_HV) != 0);
28 	default:
29 		return (false);
30 	}
31 }
32 
33 #define	boot_cpu_has(x)	static_cpu_has(x)
34 
35 #endif
36 
37 #endif
38