File Index
Files and directories
Sign in
FILE

mtrr.h

File preview with syntax highlighting.

linux-6.19.14/arch/x86/kernel/cpu/mtrr/mtrr.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * local MTRR defines.
 4 */
 5
 6#include <linux/types.h>
 7#include <linux/stddef.h>
 8
 9#define MTRR_CHANGE_MASK_FIXED     0x01
10#define MTRR_CHANGE_MASK_VARIABLE  0x02
11#define MTRR_CHANGE_MASK_DEFTYPE   0x04
12
13extern bool mtrr_debug;
14#define Dprintk(x...) do { if (mtrr_debug) pr_info(x); } while (0)
15
16extern unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES];
17
18struct mtrr_ops {
19	u32	var_regs;
20	void	(*set)(unsigned int reg, unsigned long base,
21		       unsigned long size, mtrr_type type);
22	void	(*get)(unsigned int reg, unsigned long *base,
23		       unsigned long *size, mtrr_type *type);
24	int	(*get_free_region)(unsigned long base, unsigned long size,
25				   int replace_reg);
26	int	(*validate_add_page)(unsigned long base, unsigned long size,
27				     unsigned int type);
28	int	(*have_wrcomb)(void);
29};
30
31extern int generic_get_free_region(unsigned long base, unsigned long size,
32				   int replace_reg);
33extern int generic_validate_add_page(unsigned long base, unsigned long size,
34				     unsigned int type);
35
36extern const struct mtrr_ops generic_mtrr_ops;
37
38extern int positive_have_wrcomb(void);
39
40/* library functions for processor-specific routines */
41struct set_mtrr_context {
42	unsigned long	flags;
43	unsigned long	cr4val;
44	u32		deftype_lo;
45	u32		deftype_hi;
46	u32		ccr3;
47};
48
49void fill_mtrr_var_range(unsigned int index,
50		u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi);
51bool get_mtrr_state(void);
52
53extern const struct mtrr_ops *mtrr_if;
54extern struct mutex mtrr_mutex;
55
56extern unsigned int num_var_ranges;
57extern u64 mtrr_tom2;
58extern struct mtrr_state_type mtrr_state;
59extern u32 phys_hi_rsvd;
60
61void mtrr_state_warn(void);
62const char *mtrr_attrib_to_str(int x);
63void mtrr_wrmsr(unsigned, unsigned, unsigned);
64#ifdef CONFIG_X86_32
65void mtrr_set_if(void);
66void mtrr_register_syscore(void);
67#else
68static inline void mtrr_set_if(void) { }
69static inline void mtrr_register_syscore(void) { }
70#endif
71void mtrr_build_map(void);
72void mtrr_copy_map(void);
73
74/* CPU specific mtrr_ops vectors. */
75extern const struct mtrr_ops amd_mtrr_ops;
76extern const struct mtrr_ops cyrix_mtrr_ops;
77extern const struct mtrr_ops centaur_mtrr_ops;
78
79extern int changed_by_mtrr_cleanup;
80extern int mtrr_cleanup(void);
81
82/*
83 * Must be used by code which uses mtrr_if to call platform-specific
84 * MTRR manipulation functions.
85 */
86static inline bool mtrr_enabled(void)
87{
88	return !!mtrr_if;
89}
90void generic_rebuild_map(void);
~/ Read-only file preview.