4d108765c52053e682fc3de71255253025286c89
[coreboot.git] / src / cpu / intel / model_106cx / cache_as_ram_disable.c
1 /*
2  * This file is part of the coreboot project.
3  * 
4  * Copyright (C) 2007-2008 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19
20 #include "cpu/x86/car/copy_and_run.c"
21
22 void real_main(unsigned long bist);
23
24 void stage1_main(unsigned long bist)
25 {
26         unsigned int cpu_reset = 0;
27
28         real_main(bist);
29
30         /* No servicable parts below this line .. */
31
32         {
33                 /* Check value of esp to verify if we have enough rom for stack in Cache as RAM */
34                 unsigned v_esp;
35                 __asm__ volatile (
36                         "movl   %%esp, %0\n\t"
37                         : "=a" (v_esp)
38                 );
39                 printk_spew("v_esp=%08x\r\n", v_esp);
40         }
41
42 cpu_reset_x:
43
44         printk_spew("cpu_reset = %08x\r\n",cpu_reset);
45
46         if(cpu_reset == 0) {
47                 print_spew("Clearing initial memory region: ");
48         }
49         print_spew("No cache as ram now - ");
50
51         /* store cpu_reset to ebx */
52         __asm__ volatile (
53                 "movl %0, %%ebx\n\t"
54                 ::"a" (cpu_reset)
55         );
56
57         if(cpu_reset==0) {
58 #define CLEAR_FIRST_1M_RAM 1
59 #include "cache_as_ram_post.c"
60         } else {
61 #undef CLEAR_FIRST_1M_RAM 
62 #include "cache_as_ram_post.c"
63         }
64
65         __asm__ volatile (
66                 /* set new esp */
67                 "movl   %0, %%ebp\n\t"
68                 "movl   %0, %%esp\n\t"
69                 ::"a"( CONFIG_RAMBASE + (1024-64)*1024 )
70         );
71
72         {
73                 unsigned new_cpu_reset;
74
75                 /* get back cpu_reset from ebx */
76                 __asm__ volatile (
77                         "movl %%ebx, %0\n\t"
78                         :"=a" (new_cpu_reset)
79                 );
80
81 #ifdef CONFIG_DEACTIVATE_CAR
82                 print_debug("Deactivating CAR");
83 #include CONFIG_DEACTIVATE_CAR_FILE
84                 print_debug(" - Done.\r\n");
85 #endif
86                 /* Copy and execute coreboot_ram */
87                 copy_and_run(new_cpu_reset);
88                 /* We will not return */
89         }
90
91         print_debug("sorry. parachute did not open.\r\n");
92 }