coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cpu_device.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <console/console.h>
5 
6 struct device *add_cpu_device(struct bus *cpu_bus, unsigned int apic_id,
7  int enabled)
8 {
9  struct device_path cpu_path;
10  struct device *cpu;
11 
12  /* Build the CPU device path */
14  cpu_path.apic.apic_id = apic_id;
15 
16  /* Update CPU in devicetree. */
17  if (enabled)
18  cpu = alloc_find_dev(cpu_bus, &cpu_path);
19  else
20  cpu = find_dev_path(cpu_bus, &cpu_path);
21  if (!cpu)
22  return NULL;
23 
24  cpu->enabled = enabled;
25  printk(BIOS_DEBUG, "CPU: %s %s\n",
26  dev_path(cpu), cpu->enabled?"enabled":"disabled");
27 
28  return cpu;
29 }
30 
31 void set_cpu_topology(struct device *cpu, unsigned int node,
32  unsigned int package, unsigned int core,
33  unsigned int thread)
34 {
35  cpu->path.apic.node_id = node;
36  cpu->path.apic.package_id = package;
37  cpu->path.apic.core_id = core;
38  cpu->path.apic.thread_id = thread;
39 }
#define printk(level,...)
Definition: stdlib.h:16
void set_cpu_topology(struct device *cpu, unsigned int node, unsigned int package, unsigned int core, unsigned int thread)
Definition: cpu_device.c:31
struct device * add_cpu_device(struct bus *cpu_bus, unsigned int apic_id, int enabled)
Definition: cpu_device.c:6
struct device * alloc_find_dev(struct bus *parent, struct device_path *path)
See if a device structure already exists and if not allocate it.
Definition: device.c:138
DEVTREE_CONST struct device * find_dev_path(const struct bus *parent, const struct device_path *path)
See if a device structure exists for path.
Definition: device_const.c:166
const char * dev_path(const struct device *dev)
Definition: device_util.c:149
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
@ DEVICE_PATH_APIC
Definition: path.h:12
#define NULL
Definition: stddef.h:19
unsigned int package_id
Definition: path.h:73
unsigned int thread_id
Definition: path.h:76
unsigned int node_id
Definition: path.h:74
unsigned int core_id
Definition: path.h:75
Definition: device.h:76
Definition: path.h:87
struct apic_path apic
Definition: path.h:119
Definition: device.h:107
struct device_path path
Definition: device.h:115
unsigned int enabled
Definition: device.h:122