new cache_as_ram support
[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
7         /* We don't need cache as ram for now on */
8         /* disable cache */
9         "movl    %cr0, %eax\n\t"
10         "orl    $(0x1<<30),%eax\n\t"
11         "movl    %eax, %cr0\n\t"
12
13         /* clear sth */
14         "movl    $0x269, %ecx\n\t"  /* fix4k_c8000*/
15         "xorl    %edx, %edx\n\t"
16         "xorl    %eax, %eax\n\t"
17         "wrmsr\n\t"
18 #if DCACHE_RAM_SIZE > 0x8000
19         "movl    $0x268, %ecx\n\t"  /* fix4k_c0000*/
20         "wrmsr\n\t"
21 #endif
22
23         /* disable fixed mtrr from now on, it will be enabled by linuxbios_ram again*/
24         "movl    $0xC0010010, %ecx\n\t"
25 //        "movl    $SYSCFG_MSR, %ecx\n\t"
26         "rdmsr\n\t"
27         "andl    $(~(3<<18)), %eax\n\t"
28 //        "andl    $(~(SYSCFG_MSR_MtrrFixDramModEn | SYSCFG_MSR_MtrrFixDramEn)), %eax\n\t"
29         "wrmsr\n\t"
30
31         /* Set the default memory type and disable fixed and enable variable MTRRs */
32         "movl    $0x2ff, %ecx\n\t"
33 //        "movl    $MTRRdefType_MSR, %ecx\n\t"
34         "xorl    %edx, %edx\n\t"
35         /* Enable Variable and Disable Fixed MTRRs */
36         "movl    $0x00000800, %eax\n\t"
37         "wrmsr\n\t"
38
39         /* enable cache */
40         "movl    %cr0, %eax\n\t"
41         "andl    $0x9fffffff,%eax\n\t"
42         "movl    %eax, %cr0\n\t"
43
44         );
45 }
46 /* be warned, this file will be used core 0 / node 0 and ram stack is ready*/
47
48 static void disable_cache_as_ram_bsp(void)
49 {
50         __asm__ volatile (
51
52         "pushl  %ecx\n\t"
53         "pushl  %edx\n\t"
54         "pushl  %eax\n\t"
55
56         );
57
58         disable_cache_as_ram();
59
60         __asm__ volatile (
61
62         "popl   %eax\n\t"
63         "popl   %edx\n\t"
64         "popl   %ecx\n\t"
65
66         );
67 }
68
69