Add VIA CX700 support, plus VIA vt8454c reference board support.
[coreboot.git] / src / cpu / via / car / cache_as_ram_post.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 VIA Technologies, Inc.
5  * (Written by Jason Zhao <jasonzhao@viatech.com.cn> for VIA)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20  
21         __asm__ volatile (
22         /* 
23         FIXME : backup stack in CACHE_AS_RAM into mmx and sse and after we get STACK up, we restore that.
24                 It is only needed if we want to go back
25         */
26         
27         /* We don't need cache as ram for now on */
28         /* disable cache */
29         "movl    %cr0, %eax\n\t"
30         "orl    $(0x1<<30),%eax\n\t"
31         "movl    %eax, %cr0\n\t"
32
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 caching for first 1M using variable mtrr */
43         "movl    $0x200, %ecx\n\t"
44         "xorl    %edx, %edx\n\t"
45         "movl     $(0 | 6), %eax\n\t"
46         //"movl     $(0 | MTRR_TYPE_WRBACK), %eax\n\t"
47         "wrmsr\n\t"
48  
49 /*Jasonzhao@viatech.com.cn, I enable cache for 0-7ffff, 80000-9ffff, e0000-fffff;
50 if 1M cacheable,then when S3 resume, there is stange color on screen for 2 sec. 
51 suppose problem of a0000-dfffff and cache .
52 and in x86_setup_fixed_mtrrs()(mtrr.c), 0-256M is set cacheable.*/
53
54         "movl    $0x201, %ecx\n\t"
55         "movl    $0x0000000f, %edx\n\t" /* AMD 40 bit 0xff*/
56                                 "movl    $((~(( 0 + 0x80000) - 1)) | 0x800), %eax\n\t"
57         "wrmsr\n\t"
58         
59         "movl    $0x202, %ecx\n\t"
60         "xorl    %edx, %edx\n\t"
61         "movl     $(0x80000 | 6), %eax\n\t"
62         "orl     $(0 | 6), %eax\n\t"
63         "wrmsr\n\t"
64
65         "movl    $0x203, %ecx\n\t"
66         "movl    $0x0000000f, %edx\n\t" /* AMD 40 bit 0xff*/
67                                 "movl    $((~(( 0 + 0x20000) - 1)) | 0x800), %eax\n\t"
68         "wrmsr\n\t"
69         
70         "movl    $0x204, %ecx\n\t"
71         "xorl    %edx, %edx\n\t"
72         "movl     $(0xc0000 | 6), %eax\n\t"
73         "orl     $(0 | 6), %eax\n\t"
74         "wrmsr\n\t"
75
76         "movl    $0x205, %ecx\n\t"
77         "movl    $0x0000000f, %edx\n\t" /* AMD 40 bit 0xff*/
78                                 "movl    $((~(( 0 + 0x40000) - 1)) | 0x800), %eax\n\t"
79         "wrmsr\n\t"        
80         
81         /*jasonzhao@viatech.com.cn add this 2008-11-27, cache XIP_ROM_BASE-SIZE to speedup the coreboot code*/
82                                 "movl    $0x206, %ecx\n\t"
83         "xorl    %edx, %edx\n\t"
84         "movl     $XIP_ROM_BASE,%eax\n\t"
85         "orl     $(0 | 6), %eax\n\t"
86         "wrmsr\n\t"
87
88                                 "movl    $0x207, %ecx\n\t"
89         "xorl    %edx, %edx\n\t"
90         "movl     $XIP_ROM_SIZE,%eax\n\t"
91         "decl   %eax\n\t"
92         "notl   %eax\n\t"
93         "orl     $(0 | 0x800), %eax\n\t"
94         "wrmsr\n\t"
95
96         /* enable cache */
97         "movl    %cr0, %eax\n\t"
98         "andl    $0x9fffffff,%eax\n\t"
99         "movl    %eax, %cr0\n\t"
100                                 "invd\n\t"
101
102         /* 
103         FIXME: I hope we don't need to change esp and ebp value here, so we can restore value from mmx sse back
104                 But the problem is the range is some io related, So don't go back
105         */
106         );