1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/mm.h>
16#include <linux/irq.h>
17#include <linux/init.h>
18#include <linux/delay.h>
19#include <linux/config.h>
20#include <linux/bootmem.h>
21#include <linux/smp_lock.h>
22#include <linux/kernel_stat.h>
23#include <linux/mc146818rtc.h>
24
25#include <asm/smp.h>
26#include <asm/mtrr.h>
27#include <asm/mpspec.h>
28#include <asm/pgalloc.h>
29#include <asm/smpboot.h>
30
31
32int smp_found_config;
33
34
35
36
37
38int apic_version [MAX_APICS];
39int quad_local_to_mp_bus_id [NR_CPUS/4][4];
40int mp_current_pci_id;
41int *mp_bus_id_to_type;
42int *mp_bus_id_to_node;
43int *mp_bus_id_to_local;
44int *mp_bus_id_to_pci_bus;
45int max_mp_busses;
46int max_irq_sources;
47
48
49struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
50
51
52struct mpc_config_intsrc *mp_irqs;
53
54
55int mp_irq_entries;
56
57int nr_ioapics;
58
59int pic_mode;
60unsigned long mp_lapic_addr;
61
62
63unsigned int boot_cpu_physical_apicid = -1U;
64unsigned int boot_cpu_logical_apicid = -1U;
65
66static unsigned int num_processors;
67
68
69unsigned long phys_cpu_present_map;
70unsigned long logical_cpu_present_map;
71
72#ifdef CONFIG_X86_CLUSTERED_APIC
73unsigned char esr_disable = 0;
74unsigned char clustered_apic_mode = CLUSTERED_APIC_NONE;
75unsigned int apic_broadcast_id = APIC_BROADCAST_ID_APIC;
76#endif
77unsigned char raw_phys_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
78
79
80
81
82
83#ifndef CONFIG_X86_VISWS_APIC
84
85
86
87
88static int __init mpf_checksum(unsigned char *mp, int len)
89{
90 int sum = 0;
91
92 while (len--)
93 sum += *mp++;
94
95 return sum & 0xFF;
96}
97
98
99
100
101
102static char __init *mpc_family(int family,int model)
103{
104 static char n[32];
105 static char *model_defs[]=
106 {
107 "80486DX","80486DX",
108 "80486SX","80486DX/2 or 80487",
109 "80486SL","80486SX/2",
110 "Unknown","80486DX/2-WB",
111 "80486DX/4","80486DX/4-WB"
112 };
113
114 switch (family) {
115 case 0x04:
116 if (model < 10)
117 return model_defs[model];
118 break;
119
120 case 0x05:
121 return("Pentium(tm)");
122
123 case 0x06:
124 return("Pentium(tm) Pro");
125
126 case 0x0F:
127 if (model == 0x00)
128 return("Pentium 4(tm)");
129 if (model == 0x01)
130 return("Pentium 4(tm)");
131 if (model == 0x02)
132 return("Pentium 4(tm) XEON(tm)");
133 if (model == 0x0F)
134 return("Special controller");
135 }
136 sprintf(n,"Unknown CPU [%d:%d]",family, model);
137 return n;
138}
139
140#ifdef CONFIG_X86_IO_APIC
141extern int have_acpi_tables;
142#else
143#define have_acpi_tables (0)
144#endif
145
146
147
148
149
150
151
152static int mpc_record;
153static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdata;
154
155void __init MP_processor_info (struct mpc_config_processor *m)
156{
157 int ver, quad, logical_apicid;
158
159 if (!(m->mpc_cpuflag & CPU_ENABLED))
160 return;
161
162 logical_apicid = m->mpc_apicid;
163 if (clustered_apic_mode == CLUSTERED_APIC_NUMAQ) {
164 quad = translation_table[mpc_record]->trans_quad;
165 logical_apicid = (quad << 4) +
166 (m->mpc_apicid ? m->mpc_apicid << 1 : 1);
167 printk("Processor #%d %s APIC version %d (quad %d, apic %d)\n",
168 m->mpc_apicid,
169 mpc_family((m->mpc_cpufeature & CPU_FAMILY_MASK)>>8 ,
170 (m->mpc_cpufeature & CPU_MODEL_MASK)>>4),
171 m->mpc_apicver, quad, logical_apicid);
172 } else {
173 printk("Processor #%d %s APIC version %d\n",
174 m->mpc_apicid,
175 mpc_family((m->mpc_cpufeature & CPU_FAMILY_MASK)>>8 ,
176 (m->mpc_cpufeature & CPU_MODEL_MASK)>>4),
177 m->mpc_apicver);
178 }
179
180 if (m->mpc_featureflag&(1<<0))
181 Dprintk(" Floating point unit present.\n");
182 if (m->mpc_featureflag&(1<<7))
183 Dprintk(" Machine Exception supported.\n");
184 if (m->mpc_featureflag&(1<<8))
185 Dprintk(" 64 bit compare & exchange supported.\n");
186 if (m->mpc_featureflag&(1<<9))
187 Dprintk(" Internal APIC present.\n");
188 if (m->mpc_featureflag&(1<<11))
189 Dprintk(" SEP present.\n");
190 if (m->mpc_featureflag&(1<<12))
191 Dprintk(" MTRR present.\n");
192 if (m->mpc_featureflag&(1<<13))
193 Dprintk(" PGE present.\n");
194 if (m->mpc_featureflag&(1<<14))
195 Dprintk(" MCA present.\n");
196 if (m->mpc_featureflag&(1<<15))
197 Dprintk(" CMOV present.\n");
198 if (m->mpc_featureflag&(1<<16))
199 Dprintk(" PAT present.\n");
200 if (m->mpc_featureflag&(1<<17))
201 Dprintk(" PSE present.\n");
202 if (m->mpc_featureflag&(1<<18))
203 Dprintk(" PSN present.\n");
204 if (m->mpc_featureflag&(1<<19))
205 Dprintk(" Cache Line Flush Instruction present.\n");
206
207 if (m->mpc_featureflag&(1<<21))
208 Dprintk(" Debug Trace and EMON Store present.\n");
209 if (m->mpc_featureflag&(1<<22))
210 Dprintk(" ACPI Thermal Throttle Registers present.\n");
211 if (m->mpc_featureflag&(1<<23))
212 Dprintk(" MMX present.\n");
213 if (m->mpc_featureflag&(1<<24))
214 Dprintk(" FXSR present.\n");
215 if (m->mpc_featureflag&(1<<25))
216 Dprintk(" XMM present.\n");
217 if (m->mpc_featureflag&(1<<26))
218 Dprintk(" Willamette New Instructions present.\n");
219 if (m->mpc_featureflag&(1<<27))
220 Dprintk(" Self Snoop present.\n");
221 if (m->mpc_featureflag&(1<<28))
222 Dprintk(" HT present.\n");
223 if (m->mpc_featureflag&(1<<29))
224 Dprintk(" Thermal Monitor present.\n");
225
226
227
228 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
229 Dprintk(" Bootup CPU\n");
230 boot_cpu_physical_apicid = m->mpc_apicid;
231 boot_cpu_logical_apicid = logical_apicid;
232 }
233
234 num_processors++;
235
236 if (m->mpc_apicid > MAX_APICS) {
237 printk("Processor #%d INVALID. (Max ID: %d).\n",
238 m->mpc_apicid, MAX_APICS);
239 --num_processors;
240 return;
241 }
242 ver = m->mpc_apicver;
243
244 logical_cpu_present_map |= 1 << (num_processors-1);
245 phys_cpu_present_map |= apicid_to_phys_cpu_present(m->mpc_apicid);
246
247
248
249
250 if (ver == 0x0) {
251 printk("BIOS bug, APIC version is 0 for CPU#%d! fixing up to 0x10. (tell your hw vendor)\n", m->mpc_apicid);
252 ver = 0x10;
253 }
254 apic_version[m->mpc_apicid] = ver;
255 raw_phys_apicid[num_processors - 1] = m->mpc_apicid;
256}
257
258static void __init MP_bus_info (struct mpc_config_bus *m)
259{
260 char str[7];
261 int quad;
262
263 memcpy(str, m->mpc_bustype, 6);
264 str[6] = 0;
265
266 if (clustered_apic_mode == CLUSTERED_APIC_NUMAQ) {
267 quad = translation_table[mpc_record]->trans_quad;
268 mp_bus_id_to_node[m->mpc_busid] = quad;
269 mp_bus_id_to_local[m->mpc_busid] = translation_table[mpc_record]->trans_local;
270 quad_local_to_mp_bus_id[quad][translation_table[mpc_record]->trans_local] = m->mpc_busid;
271 printk("Bus #%d is %s (node %d)\n", m->mpc_busid, str, quad);
272 } else {
273 Dprintk("Bus #%d is %s\n", m->mpc_busid, str);
274 }
275
276 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
277 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
278 } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA)-1) == 0) {
279 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA;
280 } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI)-1) == 0) {
281 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI;
282 mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
283 mp_current_pci_id++;
284 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
285 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
286 } else {
287 printk("Unknown bustype %s - ignoring\n", str);
288 }
289}
290
291static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
292{
293 if (!(m->mpc_flags & MPC_APIC_USABLE))
294 return;
295
296 printk("I/O APIC #%d Version %d at 0x%lX.\n",
297 m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr);
298 if (nr_ioapics >= MAX_IO_APICS) {
299 printk("Max # of I/O APICs (%d) exceeded (found %d).\n",
300 MAX_IO_APICS, nr_ioapics);
301 panic("Recompile kernel with bigger MAX_IO_APICS!.\n");
302 }
303 if (!m->mpc_apicaddr) {
304 printk(KERN_ERR "WARNING: bogus zero I/O APIC address"
305 " found in MP table, skipping!\n");
306 return;
307 }
308 mp_ioapics[nr_ioapics] = *m;
309 nr_ioapics++;
310}
311
312static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
313{
314 mp_irqs [mp_irq_entries] = *m;
315 Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
316 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
317 m->mpc_irqtype, m->mpc_irqflag & 3,
318 (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
319 m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
320 if (++mp_irq_entries == max_irq_sources)
321 panic("Max # of irq sources exceeded!!\n");
322}
323
324static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
325{
326 Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
327 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
328 m->mpc_irqtype, m->mpc_irqflag & 3,
329 (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
330 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
331
332
333
334
335
336
337
338 if ((m->mpc_irqtype == mp_ExtINT) &&
339 (m->mpc_destapiclint != 0))
340 BUG();
341 if ((m->mpc_irqtype == mp_NMI) &&
342 (m->mpc_destapiclint != 1))
343 BUG();
344}
345
346static void __init MP_translation_info (struct mpc_config_translation *m)
347{
348 printk("Translation: record %d, type %d, quad %d, global %d, local %d\n", mpc_record, m->trans_type, m->trans_quad, m->trans_global, m->trans_local);
349
350 if (mpc_record >= MAX_MPC_ENTRY)
351 printk("MAX_MPC_ENTRY exceeded!\n");
352 else
353 translation_table[mpc_record] = m;
354 if (m->trans_quad+1 > numnodes)
355 numnodes = m->trans_quad+1;
356}
357
358
359
360
361
362static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, \
363 unsigned short oemsize)
364{
365 int count = sizeof (*oemtable);
366 unsigned char *oemptr = ((unsigned char *)oemtable)+count;
367
368 printk("Found an OEM MPC table at %8p - parsing it ... \n", oemtable);
369 if (memcmp(oemtable->oem_signature,MPC_OEM_SIGNATURE,4))
370 {
371 printk("SMP mpc oemtable: bad signature [%c%c%c%c]!\n",
372 oemtable->oem_signature[0],
373 oemtable->oem_signature[1],
374 oemtable->oem_signature[2],
375 oemtable->oem_signature[3]);
376 return;
377 }
378 if (mpf_checksum((unsigned char *)oemtable,oemtable->oem_length))
379 {
380 printk("SMP oem mptable: checksum error!\n");
381 return;
382 }
383 while (count < oemtable->oem_length) {
384 switch (*oemptr) {
385 case MP_TRANSLATION:
386 {
387 struct mpc_config_translation *m=
388 (struct mpc_config_translation *)oemptr;
389 MP_translation_info(m);
390 oemptr += sizeof(*m);
391 count += sizeof(*m);
392 ++mpc_record;
393 break;
394 }
395 default:
396 {
397 printk("Unrecognised OEM table entry type! - %d\n", (int) *oemptr);
398 return;
399 }
400 }
401 }
402}
403
404
405
406
407
408static int __init smp_read_mpc(struct mp_config_table *mpc)
409{
410 char oem[16], prod[14];
411 int count=sizeof(*mpc);
412 unsigned char *mpt=((unsigned char *)mpc)+count;
413 int num_bus = 0;
414 int num_irq = 0;
415 unsigned char *bus_data;
416
417 if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
418 panic("SMP mptable: bad signature [%c%c%c%c]!\n",
419 mpc->mpc_signature[0],
420 mpc->mpc_signature[1],
421 mpc->mpc_signature[2],
422 mpc->mpc_signature[3]);
423 return 0;
424 }
425 if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
426 panic("SMP mptable: checksum error!\n");
427 return 0;
428 }
429 if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
430 printk(KERN_ERR "SMP mptable: bad table version (%d)!!\n",
431 mpc->mpc_spec);
432 return 0;
433 }
434 if (!mpc->mpc_lapic) {
435 printk(KERN_ERR "SMP mptable: null local APIC address!\n");
436 return 0;
437 }
438 memcpy(oem,mpc->mpc_oem,8);
439 oem[8]=0;
440 printk("OEM ID: %s ",oem);
441
442 memcpy(prod,mpc->mpc_productid,12);
443 prod[12]=0;
444 printk("Product ID: %s ",prod);
445
446 detect_clustered_apic(oem, prod);
447
448 printk("APIC at: 0x%lX\n",mpc->mpc_lapic);
449
450
451
452
453 if (!have_acpi_tables)
454 mp_lapic_addr = mpc->mpc_lapic;
455
456 if ((clustered_apic_mode == CLUSTERED_APIC_NUMAQ) && mpc->mpc_oemptr) {
457
458 mpc_record = 0;
459 smp_read_mpc_oem((struct mp_config_oemtable *) mpc->mpc_oemptr, mpc->mpc_oemsize);
460 mpc_record = 0;
461 }
462
463
464
465
466 while (count < mpc->mpc_length) {
467 switch (*mpt) {
468 case MP_PROCESSOR:
469 mpt += sizeof(struct mpc_config_processor);
470 count += sizeof(struct mpc_config_processor);
471 break;
472 case MP_BUS:
473 ++num_bus;
474 mpt += sizeof(struct mpc_config_bus);
475 count += sizeof(struct mpc_config_bus);
476 break;
477 case MP_INTSRC:
478 ++num_irq;
479 mpt += sizeof(struct mpc_config_intsrc);
480 count += sizeof(struct mpc_config_intsrc);
481 break;
482 case MP_IOAPIC:
483 mpt += sizeof(struct mpc_config_ioapic);
484 count += sizeof(struct mpc_config_ioapic);
485 break;
486 case MP_LINTSRC:
487 mpt += sizeof(struct mpc_config_lintsrc);
488 count += sizeof(struct mpc_config_lintsrc);
489 break;
490 default:
491 count = mpc->mpc_length;
492 break;
493 }
494 }
495
496
497
498
499
500
501 ++num_bus;
502 max_mp_busses = max(num_bus, MAX_MP_BUSSES);
503 if (num_irq < (4 * max_mp_busses))
504 num_irq = 4 * num_bus;
505 ++num_irq;
506 max_irq_sources = max(num_irq, MAX_IRQ_SOURCES);
507
508 count = (max_mp_busses * sizeof(int)) * 4;
509 count += (max_irq_sources * sizeof(struct mpc_config_intsrc));
510 bus_data = alloc_bootmem(count);
511 if (!bus_data) {
512 printk(KERN_ERR "SMP mptable: out of memory!\n");
513 return 0;
514 }
515 mp_bus_id_to_type = (int *)&bus_data[0];
516 mp_bus_id_to_node = (int *)&bus_data[(max_mp_busses * sizeof(int))];
517 mp_bus_id_to_local = (int *)&bus_data[(max_mp_busses * sizeof(int)) * 2];
518 mp_bus_id_to_pci_bus = (int *)&bus_data[(max_mp_busses * sizeof(int)) * 3];
519 mp_irqs = (struct mpc_config_intsrc *)&bus_data[(max_mp_busses * sizeof(int)) * 4];
520 memset(mp_bus_id_to_pci_bus, -1, max_mp_busses);
521
522
523
524
525 count = sizeof(*mpc);
526 mpt = ((unsigned char *)mpc)+count;
527 while (count < mpc->mpc_length) {
528 switch(*mpt) {
529 case MP_PROCESSOR:
530 {
531 struct mpc_config_processor *m=
532 (struct mpc_config_processor *)mpt;
533
534
535 if (!have_acpi_tables)
536 MP_processor_info(m);
537 mpt += sizeof(*m);
538 count += sizeof(*m);
539 break;
540 }
541 case MP_BUS:
542 {
543 struct mpc_config_bus *m=
544 (struct mpc_config_bus *)mpt;
545 MP_bus_info(m);
546 mpt += sizeof(*m);
547 count += sizeof(*m);
548 break;
549 }
550 case MP_IOAPIC:
551 {
552 struct mpc_config_ioapic *m=
553 (struct mpc_config_ioapic *)mpt;
554 MP_ioapic_info(m);
555 mpt+=sizeof(*m);
556 count+=sizeof(*m);
557 break;
558 }
559 case MP_INTSRC:
560 {
561 struct mpc_config_intsrc *m=
562 (struct mpc_config_intsrc *)mpt;
563
564 MP_intsrc_info(m);
565 mpt+=sizeof(*m);
566 count+=sizeof(*m);
567 break;
568 }
569 case MP_LINTSRC:
570 {
571 struct mpc_config_lintsrc *m=
572 (struct mpc_config_lintsrc *)mpt;
573 MP_lintsrc_info(m);
574 mpt+=sizeof(*m);
575 count+=sizeof(*m);
576 break;
577 }
578 default:
579 {
580 count = mpc->mpc_length;
581 break;
582 }
583 }
584 ++mpc_record;
585 }
586
587 if (clustered_apic_mode){
588 phys_cpu_present_map = logical_cpu_present_map;
589 }
590
591
592 printk("Enabling APIC mode: ");
593 if(clustered_apic_mode == CLUSTERED_APIC_NUMAQ)
594 printk("Clustered Logical. ");
595 else if(clustered_apic_mode == CLUSTERED_APIC_XAPIC)
596 printk("Physical. ");
597 else
598 printk("Flat. ");
599 printk("Using %d I/O APICs\n",nr_ioapics);
600
601 if (!num_processors)
602 printk(KERN_ERR "SMP mptable: no processors registered!\n");
603 return num_processors;
604}
605
606static int __init ELCR_trigger(unsigned int irq)
607{
608 unsigned int port;
609
610 port = 0x4d0 + (irq >> 3);
611 return (inb(port) >> (irq & 7)) & 1;
612}
613
614static void __init construct_default_ioirq_mptable(int mpc_default_type)
615{
616 struct mpc_config_intsrc intsrc;
617 int i;
618 int ELCR_fallback = 0;
619
620 intsrc.mpc_type = MP_INTSRC;
621 intsrc.mpc_irqflag = 0;
622 intsrc.mpc_srcbus = 0;
623 intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
624
625 intsrc.mpc_irqtype = mp_INT;
626
627
628
629
630
631
632
633
634
635 if (mpc_default_type == 5) {
636 printk("ISA/PCI bus type with no IRQ information... falling back to ELCR\n");
637
638 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
639 printk("ELCR contains invalid data... not using ELCR\n");
640 else {
641 printk("Using ELCR to identify PCI interrupts\n");
642 ELCR_fallback = 1;
643 }
644 }
645
646 for (i = 0; i < 16; i++) {
647 switch (mpc_default_type) {
648 case 2:
649 if (i == 0 || i == 13)
650 continue;
651
652 default:
653 if (i == 2)
654 continue;
655 }
656
657 if (ELCR_fallback) {
658
659
660
661
662
663 if (ELCR_trigger(i))
664 intsrc.mpc_irqflag = 13;
665 else
666 intsrc.mpc_irqflag = 0;
667 }
668
669 intsrc.mpc_srcbusirq = i;
670 intsrc.mpc_dstirq = i ? i : 2;
671 MP_intsrc_info(&intsrc);
672 }
673
674 intsrc.mpc_irqtype = mp_ExtINT;
675 intsrc.mpc_srcbusirq = 0;
676 intsrc.mpc_dstirq = 0;
677 MP_intsrc_info(&intsrc);
678}
679
680static inline void __init construct_default_ISA_mptable(int mpc_default_type)
681{
682 struct mpc_config_processor processor;
683 struct mpc_config_bus bus;
684 struct mpc_config_ioapic ioapic;
685 struct mpc_config_lintsrc lintsrc;
686 int linttypes[2] = { mp_ExtINT, mp_NMI };
687 int i;
688
689
690
691
692 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
693
694
695
696
697 processor.mpc_type = MP_PROCESSOR;
698
699 processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
700 processor.mpc_cpuflag = CPU_ENABLED;
701 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
702 (boot_cpu_data.x86_model << 4) |
703 boot_cpu_data.x86_mask;
704 processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
705 processor.mpc_reserved[0] = 0;
706 processor.mpc_reserved[1] = 0;
707 for (i = 0; i < 2; i++) {
708 processor.mpc_apicid = i;
709 MP_processor_info(&processor);
710 }
711
712 bus.mpc_type = MP_BUS;
713 bus.mpc_busid = 0;
714 switch (mpc_default_type) {
715 default:
716 printk("???\nUnknown standard configuration %d\n",
717 mpc_default_type);
718
719 case 1:
720 case 5:
721 memcpy(bus.mpc_bustype, "ISA ", 6);
722 break;
723 case 2:
724 case 6:
725 case 3:
726 memcpy(bus.mpc_bustype, "EISA ", 6);
727 break;
728 case 4:
729 case 7:
730 memcpy(bus.mpc_bustype, "MCA ", 6);
731 }
732 MP_bus_info(&bus);
733 if (mpc_default_type > 4) {
734 bus.mpc_busid = 1;
735 memcpy(bus.mpc_bustype, "PCI ", 6);
736 MP_bus_info(&bus);
737 }
738
739 ioapic.mpc_type = MP_IOAPIC;
740 ioapic.mpc_apicid = 2;
741 ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
742 ioapic.mpc_flags = MPC_APIC_USABLE;
743 ioapic.mpc_apicaddr = 0xFEC00000;
744 MP_ioapic_info(&ioapic);
745
746
747
748
749 construct_default_ioirq_mptable(mpc_default_type);
750
751 lintsrc.mpc_type = MP_LINTSRC;
752 lintsrc.mpc_irqflag = 0;
753 lintsrc.mpc_srcbusid = 0;
754 lintsrc.mpc_srcbusirq = 0;
755 lintsrc.mpc_destapic = MP_APIC_ALL;
756 for (i = 0; i < 2; i++) {
757 lintsrc.mpc_irqtype = linttypes[i];
758 lintsrc.mpc_destapiclint = i;
759 MP_lintsrc_info(&lintsrc);
760 }
761}
762
763static struct intel_mp_floating *mpf_found;
764extern void config_acpi_tables(void);
765
766
767
768
769void __init get_smp_config (void)
770{
771 struct intel_mp_floating *mpf = mpf_found;
772
773#ifdef CONFIG_X86_IO_APIC
774
775
776
777
778
779
780
781 config_acpi_tables();
782#endif
783
784 printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
785 if (mpf->mpf_feature2 & (1<<7)) {
786 printk(" IMCR and PIC compatibility mode.\n");
787 pic_mode = 1;
788 } else {
789 printk(" Virtual Wire compatibility mode.\n");
790 pic_mode = 0;
791 }
792
793
794
795
796 if (mpf->mpf_feature1 != 0) {
797
798 printk("Default MP configuration #%d\n", mpf->mpf_feature1);
799 construct_default_ISA_mptable(mpf->mpf_feature1);
800
801 } else if (mpf->mpf_physptr) {
802
803
804
805
806
807 if (!smp_read_mpc((void *)mpf->mpf_physptr)) {
808 smp_found_config = 0;
809 printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
810 printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
811 return;
812 }
813
814
815
816
817
818 if (!mp_irq_entries) {
819 struct mpc_config_bus bus;
820
821 printk("BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)\n");
822
823 bus.mpc_type = MP_BUS;
824 bus.mpc_busid = 0;
825 memcpy(bus.mpc_bustype, "ISA ", 6);
826 MP_bus_info(&bus);
827
828 construct_default_ioirq_mptable(0);
829 }
830
831 } else
832 BUG();
833
834 printk("Processors: %d\n", num_processors);
835
836
837
838}
839
840static int __init smp_scan_config (unsigned long base, unsigned long length)
841{
842 unsigned long *bp = phys_to_virt(base);
843 struct intel_mp_floating *mpf;
844
845 Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
846 if (sizeof(*mpf) != 16)
847 printk("Error: MPF size\n");
848
849 while (length > 0) {
850 mpf = (struct intel_mp_floating *)bp;
851 if ((*bp == SMP_MAGIC_IDENT) &&
852 (mpf->mpf_length == 1) &&
853 !mpf_checksum((unsigned char *)bp, 16) &&
854 ((mpf->mpf_specification == 1)
855 || (mpf->mpf_specification == 4)) ) {
856
857 smp_found_config = 1;
858 printk("found SMP MP-table at %08lx\n",
859 virt_to_phys(mpf));
860 reserve_bootmem(virt_to_phys(mpf), PAGE_SIZE);
861 if (mpf->mpf_physptr)
862 reserve_bootmem(mpf->mpf_physptr, PAGE_SIZE);
863 mpf_found = mpf;
864 return 1;
865 }
866 bp += 4;
867 length -= 16;
868 }
869 return 0;
870}
871
872void __init find_intel_smp (void)
873{
874 unsigned int address;
875
876
877
878
879
880
881
882
883
884 if (smp_scan_config(0x0,0x400) ||
885 smp_scan_config(639*0x400,0x400) ||
886 smp_scan_config(0xF0000,0x10000))
887 return;
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903 address = *(unsigned short *)phys_to_virt(0x40E);
904 address <<= 4;
905 smp_scan_config(address, 0x1000);
906}
907
908#else
909
910
911
912
913
914
915void __init find_visws_smp(void)
916{
917 smp_found_config = 1;
918
919 phys_cpu_present_map |= 2;
920 apic_version[1] |= 0x10;
921 apic_version[0] |= 0x10;
922
923 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
924}
925
926#endif
927
928
929
930
931
932void __init find_smp_config (void)
933{
934#ifdef CONFIG_X86_LOCAL_APIC
935 find_intel_smp();
936#endif
937#ifdef CONFIG_VISWS
938 find_visws_smp();
939#endif
940}
941
942