1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/types.h>
7 #include <linux/stddef.h>
9 #define MTRR_CHANGE_MASK_FIXED 0x01
10 #define MTRR_CHANGE_MASK_VARIABLE 0x02
11 #define MTRR_CHANGE_MASK_DEFTYPE 0x04
13 extern unsigned int mtrr_usage_table
[MTRR_MAX_VAR_RANGES
];
18 void (*set
)(unsigned int reg
, unsigned long base
,
19 unsigned long size
, mtrr_type type
);
20 void (*set_all
)(void);
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
,
26 int (*validate_add_page
)(unsigned long base
, unsigned long size
,
28 int (*have_wrcomb
)(void);
31 extern int generic_get_free_region(unsigned long base
, unsigned long size
,
33 extern int generic_validate_add_page(unsigned long base
, unsigned long size
,
36 extern const struct mtrr_ops generic_mtrr_ops
;
38 extern int positive_have_wrcomb(void);
40 /* library functions for processor-specific routines */
41 struct set_mtrr_context
{
49 void set_mtrr_done(struct set_mtrr_context
*ctxt
);
50 void set_mtrr_cache_disable(struct set_mtrr_context
*ctxt
);
51 void set_mtrr_prepare_save(struct set_mtrr_context
*ctxt
);
53 void fill_mtrr_var_range(unsigned int index
,
54 u32 base_lo
, u32 base_hi
, u32 mask_lo
, u32 mask_hi
);
55 bool get_mtrr_state(void);
56 void mtrr_bp_pat_init(void);
58 extern void __init
set_mtrr_ops(const struct mtrr_ops
*ops
);
60 extern u64 size_or_mask
, size_and_mask
;
61 extern const struct mtrr_ops
*mtrr_if
;
63 #define is_cpu(vnd) (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
64 #define use_intel() (mtrr_if && mtrr_if->use_intel_if == 1)
66 extern unsigned int num_var_ranges
;
68 extern struct mtrr_state_type mtrr_state
;
70 void mtrr_state_warn(void);
71 const char *mtrr_attrib_to_str(int x
);
72 void mtrr_wrmsr(unsigned, unsigned, unsigned);
74 /* CPU specific mtrr init functions */
75 int amd_init_mtrr(void);
76 int cyrix_init_mtrr(void);
77 int centaur_init_mtrr(void);
79 extern int changed_by_mtrr_cleanup
;
80 extern int mtrr_cleanup(unsigned address_bits
);