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 <cpu/cpu.h>
9 #include <cpu/x86/mp.h>
10 #include <cpu/x86/mtrr.h>
11 #include <cpu/x86/msr.h>
12 #include <cpu/x86/smm.h>
13 #include <acpi/acpi.h>
14 #include <device/device.h>
15 #include <device/pci_ops.h>
16 #include <soc/pci_devs.h>
17 #include <soc/cpu.h>
18 #include <soc/smi.h>
19 #include <soc/iomap.h>
20 #include <console/console.h>
21 #include <cpu/amd/microcode.h>
22 #include <types.h>
23 
24 _Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of "
25  "available cores, use the downcore_mode and disable_smt devicetree settings instead.");
26 
27 /* MP and SMM loading initialization. */
28 
29 /*
30  * Do essential initialization tasks before APs can be fired up -
31  *
32  * 1. Prevent race condition in MTRR solution. Enable MTRRs on the BSP. This
33  * creates the MTRR solution that the APs will use. Otherwise APs will try to
34  * apply the incomplete solution as the BSP is calculating it.
35  */
36 static void pre_mp_init(void)
37 {
40 }
41 
42 static void post_mp_init(void)
43 {
45 
46  /* SMMINFO only needs to be set up when booting from S5 */
47  if (!acpi_is_wakeup_s3())
49 }
50 
51 static const struct mp_ops mp_ops = {
53  .get_cpu_count = get_cpu_count,
54  .get_smm_info = get_smm_info,
55  .relocation_handler = smm_relocation_handler,
56  .post_mp_init = post_mp_init,
57 };
58 
59 void mp_init_cpus(struct bus *cpu_bus)
60 {
61  if (mp_init_with_smm(cpu_bus, &mp_ops) != CB_SUCCESS)
63  "mp_init_with_smm failed. Halting.\n");
64 
65  /* pre_mp_init made the flash not cacheable. Reset to WP for performance. */
67 }
68 
69 static void model_17_init(struct device *dev)
70 {
71  check_mca();
73 
75 }
76 
77 static struct device_operations cpu_dev_ops = {
79 };
80 
81 static struct cpu_device_id cpu_table[] = {
87  { 0, 0 },
88 };
89 
90 static const struct cpu_driver model_17 __cpu_driver = {
91  .ops = &cpu_dev_ops,
92  .id_table = cpu_table,
93 };
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
void mp_init_cpus(struct bus *cpu_bus)
Definition: cpu.c:55
_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.")
int get_cpu_count(void)
Definition: cpu.c:10
void set_cstate_io_addr(void)
Definition: cpu.c:21
static const struct cpu_driver model_17 __cpu_driver
Definition: cpu.c:90
static void pre_mp_init(void)
Definition: cpu.c:36
static void model_17_init(struct device *dev)
Definition: cpu.c:69
static struct cpu_device_id cpu_table[]
Definition: cpu.c:81
static struct device_operations cpu_dev_ops
Definition: cpu.c:77
static void post_mp_init(void)
Definition: cpu.c:42
#define PICASSO_B0_CPUID
Definition: cpu.h:7
#define RAVEN2_A1_CPUID
Definition: cpu.h:10
#define PICASSO_B1_CPUID
Definition: cpu.h:8
#define RAVEN1_B0_CPUID
Definition: cpu.h:6
#define RAVEN2_A0_CPUID
Definition: cpu.h:9
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