Angel Pons | 585495e | 2020-04-03 01:21:38 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | b28f466 | 2018-05-26 17:58:47 -0600 | [diff] [blame] | 2 | |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 3 | #include <console/console.h> |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 4 | #include <cpu/cpu.h> |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 5 | #include <cpu/x86/lapic_def.h> |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 6 | #include <cpu/x86/mp.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 7 | #include <arch/io.h> |
Elyes HAOUAS | ed69de3 | 2019-12-19 17:36:53 +0100 | [diff] [blame] | 8 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 9 | #include <device/pci_ops.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 10 | #include <arch/ioapic.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 11 | #include <device/device.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 12 | #include <stdlib.h> |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 13 | #include <smbios.h> |
Felix Held | d27ef5b | 2021-10-20 20:18:12 +0200 | [diff] [blame] | 14 | #include <types.h> |
Patrick Rudolph | 69d5ef9 | 2018-11-11 12:43:48 +0100 | [diff] [blame] | 15 | #include "memory.h" |
Myles Watson | 0520d55 | 2009-05-11 22:44:14 +0000 | [diff] [blame] | 16 | |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 17 | #include "fw_cfg.h" |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 18 | #include "fw_cfg_if.h" |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 19 | |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 20 | #include "acpi.h" |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 21 | |
Gerd Hoffmann | 05d3f49 | 2013-08-06 10:48:41 +0200 | [diff] [blame] | 22 | static void qemu_reserve_ports(struct device *dev, unsigned int idx, |
| 23 | unsigned int base, unsigned int size, |
| 24 | const char *name) |
| 25 | { |
| 26 | unsigned int end = base + size -1; |
| 27 | struct resource *res; |
| 28 | |
| 29 | printk(BIOS_DEBUG, "QEMU: reserve ioports 0x%04x-0x%04x [%s]\n", |
| 30 | base, end, name); |
| 31 | res = new_resource(dev, idx); |
| 32 | res->base = base; |
| 33 | res->size = size; |
| 34 | res->limit = 0xffff; |
| 35 | res->flags = IORESOURCE_IO | IORESOURCE_FIXED | IORESOURCE_STORED | |
| 36 | IORESOURCE_ASSIGNED; |
| 37 | } |
| 38 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 39 | static void cpu_pci_domain_set_resources(struct device *dev) |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 40 | { |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 41 | assign_resources(dev->link_list); |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 42 | } |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 43 | |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 44 | static void cpu_pci_domain_read_resources(struct device *dev) |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 45 | { |
Kyösti Mälkki | 98a9174 | 2018-05-21 21:29:16 +0300 | [diff] [blame] | 46 | u16 nbid = pci_read_config16(pcidev_on_root(0x0, 0), PCI_DEVICE_ID); |
Gerd Hoffmann | a4e7057 | 2013-08-09 10:02:22 +0200 | [diff] [blame] | 47 | int i440fx = (nbid == 0x1237); |
Gerd Hoffmann | ad690f2 | 2013-09-17 10:35:43 +0200 | [diff] [blame] | 48 | int q35 = (nbid == 0x29c0); |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 49 | struct resource *res; |
Kyösti Mälkki | 7c60068 | 2022-07-01 18:50:26 +0300 | [diff] [blame] | 50 | uint64_t tomk = 0; |
Gerd Hoffmann | 44b11f2 | 2013-06-17 13:30:50 +0200 | [diff] [blame] | 51 | int idx = 10; |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 52 | FWCfgFile f; |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 53 | |
| 54 | pci_domain_read_resources(dev); |
| 55 | |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 56 | if (!fw_cfg_check_file(&f, "etc/e820") && f.size > 0) { |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 57 | /* supported by qemu 1.7+ */ |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 58 | FwCfgE820Entry *list = malloc(f.size); |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 59 | int i; |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 60 | fw_cfg_get(f.select, list, f.size); |
| 61 | for (i = 0; i < f.size / sizeof(*list); i++) { |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 62 | switch (list[i].type) { |
Elyes HAOUAS | 8ab989e | 2016-07-30 17:46:17 +0200 | [diff] [blame] | 63 | case 1: /* RAM */ |
Himanshu Sahdev | 660ff20 | 2019-09-10 16:15:41 +0530 | [diff] [blame] | 64 | printk(BIOS_DEBUG, "QEMU: e820/ram: 0x%08llx + 0x%08llx\n", |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 65 | list[i].address, list[i].length); |
| 66 | if (list[i].address == 0) { |
| 67 | tomk = list[i].length / 1024; |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 68 | ram_from_to(dev, idx++, 0, 0xa0000); |
| 69 | ram_from_to(dev, idx++, 0xc0000, tomk * KiB); |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 70 | } else { |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 71 | ram_range(dev, idx++, list[i].address, list[i].length); |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 72 | } |
| 73 | break; |
| 74 | case 2: /* reserved */ |
| 75 | printk(BIOS_DEBUG, "QEMU: e820/res: 0x%08llx +0x%08llx\n", |
| 76 | list[i].address, list[i].length); |
| 77 | res = new_resource(dev, idx++); |
| 78 | res->base = list[i].address; |
| 79 | res->size = list[i].length; |
| 80 | res->limit = 0xffffffff; |
| 81 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | |
| 82 | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 83 | break; |
| 84 | default: |
| 85 | /* skip unknown */ |
| 86 | break; |
| 87 | } |
| 88 | } |
| 89 | free(list); |
| 90 | } |
Gerd Hoffmann | 44b11f2 | 2013-06-17 13:30:50 +0200 | [diff] [blame] | 91 | |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 92 | if (!tomk) { |
| 93 | /* qemu older than 1.7, or reading etc/e820 failed. Fallback to cmos. */ |
| 94 | tomk = qemu_get_memory_size(); |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 95 | uint64_t high = qemu_get_high_memory_size(); |
Kyösti Mälkki | 7c60068 | 2022-07-01 18:50:26 +0300 | [diff] [blame] | 96 | printk(BIOS_DEBUG, "QEMU: cmos: %llu MiB RAM below 4G.\n", tomk / 1024); |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 97 | printk(BIOS_DEBUG, "QEMU: cmos: %llu MiB RAM above 4G.\n", high / 1024); |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 98 | |
| 99 | /* Report the memory regions. */ |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 100 | ram_from_to(dev, idx++, 0, 0xa0000); |
| 101 | ram_from_to(dev, idx++, 0xc0000, tomk * KiB); |
| 102 | |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 103 | if (high) |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 104 | upper_ram_end(dev, idx++, 4ull * GiB + high * KiB); |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 105 | } |
Gerd Hoffmann | 44b11f2 | 2013-06-17 13:30:50 +0200 | [diff] [blame] | 106 | |
Gerd Hoffmann | 05d3f49 | 2013-08-06 10:48:41 +0200 | [diff] [blame] | 107 | /* Reserve I/O ports used by QEMU */ |
| 108 | qemu_reserve_ports(dev, idx++, 0x0510, 0x02, "firmware-config"); |
| 109 | qemu_reserve_ports(dev, idx++, 0x5658, 0x01, "vmware-port"); |
| 110 | if (i440fx) { |
| 111 | qemu_reserve_ports(dev, idx++, 0xae00, 0x10, "pci-hotplug"); |
| 112 | qemu_reserve_ports(dev, idx++, 0xaf00, 0x20, "cpu-hotplug"); |
| 113 | qemu_reserve_ports(dev, idx++, 0xafe0, 0x04, "piix4-gpe0"); |
| 114 | } |
| 115 | if (inb(CONFIG_CONSOLE_QEMU_DEBUGCON_PORT) == 0xe9) { |
| 116 | qemu_reserve_ports(dev, idx++, CONFIG_CONSOLE_QEMU_DEBUGCON_PORT, 1, |
| 117 | "debugcon"); |
| 118 | } |
| 119 | |
Duncan Laurie | ddd4f9a | 2020-03-17 18:46:28 -0700 | [diff] [blame] | 120 | /* A segment is legacy VGA region */ |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 121 | mmio_from_to(dev, idx++, 0xa0000, 0xc0000); |
Duncan Laurie | ddd4f9a | 2020-03-17 18:46:28 -0700 | [diff] [blame] | 122 | |
| 123 | /* C segment to 1MB is reserved RAM (low tables) */ |
Kyösti Mälkki | b20a714 | 2021-06-28 00:00:04 +0300 | [diff] [blame] | 124 | reserved_ram_from_to(dev, idx++, 0xc0000, 1 * MiB); |
Duncan Laurie | ddd4f9a | 2020-03-17 18:46:28 -0700 | [diff] [blame] | 125 | |
Gerd Hoffmann | ad690f2 | 2013-09-17 10:35:43 +0200 | [diff] [blame] | 126 | if (q35 && ((tomk * 1024) < 0xb0000000)) { |
| 127 | /* |
| 128 | * Reserve the region between top-of-ram and the |
| 129 | * mmconf xbar (ar 0xb0000000), so coreboot doesn't |
| 130 | * place pci bars there. The region isn't declared as |
Elyes HAOUAS | 8ab989e | 2016-07-30 17:46:17 +0200 | [diff] [blame] | 131 | * pci io window in the ACPI tables (\_SB.PCI0._CRS). |
Gerd Hoffmann | ad690f2 | 2013-09-17 10:35:43 +0200 | [diff] [blame] | 132 | */ |
| 133 | res = new_resource(dev, idx++); |
| 134 | res->base = tomk * 1024; |
| 135 | res->size = 0xb0000000 - tomk * 1024; |
| 136 | res->limit = 0xffffffff; |
| 137 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | |
| 138 | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 139 | } |
| 140 | |
Gerd Hoffmann | a4e7057 | 2013-08-09 10:02:22 +0200 | [diff] [blame] | 141 | if (i440fx) { |
| 142 | /* Reserve space for the IOAPIC. This should be in |
Patrick Georgi | 3f34fc4 | 2013-08-15 20:41:15 +0200 | [diff] [blame] | 143 | * the southbridge, but I couldn't tell which device |
Gerd Hoffmann | a4e7057 | 2013-08-09 10:02:22 +0200 | [diff] [blame] | 144 | * to put it in. */ |
| 145 | res = new_resource(dev, 2); |
| 146 | res->base = IO_APIC_ADDR; |
| 147 | res->size = 0x100000UL; |
| 148 | res->limit = 0xffffffffUL; |
| 149 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | |
| 150 | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 151 | } |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 152 | |
| 153 | /* Reserve space for the LAPIC. There's one in every processor, but |
| 154 | * the space only needs to be reserved once, so we do it here. */ |
| 155 | res = new_resource(dev, 3); |
Kyösti Mälkki | dea42e0 | 2021-05-31 20:26:16 +0300 | [diff] [blame] | 156 | res->base = cpu_get_lapic_addr(); |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 157 | res->size = 0x10000UL; |
| 158 | res->limit = 0xffffffffUL; |
| 159 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED | |
| 160 | IORESOURCE_ASSIGNED; |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 163 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 164 | static int qemu_get_smbios_data16(int handle, unsigned long *current) |
| 165 | { |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 166 | struct smbios_type16 *t = smbios_carve_table(*current, SMBIOS_PHYS_MEMORY_ARRAY, |
| 167 | sizeof(*t), handle); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 168 | |
Paul Menzel | b4d0757 | 2017-03-12 18:18:06 +0100 | [diff] [blame] | 169 | t->location = MEMORY_ARRAY_LOCATION_SYSTEM_BOARD; |
| 170 | t->use = MEMORY_ARRAY_USE_SYSTEM; |
| 171 | t->memory_error_correction = MEMORY_ARRAY_ECC_NONE; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 172 | t->maximum_capacity = qemu_get_memory_size(); |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 173 | |
Angel Pons | a37701a | 2021-06-28 17:36:53 +0200 | [diff] [blame] | 174 | const int len = smbios_full_table_len(&t->header, t->eos); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 175 | *current += len; |
| 176 | return len; |
| 177 | } |
| 178 | |
| 179 | static int qemu_get_smbios_data17(int handle, int parent_handle, unsigned long *current) |
| 180 | { |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 181 | struct smbios_type17 *t = smbios_carve_table(*current, SMBIOS_MEMORY_DEVICE, |
| 182 | sizeof(*t), handle); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 183 | |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 184 | t->phys_memory_array_handle = parent_handle; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 185 | t->size = qemu_get_memory_size() / 1024; |
| 186 | t->data_width = 64; |
| 187 | t->total_width = 64; |
Elyes HAOUAS | a92acec | 2020-07-19 10:20:55 +0200 | [diff] [blame] | 188 | t->form_factor = MEMORY_FORMFACTOR_DIMM; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 189 | t->device_locator = smbios_add_string(t->eos, "Virtual"); |
Elyes HAOUAS | a92acec | 2020-07-19 10:20:55 +0200 | [diff] [blame] | 190 | t->memory_type = MEMORY_TYPE_DDR; |
| 191 | t->type_detail = MEMORY_TYPE_DETAIL_SYNCHRONOUS; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 192 | t->speed = 200; |
| 193 | t->clock_speed = 200; |
| 194 | t->manufacturer = smbios_add_string(t->eos, CONFIG_MAINBOARD_VENDOR); |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 195 | |
Angel Pons | a37701a | 2021-06-28 17:36:53 +0200 | [diff] [blame] | 196 | const int len = smbios_full_table_len(&t->header, t->eos); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 197 | *current += len; |
| 198 | return len; |
| 199 | } |
| 200 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 201 | static int qemu_get_smbios_data(struct device *dev, int *handle, unsigned long *current) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 202 | { |
| 203 | int len; |
Gerd Hoffmann | db9d169 | 2014-08-27 11:25:13 +0200 | [diff] [blame] | 204 | |
| 205 | len = fw_cfg_smbios_tables(handle, current); |
| 206 | if (len != 0) |
| 207 | return len; |
| 208 | |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 209 | len = qemu_get_smbios_data16(*handle, current); |
| 210 | len += qemu_get_smbios_data17(*handle+1, *handle, current); |
| 211 | *handle += 2; |
| 212 | return len; |
| 213 | } |
| 214 | #endif |
Duncan Laurie | b40e780 | 2020-03-17 18:47:36 -0700 | [diff] [blame] | 215 | |
| 216 | #if CONFIG(HAVE_ACPI_TABLES) |
| 217 | static const char *qemu_acpi_name(const struct device *dev) |
| 218 | { |
| 219 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 220 | return "PCI0"; |
| 221 | |
Fabio Aiuto | 61ed4ef | 2022-09-30 14:55:53 +0200 | [diff] [blame] | 222 | if (!is_pci_dev_on_bus(dev, 0)) |
Duncan Laurie | b40e780 | 2020-03-17 18:47:36 -0700 | [diff] [blame] | 223 | return NULL; |
| 224 | |
| 225 | return NULL; |
| 226 | } |
| 227 | #endif |
| 228 | |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 229 | static struct device_operations pci_domain_ops = { |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 230 | .read_resources = cpu_pci_domain_read_resources, |
| 231 | .set_resources = cpu_pci_domain_set_resources, |
Myles Watson | 032a965 | 2009-05-11 22:24:53 +0000 | [diff] [blame] | 232 | .scan_bus = pci_domain_scan_bus, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 233 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 234 | .get_smbios_data = qemu_get_smbios_data, |
| 235 | #endif |
Duncan Laurie | b40e780 | 2020-03-17 18:47:36 -0700 | [diff] [blame] | 236 | #if CONFIG(HAVE_ACPI_TABLES) |
| 237 | .acpi_name = qemu_acpi_name, |
| 238 | #endif |
Myles Watson | 032a965 | 2009-05-11 22:24:53 +0000 | [diff] [blame] | 239 | }; |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 240 | |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 241 | static const struct mp_ops mp_ops_no_smm = { |
| 242 | .get_cpu_count = fw_cfg_max_cpus, |
| 243 | }; |
| 244 | |
Arthur Heymans | e69d2df | 2020-12-01 18:29:13 +0100 | [diff] [blame] | 245 | extern const struct mp_ops mp_ops_with_smm; |
| 246 | |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 247 | void mp_init_cpus(struct bus *cpu_bus) |
| 248 | { |
Arthur Heymans | 4db2e8e | 2021-10-28 16:48:36 +0200 | [diff] [blame] | 249 | const struct mp_ops *ops = CONFIG(NO_SMM) ? &mp_ops_no_smm : &mp_ops_with_smm; |
Arthur Heymans | e69d2df | 2020-12-01 18:29:13 +0100 | [diff] [blame] | 250 | |
Felix Held | 4dd7d11 | 2021-10-20 23:31:43 +0200 | [diff] [blame] | 251 | /* TODO: Handle mp_init_with_smm failure? */ |
| 252 | mp_init_with_smm(cpu_bus, ops); |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 253 | } |
| 254 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 255 | static void cpu_bus_init(struct device *dev) |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 256 | { |
Arthur Heymans | c8a20b9 | 2022-11-08 06:49:12 +0100 | [diff] [blame] | 257 | mp_cpu_bus_init(dev); |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 258 | } |
| 259 | |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 260 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 261 | .read_resources = noop_read_resources, |
| 262 | .set_resources = noop_set_resources, |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 263 | .init = cpu_bus_init, |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 264 | }; |
| 265 | |
Paul Menzel | 5f20b35 | 2013-02-24 14:27:03 +0100 | [diff] [blame] | 266 | static void northbridge_enable(struct device *dev) |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 267 | { |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 268 | /* Set the operations if it is a special bus type */ |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 269 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 270 | dev->ops = &pci_domain_ops; |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 271 | } |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 272 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 273 | dev->ops = &cpu_bus_ops; |
| 274 | } |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 275 | } |
| 276 | |
Gerd Hoffmann | 00cc7f43 | 2013-06-07 15:46:23 +0200 | [diff] [blame] | 277 | struct chip_operations mainboard_emulation_qemu_i440fx_ops = { |
| 278 | CHIP_NAME("QEMU Northbridge i440fx") |
Paul Menzel | 5f20b35 | 2013-02-24 14:27:03 +0100 | [diff] [blame] | 279 | .enable_dev = northbridge_enable, |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 280 | }; |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 281 | |
| 282 | struct chip_operations mainboard_emulation_qemu_q35_ops = { |
| 283 | CHIP_NAME("QEMU Northbridge q35") |
| 284 | .enable_dev = northbridge_enable, |
| 285 | }; |