Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2012 Kyösti Mälkki <kyosti.malkki@gmail.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <device/device.h> |
| 18 | #include <console/console.h> |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 19 | |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 20 | device_t add_cpu_device(struct bus *cpu_bus, unsigned apic_id, int enabled) |
| 21 | { |
| 22 | struct device_path cpu_path; |
| 23 | device_t cpu; |
| 24 | |
| 25 | /* Build the cpu device path */ |
| 26 | cpu_path.type = DEVICE_PATH_APIC; |
| 27 | cpu_path.apic.apic_id = apic_id; |
| 28 | |
| 29 | /* Update CPU in devicetree. */ |
| 30 | if (enabled) |
| 31 | cpu = alloc_find_dev(cpu_bus, &cpu_path); |
| 32 | else |
| 33 | cpu = find_dev_path(cpu_bus, &cpu_path); |
| 34 | if (!cpu) |
| 35 | return NULL; |
| 36 | |
| 37 | cpu->enabled = enabled; |
| 38 | printk(BIOS_DEBUG, "CPU: %s %s\n", |
| 39 | dev_path(cpu), cpu->enabled?"enabled":"disabled"); |
| 40 | |
| 41 | return cpu; |
| 42 | } |
| 43 | |
| 44 | void set_cpu_topology(device_t cpu, unsigned node, unsigned package, unsigned core, unsigned thread) |
| 45 | { |
| 46 | cpu->path.apic.node_id = node; |
| 47 | cpu->path.apic.package_id = package; |
| 48 | cpu->path.apic.core_id = core; |
| 49 | cpu->path.apic.thread_id = thread; |
| 50 | } |