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