blob: 5cd59704d2a47f239d564ed7e3b300a4949a425f [file] [log] [blame]
Stefan Reinauer52db0b92012-12-07 17:15:04 -08001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauer08dc3572013-05-14 16:57:50 -07004 * Copyright 2010 Google Inc.
Stefan Reinauer52db0b92012-12-07 17:15:04 -08005 *
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 Hendricksbba80902013-03-14 15:24:57 -070022#include <arch/cache.h>
Julius Werner85620db2013-11-13 18:22:15 -080023#include <arch/exception.h>
David Hendricks3d7344a2013-01-08 21:05:06 -080024#include <arch/hlt.h>
David Hendricks50c0a502013-01-31 17:05:50 -080025#include <arch/stages.h>
Gabe Black8b685392013-09-29 03:02:55 -070026#include <bootblock_common.h>
Hung-Te Linfe187922013-02-01 01:09:24 +080027#include <cbfs.h>
Hung-Te Linb868d402013-02-06 22:01:18 +080028#include <console/console.h>
Kyösti Mälkki5a5c8862014-01-26 14:41:54 +020029#include <smp/node.h>
David Hendricks50c0a502013-01-31 17:05:50 -080030
David Hendricks50c0a502013-01-31 17:05:50 -080031void main(void)
Stefan Reinauer52db0b92012-12-07 17:15:04 -080032{
Hung-Te Lin5f83f6c2013-02-04 14:38:03 +080033 const char *stage_name = "fallback/romstage";
34 void *entry;
David Hendricksbba80902013-03-14 15:24:57 -070035 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 Black51edd542013-09-30 23:00:33 -070043 arm_invalidate_caches();
David Hendricksbba80902013-03-14 15:24:57 -070044
45 /*
David Hendricksf9be7562013-03-21 21:58:50 -070046 * Re-enable icache and branch prediction. MMU and dcache will be
47 * set up later.
David Hendricksbba80902013-03-14 15:24:57 -070048 */
49 sctlr = read_sctlr();
David Hendricksf9be7562013-03-21 21:58:50 -070050 sctlr |= SCTLR_Z | SCTLR_I;
David Hendricksbba80902013-03-14 15:24:57 -070051 write_sctlr(sctlr);
Stefan Reinauer52db0b92012-12-07 17:15:04 -080052
Gabe Black8b685392013-09-29 03:02:55 -070053 bootblock_cpu_init();
54 bootblock_mainboard_init();
David Hendricks3d7344a2013-01-08 21:05:06 -080055
Kyösti Mälkki21333f92014-02-14 10:04:31 +020056#if CONFIG_BOOTBLOCK_CONSOLE
Hung-Te Linb868d402013-02-06 22:01:18 +080057 console_init();
Julius Werner85620db2013-11-13 18:22:15 -080058 exception_init();
Stefan Reinauer919c8042013-05-16 10:57:15 -070059#endif
60
Hung-Te Lin5f83f6c2013-02-04 14:38:03 +080061 entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, stage_name);
Hung-Te Lin6fe0cab2013-01-22 18:57:56 +080062
Hung-Te Lin5f83f6c2013-02-04 14:38:03 +080063 if (entry) stage_exit(entry);
Stefan Reinauer52db0b92012-12-07 17:15:04 -080064 hlt();
65}