summaryrefslogtreecommitdiffstats
path: root/src/cpu/x86/mp_init.c
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2022-05-14 01:23:22 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-11-05 17:18:33 +0000
commit27802bb7b20656f0c4c083a301b9bd6af131a19c (patch)
tree884254d4ebcc470e9f5ffec5dfef2c30319b0779 /src/cpu/x86/mp_init.c
parent6b8c06dc396da6b162e017af700b48d8ee9d7416 (diff)
downloadcoreboot-27802bb7b20656f0c4c083a301b9bd6af131a19c.tar.gz
coreboot-27802bb7b20656f0c4c083a301b9bd6af131a19c.tar.bz2
coreboot-27802bb7b20656f0c4c083a301b9bd6af131a19c.zip
cpu/x86/mp_init.c: Use existing code to create cpu struct device
Change-Id: I80baadd405b31d6be2fdbb894b0f4b7c775da6f8 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/64341 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jonathan Zhang <jonzhang@fb.com> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Diffstat (limited to 'src/cpu/x86/mp_init.c')
-rw-r--r--src/cpu/x86/mp_init.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index febc30b9deee..0e4a571e96c2 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -369,18 +369,9 @@ static int allocate_cpu_devices(struct bus *cpu_bus, struct mp_params *p)
info = cpu_info();
for (i = 1; i < max_cpus; i++) {
- struct device_path cpu_path;
- struct device *new;
-
- /* Build the CPU device path */
- cpu_path.type = DEVICE_PATH_APIC;
-
/* Assuming linear APIC space allocation. AP will set its own
APIC id in the ap_init() path above. */
- cpu_path.apic.apic_id = info->cpu->path.apic.apic_id + i;
-
- /* Allocate the new CPU device structure */
- new = alloc_find_dev(cpu_bus, &cpu_path);
+ struct device *new = add_cpu_device(cpu_bus, info->cpu->path.apic.apic_id + i, 1);
if (new == NULL) {
printk(BIOS_CRIT, "Could not allocate CPU device\n");
max_cpus--;
@@ -532,7 +523,6 @@ static enum cb_err bsp_do_flight_plan(struct mp_params *mp_params)
static enum cb_err init_bsp(struct bus *cpu_bus)
{
- struct device_path cpu_path;
struct cpu_info *info;
/* Print processor name */
@@ -543,13 +533,15 @@ static enum cb_err init_bsp(struct bus *cpu_bus)
enable_lapic();
setup_lapic_interrupts();
- /* Set the device path of the boot CPU. */
- cpu_path.type = DEVICE_PATH_APIC;
- cpu_path.apic.apic_id = lapicid();
+ struct device *bsp = add_cpu_device(cpu_bus, lapicid(), 1);
+ if (bsp == NULL) {
+ printk(BIOS_CRIT, "Failed to find or allocate BSP struct device\n");
+ return CB_ERR;
+ }
/* Find the device structure for the boot CPU. */
info = cpu_info();
- info->cpu = alloc_find_dev(cpu_bus, &cpu_path);
+ info->cpu = bsp;
info->cpu->name = processor_name;
if (info->index != 0) {