1. This patch adds CAR for Intel P6 series processors.
[coreboot.git] / src / cpu / intel / model_6ex / cache_as_ram_disable.c
1 /*
2  * This file is part of the coreboot project.
3  * 
4  * Copyright (C) 2007-2009 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
9  * 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,
19  * MA 02110-1301 USA
20  */
21
22 #include <arch/stages.h>
23
24 /* called from assembler code */
25 void stage1_main(unsigned long bist);
26
27 /* from romstage.c */
28 void real_main(unsigned long bist);
29
30 void stage1_main(unsigned long bist)
31 {
32         unsigned int cpu_reset = 0;
33
34         real_main(bist);
35
36         /* No servicable parts below this line .. */
37 #ifdef CAR_DEBUG
38         /* Check value of esp to verify if we have enough rom for stack in Cache as RAM */
39         unsigned v_esp;
40         __asm__ volatile (
41                 "movl   %%esp, %0\n"
42                 : "=a" (v_esp)
43         );
44         printk(BIOS_SPEW, "v_esp=%08x\n", v_esp);
45 #endif
46
47         printk(BIOS_SPEW, "cpu_reset = %08x\n", cpu_reset);
48         printk(BIOS_SPEW, "No cache as ram now - ");
49
50         /* store cpu_reset to ebx */
51         __asm__ volatile (
52                 "movl %0, %%ebx\n\t"
53                 ::"a" (cpu_reset)
54         );
55
56 #undef CLEAR_FIRST_1M_RAM 
57 #include "cache_as_ram_post.c"
58
59         /* For now: use rambase + 1MB - 64K (counting downwards) as stack. This
60          * makes sure that we stay completely within the 1M of memory we
61          * preserve with the memcpy above.
62          */
63
64 #ifndef HIGH_MEMORY_SAVE
65 #define HIGH_MEMORY_SAVE ( (1024 - 64) * 1024 )
66 #endif
67
68         __asm__ volatile (
69                 "movl %0, %%ebp\n"
70                 "movl %0, %%esp\n"
71                 :: "a" (CONFIG_RAMBASE + HIGH_MEMORY_SAVE)
72         );
73
74         {
75                 unsigned new_cpu_reset;
76
77                 /* get back cpu_reset from ebx */
78                 __asm__ volatile (
79                         "movl %%ebx, %0\n"
80                         :"=a" (new_cpu_reset)
81                 );
82
83                 /* Copy and execute coreboot_ram */
84                 copy_and_run(new_cpu_reset);
85         }
86
87         /* We will not return */
88         printk(BIOS_DEBUG, "sorry. parachute did not open.\n");
89 }