123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
#ifndef _ASM_X86_CPUID_TYPES_H
#define _ASM_X86_CPUID_TYPES_H
#include <linux/build_bug.h>
#include <linux/types.h>
#include <asm/cpuid/leaf_types.h>
struct cpuid_regs {
u32 eax;
u32 ebx;
u32 ecx;
u32 edx;
};
enum cpuid_regs_idx {
CPUID_EAX = 0,
CPUID_EBX,
CPUID_ECX,
CPUID_EDX,
};
#define CPUID_LEAF_MWAIT 0x05
#define CPUID_LEAF_DCA 0x09
#define CPUID_LEAF_XSTATE 0x0d
#define CPUID_LEAF_TSC 0x15
#define CPUID_LEAF_FREQ 0x16
#define CPUID_LEAF_TILE 0x1d
#define CPUID_RANGE(idx) ((idx) & 0xffff0000)
#define CPUID_RANGE_MAX(idx) (CPUID_RANGE(idx) + 0xffff)
#define CPUID_BASE_START 0x00000000
#define CPUID_BASE_END CPUID_RANGE_MAX(CPUID_BASE_START)
struct leaf_0x2_reg {
u32 : 31,
invalid : 1;
};
union leaf_0x2_regs {
struct leaf_0x2_reg reg[4];
u32 regv[4];
u8 desc[16];
};
enum _cache_table_type {
CACHE_L1_INST = 1,
CACHE_L1_DATA,
CACHE_L2,
CACHE_L3
} __packed;
#ifndef __CHECKER__
static_assert(sizeof(enum _cache_table_type) == 1);
#endif
#define __TLB_TABLE_TYPE_BEGIN (CACHE_L3 + 1)
enum _tlb_table_type {
TLB_INST_4K = __TLB_TABLE_TYPE_BEGIN,
TLB_INST_4M,
TLB_INST_2M_4M,
TLB_INST_ALL,
TLB_DATA_4K,
TLB_DATA_4M,
TLB_DATA_2M_4M,
TLB_DATA_4K_4M,
TLB_DATA_1G,
TLB_DATA_1G_2M_4M,
TLB_DATA0_4K,
TLB_DATA0_4M,
TLB_DATA0_2M_4M,
STLB_4K,
STLB_4K_2M,
} __packed;
#ifndef __CHECKER__
static_assert(sizeof(enum _tlb_table_type) == 1);
#endif
struct leaf_0x2_table {
union {
enum _cache_table_type c_type;
enum _tlb_table_type t_type;
};
union {
short c_size;
short entries;
};
};
extern const struct leaf_0x2_table cpuid_0x2_table[256];
#define TLB_0x63_2M_4M_ENTRIES 32
struct leaf_parse_info {
unsigned int nr_entries;
};
#define __CPUID_LEAF(_name, _count) \
struct _name _name[_count]; \
struct leaf_parse_info _name##_info
#define CPUID_LEAF(_leaf, _subleaf) \
__CPUID_LEAF(leaf_ ## _leaf ## _ ## _subleaf, 1)
#define __cpuid_leaf_first_subleaf(_l) \
LEAF_ ## _l ## _ ## SUBLEAF_N_FIRST
#define __cpuid_leaf_last_subleaf(_l) \
LEAF_ ## _l ## _ ## SUBLEAF_N_LAST
#define __cpuid_leaf_subleaf_count_min(_l) 2
#define __cpuid_leaf_subleaf_count_max(_l) \
(__cpuid_leaf_last_subleaf(_l) - __cpuid_leaf_first_subleaf(_l) + 1)
#define CPUID_LEAF_N(_leaf, _count) \
static_assert(_count >= __cpuid_leaf_subleaf_count_min(_leaf)); \
static_assert(_count <= __cpuid_leaf_subleaf_count_max(_leaf)); \
__CPUID_LEAF(leaf_ ## _leaf ## _ ## n, _count)
struct cpuid_leaves {
CPUID_LEAF ( 0x0, 0 );
CPUID_LEAF ( 0x1, 0 );
};
struct cpuid_table {
struct cpuid_leaves leaves;
};
#endif /* _ASM_X86_CPUID_TYPES_H */