coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/biosram.h>
4 #include <acpi/acpi.h>
5 #include <arch/cpu.h>
6 #include <arch/romstage.h>
7 #include <cbmem.h>
8 #include <console/console.h>
9 #include <cpu/x86/lapic.h>
10 #include <halt.h>
11 #include <program_loading.h>
12 #include <romstage_handoff.h>
13 #include <smp/node.h>
14 #include <string.h>
15 #include <timestamp.h>
18 
19 void __weak board_BeforeAgesa(struct sysinfo *cb) { }
20 
21 static void fill_sysinfo(struct sysinfo *cb)
22 {
23  memset(cb, 0, sizeof(*cb));
25 
27 }
28 
29 /* APs will enter directly here from bootblock, bypassing verstage
30  * and potential fallback / normal bootflow detection.
31  */
32 static void ap_romstage_main(void);
33 
34 static void romstage_main(void)
35 {
36  struct postcar_frame pcf;
37  struct sysinfo romstage_state;
38  struct sysinfo *cb = &romstage_state;
39  int cbmem_initted = 0;
40 
42 
43  console_init();
44 
45  printk(BIOS_DEBUG, "APIC %02u: CPU Family_Model = %08x\n",
47 
48  fill_sysinfo(cb);
49 
51 
53 
54  agesa_execute_state(cb, AMD_INIT_RESET);
55 
56  agesa_execute_state(cb, AMD_INIT_EARLY);
57 
59 
60  if (!cb->s3resume)
61  agesa_execute_state(cb, AMD_INIT_POST);
62  else
63  agesa_execute_state(cb, AMD_INIT_RESUME);
64 
66 
67  /* Work around AGESA setting all memory as WB on normal
68  * boot path.
69  */
71 
72  cbmem_initted = !cbmem_recovery(cb->s3resume);
73 
74  if (cb->s3resume && !cbmem_initted) {
75  printk(BIOS_EMERG, "Unable to recover CBMEM\n");
76  halt();
77  }
78 
80 
83 
84  run_postcar_phase(&pcf);
85  /* We do not return. */
86 }
87 
88 static void ap_romstage_main(void)
89 {
90  struct sysinfo romstage_state;
91  struct sysinfo *cb = &romstage_state;
92 
93  fill_sysinfo(cb);
94 
95  agesa_execute_state(cb, AMD_INIT_RESET);
96 
97  agesa_execute_state(cb, AMD_INIT_EARLY);
98 
99  /* Not reached. */
100  halt();
101 }
102 
104 {
105  romstage_main();
106 }
107 
108 void *cbmem_top_chipset(void)
109 {
110  /* Top of CBMEM is at highest usable DRAM address below 4GiB. */
111  return (void *)restore_top_of_low_cacheable();
112 }
#define HIGH_ROMSTAGE_STACK_SIZE
Definition: agesa_helper.h:34
static int acpi_is_wakeup_s3(void)
Definition: acpi.h:9
#define asmlinkage
Definition: cpu.h:8
static unsigned int cpuid_eax(unsigned int op)
Definition: cpu.h:79
void run_postcar_phase(struct postcar_frame *pcf)
int postcar_frame_init(struct postcar_frame *pcf, size_t stack_size)
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
uintptr_t restore_top_of_low_cacheable(void)
Definition: biosram.c:66
void set_ap_entry_ptr(void *entry)
Definition: biosram.c:56
int cbmem_recovery(int s3resume)
Definition: imd_cbmem.c:125
#define printk(level,...)
Definition: stdlib.h:16
asmlinkage void car_stage_entry(void)
Definition: romstage.c:61
void * cbmem_top_chipset(void)
Definition: romstage.c:108
void __weak board_BeforeAgesa(struct sysinfo *cb)
Definition: romstage.c:19
static void fill_sysinfo(struct sysinfo *cb)
Definition: romstage.c:21
static void romstage_main(void)
Definition: romstage.c:34
static void ap_romstage_main(void)
Definition: romstage.c:88
void agesa_set_interface(struct sysinfo *cb)
Definition: state_machine.c:43
int agesa_execute_state(struct sysinfo *cb, AGESA_STRUCT_NAME func)
void __noreturn halt(void)
halt the system reliably
Definition: halt.c:6
void console_init(void)
Definition: init.c:49
static __always_inline unsigned int initial_lapicid(void)
Definition: lapic.h:126
void timestamp_add_now(enum timestamp_id id)
Definition: timestamp.c:141
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_EMERG
BIOS_EMERG - Emergency / Fatal.
Definition: loglevel.h:25
void fixup_cbmem_to_UC(int s3resume)
Definition: mtrr_fixme.c:36
void recover_postcar_frame(struct postcar_frame *pcf, int s3resume)
Definition: mtrr_fixme.c:54
int romstage_handoff_init(int is_s3_resume)
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
int s3resume
Definition: state_machine.h:31
@ TS_INITRAM_END
@ TS_INITRAM_START
@ TS_ROMSTAGE_START