David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | e8b08ba | 2013-05-24 15:09:36 -0700 | [diff] [blame] | 4 | * Copyright 2012 Google Inc. |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Stefan Reinauer | e8b08ba | 2013-05-24 15:09:36 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | /* |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 21 | * This file contains entry/exit functions for each stage during coreboot |
| 22 | * execution (bootblock entry and ramstage exit will depend on external |
Julius Werner | fd9defc | 2014-01-21 20:11:22 -0800 | [diff] [blame] | 23 | * loading). |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 24 | * |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 25 | * Entry points should be set in the linker script and honored by CBFS, |
| 26 | * so text section layout shouldn't matter. Still, it doesn't hurt to put |
| 27 | * stage_entry first (which XXXstage.ld will do automatically through the |
| 28 | * .text.stage_entry section created by -ffunction-sections). |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include <arch/stages.h> |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 32 | #include <arch/cache.h> |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 33 | |
Daisuke Nojiri | 53b74f6 | 2014-12-30 08:55:30 -0800 | [diff] [blame] | 34 | /** |
| 35 | * generic stage entry point. override this if board specific code is needed. |
| 36 | */ |
| 37 | __attribute__((weak)) void stage_entry(void) |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 38 | { |
| 39 | main(); |
| 40 | } |
| 41 | |
Ronald G. Minnich | 601b275 | 2013-02-20 09:24:29 -0800 | [diff] [blame] | 42 | /* we had marked 'doit' as 'noreturn'. |
| 43 | * There is no apparent harm in leaving it as something we can return from, and in the one |
| 44 | * case where we call a payload, the payload is allowed to return. |
| 45 | * Hence, leave it as something we can return from. |
| 46 | */ |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 47 | void stage_exit(void *addr) |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 48 | { |
Ronald G. Minnich | 601b275 | 2013-02-20 09:24:29 -0800 | [diff] [blame] | 49 | void (*doit)(void) = addr; |
Julius Werner | fd9defc | 2014-01-21 20:11:22 -0800 | [diff] [blame] | 50 | /* |
| 51 | * Most stages load code so we need to sync caches here. Should maybe |
| 52 | * go into cbfs_load_stage() instead... |
Ronald G. Minnich | 601b275 | 2013-02-20 09:24:29 -0800 | [diff] [blame] | 53 | */ |
Julius Werner | fd9defc | 2014-01-21 20:11:22 -0800 | [diff] [blame] | 54 | cache_sync_instructions(); |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 55 | doit(); |
| 56 | } |