coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cpu.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/cpu.h>
4 #include <amdblocks/mca.h>
5 #include <amdblocks/reset.h>
6 #include <amdblocks/smm.h>
7 #include <assert.h>
8 #include <console/console.h>
9 #include <cpu/amd/microcode.h>
10 #include <cpu/cpu.h>
11 #include <cpu/x86/mp.h>
12 #include <cpu/x86/mtrr.h>
13 #include <cpu/x86/smm.h>
14 #include <acpi/acpi.h>
15 #include <device/device.h>
16 #include <soc/cpu.h>
17 #include <soc/iomap.h>
18 #include <types.h>
19 
20 _Static_assert(CONFIG_MAX_CPUS == 16, "Do not override MAX_CPUS. To reduce the number of "
21  "available cores, use the downcore_mode and disable_smt devicetree settings instead.");
22 
23 /* MP and SMM loading initialization */
24 
25 /*
26  * Do essential initialization tasks before APs can be fired up -
27  *
28  * 1. Prevent race condition in MTRR solution. Enable MTRRs on the BSP. This
29  * creates the MTRR solution that the APs will use. Otherwise APs will try to
30  * apply the incomplete solution as the BSP is calculating it.
31  */
32 static void pre_mp_init(void)
33 {
36 }
37 
38 static void post_mp_init(void)
39 {
41 
42  /* SMMINFO only needs to be set up when booting from S5 */
43  if (!acpi_is_wakeup_s3())
45 }
46 
47 static const struct mp_ops mp_ops = {
49  .get_cpu_count = get_cpu_count,
50  .get_smm_info = get_smm_info,
51  .relocation_handler = smm_relocation_handler,
52  .post_mp_init = post_mp_init,
53 };
54 
55 void mp_init_cpus(struct bus *cpu_bus)
56 {
57  if (mp_init_with_smm(cpu_bus, &mp_ops) != CB_SUCCESS)
59  "mp_init_with_smm failed. Halting.\n");
60 
61  /* pre_mp_init made the flash not cacheable. Reset to WP for performance. */
63 }
64 
65 static void zen_2_3_init(struct device *dev)
66 {
67  check_mca();
69 
71 }
72 
73 static struct device_operations cpu_dev_ops = {
74  .init = zen_2_3_init,
75 };
76 
77 static struct cpu_device_id cpu_table[] = {
79  { 0, 0 },
80 };
81 
82 static const struct cpu_driver zen_2_3 __cpu_driver = {
83  .ops = &cpu_dev_ops,
84  .id_table = cpu_table,
85 };
static int acpi_is_wakeup_s3(void)
Definition: acpi.h:9
#define FLASH_BASE_ADDR
Definition: io.h:13
#define X86_VENDOR_AMD
Definition: cpu.h:140
@ CB_SUCCESS
Call completed successfully.
Definition: cb_err.h:16
#define die_with_post_code(value, fmt,...)
Definition: console.h:21
void amd_update_microcode_from_cbfs(void)
void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase)
Definition: smmrelocate.c:90
enum cb_err mp_init_with_smm(struct bus *cpu_bus, const struct mp_ops *mp_ops)
Definition: mp_init.c:1145
void x86_mtrr_check(void)
Definition: mtrr.c:836
void mtrr_use_temp_range(uintptr_t begin, size_t size, int type)
Definition: mtrr.c:868
void x86_setup_mtrrs_with_detect_no_above_4gb(void)
Definition: mtrr.c:830
void global_smi_enable(void)
Set the EOS bit and enable SMI generation from southbridge.
Definition: smi_util.c:60
#define APM_CNT_SMMINFO
Definition: smm.h:27
void check_mca(void)
Definition: mca_common.c:36
#define POST_HW_INIT_FAILURE
Hardware initialization failure.
Definition: post_codes.h:353
int apm_control(u8 cmd)
Definition: smi_trigger.c:31
static const struct cpu_driver zen_2_3 __cpu_driver
Definition: cpu.c:82
void mp_init_cpus(struct bus *cpu_bus)
Definition: cpu.c:55
static void zen_2_3_init(struct device *dev)
Definition: cpu.c:65
_Static_assert(CONFIG_MAX_CPUS==16, "Do not override MAX_CPUS. To reduce the number of " "available cores, use the downcore_mode and disable_smt devicetree settings instead.")
static void pre_mp_init(void)
Definition: cpu.c:32
static struct cpu_device_id cpu_table[]
Definition: cpu.c:77
static struct device_operations cpu_dev_ops
Definition: cpu.c:73
static void post_mp_init(void)
Definition: cpu.c:38
#define CEZANNE_A0_CPUID
Definition: cpu.h:6
int get_cpu_count(void)
Definition: cpu.c:10
void set_cstate_io_addr(void)
Definition: cpu.c:21
static void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size)
Definition: cpu.c:149
Definition: device.h:76
Definition: cpu.h:13
struct device_operations * ops
Definition: cpu.h:14
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
Definition: mp.h:20
void(* pre_mp_init)(void)
Definition: mp.h:27
#define MTRR_TYPE_WRPROT
Definition: mtrr.h:13