coreboot/src/device/cpu_device.c
Arthur Heymans 177e135136 cpu/x86/topology: Add code to fill in topology on struct path
This is needed to generate MADT and SRAT where lapicid for threads need
to be added last. When CPUID leaf '0xB' is not present assume some
defaults that would result in identical ACPI code generation.

Change-Id: I2210eb9b663dd90941a64132aa7154440dc7e5a9
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69222
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-04-06 15:27:23 +00:00

31 lines
718 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
#include <device/device.h>
#include <console/console.h>
#include <stddef.h>
struct device *add_cpu_device(struct bus *cpu_bus, unsigned int apic_id,
int enabled)
{
struct device_path cpu_path = {};
struct device *cpu;
/* Build the CPU device path */
cpu_path.type = DEVICE_PATH_APIC;
cpu_path.apic.apic_id = apic_id;
cpu_path.apic.initial_lapicid = apic_id;
/* Update CPU in devicetree. */
if (enabled)
cpu = alloc_find_dev(cpu_bus, &cpu_path);
else
cpu = find_dev_path(cpu_bus, &cpu_path);
if (!cpu)
return NULL;
cpu->enabled = enabled;
printk(BIOS_DEBUG, "CPU: %s %s\n",
dev_path(cpu), cpu->enabled?"enabled":"disabled");
return cpu;
}