Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 1 | #include <console/console.h> |
Eric Biederman | 7003ba4 | 2004-10-16 06:20:29 +0000 | [diff] [blame] | 2 | #include <device/path.h> |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 3 | #include <device/pci_ids.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 4 | #include <cpu/cpu.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 5 | #include <arch/smp/mpspec.h> |
| 6 | #include <string.h> |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 7 | #include <arch/cpu.h> |
| 8 | #include <cpu/x86/lapic.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 9 | |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 10 | /* Initialize the specified "mc" struct with initial values. */ |
Uwe Hermann | c36d506 | 2010-12-16 19:51:38 +0000 | [diff] [blame] | 11 | void mptable_init(struct mp_config_table *mc, u32 lapic_addr) |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 12 | { |
Uwe Hermann | c36d506 | 2010-12-16 19:51:38 +0000 | [diff] [blame] | 13 | int i; |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 14 | |
| 15 | memset(mc, 0, sizeof(*mc)); |
Uwe Hermann | c36d506 | 2010-12-16 19:51:38 +0000 | [diff] [blame] | 16 | |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 17 | memcpy(mc->mpc_signature, MPC_SIGNATURE, 4); |
Uwe Hermann | c36d506 | 2010-12-16 19:51:38 +0000 | [diff] [blame] | 18 | |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 19 | mc->mpc_length = sizeof(*mc); /* Initially just the header size. */ |
| 20 | mc->mpc_spec = 0x04; /* MultiProcessor specification 1.4 */ |
| 21 | mc->mpc_checksum = 0; /* Not yet computed. */ |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 22 | mc->mpc_oemptr = 0; |
| 23 | mc->mpc_oemsize = 0; |
| 24 | mc->mpc_entry_count = 0; /* No entries yet... */ |
| 25 | mc->mpc_lapic = lapic_addr; |
| 26 | mc->mpe_length = 0; |
| 27 | mc->mpe_checksum = 0; |
| 28 | mc->reserved = 0; |
Uwe Hermann | c36d506 | 2010-12-16 19:51:38 +0000 | [diff] [blame] | 29 | |
| 30 | strncpy(mc->mpc_oem, CONFIG_MAINBOARD_VENDOR, 8); |
| 31 | strncpy(mc->mpc_productid, CONFIG_MAINBOARD_PART_NUMBER, 12); |
| 32 | |
| 33 | /* |
| 34 | * The oem/productid fields are exactly 8/12 bytes long. If the resp. |
| 35 | * entry is shorter, the remaining bytes are filled with spaces. |
| 36 | */ |
| 37 | for (i = MIN(strlen(CONFIG_MAINBOARD_VENDOR), 8); i < 8; i++) |
| 38 | mc->mpc_oem[i] = ' '; |
| 39 | for (i = MIN(strlen(CONFIG_MAINBOARD_PART_NUMBER), 12); i < 12; i++) |
| 40 | mc->mpc_productid[i] = ' '; |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 43 | unsigned char smp_compute_checksum(void *v, int len) |
| 44 | { |
| 45 | unsigned char *bytes; |
| 46 | unsigned char checksum; |
| 47 | int i; |
| 48 | bytes = v; |
| 49 | checksum = 0; |
| 50 | for(i = 0; i < len; i++) { |
| 51 | checksum -= bytes[i]; |
| 52 | } |
| 53 | return checksum; |
| 54 | } |
| 55 | |
| 56 | void *smp_write_floating_table(unsigned long addr) |
| 57 | { |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 58 | /* 16 byte align the table address */ |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 59 | addr = (addr + 0xf) & (~0xf); |
Patrick Georgi | e914903 | 2009-04-24 06:27:31 +0000 | [diff] [blame] | 60 | return smp_write_floating_table_physaddr(addr, addr + SMP_FLOATING_TABLE_LEN); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Stefan Reinauer | 4f1cb23 | 2006-07-19 15:32:49 +0000 | [diff] [blame] | 63 | void *smp_write_floating_table_physaddr(unsigned long addr, unsigned long mpf_physptr) |
| 64 | { |
| 65 | struct intel_mp_floating *mf; |
| 66 | void *v; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 67 | |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 68 | v = (void *)addr; |
Stefan Reinauer | 4f1cb23 | 2006-07-19 15:32:49 +0000 | [diff] [blame] | 69 | mf = v; |
| 70 | mf->mpf_signature[0] = '_'; |
| 71 | mf->mpf_signature[1] = 'M'; |
| 72 | mf->mpf_signature[2] = 'P'; |
| 73 | mf->mpf_signature[3] = '_'; |
| 74 | mf->mpf_physptr = mpf_physptr; |
| 75 | mf->mpf_length = 1; |
| 76 | mf->mpf_specification = 4; |
| 77 | mf->mpf_checksum = 0; |
| 78 | mf->mpf_feature1 = 0; |
| 79 | mf->mpf_feature2 = 0; |
| 80 | mf->mpf_feature3 = 0; |
| 81 | mf->mpf_feature4 = 0; |
| 82 | mf->mpf_feature5 = 0; |
| 83 | mf->mpf_checksum = smp_compute_checksum(mf, mf->mpf_length*16); |
| 84 | return v; |
| 85 | } |
| 86 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 87 | void *smp_next_mpc_entry(struct mp_config_table *mc) |
| 88 | { |
| 89 | void *v; |
| 90 | v = (void *)(((char *)mc) + mc->mpc_length); |
| 91 | return v; |
| 92 | } |
| 93 | static void smp_add_mpc_entry(struct mp_config_table *mc, unsigned length) |
| 94 | { |
| 95 | mc->mpc_length += length; |
| 96 | mc->mpc_entry_count++; |
| 97 | } |
| 98 | |
| 99 | void *smp_next_mpe_entry(struct mp_config_table *mc) |
| 100 | { |
| 101 | void *v; |
| 102 | v = (void *)(((char *)mc) + mc->mpc_length + mc->mpe_length); |
| 103 | return v; |
| 104 | } |
| 105 | static void smp_add_mpe_entry(struct mp_config_table *mc, mpe_t mpe) |
| 106 | { |
| 107 | mc->mpe_length += mpe->mpe_length; |
| 108 | } |
| 109 | |
| 110 | void smp_write_processor(struct mp_config_table *mc, |
| 111 | unsigned char apicid, unsigned char apicver, |
| 112 | unsigned char cpuflag, unsigned int cpufeature, |
| 113 | unsigned int featureflag) |
| 114 | { |
| 115 | struct mpc_config_processor *mpc; |
| 116 | mpc = smp_next_mpc_entry(mc); |
| 117 | memset(mpc, '\0', sizeof(*mpc)); |
| 118 | mpc->mpc_type = MP_PROCESSOR; |
| 119 | mpc->mpc_apicid = apicid; |
| 120 | mpc->mpc_apicver = apicver; |
| 121 | mpc->mpc_cpuflag = cpuflag; |
| 122 | mpc->mpc_cpufeature = cpufeature; |
| 123 | mpc->mpc_featureflag = featureflag; |
| 124 | smp_add_mpc_entry(mc, sizeof(*mpc)); |
| 125 | } |
| 126 | |
| 127 | /* If we assume a symmetric processor configuration we can |
| 128 | * get all of the information we need to write the processor |
| 129 | * entry from the bootstrap processor. |
| 130 | * Plus I don't think linux really even cares. |
| 131 | * Having the proper apicid's in the table so the non-bootstrap |
| 132 | * processors can be woken up should be enough. |
| 133 | */ |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 134 | void smp_write_processors(struct mp_config_table *mc) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 135 | { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 136 | int boot_apic_id; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 137 | unsigned apic_version; |
| 138 | unsigned cpu_features; |
| 139 | unsigned cpu_feature_flags; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 140 | struct cpuid_result result; |
| 141 | device_t cpu; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 142 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 143 | boot_apic_id = lapicid(); |
| 144 | apic_version = lapic_read(LAPIC_LVR) & 0xff; |
| 145 | result = cpuid(1); |
| 146 | cpu_features = result.eax; |
| 147 | cpu_feature_flags = result.edx; |
Eric Biederman | 7003ba4 | 2004-10-16 06:20:29 +0000 | [diff] [blame] | 148 | for(cpu = all_devices; cpu; cpu = cpu->next) { |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 149 | unsigned long cpu_flag; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 150 | if ((cpu->path.type != DEVICE_PATH_APIC) || |
Eric Biederman | 7003ba4 | 2004-10-16 06:20:29 +0000 | [diff] [blame] | 151 | (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER)) |
| 152 | { |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 153 | continue; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 154 | } |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 155 | if (!cpu->enabled) { |
| 156 | continue; |
| 157 | } |
| 158 | cpu_flag = MPC_CPU_ENABLED; |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 159 | if (boot_apic_id == cpu->path.apic.apic_id) { |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 160 | cpu_flag = MPC_CPU_ENABLED | MPC_CPU_BOOTPROCESSOR; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 161 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 162 | smp_write_processor(mc, |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 163 | cpu->path.apic.apic_id, apic_version, |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 164 | cpu_flag, cpu_features, cpu_feature_flags |
| 165 | ); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
Patrick Georgi patrick | 612fcc3 | 2010-11-23 07:19:54 +0000 | [diff] [blame] | 169 | static void smp_write_bus(struct mp_config_table *mc, |
Myles Watson | 6e23576 | 2009-09-29 14:56:15 +0000 | [diff] [blame] | 170 | unsigned char id, const char *bustype) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 171 | { |
| 172 | struct mpc_config_bus *mpc; |
| 173 | mpc = smp_next_mpc_entry(mc); |
| 174 | memset(mpc, '\0', sizeof(*mpc)); |
| 175 | mpc->mpc_type = MP_BUS; |
| 176 | mpc->mpc_busid = id; |
| 177 | memcpy(mpc->mpc_bustype, bustype, sizeof(mpc->mpc_bustype)); |
| 178 | smp_add_mpc_entry(mc, sizeof(*mpc)); |
| 179 | } |
| 180 | |
| 181 | void smp_write_ioapic(struct mp_config_table *mc, |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 182 | unsigned char id, unsigned char ver, |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 183 | unsigned long apicaddr) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 184 | { |
| 185 | struct mpc_config_ioapic *mpc; |
| 186 | mpc = smp_next_mpc_entry(mc); |
| 187 | memset(mpc, '\0', sizeof(*mpc)); |
| 188 | mpc->mpc_type = MP_IOAPIC; |
| 189 | mpc->mpc_apicid = id; |
| 190 | mpc->mpc_apicver = ver; |
| 191 | mpc->mpc_flags = MPC_APIC_USABLE; |
| 192 | mpc->mpc_apicaddr = apicaddr; |
| 193 | smp_add_mpc_entry(mc, sizeof(*mpc)); |
| 194 | } |
| 195 | |
| 196 | void smp_write_intsrc(struct mp_config_table *mc, |
| 197 | unsigned char irqtype, unsigned short irqflag, |
| 198 | unsigned char srcbus, unsigned char srcbusirq, |
| 199 | unsigned char dstapic, unsigned char dstirq) |
| 200 | { |
| 201 | struct mpc_config_intsrc *mpc; |
| 202 | mpc = smp_next_mpc_entry(mc); |
| 203 | memset(mpc, '\0', sizeof(*mpc)); |
| 204 | mpc->mpc_type = MP_INTSRC; |
| 205 | mpc->mpc_irqtype = irqtype; |
| 206 | mpc->mpc_irqflag = irqflag; |
| 207 | mpc->mpc_srcbus = srcbus; |
| 208 | mpc->mpc_srcbusirq = srcbusirq; |
| 209 | mpc->mpc_dstapic = dstapic; |
| 210 | mpc->mpc_dstirq = dstirq; |
| 211 | smp_add_mpc_entry(mc, sizeof(*mpc)); |
Stefan Reinauer | 5bba752 | 2009-04-21 23:00:14 +0000 | [diff] [blame] | 212 | #ifdef DEBUG_MPTABLE |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 213 | printk(BIOS_DEBUG, "add intsrc srcbus 0x%x srcbusirq 0x%x, dstapic 0x%x, dstirq 0x%x\n", |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 214 | srcbus, srcbusirq, dstapic, dstirq); |
Myles Watson | 552b327 | 2009-02-12 21:30:06 +0000 | [diff] [blame] | 215 | hexdump(__func__, mpc, sizeof(*mpc)); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 216 | #endif |
| 217 | } |
| 218 | |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 219 | void smp_write_intsrc_pci_bridge(struct mp_config_table *mc, |
| 220 | unsigned char irqtype, unsigned short irqflag, |
| 221 | struct device *dev, |
| 222 | unsigned char dstapic, unsigned char *dstirq) |
| 223 | { |
| 224 | struct device *child; |
| 225 | |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 226 | int i; |
| 227 | int srcbus; |
| 228 | int slot; |
| 229 | |
| 230 | struct bus *link; |
| 231 | unsigned char dstirq_x[4]; |
| 232 | |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 233 | for (link = dev->link_list; link; link = link->next) { |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 234 | |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 235 | child = link->children; |
| 236 | srcbus = link->secondary; |
| 237 | |
| 238 | while (child) { |
| 239 | if (child->path.type != DEVICE_PATH_PCI) |
| 240 | goto next; |
| 241 | |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 242 | slot = (child->path.pci.devfn >> 3); |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 243 | /* round pins */ |
| 244 | for (i = 0; i < 4; i++) |
| 245 | dstirq_x[i] = dstirq[(i + slot) % 4]; |
| 246 | |
| 247 | if ((child->class >> 16) != PCI_BASE_CLASS_BRIDGE) { |
| 248 | /* pci device */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 249 | printk(BIOS_DEBUG, "route irq: %s\n", dev_path(child)); |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 250 | for (i = 0; i < 4; i++) |
| 251 | smp_write_intsrc(mc, irqtype, irqflag, srcbus, (slot<<2)|i, dstapic, dstirq_x[i]); |
| 252 | goto next; |
| 253 | } |
| 254 | |
| 255 | switch (child->class>>8) { |
| 256 | case PCI_CLASS_BRIDGE_PCI: |
| 257 | case PCI_CLASS_BRIDGE_PCMCIA: |
| 258 | case PCI_CLASS_BRIDGE_CARDBUS: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 259 | printk(BIOS_DEBUG, "route irq bridge: %s\n", dev_path(child)); |
Yinghai Lu | f327d9f | 2008-02-20 17:41:38 +0000 | [diff] [blame] | 260 | smp_write_intsrc_pci_bridge(mc, irqtype, irqflag, child, dstapic, dstirq_x); |
| 261 | } |
| 262 | |
| 263 | next: |
| 264 | child = child->sibling; |
| 265 | } |
| 266 | |
| 267 | } |
| 268 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 269 | |
| 270 | void smp_write_lintsrc(struct mp_config_table *mc, |
| 271 | unsigned char irqtype, unsigned short irqflag, |
| 272 | unsigned char srcbusid, unsigned char srcbusirq, |
| 273 | unsigned char destapic, unsigned char destapiclint) |
| 274 | { |
| 275 | struct mpc_config_lintsrc *mpc; |
| 276 | mpc = smp_next_mpc_entry(mc); |
| 277 | memset(mpc, '\0', sizeof(*mpc)); |
| 278 | mpc->mpc_type = MP_LINTSRC; |
| 279 | mpc->mpc_irqtype = irqtype; |
| 280 | mpc->mpc_irqflag = irqflag; |
| 281 | mpc->mpc_srcbusid = srcbusid; |
| 282 | mpc->mpc_srcbusirq = srcbusirq; |
| 283 | mpc->mpc_destapic = destapic; |
| 284 | mpc->mpc_destapiclint = destapiclint; |
| 285 | smp_add_mpc_entry(mc, sizeof(*mpc)); |
| 286 | } |
| 287 | |
| 288 | void smp_write_address_space(struct mp_config_table *mc, |
| 289 | unsigned char busid, unsigned char address_type, |
| 290 | unsigned int address_base_low, unsigned int address_base_high, |
| 291 | unsigned int address_length_low, unsigned int address_length_high) |
| 292 | { |
| 293 | struct mp_exten_system_address_space *mpe; |
| 294 | mpe = smp_next_mpe_entry(mc); |
| 295 | memset(mpe, '\0', sizeof(*mpe)); |
| 296 | mpe->mpe_type = MPE_SYSTEM_ADDRESS_SPACE; |
| 297 | mpe->mpe_length = sizeof(*mpe); |
| 298 | mpe->mpe_busid = busid; |
| 299 | mpe->mpe_address_type = address_type; |
| 300 | mpe->mpe_address_base_low = address_base_low; |
| 301 | mpe->mpe_address_base_high = address_base_high; |
| 302 | mpe->mpe_address_length_low = address_length_low; |
| 303 | mpe->mpe_address_length_high = address_length_high; |
| 304 | smp_add_mpe_entry(mc, (mpe_t)mpe); |
| 305 | } |
| 306 | |
| 307 | |
| 308 | void smp_write_bus_hierarchy(struct mp_config_table *mc, |
| 309 | unsigned char busid, unsigned char bus_info, |
| 310 | unsigned char parent_busid) |
| 311 | { |
| 312 | struct mp_exten_bus_hierarchy *mpe; |
| 313 | mpe = smp_next_mpe_entry(mc); |
| 314 | memset(mpe, '\0', sizeof(*mpe)); |
| 315 | mpe->mpe_type = MPE_BUS_HIERARCHY; |
| 316 | mpe->mpe_length = sizeof(*mpe); |
| 317 | mpe->mpe_busid = busid; |
| 318 | mpe->mpe_bus_info = bus_info; |
| 319 | mpe->mpe_parent_busid = parent_busid; |
| 320 | smp_add_mpe_entry(mc, (mpe_t)mpe); |
| 321 | } |
| 322 | |
| 323 | void smp_write_compatibility_address_space(struct mp_config_table *mc, |
| 324 | unsigned char busid, unsigned char address_modifier, |
| 325 | unsigned int range_list) |
| 326 | { |
| 327 | struct mp_exten_compatibility_address_space *mpe; |
| 328 | mpe = smp_next_mpe_entry(mc); |
| 329 | memset(mpe, '\0', sizeof(*mpe)); |
| 330 | mpe->mpe_type = MPE_COMPATIBILITY_ADDRESS_SPACE; |
| 331 | mpe->mpe_length = sizeof(*mpe); |
| 332 | mpe->mpe_busid = busid; |
| 333 | mpe->mpe_address_modifier = address_modifier; |
| 334 | mpe->mpe_range_list = range_list; |
| 335 | smp_add_mpe_entry(mc, (mpe_t)mpe); |
| 336 | } |
| 337 | |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame^] | 338 | void mptable_lintsrc(struct mp_config_table *mc, unsigned long bus_isa) |
| 339 | { |
| 340 | smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x0); |
| 341 | smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x1); |
| 342 | } |
| 343 | |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 344 | void mptable_add_isa_interrupts(struct mp_config_table *mc, unsigned long bus_isa, unsigned long apicid, int external_int2) |
| 345 | { |
| 346 | /*I/O Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */ |
| 347 | smp_write_intsrc(mc, external_int2?mp_INT:mp_ExtINT, |
| 348 | MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, apicid, 0x0); |
| 349 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x1, apicid, 0x1); |
| 350 | smp_write_intsrc(mc, external_int2?mp_ExtINT:mp_INT, |
| 351 | MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, apicid, 0x2); |
| 352 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x3, apicid, 0x3); |
| 353 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x4, apicid, 0x4); |
| 354 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x6, apicid, 0x6); |
| 355 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x7, apicid, 0x7); |
| 356 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x8, apicid, 0x8); |
| 357 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x9, apicid, 0x9); |
| 358 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xa, apicid, 0xa); |
| 359 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xb, apicid, 0xb); |
| 360 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xc, apicid, 0xc); |
| 361 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xd, apicid, 0xd); |
| 362 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xe, apicid, 0xe); |
| 363 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xf, apicid, 0xf); |
| 364 | } |
Patrick Georgi | ab27266 | 2010-06-25 13:43:22 +0000 | [diff] [blame] | 365 | |
| 366 | void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, int *isa_bus) { |
| 367 | int dummy, i, highest; |
| 368 | char buses[256]; |
| 369 | struct device *dev; |
| 370 | |
| 371 | if (!max_pci_bus) max_pci_bus = &dummy; |
| 372 | if (!isa_bus) isa_bus = &dummy; |
| 373 | |
| 374 | *max_pci_bus = 0; |
| 375 | highest = 0; |
| 376 | memset(buses, 0, sizeof(buses)); |
| 377 | |
| 378 | for (dev = all_devices; dev; dev = dev->next) { |
| 379 | struct bus *bus; |
| 380 | for (bus = dev->link_list; bus; bus = bus->next) { |
| 381 | if (bus->secondary > 255) { |
| 382 | printk(BIOS_ERR, "A bus claims to have a bus ID > 255?!? Aborting"); |
| 383 | return; |
| 384 | } |
| 385 | buses[bus->secondary] = 1; |
| 386 | if (highest < bus->secondary) highest = bus->secondary; |
| 387 | } |
| 388 | } |
| 389 | for (i=0; i <= highest; i++) { |
| 390 | if (buses[i]) { |
| 391 | smp_write_bus(mc, i, "PCI "); |
| 392 | *max_pci_bus = i; |
| 393 | } |
| 394 | } |
| 395 | *isa_bus = *max_pci_bus + 1; |
| 396 | smp_write_bus(mc, *isa_bus, "ISA "); |
| 397 | } |
| 398 | |