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>
31 #include <mach_apic.h>
33 #include <mach_apicdef.h>
34 #include <mach_mpparse.h>
38 * Checksum an MP configuration block.
41 static int __init mpf_checksum(unsigned char *mp, int len)
51 static void __init MP_processor_info(struct mpc_cpu *m)
54 char *bootup_cpu = "";
56 if (!(m->cpuflag & CPU_ENABLED)) {
61 if (x86_quirks->mpc_apic_id)
62 apicid = x86_quirks->mpc_apic_id(m);
66 if (m->cpuflag & CPU_BOOTPROCESSOR) {
67 bootup_cpu = " (Bootup-CPU)";
68 boot_cpu_physical_apicid = m->apicid;
71 printk(KERN_INFO "Processor #%d%s\n", m->apicid, bootup_cpu);
72 generic_processor_info(apicid, m->apicver);
75 #ifdef CONFIG_X86_IO_APIC
76 static void __init MP_bus_info(struct mpc_bus *m)
79 memcpy(str, m->bustype, 6);
82 if (x86_quirks->mpc_oem_bus_info)
83 x86_quirks->mpc_oem_bus_info(m, str);
85 apic_printk(APIC_VERBOSE, "Bus #%d is %s\n", m->busid, str);
87 #if MAX_MP_BUSSES < 256
88 if (m->busid >= MAX_MP_BUSSES) {
89 printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
90 " is too large, max. supported is %d\n",
91 m->busid, str, MAX_MP_BUSSES - 1);
96 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) {
97 set_bit(m->busid, mp_bus_not_pci);
98 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
99 mp_bus_id_to_type[m->busid] = MP_BUS_ISA;
101 } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) {
102 if (x86_quirks->mpc_oem_pci_bus)
103 x86_quirks->mpc_oem_pci_bus(m);
105 clear_bit(m->busid, mp_bus_not_pci);
106 #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
107 mp_bus_id_to_type[m->busid] = MP_BUS_PCI;
108 } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) {
109 mp_bus_id_to_type[m->busid] = MP_BUS_EISA;
110 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) {
111 mp_bus_id_to_type[m->busid] = MP_BUS_MCA;
114 printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
118 #ifdef CONFIG_X86_IO_APIC
120 static int bad_ioapic(unsigned long address)
122 if (nr_ioapics >= MAX_IO_APICS) {
123 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
124 "(found %d)\n", MAX_IO_APICS, nr_ioapics);
125 panic("Recompile kernel with bigger MAX_IO_APICS!\n");
128 printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
129 " found in table, skipping!\n");
135 static void __init MP_ioapic_info(struct mpc_ioapic *m)
137 if (!(m->flags & MPC_APIC_USABLE))
140 printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n",
141 m->apicid, m->apicver, m->apicaddr);
143 if (bad_ioapic(m->apicaddr))
146 mp_ioapics[nr_ioapics].apicaddr = m->apicaddr;
147 mp_ioapics[nr_ioapics].apicid = m->apicid;
148 mp_ioapics[nr_ioapics].type = m->type;
149 mp_ioapics[nr_ioapics].apicver = m->apicver;
150 mp_ioapics[nr_ioapics].flags = m->flags;
154 static void print_MP_intsrc_info(struct mpc_intsrc *m)
156 apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x,"
157 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
158 m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbus,
159 m->srcbusirq, m->dstapic, m->dstirq);
162 static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq)
164 apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x,"
165 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
166 mp_irq->mp_irqtype, mp_irq->mp_irqflag & 3,
167 (mp_irq->mp_irqflag >> 2) & 3, mp_irq->mp_srcbus,
168 mp_irq->mp_srcbusirq, mp_irq->mp_dstapic, mp_irq->mp_dstirq);
171 static void __init assign_to_mp_irq(struct mpc_intsrc *m,
172 struct mp_config_intsrc *mp_irq)
174 mp_irq->mp_dstapic = m->dstapic;
175 mp_irq->mp_type = m->type;
176 mp_irq->mp_irqtype = m->irqtype;
177 mp_irq->mp_irqflag = m->irqflag;
178 mp_irq->mp_srcbus = m->srcbus;
179 mp_irq->mp_srcbusirq = m->srcbusirq;
180 mp_irq->mp_dstirq = m->dstirq;
183 static void __init assign_to_mpc_intsrc(struct mp_config_intsrc *mp_irq,
184 struct mpc_intsrc *m)
186 m->dstapic = mp_irq->mp_dstapic;
187 m->type = mp_irq->mp_type;
188 m->irqtype = mp_irq->mp_irqtype;
189 m->irqflag = mp_irq->mp_irqflag;
190 m->srcbus = mp_irq->mp_srcbus;
191 m->srcbusirq = mp_irq->mp_srcbusirq;
192 m->dstirq = mp_irq->mp_dstirq;
195 static int __init mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc *mp_irq,
196 struct mpc_intsrc *m)
198 if (mp_irq->mp_dstapic != m->dstapic)
200 if (mp_irq->mp_type != m->type)
202 if (mp_irq->mp_irqtype != m->irqtype)
204 if (mp_irq->mp_irqflag != m->irqflag)
206 if (mp_irq->mp_srcbus != m->srcbus)
208 if (mp_irq->mp_srcbusirq != m->srcbusirq)
210 if (mp_irq->mp_dstirq != m->dstirq)
216 static void __init MP_intsrc_info(struct mpc_intsrc *m)
220 print_MP_intsrc_info(m);
222 for (i = 0; i < mp_irq_entries; i++) {
223 if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m))
227 assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
228 if (++mp_irq_entries == MAX_IRQ_SOURCES)
229 panic("Max # of irq sources exceeded!!\n");
234 static void __init MP_lintsrc_info(struct mpc_lintsrc *m)
236 apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x,"
237 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
238 m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbusid,
239 m->srcbusirq, m->destapic, m->destapiclint);
246 static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str)
249 if (memcmp(mpc->signature, MPC_SIGNATURE, 4)) {
250 printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n",
251 mpc->signature[0], mpc->signature[1],
252 mpc->signature[2], mpc->signature[3]);
255 if (mpf_checksum((unsigned char *)mpc, mpc->length)) {
256 printk(KERN_ERR "MPTABLE: checksum error!\n");
259 if (mpc->spec != 0x01 && mpc->spec != 0x04) {
260 printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
265 printk(KERN_ERR "MPTABLE: null local APIC address!\n");
268 memcpy(oem, mpc->oem, 8);
270 printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem);
272 memcpy(str, mpc->productid, 12);
275 printk(KERN_INFO "MPTABLE: Product ID: %s\n", str);
277 printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->lapic);
282 static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)
287 int count = sizeof(*mpc);
288 unsigned char *mpt = ((unsigned char *)mpc) + count;
290 if (!smp_check_mpc(mpc, oem, str))
295 * need to make sure summit and es7000's mps_oem_check is safe to be
296 * called early via genericarch 's mps_oem_check
299 #ifdef CONFIG_X86_NUMAQ
300 numaq_mps_oem_check(mpc, oem, str);
303 mps_oem_check(mpc, oem, str);
305 /* save the local APIC address, it might be non-default */
307 mp_lapic_addr = mpc->lapic;
312 if (mpc->oemptr && x86_quirks->smp_read_mpc_oem) {
313 struct mpc_oemtable *oem_table = (void *)(long)mpc->oemptr;
314 x86_quirks->smp_read_mpc_oem(oem_table, mpc->oemsize);
318 * Now process the configuration blocks.
320 if (x86_quirks->mpc_record)
321 *x86_quirks->mpc_record = 0;
323 while (count < mpc->length) {
327 struct mpc_cpu *m = (struct mpc_cpu *)mpt;
328 /* ACPI may have already provided this data */
330 MP_processor_info(m);
337 struct mpc_bus *m = (struct mpc_bus *)mpt;
338 #ifdef CONFIG_X86_IO_APIC
347 #ifdef CONFIG_X86_IO_APIC
348 struct mpc_ioapic *m = (struct mpc_ioapic *)mpt;
351 mpt += sizeof(struct mpc_ioapic);
352 count += sizeof(struct mpc_ioapic);
357 #ifdef CONFIG_X86_IO_APIC
358 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
362 mpt += sizeof(struct mpc_intsrc);
363 count += sizeof(struct mpc_intsrc);
368 struct mpc_lintsrc *m =
369 (struct mpc_lintsrc *)mpt;
377 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n");
378 printk(KERN_ERR "type %x\n", *mpt);
379 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16,
380 1, mpc, mpc->length, 1);
384 if (x86_quirks->mpc_record)
385 (*x86_quirks->mpc_record)++;
388 #ifdef CONFIG_X86_GENERICARCH
389 generic_bigsmp_probe();
393 setup_apic_routing();
396 printk(KERN_ERR "MPTABLE: no processors registered!\n");
397 return num_processors;
400 #ifdef CONFIG_X86_IO_APIC
402 static int __init ELCR_trigger(unsigned int irq)
406 port = 0x4d0 + (irq >> 3);
407 return (inb(port) >> (irq & 7)) & 1;
410 static void __init construct_default_ioirq_mptable(int mpc_default_type)
412 struct mpc_intsrc intsrc;
414 int ELCR_fallback = 0;
416 intsrc.type = MP_INTSRC;
417 intsrc.irqflag = 0; /* conforming */
419 intsrc.dstapic = mp_ioapics[0].apicid;
421 intsrc.irqtype = mp_INT;
424 * If true, we have an ISA/PCI system with no IRQ entries
425 * in the MP table. To prevent the PCI interrupts from being set up
426 * incorrectly, we try to use the ELCR. The sanity check to see if
427 * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
428 * never be level sensitive, so we simply see if the ELCR agrees.
429 * If it does, we assume it's valid.
431 if (mpc_default_type == 5) {
432 printk(KERN_INFO "ISA/PCI bus type with no IRQ information... "
433 "falling back to ELCR\n");
435 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) ||
437 printk(KERN_ERR "ELCR contains invalid data... "
441 "Using ELCR to identify PCI interrupts\n");
446 for (i = 0; i < 16; i++) {
447 switch (mpc_default_type) {
449 if (i == 0 || i == 13)
450 continue; /* IRQ0 & IRQ13 not connected */
454 continue; /* IRQ2 is never connected */
459 * If the ELCR indicates a level-sensitive interrupt, we
460 * copy that information over to the MP table in the
461 * irqflag field (level sensitive, active high polarity).
469 intsrc.srcbusirq = i;
470 intsrc.dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
471 MP_intsrc_info(&intsrc);
474 intsrc.irqtype = mp_ExtINT;
475 intsrc.srcbusirq = 0;
476 intsrc.dstirq = 0; /* 8259A to INTIN0 */
477 MP_intsrc_info(&intsrc);
481 static void __init construct_ioapic_table(int mpc_default_type)
483 struct mpc_ioapic ioapic;
488 switch (mpc_default_type) {
490 printk(KERN_ERR "???\nUnknown standard configuration %d\n",
495 memcpy(bus.bustype, "ISA ", 6);
500 memcpy(bus.bustype, "EISA ", 6);
504 memcpy(bus.bustype, "MCA ", 6);
507 if (mpc_default_type > 4) {
509 memcpy(bus.bustype, "PCI ", 6);
513 ioapic.type = MP_IOAPIC;
515 ioapic.apicver = mpc_default_type > 4 ? 0x10 : 0x01;
516 ioapic.flags = MPC_APIC_USABLE;
517 ioapic.apicaddr = 0xFEC00000;
518 MP_ioapic_info(&ioapic);
521 * We set up most of the low 16 IO-APIC pins according to MPS rules.
523 construct_default_ioirq_mptable(mpc_default_type);
526 static inline void __init construct_ioapic_table(int mpc_default_type) { }
529 static inline void __init construct_default_ISA_mptable(int mpc_default_type)
531 struct mpc_cpu processor;
532 struct mpc_lintsrc lintsrc;
533 int linttypes[2] = { mp_ExtINT, mp_NMI };
537 * local APIC has default address
539 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
542 * 2 CPUs, numbered 0 & 1.
544 processor.type = MP_PROCESSOR;
545 /* Either an integrated APIC or a discrete 82489DX. */
546 processor.apicver = mpc_default_type > 4 ? 0x10 : 0x01;
547 processor.cpuflag = CPU_ENABLED;
548 processor.cpufeature = (boot_cpu_data.x86 << 8) |
549 (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
550 processor.featureflag = boot_cpu_data.x86_capability[0];
551 processor.reserved[0] = 0;
552 processor.reserved[1] = 0;
553 for (i = 0; i < 2; i++) {
554 processor.apicid = i;
555 MP_processor_info(&processor);
558 construct_ioapic_table(mpc_default_type);
560 lintsrc.type = MP_LINTSRC;
561 lintsrc.irqflag = 0; /* conforming */
562 lintsrc.srcbusid = 0;
563 lintsrc.srcbusirq = 0;
564 lintsrc.destapic = MP_APIC_ALL;
565 for (i = 0; i < 2; i++) {
566 lintsrc.irqtype = linttypes[i];
567 lintsrc.destapiclint = i;
568 MP_lintsrc_info(&lintsrc);
572 static struct mpf_intel *mpf_found;
575 * Scan the memory blocks for an SMP configuration block.
577 static void __init __get_smp_config(unsigned int early)
579 struct mpf_intel *mpf = mpf_found;
584 if (acpi_lapic && early)
588 * MPS doesn't support hyperthreading, aka only have
589 * thread 0 apic id in MPS table
591 if (acpi_lapic && acpi_ioapic)
594 if (x86_quirks->mach_get_smp_config) {
595 if (x86_quirks->mach_get_smp_config(early))
599 printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n",
601 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
602 if (mpf->feature2 & (1 << 7)) {
603 printk(KERN_INFO " IMCR and PIC compatibility mode.\n");
606 printk(KERN_INFO " Virtual Wire compatibility mode.\n");
611 * Now see if we need to read further.
613 if (mpf->feature1 != 0) {
616 * local APIC has default address
618 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
622 printk(KERN_INFO "Default MP configuration #%d\n",
624 construct_default_ISA_mptable(mpf->feature1);
626 } else if (mpf->physptr) {
629 * Read the physical hardware table. Anything here will
630 * override the defaults.
632 if (!smp_read_mpc(phys_to_virt(mpf->physptr), early)) {
633 #ifdef CONFIG_X86_LOCAL_APIC
634 smp_found_config = 0;
637 "BIOS bug, MP table errors detected!...\n");
638 printk(KERN_ERR "... disabling SMP support. "
639 "(tell your hw vendor)\n");
645 #ifdef CONFIG_X86_IO_APIC
647 * If there are no explicit MP IRQ entries, then we are
648 * broken. We set up most of the low 16 IO-APIC pins to
649 * ISA defaults and hope it will work.
651 if (!mp_irq_entries) {
654 printk(KERN_ERR "BIOS bug, no explicit IRQ entries, "
655 "using default mptable. "
656 "(tell your hw vendor)\n");
660 memcpy(bus.bustype, "ISA ", 6);
663 construct_default_ioirq_mptable(0);
670 printk(KERN_INFO "Processors: %d\n", num_processors);
672 * Only use the first configuration found.
676 void __init early_get_smp_config(void)
681 void __init get_smp_config(void)
686 static int __init smp_scan_config(unsigned long base, unsigned long length,
689 unsigned int *bp = phys_to_virt(base);
690 struct mpf_intel *mpf;
692 apic_printk(APIC_VERBOSE, "Scan SMP from %p for %ld bytes.\n",
694 BUILD_BUG_ON(sizeof(*mpf) != 16);
697 mpf = (struct mpf_intel *)bp;
698 if ((*bp == SMP_MAGIC_IDENT) &&
699 (mpf->length == 1) &&
700 !mpf_checksum((unsigned char *)bp, 16) &&
701 ((mpf->specification == 1)
702 || (mpf->specification == 4))) {
703 #ifdef CONFIG_X86_LOCAL_APIC
704 smp_found_config = 1;
708 printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n",
709 mpf, virt_to_phys(mpf));
713 reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE,
716 unsigned long size = PAGE_SIZE;
719 * We cannot access to MPC table to compute
720 * table size yet, as only few megabytes from
721 * the bottom is mapped now.
722 * PC-9800's MPC table places on the very last
723 * of physical memory; so that simply reserving
724 * PAGE_SIZE from mpf->physptr yields BUG()
725 * in reserve_bootmem.
727 unsigned long end = max_low_pfn * PAGE_SIZE;
728 if (mpf->physptr + size > end)
729 size = end - mpf->physptr;
731 reserve_bootmem_generic(mpf->physptr, size,
743 static void __init __find_smp_config(unsigned int reserve)
745 unsigned int address;
747 if (x86_quirks->mach_find_smp_config) {
748 if (x86_quirks->mach_find_smp_config(reserve))
752 * FIXME: Linux assumes you have 640K of base ram..
753 * this continues the error...
755 * 1) Scan the bottom 1K for a signature
756 * 2) Scan the top 1K of base RAM
757 * 3) Scan the 64K of bios
759 if (smp_scan_config(0x0, 0x400, reserve) ||
760 smp_scan_config(639 * 0x400, 0x400, reserve) ||
761 smp_scan_config(0xF0000, 0x10000, reserve))
764 * If it is an SMP machine we should know now, unless the
765 * configuration is in an EISA/MCA bus machine with an
766 * extended bios data area.
768 * there is a real-mode segmented pointer pointing to the
769 * 4K EBDA area at 0x40E, calculate and scan it here.
771 * NOTE! There are Linux loaders that will corrupt the EBDA
772 * area, and as such this kind of SMP config may be less
773 * trustworthy, simply because the SMP table may have been
774 * stomped on during early boot. These loaders are buggy and
777 * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
780 address = get_bios_ebda();
782 smp_scan_config(address, 0x400, reserve);
785 void __init early_find_smp_config(void)
787 __find_smp_config(0);
790 void __init find_smp_config(void)
792 __find_smp_config(1);
795 #ifdef CONFIG_X86_IO_APIC
796 static u8 __initdata irq_used[MAX_IRQ_SOURCES];
798 static int __init get_MP_intsrc_index(struct mpc_intsrc *m)
802 if (m->irqtype != mp_INT)
805 if (m->irqflag != 0x0f)
810 for (i = 0; i < mp_irq_entries; i++) {
811 if (mp_irqs[i].mp_irqtype != mp_INT)
814 if (mp_irqs[i].mp_irqflag != 0x0f)
817 if (mp_irqs[i].mp_srcbus != m->srcbus)
819 if (mp_irqs[i].mp_srcbusirq != m->srcbusirq)
822 /* already claimed */
833 #define SPARE_SLOT_NUM 20
835 static struct mpc_intsrc __initdata *m_spare[SPARE_SLOT_NUM];
838 static int __init replace_intsrc_all(struct mpc_table *mpc,
839 unsigned long mpc_new_phys,
840 unsigned long mpc_new_length)
842 #ifdef CONFIG_X86_IO_APIC
847 int count = sizeof(*mpc);
848 unsigned char *mpt = ((unsigned char *)mpc) + count;
850 printk(KERN_INFO "mpc_length %x\n", mpc->length);
851 while (count < mpc->length) {
855 struct mpc_cpu *m = (struct mpc_cpu *)mpt;
862 struct mpc_bus *m = (struct mpc_bus *)mpt;
869 mpt += sizeof(struct mpc_ioapic);
870 count += sizeof(struct mpc_ioapic);
875 #ifdef CONFIG_X86_IO_APIC
876 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
878 printk(KERN_INFO "OLD ");
879 print_MP_intsrc_info(m);
880 i = get_MP_intsrc_index(m);
882 assign_to_mpc_intsrc(&mp_irqs[i], m);
883 printk(KERN_INFO "NEW ");
884 print_mp_irq_info(&mp_irqs[i]);
886 /* legacy, do nothing */
887 } else if (nr_m_spare < SPARE_SLOT_NUM) {
889 * not found (-1), or duplicated (-2)
890 * are invalid entries,
891 * we need to use the slot later
893 m_spare[nr_m_spare] = m;
897 mpt += sizeof(struct mpc_intsrc);
898 count += sizeof(struct mpc_intsrc);
903 struct mpc_lintsrc *m =
904 (struct mpc_lintsrc *)mpt;
911 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n");
912 printk(KERN_ERR "type %x\n", *mpt);
913 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16,
914 1, mpc, mpc->length, 1);
919 #ifdef CONFIG_X86_IO_APIC
920 for (i = 0; i < mp_irq_entries; i++) {
924 if (mp_irqs[i].mp_irqtype != mp_INT)
927 if (mp_irqs[i].mp_irqflag != 0x0f)
930 if (nr_m_spare > 0) {
931 printk(KERN_INFO "*NEW* found ");
933 assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]);
934 m_spare[nr_m_spare] = NULL;
936 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
937 count += sizeof(struct mpc_intsrc);
939 printk(KERN_INFO "No spare slots, try to append...take your risk, new mpc_length %x\n", count);
941 if (count <= mpc_new_length)
942 printk(KERN_INFO "No spare slots, try to append..., new mpc_length %x\n", count);
944 printk(KERN_ERR "mpc_new_length %lx is too small\n", mpc_new_length);
948 assign_to_mpc_intsrc(&mp_irqs[i], m);
950 mpt += sizeof(struct mpc_intsrc);
952 print_mp_irq_info(&mp_irqs[i]);
956 /* update checksum */
958 mpc->checksum -= mpf_checksum((unsigned char *)mpc, mpc->length);
963 static int __initdata enable_update_mptable;
965 static int __init update_mptable_setup(char *str)
967 enable_update_mptable = 1;
970 early_param("update_mptable", update_mptable_setup);
972 static unsigned long __initdata mpc_new_phys;
973 static unsigned long mpc_new_length __initdata = 4096;
975 /* alloc_mptable or alloc_mptable=4k */
976 static int __initdata alloc_mptable;
977 static int __init parse_alloc_mptable_opt(char *p)
979 enable_update_mptable = 1;
983 mpc_new_length = memparse(p, &p);
986 early_param("alloc_mptable", parse_alloc_mptable_opt);
988 void __init early_reserve_e820_mpc_new(void)
990 if (enable_update_mptable && alloc_mptable) {
992 #ifdef CONFIG_X86_TRAMPOLINE
993 startt = TRAMPOLINE_BASE;
995 mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4);
999 static int __init update_mp_table(void)
1003 struct mpf_intel *mpf;
1004 struct mpc_table *mpc, *mpc_new;
1006 if (!enable_update_mptable)
1014 * Now see if we need to go further.
1016 if (mpf->feature1 != 0)
1022 mpc = phys_to_virt(mpf->physptr);
1024 if (!smp_check_mpc(mpc, oem, str))
1027 printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf));
1028 printk(KERN_INFO "physptr: %x\n", mpf->physptr);
1030 if (mpc_new_phys && mpc->length > mpc_new_length) {
1032 printk(KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n",
1036 if (!mpc_new_phys) {
1037 unsigned char old, new;
1038 /* check if we can change the postion */
1040 old = mpf_checksum((unsigned char *)mpc, mpc->length);
1041 mpc->checksum = 0xff;
1042 new = mpf_checksum((unsigned char *)mpc, mpc->length);
1044 printk(KERN_INFO "mpc is readonly, please try alloc_mptable instead\n");
1047 printk(KERN_INFO "use in-positon replacing\n");
1049 mpf->physptr = mpc_new_phys;
1050 mpc_new = phys_to_virt(mpc_new_phys);
1051 memcpy(mpc_new, mpc, mpc->length);
1053 /* check if we can modify that */
1054 if (mpc_new_phys - mpf->physptr) {
1055 struct mpf_intel *mpf_new;
1056 /* steal 16 bytes from [0, 1k) */
1057 printk(KERN_INFO "mpf new: %x\n", 0x400 - 16);
1058 mpf_new = phys_to_virt(0x400 - 16);
1059 memcpy(mpf_new, mpf, 16);
1061 mpf->physptr = mpc_new_phys;
1064 mpf->checksum -= mpf_checksum((unsigned char *)mpf, 16);
1065 printk(KERN_INFO "physptr new: %x\n", mpf->physptr);
1069 * only replace the one with mp_INT and
1070 * MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
1071 * already in mp_irqs , stored by ... and mp_config_acpi_gsi,
1072 * may need pci=routeirq for all coverage
1074 replace_intsrc_all(mpc, mpc_new_phys, mpc_new_length);
1079 late_initcall(update_mp_table);