2 /* We will use 4K bytes only */
3 #define CacheSize DCACHE_RAM_SIZE
4 #define CacheBase (0xd0000 - CacheSize)
6 #include <cpu/x86/mtrr.h>
7 #include <cpu/amd/mtrr.h>
9 /* Save the BIST result */
13 /* hope we can skip the double set for normal part */
14 #if USE_FALLBACK_IMAGE == 1
16 /* Set MtrrFixDramModEn for clear fixed mtrr */
17 xorl %eax, %eax # clear %eax and %edx
20 enable_fixed_mtrr_dram_modify:
21 movl $SYSCFG_MSR, %ecx
23 andl $(~(SYSCFG_MSR_MtrrFixDramEn|SYSCFG_MSR_MtrrVarDramEn)), %eax
24 orl $SYSCFG_MSR_MtrrFixDramModEn, %eax
27 /* Set the default memory type and enable fixed and variable MTRRs */
28 movl $MTRRdefType_MSR, %ecx
30 /* Enable Variable and Fixed MTRRs */
31 movl $0x00000c00, %eax
37 movl $fixed_mtrr_msr, %esi
41 jz clear_fixed_var_mtrr_out
47 jmp clear_fixed_var_mtrr
48 clear_fixed_var_mtrr_out:
50 /* Enable the MTRRs and IORRs in SYSCFG */
51 movl $SYSCFG_MSR, %ecx
53 orl $(SYSCFG_MSR_MtrrVarDramEn | SYSCFG_MSR_MtrrFixDramEn), %eax
57 #if CacheSize == 0x10000
58 /* enable caching for 64K using fixed mtrr */
59 movl $0x268, %ecx /* fix4k_c0000*/
60 movl $0x06060606, %eax /* WB IO type */
67 #if CacheSize == 0x8000
68 /* enable caching for 32K using fixed mtrr */
69 movl $0x269, %ecx /* fix4k_c8000*/
70 movl $0x06060606, %eax /* WB IO type */
75 /* enable caching for 16K/8K/4K using fixed mtrr */
76 movl $0x269, %ecx /* fix4k_cc000*/
77 #if CacheSize == 0x4000
78 movl $0x06060606, %edx /* WB IO type */
80 #if CacheSize == 0x2000
81 movl $0x06060000, %edx /* WB IO type */
83 #if CacheSize == 0x1000
84 movl $0x06000000, %edx /* WB IO type */
90 /* enable caching for 64K using variable mtrr */
93 movl $(CacheBase | MTRR_TYPE_WRBACK), %eax
97 movl $0x0000000f, %edx /* AMD 40 bit 0xff*/
98 movl $((~((CacheBase + CacheSize) - 1)) | 0x800), %eax
101 /* make it to be IO by clearing RD Dram and WR Dram */
102 movl $IORR0_BASE, %ecx
104 movl $CacheBase, %eax /* bit 3, and bit 4 = 0 mean clear RD ram and WR ram */
107 movl $IORR0_MASK, %ecx
108 movl $0x000000ff, %edx
109 movl $(~((CacheBase + CacheSize) - 1) | 0x800), %eax
113 /* enable memory access for 0 - 1MB using top_mem */
116 movl $(((CONFIG_LB_MEM_TOPK << 10) + TOP_MEM_MASK) & ~TOP_MEM_MASK) , %eax
124 #endif /* USE_FALLBACK_IMAGE == 1*/
126 #if defined(XIP_ROM_SIZE) && defined(XIP_ROM_BASE)
127 /* enable write base caching so we can do execute in place
132 movl $(XIP_ROM_BASE | MTRR_TYPE_WRBACK), %eax
136 movl $0x0000000f, %edx
137 movl $(~(XIP_ROM_SIZE - 1) | 0x800), %eax
139 #endif /* XIP_ROM_SIZE && XIP_ROM_BASE */
143 andl $0x9fffffff,%eax
146 #if USE_FALLBACK_IMAGE == 1
149 /* Read the range with lodsl*/
150 movl $(CacheBase+CacheSize-4), %esi
152 movl $(CacheSize>>2), %ecx
154 /* Clear the range */
155 movl $(CacheBase+CacheSize-4), %edi
156 movl $(CacheSize>>2), %ecx
161 /* check the cache as ram */
162 movl $CacheBase, %esi
163 movl $(CacheSize>>2), %ecx
176 je .xin2 /* dont show */
190 #endif /*USE_FALLBACK_IMAGE == 1*/
193 movl $(CacheBase+CacheSize-4), %eax
197 /* Restore the BIST result */
199 /* We need to set ebp ? No need */
201 pushl %eax /* bist */
203 /* We will not go back */
206 .long 0x250, 0x258, 0x259
207 .long 0x268, 0x269, 0x26A
208 .long 0x26B, 0x26C, 0x26D
211 .long 0x200, 0x201, 0x202, 0x203
212 .long 0x204, 0x205, 0x206, 0x207
213 .long 0x208, 0x209, 0x20A, 0x20B
214 .long 0x20C, 0x20D, 0x20E, 0x20F
216 .long 0xC0010016, 0xC0010017, 0xC0010018, 0xC0010019
218 .long 0xC001001A, 0xC001001D
219 .long 0x000 /* NULL, end of table */