cpu.h 2.5 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3
#ifndef ARCH_X86_CPU_H
#define ARCH_X86_CPU_H
L
Linus Torvalds 已提交
4 5 6

/* attempt to consolidate cpu attributes */
struct cpu_dev {
J
Jaswinder Singh Rajput 已提交
7
	const char	*c_vendor;
L
Linus Torvalds 已提交
8 9

	/* some have two possibilities for cpuid string */
J
Jaswinder Singh Rajput 已提交
10
	const char	*c_ident[2];
L
Linus Torvalds 已提交
11

J
Jaswinder Singh Rajput 已提交
12
	void            (*c_early_init)(struct cpuinfo_x86 *);
B
Borislav Petkov 已提交
13
	void		(*c_bsp_init)(struct cpuinfo_x86 *);
J
Jaswinder Singh Rajput 已提交
14 15
	void		(*c_init)(struct cpuinfo_x86 *);
	void		(*c_identify)(struct cpuinfo_x86 *);
16
	void		(*c_detect_tlb)(struct cpuinfo_x86 *);
17
	void		(*c_bsp_resume)(struct cpuinfo_x86 *);
J
Jaswinder Singh Rajput 已提交
18
	int		c_x86_vendor;
19 20 21 22 23 24 25 26 27 28 29
#ifdef CONFIG_X86_32
	/* Optional vendor specific routine to obtain the cache size. */
	unsigned int	(*legacy_cache_size)(struct cpuinfo_x86 *,
					     unsigned int);

	/* Family/stepping-based lookup table for model names. */
	struct legacy_cpu_model_info {
		int		family;
		const char	*model_names[16];
	}		legacy_models[5];
#endif
L
Linus Torvalds 已提交
30 31
};

32 33 34 35 36 37 38 39
struct _tlb_table {
	unsigned char descriptor;
	char tlb_type;
	unsigned int entries;
	/* unsigned int ways; */
	char info[128];
};

Y
Yinghai Lu 已提交
40
#define cpu_dev_register(cpu_devX) \
41
	static const struct cpu_dev *const __cpu_dev_##cpu_devX __used \
Y
Yinghai Lu 已提交
42 43
	__attribute__((__section__(".x86_cpu_dev.init"))) = \
	&cpu_devX;
L
Linus Torvalds 已提交
44

45 46
extern const struct cpu_dev *const __x86_cpu_dev_start[],
			    *const __x86_cpu_dev_end[];
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#ifdef CONFIG_CPU_SUP_INTEL
enum tsx_ctrl_states {
	TSX_CTRL_ENABLE,
	TSX_CTRL_DISABLE,
	TSX_CTRL_NOT_SUPPORTED,
};

extern __ro_after_init enum tsx_ctrl_states tsx_ctrl_state;

extern void __init tsx_init(void);
extern void tsx_enable(void);
extern void tsx_disable(void);
#else
static inline void tsx_init(void) { }
#endif /* CONFIG_CPU_SUP_INTEL */

64
extern void get_cpu_cap(struct cpuinfo_x86 *c);
65
extern void get_cpu_address_sizes(struct cpuinfo_x86 *c);
66
extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c);
67 68 69 70
extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
extern u32 get_scattered_cpuid_leaf(unsigned int level,
				    unsigned int sub_leaf,
				    enum cpuid_regs_idx reg);
71
extern void init_intel_cacheinfo(struct cpuinfo_x86 *c);
72 73
extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);

74
extern void detect_num_cpu_cores(struct cpuinfo_x86 *c);
75
extern int detect_extended_topology_early(struct cpuinfo_x86 *c);
76
extern int detect_extended_topology(struct cpuinfo_x86 *c);
77
extern int detect_ht_early(struct cpuinfo_x86 *c);
78
extern void detect_ht(struct cpuinfo_x86 *c);
79 80 81

unsigned int aperfmperf_get_khz(int cpu);

82 83
extern void x86_spec_ctrl_setup_ap(void);

84 85
extern u64 x86_read_arch_cap_msr(void);

86
#endif /* ARCH_X86_CPU_H */