This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / cpu / x86 / car / cache_as_ram_post.c
1
2         __asm__ volatile (
3         /* 
4         FIXME : backup stack in CACHE_AS_RAM into mmx and sse and after we get STACK up, we restore that.
5                 It is only needed if we want to go back
6         */
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 CONFIG_DCACHE_RAM_SIZE > 0x8000
20         "movl    $0x268, %ecx\n\t"  /* fix4k_c0000*/
21         "wrmsr\n\t"
22 #endif
23
24         /* Set the default memory type and disable fixed and enable variable MTRRs */
25         "movl    $0x2ff, %ecx\n\t"
26 //        "movl    $MTRRdefType_MSR, %ecx\n\t"
27         "xorl    %edx, %edx\n\t"
28         /* Enable Variable and Disable Fixed MTRRs */
29         "movl    $0x00000800, %eax\n\t"
30         "wrmsr\n\t"
31
32 #if defined(CLEAR_FIRST_1M_RAM)
33         /* enable caching for first 1M using variable mtrr */
34         "movl    $0x200, %ecx\n\t"
35         "xorl    %edx, %edx\n\t"
36         "movl     $(0 | 1), %eax\n\t"
37 //      "movl     $(0 | MTRR_TYPE_WRCOMB), %eax\n\t"
38         "wrmsr\n\t"
39
40         "movl    $0x201, %ecx\n\t"
41         "movl    $0x0000000f, %edx\n\t" /* AMD 40 bit 0xff*/
42         "movl    $((~(( 0 + 0x100000) - 1)) | 0x800), %eax\n\t"
43         "wrmsr\n\t"
44 #endif
45
46         /* enable cache */
47         "movl    %cr0, %eax\n\t"
48         "andl    $0x9fffffff,%eax\n\t"
49         "movl    %eax, %cr0\n\t"
50 #if defined(CLEAR_FIRST_1M_RAM)
51         /* clear the first 1M */
52         "movl    $0x0, %edi\n\t"
53         "cld\n\t"
54         "movl    $(0x100000>>2), %ecx\n\t"
55         "xorl    %eax, %eax\n\t"
56         "rep     stosl\n\t"
57
58         /* disable cache */
59         "movl    %cr0, %eax\n\t"
60         "orl    $(0x1<<30),%eax\n\t"
61         "movl    %eax, %cr0\n\t"
62
63         /* enable caching for first 1M using variable mtrr */
64         "movl    $0x200, %ecx\n\t"
65         "xorl    %edx, %edx\n\t"
66         "movl     $(0 | 6), %eax\n\t"
67 //      "movl     $(0 | MTRR_TYPE_WRBACK), %eax\n\t"
68         "wrmsr\n\t"
69
70         "movl    $0x201, %ecx\n\t"
71         "movl    $0x0000000f, %edx\n\t" /* AMD 40 bit 0xff*/
72         "movl    $((~(( 0 + 0x100000) - 1)) | 0x800), %eax\n\t"
73         "wrmsr\n\t"
74
75         /* enable cache */
76         "movl    %cr0, %eax\n\t"
77         "andl    $0x9fffffff,%eax\n\t"
78         "movl    %eax, %cr0\n\t"
79         "invd\n\t"
80
81         /* 
82         FIXME: I hope we don't need to change esp and ebp value here, so we can restore value from mmx sse back
83                 But the problem is the range is some io related, So don't go back
84         */
85 #endif
86         );