coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
stages.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 /*
4  * This file contains entry/exit functions for each stage during coreboot
5  * execution (bootblock entry and ramstage exit will depend on external
6  * loading).
7  *
8  * Entry points must be placed at the location the previous stage jumps
9  * to (the lowest address in the stage image). This is done by giving
10  * stage_entry() its own section in .text and placing it first in the
11  * linker script.
12  */
13 
14 #include <cbmem.h>
15 #include <arch/stages.h>
16 #include <cpu/power/spr.h>
17 
18 void stage_entry(uintptr_t stage_arg)
19 {
20 #if ENV_RAMSTAGE
21  uint64_t hrmor;
22 #endif
23 
25  _cbmem_top_ptr = stage_arg;
26 
27 #if ENV_RAMSTAGE
28  hrmor = read_spr(SPR_HRMOR);
29  asm volatile("sync; isync" ::: "memory");
30  write_spr(SPR_HRMOR, 0);
31  asm volatile("or 1,1,%0; slbia 7; sync; isync" :: "r"(hrmor) : "memory");
32 #endif
33 
34  main();
35 }
void main(void)
Definition: romstage.c:13
__weak void stage_entry(uintptr_t stage_arg)
generic stage entry point.
Definition: stages.c:20
uintptr_t _cbmem_top_ptr
Definition: imd_cbmem.c:14
#define ENV_ROMSTAGE_OR_BEFORE
Definition: rules.h:263
static void write_spr(int spr, uint64_t val)
Definition: spr.h:45
static uint64_t read_spr(int spr)
Definition: spr.h:38
#define SPR_HRMOR
Definition: spr.h:15
unsigned long uintptr_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:17