2 * Intel Multiprocessor Specification 1.1 and 1.4
3 * compliant MP-table parsing routines.
5 * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
6 * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
7 * (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de>
11 #include <linux/init.h>
12 #include <linux/delay.h>
13 #include <linux/bootmem.h>
14 #include <linux/kernel_stat.h>
15 #include <linux/mc146818rtc.h>
16 #include <linux/bitops.h>
17 #include <linux/acpi.h>
18 #include <linux/module.h>
19 #include <linux/smp.h>
20 #include <linux/acpi.h>
23 #include <asm/mpspec.h>
24 #include <asm/pgalloc.h>
25 #include <asm/io_apic.h>
26 #include <asm/proto.h>
27 #include <asm/bios_ebda.h>
29 #include <asm/trampoline.h>
30 #include <asm/setup.h>
32 #include <mach_apic.h>
34 #include <mach_apicdef.h>
35 #include <mach_mpparse.h>
39 * Checksum an MP configuration block.
42 static int __init
mpf_checksum(unsigned char *mp
, int len
)
52 static void __init
MP_processor_info(struct mpc_cpu
*m
)
55 char *bootup_cpu
= "";
57 if (!(m
->cpuflag
& CPU_ENABLED
)) {
62 if (x86_quirks
->mpc_apic_id
)
63 apicid
= x86_quirks
->mpc_apic_id(m
);
67 if (m
->cpuflag
& CPU_BOOTPROCESSOR
) {
68 bootup_cpu
= " (Bootup-CPU)";
69 boot_cpu_physical_apicid
= m
->apicid
;
72 printk(KERN_INFO
"Processor #%d%s\n", m
->apicid
, bootup_cpu
);
73 generic_processor_info(apicid
, m
->apicver
);
76 #ifdef CONFIG_X86_IO_APIC
77 static void __init
MP_bus_info(struct mpc_bus
*m
)
80 memcpy(str
, m
->mpc_bustype
, 6);
83 if (x86_quirks
->mpc_oem_bus_info
)
84 x86_quirks
->mpc_oem_bus_info(m
, str
);
86 apic_printk(APIC_VERBOSE
, "Bus #%d is %s\n", m
->mpc_busid
, str
);
88 #if MAX_MP_BUSSES < 256
89 if (m
->mpc_busid
>= MAX_MP_BUSSES
) {
90 printk(KERN_WARNING
"MP table busid value (%d) for bustype %s "
91 " is too large, max. supported is %d\n",
92 m
->mpc_busid
, str
, MAX_MP_BUSSES
- 1);
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
;
102 } else if (strncmp(str
, BUSTYPE_PCI
, sizeof(BUSTYPE_PCI
) - 1) == 0) {
103 if (x86_quirks
->mpc_oem_pci_bus
)
104 x86_quirks
->mpc_oem_pci_bus(m
);
106 clear_bit(m
->mpc_busid
, mp_bus_not_pci
);
107 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
108 mp_bus_id_to_type
[m
->mpc_busid
] = MP_BUS_PCI
;
109 } else if (strncmp(str
, BUSTYPE_EISA
, sizeof(BUSTYPE_EISA
) - 1) == 0) {
110 mp_bus_id_to_type
[m
->mpc_busid
] = MP_BUS_EISA
;
111 } else if (strncmp(str
, BUSTYPE_MCA
, sizeof(BUSTYPE_MCA
) - 1) == 0) {
112 mp_bus_id_to_type
[m
->mpc_busid
] = MP_BUS_MCA
;
115 printk(KERN_WARNING
"Unknown bustype %s - ignoring\n", str
);
119 #ifdef CONFIG_X86_IO_APIC
121 static int bad_ioapic(unsigned long address
)
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");
129 printk(KERN_ERR
"WARNING: Bogus (zero) I/O APIC address"
130 " found in table, skipping!\n");
136 static void __init
MP_ioapic_info(struct mpc_ioapic
*m
)
138 if (!(m
->flags
& MPC_APIC_USABLE
))
141 printk(KERN_INFO
"I/O APIC #%d Version %d at 0x%X.\n",
142 m
->apicid
, m
->apicver
, m
->apicaddr
);
144 if (bad_ioapic(m
->apicaddr
))
147 mp_ioapics
[nr_ioapics
].mp_apicaddr
= m
->apicaddr
;
148 mp_ioapics
[nr_ioapics
].mp_apicid
= m
->apicid
;
149 mp_ioapics
[nr_ioapics
].mp_type
= m
->type
;
150 mp_ioapics
[nr_ioapics
].mp_apicver
= m
->apicver
;
151 mp_ioapics
[nr_ioapics
].mp_flags
= m
->flags
;
155 static void print_MP_intsrc_info(struct mpc_intsrc
*m
)
157 apic_printk(APIC_VERBOSE
, "Int: type %d, pol %d, trig %d, bus %02x,"
158 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
159 m
->irqtype
, m
->irqflag
& 3, (m
->irqflag
>> 2) & 3, m
->srcbus
,
160 m
->srcbusirq
, m
->dstapic
, m
->dstirq
);
163 static void __init
print_mp_irq_info(struct mp_config_intsrc
*mp_irq
)
165 apic_printk(APIC_VERBOSE
, "Int: type %d, pol %d, trig %d, bus %02x,"
166 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
167 mp_irq
->mp_irqtype
, mp_irq
->mp_irqflag
& 3,
168 (mp_irq
->mp_irqflag
>> 2) & 3, mp_irq
->mp_srcbus
,
169 mp_irq
->mp_srcbusirq
, mp_irq
->mp_dstapic
, mp_irq
->mp_dstirq
);
172 static void __init
assign_to_mp_irq(struct mpc_intsrc
*m
,
173 struct mp_config_intsrc
*mp_irq
)
175 mp_irq
->mp_dstapic
= m
->dstapic
;
176 mp_irq
->mp_type
= m
->type
;
177 mp_irq
->mp_irqtype
= m
->irqtype
;
178 mp_irq
->mp_irqflag
= m
->irqflag
;
179 mp_irq
->mp_srcbus
= m
->srcbus
;
180 mp_irq
->mp_srcbusirq
= m
->srcbusirq
;
181 mp_irq
->mp_dstirq
= m
->dstirq
;
184 static void __init
assign_to_mpc_intsrc(struct mp_config_intsrc
*mp_irq
,
185 struct mpc_intsrc
*m
)
187 m
->dstapic
= mp_irq
->mp_dstapic
;
188 m
->type
= mp_irq
->mp_type
;
189 m
->irqtype
= mp_irq
->mp_irqtype
;
190 m
->irqflag
= mp_irq
->mp_irqflag
;
191 m
->srcbus
= mp_irq
->mp_srcbus
;
192 m
->srcbusirq
= mp_irq
->mp_srcbusirq
;
193 m
->dstirq
= mp_irq
->mp_dstirq
;
196 static int __init
mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc
*mp_irq
,
197 struct mpc_intsrc
*m
)
199 if (mp_irq
->mp_dstapic
!= m
->dstapic
)
201 if (mp_irq
->mp_type
!= m
->type
)
203 if (mp_irq
->mp_irqtype
!= m
->irqtype
)
205 if (mp_irq
->mp_irqflag
!= m
->irqflag
)
207 if (mp_irq
->mp_srcbus
!= m
->srcbus
)
209 if (mp_irq
->mp_srcbusirq
!= m
->srcbusirq
)
211 if (mp_irq
->mp_dstirq
!= m
->dstirq
)
217 static void __init
MP_intsrc_info(struct mpc_intsrc
*m
)
221 print_MP_intsrc_info(m
);
223 for (i
= 0; i
< mp_irq_entries
; i
++) {
224 if (!mp_irq_mpc_intsrc_cmp(&mp_irqs
[i
], m
))
228 assign_to_mp_irq(m
, &mp_irqs
[mp_irq_entries
]);
229 if (++mp_irq_entries
== MAX_IRQ_SOURCES
)
230 panic("Max # of irq sources exceeded!!\n");
235 static void __init
MP_lintsrc_info(struct mpc_lintsrc
*m
)
237 apic_printk(APIC_VERBOSE
, "Lint: type %d, pol %d, trig %d, bus %02x,"
238 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
239 m
->irqtype
, m
->irqflag
& 3, (m
->irqflag
>> 2) & 3, m
->srcbusid
,
240 m
->srcbusirq
, m
->destapic
, m
->destapiclint
);
247 static int __init
smp_check_mpc(struct mpc_table
*mpc
, char *oem
, char *str
)
250 if (memcmp(mpc
->mpc_signature
, MPC_SIGNATURE
, 4)) {
251 printk(KERN_ERR
"MPTABLE: bad signature [%c%c%c%c]!\n",
252 mpc
->mpc_signature
[0], mpc
->mpc_signature
[1],
253 mpc
->mpc_signature
[2], mpc
->mpc_signature
[3]);
256 if (mpf_checksum((unsigned char *)mpc
, mpc
->mpc_length
)) {
257 printk(KERN_ERR
"MPTABLE: checksum error!\n");
260 if (mpc
->mpc_spec
!= 0x01 && mpc
->mpc_spec
!= 0x04) {
261 printk(KERN_ERR
"MPTABLE: bad table version (%d)!!\n",
265 if (!mpc
->mpc_lapic
) {
266 printk(KERN_ERR
"MPTABLE: null local APIC address!\n");
269 memcpy(oem
, mpc
->mpc_oem
, 8);
271 printk(KERN_INFO
"MPTABLE: OEM ID: %s\n", oem
);
273 memcpy(str
, mpc
->mpc_productid
, 12);
276 printk(KERN_INFO
"MPTABLE: Product ID: %s\n", str
);
278 printk(KERN_INFO
"MPTABLE: APIC at: 0x%X\n", mpc
->mpc_lapic
);
283 static int __init
smp_read_mpc(struct mpc_table
*mpc
, unsigned early
)
288 int count
= sizeof(*mpc
);
289 unsigned char *mpt
= ((unsigned char *)mpc
) + count
;
291 if (!smp_check_mpc(mpc
, oem
, str
))
296 * need to make sure summit and es7000's mps_oem_check is safe to be
297 * called early via genericarch 's mps_oem_check
300 #ifdef CONFIG_X86_NUMAQ
301 numaq_mps_oem_check(mpc
, oem
, str
);
304 mps_oem_check(mpc
, oem
, str
);
306 /* save the local APIC address, it might be non-default */
308 mp_lapic_addr
= mpc
->mpc_lapic
;
313 if (mpc
->mpc_oemptr
&& x86_quirks
->smp_read_mpc_oem
) {
314 struct mpc_oemtable
*oem_table
= (void *)(long)mpc
->mpc_oemptr
;
315 x86_quirks
->smp_read_mpc_oem(oem_table
, mpc
->mpc_oemsize
);
319 * Now process the configuration blocks.
321 if (x86_quirks
->mpc_record
)
322 *x86_quirks
->mpc_record
= 0;
324 while (count
< mpc
->mpc_length
) {
328 struct mpc_cpu
*m
= (struct mpc_cpu
*)mpt
;
329 /* ACPI may have already provided this data */
331 MP_processor_info(m
);
338 struct mpc_bus
*m
= (struct mpc_bus
*)mpt
;
339 #ifdef CONFIG_X86_IO_APIC
348 #ifdef CONFIG_X86_IO_APIC
349 struct mpc_ioapic
*m
= (struct mpc_ioapic
*)mpt
;
352 mpt
+= sizeof(struct mpc_ioapic
);
353 count
+= sizeof(struct mpc_ioapic
);
358 #ifdef CONFIG_X86_IO_APIC
359 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
363 mpt
+= sizeof(struct mpc_intsrc
);
364 count
+= sizeof(struct mpc_intsrc
);
369 struct mpc_lintsrc
*m
=
370 (struct mpc_lintsrc
*)mpt
;
378 printk(KERN_ERR
"Your mptable is wrong, contact your HW vendor!\n");
379 printk(KERN_ERR
"type %x\n", *mpt
);
380 print_hex_dump(KERN_ERR
, " ", DUMP_PREFIX_ADDRESS
, 16,
381 1, mpc
, mpc
->mpc_length
, 1);
382 count
= mpc
->mpc_length
;
385 if (x86_quirks
->mpc_record
)
386 (*x86_quirks
->mpc_record
)++;
389 #ifdef CONFIG_X86_GENERICARCH
390 generic_bigsmp_probe();
394 setup_apic_routing();
397 printk(KERN_ERR
"MPTABLE: no processors registered!\n");
398 return num_processors
;
401 #ifdef CONFIG_X86_IO_APIC
403 static int __init
ELCR_trigger(unsigned int irq
)
407 port
= 0x4d0 + (irq
>> 3);
408 return (inb(port
) >> (irq
& 7)) & 1;
411 static void __init
construct_default_ioirq_mptable(int mpc_default_type
)
413 struct mpc_intsrc intsrc
;
415 int ELCR_fallback
= 0;
417 intsrc
.type
= MP_INTSRC
;
418 intsrc
.irqflag
= 0; /* conforming */
420 intsrc
.dstapic
= mp_ioapics
[0].mp_apicid
;
422 intsrc
.irqtype
= mp_INT
;
425 * If true, we have an ISA/PCI system with no IRQ entries
426 * in the MP table. To prevent the PCI interrupts from being set up
427 * incorrectly, we try to use the ELCR. The sanity check to see if
428 * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
429 * never be level sensitive, so we simply see if the ELCR agrees.
430 * If it does, we assume it's valid.
432 if (mpc_default_type
== 5) {
433 printk(KERN_INFO
"ISA/PCI bus type with no IRQ information... "
434 "falling back to ELCR\n");
436 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) ||
438 printk(KERN_ERR
"ELCR contains invalid data... "
442 "Using ELCR to identify PCI interrupts\n");
447 for (i
= 0; i
< 16; i
++) {
448 switch (mpc_default_type
) {
450 if (i
== 0 || i
== 13)
451 continue; /* IRQ0 & IRQ13 not connected */
455 continue; /* IRQ2 is never connected */
460 * If the ELCR indicates a level-sensitive interrupt, we
461 * copy that information over to the MP table in the
462 * irqflag field (level sensitive, active high polarity).
470 intsrc
.srcbusirq
= i
;
471 intsrc
.dstirq
= i
? i
: 2; /* IRQ0 to INTIN2 */
472 MP_intsrc_info(&intsrc
);
475 intsrc
.irqtype
= mp_ExtINT
;
476 intsrc
.srcbusirq
= 0;
477 intsrc
.dstirq
= 0; /* 8259A to INTIN0 */
478 MP_intsrc_info(&intsrc
);
482 static void __init
construct_ioapic_table(int mpc_default_type
)
484 struct mpc_ioapic ioapic
;
487 bus
.mpc_type
= MP_BUS
;
489 switch (mpc_default_type
) {
491 printk(KERN_ERR
"???\nUnknown standard configuration %d\n",
496 memcpy(bus
.mpc_bustype
, "ISA ", 6);
501 memcpy(bus
.mpc_bustype
, "EISA ", 6);
505 memcpy(bus
.mpc_bustype
, "MCA ", 6);
508 if (mpc_default_type
> 4) {
510 memcpy(bus
.mpc_bustype
, "PCI ", 6);
514 ioapic
.type
= MP_IOAPIC
;
516 ioapic
.apicver
= mpc_default_type
> 4 ? 0x10 : 0x01;
517 ioapic
.flags
= MPC_APIC_USABLE
;
518 ioapic
.apicaddr
= 0xFEC00000;
519 MP_ioapic_info(&ioapic
);
522 * We set up most of the low 16 IO-APIC pins according to MPS rules.
524 construct_default_ioirq_mptable(mpc_default_type
);
527 static inline void __init
construct_ioapic_table(int mpc_default_type
) { }
530 static inline void __init
construct_default_ISA_mptable(int mpc_default_type
)
532 struct mpc_cpu processor
;
533 struct mpc_lintsrc lintsrc
;
534 int linttypes
[2] = { mp_ExtINT
, mp_NMI
};
538 * local APIC has default address
540 mp_lapic_addr
= APIC_DEFAULT_PHYS_BASE
;
543 * 2 CPUs, numbered 0 & 1.
545 processor
.type
= MP_PROCESSOR
;
546 /* Either an integrated APIC or a discrete 82489DX. */
547 processor
.apicver
= mpc_default_type
> 4 ? 0x10 : 0x01;
548 processor
.cpuflag
= CPU_ENABLED
;
549 processor
.cpufeature
= (boot_cpu_data
.x86
<< 8) |
550 (boot_cpu_data
.x86_model
<< 4) | boot_cpu_data
.x86_mask
;
551 processor
.featureflag
= boot_cpu_data
.x86_capability
[0];
552 processor
.reserved
[0] = 0;
553 processor
.reserved
[1] = 0;
554 for (i
= 0; i
< 2; i
++) {
555 processor
.apicid
= i
;
556 MP_processor_info(&processor
);
559 construct_ioapic_table(mpc_default_type
);
561 lintsrc
.type
= MP_LINTSRC
;
562 lintsrc
.irqflag
= 0; /* conforming */
563 lintsrc
.srcbusid
= 0;
564 lintsrc
.srcbusirq
= 0;
565 lintsrc
.destapic
= MP_APIC_ALL
;
566 for (i
= 0; i
< 2; i
++) {
567 lintsrc
.irqtype
= linttypes
[i
];
568 lintsrc
.destapiclint
= i
;
569 MP_lintsrc_info(&lintsrc
);
573 static struct intel_mp_floating
*mpf_found
;
576 * Scan the memory blocks for an SMP configuration block.
578 static void __init
__get_smp_config(unsigned int early
)
580 struct intel_mp_floating
*mpf
= mpf_found
;
585 if (acpi_lapic
&& early
)
589 * MPS doesn't support hyperthreading, aka only have
590 * thread 0 apic id in MPS table
592 if (acpi_lapic
&& acpi_ioapic
)
595 if (x86_quirks
->mach_get_smp_config
) {
596 if (x86_quirks
->mach_get_smp_config(early
))
600 printk(KERN_INFO
"Intel MultiProcessor Specification v1.%d\n",
601 mpf
->mpf_specification
);
602 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
603 if (mpf
->mpf_feature2
& (1 << 7)) {
604 printk(KERN_INFO
" IMCR and PIC compatibility mode.\n");
607 printk(KERN_INFO
" Virtual Wire compatibility mode.\n");
612 * Now see if we need to read further.
614 if (mpf
->mpf_feature1
!= 0) {
617 * local APIC has default address
619 mp_lapic_addr
= APIC_DEFAULT_PHYS_BASE
;
623 printk(KERN_INFO
"Default MP configuration #%d\n",
625 construct_default_ISA_mptable(mpf
->mpf_feature1
);
627 } else if (mpf
->mpf_physptr
) {
630 * Read the physical hardware table. Anything here will
631 * override the defaults.
633 if (!smp_read_mpc(phys_to_virt(mpf
->mpf_physptr
), early
)) {
634 #ifdef CONFIG_X86_LOCAL_APIC
635 smp_found_config
= 0;
638 "BIOS bug, MP table errors detected!...\n");
639 printk(KERN_ERR
"... disabling SMP support. "
640 "(tell your hw vendor)\n");
646 #ifdef CONFIG_X86_IO_APIC
648 * If there are no explicit MP IRQ entries, then we are
649 * broken. We set up most of the low 16 IO-APIC pins to
650 * ISA defaults and hope it will work.
652 if (!mp_irq_entries
) {
655 printk(KERN_ERR
"BIOS bug, no explicit IRQ entries, "
656 "using default mptable. "
657 "(tell your hw vendor)\n");
659 bus
.mpc_type
= MP_BUS
;
661 memcpy(bus
.mpc_bustype
, "ISA ", 6);
664 construct_default_ioirq_mptable(0);
671 printk(KERN_INFO
"Processors: %d\n", num_processors
);
673 * Only use the first configuration found.
677 void __init
early_get_smp_config(void)
682 void __init
get_smp_config(void)
687 static int __init
smp_scan_config(unsigned long base
, unsigned long length
,
690 unsigned int *bp
= phys_to_virt(base
);
691 struct intel_mp_floating
*mpf
;
693 apic_printk(APIC_VERBOSE
, "Scan SMP from %p for %ld bytes.\n",
695 BUILD_BUG_ON(sizeof(*mpf
) != 16);
698 mpf
= (struct intel_mp_floating
*)bp
;
699 if ((*bp
== SMP_MAGIC_IDENT
) &&
700 (mpf
->mpf_length
== 1) &&
701 !mpf_checksum((unsigned char *)bp
, 16) &&
702 ((mpf
->mpf_specification
== 1)
703 || (mpf
->mpf_specification
== 4))) {
704 #ifdef CONFIG_X86_LOCAL_APIC
705 smp_found_config
= 1;
709 printk(KERN_INFO
"found SMP MP-table at [%p] %08lx\n",
710 mpf
, virt_to_phys(mpf
));
714 reserve_bootmem_generic(virt_to_phys(mpf
), PAGE_SIZE
,
716 if (mpf
->mpf_physptr
) {
717 unsigned long size
= PAGE_SIZE
;
720 * We cannot access to MPC table to compute
721 * table size yet, as only few megabytes from
722 * the bottom is mapped now.
723 * PC-9800's MPC table places on the very last
724 * of physical memory; so that simply reserving
725 * PAGE_SIZE from mpg->mpf_physptr yields BUG()
726 * in reserve_bootmem.
728 unsigned long end
= max_low_pfn
* PAGE_SIZE
;
729 if (mpf
->mpf_physptr
+ size
> end
)
730 size
= end
- mpf
->mpf_physptr
;
732 reserve_bootmem_generic(mpf
->mpf_physptr
, size
,
744 static void __init
__find_smp_config(unsigned int reserve
)
746 unsigned int address
;
748 if (x86_quirks
->mach_find_smp_config
) {
749 if (x86_quirks
->mach_find_smp_config(reserve
))
753 * FIXME: Linux assumes you have 640K of base ram..
754 * this continues the error...
756 * 1) Scan the bottom 1K for a signature
757 * 2) Scan the top 1K of base RAM
758 * 3) Scan the 64K of bios
760 if (smp_scan_config(0x0, 0x400, reserve
) ||
761 smp_scan_config(639 * 0x400, 0x400, reserve
) ||
762 smp_scan_config(0xF0000, 0x10000, reserve
))
765 * If it is an SMP machine we should know now, unless the
766 * configuration is in an EISA/MCA bus machine with an
767 * extended bios data area.
769 * there is a real-mode segmented pointer pointing to the
770 * 4K EBDA area at 0x40E, calculate and scan it here.
772 * NOTE! There are Linux loaders that will corrupt the EBDA
773 * area, and as such this kind of SMP config may be less
774 * trustworthy, simply because the SMP table may have been
775 * stomped on during early boot. These loaders are buggy and
778 * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
781 address
= get_bios_ebda();
783 smp_scan_config(address
, 0x400, reserve
);
786 void __init
early_find_smp_config(void)
788 __find_smp_config(0);
791 void __init
find_smp_config(void)
793 __find_smp_config(1);
796 #ifdef CONFIG_X86_IO_APIC
797 static u8 __initdata irq_used
[MAX_IRQ_SOURCES
];
799 static int __init
get_MP_intsrc_index(struct mpc_intsrc
*m
)
803 if (m
->irqtype
!= mp_INT
)
806 if (m
->irqflag
!= 0x0f)
811 for (i
= 0; i
< mp_irq_entries
; i
++) {
812 if (mp_irqs
[i
].mp_irqtype
!= mp_INT
)
815 if (mp_irqs
[i
].mp_irqflag
!= 0x0f)
818 if (mp_irqs
[i
].mp_srcbus
!= m
->srcbus
)
820 if (mp_irqs
[i
].mp_srcbusirq
!= m
->srcbusirq
)
823 /* already claimed */
834 #define SPARE_SLOT_NUM 20
836 static struct mpc_intsrc __initdata
*m_spare
[SPARE_SLOT_NUM
];
839 static int __init
replace_intsrc_all(struct mpc_table
*mpc
,
840 unsigned long mpc_new_phys
,
841 unsigned long mpc_new_length
)
843 #ifdef CONFIG_X86_IO_APIC
848 int count
= sizeof(*mpc
);
849 unsigned char *mpt
= ((unsigned char *)mpc
) + count
;
851 printk(KERN_INFO
"mpc_length %x\n", mpc
->mpc_length
);
852 while (count
< mpc
->mpc_length
) {
856 struct mpc_cpu
*m
= (struct mpc_cpu
*)mpt
;
863 struct mpc_bus
*m
= (struct mpc_bus
*)mpt
;
870 mpt
+= sizeof(struct mpc_ioapic
);
871 count
+= sizeof(struct mpc_ioapic
);
876 #ifdef CONFIG_X86_IO_APIC
877 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
879 printk(KERN_INFO
"OLD ");
880 print_MP_intsrc_info(m
);
881 i
= get_MP_intsrc_index(m
);
883 assign_to_mpc_intsrc(&mp_irqs
[i
], m
);
884 printk(KERN_INFO
"NEW ");
885 print_mp_irq_info(&mp_irqs
[i
]);
887 /* legacy, do nothing */
888 } else if (nr_m_spare
< SPARE_SLOT_NUM
) {
890 * not found (-1), or duplicated (-2)
891 * are invalid entries,
892 * we need to use the slot later
894 m_spare
[nr_m_spare
] = m
;
898 mpt
+= sizeof(struct mpc_intsrc
);
899 count
+= sizeof(struct mpc_intsrc
);
904 struct mpc_lintsrc
*m
=
905 (struct mpc_lintsrc
*)mpt
;
912 printk(KERN_ERR
"Your mptable is wrong, contact your HW vendor!\n");
913 printk(KERN_ERR
"type %x\n", *mpt
);
914 print_hex_dump(KERN_ERR
, " ", DUMP_PREFIX_ADDRESS
, 16,
915 1, mpc
, mpc
->mpc_length
, 1);
920 #ifdef CONFIG_X86_IO_APIC
921 for (i
= 0; i
< mp_irq_entries
; i
++) {
925 if (mp_irqs
[i
].mp_irqtype
!= mp_INT
)
928 if (mp_irqs
[i
].mp_irqflag
!= 0x0f)
931 if (nr_m_spare
> 0) {
932 printk(KERN_INFO
"*NEW* found ");
934 assign_to_mpc_intsrc(&mp_irqs
[i
], m_spare
[nr_m_spare
]);
935 m_spare
[nr_m_spare
] = NULL
;
937 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
938 count
+= sizeof(struct mpc_intsrc
);
940 printk(KERN_INFO
"No spare slots, try to append...take your risk, new mpc_length %x\n", count
);
942 if (count
<= mpc_new_length
)
943 printk(KERN_INFO
"No spare slots, try to append..., new mpc_length %x\n", count
);
945 printk(KERN_ERR
"mpc_new_length %lx is too small\n", mpc_new_length
);
949 assign_to_mpc_intsrc(&mp_irqs
[i
], m
);
950 mpc
->mpc_length
= count
;
951 mpt
+= sizeof(struct mpc_intsrc
);
953 print_mp_irq_info(&mp_irqs
[i
]);
957 /* update checksum */
958 mpc
->mpc_checksum
= 0;
959 mpc
->mpc_checksum
-= mpf_checksum((unsigned char *)mpc
,
965 static int __initdata enable_update_mptable
;
967 static int __init
update_mptable_setup(char *str
)
969 enable_update_mptable
= 1;
972 early_param("update_mptable", update_mptable_setup
);
974 static unsigned long __initdata mpc_new_phys
;
975 static unsigned long mpc_new_length __initdata
= 4096;
977 /* alloc_mptable or alloc_mptable=4k */
978 static int __initdata alloc_mptable
;
979 static int __init
parse_alloc_mptable_opt(char *p
)
981 enable_update_mptable
= 1;
985 mpc_new_length
= memparse(p
, &p
);
988 early_param("alloc_mptable", parse_alloc_mptable_opt
);
990 void __init
early_reserve_e820_mpc_new(void)
992 if (enable_update_mptable
&& alloc_mptable
) {
994 #ifdef CONFIG_X86_TRAMPOLINE
995 startt
= TRAMPOLINE_BASE
;
997 mpc_new_phys
= early_reserve_e820(startt
, mpc_new_length
, 4);
1001 static int __init
update_mp_table(void)
1005 struct intel_mp_floating
*mpf
;
1006 struct mpc_table
*mpc
, *mpc_new
;
1008 if (!enable_update_mptable
)
1016 * Now see if we need to go further.
1018 if (mpf
->mpf_feature1
!= 0)
1021 if (!mpf
->mpf_physptr
)
1024 mpc
= phys_to_virt(mpf
->mpf_physptr
);
1026 if (!smp_check_mpc(mpc
, oem
, str
))
1029 printk(KERN_INFO
"mpf: %lx\n", virt_to_phys(mpf
));
1030 printk(KERN_INFO
"mpf_physptr: %x\n", mpf
->mpf_physptr
);
1032 if (mpc_new_phys
&& mpc
->mpc_length
> mpc_new_length
) {
1034 printk(KERN_INFO
"mpc_new_length is %ld, please use alloc_mptable=8k\n",
1038 if (!mpc_new_phys
) {
1039 unsigned char old
, new;
1040 /* check if we can change the postion */
1041 mpc
->mpc_checksum
= 0;
1042 old
= mpf_checksum((unsigned char *)mpc
, mpc
->mpc_length
);
1043 mpc
->mpc_checksum
= 0xff;
1044 new = mpf_checksum((unsigned char *)mpc
, mpc
->mpc_length
);
1046 printk(KERN_INFO
"mpc is readonly, please try alloc_mptable instead\n");
1049 printk(KERN_INFO
"use in-positon replacing\n");
1051 mpf
->mpf_physptr
= mpc_new_phys
;
1052 mpc_new
= phys_to_virt(mpc_new_phys
);
1053 memcpy(mpc_new
, mpc
, mpc
->mpc_length
);
1055 /* check if we can modify that */
1056 if (mpc_new_phys
- mpf
->mpf_physptr
) {
1057 struct intel_mp_floating
*mpf_new
;
1058 /* steal 16 bytes from [0, 1k) */
1059 printk(KERN_INFO
"mpf new: %x\n", 0x400 - 16);
1060 mpf_new
= phys_to_virt(0x400 - 16);
1061 memcpy(mpf_new
, mpf
, 16);
1063 mpf
->mpf_physptr
= mpc_new_phys
;
1065 mpf
->mpf_checksum
= 0;
1066 mpf
->mpf_checksum
-= mpf_checksum((unsigned char *)mpf
, 16);
1067 printk(KERN_INFO
"mpf_physptr new: %x\n", mpf
->mpf_physptr
);
1071 * only replace the one with mp_INT and
1072 * MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
1073 * already in mp_irqs , stored by ... and mp_config_acpi_gsi,
1074 * may need pci=routeirq for all coverage
1076 replace_intsrc_all(mpc
, mpc_new_phys
, mpc_new_length
);
1081 late_initcall(update_mp_table
);