Part of 5560 Dunno why I need extra delete after move.
[coreboot.git] / src / cpu / amd / car / disable_cache_as_ram.c
1 /* by yhlu 6.2005 */
2 /* be warned, this file will be used other cores and core 0 / node 0 */
3 static inline __attribute__((always_inline)) void disable_cache_as_ram(void)
4 {
5         __asm__ __volatile__ (
6         /* We don't need cache as ram for now on */
7         /* disable cache */
8         "movl    %%cr0, %%eax\n\t"
9         "orl    $(0x1<<30),%%eax\n\t"
10         "movl    %%eax, %%cr0\n\t"
11
12         /* clear sth */
13         "movl    $0x269, %%ecx\n\t"  /* fix4k_c8000*/
14         "xorl    %%edx, %%edx\n\t"
15         "xorl    %%eax, %%eax\n\t"
16         "wrmsr\n\t"
17 #if CONFIG_DCACHE_RAM_SIZE > 0x8000
18         "movl    $0x268, %%ecx\n\t"  /* fix4k_c0000*/
19         "wrmsr\n\t"
20 #endif
21
22         /* disable fixed mtrr from now on, it will be enabled by coreboot_ram again*/
23         "movl    $0xC0010010, %%ecx\n\t"
24 //      "movl    $SYSCFG_MSR, %ecx\n\t"
25         "rdmsr\n\t"
26         "andl    $(~(3<<18)), %%eax\n\t"
27 //      "andl    $(~(SYSCFG_MSR_MtrrFixDramModEn | SYSCFG_MSR_MtrrFixDramEn)), %eax\n\t"
28         "wrmsr\n\t"
29
30         /* Set the default memory type and disable fixed and enable variable MTRRs */
31         "movl    $0x2ff, %%ecx\n\t"
32 //      "movl    $MTRRdefType_MSR, %ecx\n\t"
33         "xorl    %%edx, %%edx\n\t"
34         /* Enable Variable and Disable Fixed MTRRs */
35         "movl    $0x00000800, %%eax\n\t"
36         "wrmsr\n\t"
37
38         /* enable cache */
39         "movl    %%cr0, %%eax\n\t"
40         "andl    $0x9fffffff,%%eax\n\t"
41         "movl    %%eax, %%cr0\n\t"
42         ::: "memory", "eax", "ecx", "edx"
43         );
44 }
45
46 static void disable_cache_as_ram_bsp(void)
47 {
48         disable_cache_as_ram();
49 }
50