| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 2 | *	Intel Multiprocessor Specification 1.1 and 1.4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | *	compliant MP-table parsing routines. | 
|  | 4 | * | 
| Alan Cox | 87c6fe2 | 2009-01-05 14:08:04 +0000 | [diff] [blame] | 5 | *	(c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk> | 
| Ingo Molnar | 8f47e16 | 2009-01-31 02:03:42 +0100 | [diff] [blame] | 6 | *	(c) 1998, 1999, 2000, 2009 Ingo Molnar <mingo@redhat.com> | 
| Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 7 | *      (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ | 
|  | 9 |  | 
|  | 10 | #include <linux/mm.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/delay.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/bootmem.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kernel_stat.h> | 
|  | 15 | #include <linux/mc146818rtc.h> | 
|  | 16 | #include <linux/bitops.h> | 
| Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 17 | #include <linux/acpi.h> | 
|  | 18 | #include <linux/module.h> | 
| Jaswinder Singh Rajput | 103ceff | 2009-01-02 23:43:25 +0530 | [diff] [blame] | 19 | #include <linux/smp.h> | 
| Yinghai Lu | 629e15d | 2009-05-15 13:05:16 -0700 | [diff] [blame] | 20 | #include <linux/pci.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <asm/mtrr.h> | 
|  | 23 | #include <asm/mpspec.h> | 
| Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 24 | #include <asm/pgalloc.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/io_apic.h> | 
| Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 26 | #include <asm/proto.h> | 
| Alexey Starikovskiy | ce3fe6b | 2008-03-17 22:08:17 +0300 | [diff] [blame] | 27 | #include <asm/bios_ebda.h> | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 28 | #include <asm/e820.h> | 
|  | 29 | #include <asm/trampoline.h> | 
| Yinghai Lu | 3c9cb6d | 2008-07-19 02:07:25 -0700 | [diff] [blame] | 30 | #include <asm/setup.h> | 
| Jaswinder Singh Rajput | 4884d8e | 2009-01-11 18:38:55 +0530 | [diff] [blame] | 31 | #include <asm/smp.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 |  | 
| Ingo Molnar | 7b6aa33 | 2009-02-17 13:58:15 +0100 | [diff] [blame] | 33 | #include <asm/apic.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | * Checksum an MP configuration block. | 
|  | 36 | */ | 
|  | 37 |  | 
|  | 38 | static int __init mpf_checksum(unsigned char *mp, int len) | 
|  | 39 | { | 
|  | 40 | int sum = 0; | 
|  | 41 |  | 
|  | 42 | while (len--) | 
|  | 43 | sum += *mp++; | 
|  | 44 |  | 
|  | 45 | return sum & 0xFF; | 
|  | 46 | } | 
|  | 47 |  | 
| Thomas Gleixner | fd6c666 | 2009-08-20 10:41:58 +0200 | [diff] [blame] | 48 | int __init default_mpc_apic_id(struct mpc_cpu *m) | 
|  | 49 | { | 
|  | 50 | return m->apicid; | 
|  | 51 | } | 
|  | 52 |  | 
| Jaswinder Singh Rajput | f4f21b7 | 2009-01-03 15:48:52 +0530 | [diff] [blame] | 53 | static void __init MP_processor_info(struct mpc_cpu *m) | 
| Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 54 | { | 
|  | 55 | int apicid; | 
| Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 56 | char *bootup_cpu = ""; | 
| Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 57 |  | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 58 | if (!(m->cpuflag & CPU_ENABLED)) { | 
| Glauber Costa | 7b1292e | 2008-03-03 14:12:41 -0300 | [diff] [blame] | 59 | disabled_cpus++; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | return; | 
| Glauber Costa | 7b1292e | 2008-03-03 14:12:41 -0300 | [diff] [blame] | 61 | } | 
| Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 62 |  | 
| Thomas Gleixner | fd6c666 | 2009-08-20 10:41:58 +0200 | [diff] [blame] | 63 | apicid = x86_init.mpparse.mpc_apic_id(m); | 
| Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 64 |  | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 65 | if (m->cpuflag & CPU_BOOTPROCESSOR) { | 
| Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 66 | bootup_cpu = " (Bootup-CPU)"; | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 67 | boot_cpu_physical_apicid = m->apicid; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | } | 
|  | 69 |  | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 70 | printk(KERN_INFO "Processor #%d%s\n", m->apicid, bootup_cpu); | 
|  | 71 | generic_processor_info(apicid, m->apicver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } | 
|  | 73 |  | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 74 | #ifdef CONFIG_X86_IO_APIC | 
| Thomas Gleixner | 90e1c69 | 2009-08-20 12:34:47 +0200 | [diff] [blame] | 75 | void __init default_mpc_oem_bus_info(struct mpc_bus *m, char *str) | 
|  | 76 | { | 
|  | 77 | memcpy(str, m->bustype, 6); | 
|  | 78 | str[6] = 0; | 
|  | 79 | apic_printk(APIC_VERBOSE, "Bus #%d is %s\n", m->busid, str); | 
|  | 80 | } | 
|  | 81 |  | 
| Jaswinder Singh Rajput | 00fb860 | 2009-01-03 15:47:32 +0530 | [diff] [blame] | 82 | static void __init MP_bus_info(struct mpc_bus *m) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { | 
|  | 84 | char str[7]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 |  | 
| Thomas Gleixner | 90e1c69 | 2009-08-20 12:34:47 +0200 | [diff] [blame] | 86 | x86_init.mpparse.mpc_oem_bus_info(m, str); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 |  | 
| Andi Kleen | 5e4edbb | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 88 | #if MAX_MP_BUSSES < 256 | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 89 | if (m->busid >= MAX_MP_BUSSES) { | 
| Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 90 | printk(KERN_WARNING "MP table busid value (%d) for bustype %s " | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 91 | " is too large, max. supported is %d\n", | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 92 | m->busid, str, MAX_MP_BUSSES - 1); | 
| Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 93 | return; | 
|  | 94 | } | 
| Andi Kleen | 5e4edbb | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 95 | #endif | 
| Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 96 |  | 
| Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 97 | if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) { | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 98 | set_bit(m->busid, mp_bus_not_pci); | 
| Jaswinder Singh Rajput | 103ceff | 2009-01-02 23:43:25 +0530 | [diff] [blame] | 99 | #if defined(CONFIG_EISA) || defined(CONFIG_MCA) | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 100 | mp_bus_id_to_type[m->busid] = MP_BUS_ISA; | 
| Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 101 | #endif | 
|  | 102 | } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) { | 
| Thomas Gleixner | 52fdb56 | 2009-08-20 12:45:33 +0200 | [diff] [blame] | 103 | if (x86_init.mpparse.mpc_oem_pci_bus) | 
|  | 104 | x86_init.mpparse.mpc_oem_pci_bus(m); | 
| Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 105 |  | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 106 | clear_bit(m->busid, mp_bus_not_pci); | 
| Jaswinder Singh Rajput | 103ceff | 2009-01-02 23:43:25 +0530 | [diff] [blame] | 107 | #if defined(CONFIG_EISA) || defined(CONFIG_MCA) | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 108 | mp_bus_id_to_type[m->busid] = MP_BUS_PCI; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 109 | } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) { | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 110 | mp_bus_id_to_type[m->busid] = MP_BUS_EISA; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 111 | } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) { | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 112 | mp_bus_id_to_type[m->busid] = MP_BUS_MCA; | 
| Alexey Starikovskiy | c0a282c | 2008-03-20 14:55:02 +0300 | [diff] [blame] | 113 | #endif | 
| Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 114 | } else | 
|  | 115 | printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } | 
| Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 117 |  | 
| Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 118 | static int bad_ioapic(unsigned long address) | 
|  | 119 | { | 
|  | 120 | if (nr_ioapics >= MAX_IO_APICS) { | 
|  | 121 | printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " | 
|  | 122 | "(found %d)\n", MAX_IO_APICS, nr_ioapics); | 
|  | 123 | panic("Recompile kernel with bigger MAX_IO_APICS!\n"); | 
|  | 124 | } | 
|  | 125 | if (!address) { | 
|  | 126 | printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address" | 
|  | 127 | " found in table, skipping!\n"); | 
|  | 128 | return 1; | 
|  | 129 | } | 
|  | 130 | return 0; | 
|  | 131 | } | 
|  | 132 |  | 
| Jaswinder Singh Rajput | 2b85b5f | 2009-01-03 15:49:57 +0530 | [diff] [blame] | 133 | static void __init MP_ioapic_info(struct mpc_ioapic *m) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { | 
| Jaswinder Singh Rajput | 5df82c7 | 2009-01-04 21:54:39 +0530 | [diff] [blame] | 135 | if (!(m->flags & MPC_APIC_USABLE)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | return; | 
|  | 137 |  | 
| Thomas Gleixner | 64883ab | 2008-01-30 13:30:35 +0100 | [diff] [blame] | 138 | printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n", | 
| Jaswinder Singh Rajput | 5df82c7 | 2009-01-04 21:54:39 +0530 | [diff] [blame] | 139 | m->apicid, m->apicver, m->apicaddr); | 
| Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 140 |  | 
| Jaswinder Singh Rajput | 5df82c7 | 2009-01-04 21:54:39 +0530 | [diff] [blame] | 141 | if (bad_ioapic(m->apicaddr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | return; | 
| Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 143 |  | 
| Jaswinder Singh Rajput | b5ba7e6 | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 144 | mp_ioapics[nr_ioapics].apicaddr = m->apicaddr; | 
|  | 145 | mp_ioapics[nr_ioapics].apicid = m->apicid; | 
|  | 146 | mp_ioapics[nr_ioapics].type = m->type; | 
|  | 147 | mp_ioapics[nr_ioapics].apicver = m->apicver; | 
|  | 148 | mp_ioapics[nr_ioapics].flags = m->flags; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | nr_ioapics++; | 
|  | 150 | } | 
|  | 151 |  | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 152 | static void print_MP_intsrc_info(struct mpc_intsrc *m) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { | 
| Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 154 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 156 | m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbus, | 
|  | 157 | m->srcbusirq, m->dstapic, m->dstirq); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 158 | } | 
|  | 159 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 160 | static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 161 | { | 
| Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 162 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 163 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 164 | mp_irq->irqtype, mp_irq->irqflag & 3, | 
|  | 165 | (mp_irq->irqflag >> 2) & 3, mp_irq->srcbus, | 
|  | 166 | mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 167 | } | 
|  | 168 |  | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 169 | static void __init assign_to_mp_irq(struct mpc_intsrc *m, | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 170 | struct mpc_intsrc *mp_irq) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 171 | { | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 172 | mp_irq->dstapic = m->dstapic; | 
|  | 173 | mp_irq->type = m->type; | 
|  | 174 | mp_irq->irqtype = m->irqtype; | 
|  | 175 | mp_irq->irqflag = m->irqflag; | 
|  | 176 | mp_irq->srcbus = m->srcbus; | 
|  | 177 | mp_irq->srcbusirq = m->srcbusirq; | 
|  | 178 | mp_irq->dstirq = m->dstirq; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 179 | } | 
|  | 180 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 181 | static void __init assign_to_mpc_intsrc(struct mpc_intsrc *mp_irq, | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 182 | struct mpc_intsrc *m) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 183 | { | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 184 | m->dstapic = mp_irq->dstapic; | 
|  | 185 | m->type = mp_irq->type; | 
|  | 186 | m->irqtype = mp_irq->irqtype; | 
|  | 187 | m->irqflag = mp_irq->irqflag; | 
|  | 188 | m->srcbus = mp_irq->srcbus; | 
|  | 189 | m->srcbusirq = mp_irq->srcbusirq; | 
|  | 190 | m->dstirq = mp_irq->dstirq; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 191 | } | 
|  | 192 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 193 | static int __init mp_irq_mpc_intsrc_cmp(struct mpc_intsrc *mp_irq, | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 194 | struct mpc_intsrc *m) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 195 | { | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 196 | if (mp_irq->dstapic != m->dstapic) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 197 | return 1; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 198 | if (mp_irq->type != m->type) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 199 | return 2; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 200 | if (mp_irq->irqtype != m->irqtype) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 201 | return 3; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 202 | if (mp_irq->irqflag != m->irqflag) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 203 | return 4; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 204 | if (mp_irq->srcbus != m->srcbus) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 205 | return 5; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 206 | if (mp_irq->srcbusirq != m->srcbusirq) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 207 | return 6; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 208 | if (mp_irq->dstirq != m->dstirq) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 209 | return 7; | 
|  | 210 |  | 
|  | 211 | return 0; | 
|  | 212 | } | 
|  | 213 |  | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 214 | static void __init MP_intsrc_info(struct mpc_intsrc *m) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 215 | { | 
|  | 216 | int i; | 
|  | 217 |  | 
|  | 218 | print_MP_intsrc_info(m); | 
|  | 219 |  | 
| Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 220 | for (i = 0; i < mp_irq_entries; i++) { | 
|  | 221 | if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) | 
|  | 222 | return; | 
|  | 223 | } | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 224 |  | 
|  | 225 | assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | if (++mp_irq_entries == MAX_IRQ_SOURCES) | 
|  | 227 | panic("Max # of irq sources exceeded!!\n"); | 
|  | 228 | } | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 229 | #else /* CONFIG_X86_IO_APIC */ | 
|  | 230 | static inline void __init MP_bus_info(struct mpc_bus *m) {} | 
|  | 231 | static inline void __init MP_ioapic_info(struct mpc_ioapic *m) {} | 
|  | 232 | static inline void __init MP_intsrc_info(struct mpc_intsrc *m) {} | 
|  | 233 | #endif /* CONFIG_X86_IO_APIC */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 |  | 
| Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 235 |  | 
| Jaswinder Singh Rajput | 8fb2952 | 2009-01-03 15:51:54 +0530 | [diff] [blame] | 236 | static void __init MP_lintsrc_info(struct mpc_lintsrc *m) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | { | 
| Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 238 | apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x," | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | " IRQ %02x, APIC ID %x, APIC LINT %02x\n", | 
| Jaswinder Singh Rajput | b5ced7c | 2009-01-04 21:55:53 +0530 | [diff] [blame] | 240 | m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbusid, | 
|  | 241 | m->srcbusirq, m->destapic, m->destapiclint); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } | 
|  | 243 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | /* | 
|  | 245 | * Read/parse the MPC | 
|  | 246 | */ | 
|  | 247 |  | 
| Jaswinder Singh Rajput | f29521e | 2009-01-03 15:46:57 +0530 | [diff] [blame] | 248 | static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 |  | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 251 | if (memcmp(mpc->signature, MPC_SIGNATURE, 4)) { | 
| Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 252 | printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n", | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 253 | mpc->signature[0], mpc->signature[1], | 
|  | 254 | mpc->signature[2], mpc->signature[3]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | return 0; | 
|  | 256 | } | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 257 | if (mpf_checksum((unsigned char *)mpc, mpc->length)) { | 
| Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 258 | printk(KERN_ERR "MPTABLE: checksum error!\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | return 0; | 
|  | 260 | } | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 261 | if (mpc->spec != 0x01 && mpc->spec != 0x04) { | 
| Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 262 | printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n", | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 263 | mpc->spec); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | return 0; | 
|  | 265 | } | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 266 | if (!mpc->lapic) { | 
| Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 267 | printk(KERN_ERR "MPTABLE: null local APIC address!\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | return 0; | 
|  | 269 | } | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 270 | memcpy(oem, mpc->oem, 8); | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 271 | oem[8] = 0; | 
| Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 272 | printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 |  | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 274 | memcpy(str, mpc->productid, 12); | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 275 | str[12] = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 |  | 
| Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 277 | printk(KERN_INFO "MPTABLE: Product ID: %s\n", str); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 |  | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 279 | printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->lapic); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 |  | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 281 | return 1; | 
|  | 282 | } | 
|  | 283 |  | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 284 | static void skip_entry(unsigned char **ptr, int *count, int size) | 
|  | 285 | { | 
|  | 286 | *ptr += size; | 
|  | 287 | *count += size; | 
|  | 288 | } | 
|  | 289 |  | 
| Jaswinder Singh Rajput | 5a5737e | 2009-03-21 13:28:39 +0530 | [diff] [blame] | 290 | static void __init smp_dump_mptable(struct mpc_table *mpc, unsigned char *mpt) | 
|  | 291 | { | 
|  | 292 | printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n" | 
|  | 293 | "type %x\n", *mpt); | 
|  | 294 | print_hex_dump(KERN_ERR, "  ", DUMP_PREFIX_ADDRESS, 16, | 
|  | 295 | 1, mpc, mpc->length, 1); | 
|  | 296 | } | 
|  | 297 |  | 
| Thomas Gleixner | 7230214 | 2009-08-20 12:18:32 +0200 | [diff] [blame] | 298 | void __init default_smp_read_mpc_oem(struct mpc_table *mpc) { } | 
|  | 299 |  | 
| Jaswinder Singh Rajput | f29521e | 2009-01-03 15:46:57 +0530 | [diff] [blame] | 300 | static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 301 | { | 
|  | 302 | char str[16]; | 
|  | 303 | char oem[10]; | 
|  | 304 |  | 
|  | 305 | int count = sizeof(*mpc); | 
|  | 306 | unsigned char *mpt = ((unsigned char *)mpc) + count; | 
|  | 307 |  | 
|  | 308 | if (!smp_check_mpc(mpc, oem, str)) | 
|  | 309 | return 0; | 
|  | 310 |  | 
|  | 311 | #ifdef CONFIG_X86_32 | 
| Ingo Molnar | 9c76424 | 2009-01-28 13:44:32 +0100 | [diff] [blame] | 312 | generic_mps_oem_check(mpc, oem, str); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 313 | #endif | 
| Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 314 | /* save the local APIC address, it might be non-default */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | if (!acpi_lapic) | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 316 | mp_lapic_addr = mpc->lapic; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 |  | 
| Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 318 | if (early) | 
|  | 319 | return 1; | 
|  | 320 |  | 
| Thomas Gleixner | 7230214 | 2009-08-20 12:18:32 +0200 | [diff] [blame] | 321 | if (mpc->oemptr) | 
|  | 322 | x86_init.mpparse.smp_read_mpc_oem(mpc); | 
| Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 323 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | /* | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 325 | *      Now process the configuration blocks. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | */ | 
| Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 327 | x86_init.mpparse.mpc_record(0); | 
| Yinghai Lu | 64898a8 | 2008-07-19 18:01:16 -0700 | [diff] [blame] | 328 |  | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 329 | while (count < mpc->length) { | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 330 | switch (*mpt) { | 
|  | 331 | case MP_PROCESSOR: | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 332 | /* ACPI may have already provided this data */ | 
|  | 333 | if (!acpi_lapic) | 
| Ingo Molnar | c58603e | 2009-03-19 08:50:35 +0100 | [diff] [blame] | 334 | MP_processor_info((struct mpc_cpu *)mpt); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 335 | skip_entry(&mpt, &count, sizeof(struct mpc_cpu)); | 
|  | 336 | break; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 337 | case MP_BUS: | 
| Ingo Molnar | c58603e | 2009-03-19 08:50:35 +0100 | [diff] [blame] | 338 | MP_bus_info((struct mpc_bus *)mpt); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 339 | skip_entry(&mpt, &count, sizeof(struct mpc_bus)); | 
|  | 340 | break; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 341 | case MP_IOAPIC: | 
| Ingo Molnar | c58603e | 2009-03-19 08:50:35 +0100 | [diff] [blame] | 342 | MP_ioapic_info((struct mpc_ioapic *)mpt); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 343 | skip_entry(&mpt, &count, sizeof(struct mpc_ioapic)); | 
|  | 344 | break; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 345 | case MP_INTSRC: | 
| Ingo Molnar | c58603e | 2009-03-19 08:50:35 +0100 | [diff] [blame] | 346 | MP_intsrc_info((struct mpc_intsrc *)mpt); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 347 | skip_entry(&mpt, &count, sizeof(struct mpc_intsrc)); | 
|  | 348 | break; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 349 | case MP_LINTSRC: | 
| Ingo Molnar | c58603e | 2009-03-19 08:50:35 +0100 | [diff] [blame] | 350 | MP_lintsrc_info((struct mpc_lintsrc *)mpt); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 351 | skip_entry(&mpt, &count, sizeof(struct mpc_lintsrc)); | 
|  | 352 | break; | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 353 | default: | 
| Yinghai Lu | 711554d | 2008-04-07 11:36:39 -0700 | [diff] [blame] | 354 | /* wrong mptable */ | 
| Jaswinder Singh Rajput | 5a5737e | 2009-03-21 13:28:39 +0530 | [diff] [blame] | 355 | smp_dump_mptable(mpc, mpt); | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 356 | count = mpc->length; | 
| Yinghai Lu | 711554d | 2008-04-07 11:36:39 -0700 | [diff] [blame] | 357 | break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } | 
| Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 359 | x86_init.mpparse.mpc_record(1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | } | 
| Yinghai Lu | e0da336 | 2008-06-08 18:29:22 -0700 | [diff] [blame] | 361 |  | 
| Yinghai Lu | 26f7ef1 | 2009-01-29 14:19:22 -0800 | [diff] [blame] | 362 | #ifdef CONFIG_X86_BIGSMP | 
|  | 363 | generic_bigsmp_probe(); | 
| Yinghai Lu | e0da336 | 2008-06-08 18:29:22 -0700 | [diff] [blame] | 364 | #endif | 
|  | 365 |  | 
| Ingo Molnar | 72ce016 | 2009-01-28 06:50:47 +0100 | [diff] [blame] | 366 | if (apic->setup_apic_routing) | 
|  | 367 | apic->setup_apic_routing(); | 
|  | 368 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | if (!num_processors) | 
| Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 370 | printk(KERN_ERR "MPTABLE: no processors registered!\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | return num_processors; | 
|  | 372 | } | 
|  | 373 |  | 
| Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 374 | #ifdef CONFIG_X86_IO_APIC | 
|  | 375 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | static int __init ELCR_trigger(unsigned int irq) | 
|  | 377 | { | 
|  | 378 | unsigned int port; | 
|  | 379 |  | 
|  | 380 | port = 0x4d0 + (irq >> 3); | 
|  | 381 | return (inb(port) >> (irq & 7)) & 1; | 
|  | 382 | } | 
|  | 383 |  | 
|  | 384 | static void __init construct_default_ioirq_mptable(int mpc_default_type) | 
|  | 385 | { | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 386 | struct mpc_intsrc intsrc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | int i; | 
|  | 388 | int ELCR_fallback = 0; | 
|  | 389 |  | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 390 | intsrc.type = MP_INTSRC; | 
|  | 391 | intsrc.irqflag = 0;	/* conforming */ | 
|  | 392 | intsrc.srcbus = 0; | 
| Jaswinder Singh Rajput | b5ba7e6 | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 393 | intsrc.dstapic = mp_ioapics[0].apicid; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 |  | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 395 | intsrc.irqtype = mp_INT; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 |  | 
|  | 397 | /* | 
|  | 398 | *  If true, we have an ISA/PCI system with no IRQ entries | 
|  | 399 | *  in the MP table. To prevent the PCI interrupts from being set up | 
|  | 400 | *  incorrectly, we try to use the ELCR. The sanity check to see if | 
|  | 401 | *  there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can | 
|  | 402 | *  never be level sensitive, so we simply see if the ELCR agrees. | 
|  | 403 | *  If it does, we assume it's valid. | 
|  | 404 | */ | 
|  | 405 | if (mpc_default_type == 5) { | 
| Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 406 | printk(KERN_INFO "ISA/PCI bus type with no IRQ information... " | 
|  | 407 | "falling back to ELCR\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 |  | 
| Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 409 | if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || | 
|  | 410 | ELCR_trigger(13)) | 
|  | 411 | printk(KERN_ERR "ELCR contains invalid data... " | 
|  | 412 | "not using ELCR\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | else { | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 414 | printk(KERN_INFO | 
|  | 415 | "Using ELCR to identify PCI interrupts\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | ELCR_fallback = 1; | 
|  | 417 | } | 
|  | 418 | } | 
|  | 419 |  | 
|  | 420 | for (i = 0; i < 16; i++) { | 
|  | 421 | switch (mpc_default_type) { | 
|  | 422 | case 2: | 
|  | 423 | if (i == 0 || i == 13) | 
|  | 424 | continue;	/* IRQ0 & IRQ13 not connected */ | 
|  | 425 | /* fall through */ | 
|  | 426 | default: | 
|  | 427 | if (i == 2) | 
|  | 428 | continue;	/* IRQ2 is never connected */ | 
|  | 429 | } | 
|  | 430 |  | 
|  | 431 | if (ELCR_fallback) { | 
|  | 432 | /* | 
|  | 433 | *  If the ELCR indicates a level-sensitive interrupt, we | 
|  | 434 | *  copy that information over to the MP table in the | 
|  | 435 | *  irqflag field (level sensitive, active high polarity). | 
|  | 436 | */ | 
|  | 437 | if (ELCR_trigger(i)) | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 438 | intsrc.irqflag = 13; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | else | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 440 | intsrc.irqflag = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | } | 
|  | 442 |  | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 443 | intsrc.srcbusirq = i; | 
|  | 444 | intsrc.dstirq = i ? i : 2;	/* IRQ0 to INTIN2 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | MP_intsrc_info(&intsrc); | 
|  | 446 | } | 
|  | 447 |  | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 448 | intsrc.irqtype = mp_ExtINT; | 
|  | 449 | intsrc.srcbusirq = 0; | 
|  | 450 | intsrc.dstirq = 0;	/* 8259A to INTIN0 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | MP_intsrc_info(&intsrc); | 
|  | 452 | } | 
|  | 453 |  | 
| Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 454 |  | 
| Marcin Slusarz | 39e00fe | 2008-08-11 00:09:38 +0200 | [diff] [blame] | 455 | static void __init construct_ioapic_table(int mpc_default_type) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | { | 
| Jaswinder Singh Rajput | 2b85b5f | 2009-01-03 15:49:57 +0530 | [diff] [blame] | 457 | struct mpc_ioapic ioapic; | 
| Jaswinder Singh Rajput | 00fb860 | 2009-01-03 15:47:32 +0530 | [diff] [blame] | 458 | struct mpc_bus bus; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 |  | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 460 | bus.type = MP_BUS; | 
|  | 461 | bus.busid = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | switch (mpc_default_type) { | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 463 | default: | 
| Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 464 | printk(KERN_ERR "???\nUnknown standard configuration %d\n", | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 465 | mpc_default_type); | 
|  | 466 | /* fall through */ | 
|  | 467 | case 1: | 
|  | 468 | case 5: | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 469 | memcpy(bus.bustype, "ISA   ", 6); | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 470 | break; | 
|  | 471 | case 2: | 
|  | 472 | case 6: | 
|  | 473 | case 3: | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 474 | memcpy(bus.bustype, "EISA  ", 6); | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 475 | break; | 
|  | 476 | case 4: | 
|  | 477 | case 7: | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 478 | memcpy(bus.bustype, "MCA   ", 6); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } | 
|  | 480 | MP_bus_info(&bus); | 
|  | 481 | if (mpc_default_type > 4) { | 
| Jaswinder Singh Rajput | d4c715f | 2009-01-04 21:59:26 +0530 | [diff] [blame] | 482 | bus.busid = 1; | 
|  | 483 | memcpy(bus.bustype, "PCI   ", 6); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | MP_bus_info(&bus); | 
|  | 485 | } | 
|  | 486 |  | 
| Cyrill Gorcunov | 8f3e1df | 2009-08-24 21:53:36 +0400 | [diff] [blame] | 487 | ioapic.type	= MP_IOAPIC; | 
|  | 488 | ioapic.apicid	= 2; | 
|  | 489 | ioapic.apicver	= mpc_default_type > 4 ? 0x10 : 0x01; | 
|  | 490 | ioapic.flags	= MPC_APIC_USABLE; | 
|  | 491 | ioapic.apicaddr	= IO_APIC_DEFAULT_PHYS_BASE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | MP_ioapic_info(&ioapic); | 
|  | 493 |  | 
|  | 494 | /* | 
|  | 495 | * We set up most of the low 16 IO-APIC pins according to MPS rules. | 
|  | 496 | */ | 
|  | 497 | construct_default_ioirq_mptable(mpc_default_type); | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 498 | } | 
|  | 499 | #else | 
| Marcin Slusarz | 39e00fe | 2008-08-11 00:09:38 +0200 | [diff] [blame] | 500 | static inline void __init construct_ioapic_table(int mpc_default_type) { } | 
| Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 501 | #endif | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 502 |  | 
|  | 503 | static inline void __init construct_default_ISA_mptable(int mpc_default_type) | 
|  | 504 | { | 
| Jaswinder Singh Rajput | f4f21b7 | 2009-01-03 15:48:52 +0530 | [diff] [blame] | 505 | struct mpc_cpu processor; | 
| Jaswinder Singh Rajput | 8fb2952 | 2009-01-03 15:51:54 +0530 | [diff] [blame] | 506 | struct mpc_lintsrc lintsrc; | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 507 | int linttypes[2] = { mp_ExtINT, mp_NMI }; | 
|  | 508 | int i; | 
|  | 509 |  | 
|  | 510 | /* | 
|  | 511 | * local APIC has default address | 
|  | 512 | */ | 
|  | 513 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; | 
|  | 514 |  | 
|  | 515 | /* | 
|  | 516 | * 2 CPUs, numbered 0 & 1. | 
|  | 517 | */ | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 518 | processor.type = MP_PROCESSOR; | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 519 | /* Either an integrated APIC or a discrete 82489DX. */ | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 520 | processor.apicver = mpc_default_type > 4 ? 0x10 : 0x01; | 
|  | 521 | processor.cpuflag = CPU_ENABLED; | 
|  | 522 | processor.cpufeature = (boot_cpu_data.x86 << 8) | | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 523 | (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask; | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 524 | processor.featureflag = boot_cpu_data.x86_capability[0]; | 
|  | 525 | processor.reserved[0] = 0; | 
|  | 526 | processor.reserved[1] = 0; | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 527 | for (i = 0; i < 2; i++) { | 
| Jaswinder Singh Rajput | c456382 | 2009-01-04 21:58:25 +0530 | [diff] [blame] | 528 | processor.apicid = i; | 
| Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 529 | MP_processor_info(&processor); | 
|  | 530 | } | 
|  | 531 |  | 
|  | 532 | construct_ioapic_table(mpc_default_type); | 
|  | 533 |  | 
| Jaswinder Singh Rajput | b5ced7c | 2009-01-04 21:55:53 +0530 | [diff] [blame] | 534 | lintsrc.type = MP_LINTSRC; | 
|  | 535 | lintsrc.irqflag = 0;		/* conforming */ | 
|  | 536 | lintsrc.srcbusid = 0; | 
|  | 537 | lintsrc.srcbusirq = 0; | 
|  | 538 | lintsrc.destapic = MP_APIC_ALL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | for (i = 0; i < 2; i++) { | 
| Jaswinder Singh Rajput | b5ced7c | 2009-01-04 21:55:53 +0530 | [diff] [blame] | 540 | lintsrc.irqtype = linttypes[i]; | 
|  | 541 | lintsrc.destapiclint = i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | MP_lintsrc_info(&lintsrc); | 
|  | 543 | } | 
|  | 544 | } | 
|  | 545 |  | 
| Jaswinder Singh Rajput | 41401db | 2009-01-08 15:42:46 +0530 | [diff] [blame] | 546 | static struct mpf_intel *mpf_found; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 |  | 
| Yinghai Lu | 8d4dd91 | 2009-03-04 01:25:21 -0800 | [diff] [blame] | 548 | static unsigned long __init get_mpc_size(unsigned long physptr) | 
|  | 549 | { | 
|  | 550 | struct mpc_table *mpc; | 
|  | 551 | unsigned long size; | 
|  | 552 |  | 
|  | 553 | mpc = early_ioremap(physptr, PAGE_SIZE); | 
|  | 554 | size = mpc->length; | 
|  | 555 | early_iounmap(mpc, PAGE_SIZE); | 
|  | 556 | apic_printk(APIC_VERBOSE, "  mpc: %lx-%lx\n", physptr, physptr + size); | 
|  | 557 |  | 
|  | 558 | return size; | 
|  | 559 | } | 
|  | 560 |  | 
| Jaswinder Singh Rajput | 0b3ba0c | 2009-03-21 13:43:20 +0530 | [diff] [blame] | 561 | static int __init check_physptr(struct mpf_intel *mpf, unsigned int early) | 
|  | 562 | { | 
|  | 563 | struct mpc_table *mpc; | 
|  | 564 | unsigned long size; | 
|  | 565 |  | 
|  | 566 | size = get_mpc_size(mpf->physptr); | 
|  | 567 | mpc = early_ioremap(mpf->physptr, size); | 
|  | 568 | /* | 
|  | 569 | * Read the physical hardware table.  Anything here will | 
|  | 570 | * override the defaults. | 
|  | 571 | */ | 
|  | 572 | if (!smp_read_mpc(mpc, early)) { | 
|  | 573 | #ifdef CONFIG_X86_LOCAL_APIC | 
|  | 574 | smp_found_config = 0; | 
|  | 575 | #endif | 
|  | 576 | printk(KERN_ERR "BIOS bug, MP table errors detected!...\n" | 
|  | 577 | "... disabling SMP support. (tell your hw vendor)\n"); | 
|  | 578 | early_iounmap(mpc, size); | 
|  | 579 | return -1; | 
|  | 580 | } | 
|  | 581 | early_iounmap(mpc, size); | 
|  | 582 |  | 
|  | 583 | if (early) | 
|  | 584 | return -1; | 
|  | 585 |  | 
|  | 586 | #ifdef CONFIG_X86_IO_APIC | 
|  | 587 | /* | 
|  | 588 | * If there are no explicit MP IRQ entries, then we are | 
|  | 589 | * broken.  We set up most of the low 16 IO-APIC pins to | 
|  | 590 | * ISA defaults and hope it will work. | 
|  | 591 | */ | 
|  | 592 | if (!mp_irq_entries) { | 
|  | 593 | struct mpc_bus bus; | 
|  | 594 |  | 
|  | 595 | printk(KERN_ERR "BIOS bug, no explicit IRQ entries, " | 
|  | 596 | "using default mptable. (tell your hw vendor)\n"); | 
|  | 597 |  | 
|  | 598 | bus.type = MP_BUS; | 
|  | 599 | bus.busid = 0; | 
|  | 600 | memcpy(bus.bustype, "ISA   ", 6); | 
|  | 601 | MP_bus_info(&bus); | 
|  | 602 |  | 
|  | 603 | construct_default_ioirq_mptable(0); | 
|  | 604 | } | 
|  | 605 | #endif | 
|  | 606 |  | 
|  | 607 | return 0; | 
|  | 608 | } | 
|  | 609 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | /* | 
|  | 611 | * Scan the memory blocks for an SMP configuration block. | 
|  | 612 | */ | 
| Thomas Gleixner | b3f1b61 | 2009-08-20 11:11:52 +0200 | [diff] [blame] | 613 | void __init default_get_smp_config(unsigned int early) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | { | 
| Jaswinder Singh Rajput | 41401db | 2009-01-08 15:42:46 +0530 | [diff] [blame] | 615 | struct mpf_intel *mpf = mpf_found; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 |  | 
| Yinghai Lu | 69b88af | 2008-12-05 22:45:50 -0800 | [diff] [blame] | 617 | if (!mpf) | 
|  | 618 | return; | 
|  | 619 |  | 
|  | 620 | if (acpi_lapic && early) | 
|  | 621 | return; | 
|  | 622 |  | 
|  | 623 | /* | 
|  | 624 | * MPS doesn't support hyperthreading, aka only have | 
|  | 625 | * thread 0 apic id in MPS table | 
|  | 626 | */ | 
|  | 627 | if (acpi_lapic && acpi_ioapic) | 
|  | 628 | return; | 
|  | 629 |  | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 630 | printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 631 | mpf->specification); | 
| Alexey Starikovskiy | b3e2416 | 2008-05-23 01:54:44 +0400 | [diff] [blame] | 632 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 633 | if (mpf->feature2 & (1 << 7)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | printk(KERN_INFO "    IMCR and PIC compatibility mode.\n"); | 
|  | 635 | pic_mode = 1; | 
|  | 636 | } else { | 
|  | 637 | printk(KERN_INFO "    Virtual Wire compatibility mode.\n"); | 
|  | 638 | pic_mode = 0; | 
|  | 639 | } | 
| Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 640 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | /* | 
|  | 642 | * Now see if we need to read further. | 
|  | 643 | */ | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 644 | if (mpf->feature1 != 0) { | 
| Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 645 | if (early) { | 
|  | 646 | /* | 
|  | 647 | * local APIC has default address | 
|  | 648 | */ | 
|  | 649 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; | 
|  | 650 | return; | 
|  | 651 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 |  | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 653 | printk(KERN_INFO "Default MP configuration #%d\n", | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 654 | mpf->feature1); | 
|  | 655 | construct_default_ISA_mptable(mpf->feature1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 |  | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 657 | } else if (mpf->physptr) { | 
| Jaswinder Singh Rajput | 0b3ba0c | 2009-03-21 13:43:20 +0530 | [diff] [blame] | 658 | if (check_physptr(mpf, early)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | return; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } else | 
|  | 661 | BUG(); | 
|  | 662 |  | 
| Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 663 | if (!early) | 
|  | 664 | printk(KERN_INFO "Processors: %d\n", num_processors); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | /* | 
|  | 666 | * Only use the first configuration found. | 
|  | 667 | */ | 
|  | 668 | } | 
|  | 669 |  | 
| Rakib Mullick | 5759222 | 2009-04-11 09:04:59 +0600 | [diff] [blame] | 670 | static void __init smp_reserve_bootmem(struct mpf_intel *mpf) | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 671 | { | 
|  | 672 | unsigned long size = get_mpc_size(mpf->physptr); | 
|  | 673 | #ifdef CONFIG_X86_32 | 
|  | 674 | /* | 
|  | 675 | * We cannot access to MPC table to compute table size yet, | 
|  | 676 | * as only few megabytes from the bottom is mapped now. | 
|  | 677 | * PC-9800's MPC table places on the very last of physical | 
|  | 678 | * memory; so that simply reserving PAGE_SIZE from mpf->physptr | 
|  | 679 | * yields BUG() in reserve_bootmem. | 
|  | 680 | * also need to make sure physptr is below than max_low_pfn | 
|  | 681 | * we don't need reserve the area above max_low_pfn | 
|  | 682 | */ | 
|  | 683 | unsigned long end = max_low_pfn * PAGE_SIZE; | 
|  | 684 |  | 
|  | 685 | if (mpf->physptr < end) { | 
|  | 686 | if (mpf->physptr + size > end) | 
|  | 687 | size = end - mpf->physptr; | 
|  | 688 | reserve_bootmem_generic(mpf->physptr, size, BOOTMEM_DEFAULT); | 
|  | 689 | } | 
|  | 690 | #else | 
|  | 691 | reserve_bootmem_generic(mpf->physptr, size, BOOTMEM_DEFAULT); | 
|  | 692 | #endif | 
|  | 693 | } | 
|  | 694 |  | 
| Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 695 | static int __init smp_scan_config(unsigned long base, unsigned long length, | 
|  | 696 | unsigned reserve) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | { | 
| Alexey Starikovskiy | 92fd4b7 | 2008-04-04 23:42:46 +0400 | [diff] [blame] | 698 | unsigned int *bp = phys_to_virt(base); | 
| Jaswinder Singh Rajput | 41401db | 2009-01-08 15:42:46 +0530 | [diff] [blame] | 699 | struct mpf_intel *mpf; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 |  | 
| Rene Herman | eeb0d7d | 2008-08-11 17:44:57 +0200 | [diff] [blame] | 701 | apic_printk(APIC_VERBOSE, "Scan SMP from %p for %ld bytes.\n", | 
|  | 702 | bp, length); | 
| Akinobu Mita | 5d47a27 | 2008-04-19 23:55:11 +0900 | [diff] [blame] | 703 | BUILD_BUG_ON(sizeof(*mpf) != 16); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 |  | 
|  | 705 | while (length > 0) { | 
| Jaswinder Singh Rajput | 41401db | 2009-01-08 15:42:46 +0530 | [diff] [blame] | 706 | mpf = (struct mpf_intel *)bp; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | if ((*bp == SMP_MAGIC_IDENT) && | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 708 | (mpf->length == 1) && | 
| Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 709 | !mpf_checksum((unsigned char *)bp, 16) && | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 710 | ((mpf->specification == 1) | 
|  | 711 | || (mpf->specification == 4))) { | 
| Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 712 | #ifdef CONFIG_X86_LOCAL_APIC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | smp_found_config = 1; | 
| Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 714 | #endif | 
| Alexey Starikovskiy | 92fd4b7 | 2008-04-04 23:42:46 +0400 | [diff] [blame] | 715 | mpf_found = mpf; | 
| Yinghai Lu | b1f006b | 2008-06-09 18:11:36 -0700 | [diff] [blame] | 716 |  | 
| Jaswinder Singh Rajput | ba1511b | 2009-02-11 23:38:25 +0530 | [diff] [blame] | 717 | printk(KERN_INFO "found SMP MP-table at [%p] %llx\n", | 
|  | 718 | mpf, (u64)virt_to_phys(mpf)); | 
| Yinghai Lu | b1f006b | 2008-06-09 18:11:36 -0700 | [diff] [blame] | 719 |  | 
|  | 720 | if (!reserve) | 
|  | 721 | return 1; | 
| Yinghai Lu | f624323 | 2009-03-04 01:25:54 -0800 | [diff] [blame] | 722 | reserve_bootmem_generic(virt_to_phys(mpf), sizeof(*mpf), | 
| Bernhard Walle | 72a7fe3 | 2008-02-07 00:15:17 -0800 | [diff] [blame] | 723 | BOOTMEM_DEFAULT); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 724 | if (mpf->physptr) | 
|  | 725 | smp_reserve_bootmem(mpf); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 |  | 
| Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 727 | return 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | } | 
|  | 729 | bp += 4; | 
|  | 730 | length -= 16; | 
|  | 731 | } | 
|  | 732 | return 0; | 
|  | 733 | } | 
|  | 734 |  | 
| Thomas Gleixner | b3f1b61 | 2009-08-20 11:11:52 +0200 | [diff] [blame] | 735 | void __init default_find_smp_config(unsigned int reserve) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | { | 
|  | 737 | unsigned int address; | 
|  | 738 |  | 
|  | 739 | /* | 
|  | 740 | * FIXME: Linux assumes you have 640K of base ram.. | 
|  | 741 | * this continues the error... | 
|  | 742 | * | 
|  | 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 | 
|  | 746 | */ | 
| Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 747 | if (smp_scan_config(0x0, 0x400, reserve) || | 
|  | 748 | smp_scan_config(639 * 0x400, 0x400, reserve) || | 
|  | 749 | smp_scan_config(0xF0000, 0x10000, reserve)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | return; | 
|  | 751 | /* | 
|  | 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. | 
|  | 755 | * | 
|  | 756 | * there is a real-mode segmented pointer pointing to the | 
|  | 757 | * 4K EBDA area at 0x40E, calculate and scan it here. | 
|  | 758 | * | 
|  | 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 | 
|  | 763 | * should be fixed. | 
|  | 764 | * | 
|  | 765 | * MP1.4 SPEC states to only scan first 1K of 4K EBDA. | 
|  | 766 | */ | 
|  | 767 |  | 
|  | 768 | address = get_bios_ebda(); | 
|  | 769 | if (address) | 
| Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 770 | smp_scan_config(address, 0x400, reserve); | 
|  | 771 | } | 
|  | 772 |  | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 773 | #ifdef CONFIG_X86_IO_APIC | 
|  | 774 | static u8 __initdata irq_used[MAX_IRQ_SOURCES]; | 
|  | 775 |  | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 776 | static int  __init get_MP_intsrc_index(struct mpc_intsrc *m) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 777 | { | 
|  | 778 | int i; | 
|  | 779 |  | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 780 | if (m->irqtype != mp_INT) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 781 | return 0; | 
|  | 782 |  | 
| Jaswinder Singh Rajput | e253b39 | 2009-01-04 21:56:44 +0530 | [diff] [blame] | 783 | if (m->irqflag != 0x0f) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 784 | return 0; | 
|  | 785 |  | 
|  | 786 | /* not legacy */ | 
|  | 787 |  | 
|  | 788 | for (i = 0; i < mp_irq_entries; i++) { | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 789 | if (mp_irqs[i].irqtype != mp_INT) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 790 | continue; | 
|  | 791 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 792 | if (mp_irqs[i].irqflag != 0x0f) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 793 | continue; | 
|  | 794 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 795 | if (mp_irqs[i].srcbus != m->srcbus) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 796 | continue; | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 797 | if (mp_irqs[i].srcbusirq != m->srcbusirq) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 798 | continue; | 
|  | 799 | if (irq_used[i]) { | 
|  | 800 | /* already claimed */ | 
|  | 801 | return -2; | 
|  | 802 | } | 
|  | 803 | irq_used[i] = 1; | 
|  | 804 | return i; | 
|  | 805 | } | 
|  | 806 |  | 
|  | 807 | /* not found */ | 
|  | 808 | return -1; | 
|  | 809 | } | 
|  | 810 |  | 
|  | 811 | #define SPARE_SLOT_NUM 20 | 
|  | 812 |  | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 813 | static struct mpc_intsrc __initdata *m_spare[SPARE_SLOT_NUM]; | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 814 |  | 
| Rakib Mullick | 5759222 | 2009-04-11 09:04:59 +0600 | [diff] [blame] | 815 | static void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 816 | { | 
|  | 817 | int i; | 
|  | 818 |  | 
|  | 819 | apic_printk(APIC_VERBOSE, "OLD "); | 
|  | 820 | print_MP_intsrc_info(m); | 
|  | 821 |  | 
|  | 822 | i = get_MP_intsrc_index(m); | 
|  | 823 | if (i > 0) { | 
|  | 824 | assign_to_mpc_intsrc(&mp_irqs[i], m); | 
|  | 825 | apic_printk(APIC_VERBOSE, "NEW "); | 
|  | 826 | print_mp_irq_info(&mp_irqs[i]); | 
|  | 827 | return; | 
|  | 828 | } | 
|  | 829 | if (!i) { | 
|  | 830 | /* legacy, do nothing */ | 
|  | 831 | return; | 
|  | 832 | } | 
|  | 833 | if (*nr_m_spare < SPARE_SLOT_NUM) { | 
|  | 834 | /* | 
|  | 835 | * not found (-1), or duplicated (-2) are invalid entries, | 
|  | 836 | * we need to use the slot later | 
|  | 837 | */ | 
|  | 838 | m_spare[*nr_m_spare] = m; | 
|  | 839 | *nr_m_spare += 1; | 
|  | 840 | } | 
|  | 841 | } | 
|  | 842 | #else /* CONFIG_X86_IO_APIC */ | 
| Rakib Mullick | 5759222 | 2009-04-11 09:04:59 +0600 | [diff] [blame] | 843 | static | 
|  | 844 | inline void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) {} | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 845 | #endif /* CONFIG_X86_IO_APIC */ | 
|  | 846 |  | 
| Yinghai Lu | ee21455 | 2009-05-06 10:07:07 -0700 | [diff] [blame] | 847 | static int | 
|  | 848 | check_slot(unsigned long mpc_new_phys, unsigned long mpc_new_length, int count) | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 849 | { | 
| Yinghai Lu | ee21455 | 2009-05-06 10:07:07 -0700 | [diff] [blame] | 850 | int ret = 0; | 
|  | 851 |  | 
|  | 852 | if (!mpc_new_phys || count <= mpc_new_length) { | 
|  | 853 | WARN(1, "update_mptable: No spare slots (length: %x)\n", count); | 
|  | 854 | return -1; | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 855 | } | 
|  | 856 |  | 
| Yinghai Lu | ee21455 | 2009-05-06 10:07:07 -0700 | [diff] [blame] | 857 | return ret; | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 858 | } | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 859 |  | 
| Jaswinder Singh Rajput | f29521e | 2009-01-03 15:46:57 +0530 | [diff] [blame] | 860 | static int  __init replace_intsrc_all(struct mpc_table *mpc, | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 861 | unsigned long mpc_new_phys, | 
|  | 862 | unsigned long mpc_new_length) | 
|  | 863 | { | 
|  | 864 | #ifdef CONFIG_X86_IO_APIC | 
|  | 865 | int i; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 866 | #endif | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 867 | int count = sizeof(*mpc); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 868 | int nr_m_spare = 0; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 869 | unsigned char *mpt = ((unsigned char *)mpc) + count; | 
|  | 870 |  | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 871 | printk(KERN_INFO "mpc_length %x\n", mpc->length); | 
|  | 872 | while (count < mpc->length) { | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 873 | switch (*mpt) { | 
|  | 874 | case MP_PROCESSOR: | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 875 | skip_entry(&mpt, &count, sizeof(struct mpc_cpu)); | 
|  | 876 | break; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 877 | case MP_BUS: | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 878 | skip_entry(&mpt, &count, sizeof(struct mpc_bus)); | 
|  | 879 | break; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 880 | case MP_IOAPIC: | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 881 | skip_entry(&mpt, &count, sizeof(struct mpc_ioapic)); | 
|  | 882 | break; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 883 | case MP_INTSRC: | 
| Ingo Molnar | c58603e | 2009-03-19 08:50:35 +0100 | [diff] [blame] | 884 | check_irq_src((struct mpc_intsrc *)mpt, &nr_m_spare); | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 885 | skip_entry(&mpt, &count, sizeof(struct mpc_intsrc)); | 
|  | 886 | break; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 887 | case MP_LINTSRC: | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 888 | skip_entry(&mpt, &count, sizeof(struct mpc_lintsrc)); | 
|  | 889 | break; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 890 | default: | 
|  | 891 | /* wrong mptable */ | 
| Jaswinder Singh Rajput | 5a5737e | 2009-03-21 13:28:39 +0530 | [diff] [blame] | 892 | smp_dump_mptable(mpc, mpt); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 893 | goto out; | 
|  | 894 | } | 
|  | 895 | } | 
|  | 896 |  | 
|  | 897 | #ifdef CONFIG_X86_IO_APIC | 
|  | 898 | for (i = 0; i < mp_irq_entries; i++) { | 
|  | 899 | if (irq_used[i]) | 
|  | 900 | continue; | 
|  | 901 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 902 | if (mp_irqs[i].irqtype != mp_INT) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 903 | continue; | 
|  | 904 |  | 
| Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 905 | if (mp_irqs[i].irqflag != 0x0f) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 906 | continue; | 
|  | 907 |  | 
|  | 908 | if (nr_m_spare > 0) { | 
| Jan Beulich | 82034d6 | 2009-03-12 12:57:10 +0000 | [diff] [blame] | 909 | apic_printk(APIC_VERBOSE, "*NEW* found\n"); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 910 | nr_m_spare--; | 
|  | 911 | assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); | 
|  | 912 | m_spare[nr_m_spare] = NULL; | 
|  | 913 | } else { | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 914 | struct mpc_intsrc *m = (struct mpc_intsrc *)mpt; | 
|  | 915 | count += sizeof(struct mpc_intsrc); | 
| Yinghai Lu | ee21455 | 2009-05-06 10:07:07 -0700 | [diff] [blame] | 916 | if (check_slot(mpc_new_phys, mpc_new_length, count) < 0) | 
| Jaswinder Singh Rajput | a683027 | 2009-03-18 20:42:28 +0530 | [diff] [blame] | 917 | goto out; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 918 | assign_to_mpc_intsrc(&mp_irqs[i], m); | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 919 | mpc->length = count; | 
| Jaswinder Singh Rajput | 540d4e7 | 2009-01-03 15:50:52 +0530 | [diff] [blame] | 920 | mpt += sizeof(struct mpc_intsrc); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 921 | } | 
|  | 922 | print_mp_irq_info(&mp_irqs[i]); | 
|  | 923 | } | 
|  | 924 | #endif | 
|  | 925 | out: | 
|  | 926 | /* update checksum */ | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 927 | mpc->checksum = 0; | 
|  | 928 | mpc->checksum -= mpf_checksum((unsigned char *)mpc, mpc->length); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 929 |  | 
|  | 930 | return 0; | 
|  | 931 | } | 
|  | 932 |  | 
| Yinghai Lu | f1bdb52 | 2009-05-15 13:05:16 -0700 | [diff] [blame] | 933 | int enable_update_mptable; | 
| Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 934 |  | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 935 | static int __init update_mptable_setup(char *str) | 
|  | 936 | { | 
|  | 937 | enable_update_mptable = 1; | 
| Yinghai Lu | 629e15d | 2009-05-15 13:05:16 -0700 | [diff] [blame] | 938 | #ifdef CONFIG_PCI | 
|  | 939 | pci_routeirq = 1; | 
|  | 940 | #endif | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 941 | return 0; | 
|  | 942 | } | 
|  | 943 | early_param("update_mptable", update_mptable_setup); | 
|  | 944 |  | 
|  | 945 | static unsigned long __initdata mpc_new_phys; | 
|  | 946 | static unsigned long mpc_new_length __initdata = 4096; | 
|  | 947 |  | 
|  | 948 | /* alloc_mptable or alloc_mptable=4k */ | 
|  | 949 | static int __initdata alloc_mptable; | 
|  | 950 | static int __init parse_alloc_mptable_opt(char *p) | 
|  | 951 | { | 
|  | 952 | enable_update_mptable = 1; | 
| Yinghai Lu | 629e15d | 2009-05-15 13:05:16 -0700 | [diff] [blame] | 953 | #ifdef CONFIG_PCI | 
|  | 954 | pci_routeirq = 1; | 
|  | 955 | #endif | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 956 | alloc_mptable = 1; | 
|  | 957 | if (!p) | 
|  | 958 | return 0; | 
|  | 959 | mpc_new_length = memparse(p, &p); | 
|  | 960 | return 0; | 
|  | 961 | } | 
|  | 962 | early_param("alloc_mptable", parse_alloc_mptable_opt); | 
|  | 963 |  | 
|  | 964 | void __init early_reserve_e820_mpc_new(void) | 
|  | 965 | { | 
|  | 966 | if (enable_update_mptable && alloc_mptable) { | 
|  | 967 | u64 startt = 0; | 
|  | 968 | #ifdef CONFIG_X86_TRAMPOLINE | 
|  | 969 | startt = TRAMPOLINE_BASE; | 
|  | 970 | #endif | 
|  | 971 | mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4); | 
|  | 972 | } | 
|  | 973 | } | 
|  | 974 |  | 
|  | 975 | static int __init update_mp_table(void) | 
|  | 976 | { | 
|  | 977 | char str[16]; | 
|  | 978 | char oem[10]; | 
| Jaswinder Singh Rajput | 41401db | 2009-01-08 15:42:46 +0530 | [diff] [blame] | 979 | struct mpf_intel *mpf; | 
| Jaswinder Singh Rajput | f29521e | 2009-01-03 15:46:57 +0530 | [diff] [blame] | 980 | struct mpc_table *mpc, *mpc_new; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 981 |  | 
|  | 982 | if (!enable_update_mptable) | 
|  | 983 | return 0; | 
|  | 984 |  | 
|  | 985 | mpf = mpf_found; | 
|  | 986 | if (!mpf) | 
|  | 987 | return 0; | 
|  | 988 |  | 
|  | 989 | /* | 
|  | 990 | * Now see if we need to go further. | 
|  | 991 | */ | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 992 | if (mpf->feature1 != 0) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 993 | return 0; | 
|  | 994 |  | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 995 | if (!mpf->physptr) | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 996 | return 0; | 
|  | 997 |  | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 998 | mpc = phys_to_virt(mpf->physptr); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 999 |  | 
|  | 1000 | if (!smp_check_mpc(mpc, oem, str)) | 
|  | 1001 | return 0; | 
|  | 1002 |  | 
| Jaswinder Singh Rajput | ba1511b | 2009-02-11 23:38:25 +0530 | [diff] [blame] | 1003 | printk(KERN_INFO "mpf: %llx\n", (u64)virt_to_phys(mpf)); | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 1004 | printk(KERN_INFO "physptr: %x\n", mpf->physptr); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1005 |  | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 1006 | if (mpc_new_phys && mpc->length > mpc_new_length) { | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1007 | mpc_new_phys = 0; | 
|  | 1008 | printk(KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n", | 
|  | 1009 | mpc_new_length); | 
|  | 1010 | } | 
|  | 1011 |  | 
|  | 1012 | if (!mpc_new_phys) { | 
|  | 1013 | unsigned char old, new; | 
|  | 1014 | /* check if we can change the postion */ | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 1015 | mpc->checksum = 0; | 
|  | 1016 | old = mpf_checksum((unsigned char *)mpc, mpc->length); | 
|  | 1017 | mpc->checksum = 0xff; | 
|  | 1018 | new = mpf_checksum((unsigned char *)mpc, mpc->length); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1019 | if (old == new) { | 
|  | 1020 | printk(KERN_INFO "mpc is readonly, please try alloc_mptable instead\n"); | 
|  | 1021 | return 0; | 
|  | 1022 | } | 
|  | 1023 | printk(KERN_INFO "use in-positon replacing\n"); | 
|  | 1024 | } else { | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 1025 | mpf->physptr = mpc_new_phys; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1026 | mpc_new = phys_to_virt(mpc_new_phys); | 
| Jaswinder Singh Rajput | 6c65da5 | 2009-01-04 22:22:56 +0530 | [diff] [blame] | 1027 | memcpy(mpc_new, mpc, mpc->length); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1028 | mpc = mpc_new; | 
|  | 1029 | /* check if we can modify that */ | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 1030 | if (mpc_new_phys - mpf->physptr) { | 
| Jaswinder Singh Rajput | 41401db | 2009-01-08 15:42:46 +0530 | [diff] [blame] | 1031 | struct mpf_intel *mpf_new; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1032 | /* steal 16 bytes from [0, 1k) */ | 
|  | 1033 | printk(KERN_INFO "mpf new: %x\n", 0x400 - 16); | 
|  | 1034 | mpf_new = phys_to_virt(0x400 - 16); | 
|  | 1035 | memcpy(mpf_new, mpf, 16); | 
|  | 1036 | mpf = mpf_new; | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 1037 | mpf->physptr = mpc_new_phys; | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1038 | } | 
| Jaswinder Singh Rajput | 1eb1b3b | 2009-01-08 15:43:26 +0530 | [diff] [blame] | 1039 | mpf->checksum = 0; | 
|  | 1040 | mpf->checksum -= mpf_checksum((unsigned char *)mpf, 16); | 
|  | 1041 | printk(KERN_INFO "physptr new: %x\n", mpf->physptr); | 
| Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1042 | } | 
|  | 1043 |  | 
|  | 1044 | /* | 
|  | 1045 | * only replace the one with mp_INT and | 
|  | 1046 | *	 MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, | 
|  | 1047 | * already in mp_irqs , stored by ... and mp_config_acpi_gsi, | 
|  | 1048 | * may need pci=routeirq for all coverage | 
|  | 1049 | */ | 
|  | 1050 | replace_intsrc_all(mpc, mpc_new_phys, mpc_new_length); | 
|  | 1051 |  | 
|  | 1052 | return 0; | 
|  | 1053 | } | 
|  | 1054 |  | 
|  | 1055 | late_initcall(update_mp_table); |