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