1 /* 2 * local mtrr defines. 3 */ 4 5 #include <linux/types.h> 6 #include <linux/stddef.h> 7 8 #define MTRRcap_MSR 0x0fe 9 #define MTRRdefType_MSR 0x2ff 10 11 #define MTRRfix64K_00000_MSR 0x250 12 #define MTRRfix16K_80000_MSR 0x258 13 #define MTRRfix16K_A0000_MSR 0x259 14 #define MTRRfix4K_C0000_MSR 0x268 15 #define MTRRfix4K_C8000_MSR 0x269 16 #define MTRRfix4K_D0000_MSR 0x26a 17 #define MTRRfix4K_D8000_MSR 0x26b 18 #define MTRRfix4K_E0000_MSR 0x26c 19 #define MTRRfix4K_E8000_MSR 0x26d 20 #define MTRRfix4K_F0000_MSR 0x26e 21 #define MTRRfix4K_F8000_MSR 0x26f 22 23 #define MTRR_CHANGE_MASK_FIXED 0x01 24 #define MTRR_CHANGE_MASK_VARIABLE 0x02 25 #define MTRR_CHANGE_MASK_DEFTYPE 0x04 26 27 extern unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES]; 28 29 struct mtrr_ops { 30 u32 vendor; 31 u32 use_intel_if; 32 // void (*init)(void); 33 void (*set)(unsigned int reg, unsigned long base, 34 unsigned long size, mtrr_type type); 35 void (*set_all)(void); 36 37 void (*get)(unsigned int reg, unsigned long *base, 38 unsigned long *size, mtrr_type * type); 39 int (*get_free_region)(unsigned long base, unsigned long size, 40 int replace_reg); 41 int (*validate_add_page)(unsigned long base, unsigned long size, 42 unsigned int type); 43 int (*have_wrcomb)(void); 44 }; 45 46 extern int generic_get_free_region(unsigned long base, unsigned long size, 47 int replace_reg); 48 extern int generic_validate_add_page(unsigned long base, unsigned long size, 49 unsigned int type); 50 51 extern struct mtrr_ops generic_mtrr_ops; 52 53 extern int positive_have_wrcomb(void); 54 55 /* library functions for processor-specific routines */ 56 struct set_mtrr_context { 57 unsigned long flags; 58 unsigned long cr4val; 59 u32 deftype_lo; 60 u32 deftype_hi; 61 u32 ccr3; 62 }; 63 64 void set_mtrr_done(struct set_mtrr_context *ctxt); 65 void set_mtrr_cache_disable(struct set_mtrr_context *ctxt); 66 void set_mtrr_prepare_save(struct set_mtrr_context *ctxt); 67 68 void fill_mtrr_var_range(unsigned int index, 69 u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi); 70 void get_mtrr_state(void); 71 72 extern void set_mtrr_ops(struct mtrr_ops * ops); 73 74 extern u64 size_or_mask, size_and_mask; 75 extern struct mtrr_ops * mtrr_if; 76 77 #define is_cpu(vnd) (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd) 78 #define use_intel() (mtrr_if && mtrr_if->use_intel_if == 1) 79 80 extern unsigned int num_var_ranges; 81 extern u64 mtrr_tom2; 82 extern struct mtrr_state_type mtrr_state; 83 84 void mtrr_state_warn(void); 85 const char *mtrr_attrib_to_str(int x); 86 void mtrr_wrmsr(unsigned, unsigned, unsigned); 87 88 /* CPU specific mtrr init functions */ 89 int amd_init_mtrr(void); 90 int cyrix_init_mtrr(void); 91 int centaur_init_mtrr(void); 92 93 extern int changed_by_mtrr_cleanup; 94 extern int mtrr_cleanup(unsigned address_bits); 95