Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 08dc357 | 2013-05-14 16:57:50 -0700 | [diff] [blame] | 4 | * Copyright 2010 Google Inc. |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [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 | |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 22 | #include <arch/cache.h> |
Julius Werner | 85620db | 2013-11-13 18:22:15 -0800 | [diff] [blame^] | 23 | #include <arch/exception.h> |
David Hendricks | 3d7344a | 2013-01-08 21:05:06 -0800 | [diff] [blame] | 24 | #include <arch/hlt.h> |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 25 | #include <arch/stages.h> |
Gabe Black | 8b68539 | 2013-09-29 03:02:55 -0700 | [diff] [blame] | 26 | #include <bootblock_common.h> |
Hung-Te Lin | fe18792 | 2013-02-01 01:09:24 +0800 | [diff] [blame] | 27 | #include <cbfs.h> |
Hung-Te Lin | b868d40 | 2013-02-06 22:01:18 +0800 | [diff] [blame] | 28 | #include <console/console.h> |
Kyösti Mälkki | 5a5c886 | 2014-01-26 14:41:54 +0200 | [diff] [blame] | 29 | #include <smp/node.h> |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 30 | |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 31 | void main(void) |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 32 | { |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 33 | const char *stage_name = "fallback/romstage"; |
| 34 | void *entry; |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 35 | uint32_t sctlr; |
| 36 | |
| 37 | /* Globally disable MMU, caches, and branch prediction (these should |
| 38 | * be disabled by default on reset) */ |
| 39 | sctlr = read_sctlr(); |
| 40 | sctlr &= ~(SCTLR_M | SCTLR_C | SCTLR_Z | SCTLR_I); |
| 41 | write_sctlr(sctlr); |
| 42 | |
Gabe Black | 51edd54 | 2013-09-30 23:00:33 -0700 | [diff] [blame] | 43 | arm_invalidate_caches(); |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 44 | |
| 45 | /* |
David Hendricks | f9be756 | 2013-03-21 21:58:50 -0700 | [diff] [blame] | 46 | * Re-enable icache and branch prediction. MMU and dcache will be |
| 47 | * set up later. |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 48 | */ |
| 49 | sctlr = read_sctlr(); |
David Hendricks | f9be756 | 2013-03-21 21:58:50 -0700 | [diff] [blame] | 50 | sctlr |= SCTLR_Z | SCTLR_I; |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 51 | write_sctlr(sctlr); |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 52 | |
Gabe Black | 8b68539 | 2013-09-29 03:02:55 -0700 | [diff] [blame] | 53 | bootblock_cpu_init(); |
| 54 | bootblock_mainboard_init(); |
David Hendricks | 3d7344a | 2013-01-08 21:05:06 -0800 | [diff] [blame] | 55 | |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 56 | #if CONFIG_BOOTBLOCK_CONSOLE |
Hung-Te Lin | b868d40 | 2013-02-06 22:01:18 +0800 | [diff] [blame] | 57 | console_init(); |
Julius Werner | 85620db | 2013-11-13 18:22:15 -0800 | [diff] [blame^] | 58 | exception_init(); |
Stefan Reinauer | 919c804 | 2013-05-16 10:57:15 -0700 | [diff] [blame] | 59 | #endif |
| 60 | |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 61 | entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, stage_name); |
Hung-Te Lin | 6fe0cab | 2013-01-22 18:57:56 +0800 | [diff] [blame] | 62 | |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 63 | if (entry) stage_exit(entry); |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 64 | hlt(); |
| 65 | } |