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>
35 * Checksum an MP configuration block.
38 static int __init
mpf_checksum(unsigned char *mp
, int len
)
48 static void __init
MP_processor_info(struct mpc_cpu
*m
)
51 char *bootup_cpu
= "";
53 if (!(m
->cpuflag
& CPU_ENABLED
)) {
58 if (x86_quirks
->mpc_apic_id
)
59 apicid
= x86_quirks
->mpc_apic_id(m
);
63 if (m
->cpuflag
& CPU_BOOTPROCESSOR
) {
64 bootup_cpu
= " (Bootup-CPU)";
65 boot_cpu_physical_apicid
= m
->apicid
;
68 printk(KERN_INFO
"Processor #%d%s\n", m
->apicid
, bootup_cpu
);
69 generic_processor_info(apicid
, m
->apicver
);
72 #ifdef CONFIG_X86_IO_APIC
73 static void __init
MP_bus_info(struct mpc_bus
*m
)
76 memcpy(str
, m
->bustype
, 6);
79 if (x86_quirks
->mpc_oem_bus_info
)
80 x86_quirks
->mpc_oem_bus_info(m
, str
);
82 apic_printk(APIC_VERBOSE
, "Bus #%d is %s\n", m
->busid
, str
);
84 #if MAX_MP_BUSSES < 256
85 if (m
->busid
>= MAX_MP_BUSSES
) {
86 printk(KERN_WARNING
"MP table busid value (%d) for bustype %s "
87 " is too large, max. supported is %d\n",
88 m
->busid
, str
, MAX_MP_BUSSES
- 1);
93 if (strncmp(str
, BUSTYPE_ISA
, sizeof(BUSTYPE_ISA
) - 1) == 0) {
94 set_bit(m
->busid
, mp_bus_not_pci
);
95 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
96 mp_bus_id_to_type
[m
->busid
] = MP_BUS_ISA
;
98 } else if (strncmp(str
, BUSTYPE_PCI
, sizeof(BUSTYPE_PCI
) - 1) == 0) {
99 if (x86_quirks
->mpc_oem_pci_bus
)
100 x86_quirks
->mpc_oem_pci_bus(m
);
102 clear_bit(m
->busid
, mp_bus_not_pci
);
103 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
104 mp_bus_id_to_type
[m
->busid
] = MP_BUS_PCI
;
105 } else if (strncmp(str
, BUSTYPE_EISA
, sizeof(BUSTYPE_EISA
) - 1) == 0) {
106 mp_bus_id_to_type
[m
->busid
] = MP_BUS_EISA
;
107 } else if (strncmp(str
, BUSTYPE_MCA
, sizeof(BUSTYPE_MCA
) - 1) == 0) {
108 mp_bus_id_to_type
[m
->busid
] = MP_BUS_MCA
;
111 printk(KERN_WARNING
"Unknown bustype %s - ignoring\n", str
);
115 #ifdef CONFIG_X86_IO_APIC
117 static int bad_ioapic(unsigned long address
)
119 if (nr_ioapics
>= MAX_IO_APICS
) {
120 printk(KERN_ERR
"ERROR: Max # of I/O APICs (%d) exceeded "
121 "(found %d)\n", MAX_IO_APICS
, nr_ioapics
);
122 panic("Recompile kernel with bigger MAX_IO_APICS!\n");
125 printk(KERN_ERR
"WARNING: Bogus (zero) I/O APIC address"
126 " found in table, skipping!\n");
132 static void __init
MP_ioapic_info(struct mpc_ioapic
*m
)
134 if (!(m
->flags
& MPC_APIC_USABLE
))
137 printk(KERN_INFO
"I/O APIC #%d Version %d at 0x%X.\n",
138 m
->apicid
, m
->apicver
, m
->apicaddr
);
140 if (bad_ioapic(m
->apicaddr
))
143 mp_ioapics
[nr_ioapics
].apicaddr
= m
->apicaddr
;
144 mp_ioapics
[nr_ioapics
].apicid
= m
->apicid
;
145 mp_ioapics
[nr_ioapics
].type
= m
->type
;
146 mp_ioapics
[nr_ioapics
].apicver
= m
->apicver
;
147 mp_ioapics
[nr_ioapics
].flags
= m
->flags
;
151 static void print_MP_intsrc_info(struct mpc_intsrc
*m
)
153 apic_printk(APIC_VERBOSE
, "Int: type %d, pol %d, trig %d, bus %02x,"
154 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
155 m
->irqtype
, m
->irqflag
& 3, (m
->irqflag
>> 2) & 3, m
->srcbus
,
156 m
->srcbusirq
, m
->dstapic
, m
->dstirq
);
159 static void __init
print_mp_irq_info(struct mpc_intsrc
*mp_irq
)
161 apic_printk(APIC_VERBOSE
, "Int: type %d, pol %d, trig %d, bus %02x,"
162 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
163 mp_irq
->irqtype
, mp_irq
->irqflag
& 3,
164 (mp_irq
->irqflag
>> 2) & 3, mp_irq
->srcbus
,
165 mp_irq
->srcbusirq
, mp_irq
->dstapic
, mp_irq
->dstirq
);
168 static void __init
assign_to_mp_irq(struct mpc_intsrc
*m
,
169 struct mpc_intsrc
*mp_irq
)
171 mp_irq
->dstapic
= m
->dstapic
;
172 mp_irq
->type
= m
->type
;
173 mp_irq
->irqtype
= m
->irqtype
;
174 mp_irq
->irqflag
= m
->irqflag
;
175 mp_irq
->srcbus
= m
->srcbus
;
176 mp_irq
->srcbusirq
= m
->srcbusirq
;
177 mp_irq
->dstirq
= m
->dstirq
;
180 static void __init
assign_to_mpc_intsrc(struct mpc_intsrc
*mp_irq
,
181 struct mpc_intsrc
*m
)
183 m
->dstapic
= mp_irq
->dstapic
;
184 m
->type
= mp_irq
->type
;
185 m
->irqtype
= mp_irq
->irqtype
;
186 m
->irqflag
= mp_irq
->irqflag
;
187 m
->srcbus
= mp_irq
->srcbus
;
188 m
->srcbusirq
= mp_irq
->srcbusirq
;
189 m
->dstirq
= mp_irq
->dstirq
;
192 static int __init
mp_irq_mpc_intsrc_cmp(struct mpc_intsrc
*mp_irq
,
193 struct mpc_intsrc
*m
)
195 if (mp_irq
->dstapic
!= m
->dstapic
)
197 if (mp_irq
->type
!= m
->type
)
199 if (mp_irq
->irqtype
!= m
->irqtype
)
201 if (mp_irq
->irqflag
!= m
->irqflag
)
203 if (mp_irq
->srcbus
!= m
->srcbus
)
205 if (mp_irq
->srcbusirq
!= m
->srcbusirq
)
207 if (mp_irq
->dstirq
!= m
->dstirq
)
213 static void __init
MP_intsrc_info(struct mpc_intsrc
*m
)
217 print_MP_intsrc_info(m
);
219 for (i
= 0; i
< mp_irq_entries
; i
++) {
220 if (!mp_irq_mpc_intsrc_cmp(&mp_irqs
[i
], m
))
224 assign_to_mp_irq(m
, &mp_irqs
[mp_irq_entries
]);
225 if (++mp_irq_entries
== MAX_IRQ_SOURCES
)
226 panic("Max # of irq sources exceeded!!\n");
231 static void __init
MP_lintsrc_info(struct mpc_lintsrc
*m
)
233 apic_printk(APIC_VERBOSE
, "Lint: type %d, pol %d, trig %d, bus %02x,"
234 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
235 m
->irqtype
, m
->irqflag
& 3, (m
->irqflag
>> 2) & 3, m
->srcbusid
,
236 m
->srcbusirq
, m
->destapic
, m
->destapiclint
);
243 static int __init
smp_check_mpc(struct mpc_table
*mpc
, char *oem
, char *str
)
246 if (memcmp(mpc
->signature
, MPC_SIGNATURE
, 4)) {
247 printk(KERN_ERR
"MPTABLE: bad signature [%c%c%c%c]!\n",
248 mpc
->signature
[0], mpc
->signature
[1],
249 mpc
->signature
[2], mpc
->signature
[3]);
252 if (mpf_checksum((unsigned char *)mpc
, mpc
->length
)) {
253 printk(KERN_ERR
"MPTABLE: checksum error!\n");
256 if (mpc
->spec
!= 0x01 && mpc
->spec
!= 0x04) {
257 printk(KERN_ERR
"MPTABLE: bad table version (%d)!!\n",
262 printk(KERN_ERR
"MPTABLE: null local APIC address!\n");
265 memcpy(oem
, mpc
->oem
, 8);
267 printk(KERN_INFO
"MPTABLE: OEM ID: %s\n", oem
);
269 memcpy(str
, mpc
->productid
, 12);
272 printk(KERN_INFO
"MPTABLE: Product ID: %s\n", str
);
274 printk(KERN_INFO
"MPTABLE: APIC at: 0x%X\n", mpc
->lapic
);
279 static int __init
smp_read_mpc(struct mpc_table
*mpc
, unsigned early
)
284 int count
= sizeof(*mpc
);
285 unsigned char *mpt
= ((unsigned char *)mpc
) + count
;
287 if (!smp_check_mpc(mpc
, oem
, str
))
291 generic_mps_oem_check(mpc
, oem
, str
);
293 /* save the local APIC address, it might be non-default */
295 mp_lapic_addr
= mpc
->lapic
;
300 if (mpc
->oemptr
&& x86_quirks
->smp_read_mpc_oem
) {
301 struct mpc_oemtable
*oem_table
= (void *)(long)mpc
->oemptr
;
302 x86_quirks
->smp_read_mpc_oem(oem_table
, mpc
->oemsize
);
306 * Now process the configuration blocks.
308 if (x86_quirks
->mpc_record
)
309 *x86_quirks
->mpc_record
= 0;
311 while (count
< mpc
->length
) {
315 struct mpc_cpu
*m
= (struct mpc_cpu
*)mpt
;
316 /* ACPI may have already provided this data */
318 MP_processor_info(m
);
325 struct mpc_bus
*m
= (struct mpc_bus
*)mpt
;
326 #ifdef CONFIG_X86_IO_APIC
335 #ifdef CONFIG_X86_IO_APIC
336 struct mpc_ioapic
*m
= (struct mpc_ioapic
*)mpt
;
339 mpt
+= sizeof(struct mpc_ioapic
);
340 count
+= sizeof(struct mpc_ioapic
);
345 #ifdef CONFIG_X86_IO_APIC
346 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
350 mpt
+= sizeof(struct mpc_intsrc
);
351 count
+= sizeof(struct mpc_intsrc
);
356 struct mpc_lintsrc
*m
=
357 (struct mpc_lintsrc
*)mpt
;
365 printk(KERN_ERR
"Your mptable is wrong, contact your HW vendor!\n");
366 printk(KERN_ERR
"type %x\n", *mpt
);
367 print_hex_dump(KERN_ERR
, " ", DUMP_PREFIX_ADDRESS
, 16,
368 1, mpc
, mpc
->length
, 1);
372 if (x86_quirks
->mpc_record
)
373 (*x86_quirks
->mpc_record
)++;
376 #ifdef CONFIG_X86_GENERICARCH
377 generic_bigsmp_probe();
380 if (apic
->setup_apic_routing
)
381 apic
->setup_apic_routing();
384 printk(KERN_ERR
"MPTABLE: no processors registered!\n");
385 return num_processors
;
388 #ifdef CONFIG_X86_IO_APIC
390 static int __init
ELCR_trigger(unsigned int irq
)
394 port
= 0x4d0 + (irq
>> 3);
395 return (inb(port
) >> (irq
& 7)) & 1;
398 static void __init
construct_default_ioirq_mptable(int mpc_default_type
)
400 struct mpc_intsrc intsrc
;
402 int ELCR_fallback
= 0;
404 intsrc
.type
= MP_INTSRC
;
405 intsrc
.irqflag
= 0; /* conforming */
407 intsrc
.dstapic
= mp_ioapics
[0].apicid
;
409 intsrc
.irqtype
= mp_INT
;
412 * If true, we have an ISA/PCI system with no IRQ entries
413 * in the MP table. To prevent the PCI interrupts from being set up
414 * incorrectly, we try to use the ELCR. The sanity check to see if
415 * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
416 * never be level sensitive, so we simply see if the ELCR agrees.
417 * If it does, we assume it's valid.
419 if (mpc_default_type
== 5) {
420 printk(KERN_INFO
"ISA/PCI bus type with no IRQ information... "
421 "falling back to ELCR\n");
423 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) ||
425 printk(KERN_ERR
"ELCR contains invalid data... "
429 "Using ELCR to identify PCI interrupts\n");
434 for (i
= 0; i
< 16; i
++) {
435 switch (mpc_default_type
) {
437 if (i
== 0 || i
== 13)
438 continue; /* IRQ0 & IRQ13 not connected */
442 continue; /* IRQ2 is never connected */
447 * If the ELCR indicates a level-sensitive interrupt, we
448 * copy that information over to the MP table in the
449 * irqflag field (level sensitive, active high polarity).
457 intsrc
.srcbusirq
= i
;
458 intsrc
.dstirq
= i
? i
: 2; /* IRQ0 to INTIN2 */
459 MP_intsrc_info(&intsrc
);
462 intsrc
.irqtype
= mp_ExtINT
;
463 intsrc
.srcbusirq
= 0;
464 intsrc
.dstirq
= 0; /* 8259A to INTIN0 */
465 MP_intsrc_info(&intsrc
);
469 static void __init
construct_ioapic_table(int mpc_default_type
)
471 struct mpc_ioapic ioapic
;
476 switch (mpc_default_type
) {
478 printk(KERN_ERR
"???\nUnknown standard configuration %d\n",
483 memcpy(bus
.bustype
, "ISA ", 6);
488 memcpy(bus
.bustype
, "EISA ", 6);
492 memcpy(bus
.bustype
, "MCA ", 6);
495 if (mpc_default_type
> 4) {
497 memcpy(bus
.bustype
, "PCI ", 6);
501 ioapic
.type
= MP_IOAPIC
;
503 ioapic
.apicver
= mpc_default_type
> 4 ? 0x10 : 0x01;
504 ioapic
.flags
= MPC_APIC_USABLE
;
505 ioapic
.apicaddr
= 0xFEC00000;
506 MP_ioapic_info(&ioapic
);
509 * We set up most of the low 16 IO-APIC pins according to MPS rules.
511 construct_default_ioirq_mptable(mpc_default_type
);
514 static inline void __init
construct_ioapic_table(int mpc_default_type
) { }
517 static inline void __init
construct_default_ISA_mptable(int mpc_default_type
)
519 struct mpc_cpu processor
;
520 struct mpc_lintsrc lintsrc
;
521 int linttypes
[2] = { mp_ExtINT
, mp_NMI
};
525 * local APIC has default address
527 mp_lapic_addr
= APIC_DEFAULT_PHYS_BASE
;
530 * 2 CPUs, numbered 0 & 1.
532 processor
.type
= MP_PROCESSOR
;
533 /* Either an integrated APIC or a discrete 82489DX. */
534 processor
.apicver
= mpc_default_type
> 4 ? 0x10 : 0x01;
535 processor
.cpuflag
= CPU_ENABLED
;
536 processor
.cpufeature
= (boot_cpu_data
.x86
<< 8) |
537 (boot_cpu_data
.x86_model
<< 4) | boot_cpu_data
.x86_mask
;
538 processor
.featureflag
= boot_cpu_data
.x86_capability
[0];
539 processor
.reserved
[0] = 0;
540 processor
.reserved
[1] = 0;
541 for (i
= 0; i
< 2; i
++) {
542 processor
.apicid
= i
;
543 MP_processor_info(&processor
);
546 construct_ioapic_table(mpc_default_type
);
548 lintsrc
.type
= MP_LINTSRC
;
549 lintsrc
.irqflag
= 0; /* conforming */
550 lintsrc
.srcbusid
= 0;
551 lintsrc
.srcbusirq
= 0;
552 lintsrc
.destapic
= MP_APIC_ALL
;
553 for (i
= 0; i
< 2; i
++) {
554 lintsrc
.irqtype
= linttypes
[i
];
555 lintsrc
.destapiclint
= i
;
556 MP_lintsrc_info(&lintsrc
);
560 static struct mpf_intel
*mpf_found
;
563 * Scan the memory blocks for an SMP configuration block.
565 static void __init
__get_smp_config(unsigned int early
)
567 struct mpf_intel
*mpf
= mpf_found
;
572 if (acpi_lapic
&& early
)
576 * MPS doesn't support hyperthreading, aka only have
577 * thread 0 apic id in MPS table
579 if (acpi_lapic
&& acpi_ioapic
)
582 if (x86_quirks
->mach_get_smp_config
) {
583 if (x86_quirks
->mach_get_smp_config(early
))
587 printk(KERN_INFO
"Intel MultiProcessor Specification v1.%d\n",
589 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
590 if (mpf
->feature2
& (1 << 7)) {
591 printk(KERN_INFO
" IMCR and PIC compatibility mode.\n");
594 printk(KERN_INFO
" Virtual Wire compatibility mode.\n");
599 * Now see if we need to read further.
601 if (mpf
->feature1
!= 0) {
604 * local APIC has default address
606 mp_lapic_addr
= APIC_DEFAULT_PHYS_BASE
;
610 printk(KERN_INFO
"Default MP configuration #%d\n",
612 construct_default_ISA_mptable(mpf
->feature1
);
614 } else if (mpf
->physptr
) {
617 * Read the physical hardware table. Anything here will
618 * override the defaults.
620 if (!smp_read_mpc(phys_to_virt(mpf
->physptr
), early
)) {
621 #ifdef CONFIG_X86_LOCAL_APIC
622 smp_found_config
= 0;
625 "BIOS bug, MP table errors detected!...\n");
626 printk(KERN_ERR
"... disabling SMP support. "
627 "(tell your hw vendor)\n");
633 #ifdef CONFIG_X86_IO_APIC
635 * If there are no explicit MP IRQ entries, then we are
636 * broken. We set up most of the low 16 IO-APIC pins to
637 * ISA defaults and hope it will work.
639 if (!mp_irq_entries
) {
642 printk(KERN_ERR
"BIOS bug, no explicit IRQ entries, "
643 "using default mptable. "
644 "(tell your hw vendor)\n");
648 memcpy(bus
.bustype
, "ISA ", 6);
651 construct_default_ioirq_mptable(0);
658 printk(KERN_INFO
"Processors: %d\n", num_processors
);
660 * Only use the first configuration found.
664 void __init
early_get_smp_config(void)
669 void __init
get_smp_config(void)
674 static int __init
smp_scan_config(unsigned long base
, unsigned long length
,
677 unsigned int *bp
= phys_to_virt(base
);
678 struct mpf_intel
*mpf
;
680 apic_printk(APIC_VERBOSE
, "Scan SMP from %p for %ld bytes.\n",
682 BUILD_BUG_ON(sizeof(*mpf
) != 16);
685 mpf
= (struct mpf_intel
*)bp
;
686 if ((*bp
== SMP_MAGIC_IDENT
) &&
687 (mpf
->length
== 1) &&
688 !mpf_checksum((unsigned char *)bp
, 16) &&
689 ((mpf
->specification
== 1)
690 || (mpf
->specification
== 4))) {
691 #ifdef CONFIG_X86_LOCAL_APIC
692 smp_found_config
= 1;
696 printk(KERN_INFO
"found SMP MP-table at [%p] %08lx\n",
697 mpf
, virt_to_phys(mpf
));
701 reserve_bootmem_generic(virt_to_phys(mpf
), PAGE_SIZE
,
704 unsigned long size
= PAGE_SIZE
;
707 * We cannot access to MPC table to compute
708 * table size yet, as only few megabytes from
709 * the bottom is mapped now.
710 * PC-9800's MPC table places on the very last
711 * of physical memory; so that simply reserving
712 * PAGE_SIZE from mpf->physptr yields BUG()
713 * in reserve_bootmem.
715 unsigned long end
= max_low_pfn
* PAGE_SIZE
;
716 if (mpf
->physptr
+ size
> end
)
717 size
= end
- mpf
->physptr
;
719 reserve_bootmem_generic(mpf
->physptr
, size
,
731 static void __init
__find_smp_config(unsigned int reserve
)
733 unsigned int address
;
735 if (x86_quirks
->mach_find_smp_config
) {
736 if (x86_quirks
->mach_find_smp_config(reserve
))
740 * FIXME: Linux assumes you have 640K of base ram..
741 * this continues the error...
743 * 1) Scan the bottom 1K for a signature
744 * 2) Scan the top 1K of base RAM
745 * 3) Scan the 64K of bios
747 if (smp_scan_config(0x0, 0x400, reserve
) ||
748 smp_scan_config(639 * 0x400, 0x400, reserve
) ||
749 smp_scan_config(0xF0000, 0x10000, reserve
))
752 * If it is an SMP machine we should know now, unless the
753 * configuration is in an EISA/MCA bus machine with an
754 * extended bios data area.
756 * there is a real-mode segmented pointer pointing to the
757 * 4K EBDA area at 0x40E, calculate and scan it here.
759 * NOTE! There are Linux loaders that will corrupt the EBDA
760 * area, and as such this kind of SMP config may be less
761 * trustworthy, simply because the SMP table may have been
762 * stomped on during early boot. These loaders are buggy and
765 * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
768 address
= get_bios_ebda();
770 smp_scan_config(address
, 0x400, reserve
);
773 void __init
early_find_smp_config(void)
775 __find_smp_config(0);
778 void __init
find_smp_config(void)
780 __find_smp_config(1);
783 #ifdef CONFIG_X86_IO_APIC
784 static u8 __initdata irq_used
[MAX_IRQ_SOURCES
];
786 static int __init
get_MP_intsrc_index(struct mpc_intsrc
*m
)
790 if (m
->irqtype
!= mp_INT
)
793 if (m
->irqflag
!= 0x0f)
798 for (i
= 0; i
< mp_irq_entries
; i
++) {
799 if (mp_irqs
[i
].irqtype
!= mp_INT
)
802 if (mp_irqs
[i
].irqflag
!= 0x0f)
805 if (mp_irqs
[i
].srcbus
!= m
->srcbus
)
807 if (mp_irqs
[i
].srcbusirq
!= m
->srcbusirq
)
810 /* already claimed */
821 #define SPARE_SLOT_NUM 20
823 static struct mpc_intsrc __initdata
*m_spare
[SPARE_SLOT_NUM
];
826 static int __init
replace_intsrc_all(struct mpc_table
*mpc
,
827 unsigned long mpc_new_phys
,
828 unsigned long mpc_new_length
)
830 #ifdef CONFIG_X86_IO_APIC
835 int count
= sizeof(*mpc
);
836 unsigned char *mpt
= ((unsigned char *)mpc
) + count
;
838 printk(KERN_INFO
"mpc_length %x\n", mpc
->length
);
839 while (count
< mpc
->length
) {
843 struct mpc_cpu
*m
= (struct mpc_cpu
*)mpt
;
850 struct mpc_bus
*m
= (struct mpc_bus
*)mpt
;
857 mpt
+= sizeof(struct mpc_ioapic
);
858 count
+= sizeof(struct mpc_ioapic
);
863 #ifdef CONFIG_X86_IO_APIC
864 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
866 printk(KERN_INFO
"OLD ");
867 print_MP_intsrc_info(m
);
868 i
= get_MP_intsrc_index(m
);
870 assign_to_mpc_intsrc(&mp_irqs
[i
], m
);
871 printk(KERN_INFO
"NEW ");
872 print_mp_irq_info(&mp_irqs
[i
]);
874 /* legacy, do nothing */
875 } else if (nr_m_spare
< SPARE_SLOT_NUM
) {
877 * not found (-1), or duplicated (-2)
878 * are invalid entries,
879 * we need to use the slot later
881 m_spare
[nr_m_spare
] = m
;
885 mpt
+= sizeof(struct mpc_intsrc
);
886 count
+= sizeof(struct mpc_intsrc
);
891 struct mpc_lintsrc
*m
=
892 (struct mpc_lintsrc
*)mpt
;
899 printk(KERN_ERR
"Your mptable is wrong, contact your HW vendor!\n");
900 printk(KERN_ERR
"type %x\n", *mpt
);
901 print_hex_dump(KERN_ERR
, " ", DUMP_PREFIX_ADDRESS
, 16,
902 1, mpc
, mpc
->length
, 1);
907 #ifdef CONFIG_X86_IO_APIC
908 for (i
= 0; i
< mp_irq_entries
; i
++) {
912 if (mp_irqs
[i
].irqtype
!= mp_INT
)
915 if (mp_irqs
[i
].irqflag
!= 0x0f)
918 if (nr_m_spare
> 0) {
919 printk(KERN_INFO
"*NEW* found ");
921 assign_to_mpc_intsrc(&mp_irqs
[i
], m_spare
[nr_m_spare
]);
922 m_spare
[nr_m_spare
] = NULL
;
924 struct mpc_intsrc
*m
= (struct mpc_intsrc
*)mpt
;
925 count
+= sizeof(struct mpc_intsrc
);
927 printk(KERN_INFO
"No spare slots, try to append...take your risk, new mpc_length %x\n", count
);
929 if (count
<= mpc_new_length
)
930 printk(KERN_INFO
"No spare slots, try to append..., new mpc_length %x\n", count
);
932 printk(KERN_ERR
"mpc_new_length %lx is too small\n", mpc_new_length
);
936 assign_to_mpc_intsrc(&mp_irqs
[i
], m
);
938 mpt
+= sizeof(struct mpc_intsrc
);
940 print_mp_irq_info(&mp_irqs
[i
]);
944 /* update checksum */
946 mpc
->checksum
-= mpf_checksum((unsigned char *)mpc
, mpc
->length
);
951 static int __initdata enable_update_mptable
;
953 static int __init
update_mptable_setup(char *str
)
955 enable_update_mptable
= 1;
958 early_param("update_mptable", update_mptable_setup
);
960 static unsigned long __initdata mpc_new_phys
;
961 static unsigned long mpc_new_length __initdata
= 4096;
963 /* alloc_mptable or alloc_mptable=4k */
964 static int __initdata alloc_mptable
;
965 static int __init
parse_alloc_mptable_opt(char *p
)
967 enable_update_mptable
= 1;
971 mpc_new_length
= memparse(p
, &p
);
974 early_param("alloc_mptable", parse_alloc_mptable_opt
);
976 void __init
early_reserve_e820_mpc_new(void)
978 if (enable_update_mptable
&& alloc_mptable
) {
980 #ifdef CONFIG_X86_TRAMPOLINE
981 startt
= TRAMPOLINE_BASE
;
983 mpc_new_phys
= early_reserve_e820(startt
, mpc_new_length
, 4);
987 static int __init
update_mp_table(void)
991 struct mpf_intel
*mpf
;
992 struct mpc_table
*mpc
, *mpc_new
;
994 if (!enable_update_mptable
)
1002 * Now see if we need to go further.
1004 if (mpf
->feature1
!= 0)
1010 mpc
= phys_to_virt(mpf
->physptr
);
1012 if (!smp_check_mpc(mpc
, oem
, str
))
1015 printk(KERN_INFO
"mpf: %lx\n", virt_to_phys(mpf
));
1016 printk(KERN_INFO
"physptr: %x\n", mpf
->physptr
);
1018 if (mpc_new_phys
&& mpc
->length
> mpc_new_length
) {
1020 printk(KERN_INFO
"mpc_new_length is %ld, please use alloc_mptable=8k\n",
1024 if (!mpc_new_phys
) {
1025 unsigned char old
, new;
1026 /* check if we can change the postion */
1028 old
= mpf_checksum((unsigned char *)mpc
, mpc
->length
);
1029 mpc
->checksum
= 0xff;
1030 new = mpf_checksum((unsigned char *)mpc
, mpc
->length
);
1032 printk(KERN_INFO
"mpc is readonly, please try alloc_mptable instead\n");
1035 printk(KERN_INFO
"use in-positon replacing\n");
1037 mpf
->physptr
= mpc_new_phys
;
1038 mpc_new
= phys_to_virt(mpc_new_phys
);
1039 memcpy(mpc_new
, mpc
, mpc
->length
);
1041 /* check if we can modify that */
1042 if (mpc_new_phys
- mpf
->physptr
) {
1043 struct mpf_intel
*mpf_new
;
1044 /* steal 16 bytes from [0, 1k) */
1045 printk(KERN_INFO
"mpf new: %x\n", 0x400 - 16);
1046 mpf_new
= phys_to_virt(0x400 - 16);
1047 memcpy(mpf_new
, mpf
, 16);
1049 mpf
->physptr
= mpc_new_phys
;
1052 mpf
->checksum
-= mpf_checksum((unsigned char *)mpf
, 16);
1053 printk(KERN_INFO
"physptr new: %x\n", mpf
->physptr
);
1057 * only replace the one with mp_INT and
1058 * MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
1059 * already in mp_irqs , stored by ... and mp_config_acpi_gsi,
1060 * may need pci=routeirq for all coverage
1062 replace_intsrc_all(mpc
, mpc_new_phys
, mpc_new_length
);
1067 late_initcall(update_mp_table
);