blob: d67cd7600a21dbfc33a489f36ead24b8da1d45bb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04002 * Intel Multiprocessor Specification 1.1 and 1.4
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * compliant MP-table parsing routines.
4 *
5 * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
6 * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +04007 * (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
10#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/bootmem.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/kernel_stat.h>
15#include <linux/mc146818rtc.h>
16#include <linux/bitops.h>
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040017#include <linux/acpi.h>
18#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#include <asm/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/mtrr.h>
22#include <asm/mpspec.h>
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040023#include <asm/pgalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/io_apic.h>
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040025#include <asm/proto.h>
26#include <asm/acpi.h>
Alexey Starikovskiyce3fe6b2008-03-17 22:08:17 +030027#include <asm/bios_ebda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include <mach_apic.h>
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040030#ifdef CONFIG_X86_32
Andi Kleen874c4fe2006-09-26 10:52:26 +020031#include <mach_apicdef.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <mach_mpparse.h>
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040033#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Linus Torvalds1da177e2005-04-16 15:20:36 -070035/*
36 * Various Linux-internal data structures created from the
37 * MP-table.
38 */
Alexey Starikovskiyc0a282c2008-03-20 14:55:02 +030039#if defined (CONFIG_MCA) || defined (CONFIG_EISA)
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +040040int mp_bus_id_to_type[MAX_MP_BUSSES];
Alexey Starikovskiyc0a282c2008-03-20 14:55:02 +030041#endif
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040042
Alexey Starikovskiya6333c32008-03-20 14:54:09 +030043DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +040044int mp_bus_id_to_pci_bus[MAX_MP_BUSSES] = {[0 ... MAX_MP_BUSSES - 1] = -1 };
Alexey Starikovskiy85bddde2008-04-04 23:43:18 +040045
Linus Torvalds1da177e2005-04-16 15:20:36 -070046static int mp_current_pci_id;
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048/*
49 * Intel MP BIOS table parsing routines:
50 */
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052/*
53 * Checksum an MP configuration block.
54 */
55
56static int __init mpf_checksum(unsigned char *mp, int len)
57{
58 int sum = 0;
59
60 while (len--)
61 sum += *mp++;
62
63 return sum & 0xFF;
64}
65
Alexey Starikovskiy86420502008-03-17 22:08:55 +030066#ifdef CONFIG_X86_NUMAQ
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/*
68 * Have to match translation table entries to main table entries by counter
69 * hence the mpc_record variable .... can't see a less disgusting way of
70 * doing this ....
71 */
72
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +040073static int mpc_record;
74static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY]
75 __cpuinitdata;
Alexey Starikovskiy86420502008-03-17 22:08:55 +030076#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Alexey Starikovskiyc853c672008-03-27 23:54:13 +030078static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
79{
80 int apicid;
Alexey Starikovskiy746f2242008-04-04 23:42:15 +040081 char *bootup_cpu = "";
Alexey Starikovskiyc853c672008-03-27 23:54:13 +030082
Glauber Costa7b1292e2008-03-03 14:12:41 -030083 if (!(m->mpc_cpuflag & CPU_ENABLED)) {
84 disabled_cpus++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 return;
Glauber Costa7b1292e2008-03-03 14:12:41 -030086 }
Alexey Starikovskiy4655c7d2008-03-17 22:08:36 +030087#ifdef CONFIG_X86_NUMAQ
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 apicid = mpc_apic_id(m, translation_table[mpc_record]);
Alexey Starikovskiy4655c7d2008-03-17 22:08:36 +030089#else
Alexey Starikovskiy4655c7d2008-03-17 22:08:36 +030090 apicid = m->mpc_apicid;
91#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
Alexey Starikovskiy746f2242008-04-04 23:42:15 +040093 bootup_cpu = " (Bootup-CPU)";
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 boot_cpu_physical_apicid = m->mpc_apicid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 }
96
Alexey Starikovskiy746f2242008-04-04 23:42:15 +040097 printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);
Alexey Starikovskiyc853c672008-03-27 23:54:13 +030098 generic_processor_info(apicid, m->mpc_apicver);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400101static void __init MP_bus_info(struct mpc_config_bus *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
103 char str[7];
104
105 memcpy(str, m->mpc_bustype, 6);
106 str[6] = 0;
107
Alexey Starikovskiy0ec153a2008-03-17 22:08:48 +0300108#ifdef CONFIG_X86_NUMAQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 mpc_oem_bus_info(m, str, translation_table[mpc_record]);
Alexey Starikovskiy0ec153a2008-03-17 22:08:48 +0300110#else
Yinghai Lu11a62a02008-05-12 15:43:38 +0200111 printk(KERN_INFO "Bus #%d is %s\n", m->mpc_busid, str);
Alexey Starikovskiy0ec153a2008-03-17 22:08:48 +0300112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Andi Kleen5e4edbb2006-09-26 10:52:35 +0200114#if MAX_MP_BUSSES < 256
Randy Dunlapc0ec31a2006-04-10 22:53:13 -0700115 if (m->mpc_busid >= MAX_MP_BUSSES) {
116 printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400117 " is too large, max. supported is %d\n",
118 m->mpc_busid, str, MAX_MP_BUSSES - 1);
Randy Dunlapc0ec31a2006-04-10 22:53:13 -0700119 return;
120 }
Andi Kleen5e4edbb2006-09-26 10:52:35 +0200121#endif
Randy Dunlapc0ec31a2006-04-10 22:53:13 -0700122
Alexey Starikovskiyf8924e72008-04-04 23:42:21 +0400123 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) {
124 set_bit(m->mpc_busid, mp_bus_not_pci);
125#if defined(CONFIG_EISA) || defined (CONFIG_MCA)
126 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
127#endif
128 } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) {
Alexey Starikovskiyd285e332008-03-17 22:08:42 +0300129#ifdef CONFIG_X86_NUMAQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 mpc_oem_pci_bus(m, translation_table[mpc_record]);
Alexey Starikovskiyd285e332008-03-17 22:08:42 +0300131#endif
Alexey Starikovskiya6333c32008-03-20 14:54:09 +0300132 clear_bit(m->mpc_busid, mp_bus_not_pci);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
134 mp_current_pci_id++;
Alexey Starikovskiyc0a282c2008-03-20 14:55:02 +0300135#if defined(CONFIG_EISA) || defined (CONFIG_MCA)
136 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400137 } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) {
Alexey Starikovskiy9e0a2de2008-03-20 14:54:56 +0300138 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400139 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
Alexey Starikovskiyc0a282c2008-03-20 14:55:02 +0300141#endif
Alexey Starikovskiyf8924e72008-04-04 23:42:21 +0400142 } else
143 printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400146#ifdef CONFIG_X86_IO_APIC
147
Alexey Starikovskiy857033a2008-03-17 22:08:05 +0300148static int bad_ioapic(unsigned long address)
149{
150 if (nr_ioapics >= MAX_IO_APICS) {
151 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
152 "(found %d)\n", MAX_IO_APICS, nr_ioapics);
153 panic("Recompile kernel with bigger MAX_IO_APICS!\n");
154 }
155 if (!address) {
156 printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
157 " found in table, skipping!\n");
158 return 1;
159 }
160 return 0;
161}
162
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400163static void __init MP_ioapic_info(struct mpc_config_ioapic *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164{
165 if (!(m->mpc_flags & MPC_APIC_USABLE))
166 return;
167
Thomas Gleixner64883ab2008-01-30 13:30:35 +0100168 printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n",
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400169 m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr);
Alexey Starikovskiy857033a2008-03-17 22:08:05 +0300170
171 if (bad_ioapic(m->mpc_apicaddr))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 return;
Alexey Starikovskiy857033a2008-03-17 22:08:05 +0300173
Alexey Starikovskiyec2cd0a2008-05-14 19:03:10 +0400174 mp_ioapics[nr_ioapics].mp_apicaddr = m->mpc_apicaddr;
175 mp_ioapics[nr_ioapics].mp_apicid = m->mpc_apicid;
176 mp_ioapics[nr_ioapics].mp_type = m->mpc_type;
177 mp_ioapics[nr_ioapics].mp_apicver = m->mpc_apicver;
178 mp_ioapics[nr_ioapics].mp_flags = m->mpc_flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 nr_ioapics++;
180}
181
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400182static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183{
Yinghai Lu11a62a02008-05-12 15:43:38 +0200184 printk(KERN_INFO "Int: type %d, pol %d, trig %d, bus %02x,"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400186 m->mpc_irqtype, m->mpc_irqflag & 3,
187 (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
188 m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
Alexey Starikovskiy2fddb6e282008-05-14 19:03:17 +0400189 mp_irqs[mp_irq_entries].mp_dstapic = m->mpc_dstapic;
190 mp_irqs[mp_irq_entries].mp_type = m->mpc_type;
191 mp_irqs[mp_irq_entries].mp_irqtype = m->mpc_irqtype;
192 mp_irqs[mp_irq_entries].mp_irqflag = m->mpc_irqflag;
193 mp_irqs[mp_irq_entries].mp_srcbus = m->mpc_srcbus;
194 mp_irqs[mp_irq_entries].mp_srcbusirq = m->mpc_srcbusirq;
195 mp_irqs[mp_irq_entries].mp_dstirq = m->mpc_dstirq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 if (++mp_irq_entries == MAX_IRQ_SOURCES)
197 panic("Max # of irq sources exceeded!!\n");
198}
199
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400200#endif
201
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400202static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203{
Yinghai Lu11a62a02008-05-12 15:43:38 +0200204 printk(KERN_INFO "Lint: type %d, pol %d, trig %d, bus %02x,"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400206 m->mpc_irqtype, m->mpc_irqflag & 3,
207 (m->mpc_irqflag >> 2) & 3, m->mpc_srcbusid,
208 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209}
210
211#ifdef CONFIG_X86_NUMAQ
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400212static void __init MP_translation_info(struct mpc_config_translation *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213{
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400214 printk(KERN_INFO
215 "Translation: record %d, type %d, quad %d, global %d, local %d\n",
216 mpc_record, m->trans_type, m->trans_quad, m->trans_global,
217 m->trans_local);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400219 if (mpc_record >= MAX_MPC_ENTRY)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n");
221 else
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400222 translation_table[mpc_record] = m; /* stash this for later */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 if (m->trans_quad < MAX_NUMNODES && !node_online(m->trans_quad))
224 node_set_online(m->trans_quad);
225}
226
227/*
228 * Read/parse the MPC oem tables
229 */
230
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400231static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable,
232 unsigned short oemsize)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400234 int count = sizeof(*oemtable); /* the header size */
235 unsigned char *oemptr = ((unsigned char *)oemtable) + count;
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 mpc_record = 0;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400238 printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n",
239 oemtable);
240 if (memcmp(oemtable->oem_signature, MPC_OEM_SIGNATURE, 4)) {
241 printk(KERN_WARNING
242 "SMP mpc oemtable: bad signature [%c%c%c%c]!\n",
243 oemtable->oem_signature[0], oemtable->oem_signature[1],
244 oemtable->oem_signature[2], oemtable->oem_signature[3]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 return;
246 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400247 if (mpf_checksum((unsigned char *)oemtable, oemtable->oem_length)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 printk(KERN_WARNING "SMP oem mptable: checksum error!\n");
249 return;
250 }
251 while (count < oemtable->oem_length) {
252 switch (*oemptr) {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400253 case MP_TRANSLATION:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400255 struct mpc_config_translation *m =
256 (struct mpc_config_translation *)oemptr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 MP_translation_info(m);
258 oemptr += sizeof(*m);
259 count += sizeof(*m);
260 ++mpc_record;
261 break;
262 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400263 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400265 printk(KERN_WARNING
266 "Unrecognised OEM table entry type! - %d\n",
267 (int)*oemptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 return;
269 }
270 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400271 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272}
273
274static inline void mps_oem_check(struct mp_config_table *mpc, char *oem,
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400275 char *productid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276{
277 if (strncmp(oem, "IBM NUMA", 8))
278 printk("Warning! May not be a NUMA-Q system!\n");
279 if (mpc->mpc_oemptr)
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400280 smp_read_mpc_oem((struct mp_config_oemtable *)mpc->mpc_oemptr,
281 mpc->mpc_oemsize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282}
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400283#endif /* CONFIG_X86_NUMAQ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
285/*
286 * Read/parse the MPC
287 */
288
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400289static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290{
291 char str[16];
292 char oem[10];
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400293 int count = sizeof(*mpc);
294 unsigned char *mpt = ((unsigned char *)mpc) + count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400296 if (memcmp(mpc->mpc_signature, MPC_SIGNATURE, 4)) {
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400297 printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n",
298 mpc->mpc_signature[0], mpc->mpc_signature[1],
299 mpc->mpc_signature[2], mpc->mpc_signature[3]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 return 0;
301 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400302 if (mpf_checksum((unsigned char *)mpc, mpc->mpc_length)) {
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400303 printk(KERN_ERR "MPTABLE: checksum error!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 return 0;
305 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400306 if (mpc->mpc_spec != 0x01 && mpc->mpc_spec != 0x04) {
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400307 printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400308 mpc->mpc_spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 return 0;
310 }
311 if (!mpc->mpc_lapic) {
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400312 printk(KERN_ERR "MPTABLE: null local APIC address!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 return 0;
314 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400315 memcpy(oem, mpc->mpc_oem, 8);
316 oem[8] = 0;
Yinghai Lu11a62a02008-05-12 15:43:38 +0200317 printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400319 memcpy(str, mpc->mpc_productid, 12);
320 str[12] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400322#ifdef CONFIG_X86_32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 mps_oem_check(mpc, oem, str);
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400324#endif
Yinghai Lu11a62a02008-05-12 15:43:38 +0200325 printk(KERN_INFO "MPTABLE: Product ID: %s\n", str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400327 printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400329 /* save the local APIC address, it might be non-default */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 if (!acpi_lapic)
331 mp_lapic_addr = mpc->mpc_lapic;
332
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400333 if (early)
334 return 1;
335
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 /*
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400337 * Now process the configuration blocks.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 */
Alexey Starikovskiy86420502008-03-17 22:08:55 +0300339#ifdef CONFIG_X86_NUMAQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 mpc_record = 0;
Alexey Starikovskiy86420502008-03-17 22:08:55 +0300341#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 while (count < mpc->mpc_length) {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400343 switch (*mpt) {
344 case MP_PROCESSOR:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400346 struct mpc_config_processor *m =
347 (struct mpc_config_processor *)mpt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 /* ACPI may have already provided this data */
349 if (!acpi_lapic)
350 MP_processor_info(m);
351 mpt += sizeof(*m);
352 count += sizeof(*m);
353 break;
354 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400355 case MP_BUS:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400357 struct mpc_config_bus *m =
358 (struct mpc_config_bus *)mpt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 MP_bus_info(m);
360 mpt += sizeof(*m);
361 count += sizeof(*m);
362 break;
363 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400364 case MP_IOAPIC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 {
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400366#ifdef CONFIG_X86_IO_APIC
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400367 struct mpc_config_ioapic *m =
368 (struct mpc_config_ioapic *)mpt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 MP_ioapic_info(m);
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400370#endif
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400371 mpt += sizeof(struct mpc_config_ioapic);
372 count += sizeof(struct mpc_config_ioapic);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 break;
374 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400375 case MP_INTSRC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 {
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400377#ifdef CONFIG_X86_IO_APIC
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400378 struct mpc_config_intsrc *m =
379 (struct mpc_config_intsrc *)mpt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381 MP_intsrc_info(m);
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400382#endif
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400383 mpt += sizeof(struct mpc_config_intsrc);
384 count += sizeof(struct mpc_config_intsrc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 break;
386 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400387 case MP_LINTSRC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400389 struct mpc_config_lintsrc *m =
390 (struct mpc_config_lintsrc *)mpt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 MP_lintsrc_info(m);
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400392 mpt += sizeof(*m);
393 count += sizeof(*m);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 break;
395 }
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400396 default:
Yinghai Lu711554d2008-04-07 11:36:39 -0700397 /* wrong mptable */
398 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n");
399 printk(KERN_ERR "type %x\n", *mpt);
400 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16,
401 1, mpc, mpc->mpc_length, 1);
402 count = mpc->mpc_length;
403 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 }
Alexey Starikovskiy86420502008-03-17 22:08:55 +0300405#ifdef CONFIG_X86_NUMAQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 ++mpc_record;
Alexey Starikovskiy86420502008-03-17 22:08:55 +0300407#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 }
Ingo Molnar3c43f032007-05-02 19:27:04 +0200409 setup_apic_routing();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 if (!num_processors)
Alexey Starikovskiye950bea2008-04-04 23:42:27 +0400411 printk(KERN_ERR "MPTABLE: no processors registered!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 return num_processors;
413}
414
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400415#ifdef CONFIG_X86_IO_APIC
416
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417static int __init ELCR_trigger(unsigned int irq)
418{
419 unsigned int port;
420
421 port = 0x4d0 + (irq >> 3);
422 return (inb(port) >> (irq & 7)) & 1;
423}
424
425static void __init construct_default_ioirq_mptable(int mpc_default_type)
426{
427 struct mpc_config_intsrc intsrc;
428 int i;
429 int ELCR_fallback = 0;
430
431 intsrc.mpc_type = MP_INTSRC;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400432 intsrc.mpc_irqflag = 0; /* conforming */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 intsrc.mpc_srcbus = 0;
Alexey Starikovskiyec2cd0a2008-05-14 19:03:10 +0400434 intsrc.mpc_dstapic = mp_ioapics[0].mp_apicid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
436 intsrc.mpc_irqtype = mp_INT;
437
438 /*
439 * If true, we have an ISA/PCI system with no IRQ entries
440 * in the MP table. To prevent the PCI interrupts from being set up
441 * incorrectly, we try to use the ELCR. The sanity check to see if
442 * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
443 * never be level sensitive, so we simply see if the ELCR agrees.
444 * If it does, we assume it's valid.
445 */
446 if (mpc_default_type == 5) {
Alexey Starikovskiy62441bf2008-04-04 23:42:34 +0400447 printk(KERN_INFO "ISA/PCI bus type with no IRQ information... "
448 "falling back to ELCR\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
Alexey Starikovskiy62441bf2008-04-04 23:42:34 +0400450 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) ||
451 ELCR_trigger(13))
452 printk(KERN_ERR "ELCR contains invalid data... "
453 "not using ELCR\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 else {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400455 printk(KERN_INFO
456 "Using ELCR to identify PCI interrupts\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 ELCR_fallback = 1;
458 }
459 }
460
461 for (i = 0; i < 16; i++) {
462 switch (mpc_default_type) {
463 case 2:
464 if (i == 0 || i == 13)
465 continue; /* IRQ0 & IRQ13 not connected */
466 /* fall through */
467 default:
468 if (i == 2)
469 continue; /* IRQ2 is never connected */
470 }
471
472 if (ELCR_fallback) {
473 /*
474 * If the ELCR indicates a level-sensitive interrupt, we
475 * copy that information over to the MP table in the
476 * irqflag field (level sensitive, active high polarity).
477 */
478 if (ELCR_trigger(i))
479 intsrc.mpc_irqflag = 13;
480 else
481 intsrc.mpc_irqflag = 0;
482 }
483
484 intsrc.mpc_srcbusirq = i;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400485 intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 MP_intsrc_info(&intsrc);
487 }
488
489 intsrc.mpc_irqtype = mp_ExtINT;
490 intsrc.mpc_srcbusirq = 0;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400491 intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 MP_intsrc_info(&intsrc);
493}
494
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400495#endif
496
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497static inline void __init construct_default_ISA_mptable(int mpc_default_type)
498{
499 struct mpc_config_processor processor;
500 struct mpc_config_bus bus;
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400501#ifdef CONFIG_X86_IO_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 struct mpc_config_ioapic ioapic;
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400503#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 struct mpc_config_lintsrc lintsrc;
505 int linttypes[2] = { mp_ExtINT, mp_NMI };
506 int i;
507
508 /*
509 * local APIC has default address
510 */
511 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
512
513 /*
514 * 2 CPUs, numbered 0 & 1.
515 */
516 processor.mpc_type = MP_PROCESSOR;
517 /* Either an integrated APIC or a discrete 82489DX. */
518 processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
519 processor.mpc_cpuflag = CPU_ENABLED;
520 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400521 (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
523 processor.mpc_reserved[0] = 0;
524 processor.mpc_reserved[1] = 0;
525 for (i = 0; i < 2; i++) {
526 processor.mpc_apicid = i;
527 MP_processor_info(&processor);
528 }
529
530 bus.mpc_type = MP_BUS;
531 bus.mpc_busid = 0;
532 switch (mpc_default_type) {
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400533 default:
Alexey Starikovskiy62441bf2008-04-04 23:42:34 +0400534 printk(KERN_ERR "???\nUnknown standard configuration %d\n",
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400535 mpc_default_type);
536 /* fall through */
537 case 1:
538 case 5:
539 memcpy(bus.mpc_bustype, "ISA ", 6);
540 break;
541 case 2:
542 case 6:
543 case 3:
544 memcpy(bus.mpc_bustype, "EISA ", 6);
545 break;
546 case 4:
547 case 7:
548 memcpy(bus.mpc_bustype, "MCA ", 6);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 }
550 MP_bus_info(&bus);
551 if (mpc_default_type > 4) {
552 bus.mpc_busid = 1;
553 memcpy(bus.mpc_bustype, "PCI ", 6);
554 MP_bus_info(&bus);
555 }
556
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400557#ifdef CONFIG_X86_IO_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 ioapic.mpc_type = MP_IOAPIC;
559 ioapic.mpc_apicid = 2;
560 ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
561 ioapic.mpc_flags = MPC_APIC_USABLE;
562 ioapic.mpc_apicaddr = 0xFEC00000;
563 MP_ioapic_info(&ioapic);
564
565 /*
566 * We set up most of the low 16 IO-APIC pins according to MPS rules.
567 */
568 construct_default_ioirq_mptable(mpc_default_type);
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400569#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 lintsrc.mpc_type = MP_LINTSRC;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400571 lintsrc.mpc_irqflag = 0; /* conforming */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 lintsrc.mpc_srcbusid = 0;
573 lintsrc.mpc_srcbusirq = 0;
574 lintsrc.mpc_destapic = MP_APIC_ALL;
575 for (i = 0; i < 2; i++) {
576 lintsrc.mpc_irqtype = linttypes[i];
577 lintsrc.mpc_destapiclint = i;
578 MP_lintsrc_info(&lintsrc);
579 }
580}
581
582static struct intel_mp_floating *mpf_found;
583
584/*
585 * Scan the memory blocks for an SMP configuration block.
586 */
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400587static void __init __get_smp_config(unsigned early)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588{
589 struct intel_mp_floating *mpf = mpf_found;
590
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400591 if (acpi_lapic && early)
592 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 /*
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400594 * ACPI supports both logical (e.g. Hyper-Threading) and physical
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 * processors, where MPS only supports physical.
596 */
597 if (acpi_lapic && acpi_ioapic) {
Alexey Starikovskiy4421b1c2008-04-04 23:42:40 +0400598 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
599 "information\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 return;
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400601 } else if (acpi_lapic)
Alexey Starikovskiy4421b1c2008-04-04 23:42:40 +0400602 printk(KERN_INFO "Using ACPI for processor (LAPIC) "
603 "configuration information\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400605 printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n",
606 mpf->mpf_specification);
Alexey Starikovskiyb3e24162008-05-23 01:54:44 +0400607#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400608 if (mpf->mpf_feature2 & (1 << 7)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 printk(KERN_INFO " IMCR and PIC compatibility mode.\n");
610 pic_mode = 1;
611 } else {
612 printk(KERN_INFO " Virtual Wire compatibility mode.\n");
613 pic_mode = 0;
614 }
Alexey Starikovskiy4421b1c2008-04-04 23:42:40 +0400615#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 /*
617 * Now see if we need to read further.
618 */
619 if (mpf->mpf_feature1 != 0) {
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400620 if (early) {
621 /*
622 * local APIC has default address
623 */
624 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
625 return;
626 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400628 printk(KERN_INFO "Default MP configuration #%d\n",
629 mpf->mpf_feature1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 construct_default_ISA_mptable(mpf->mpf_feature1);
631
632 } else if (mpf->mpf_physptr) {
633
634 /*
635 * Read the physical hardware table. Anything here will
636 * override the defaults.
637 */
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400638 if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr), early)) {
Alexey Starikovskiybab4b272008-05-19 19:47:03 +0400639#ifdef CONFIG_X86_LOCAL_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 smp_found_config = 0;
Alexey Starikovskiybab4b272008-05-19 19:47:03 +0400641#endif
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400642 printk(KERN_ERR
643 "BIOS bug, MP table errors detected!...\n");
Alexey Starikovskiy4421b1c2008-04-04 23:42:40 +0400644 printk(KERN_ERR "... disabling SMP support. "
645 "(tell your hw vendor)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 return;
647 }
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400648
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400649 if (early)
650 return;
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400651#ifdef CONFIG_X86_IO_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 /*
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) {
658 struct mpc_config_bus bus;
659
Alexey Starikovskiy4421b1c2008-04-04 23:42:40 +0400660 printk(KERN_ERR "BIOS bug, no explicit IRQ entries, "
661 "using default mptable. "
662 "(tell your hw vendor)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
664 bus.mpc_type = MP_BUS;
665 bus.mpc_busid = 0;
666 memcpy(bus.mpc_bustype, "ISA ", 6);
667 MP_bus_info(&bus);
668
669 construct_default_ioirq_mptable(0);
670 }
Alexey Starikovskiy61048c62008-04-04 23:41:07 +0400671#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 } else
673 BUG();
674
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400675 if (!early)
676 printk(KERN_INFO "Processors: %d\n", num_processors);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 /*
678 * Only use the first configuration found.
679 */
680}
681
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400682void __init early_get_smp_config(void)
683{
684 __get_smp_config(1);
685}
686
687void __init get_smp_config(void)
688{
689 __get_smp_config(0);
690}
691
692static int __init smp_scan_config(unsigned long base, unsigned long length,
693 unsigned reserve)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694{
Alexey Starikovskiy92fd4b72008-04-04 23:42:46 +0400695 unsigned int *bp = phys_to_virt(base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 struct intel_mp_floating *mpf;
697
Yinghai Lu11a62a02008-05-12 15:43:38 +0200698 printk(KERN_DEBUG "Scan SMP from %p for %ld bytes.\n", bp, length);
Akinobu Mita5d47a272008-04-19 23:55:11 +0900699 BUILD_BUG_ON(sizeof(*mpf) != 16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700
701 while (length > 0) {
702 mpf = (struct intel_mp_floating *)bp;
703 if ((*bp == SMP_MAGIC_IDENT) &&
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400704 (mpf->mpf_length == 1) &&
705 !mpf_checksum((unsigned char *)bp, 16) &&
706 ((mpf->mpf_specification == 1)
707 || (mpf->mpf_specification == 4))) {
Alexey Starikovskiybab4b272008-05-19 19:47:03 +0400708#ifdef CONFIG_X86_LOCAL_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 smp_found_config = 1;
Alexey Starikovskiybab4b272008-05-19 19:47:03 +0400710#endif
Alexey Starikovskiy92fd4b72008-04-04 23:42:46 +0400711 mpf_found = mpf;
712#ifdef CONFIG_X86_32
Ingo Molnare91a3b42008-01-30 13:33:08 +0100713 printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n",
Alexey Starikovskiy4ef81292008-04-04 23:42:03 +0400714 mpf, virt_to_phys(mpf));
Bernhard Walle72a7fe32008-02-07 00:15:17 -0800715 reserve_bootmem(virt_to_phys(mpf), PAGE_SIZE,
716 BOOTMEM_DEFAULT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 if (mpf->mpf_physptr) {
718 /*
719 * We cannot access to MPC table to compute
720 * table size yet, as only few megabytes from
721 * the bottom is mapped now.
722 * PC-9800's MPC table places on the very last
723 * of physical memory; so that simply reserving
724 * PAGE_SIZE from mpg->mpf_physptr yields BUG()
725 * in reserve_bootmem.
726 */
727 unsigned long size = PAGE_SIZE;
728 unsigned long end = max_low_pfn * PAGE_SIZE;
729 if (mpf->mpf_physptr + size > end)
730 size = end - mpf->mpf_physptr;
Bernhard Walle72a7fe32008-02-07 00:15:17 -0800731 reserve_bootmem(mpf->mpf_physptr, size,
732 BOOTMEM_DEFAULT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 }
734
Alexey Starikovskiy92fd4b72008-04-04 23:42:46 +0400735#else
736 if (!reserve)
737 return 1;
738
739 reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE);
740 if (mpf->mpf_physptr)
741 reserve_bootmem_generic(mpf->mpf_physptr,
742 PAGE_SIZE);
743#endif
744 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 }
746 bp += 4;
747 length -= 16;
748 }
749 return 0;
750}
751
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400752static void __init __find_smp_config(unsigned reserve)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753{
754 unsigned int address;
755
756 /*
757 * FIXME: Linux assumes you have 640K of base ram..
758 * this continues the error...
759 *
760 * 1) Scan the bottom 1K for a signature
761 * 2) Scan the top 1K of base RAM
762 * 3) Scan the 64K of bios
763 */
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400764 if (smp_scan_config(0x0, 0x400, reserve) ||
765 smp_scan_config(639 * 0x400, 0x400, reserve) ||
766 smp_scan_config(0xF0000, 0x10000, reserve))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 return;
768 /*
769 * If it is an SMP machine we should know now, unless the
770 * configuration is in an EISA/MCA bus machine with an
771 * extended bios data area.
772 *
773 * there is a real-mode segmented pointer pointing to the
774 * 4K EBDA area at 0x40E, calculate and scan it here.
775 *
776 * NOTE! There are Linux loaders that will corrupt the EBDA
777 * area, and as such this kind of SMP config may be less
778 * trustworthy, simply because the SMP table may have been
779 * stomped on during early boot. These loaders are buggy and
780 * should be fixed.
781 *
782 * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
783 */
784
785 address = get_bios_ebda();
786 if (address)
Alexey Starikovskiy888032c2008-04-04 23:42:09 +0400787 smp_scan_config(address, 0x400, reserve);
788}
789
790void __init early_find_smp_config(void)
791{
792 __find_smp_config(0);
793}
794
795void __init find_smp_config(void)
796{
797 __find_smp_config(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798}