1 /* Generic MTRR (Memory Type Range Register) 1 2 3 Copyright (C) 1997-1999 Richard Gooch 4 5 This library is free software; you can red 6 modify it under the terms of the GNU Libra 7 License as published by the Free Software 8 version 2 of the License, or (at your opti 9 10 This library is distributed in the hope th 11 but WITHOUT ANY WARRANTY; without even the 12 MERCHANTABILITY or FITNESS FOR A PARTICULA 13 Library General Public License for more de 14 15 You should have received a copy of the GNU 16 License along with this library; if not, w 17 Software Foundation, Inc., 675 Mass Ave, C 18 19 Richard Gooch may be reached by email at 20 The postal address is: 21 Richard Gooch, c/o ATNF, P. O. Box 76, E 22 */ 23 #ifndef _ASM_X86_MTRR_H 24 #define _ASM_X86_MTRR_H 25 26 #include <linux/bits.h> 27 #include <uapi/asm/mtrr.h> 28 29 /* Defines for hardware MTRR registers. */ 30 #define MTRR_CAP_VCNT GENMASK(7, 0) 31 #define MTRR_CAP_FIX BIT_MASK(8) 32 #define MTRR_CAP_WC BIT_MASK(10) 33 34 #define MTRR_DEF_TYPE_TYPE GENMASK(7, 0) 35 #define MTRR_DEF_TYPE_FE BIT_MASK(10) 36 #define MTRR_DEF_TYPE_E BIT_MASK(11) 37 38 #define MTRR_DEF_TYPE_ENABLE (MTRR_DEF_TYPE 39 #define MTRR_DEF_TYPE_DISABLE ~(MTRR_DEF_TYP 40 41 #define MTRR_PHYSBASE_TYPE GENMASK(7, 0) 42 #define MTRR_PHYSBASE_RSVD GENMASK(11, 8) 43 44 #define MTRR_PHYSMASK_RSVD GENMASK(10, 0) 45 #define MTRR_PHYSMASK_V BIT_MASK(11) 46 47 struct mtrr_state_type { 48 struct mtrr_var_range var_ranges[MTRR_ 49 mtrr_type fixed_ranges[MTRR_NUM_FIXED_ 50 unsigned char enabled; 51 bool have_fixed; 52 mtrr_type def_type; 53 }; 54 55 /* 56 * The following functions are for use by othe 57 * arch_phys_wc_add and arch_phys_wc_del. 58 */ 59 # ifdef CONFIG_MTRR 60 void mtrr_bp_init(void); 61 void mtrr_overwrite_state(struct mtrr_var_rang 62 mtrr_type def_type); 63 extern u8 mtrr_type_lookup(u64 addr, u64 end, 64 extern void mtrr_save_fixed_ranges(void *); 65 extern void mtrr_save_state(void); 66 extern int mtrr_add(unsigned long base, unsign 67 unsigned int type, bool in 68 extern int mtrr_add_page(unsigned long base, u 69 unsigned int type, bo 70 extern int mtrr_del(int reg, unsigned long bas 71 extern int mtrr_del_page(int reg, unsigned lon 72 extern int mtrr_trim_uncached_memory(unsigned 73 extern int amd_special_default_mtrr(void); 74 void mtrr_disable(void); 75 void mtrr_enable(void); 76 void mtrr_generic_set_state(void); 77 # else 78 static inline void mtrr_overwrite_state(struct 79 unsign 80 mtrr_t 81 { 82 } 83 84 static inline u8 mtrr_type_lookup(u64 addr, u6 85 { 86 /* 87 * Return the default MTRR type, witho 88 * that range. 89 */ 90 *uniform = 1; 91 92 return MTRR_TYPE_UNCACHABLE; 93 } 94 #define mtrr_save_fixed_ranges(arg) do {} whil 95 #define mtrr_save_state() do {} while (0) 96 static inline int mtrr_add(unsigned long base, 97 unsigned int type, 98 { 99 return -ENODEV; 100 } 101 static inline int mtrr_add_page(unsigned long 102 unsigned int t 103 { 104 return -ENODEV; 105 } 106 static inline int mtrr_del(int reg, unsigned l 107 { 108 return -ENODEV; 109 } 110 static inline int mtrr_del_page(int reg, unsig 111 { 112 return -ENODEV; 113 } 114 static inline int mtrr_trim_uncached_memory(un 115 { 116 return 0; 117 } 118 #define mtrr_bp_init() do {} while (0) 119 #define mtrr_disable() do {} while (0) 120 #define mtrr_enable() do {} while (0) 121 #define mtrr_generic_set_state() do {} while ( 122 # endif 123 124 #ifdef CONFIG_COMPAT 125 #include <linux/compat.h> 126 127 struct mtrr_sentry32 { 128 compat_ulong_t base; /* Base address 129 compat_uint_t size; /* Size of region 130 compat_uint_t type; /* Type of region 131 }; 132 133 struct mtrr_gentry32 { 134 compat_ulong_t regnum; /* Register numb 135 compat_uint_t base; /* Base address 136 compat_uint_t size; /* Size of region 137 compat_uint_t type; /* Type of region 138 }; 139 140 #define MTRR_IOCTL_BASE 'M' 141 142 #define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOC 143 #define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOC 144 #define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOC 145 #define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IO 146 #define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOC 147 #define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOC 148 #define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOC 149 #define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOC 150 #define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IO 151 #define MTRRIOC32_KILL_PAGE_ENTRY 152 _IOW(MTRR_IOC 153 #endif /* CONFIG_COMPAT */ 154 155 /* Bit fields for enabled in struct mtrr_state 156 #define MTRR_STATE_SHIFT 10 157 #define MTRR_STATE_MTRR_FIXED_ENABLED (MTRR_ 158 #define MTRR_STATE_MTRR_ENABLED (MTRR_ 159 160 #endif /* _ASM_X86_MTRR_H */ 161
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.