MTRR related improvements for AMD family 10h and family 0Fh systems
[coreboot.git] / src / include / cpu / x86 / mtrr.h
1 #ifndef CPU_X86_MTRR_H
2 #define CPU_X86_MTRR_H
3
4
5 /*  These are the region types  */
6 #define MTRR_TYPE_UNCACHEABLE 0
7 #define MTRR_TYPE_WRCOMB     1
8 /*#define MTRR_TYPE_         2*/
9 /*#define MTRR_TYPE_         3*/
10 #define MTRR_TYPE_WRTHROUGH  4
11 #define MTRR_TYPE_WRPROT     5
12 #define MTRR_TYPE_WRBACK     6
13 #define MTRR_NUM_TYPES       7
14
15 #define MTRRcap_MSR     0x0fe
16 #define MTRRdefType_MSR 0x2ff
17
18 #define MTRRdefTypeEn           (1 << 11)
19 #define MTRRdefTypeFixEn        (1 << 10)
20
21 #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
22 #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
23
24 #define NUM_FIXED_RANGES 88
25 #define MTRRfix64K_00000_MSR 0x250
26 #define MTRRfix16K_80000_MSR 0x258
27 #define MTRRfix16K_A0000_MSR 0x259
28 #define MTRRfix4K_C0000_MSR 0x268
29 #define MTRRfix4K_C8000_MSR 0x269
30 #define MTRRfix4K_D0000_MSR 0x26a
31 #define MTRRfix4K_D8000_MSR 0x26b
32 #define MTRRfix4K_E0000_MSR 0x26c
33 #define MTRRfix4K_E8000_MSR 0x26d
34 #define MTRRfix4K_F0000_MSR 0x26e
35 #define MTRRfix4K_F8000_MSR 0x26f
36
37 #if !defined (ASSEMBLY) && !defined(__PRE_RAM__)
38 #include <device/device.h>
39 void enable_fixed_mtrr(void);
40 void x86_setup_var_mtrrs(unsigned int address_bits, unsigned int above4gb);
41 void x86_setup_mtrrs(unsigned address_bits);
42 int x86_mtrr_check(void);
43 void set_var_mtrr_resource(void *gp, struct device *dev, struct resource *res);
44 void x86_setup_fixed_mtrrs(void);
45 #endif
46
47 /* Validate CONFIG_XIP_ROM_SIZE and CONFIG_XIP_ROM_BASE */
48 #if defined(CONFIG_XIP_ROM_SIZE) && !defined(CONFIG_XIP_ROM_BASE)
49 # error "CONFIG_XIP_ROM_SIZE without CONFIG_XIP_ROM_BASE"
50 #endif
51 #if defined(CONFIG_XIP_ROM_BASE) && !defined(CONFIG_XIP_ROM_SIZE)
52 # error "CONFIG_XIP_ROM_BASE without CONFIG_XIP_ROM_SIZE"
53 #endif
54 #if !defined(CONFIG_RAMTOP)
55 # error "CONFIG_RAMTOP not defined"
56 #endif
57
58 #if defined(CONFIG_XIP_ROM_SIZE) && ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE -1)) != 0)
59 # error "CONFIG_XIP_ROM_SIZE is not a power of 2"
60 #endif
61 #if defined(CONFIG_XIP_ROM_SIZE) && ((CONFIG_XIP_ROM_BASE % CONFIG_XIP_ROM_SIZE) != 0)
62 # error "CONFIG_XIP_ROM_BASE is not a multiple of CONFIG_XIP_ROM_SIZE"
63 #endif
64
65 #if (CONFIG_RAMTOP & (CONFIG_RAMTOP -1)) != 0
66 # error "CONFIG_RAMTOP must be a power of 2"
67 #endif
68
69
70 #if !defined (ASSEMBLY)
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
81
82 #endif /* CPU_X86_MTRR_H */