blob: 01506d95a4380ece6cdfbe3be0f46468aea48d48 [file] [log] [blame]
David Hendricks50c0a502013-01-31 17:05:50 -08001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauere8b08ba2013-05-24 15:09:36 -07004 * Copyright 2012 Google Inc.
David Hendricks50c0a502013-01-31 17:05:50 -08005 *
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 Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Stefan Reinauere8b08ba2013-05-24 15:09:36 -070018 */
19
20/*
David Hendricks50c0a502013-01-31 17:05:50 -080021 * This file contains entry/exit functions for each stage during coreboot
22 * execution (bootblock entry and ramstage exit will depend on external
Julius Wernerfd9defc2014-01-21 20:11:22 -080023 * loading).
David Hendricks50c0a502013-01-31 17:05:50 -080024 *
Julius Wernerec5e5e02014-08-20 15:29:56 -070025 * 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 Hendricks50c0a502013-01-31 17:05:50 -080029 */
30
31#include <arch/stages.h>
David Hendricksbba80902013-03-14 15:24:57 -070032#include <arch/cache.h>
David Hendricks50c0a502013-01-31 17:05:50 -080033
Daisuke Nojiri53b74f62014-12-30 08:55:30 -080034/**
35 * generic stage entry point. override this if board specific code is needed.
36 */
37__attribute__((weak)) void stage_entry(void)
David Hendricks50c0a502013-01-31 17:05:50 -080038{
39 main();
40}
41
Ronald G. Minnich601b2752013-02-20 09:24:29 -080042/* 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 Lin5f83f6c2013-02-04 14:38:03 +080047void stage_exit(void *addr)
David Hendricks50c0a502013-01-31 17:05:50 -080048{
Ronald G. Minnich601b2752013-02-20 09:24:29 -080049 void (*doit)(void) = addr;
Julius Wernerfd9defc2014-01-21 20:11:22 -080050 /*
51 * Most stages load code so we need to sync caches here. Should maybe
52 * go into cbfs_load_stage() instead...
Ronald G. Minnich601b2752013-02-20 09:24:29 -080053 */
Julius Wernerfd9defc2014-01-21 20:11:22 -080054 cache_sync_instructions();
David Hendricks50c0a502013-01-31 17:05:50 -080055 doit();
56}