06a558f413c7c96d4ba9411752e8f6474177763c
[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         FIXME : backup stack in CACHE_AS_RAM into mmx and sse and after we get STACK up, we restore that.
8                 It is only needed if we want to go back
9         */
10         /* We don't need cache as ram for now on */
11         /* disable cache */
12         "movl    %cr0, %eax\n\t"
13         "orl    $(0x1<<30),%eax\n\t"
14         "movl    %eax, %cr0\n\t"
15
16         /* clear sth */
17         "movl    $0x269, %ecx\n\t"  /* fix4k_c8000*/
18         "xorl    %edx, %edx\n\t"
19         "xorl    %eax, %eax\n\t"
20         "wrmsr\n\t"
21 #if DCACHE_RAM_SIZE > 0x8000
22         "movl    $0x268, %ecx\n\t"  /* fix4k_c0000*/
23         "wrmsr\n\t"
24 #endif
25
26         /* disable fixed mtrr from now on, it will be enabled by linuxbios_ram again*/
27         "movl    $0xC0010010, %ecx\n\t"
28 //        "movl    $SYSCFG_MSR, %ecx\n\t"
29         "rdmsr\n\t"
30         "andl    $(~(3<<18)), %eax\n\t"
31 //        "andl    $(~(SYSCFG_MSR_MtrrFixDramModEn | SYSCFG_MSR_MtrrFixDramEn)), %eax\n\t"
32         "wrmsr\n\t"
33
34         /* Set the default memory type and disable fixed and enable variable MTRRs */
35         "movl    $0x2ff, %ecx\n\t"
36 //        "movl    $MTRRdefType_MSR, %ecx\n\t"
37         "xorl    %edx, %edx\n\t"
38         /* Enable Variable and Disable Fixed MTRRs */
39         "movl    $0x00000800, %eax\n\t"
40         "wrmsr\n\t"
41
42         /* enable cache */
43         "movl    %cr0, %eax\n\t"
44         "andl    $0x9fffffff,%eax\n\t"
45         "movl    %eax, %cr0\n\t"
46         );
47 }