2 * Intel Multiprocessor Specification 1.1 and 1.4
3 * compliant MP-table parsing routines.
5 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
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>
22 #include <asm/mpspec.h>
23 #include <asm/pgalloc.h>
24 #include <asm/io_apic.h>
25 #include <asm/proto.h>
26 #include <asm/bios_ebda.h>
28 #include <asm/trampoline.h>
29 #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
->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
->busid
, str
);
88 #if MAX_MP_BUSSES < 256
89 if (m
->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
->busid
, str
, MAX_MP_BUSSES
- 1);
97 if (strncmp(str
, BUSTYPE_ISA
, sizeof(BUSTYPE_ISA
) - 1) == 0) {
98 set_bit(m
->busid
, mp_bus_not_pci
);
99 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
100 mp_bus_id_to_type
[m
->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
->busid
, mp_bus_not_pci
);
107 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
108 mp_bus_id_to_type
[m
->busid
] = MP_BUS_PCI
;
109 } else if (strncmp(str
, BUSTYPE_EISA
, sizeof(BUSTYPE_EISA
) - 1) == 0) {
110 mp_bus_id_to_type
[m
->busid
] = MP_BUS_EISA
;
111 } else if (strncmp(str
, BUSTYPE_MCA
, sizeof(BUSTYPE_MCA
) - 1) == 0) {
112 mp_bus_id_to_type
[m
->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
].apicaddr
= m
->apicaddr
;
148 mp_ioapics
[nr_ioapics
].apicid
= m
->apicid
;
149 mp_ioapics
[nr_ioapics
].type
= m
->type
;
150 mp_ioapics
[nr_ioapics
].apicver
= m
->apicver
;
151 mp_ioapics
[nr_ioapics
].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 mpc_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
->irqtype
, mp_irq
->irqflag
& 3,
168 (mp_irq
->irqflag
>> 2) & 3, mp_irq
->srcbus
,
169 mp_irq
->srcbusirq
, mp_irq
->dstapic
, mp_irq
->dstirq
);
172 static void __init
assign_to_mp_irq(struct mpc_intsrc
*m
,
173 struct mpc_intsrc
*mp_irq
)
175 mp_irq
->dstapic
= m
->dstapic
;
176 mp_irq
->type
= m
->type
;
177 mp_irq
->irqtype
= m
->irqtype
;
178 mp_irq
->irqflag
= m
->irqflag
;
179 mp_irq
->srcbus
= m
->srcbus
;
180 mp_irq
->srcbusirq
= m
->srcbusirq
;
181 mp_irq
->dstirq
= m
->dstirq
;
184 static void __init
assign_to_mpc_intsrc(struct mpc_intsrc
*mp_irq
,
185 struct mpc_intsrc
*m
)
187 m
->dstapic
= mp_irq
->dstapic
;
188 m
->type
= mp_irq
->type
;
189 m
->irqtype
= mp_irq
->irqtype
;
190 m
->irqflag
= mp_irq
->irqflag
;
191 m
->srcbus
= mp_irq
->srcbus
;
192 m
->srcbusirq
= mp_irq
->srcbusirq
;
193 m
->dstirq
= mp_irq
->dstirq
;
196 static int __init
mp_irq_mpc_intsrc_cmp(struct mpc_intsrc
*mp_irq
,
197 struct mpc_intsrc
*m
)
199 if (mp_irq
->dstapic
!= m
->dstapic
)
201 if (mp_irq
->type
!= m
->type
)
203 if (mp_irq
->irqtype
!= m
->irqtype
)
205 if (mp_irq
->irqflag
!= m
->irqflag
)
207 if (mp_irq
->srcbus
!= m
->srcbus
)
209 if (mp_irq
->srcbusirq
!= m
->srcbusirq
)
211 if (mp_irq
->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
->signature
, MPC_SIGNATURE
, 4)) {
251 printk(KERN_ERR
"MPTABLE: bad signature [%c%c%c%c]!\n",
252 mpc
->signature
[0], mpc
->signature
[1],
253 mpc
->signature
[2], mpc
->signature
[3]);
256 if (mpf_checksum((unsigned char *)mpc
, mpc
->length
)) {
257 printk(KERN_ERR
"MPTABLE: checksum error!\n");
260 if (mpc
->spec
!= 0x01 && mpc
->spec
!= 0x04) {
261 printk(KERN_ERR
"MPTABLE: bad table version (%d)!!\n",
266 printk(KERN_ERR
"MPTABLE: null local APIC address!\n");
269 memcpy(oem
, mpc
->oem
, 8);
271 printk(KERN_INFO
"MPTABLE: OEM ID: %s\n", oem
);
273 memcpy(str
, mpc
->productid
, 12);
276 printk(KERN_INFO
"MPTABLE: Product ID: %s\n", str
);
278 printk(KERN_INFO
"MPTABLE: APIC at: 0x%X\n", 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
))
295 generic_mps_oem_check(mpc
, oem
, str
);
297 /* save the local APIC address, it might be non-default */
299 mp_lapic_addr
= mpc
->lapic
;
304 if (mpc
->oemptr
&& x86_quirks
->smp_read_mpc_oem
) {
305 struct mpc_oemtable
*oem_table
= (void *)(long)mpc
->oemptr
;
306 x86_quirks
->smp_read_mpc_oem(oem_table
, mpc
->oemsize
);
310 * Now process the configuration blocks.
312 if (x86_quirks
->mpc_record
)
313 *x86_quirks
->mpc_record
= 0;
315 while (count
< mpc
->length
) {
319 struct mpc_cpu
*m
= (struct mpc_cpu
*)mpt
;
320 /* ACPI may have already provided this data */
322 MP_processor_info(m
);
329 struct mpc_bus
*m
= (struct mpc_bus
*)mpt
;
330 #ifdef CONFIG_X86_IO_APIC
339 #ifdef CONFIG_X86_IO_APIC
340 struct mpc_ioapic
*m
= (struct mpc_ioapic
*)mpt
;
343 mpt
+= sizeof(struct mpc_ioapic
);
344 count
+= sizeof(struct mpc_ioapic
);
349 #ifdef CONFIG_X86_IO_APIC
350 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
354 mpt
+= sizeof(struct mpc_intsrc
);
355 count
+= sizeof(struct mpc_intsrc
);
360 struct mpc_lintsrc
*m
=
361 (struct mpc_lintsrc
*)mpt
;
369 printk(KERN_ERR
"Your mptable is wrong, contact your HW vendor!\n");
370 printk(KERN_ERR
"type %x\n", *mpt
);
371 print_hex_dump(KERN_ERR
, " ", DUMP_PREFIX_ADDRESS
, 16,
372 1, mpc
, mpc
->length
, 1);
376 if (x86_quirks
->mpc_record
)
377 (*x86_quirks
->mpc_record
)++;
380 #ifdef CONFIG_X86_GENERICARCH
381 generic_bigsmp_probe();
384 if (apic
->setup_apic_routing
)
385 apic
->setup_apic_routing();
388 printk(KERN_ERR
"MPTABLE: no processors registered!\n");
389 return num_processors
;
392 #ifdef CONFIG_X86_IO_APIC
394 static int __init
ELCR_trigger(unsigned int irq
)
398 port
= 0x4d0 + (irq
>> 3);
399 return (inb(port
) >> (irq
& 7)) & 1;
402 static void __init
construct_default_ioirq_mptable(int mpc_default_type
)
404 struct mpc_intsrc intsrc
;
406 int ELCR_fallback
= 0;
408 intsrc
.type
= MP_INTSRC
;
409 intsrc
.irqflag
= 0; /* conforming */
411 intsrc
.dstapic
= mp_ioapics
[0].apicid
;
413 intsrc
.irqtype
= mp_INT
;
416 * If true, we have an ISA/PCI system with no IRQ entries
417 * in the MP table. To prevent the PCI interrupts from being set up
418 * incorrectly, we try to use the ELCR. The sanity check to see if
419 * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
420 * never be level sensitive, so we simply see if the ELCR agrees.
421 * If it does, we assume it's valid.
423 if (mpc_default_type
== 5) {
424 printk(KERN_INFO
"ISA/PCI bus type with no IRQ information... "
425 "falling back to ELCR\n");
427 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) ||
429 printk(KERN_ERR
"ELCR contains invalid data... "
433 "Using ELCR to identify PCI interrupts\n");
438 for (i
= 0; i
< 16; i
++) {
439 switch (mpc_default_type
) {
441 if (i
== 0 || i
== 13)
442 continue; /* IRQ0 & IRQ13 not connected */
446 continue; /* IRQ2 is never connected */
451 * If the ELCR indicates a level-sensitive interrupt, we
452 * copy that information over to the MP table in the
453 * irqflag field (level sensitive, active high polarity).
461 intsrc
.srcbusirq
= i
;
462 intsrc
.dstirq
= i
? i
: 2; /* IRQ0 to INTIN2 */
463 MP_intsrc_info(&intsrc
);
466 intsrc
.irqtype
= mp_ExtINT
;
467 intsrc
.srcbusirq
= 0;
468 intsrc
.dstirq
= 0; /* 8259A to INTIN0 */
469 MP_intsrc_info(&intsrc
);
473 static void __init
construct_ioapic_table(int mpc_default_type
)
475 struct mpc_ioapic ioapic
;
480 switch (mpc_default_type
) {
482 printk(KERN_ERR
"???\nUnknown standard configuration %d\n",
487 memcpy(bus
.bustype
, "ISA ", 6);
492 memcpy(bus
.bustype
, "EISA ", 6);
496 memcpy(bus
.bustype
, "MCA ", 6);
499 if (mpc_default_type
> 4) {
501 memcpy(bus
.bustype
, "PCI ", 6);
505 ioapic
.type
= MP_IOAPIC
;
507 ioapic
.apicver
= mpc_default_type
> 4 ? 0x10 : 0x01;
508 ioapic
.flags
= MPC_APIC_USABLE
;
509 ioapic
.apicaddr
= 0xFEC00000;
510 MP_ioapic_info(&ioapic
);
513 * We set up most of the low 16 IO-APIC pins according to MPS rules.
515 construct_default_ioirq_mptable(mpc_default_type
);
518 static inline void __init
construct_ioapic_table(int mpc_default_type
) { }
521 static inline void __init
construct_default_ISA_mptable(int mpc_default_type
)
523 struct mpc_cpu processor
;
524 struct mpc_lintsrc lintsrc
;
525 int linttypes
[2] = { mp_ExtINT
, mp_NMI
};
529 * local APIC has default address
531 mp_lapic_addr
= APIC_DEFAULT_PHYS_BASE
;
534 * 2 CPUs, numbered 0 & 1.
536 processor
.type
= MP_PROCESSOR
;
537 /* Either an integrated APIC or a discrete 82489DX. */
538 processor
.apicver
= mpc_default_type
> 4 ? 0x10 : 0x01;
539 processor
.cpuflag
= CPU_ENABLED
;
540 processor
.cpufeature
= (boot_cpu_data
.x86
<< 8) |
541 (boot_cpu_data
.x86_model
<< 4) | boot_cpu_data
.x86_mask
;
542 processor
.featureflag
= boot_cpu_data
.x86_capability
[0];
543 processor
.reserved
[0] = 0;
544 processor
.reserved
[1] = 0;
545 for (i
= 0; i
< 2; i
++) {
546 processor
.apicid
= i
;
547 MP_processor_info(&processor
);
550 construct_ioapic_table(mpc_default_type
);
552 lintsrc
.type
= MP_LINTSRC
;
553 lintsrc
.irqflag
= 0; /* conforming */
554 lintsrc
.srcbusid
= 0;
555 lintsrc
.srcbusirq
= 0;
556 lintsrc
.destapic
= MP_APIC_ALL
;
557 for (i
= 0; i
< 2; i
++) {
558 lintsrc
.irqtype
= linttypes
[i
];
559 lintsrc
.destapiclint
= i
;
560 MP_lintsrc_info(&lintsrc
);
564 static struct mpf_intel
*mpf_found
;
567 * Scan the memory blocks for an SMP configuration block.
569 static void __init
__get_smp_config(unsigned int early
)
571 struct mpf_intel
*mpf
= mpf_found
;
576 if (acpi_lapic
&& early
)
580 * MPS doesn't support hyperthreading, aka only have
581 * thread 0 apic id in MPS table
583 if (acpi_lapic
&& acpi_ioapic
)
586 if (x86_quirks
->mach_get_smp_config
) {
587 if (x86_quirks
->mach_get_smp_config(early
))
591 printk(KERN_INFO
"Intel MultiProcessor Specification v1.%d\n",
593 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
594 if (mpf
->feature2
& (1 << 7)) {
595 printk(KERN_INFO
" IMCR and PIC compatibility mode.\n");
598 printk(KERN_INFO
" Virtual Wire compatibility mode.\n");
603 * Now see if we need to read further.
605 if (mpf
->feature1
!= 0) {
608 * local APIC has default address
610 mp_lapic_addr
= APIC_DEFAULT_PHYS_BASE
;
614 printk(KERN_INFO
"Default MP configuration #%d\n",
616 construct_default_ISA_mptable(mpf
->feature1
);
618 } else if (mpf
->physptr
) {
621 * Read the physical hardware table. Anything here will
622 * override the defaults.
624 if (!smp_read_mpc(phys_to_virt(mpf
->physptr
), early
)) {
625 #ifdef CONFIG_X86_LOCAL_APIC
626 smp_found_config
= 0;
629 "BIOS bug, MP table errors detected!...\n");
630 printk(KERN_ERR
"... disabling SMP support. "
631 "(tell your hw vendor)\n");
637 #ifdef CONFIG_X86_IO_APIC
639 * If there are no explicit MP IRQ entries, then we are
640 * broken. We set up most of the low 16 IO-APIC pins to
641 * ISA defaults and hope it will work.
643 if (!mp_irq_entries
) {
646 printk(KERN_ERR
"BIOS bug, no explicit IRQ entries, "
647 "using default mptable. "
648 "(tell your hw vendor)\n");
652 memcpy(bus
.bustype
, "ISA ", 6);
655 construct_default_ioirq_mptable(0);
662 printk(KERN_INFO
"Processors: %d\n", num_processors
);
664 * Only use the first configuration found.
668 void __init
early_get_smp_config(void)
673 void __init
get_smp_config(void)
678 static int __init
smp_scan_config(unsigned long base
, unsigned long length
,
681 unsigned int *bp
= phys_to_virt(base
);
682 struct mpf_intel
*mpf
;
684 apic_printk(APIC_VERBOSE
, "Scan SMP from %p for %ld bytes.\n",
686 BUILD_BUG_ON(sizeof(*mpf
) != 16);
689 mpf
= (struct mpf_intel
*)bp
;
690 if ((*bp
== SMP_MAGIC_IDENT
) &&
691 (mpf
->length
== 1) &&
692 !mpf_checksum((unsigned char *)bp
, 16) &&
693 ((mpf
->specification
== 1)
694 || (mpf
->specification
== 4))) {
695 #ifdef CONFIG_X86_LOCAL_APIC
696 smp_found_config
= 1;
700 printk(KERN_INFO
"found SMP MP-table at [%p] %08lx\n",
701 mpf
, virt_to_phys(mpf
));
705 reserve_bootmem_generic(virt_to_phys(mpf
), PAGE_SIZE
,
708 unsigned long size
= PAGE_SIZE
;
711 * We cannot access to MPC table to compute
712 * table size yet, as only few megabytes from
713 * the bottom is mapped now.
714 * PC-9800's MPC table places on the very last
715 * of physical memory; so that simply reserving
716 * PAGE_SIZE from mpf->physptr yields BUG()
717 * in reserve_bootmem.
719 unsigned long end
= max_low_pfn
* PAGE_SIZE
;
720 if (mpf
->physptr
+ size
> end
)
721 size
= end
- mpf
->physptr
;
723 reserve_bootmem_generic(mpf
->physptr
, size
,
735 static void __init
__find_smp_config(unsigned int reserve
)
737 unsigned int address
;
739 if (x86_quirks
->mach_find_smp_config
) {
740 if (x86_quirks
->mach_find_smp_config(reserve
))
744 * FIXME: Linux assumes you have 640K of base ram..
745 * this continues the error...
747 * 1) Scan the bottom 1K for a signature
748 * 2) Scan the top 1K of base RAM
749 * 3) Scan the 64K of bios
751 if (smp_scan_config(0x0, 0x400, reserve
) ||
752 smp_scan_config(639 * 0x400, 0x400, reserve
) ||
753 smp_scan_config(0xF0000, 0x10000, reserve
))
756 * If it is an SMP machine we should know now, unless the
757 * configuration is in an EISA/MCA bus machine with an
758 * extended bios data area.
760 * there is a real-mode segmented pointer pointing to the
761 * 4K EBDA area at 0x40E, calculate and scan it here.
763 * NOTE! There are Linux loaders that will corrupt the EBDA
764 * area, and as such this kind of SMP config may be less
765 * trustworthy, simply because the SMP table may have been
766 * stomped on during early boot. These loaders are buggy and
769 * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
772 address
= get_bios_ebda();
774 smp_scan_config(address
, 0x400, reserve
);
777 void __init
early_find_smp_config(void)
779 __find_smp_config(0);
782 void __init
find_smp_config(void)
784 __find_smp_config(1);
787 #ifdef CONFIG_X86_IO_APIC
788 static u8 __initdata irq_used
[MAX_IRQ_SOURCES
];
790 static int __init
get_MP_intsrc_index(struct mpc_intsrc
*m
)
794 if (m
->irqtype
!= mp_INT
)
797 if (m
->irqflag
!= 0x0f)
802 for (i
= 0; i
< mp_irq_entries
; i
++) {
803 if (mp_irqs
[i
].irqtype
!= mp_INT
)
806 if (mp_irqs
[i
].irqflag
!= 0x0f)
809 if (mp_irqs
[i
].srcbus
!= m
->srcbus
)
811 if (mp_irqs
[i
].srcbusirq
!= m
->srcbusirq
)
814 /* already claimed */
825 #define SPARE_SLOT_NUM 20
827 static struct mpc_intsrc __initdata
*m_spare
[SPARE_SLOT_NUM
];
830 static int __init
replace_intsrc_all(struct mpc_table
*mpc
,
831 unsigned long mpc_new_phys
,
832 unsigned long mpc_new_length
)
834 #ifdef CONFIG_X86_IO_APIC
839 int count
= sizeof(*mpc
);
840 unsigned char *mpt
= ((unsigned char *)mpc
) + count
;
842 printk(KERN_INFO
"mpc_length %x\n", mpc
->length
);
843 while (count
< mpc
->length
) {
847 struct mpc_cpu
*m
= (struct mpc_cpu
*)mpt
;
854 struct mpc_bus
*m
= (struct mpc_bus
*)mpt
;
861 mpt
+= sizeof(struct mpc_ioapic
);
862 count
+= sizeof(struct mpc_ioapic
);
867 #ifdef CONFIG_X86_IO_APIC
868 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
870 printk(KERN_INFO
"OLD ");
871 print_MP_intsrc_info(m
);
872 i
= get_MP_intsrc_index(m
);
874 assign_to_mpc_intsrc(&mp_irqs
[i
], m
);
875 printk(KERN_INFO
"NEW ");
876 print_mp_irq_info(&mp_irqs
[i
]);
878 /* legacy, do nothing */
879 } else if (nr_m_spare
< SPARE_SLOT_NUM
) {
881 * not found (-1), or duplicated (-2)
882 * are invalid entries,
883 * we need to use the slot later
885 m_spare
[nr_m_spare
] = m
;
889 mpt
+= sizeof(struct mpc_intsrc
);
890 count
+= sizeof(struct mpc_intsrc
);
895 struct mpc_lintsrc
*m
=
896 (struct mpc_lintsrc
*)mpt
;
903 printk(KERN_ERR
"Your mptable is wrong, contact your HW vendor!\n");
904 printk(KERN_ERR
"type %x\n", *mpt
);
905 print_hex_dump(KERN_ERR
, " ", DUMP_PREFIX_ADDRESS
, 16,
906 1, mpc
, mpc
->length
, 1);
911 #ifdef CONFIG_X86_IO_APIC
912 for (i
= 0; i
< mp_irq_entries
; i
++) {
916 if (mp_irqs
[i
].irqtype
!= mp_INT
)
919 if (mp_irqs
[i
].irqflag
!= 0x0f)
922 if (nr_m_spare
> 0) {
923 printk(KERN_INFO
"*NEW* found ");
925 assign_to_mpc_intsrc(&mp_irqs
[i
], m_spare
[nr_m_spare
]);
926 m_spare
[nr_m_spare
] = NULL
;
928 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
929 count
+= sizeof(struct mpc_intsrc
);
931 printk(KERN_INFO
"No spare slots, try to append...take your risk, new mpc_length %x\n", count
);
933 if (count
<= mpc_new_length
)
934 printk(KERN_INFO
"No spare slots, try to append..., new mpc_length %x\n", count
);
936 printk(KERN_ERR
"mpc_new_length %lx is too small\n", mpc_new_length
);
940 assign_to_mpc_intsrc(&mp_irqs
[i
], m
);
942 mpt
+= sizeof(struct mpc_intsrc
);
944 print_mp_irq_info(&mp_irqs
[i
]);
948 /* update checksum */
950 mpc
->checksum
-= mpf_checksum((unsigned char *)mpc
, mpc
->length
);
955 static int __initdata enable_update_mptable
;
957 static int __init
update_mptable_setup(char *str
)
959 enable_update_mptable
= 1;
962 early_param("update_mptable", update_mptable_setup
);
964 static unsigned long __initdata mpc_new_phys
;
965 static unsigned long mpc_new_length __initdata
= 4096;
967 /* alloc_mptable or alloc_mptable=4k */
968 static int __initdata alloc_mptable
;
969 static int __init
parse_alloc_mptable_opt(char *p
)
971 enable_update_mptable
= 1;
975 mpc_new_length
= memparse(p
, &p
);
978 early_param("alloc_mptable", parse_alloc_mptable_opt
);
980 void __init
early_reserve_e820_mpc_new(void)
982 if (enable_update_mptable
&& alloc_mptable
) {
984 #ifdef CONFIG_X86_TRAMPOLINE
985 startt
= TRAMPOLINE_BASE
;
987 mpc_new_phys
= early_reserve_e820(startt
, mpc_new_length
, 4);
991 static int __init
update_mp_table(void)
995 struct mpf_intel
*mpf
;
996 struct mpc_table
*mpc
, *mpc_new
;
998 if (!enable_update_mptable
)
1006 * Now see if we need to go further.
1008 if (mpf
->feature1
!= 0)
1014 mpc
= phys_to_virt(mpf
->physptr
);
1016 if (!smp_check_mpc(mpc
, oem
, str
))
1019 printk(KERN_INFO
"mpf: %lx\n", virt_to_phys(mpf
));
1020 printk(KERN_INFO
"physptr: %x\n", mpf
->physptr
);
1022 if (mpc_new_phys
&& mpc
->length
> mpc_new_length
) {
1024 printk(KERN_INFO
"mpc_new_length is %ld, please use alloc_mptable=8k\n",
1028 if (!mpc_new_phys
) {
1029 unsigned char old
, new;
1030 /* check if we can change the postion */
1032 old
= mpf_checksum((unsigned char *)mpc
, mpc
->length
);
1033 mpc
->checksum
= 0xff;
1034 new = mpf_checksum((unsigned char *)mpc
, mpc
->length
);
1036 printk(KERN_INFO
"mpc is readonly, please try alloc_mptable instead\n");
1039 printk(KERN_INFO
"use in-positon replacing\n");
1041 mpf
->physptr
= mpc_new_phys
;
1042 mpc_new
= phys_to_virt(mpc_new_phys
);
1043 memcpy(mpc_new
, mpc
, mpc
->length
);
1045 /* check if we can modify that */
1046 if (mpc_new_phys
- mpf
->physptr
) {
1047 struct mpf_intel
*mpf_new
;
1048 /* steal 16 bytes from [0, 1k) */
1049 printk(KERN_INFO
"mpf new: %x\n", 0x400 - 16);
1050 mpf_new
= phys_to_virt(0x400 - 16);
1051 memcpy(mpf_new
, mpf
, 16);
1053 mpf
->physptr
= mpc_new_phys
;
1056 mpf
->checksum
-= mpf_checksum((unsigned char *)mpf
, 16);
1057 printk(KERN_INFO
"physptr new: %x\n", mpf
->physptr
);
1061 * only replace the one with mp_INT and
1062 * MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
1063 * already in mp_irqs , stored by ... and mp_config_acpi_gsi,
1064 * may need pci=routeirq for all coverage
1066 replace_intsrc_all(mpc
, mpc_new_phys
, mpc_new_length
);
1071 late_initcall(update_mp_table
);