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