Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 2 | * Intel Multiprocessor Specification 1.1 and 1.4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * compliant MP-table parsing routines. |
| 4 | * |
| 5 | * (c) 1995 Alan Cox, Building #3 <alan@redhat.com> |
| 6 | * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 7 | * (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/bootmem.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kernel_stat.h> |
| 15 | #include <linux/mc146818rtc.h> |
| 16 | #include <linux/bitops.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 17 | #include <linux/acpi.h> |
| 18 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #include <asm/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/mtrr.h> |
| 22 | #include <asm/mpspec.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 23 | #include <asm/pgalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <asm/io_apic.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 25 | #include <asm/proto.h> |
| 26 | #include <asm/acpi.h> |
Alexey Starikovskiy | ce3fe6b | 2008-03-17 22:08:17 +0300 | [diff] [blame] | 27 | #include <asm/bios_ebda.h> |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 28 | #include <asm/e820.h> |
| 29 | #include <asm/trampoline.h> |
Yinghai Lu | 3c9cb6d | 2008-07-19 02:07:25 -0700 | [diff] [blame] | 30 | #include <asm/setup.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | #include <mach_apic.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 33 | #ifdef CONFIG_X86_32 |
Andi Kleen | 874c4fe | 2006-09-26 10:52:26 +0200 | [diff] [blame] | 34 | #include <mach_apicdef.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <mach_mpparse.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 36 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | * Checksum an MP configuration block. |
| 40 | */ |
| 41 | |
| 42 | static int __init mpf_checksum(unsigned char *mp, int len) |
| 43 | { |
| 44 | int sum = 0; |
| 45 | |
| 46 | while (len--) |
| 47 | sum += *mp++; |
| 48 | |
| 49 | return sum & 0xFF; |
| 50 | } |
| 51 | |
Marcin Slusarz | 67d0c9e | 2008-08-11 00:12:37 +0200 | [diff] [blame] | 52 | static void __init MP_processor_info(struct mpc_config_processor *m) |
Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 53 | { |
| 54 | int apicid; |
Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 55 | char *bootup_cpu = ""; |
Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 56 | |
Glauber Costa | 7b1292e | 2008-03-03 14:12:41 -0300 | [diff] [blame] | 57 | if (!(m->mpc_cpuflag & CPU_ENABLED)) { |
| 58 | disabled_cpus++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | return; |
Glauber Costa | 7b1292e | 2008-03-03 14:12:41 -0300 | [diff] [blame] | 60 | } |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 61 | |
| 62 | if (x86_quirks->mpc_apic_id) |
| 63 | apicid = x86_quirks->mpc_apic_id(m); |
Yinghai Lu | ab530e1 | 2008-06-03 10:25:54 -0700 | [diff] [blame] | 64 | else |
| 65 | apicid = m->mpc_apicid; |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { |
Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 68 | bootup_cpu = " (Bootup-CPU)"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | boot_cpu_physical_apicid = m->mpc_apicid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 72 | printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu); |
Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 73 | generic_processor_info(apicid, m->mpc_apicver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 76 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 77 | static void __init MP_bus_info(struct mpc_config_bus *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
| 79 | char str[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | memcpy(str, m->mpc_bustype, 6); |
| 81 | str[6] = 0; |
| 82 | |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 83 | if (x86_quirks->mpc_oem_bus_info) |
| 84 | x86_quirks->mpc_oem_bus_info(m, str); |
| 85 | else |
Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 86 | apic_printk(APIC_VERBOSE, "Bus #%d is %s\n", m->mpc_busid, str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Andi Kleen | 5e4edbb | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 88 | #if MAX_MP_BUSSES < 256 |
Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 89 | if (m->mpc_busid >= MAX_MP_BUSSES) { |
| 90 | printk(KERN_WARNING "MP table busid value (%d) for bustype %s " |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 91 | " is too large, max. supported is %d\n", |
| 92 | m->mpc_busid, str, MAX_MP_BUSSES - 1); |
Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 93 | return; |
| 94 | } |
Andi Kleen | 5e4edbb | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 95 | #endif |
Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 96 | |
Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 97 | if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) { |
| 98 | set_bit(m->mpc_busid, mp_bus_not_pci); |
| 99 | #if defined(CONFIG_EISA) || defined (CONFIG_MCA) |
| 100 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA; |
| 101 | #endif |
| 102 | } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) { |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 103 | if (x86_quirks->mpc_oem_pci_bus) |
| 104 | x86_quirks->mpc_oem_pci_bus(m); |
| 105 | |
Alexey Starikovskiy | a6333c3 | 2008-03-20 14:54:09 +0300 | [diff] [blame] | 106 | clear_bit(m->mpc_busid, mp_bus_not_pci); |
Alexey Starikovskiy | c0a282c | 2008-03-20 14:55:02 +0300 | [diff] [blame] | 107 | #if defined(CONFIG_EISA) || defined (CONFIG_MCA) |
| 108 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 109 | } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) { |
Alexey Starikovskiy | 9e0a2de | 2008-03-20 14:54:56 +0300 | [diff] [blame] | 110 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 111 | } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA; |
Alexey Starikovskiy | c0a282c | 2008-03-20 14:55:02 +0300 | [diff] [blame] | 113 | #endif |
Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 114 | } else |
| 115 | printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 117 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 119 | #ifdef CONFIG_X86_IO_APIC |
| 120 | |
Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 121 | static int bad_ioapic(unsigned long address) |
| 122 | { |
| 123 | if (nr_ioapics >= MAX_IO_APICS) { |
| 124 | printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " |
| 125 | "(found %d)\n", MAX_IO_APICS, nr_ioapics); |
| 126 | panic("Recompile kernel with bigger MAX_IO_APICS!\n"); |
| 127 | } |
| 128 | if (!address) { |
| 129 | printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address" |
| 130 | " found in table, skipping!\n"); |
| 131 | return 1; |
| 132 | } |
| 133 | return 0; |
| 134 | } |
| 135 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 136 | static void __init MP_ioapic_info(struct mpc_config_ioapic *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
| 138 | if (!(m->mpc_flags & MPC_APIC_USABLE)) |
| 139 | return; |
| 140 | |
Thomas Gleixner | 64883ab | 2008-01-30 13:30:35 +0100 | [diff] [blame] | 141 | printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 142 | m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr); |
Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 143 | |
| 144 | if (bad_ioapic(m->mpc_apicaddr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | return; |
Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 146 | |
Alexey Starikovskiy | ec2cd0a | 2008-05-14 19:03:10 +0400 | [diff] [blame] | 147 | mp_ioapics[nr_ioapics].mp_apicaddr = m->mpc_apicaddr; |
| 148 | mp_ioapics[nr_ioapics].mp_apicid = m->mpc_apicid; |
| 149 | mp_ioapics[nr_ioapics].mp_type = m->mpc_type; |
| 150 | mp_ioapics[nr_ioapics].mp_apicver = m->mpc_apicver; |
| 151 | mp_ioapics[nr_ioapics].mp_flags = m->mpc_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | nr_ioapics++; |
| 153 | } |
| 154 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 155 | static void print_MP_intsrc_info(struct mpc_config_intsrc *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | { |
Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 157 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 159 | m->mpc_irqtype, m->mpc_irqflag & 3, |
| 160 | (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus, |
| 161 | m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq); |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq) |
| 165 | { |
Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 166 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 167 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", |
| 168 | mp_irq->mp_irqtype, mp_irq->mp_irqflag & 3, |
| 169 | (mp_irq->mp_irqflag >> 2) & 3, mp_irq->mp_srcbus, |
| 170 | mp_irq->mp_srcbusirq, mp_irq->mp_dstapic, mp_irq->mp_dstirq); |
| 171 | } |
| 172 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 173 | static void __init assign_to_mp_irq(struct mpc_config_intsrc *m, |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 174 | struct mp_config_intsrc *mp_irq) |
| 175 | { |
| 176 | mp_irq->mp_dstapic = m->mpc_dstapic; |
| 177 | mp_irq->mp_type = m->mpc_type; |
| 178 | mp_irq->mp_irqtype = m->mpc_irqtype; |
| 179 | mp_irq->mp_irqflag = m->mpc_irqflag; |
| 180 | mp_irq->mp_srcbus = m->mpc_srcbus; |
| 181 | mp_irq->mp_srcbusirq = m->mpc_srcbusirq; |
| 182 | mp_irq->mp_dstirq = m->mpc_dstirq; |
| 183 | } |
| 184 | |
| 185 | static void __init assign_to_mpc_intsrc(struct mp_config_intsrc *mp_irq, |
| 186 | struct mpc_config_intsrc *m) |
| 187 | { |
| 188 | m->mpc_dstapic = mp_irq->mp_dstapic; |
| 189 | m->mpc_type = mp_irq->mp_type; |
| 190 | m->mpc_irqtype = mp_irq->mp_irqtype; |
| 191 | m->mpc_irqflag = mp_irq->mp_irqflag; |
| 192 | m->mpc_srcbus = mp_irq->mp_srcbus; |
| 193 | m->mpc_srcbusirq = mp_irq->mp_srcbusirq; |
| 194 | m->mpc_dstirq = mp_irq->mp_dstirq; |
| 195 | } |
| 196 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 197 | static int __init mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc *mp_irq, |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 198 | struct mpc_config_intsrc *m) |
| 199 | { |
| 200 | if (mp_irq->mp_dstapic != m->mpc_dstapic) |
| 201 | return 1; |
| 202 | if (mp_irq->mp_type != m->mpc_type) |
| 203 | return 2; |
| 204 | if (mp_irq->mp_irqtype != m->mpc_irqtype) |
| 205 | return 3; |
| 206 | if (mp_irq->mp_irqflag != m->mpc_irqflag) |
| 207 | return 4; |
| 208 | if (mp_irq->mp_srcbus != m->mpc_srcbus) |
| 209 | return 5; |
| 210 | if (mp_irq->mp_srcbusirq != m->mpc_srcbusirq) |
| 211 | return 6; |
| 212 | if (mp_irq->mp_dstirq != m->mpc_dstirq) |
| 213 | return 7; |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 218 | static void __init MP_intsrc_info(struct mpc_config_intsrc *m) |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 219 | { |
| 220 | int i; |
| 221 | |
| 222 | print_MP_intsrc_info(m); |
| 223 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 224 | for (i = 0; i < mp_irq_entries; i++) { |
| 225 | if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) |
| 226 | return; |
| 227 | } |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 228 | |
| 229 | assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | if (++mp_irq_entries == MAX_IRQ_SOURCES) |
| 231 | panic("Max # of irq sources exceeded!!\n"); |
| 232 | } |
| 233 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 234 | #endif |
| 235 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 236 | static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | { |
Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 238 | apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x," |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | " IRQ %02x, APIC ID %x, APIC LINT %02x\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 240 | m->mpc_irqtype, m->mpc_irqflag & 3, |
| 241 | (m->mpc_irqflag >> 2) & 3, m->mpc_srcbusid, |
| 242 | m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | /* |
| 246 | * Read/parse the MPC |
| 247 | */ |
| 248 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 249 | static int __init smp_check_mpc(struct mp_config_table *mpc, char *oem, |
| 250 | char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 253 | if (memcmp(mpc->mpc_signature, MPC_SIGNATURE, 4)) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 254 | printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n", |
| 255 | mpc->mpc_signature[0], mpc->mpc_signature[1], |
| 256 | mpc->mpc_signature[2], mpc->mpc_signature[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | return 0; |
| 258 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 259 | if (mpf_checksum((unsigned char *)mpc, mpc->mpc_length)) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 260 | printk(KERN_ERR "MPTABLE: checksum error!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | return 0; |
| 262 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 263 | if (mpc->mpc_spec != 0x01 && mpc->mpc_spec != 0x04) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 264 | printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 265 | mpc->mpc_spec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | return 0; |
| 267 | } |
| 268 | if (!mpc->mpc_lapic) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 269 | printk(KERN_ERR "MPTABLE: null local APIC address!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | return 0; |
| 271 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 272 | memcpy(oem, mpc->mpc_oem, 8); |
| 273 | oem[8] = 0; |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 274 | printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 276 | memcpy(str, mpc->mpc_productid, 12); |
| 277 | str[12] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 279 | printk(KERN_INFO "MPTABLE: Product ID: %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 281 | printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 283 | return 1; |
| 284 | } |
| 285 | |
| 286 | static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early) |
| 287 | { |
| 288 | char str[16]; |
| 289 | char oem[10]; |
| 290 | |
| 291 | int count = sizeof(*mpc); |
| 292 | unsigned char *mpt = ((unsigned char *)mpc) + count; |
| 293 | |
| 294 | if (!smp_check_mpc(mpc, oem, str)) |
| 295 | return 0; |
| 296 | |
| 297 | #ifdef CONFIG_X86_32 |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 298 | /* |
| 299 | * need to make sure summit and es7000's mps_oem_check is safe to be |
| 300 | * called early via genericarch 's mps_oem_check |
| 301 | */ |
| 302 | if (early) { |
| 303 | #ifdef CONFIG_X86_NUMAQ |
| 304 | numaq_mps_oem_check(mpc, oem, str); |
| 305 | #endif |
| 306 | } else |
| 307 | mps_oem_check(mpc, oem, str); |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 308 | #endif |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 309 | /* save the local APIC address, it might be non-default */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | if (!acpi_lapic) |
| 311 | mp_lapic_addr = mpc->mpc_lapic; |
| 312 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 313 | if (early) |
| 314 | return 1; |
| 315 | |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 316 | if (mpc->mpc_oemptr && x86_quirks->smp_read_mpc_oem) { |
| 317 | struct mp_config_oemtable *oem_table = (struct mp_config_oemtable *)(unsigned long)mpc->mpc_oemptr; |
| 318 | x86_quirks->smp_read_mpc_oem(oem_table, mpc->mpc_oemsize); |
| 319 | } |
| 320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | /* |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 322 | * Now process the configuration blocks. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | */ |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 324 | if (x86_quirks->mpc_record) |
| 325 | *x86_quirks->mpc_record = 0; |
| 326 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | while (count < mpc->mpc_length) { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 328 | switch (*mpt) { |
| 329 | case MP_PROCESSOR: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 331 | struct mpc_config_processor *m = |
| 332 | (struct mpc_config_processor *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | /* ACPI may have already provided this data */ |
| 334 | if (!acpi_lapic) |
| 335 | MP_processor_info(m); |
| 336 | mpt += sizeof(*m); |
| 337 | count += sizeof(*m); |
| 338 | break; |
| 339 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 340 | case MP_BUS: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 342 | struct mpc_config_bus *m = |
| 343 | (struct mpc_config_bus *)mpt; |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 344 | #ifdef CONFIG_X86_IO_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | MP_bus_info(m); |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 346 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | mpt += sizeof(*m); |
| 348 | count += sizeof(*m); |
| 349 | break; |
| 350 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 351 | case MP_IOAPIC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | { |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 353 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 354 | struct mpc_config_ioapic *m = |
| 355 | (struct mpc_config_ioapic *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | MP_ioapic_info(m); |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 357 | #endif |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 358 | mpt += sizeof(struct mpc_config_ioapic); |
| 359 | count += sizeof(struct mpc_config_ioapic); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | break; |
| 361 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 362 | case MP_INTSRC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | { |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 364 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 365 | struct mpc_config_intsrc *m = |
| 366 | (struct mpc_config_intsrc *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
| 368 | MP_intsrc_info(m); |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 369 | #endif |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 370 | mpt += sizeof(struct mpc_config_intsrc); |
| 371 | count += sizeof(struct mpc_config_intsrc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | break; |
| 373 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 374 | case MP_LINTSRC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 376 | struct mpc_config_lintsrc *m = |
| 377 | (struct mpc_config_lintsrc *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | MP_lintsrc_info(m); |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 379 | mpt += sizeof(*m); |
| 380 | count += sizeof(*m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | break; |
| 382 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 383 | default: |
Yinghai Lu | 711554d | 2008-04-07 11:36:39 -0700 | [diff] [blame] | 384 | /* wrong mptable */ |
| 385 | printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n"); |
| 386 | printk(KERN_ERR "type %x\n", *mpt); |
| 387 | print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16, |
| 388 | 1, mpc, mpc->mpc_length, 1); |
| 389 | count = mpc->mpc_length; |
| 390 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 392 | if (x86_quirks->mpc_record) |
| 393 | (*x86_quirks->mpc_record)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | } |
Yinghai Lu | e0da336 | 2008-06-08 18:29:22 -0700 | [diff] [blame] | 395 | |
| 396 | #ifdef CONFIG_X86_GENERICARCH |
| 397 | generic_bigsmp_probe(); |
| 398 | #endif |
| 399 | |
Ingo Molnar | 3c43f03 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 400 | setup_apic_routing(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | if (!num_processors) |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 402 | printk(KERN_ERR "MPTABLE: no processors registered!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | return num_processors; |
| 404 | } |
| 405 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 406 | #ifdef CONFIG_X86_IO_APIC |
| 407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | static int __init ELCR_trigger(unsigned int irq) |
| 409 | { |
| 410 | unsigned int port; |
| 411 | |
| 412 | port = 0x4d0 + (irq >> 3); |
| 413 | return (inb(port) >> (irq & 7)) & 1; |
| 414 | } |
| 415 | |
| 416 | static void __init construct_default_ioirq_mptable(int mpc_default_type) |
| 417 | { |
| 418 | struct mpc_config_intsrc intsrc; |
| 419 | int i; |
| 420 | int ELCR_fallback = 0; |
| 421 | |
| 422 | intsrc.mpc_type = MP_INTSRC; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 423 | intsrc.mpc_irqflag = 0; /* conforming */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | intsrc.mpc_srcbus = 0; |
Alexey Starikovskiy | ec2cd0a | 2008-05-14 19:03:10 +0400 | [diff] [blame] | 425 | intsrc.mpc_dstapic = mp_ioapics[0].mp_apicid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
| 427 | intsrc.mpc_irqtype = mp_INT; |
| 428 | |
| 429 | /* |
| 430 | * If true, we have an ISA/PCI system with no IRQ entries |
| 431 | * in the MP table. To prevent the PCI interrupts from being set up |
| 432 | * incorrectly, we try to use the ELCR. The sanity check to see if |
| 433 | * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can |
| 434 | * never be level sensitive, so we simply see if the ELCR agrees. |
| 435 | * If it does, we assume it's valid. |
| 436 | */ |
| 437 | if (mpc_default_type == 5) { |
Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 438 | printk(KERN_INFO "ISA/PCI bus type with no IRQ information... " |
| 439 | "falling back to ELCR\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 441 | if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || |
| 442 | ELCR_trigger(13)) |
| 443 | printk(KERN_ERR "ELCR contains invalid data... " |
| 444 | "not using ELCR\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | else { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 446 | printk(KERN_INFO |
| 447 | "Using ELCR to identify PCI interrupts\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | ELCR_fallback = 1; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | for (i = 0; i < 16; i++) { |
| 453 | switch (mpc_default_type) { |
| 454 | case 2: |
| 455 | if (i == 0 || i == 13) |
| 456 | continue; /* IRQ0 & IRQ13 not connected */ |
| 457 | /* fall through */ |
| 458 | default: |
| 459 | if (i == 2) |
| 460 | continue; /* IRQ2 is never connected */ |
| 461 | } |
| 462 | |
| 463 | if (ELCR_fallback) { |
| 464 | /* |
| 465 | * If the ELCR indicates a level-sensitive interrupt, we |
| 466 | * copy that information over to the MP table in the |
| 467 | * irqflag field (level sensitive, active high polarity). |
| 468 | */ |
| 469 | if (ELCR_trigger(i)) |
| 470 | intsrc.mpc_irqflag = 13; |
| 471 | else |
| 472 | intsrc.mpc_irqflag = 0; |
| 473 | } |
| 474 | |
| 475 | intsrc.mpc_srcbusirq = i; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 476 | intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | MP_intsrc_info(&intsrc); |
| 478 | } |
| 479 | |
| 480 | intsrc.mpc_irqtype = mp_ExtINT; |
| 481 | intsrc.mpc_srcbusirq = 0; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 482 | intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | MP_intsrc_info(&intsrc); |
| 484 | } |
| 485 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 486 | |
Marcin Slusarz | 39e00fe | 2008-08-11 00:09:38 +0200 | [diff] [blame^] | 487 | static void __init construct_ioapic_table(int mpc_default_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | struct mpc_config_ioapic ioapic; |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 490 | struct mpc_config_bus bus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
| 492 | bus.mpc_type = MP_BUS; |
| 493 | bus.mpc_busid = 0; |
| 494 | switch (mpc_default_type) { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 495 | default: |
Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 496 | printk(KERN_ERR "???\nUnknown standard configuration %d\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 497 | mpc_default_type); |
| 498 | /* fall through */ |
| 499 | case 1: |
| 500 | case 5: |
| 501 | memcpy(bus.mpc_bustype, "ISA ", 6); |
| 502 | break; |
| 503 | case 2: |
| 504 | case 6: |
| 505 | case 3: |
| 506 | memcpy(bus.mpc_bustype, "EISA ", 6); |
| 507 | break; |
| 508 | case 4: |
| 509 | case 7: |
| 510 | memcpy(bus.mpc_bustype, "MCA ", 6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } |
| 512 | MP_bus_info(&bus); |
| 513 | if (mpc_default_type > 4) { |
| 514 | bus.mpc_busid = 1; |
| 515 | memcpy(bus.mpc_bustype, "PCI ", 6); |
| 516 | MP_bus_info(&bus); |
| 517 | } |
| 518 | |
| 519 | ioapic.mpc_type = MP_IOAPIC; |
| 520 | ioapic.mpc_apicid = 2; |
| 521 | ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; |
| 522 | ioapic.mpc_flags = MPC_APIC_USABLE; |
| 523 | ioapic.mpc_apicaddr = 0xFEC00000; |
| 524 | MP_ioapic_info(&ioapic); |
| 525 | |
| 526 | /* |
| 527 | * We set up most of the low 16 IO-APIC pins according to MPS rules. |
| 528 | */ |
| 529 | construct_default_ioirq_mptable(mpc_default_type); |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 530 | } |
| 531 | #else |
Marcin Slusarz | 39e00fe | 2008-08-11 00:09:38 +0200 | [diff] [blame^] | 532 | static inline void __init construct_ioapic_table(int mpc_default_type) { } |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 533 | #endif |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 534 | |
| 535 | static inline void __init construct_default_ISA_mptable(int mpc_default_type) |
| 536 | { |
| 537 | struct mpc_config_processor processor; |
| 538 | struct mpc_config_lintsrc lintsrc; |
| 539 | int linttypes[2] = { mp_ExtINT, mp_NMI }; |
| 540 | int i; |
| 541 | |
| 542 | /* |
| 543 | * local APIC has default address |
| 544 | */ |
| 545 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; |
| 546 | |
| 547 | /* |
| 548 | * 2 CPUs, numbered 0 & 1. |
| 549 | */ |
| 550 | processor.mpc_type = MP_PROCESSOR; |
| 551 | /* Either an integrated APIC or a discrete 82489DX. */ |
| 552 | processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; |
| 553 | processor.mpc_cpuflag = CPU_ENABLED; |
| 554 | processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | |
| 555 | (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask; |
| 556 | processor.mpc_featureflag = boot_cpu_data.x86_capability[0]; |
| 557 | processor.mpc_reserved[0] = 0; |
| 558 | processor.mpc_reserved[1] = 0; |
| 559 | for (i = 0; i < 2; i++) { |
| 560 | processor.mpc_apicid = i; |
| 561 | MP_processor_info(&processor); |
| 562 | } |
| 563 | |
| 564 | construct_ioapic_table(mpc_default_type); |
| 565 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | lintsrc.mpc_type = MP_LINTSRC; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 567 | lintsrc.mpc_irqflag = 0; /* conforming */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | lintsrc.mpc_srcbusid = 0; |
| 569 | lintsrc.mpc_srcbusirq = 0; |
| 570 | lintsrc.mpc_destapic = MP_APIC_ALL; |
| 571 | for (i = 0; i < 2; i++) { |
| 572 | lintsrc.mpc_irqtype = linttypes[i]; |
| 573 | lintsrc.mpc_destapiclint = i; |
| 574 | MP_lintsrc_info(&lintsrc); |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | static struct intel_mp_floating *mpf_found; |
| 579 | |
| 580 | /* |
| 581 | * Scan the memory blocks for an SMP configuration block. |
| 582 | */ |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame] | 583 | static void __init __get_smp_config(unsigned int early) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | { |
| 585 | struct intel_mp_floating *mpf = mpf_found; |
| 586 | |
Yinghai Lu | 3c9cb6d | 2008-07-19 02:07:25 -0700 | [diff] [blame] | 587 | if (x86_quirks->mach_get_smp_config) { |
| 588 | if (x86_quirks->mach_get_smp_config(early)) |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame] | 589 | return; |
| 590 | } |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 591 | if (acpi_lapic && early) |
| 592 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | /* |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 594 | * ACPI supports both logical (e.g. Hyper-Threading) and physical |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | * processors, where MPS only supports physical. |
| 596 | */ |
| 597 | if (acpi_lapic && acpi_ioapic) { |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 598 | printk(KERN_INFO "Using ACPI (MADT) for SMP configuration " |
| 599 | "information\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | return; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 601 | } else if (acpi_lapic) |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 602 | printk(KERN_INFO "Using ACPI for processor (LAPIC) " |
| 603 | "configuration information\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 605 | printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", |
| 606 | mpf->mpf_specification); |
Alexey Starikovskiy | b3e2416 | 2008-05-23 01:54:44 +0400 | [diff] [blame] | 607 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 608 | if (mpf->mpf_feature2 & (1 << 7)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | printk(KERN_INFO " IMCR and PIC compatibility mode.\n"); |
| 610 | pic_mode = 1; |
| 611 | } else { |
| 612 | printk(KERN_INFO " Virtual Wire compatibility mode.\n"); |
| 613 | pic_mode = 0; |
| 614 | } |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 615 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | /* |
| 617 | * Now see if we need to read further. |
| 618 | */ |
| 619 | if (mpf->mpf_feature1 != 0) { |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 620 | if (early) { |
| 621 | /* |
| 622 | * local APIC has default address |
| 623 | */ |
| 624 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; |
| 625 | return; |
| 626 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 628 | printk(KERN_INFO "Default MP configuration #%d\n", |
| 629 | mpf->mpf_feature1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | construct_default_ISA_mptable(mpf->mpf_feature1); |
| 631 | |
| 632 | } else if (mpf->mpf_physptr) { |
| 633 | |
| 634 | /* |
| 635 | * Read the physical hardware table. Anything here will |
| 636 | * override the defaults. |
| 637 | */ |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 638 | if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr), early)) { |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 639 | #ifdef CONFIG_X86_LOCAL_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | smp_found_config = 0; |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 641 | #endif |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 642 | printk(KERN_ERR |
| 643 | "BIOS bug, MP table errors detected!...\n"); |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 644 | printk(KERN_ERR "... disabling SMP support. " |
| 645 | "(tell your hw vendor)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | return; |
| 647 | } |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 648 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 649 | if (early) |
| 650 | return; |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 651 | #ifdef CONFIG_X86_IO_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | /* |
| 653 | * If there are no explicit MP IRQ entries, then we are |
| 654 | * broken. We set up most of the low 16 IO-APIC pins to |
| 655 | * ISA defaults and hope it will work. |
| 656 | */ |
| 657 | if (!mp_irq_entries) { |
| 658 | struct mpc_config_bus bus; |
| 659 | |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 660 | printk(KERN_ERR "BIOS bug, no explicit IRQ entries, " |
| 661 | "using default mptable. " |
| 662 | "(tell your hw vendor)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | |
| 664 | bus.mpc_type = MP_BUS; |
| 665 | bus.mpc_busid = 0; |
| 666 | memcpy(bus.mpc_bustype, "ISA ", 6); |
| 667 | MP_bus_info(&bus); |
| 668 | |
| 669 | construct_default_ioirq_mptable(0); |
| 670 | } |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 671 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | } else |
| 673 | BUG(); |
| 674 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 675 | if (!early) |
| 676 | printk(KERN_INFO "Processors: %d\n", num_processors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | /* |
| 678 | * Only use the first configuration found. |
| 679 | */ |
| 680 | } |
| 681 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 682 | void __init early_get_smp_config(void) |
| 683 | { |
| 684 | __get_smp_config(1); |
| 685 | } |
| 686 | |
| 687 | void __init get_smp_config(void) |
| 688 | { |
| 689 | __get_smp_config(0); |
| 690 | } |
| 691 | |
| 692 | static int __init smp_scan_config(unsigned long base, unsigned long length, |
| 693 | unsigned reserve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | { |
Alexey Starikovskiy | 92fd4b7 | 2008-04-04 23:42:46 +0400 | [diff] [blame] | 695 | unsigned int *bp = phys_to_virt(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | struct intel_mp_floating *mpf; |
| 697 | |
Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 698 | apic_printk(APIC_VERBOSE, "Scan SMP from %p for %ld bytes.\n", |
| 699 | bp, length); |
Akinobu Mita | 5d47a27 | 2008-04-19 23:55:11 +0900 | [diff] [blame] | 700 | BUILD_BUG_ON(sizeof(*mpf) != 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | |
| 702 | while (length > 0) { |
| 703 | mpf = (struct intel_mp_floating *)bp; |
| 704 | if ((*bp == SMP_MAGIC_IDENT) && |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 705 | (mpf->mpf_length == 1) && |
| 706 | !mpf_checksum((unsigned char *)bp, 16) && |
| 707 | ((mpf->mpf_specification == 1) |
| 708 | || (mpf->mpf_specification == 4))) { |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 709 | #ifdef CONFIG_X86_LOCAL_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | smp_found_config = 1; |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 711 | #endif |
Alexey Starikovskiy | 92fd4b7 | 2008-04-04 23:42:46 +0400 | [diff] [blame] | 712 | mpf_found = mpf; |
Yinghai Lu | b1f006b | 2008-06-09 18:11:36 -0700 | [diff] [blame] | 713 | |
Ingo Molnar | e91a3b43 | 2008-01-30 13:33:08 +0100 | [diff] [blame] | 714 | printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 715 | mpf, virt_to_phys(mpf)); |
Yinghai Lu | b1f006b | 2008-06-09 18:11:36 -0700 | [diff] [blame] | 716 | |
| 717 | if (!reserve) |
| 718 | return 1; |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 719 | reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE, |
Bernhard Walle | 72a7fe3 | 2008-02-07 00:15:17 -0800 | [diff] [blame] | 720 | BOOTMEM_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | if (mpf->mpf_physptr) { |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 722 | unsigned long size = PAGE_SIZE; |
| 723 | #ifdef CONFIG_X86_32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | /* |
| 725 | * We cannot access to MPC table to compute |
| 726 | * table size yet, as only few megabytes from |
| 727 | * the bottom is mapped now. |
| 728 | * PC-9800's MPC table places on the very last |
| 729 | * of physical memory; so that simply reserving |
| 730 | * PAGE_SIZE from mpg->mpf_physptr yields BUG() |
| 731 | * in reserve_bootmem. |
| 732 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | unsigned long end = max_low_pfn * PAGE_SIZE; |
| 734 | if (mpf->mpf_physptr + size > end) |
| 735 | size = end - mpf->mpf_physptr; |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 736 | #endif |
| 737 | reserve_bootmem_generic(mpf->mpf_physptr, size, |
Bernhard Walle | 72a7fe3 | 2008-02-07 00:15:17 -0800 | [diff] [blame] | 738 | BOOTMEM_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | } |
| 740 | |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 741 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | } |
| 743 | bp += 4; |
| 744 | length -= 16; |
| 745 | } |
| 746 | return 0; |
| 747 | } |
| 748 | |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame] | 749 | static void __init __find_smp_config(unsigned int reserve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | { |
| 751 | unsigned int address; |
| 752 | |
Yinghai Lu | 3c9cb6d | 2008-07-19 02:07:25 -0700 | [diff] [blame] | 753 | if (x86_quirks->mach_find_smp_config) { |
| 754 | if (x86_quirks->mach_find_smp_config(reserve)) |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame] | 755 | return; |
| 756 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | /* |
| 758 | * FIXME: Linux assumes you have 640K of base ram.. |
| 759 | * this continues the error... |
| 760 | * |
| 761 | * 1) Scan the bottom 1K for a signature |
| 762 | * 2) Scan the top 1K of base RAM |
| 763 | * 3) Scan the 64K of bios |
| 764 | */ |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 765 | if (smp_scan_config(0x0, 0x400, reserve) || |
| 766 | smp_scan_config(639 * 0x400, 0x400, reserve) || |
| 767 | smp_scan_config(0xF0000, 0x10000, reserve)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | return; |
| 769 | /* |
| 770 | * If it is an SMP machine we should know now, unless the |
| 771 | * configuration is in an EISA/MCA bus machine with an |
| 772 | * extended bios data area. |
| 773 | * |
| 774 | * there is a real-mode segmented pointer pointing to the |
| 775 | * 4K EBDA area at 0x40E, calculate and scan it here. |
| 776 | * |
| 777 | * NOTE! There are Linux loaders that will corrupt the EBDA |
| 778 | * area, and as such this kind of SMP config may be less |
| 779 | * trustworthy, simply because the SMP table may have been |
| 780 | * stomped on during early boot. These loaders are buggy and |
| 781 | * should be fixed. |
| 782 | * |
| 783 | * MP1.4 SPEC states to only scan first 1K of 4K EBDA. |
| 784 | */ |
| 785 | |
| 786 | address = get_bios_ebda(); |
| 787 | if (address) |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 788 | smp_scan_config(address, 0x400, reserve); |
| 789 | } |
| 790 | |
| 791 | void __init early_find_smp_config(void) |
| 792 | { |
| 793 | __find_smp_config(0); |
| 794 | } |
| 795 | |
| 796 | void __init find_smp_config(void) |
| 797 | { |
| 798 | __find_smp_config(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | } |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 800 | |
| 801 | #ifdef CONFIG_X86_IO_APIC |
| 802 | static u8 __initdata irq_used[MAX_IRQ_SOURCES]; |
| 803 | |
| 804 | static int __init get_MP_intsrc_index(struct mpc_config_intsrc *m) |
| 805 | { |
| 806 | int i; |
| 807 | |
| 808 | if (m->mpc_irqtype != mp_INT) |
| 809 | return 0; |
| 810 | |
| 811 | if (m->mpc_irqflag != 0x0f) |
| 812 | return 0; |
| 813 | |
| 814 | /* not legacy */ |
| 815 | |
| 816 | for (i = 0; i < mp_irq_entries; i++) { |
| 817 | if (mp_irqs[i].mp_irqtype != mp_INT) |
| 818 | continue; |
| 819 | |
| 820 | if (mp_irqs[i].mp_irqflag != 0x0f) |
| 821 | continue; |
| 822 | |
| 823 | if (mp_irqs[i].mp_srcbus != m->mpc_srcbus) |
| 824 | continue; |
| 825 | if (mp_irqs[i].mp_srcbusirq != m->mpc_srcbusirq) |
| 826 | continue; |
| 827 | if (irq_used[i]) { |
| 828 | /* already claimed */ |
| 829 | return -2; |
| 830 | } |
| 831 | irq_used[i] = 1; |
| 832 | return i; |
| 833 | } |
| 834 | |
| 835 | /* not found */ |
| 836 | return -1; |
| 837 | } |
| 838 | |
| 839 | #define SPARE_SLOT_NUM 20 |
| 840 | |
| 841 | static struct mpc_config_intsrc __initdata *m_spare[SPARE_SLOT_NUM]; |
| 842 | #endif |
| 843 | |
| 844 | static int __init replace_intsrc_all(struct mp_config_table *mpc, |
| 845 | unsigned long mpc_new_phys, |
| 846 | unsigned long mpc_new_length) |
| 847 | { |
| 848 | #ifdef CONFIG_X86_IO_APIC |
| 849 | int i; |
| 850 | int nr_m_spare = 0; |
| 851 | #endif |
| 852 | |
| 853 | int count = sizeof(*mpc); |
| 854 | unsigned char *mpt = ((unsigned char *)mpc) + count; |
| 855 | |
| 856 | printk(KERN_INFO "mpc_length %x\n", mpc->mpc_length); |
| 857 | while (count < mpc->mpc_length) { |
| 858 | switch (*mpt) { |
| 859 | case MP_PROCESSOR: |
| 860 | { |
| 861 | struct mpc_config_processor *m = |
| 862 | (struct mpc_config_processor *)mpt; |
| 863 | mpt += sizeof(*m); |
| 864 | count += sizeof(*m); |
| 865 | break; |
| 866 | } |
| 867 | case MP_BUS: |
| 868 | { |
| 869 | struct mpc_config_bus *m = |
| 870 | (struct mpc_config_bus *)mpt; |
| 871 | mpt += sizeof(*m); |
| 872 | count += sizeof(*m); |
| 873 | break; |
| 874 | } |
| 875 | case MP_IOAPIC: |
| 876 | { |
| 877 | mpt += sizeof(struct mpc_config_ioapic); |
| 878 | count += sizeof(struct mpc_config_ioapic); |
| 879 | break; |
| 880 | } |
| 881 | case MP_INTSRC: |
| 882 | { |
| 883 | #ifdef CONFIG_X86_IO_APIC |
| 884 | struct mpc_config_intsrc *m = |
| 885 | (struct mpc_config_intsrc *)mpt; |
| 886 | |
| 887 | printk(KERN_INFO "OLD "); |
| 888 | print_MP_intsrc_info(m); |
| 889 | i = get_MP_intsrc_index(m); |
| 890 | if (i > 0) { |
| 891 | assign_to_mpc_intsrc(&mp_irqs[i], m); |
| 892 | printk(KERN_INFO "NEW "); |
| 893 | print_mp_irq_info(&mp_irqs[i]); |
| 894 | } else if (!i) { |
| 895 | /* legacy, do nothing */ |
| 896 | } else if (nr_m_spare < SPARE_SLOT_NUM) { |
| 897 | /* |
| 898 | * not found (-1), or duplicated (-2) |
| 899 | * are invalid entries, |
| 900 | * we need to use the slot later |
| 901 | */ |
| 902 | m_spare[nr_m_spare] = m; |
| 903 | nr_m_spare++; |
| 904 | } |
| 905 | #endif |
| 906 | mpt += sizeof(struct mpc_config_intsrc); |
| 907 | count += sizeof(struct mpc_config_intsrc); |
| 908 | break; |
| 909 | } |
| 910 | case MP_LINTSRC: |
| 911 | { |
| 912 | struct mpc_config_lintsrc *m = |
| 913 | (struct mpc_config_lintsrc *)mpt; |
| 914 | mpt += sizeof(*m); |
| 915 | count += sizeof(*m); |
| 916 | break; |
| 917 | } |
| 918 | default: |
| 919 | /* wrong mptable */ |
| 920 | printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n"); |
| 921 | printk(KERN_ERR "type %x\n", *mpt); |
| 922 | print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16, |
| 923 | 1, mpc, mpc->mpc_length, 1); |
| 924 | goto out; |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | #ifdef CONFIG_X86_IO_APIC |
| 929 | for (i = 0; i < mp_irq_entries; i++) { |
| 930 | if (irq_used[i]) |
| 931 | continue; |
| 932 | |
| 933 | if (mp_irqs[i].mp_irqtype != mp_INT) |
| 934 | continue; |
| 935 | |
| 936 | if (mp_irqs[i].mp_irqflag != 0x0f) |
| 937 | continue; |
| 938 | |
| 939 | if (nr_m_spare > 0) { |
| 940 | printk(KERN_INFO "*NEW* found "); |
| 941 | nr_m_spare--; |
| 942 | assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); |
| 943 | m_spare[nr_m_spare] = NULL; |
| 944 | } else { |
| 945 | struct mpc_config_intsrc *m = |
| 946 | (struct mpc_config_intsrc *)mpt; |
| 947 | count += sizeof(struct mpc_config_intsrc); |
| 948 | if (!mpc_new_phys) { |
| 949 | printk(KERN_INFO "No spare slots, try to append...take your risk, new mpc_length %x\n", count); |
| 950 | } else { |
| 951 | if (count <= mpc_new_length) |
| 952 | printk(KERN_INFO "No spare slots, try to append..., new mpc_length %x\n", count); |
| 953 | else { |
| 954 | printk(KERN_ERR "mpc_new_length %lx is too small\n", mpc_new_length); |
| 955 | goto out; |
| 956 | } |
| 957 | } |
| 958 | assign_to_mpc_intsrc(&mp_irqs[i], m); |
| 959 | mpc->mpc_length = count; |
| 960 | mpt += sizeof(struct mpc_config_intsrc); |
| 961 | } |
| 962 | print_mp_irq_info(&mp_irqs[i]); |
| 963 | } |
| 964 | #endif |
| 965 | out: |
| 966 | /* update checksum */ |
| 967 | mpc->mpc_checksum = 0; |
| 968 | mpc->mpc_checksum -= mpf_checksum((unsigned char *)mpc, |
| 969 | mpc->mpc_length); |
| 970 | |
| 971 | return 0; |
| 972 | } |
| 973 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 974 | static int __initdata enable_update_mptable; |
| 975 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 976 | static int __init update_mptable_setup(char *str) |
| 977 | { |
| 978 | enable_update_mptable = 1; |
| 979 | return 0; |
| 980 | } |
| 981 | early_param("update_mptable", update_mptable_setup); |
| 982 | |
| 983 | static unsigned long __initdata mpc_new_phys; |
| 984 | static unsigned long mpc_new_length __initdata = 4096; |
| 985 | |
| 986 | /* alloc_mptable or alloc_mptable=4k */ |
| 987 | static int __initdata alloc_mptable; |
| 988 | static int __init parse_alloc_mptable_opt(char *p) |
| 989 | { |
| 990 | enable_update_mptable = 1; |
| 991 | alloc_mptable = 1; |
| 992 | if (!p) |
| 993 | return 0; |
| 994 | mpc_new_length = memparse(p, &p); |
| 995 | return 0; |
| 996 | } |
| 997 | early_param("alloc_mptable", parse_alloc_mptable_opt); |
| 998 | |
| 999 | void __init early_reserve_e820_mpc_new(void) |
| 1000 | { |
| 1001 | if (enable_update_mptable && alloc_mptable) { |
| 1002 | u64 startt = 0; |
| 1003 | #ifdef CONFIG_X86_TRAMPOLINE |
| 1004 | startt = TRAMPOLINE_BASE; |
| 1005 | #endif |
| 1006 | mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4); |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | static int __init update_mp_table(void) |
| 1011 | { |
| 1012 | char str[16]; |
| 1013 | char oem[10]; |
| 1014 | struct intel_mp_floating *mpf; |
| 1015 | struct mp_config_table *mpc; |
| 1016 | struct mp_config_table *mpc_new; |
| 1017 | |
| 1018 | if (!enable_update_mptable) |
| 1019 | return 0; |
| 1020 | |
| 1021 | mpf = mpf_found; |
| 1022 | if (!mpf) |
| 1023 | return 0; |
| 1024 | |
| 1025 | /* |
| 1026 | * Now see if we need to go further. |
| 1027 | */ |
| 1028 | if (mpf->mpf_feature1 != 0) |
| 1029 | return 0; |
| 1030 | |
| 1031 | if (!mpf->mpf_physptr) |
| 1032 | return 0; |
| 1033 | |
| 1034 | mpc = phys_to_virt(mpf->mpf_physptr); |
| 1035 | |
| 1036 | if (!smp_check_mpc(mpc, oem, str)) |
| 1037 | return 0; |
| 1038 | |
| 1039 | printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf)); |
| 1040 | printk(KERN_INFO "mpf_physptr: %x\n", mpf->mpf_physptr); |
| 1041 | |
| 1042 | if (mpc_new_phys && mpc->mpc_length > mpc_new_length) { |
| 1043 | mpc_new_phys = 0; |
| 1044 | printk(KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n", |
| 1045 | mpc_new_length); |
| 1046 | } |
| 1047 | |
| 1048 | if (!mpc_new_phys) { |
| 1049 | unsigned char old, new; |
| 1050 | /* check if we can change the postion */ |
| 1051 | mpc->mpc_checksum = 0; |
| 1052 | old = mpf_checksum((unsigned char *)mpc, mpc->mpc_length); |
| 1053 | mpc->mpc_checksum = 0xff; |
| 1054 | new = mpf_checksum((unsigned char *)mpc, mpc->mpc_length); |
| 1055 | if (old == new) { |
| 1056 | printk(KERN_INFO "mpc is readonly, please try alloc_mptable instead\n"); |
| 1057 | return 0; |
| 1058 | } |
| 1059 | printk(KERN_INFO "use in-positon replacing\n"); |
| 1060 | } else { |
| 1061 | mpf->mpf_physptr = mpc_new_phys; |
| 1062 | mpc_new = phys_to_virt(mpc_new_phys); |
| 1063 | memcpy(mpc_new, mpc, mpc->mpc_length); |
| 1064 | mpc = mpc_new; |
| 1065 | /* check if we can modify that */ |
| 1066 | if (mpc_new_phys - mpf->mpf_physptr) { |
| 1067 | struct intel_mp_floating *mpf_new; |
| 1068 | /* steal 16 bytes from [0, 1k) */ |
| 1069 | printk(KERN_INFO "mpf new: %x\n", 0x400 - 16); |
| 1070 | mpf_new = phys_to_virt(0x400 - 16); |
| 1071 | memcpy(mpf_new, mpf, 16); |
| 1072 | mpf = mpf_new; |
| 1073 | mpf->mpf_physptr = mpc_new_phys; |
| 1074 | } |
| 1075 | mpf->mpf_checksum = 0; |
| 1076 | mpf->mpf_checksum -= mpf_checksum((unsigned char *)mpf, 16); |
| 1077 | printk(KERN_INFO "mpf_physptr new: %x\n", mpf->mpf_physptr); |
| 1078 | } |
| 1079 | |
| 1080 | /* |
| 1081 | * only replace the one with mp_INT and |
| 1082 | * MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, |
| 1083 | * already in mp_irqs , stored by ... and mp_config_acpi_gsi, |
| 1084 | * may need pci=routeirq for all coverage |
| 1085 | */ |
| 1086 | replace_intsrc_all(mpc, mpc_new_phys, mpc_new_length); |
| 1087 | |
| 1088 | return 0; |
| 1089 | } |
| 1090 | |
| 1091 | late_initcall(update_mp_table); |