Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 1 | #ifndef CPU_X86_MTRR_H |
| 2 | #define CPU_X86_MTRR_H |
| 3 | |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 4 | /* These are the region types */ |
| 5 | #define MTRR_TYPE_UNCACHEABLE 0 |
| 6 | #define MTRR_TYPE_WRCOMB 1 |
| 7 | /*#define MTRR_TYPE_ 2*/ |
| 8 | /*#define MTRR_TYPE_ 3*/ |
| 9 | #define MTRR_TYPE_WRTHROUGH 4 |
| 10 | #define MTRR_TYPE_WRPROT 5 |
| 11 | #define MTRR_TYPE_WRBACK 6 |
| 12 | #define MTRR_NUM_TYPES 7 |
| 13 | |
| 14 | #define MTRRcap_MSR 0x0fe |
| 15 | #define MTRRdefType_MSR 0x2ff |
| 16 | |
Uwe Hermann | 66d1687 | 2010-10-01 07:27:51 +0000 | [diff] [blame] | 17 | #define MTRRdefTypeEn (1 << 11) |
| 18 | #define MTRRdefTypeFixEn (1 << 10) |
| 19 | |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 20 | #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg)) |
| 21 | #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1) |
| 22 | |
Kevin O'Connor | 5bb9fd6 | 2011-01-19 06:32:35 +0000 | [diff] [blame] | 23 | #define MTRRphysMaskValid (1 << 11) |
| 24 | |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 25 | #define NUM_FIXED_RANGES 88 |
| 26 | #define MTRRfix64K_00000_MSR 0x250 |
| 27 | #define MTRRfix16K_80000_MSR 0x258 |
| 28 | #define MTRRfix16K_A0000_MSR 0x259 |
| 29 | #define MTRRfix4K_C0000_MSR 0x268 |
| 30 | #define MTRRfix4K_C8000_MSR 0x269 |
| 31 | #define MTRRfix4K_D0000_MSR 0x26a |
| 32 | #define MTRRfix4K_D8000_MSR 0x26b |
| 33 | #define MTRRfix4K_E0000_MSR 0x26c |
| 34 | #define MTRRfix4K_E8000_MSR 0x26d |
| 35 | #define MTRRfix4K_F0000_MSR 0x26e |
| 36 | #define MTRRfix4K_F8000_MSR 0x26f |
| 37 | |
Stefan Reinauer | 61aee5f | 2011-04-10 04:15:23 +0000 | [diff] [blame] | 38 | #if !defined (__ASSEMBLER__) && !defined(__PRE_RAM__) |
Maciej Pijanka | ea92185 | 2009-10-27 14:29:29 +0000 | [diff] [blame] | 39 | #include <device/device.h> |
Maciej Pijanka | ea92185 | 2009-10-27 14:29:29 +0000 | [diff] [blame] | 40 | void enable_fixed_mtrr(void); |
Scott Duplichan | f3cce2f | 2010-11-13 19:07:59 +0000 | [diff] [blame] | 41 | void x86_setup_var_mtrrs(unsigned int address_bits, unsigned int above4gb); |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 42 | void x86_setup_mtrrs(unsigned address_bits); |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 43 | int x86_mtrr_check(void); |
Maciej Pijanka | ea92185 | 2009-10-27 14:29:29 +0000 | [diff] [blame] | 44 | void set_var_mtrr_resource(void *gp, struct device *dev, struct resource *res); |
| 45 | void x86_setup_fixed_mtrrs(void); |
Stefan Reinauer | 35b6bbb | 2010-03-28 21:26:54 +0000 | [diff] [blame] | 46 | #endif |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 47 | |
Stefan Reinauer | 8f2c616 | 2010-04-06 21:50:21 +0000 | [diff] [blame] | 48 | /* Validate CONFIG_XIP_ROM_SIZE and CONFIG_XIP_ROM_BASE */ |
| 49 | #if defined(CONFIG_XIP_ROM_SIZE) && !defined(CONFIG_XIP_ROM_BASE) |
| 50 | # error "CONFIG_XIP_ROM_SIZE without CONFIG_XIP_ROM_BASE" |
| 51 | #endif |
| 52 | #if defined(CONFIG_XIP_ROM_BASE) && !defined(CONFIG_XIP_ROM_SIZE) |
| 53 | # error "CONFIG_XIP_ROM_BASE without CONFIG_XIP_ROM_SIZE" |
| 54 | #endif |
| 55 | #if !defined(CONFIG_RAMTOP) |
| 56 | # error "CONFIG_RAMTOP not defined" |
| 57 | #endif |
| 58 | |
| 59 | #if defined(CONFIG_XIP_ROM_SIZE) && ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE -1)) != 0) |
| 60 | # error "CONFIG_XIP_ROM_SIZE is not a power of 2" |
| 61 | #endif |
| 62 | #if defined(CONFIG_XIP_ROM_SIZE) && ((CONFIG_XIP_ROM_BASE % CONFIG_XIP_ROM_SIZE) != 0) |
| 63 | # error "CONFIG_XIP_ROM_BASE is not a multiple of CONFIG_XIP_ROM_SIZE" |
| 64 | #endif |
| 65 | |
Stefan Reinauer | 1d888a9 | 2011-04-21 20:24:43 +0000 | [diff] [blame^] | 66 | #if (CONFIG_RAMTOP & (CONFIG_RAMTOP - 1)) != 0 |
Stefan Reinauer | 8f2c616 | 2010-04-06 21:50:21 +0000 | [diff] [blame] | 67 | # error "CONFIG_RAMTOP must be a power of 2" |
| 68 | #endif |
| 69 | |
Stefan Reinauer | 61aee5f | 2011-04-10 04:15:23 +0000 | [diff] [blame] | 70 | #if !defined (__ASSEMBLER__) |
Stefan Reinauer | 8f2c616 | 2010-04-06 21:50:21 +0000 | [diff] [blame] | 71 | #if defined(CONFIG_XIP_ROM_SIZE) |
| 72 | # if defined(CONFIG_TINY_BOOTBLOCK) && CONFIG_TINY_BOOTBLOCK |
| 73 | extern unsigned long AUTO_XIP_ROM_BASE; |
| 74 | # define REAL_XIP_ROM_BASE AUTO_XIP_ROM_BASE |
| 75 | # else |
| 76 | # define REAL_XIP_ROM_BASE CONFIG_XIP_ROM_BASE |
| 77 | # endif |
| 78 | #endif |
| 79 | |
| 80 | #endif |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 81 | |
| 82 | #endif /* CPU_X86_MTRR_H */ |