Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2009 coresystems GmbH |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 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 | |
Joseph Smith | 7488e04 | 2010-04-09 11:10:25 +0000 | [diff] [blame] | 22 | #include <arch/stages.h> |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 23 | |
Stefan Reinauer | 53b0ea4 | 2010-03-22 11:50:52 +0000 | [diff] [blame] | 24 | /* called from assembler code */ |
| 25 | void stage1_main(unsigned long bist); |
| 26 | |
| 27 | /* from romstage.c */ |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 28 | void real_main(unsigned long bist); |
| 29 | |
| 30 | void stage1_main(unsigned long bist) |
| 31 | { |
| 32 | unsigned int cpu_reset = 0; |
| 33 | |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 34 | real_main(bist); |
| 35 | |
| 36 | /* No servicable parts below this line .. */ |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 37 | #ifdef CAR_DEBUG |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 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 | ); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 44 | printk(BIOS_SPEW, "v_esp=%08x\n", v_esp); |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 45 | #endif |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 46 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 47 | printk(BIOS_SPEW, "cpu_reset = %08x\n", cpu_reset); |
| 48 | printk(BIOS_SPEW, "No cache as ram now - "); |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 49 | |
| 50 | /* store cpu_reset to ebx */ |
| 51 | __asm__ volatile ( |
| 52 | "movl %0, %%ebx\n\t" |
| 53 | ::"a" (cpu_reset) |
| 54 | ); |
| 55 | |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 56 | #undef CLEAR_FIRST_1M_RAM |
| 57 | #include "cache_as_ram_post.c" |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 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 |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 67 | |
| 68 | __asm__ volatile ( |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 69 | "movl %0, %%ebp\n" |
| 70 | "movl %0, %%esp\n" |
| 71 | :: "a" (CONFIG_RAMBASE + HIGH_MEMORY_SAVE) |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 72 | ); |
| 73 | |
| 74 | { |
| 75 | unsigned new_cpu_reset; |
| 76 | |
| 77 | /* get back cpu_reset from ebx */ |
| 78 | __asm__ volatile ( |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 79 | "movl %%ebx, %0\n" |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 80 | :"=a" (new_cpu_reset) |
| 81 | ); |
| 82 | |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 83 | /* Copy and execute coreboot_ram */ |
| 84 | copy_and_run(new_cpu_reset); |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Stefan Reinauer | 3b31402 | 2009-10-26 17:04:28 +0000 | [diff] [blame] | 87 | /* We will not return */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 88 | printk(BIOS_DEBUG, "sorry. parachute did not open.\n"); |
Stefan Reinauer | 00a889c | 2008-10-29 04:48:44 +0000 | [diff] [blame] | 89 | } |