blob: 6e5b8cd4a57c9e44ac760e8b924b76a70c680ba7 [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.
Stefan Reinauere8b08ba2013-05-24 15:09:36 -070014 */
15
16/*
David Hendricks50c0a502013-01-31 17:05:50 -080017 * This file contains entry/exit functions for each stage during coreboot
18 * execution (bootblock entry and ramstage exit will depend on external
Julius Wernerfd9defc2014-01-21 20:11:22 -080019 * loading).
David Hendricks50c0a502013-01-31 17:05:50 -080020 *
Julius Wernerec5e5e02014-08-20 15:29:56 -070021 * 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 Hendricks50c0a502013-01-31 17:05:50 -080025 */
26
27#include <arch/stages.h>
David Hendricksbba80902013-03-14 15:24:57 -070028#include <arch/cache.h>
David Hendricks50c0a502013-01-31 17:05:50 -080029
Daisuke Nojiri53b74f62014-12-30 08:55:30 -080030/**
31 * generic stage entry point. override this if board specific code is needed.
32 */
33__attribute__((weak)) void stage_entry(void)
David Hendricks50c0a502013-01-31 17:05:50 -080034{
35 main();
36}
37
Ronald G. Minnich601b2752013-02-20 09:24:29 -080038/* 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 Lin5f83f6c2013-02-04 14:38:03 +080043void stage_exit(void *addr)
David Hendricks50c0a502013-01-31 17:05:50 -080044{
Ronald G. Minnich601b2752013-02-20 09:24:29 -080045 void (*doit)(void) = addr;
Julius Wernerfd9defc2014-01-21 20:11:22 -080046 /*
47 * Most stages load code so we need to sync caches here. Should maybe
48 * go into cbfs_load_stage() instead...
Ronald G. Minnich601b2752013-02-20 09:24:29 -080049 */
Julius Wernerfd9defc2014-01-21 20:11:22 -080050 cache_sync_instructions();
David Hendricks50c0a502013-01-31 17:05:50 -080051 doit();
52}