blob: f859336adf75af12e6d8bde54a3f5c56180fb468 [file] [log] [blame]
Stefan Reinauer00a889c2008-10-29 04:48:44 +00001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauer3b314022009-10-26 17:04:28 +00004 * Copyright (C) 2007-2009 coresystems GmbH
Stefan Reinauer00a889c2008-10-29 04:48:44 +00005 *
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
Joseph Smith7488e042010-04-09 11:10:25 +000022#include <arch/stages.h>
Stefan Reinauer00a889c2008-10-29 04:48:44 +000023
Stefan Reinauer53b0ea42010-03-22 11:50:52 +000024/* called from assembler code */
25void stage1_main(unsigned long bist);
26
27/* from romstage.c */
Stefan Reinauer00a889c2008-10-29 04:48:44 +000028void real_main(unsigned long bist);
29
30void stage1_main(unsigned long bist)
31{
32 unsigned int cpu_reset = 0;
33
Stefan Reinauer00a889c2008-10-29 04:48:44 +000034 real_main(bist);
35
36 /* No servicable parts below this line .. */
Stefan Reinauerde3206a2010-02-22 06:09:43 +000037#ifdef CAR_DEBUG
Stefan Reinauer3b314022009-10-26 17:04:28 +000038 /* 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 );
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000044 printk(BIOS_SPEW, "v_esp=%08x\n", v_esp);
Stefan Reinauer3b314022009-10-26 17:04:28 +000045#endif
Stefan Reinauer00a889c2008-10-29 04:48:44 +000046
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000047 printk(BIOS_SPEW, "cpu_reset = %08x\n", cpu_reset);
48 printk(BIOS_SPEW, "No cache as ram now - ");
Stefan Reinauer00a889c2008-10-29 04:48:44 +000049
50 /* store cpu_reset to ebx */
51 __asm__ volatile (
52 "movl %0, %%ebx\n\t"
53 ::"a" (cpu_reset)
54 );
55
Stefan Reinauer00a889c2008-10-29 04:48:44 +000056#undef CLEAR_FIRST_1M_RAM
57#include "cache_as_ram_post.c"
Stefan Reinauer3b314022009-10-26 17:04:28 +000058
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
Stefan Reinauer00a889c2008-10-29 04:48:44 +000067
68 __asm__ volatile (
Stefan Reinauer3b314022009-10-26 17:04:28 +000069 "movl %0, %%ebp\n"
70 "movl %0, %%esp\n"
71 :: "a" (CONFIG_RAMBASE + HIGH_MEMORY_SAVE)
Stefan Reinauer00a889c2008-10-29 04:48:44 +000072 );
73
74 {
75 unsigned new_cpu_reset;
76
77 /* get back cpu_reset from ebx */
78 __asm__ volatile (
Stefan Reinauer3b314022009-10-26 17:04:28 +000079 "movl %%ebx, %0\n"
Stefan Reinauer00a889c2008-10-29 04:48:44 +000080 :"=a" (new_cpu_reset)
81 );
82
Stefan Reinauer00a889c2008-10-29 04:48:44 +000083 /* Copy and execute coreboot_ram */
84 copy_and_run(new_cpu_reset);
Stefan Reinauer00a889c2008-10-29 04:48:44 +000085 }
86
Stefan Reinauer3b314022009-10-26 17:04:28 +000087 /* We will not return */
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000088 printk(BIOS_DEBUG, "sorry. parachute did not open.\n");
Stefan Reinauer00a889c2008-10-29 04:48:44 +000089}