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. |
Stefan Reinauer | e8b08ba | 2013-05-24 15:09:36 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | /* |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 17 | * This file contains entry/exit functions for each stage during coreboot |
| 18 | * execution (bootblock entry and ramstage exit will depend on external |
Julius Werner | fd9defc | 2014-01-21 20:11:22 -0800 | [diff] [blame] | 19 | * loading). |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 20 | * |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 21 | * Entry points should be set in the linker script and honored by CBFS, |
| 22 | * so text section layout shouldn't matter. Still, it doesn't hurt to put |
| 23 | * stage_entry first (which XXXstage.ld will do automatically through the |
| 24 | * .text.stage_entry section created by -ffunction-sections). |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #include <arch/stages.h> |
David Hendricks | bba8090 | 2013-03-14 15:24:57 -0700 | [diff] [blame] | 28 | #include <arch/cache.h> |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 29 | |
Daisuke Nojiri | 53b74f6 | 2014-12-30 08:55:30 -0800 | [diff] [blame] | 30 | /** |
| 31 | * generic stage entry point. override this if board specific code is needed. |
| 32 | */ |
| 33 | __attribute__((weak)) void stage_entry(void) |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 34 | { |
| 35 | main(); |
| 36 | } |
| 37 | |
Ronald G. Minnich | 601b275 | 2013-02-20 09:24:29 -0800 | [diff] [blame] | 38 | /* we had marked 'doit' as 'noreturn'. |
| 39 | * There is no apparent harm in leaving it as something we can return from, and in the one |
| 40 | * case where we call a payload, the payload is allowed to return. |
| 41 | * Hence, leave it as something we can return from. |
| 42 | */ |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 43 | void stage_exit(void *addr) |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 44 | { |
Ronald G. Minnich | 601b275 | 2013-02-20 09:24:29 -0800 | [diff] [blame] | 45 | void (*doit)(void) = addr; |
Julius Werner | fd9defc | 2014-01-21 20:11:22 -0800 | [diff] [blame] | 46 | /* |
| 47 | * Most stages load code so we need to sync caches here. Should maybe |
| 48 | * go into cbfs_load_stage() instead... |
Ronald G. Minnich | 601b275 | 2013-02-20 09:24:29 -0800 | [diff] [blame] | 49 | */ |
Julius Werner | fd9defc | 2014-01-21 20:11:22 -0800 | [diff] [blame] | 50 | cache_sync_instructions(); |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 51 | doit(); |
| 52 | } |