mpparse.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:22k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Intel Multiprocessor Specificiation 1.1 and 1.4
  3.  * 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>
  7.  *
  8.  * Fixes
  9.  * Erich Boleyn : MP v1.4 and additional changes.
  10.  * Alan Cox : Added EBDA scanning
  11.  * Ingo Molnar : various cleanups and rewrites
  12.  * Maciej W. Rozycki : Bits for default MP configurations
  13.  */
  14. #include <linux/mm.h>
  15. #include <linux/irq.h>
  16. #include <linux/init.h>
  17. #include <linux/delay.h>
  18. #include <linux/config.h>
  19. #include <linux/bootmem.h>
  20. #include <linux/smp_lock.h>
  21. #include <linux/kernel_stat.h>
  22. #include <linux/mc146818rtc.h>
  23. #include <asm/smp.h>
  24. #include <asm/mtrr.h>
  25. #include <asm/mpspec.h>
  26. #include <asm/pgalloc.h>
  27. #include <asm/smpboot.h>
  28. /* Have we found an MP table */
  29. int smp_found_config;
  30. /*
  31.  * Various Linux-internal data structures created from the
  32.  * MP-table.
  33.  */
  34. int apic_version [MAX_APICS];
  35. int mp_bus_id_to_type [MAX_MP_BUSSES];
  36. int mp_bus_id_to_node [MAX_MP_BUSSES];
  37. int mp_bus_id_to_local [MAX_MP_BUSSES];
  38. int quad_local_to_mp_bus_id [NR_CPUS/4][4];
  39. int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
  40. int mp_current_pci_id;
  41. /* I/O APIC entries */
  42. struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
  43. /* # of MP IRQ source entries */
  44. struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
  45. /* MP IRQ source entries */
  46. int mp_irq_entries;
  47. int nr_ioapics;
  48. int pic_mode;
  49. unsigned long mp_lapic_addr;
  50. /* Processor that is doing the boot up */
  51. unsigned int boot_cpu_physical_apicid = -1U;
  52. unsigned int boot_cpu_logical_apicid = -1U;
  53. /* Internal processor count */
  54. static unsigned int num_processors;
  55. /* Bitmask of physically existing CPUs */
  56. unsigned long phys_cpu_present_map;
  57. unsigned char esr_disable = 0;
  58. /*
  59.  * Intel MP BIOS table parsing routines:
  60.  */
  61. #ifndef CONFIG_X86_VISWS_APIC
  62. /*
  63.  * Checksum an MP configuration block.
  64.  */
  65. static int __init mpf_checksum(unsigned char *mp, int len)
  66. {
  67. int sum = 0;
  68. while (len--)
  69. sum += *mp++;
  70. return sum & 0xFF;
  71. }
  72. /*
  73.  * Processor encoding in an MP configuration block
  74.  */
  75. static char __init *mpc_family(int family,int model)
  76. {
  77. static char n[32];
  78. static char *model_defs[]=
  79. {
  80. "80486DX","80486DX",
  81. "80486SX","80486DX/2 or 80487",
  82. "80486SL","80486SX/2",
  83. "Unknown","80486DX/2-WB",
  84. "80486DX/4","80486DX/4-WB"
  85. };
  86. switch (family) {
  87. case 0x04:
  88. if (model < 10)
  89. return model_defs[model];
  90. break;
  91. case 0x05:
  92. return("Pentium(tm)");
  93. case 0x06:
  94. return("Pentium(tm) Pro");
  95. case 0x0F:
  96. if (model == 0x00)
  97. return("Pentium 4(tm)");
  98. if (model == 0x02)
  99. return("Pentium 4(tm) XEON(tm)");
  100. if (model == 0x0F)
  101. return("Special controller");
  102. }
  103. sprintf(n,"Unknown CPU [%d:%d]",family, model);
  104. return n;
  105. }
  106. #ifdef CONFIG_X86_IO_APIC
  107. extern int have_acpi_tables; /* set by acpitable.c */
  108. #else
  109. #define have_acpi_tables (0)
  110. #endif
  111. /* 
  112.  * Have to match translation table entries to main table entries by counter
  113.  * hence the mpc_record variable .... can't see a less disgusting way of
  114.  * doing this ....
  115.  */
  116. static int mpc_record; 
  117. static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdata;
  118. void __init MP_processor_info (struct mpc_config_processor *m)
  119. {
  120.   int ver, quad, logical_apicid;
  121.  
  122. if (!(m->mpc_cpuflag & CPU_ENABLED))
  123. return;
  124. logical_apicid = m->mpc_apicid;
  125. if (clustered_apic_mode == CLUSTERED_APIC_NUMAQ) {
  126. quad = translation_table[mpc_record]->trans_quad;
  127. logical_apicid = (quad << 4) + 
  128. (m->mpc_apicid ? m->mpc_apicid << 1 : 1);
  129. printk("Processor #%d %s APIC version %d (quad %d, apic %d)n",
  130. m->mpc_apicid,
  131. mpc_family((m->mpc_cpufeature & CPU_FAMILY_MASK)>>8 ,
  132.    (m->mpc_cpufeature & CPU_MODEL_MASK)>>4),
  133. m->mpc_apicver, quad, logical_apicid);
  134. } else {
  135. printk("Processor #%d %s APIC version %dn",
  136. m->mpc_apicid,
  137. mpc_family((m->mpc_cpufeature & CPU_FAMILY_MASK)>>8 ,
  138.    (m->mpc_cpufeature & CPU_MODEL_MASK)>>4),
  139. m->mpc_apicver);
  140. }
  141. if (m->mpc_featureflag&(1<<0))
  142. Dprintk("    Floating point unit present.n");
  143. if (m->mpc_featureflag&(1<<7))
  144. Dprintk("    Machine Exception supported.n");
  145. if (m->mpc_featureflag&(1<<8))
  146. Dprintk("    64 bit compare & exchange supported.n");
  147. if (m->mpc_featureflag&(1<<9))
  148. Dprintk("    Internal APIC present.n");
  149. if (m->mpc_featureflag&(1<<11))
  150. Dprintk("    SEP present.n");
  151. if (m->mpc_featureflag&(1<<12))
  152. Dprintk("    MTRR  present.n");
  153. if (m->mpc_featureflag&(1<<13))
  154. Dprintk("    PGE  present.n");
  155. if (m->mpc_featureflag&(1<<14))
  156. Dprintk("    MCA  present.n");
  157. if (m->mpc_featureflag&(1<<15))
  158. Dprintk("    CMOV  present.n");
  159. if (m->mpc_featureflag&(1<<16))
  160. Dprintk("    PAT  present.n");
  161. if (m->mpc_featureflag&(1<<17))
  162. Dprintk("    PSE  present.n");
  163. if (m->mpc_featureflag&(1<<18))
  164. Dprintk("    PSN  present.n");
  165. if (m->mpc_featureflag&(1<<19))
  166. Dprintk("    Cache Line Flush Instruction present.n");
  167. /* 20 Reserved */
  168. if (m->mpc_featureflag&(1<<21))
  169. Dprintk("    Debug Trace and EMON Store present.n");
  170. if (m->mpc_featureflag&(1<<22))
  171. Dprintk("    ACPI Thermal Throttle Registers  present.n");
  172. if (m->mpc_featureflag&(1<<23))
  173. Dprintk("    MMX  present.n");
  174. if (m->mpc_featureflag&(1<<24))
  175. Dprintk("    FXSR  present.n");
  176. if (m->mpc_featureflag&(1<<25))
  177. Dprintk("    XMM  present.n");
  178. if (m->mpc_featureflag&(1<<26))
  179. Dprintk("    Willamette New Instructions  present.n");
  180. if (m->mpc_featureflag&(1<<27))
  181. Dprintk("    Self Snoop  present.n");
  182. if (m->mpc_featureflag&(1<<28))
  183. Dprintk("    HT  present.n");
  184. if (m->mpc_featureflag&(1<<29))
  185. Dprintk("    Thermal Monitor present.n");
  186. /* 30, 31 Reserved */
  187. if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
  188. Dprintk("    Bootup CPUn");
  189. boot_cpu_physical_apicid = m->mpc_apicid;
  190. boot_cpu_logical_apicid = logical_apicid;
  191. }
  192. num_processors++;
  193. if (m->mpc_apicid > MAX_APICS) {
  194. printk("Processor #%d INVALID. (Max ID: %d).n",
  195. m->mpc_apicid, MAX_APICS);
  196. --num_processors;
  197. return;
  198. }
  199. ver = m->mpc_apicver;
  200. if (clustered_apic_mode == CLUSTERED_APIC_NUMAQ) {
  201. phys_cpu_present_map |= (logical_apicid&0xf) << (4*quad);
  202. } else {
  203. phys_cpu_present_map |= 1 << m->mpc_apicid;
  204. }
  205. /*
  206.  * Validate version
  207.  */
  208. if (ver == 0x0) {
  209. printk("BIOS bug, APIC version is 0 for CPU#%d! fixing up to 0x10. (tell your hw vendor)n", m->mpc_apicid);
  210. ver = 0x10;
  211. }
  212. apic_version[m->mpc_apicid] = ver;
  213. }
  214. static void __init MP_bus_info (struct mpc_config_bus *m)
  215. {
  216. char str[7];
  217. int quad;
  218. memcpy(str, m->mpc_bustype, 6);
  219. str[6] = 0;
  220. if (clustered_apic_mode == CLUSTERED_APIC_NUMAQ) {
  221. quad = translation_table[mpc_record]->trans_quad;
  222. mp_bus_id_to_node[m->mpc_busid] = quad;
  223. mp_bus_id_to_local[m->mpc_busid] = translation_table[mpc_record]->trans_local;
  224. quad_local_to_mp_bus_id[quad][translation_table[mpc_record]->trans_local] = m->mpc_busid;
  225. printk("Bus #%d is %s (node %d)n", m->mpc_busid, str, quad);
  226. } else {
  227. Dprintk("Bus #%d is %sn", m->mpc_busid, str);
  228. }
  229. if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
  230. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
  231. } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA)-1) == 0) {
  232. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA;
  233. } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI)-1) == 0) {
  234. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI;
  235. mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
  236. mp_current_pci_id++;
  237. } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
  238. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
  239. } else {
  240. printk("Unknown bustype %s - ignoringn", str);
  241. }
  242. }
  243. static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
  244. {
  245. if (!(m->mpc_flags & MPC_APIC_USABLE))
  246. return;
  247. printk("I/O APIC #%d Version %d at 0x%lX.n",
  248. m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr);
  249. if (nr_ioapics >= MAX_IO_APICS) {
  250. printk("Max # of I/O APICs (%d) exceeded (found %d).n",
  251. MAX_IO_APICS, nr_ioapics);
  252. panic("Recompile kernel with bigger MAX_IO_APICS!.n");
  253. }
  254. if (!m->mpc_apicaddr) {
  255. printk(KERN_ERR "WARNING: bogus zero I/O APIC address"
  256. " found in MP table, skipping!n");
  257. return;
  258. }
  259. mp_ioapics[nr_ioapics] = *m;
  260. nr_ioapics++;
  261. }
  262. static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
  263. {
  264. mp_irqs [mp_irq_entries] = *m;
  265. Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
  266. " IRQ %02x, APIC ID %x, APIC INT %02xn",
  267. m->mpc_irqtype, m->mpc_irqflag & 3,
  268. (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
  269. m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
  270. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  271. panic("Max # of irq sources exceeded!!n");
  272. }
  273. static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
  274. {
  275. Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
  276. " IRQ %02x, APIC ID %x, APIC LINT %02xn",
  277. m->mpc_irqtype, m->mpc_irqflag & 3,
  278. (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
  279. m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
  280. /*
  281.  * Well it seems all SMP boards in existence
  282.  * use ExtINT/LVT1 == LINT0 and
  283.  * NMI/LVT2 == LINT1 - the following check
  284.  * will show us if this assumptions is false.
  285.  * Until then we do not have to add baggage.
  286.  */
  287. if ((m->mpc_irqtype == mp_ExtINT) &&
  288. (m->mpc_destapiclint != 0))
  289. BUG();
  290. if ((m->mpc_irqtype == mp_NMI) &&
  291. (m->mpc_destapiclint != 1))
  292. BUG();
  293. }
  294. static void __init MP_translation_info (struct mpc_config_translation *m)
  295. {
  296. printk("Translation: record %d, type %d, quad %d, global %d, local %dn", mpc_record, m->trans_type, m->trans_quad, m->trans_global, m->trans_local);
  297. if (mpc_record >= MAX_MPC_ENTRY) 
  298. printk("MAX_MPC_ENTRY exceeded!n");
  299. else
  300. translation_table[mpc_record] = m; /* stash this for later */
  301. if (m->trans_quad+1 > numnodes)
  302. numnodes = m->trans_quad+1;
  303. }
  304. /*
  305.  * Read/parse the MPC oem tables
  306.  */
  307. static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, 
  308. unsigned short oemsize)
  309. {
  310. int count = sizeof (*oemtable); /* the header size */
  311. unsigned char *oemptr = ((unsigned char *)oemtable)+count;
  312. printk("Found an OEM MPC table at %8p - parsing it ... n", oemtable);
  313. if (memcmp(oemtable->oem_signature,MPC_OEM_SIGNATURE,4))
  314. {
  315. printk("SMP mpc oemtable: bad signature [%c%c%c%c]!n",
  316. oemtable->oem_signature[0],
  317. oemtable->oem_signature[1],
  318. oemtable->oem_signature[2],
  319. oemtable->oem_signature[3]);
  320. return;
  321. }
  322. if (mpf_checksum((unsigned char *)oemtable,oemtable->oem_length))
  323. {
  324. printk("SMP oem mptable: checksum error!n");
  325. return;
  326. }
  327. while (count < oemtable->oem_length) {
  328. switch (*oemptr) {
  329. case MP_TRANSLATION:
  330. {
  331. struct mpc_config_translation *m=
  332. (struct mpc_config_translation *)oemptr;
  333. MP_translation_info(m);
  334. oemptr += sizeof(*m);
  335. count += sizeof(*m);
  336. ++mpc_record;
  337. break;
  338. }
  339. default:
  340. {
  341. printk("Unrecognised OEM table entry type! - %dn", (int) *oemptr);
  342. return;
  343. }
  344. }
  345.        }
  346. }
  347. /*
  348.  * Read/parse the MPC
  349.  */
  350. static int __init smp_read_mpc(struct mp_config_table *mpc)
  351. {
  352. char str[16];
  353. int count=sizeof(*mpc);
  354. unsigned char *mpt=((unsigned char *)mpc)+count;
  355. if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
  356. panic("SMP mptable: bad signature [%c%c%c%c]!n",
  357. mpc->mpc_signature[0],
  358. mpc->mpc_signature[1],
  359. mpc->mpc_signature[2],
  360. mpc->mpc_signature[3]);
  361. return 0;
  362. }
  363. if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
  364. panic("SMP mptable: checksum error!n");
  365. return 0;
  366. }
  367. if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
  368. printk(KERN_ERR "SMP mptable: bad table version (%d)!!n",
  369. mpc->mpc_spec);
  370. return 0;
  371. }
  372. if (!mpc->mpc_lapic) {
  373. printk(KERN_ERR "SMP mptable: null local APIC address!n");
  374. return 0;
  375. }
  376. memcpy(str,mpc->mpc_oem,8);
  377. str[8]=0;
  378. printk("OEM ID: %s ",str);
  379. memcpy(str,mpc->mpc_productid,12);
  380. str[12]=0;
  381. printk("Product ID: %s ",str);
  382. printk("APIC at: 0x%lXn",mpc->mpc_lapic);
  383. /* save the local APIC address, it might be non-default,
  384.  * but only if we're not using the ACPI tables
  385.  */
  386. if (!have_acpi_tables)
  387. mp_lapic_addr = mpc->mpc_lapic;
  388. if ((clustered_apic_mode == CLUSTERED_APIC_NUMAQ) && mpc->mpc_oemptr) {
  389. /* We need to process the oem mpc tables to tell us which quad things are in ... */
  390. mpc_record = 0;
  391. smp_read_mpc_oem((struct mp_config_oemtable *) mpc->mpc_oemptr, mpc->mpc_oemsize);
  392. mpc_record = 0;
  393. }
  394. /*
  395.  * Now process the configuration blocks.
  396.  */
  397. while (count < mpc->mpc_length) {
  398. switch(*mpt) {
  399. case MP_PROCESSOR:
  400. {
  401. struct mpc_config_processor *m=
  402. (struct mpc_config_processor *)mpt;
  403. /* ACPI may already have provided this one for us */
  404. if (!have_acpi_tables)
  405. MP_processor_info(m);
  406. mpt += sizeof(*m);
  407. count += sizeof(*m);
  408. break;
  409. }
  410. case MP_BUS:
  411. {
  412. struct mpc_config_bus *m=
  413. (struct mpc_config_bus *)mpt;
  414. MP_bus_info(m);
  415. mpt += sizeof(*m);
  416. count += sizeof(*m);
  417. break;
  418. }
  419. case MP_IOAPIC:
  420. {
  421. struct mpc_config_ioapic *m=
  422. (struct mpc_config_ioapic *)mpt;
  423. MP_ioapic_info(m);
  424. mpt+=sizeof(*m);
  425. count+=sizeof(*m);
  426. break;
  427. }
  428. case MP_INTSRC:
  429. {
  430. struct mpc_config_intsrc *m=
  431. (struct mpc_config_intsrc *)mpt;
  432. MP_intsrc_info(m);
  433. mpt+=sizeof(*m);
  434. count+=sizeof(*m);
  435. break;
  436. }
  437. case MP_LINTSRC:
  438. {
  439. struct mpc_config_lintsrc *m=
  440. (struct mpc_config_lintsrc *)mpt;
  441. MP_lintsrc_info(m);
  442. mpt+=sizeof(*m);
  443. count+=sizeof(*m);
  444. break;
  445. }
  446. default:
  447. {
  448. count = mpc->mpc_length;
  449. break;
  450. }
  451. }
  452. ++mpc_record;
  453. }
  454. if (clustered_apic_mode){
  455. esr_disable = 1;
  456. }
  457. if (!num_processors)
  458. printk(KERN_ERR "SMP mptable: no processors registered!n");
  459. return num_processors;
  460. }
  461. static int __init ELCR_trigger(unsigned int irq)
  462. {
  463. unsigned int port;
  464. port = 0x4d0 + (irq >> 3);
  465. return (inb(port) >> (irq & 7)) & 1;
  466. }
  467. static void __init construct_default_ioirq_mptable(int mpc_default_type)
  468. {
  469. struct mpc_config_intsrc intsrc;
  470. int i;
  471. int ELCR_fallback = 0;
  472. intsrc.mpc_type = MP_INTSRC;
  473. intsrc.mpc_irqflag = 0; /* conforming */
  474. intsrc.mpc_srcbus = 0;
  475. intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
  476. intsrc.mpc_irqtype = mp_INT;
  477. /*
  478.  *  If true, we have an ISA/PCI system with no IRQ entries
  479.  *  in the MP table. To prevent the PCI interrupts from being set up
  480.  *  incorrectly, we try to use the ELCR. The sanity check to see if
  481.  *  there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
  482.  *  never be level sensitive, so we simply see if the ELCR agrees.
  483.  *  If it does, we assume it's valid.
  484.  */
  485. if (mpc_default_type == 5) {
  486. printk("ISA/PCI bus type with no IRQ information... falling back to ELCRn");
  487. if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
  488. printk("ELCR contains invalid data... not using ELCRn");
  489. else {
  490. printk("Using ELCR to identify PCI interruptsn");
  491. ELCR_fallback = 1;
  492. }
  493. }
  494. for (i = 0; i < 16; i++) {
  495. switch (mpc_default_type) {
  496. case 2:
  497. if (i == 0 || i == 13)
  498. continue; /* IRQ0 & IRQ13 not connected */
  499. /* fall through */
  500. default:
  501. if (i == 2)
  502. continue; /* IRQ2 is never connected */
  503. }
  504. if (ELCR_fallback) {
  505. /*
  506.  *  If the ELCR indicates a level-sensitive interrupt, we
  507.  *  copy that information over to the MP table in the
  508.  *  irqflag field (level sensitive, active high polarity).
  509.  */
  510. if (ELCR_trigger(i))
  511. intsrc.mpc_irqflag = 13;
  512. else
  513. intsrc.mpc_irqflag = 0;
  514. }
  515. intsrc.mpc_srcbusirq = i;
  516. intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
  517. MP_intsrc_info(&intsrc);
  518. }
  519. intsrc.mpc_irqtype = mp_ExtINT;
  520. intsrc.mpc_srcbusirq = 0;
  521. intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */
  522. MP_intsrc_info(&intsrc);
  523. }
  524. static inline void __init construct_default_ISA_mptable(int mpc_default_type)
  525. {
  526. struct mpc_config_processor processor;
  527. struct mpc_config_bus bus;
  528. struct mpc_config_ioapic ioapic;
  529. struct mpc_config_lintsrc lintsrc;
  530. int linttypes[2] = { mp_ExtINT, mp_NMI };
  531. int i;
  532. /*
  533.  * local APIC has default address
  534.  */
  535. mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
  536. /*
  537.  * 2 CPUs, numbered 0 & 1.
  538.  */
  539. processor.mpc_type = MP_PROCESSOR;
  540. /* Either an integrated APIC or a discrete 82489DX. */
  541. processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
  542. processor.mpc_cpuflag = CPU_ENABLED;
  543. processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
  544.    (boot_cpu_data.x86_model << 4) |
  545.    boot_cpu_data.x86_mask;
  546. processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
  547. processor.mpc_reserved[0] = 0;
  548. processor.mpc_reserved[1] = 0;
  549. for (i = 0; i < 2; i++) {
  550. processor.mpc_apicid = i;
  551. MP_processor_info(&processor);
  552. }
  553. bus.mpc_type = MP_BUS;
  554. bus.mpc_busid = 0;
  555. switch (mpc_default_type) {
  556. default:
  557. printk("???nUnknown standard configuration %dn",
  558. mpc_default_type);
  559. /* fall through */
  560. case 1:
  561. case 5:
  562. memcpy(bus.mpc_bustype, "ISA   ", 6);
  563. break;
  564. case 2:
  565. case 6:
  566. case 3:
  567. memcpy(bus.mpc_bustype, "EISA  ", 6);
  568. break;
  569. case 4:
  570. case 7:
  571. memcpy(bus.mpc_bustype, "MCA   ", 6);
  572. }
  573. MP_bus_info(&bus);
  574. if (mpc_default_type > 4) {
  575. bus.mpc_busid = 1;
  576. memcpy(bus.mpc_bustype, "PCI   ", 6);
  577. MP_bus_info(&bus);
  578. }
  579. ioapic.mpc_type = MP_IOAPIC;
  580. ioapic.mpc_apicid = 2;
  581. ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
  582. ioapic.mpc_flags = MPC_APIC_USABLE;
  583. ioapic.mpc_apicaddr = 0xFEC00000;
  584. MP_ioapic_info(&ioapic);
  585. /*
  586.  * We set up most of the low 16 IO-APIC pins according to MPS rules.
  587.  */
  588. construct_default_ioirq_mptable(mpc_default_type);
  589. lintsrc.mpc_type = MP_LINTSRC;
  590. lintsrc.mpc_irqflag = 0; /* conforming */
  591. lintsrc.mpc_srcbusid = 0;
  592. lintsrc.mpc_srcbusirq = 0;
  593. lintsrc.mpc_destapic = MP_APIC_ALL;
  594. for (i = 0; i < 2; i++) {
  595. lintsrc.mpc_irqtype = linttypes[i];
  596. lintsrc.mpc_destapiclint = i;
  597. MP_lintsrc_info(&lintsrc);
  598. }
  599. }
  600. static struct intel_mp_floating *mpf_found;
  601. extern void  config_acpi_tables(void);
  602. /*
  603.  * Scan the memory blocks for an SMP configuration block.
  604.  */
  605. void __init get_smp_config (void)
  606. {
  607. struct intel_mp_floating *mpf = mpf_found;
  608. #ifdef CONFIG_X86_IO_APIC
  609. /*
  610.  * Check if the ACPI tables are provided. Use them only to get
  611.  * the processor information, mainly because it provides
  612.  * the info on the logical processor(s), rather than the physical
  613.  * processor(s) that are provided by the MPS. We attempt to 
  614.  * check only if the user provided a commandline override
  615.  */
  616. config_acpi_tables();
  617. #endif
  618. printk("Intel MultiProcessor Specification v1.%dn", mpf->mpf_specification);
  619. if (mpf->mpf_feature2 & (1<<7)) {
  620. printk("    IMCR and PIC compatibility mode.n");
  621. pic_mode = 1;
  622. } else {
  623. printk("    Virtual Wire compatibility mode.n");
  624. pic_mode = 0;
  625. }
  626. /*
  627.  * Now see if we need to read further.
  628.  */
  629. if (mpf->mpf_feature1 != 0) {
  630. printk("Default MP configuration #%dn", mpf->mpf_feature1);
  631. construct_default_ISA_mptable(mpf->mpf_feature1);
  632. } else if (mpf->mpf_physptr) {
  633. /*
  634.  * Read the physical hardware table.  Anything here will
  635.  * override the defaults.
  636.  */
  637. if (!smp_read_mpc((void *)mpf->mpf_physptr)) {
  638. smp_found_config = 0;
  639. printk(KERN_ERR "BIOS bug, MP table errors detected!...n");
  640. printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)n");
  641. return;
  642. }
  643. /*
  644.  * If there are no explicit MP IRQ entries, then we are
  645.  * broken.  We set up most of the low 16 IO-APIC pins to
  646.  * ISA defaults and hope it will work.
  647.  */
  648. if (!mp_irq_entries) {
  649. struct mpc_config_bus bus;
  650. printk("BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)n");
  651. bus.mpc_type = MP_BUS;
  652. bus.mpc_busid = 0;
  653. memcpy(bus.mpc_bustype, "ISA   ", 6);
  654. MP_bus_info(&bus);
  655. construct_default_ioirq_mptable(0);
  656. }
  657. } else
  658. BUG();
  659. printk("Processors: %dn", num_processors);
  660. /*
  661.  * Only use the first configuration found.
  662.  */
  663. }
  664. static int __init smp_scan_config (unsigned long base, unsigned long length)
  665. {
  666. unsigned long *bp = phys_to_virt(base);
  667. struct intel_mp_floating *mpf;
  668. Dprintk("Scan SMP from %p for %ld bytes.n", bp,length);
  669. if (sizeof(*mpf) != 16)
  670. printk("Error: MPF sizen");
  671. while (length > 0) {
  672. mpf = (struct intel_mp_floating *)bp;
  673. if ((*bp == SMP_MAGIC_IDENT) &&
  674. (mpf->mpf_length == 1) &&
  675. !mpf_checksum((unsigned char *)bp, 16) &&
  676. ((mpf->mpf_specification == 1)
  677. || (mpf->mpf_specification == 4)) ) {
  678. smp_found_config = 1;
  679. printk("found SMP MP-table at %08lxn",
  680. virt_to_phys(mpf));
  681. reserve_bootmem(virt_to_phys(mpf), PAGE_SIZE);
  682. if (mpf->mpf_physptr)
  683. reserve_bootmem(mpf->mpf_physptr, PAGE_SIZE);
  684. mpf_found = mpf;
  685. return 1;
  686. }
  687. bp += 4;
  688. length -= 16;
  689. }
  690. return 0;
  691. }
  692. void __init find_intel_smp (void)
  693. {
  694. unsigned int address;
  695. /*
  696.  * FIXME: Linux assumes you have 640K of base ram..
  697.  * this continues the error...
  698.  *
  699.  * 1) Scan the bottom 1K for a signature
  700.  * 2) Scan the top 1K of base RAM
  701.  * 3) Scan the 64K of bios
  702.  */
  703. if (smp_scan_config(0x0,0x400) ||
  704. smp_scan_config(639*0x400,0x400) ||
  705. smp_scan_config(0xF0000,0x10000))
  706. return;
  707. /*
  708.  * If it is an SMP machine we should know now, unless the
  709.  * configuration is in an EISA/MCA bus machine with an
  710.  * extended bios data area.
  711.  *
  712.  * there is a real-mode segmented pointer pointing to the
  713.  * 4K EBDA area at 0x40E, calculate and scan it here.
  714.  *
  715.  * NOTE! There are Linux loaders that will corrupt the EBDA
  716.  * area, and as such this kind of SMP config may be less
  717.  * trustworthy, simply because the SMP table may have been
  718.  * stomped on during early boot. These loaders are buggy and
  719.  * should be fixed.
  720.  */
  721. address = *(unsigned short *)phys_to_virt(0x40E);
  722. address <<= 4;
  723. smp_scan_config(address, 0x1000);
  724. if (smp_found_config)
  725. printk(KERN_WARNING "WARNING: MP table in the EBDA can be UNSAFE, contact linux-smp@vger.kernel.org if you experience SMP problems!n");
  726. }
  727. #else
  728. /*
  729.  * The Visual Workstation is Intel MP compliant in the hardware
  730.  * sense, but it doesn't have a BIOS(-configuration table).
  731.  * No problem for Linux.
  732.  */
  733. void __init find_visws_smp(void)
  734. {
  735. smp_found_config = 1;
  736. phys_cpu_present_map |= 2; /* or in id 1 */
  737. apic_version[1] |= 0x10; /* integrated APIC */
  738. apic_version[0] |= 0x10;
  739. mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
  740. }
  741. #endif
  742. /*
  743.  * - Intel MP Configuration Table
  744.  * - or SGI Visual Workstation configuration
  745.  */
  746. void __init find_smp_config (void)
  747. {
  748. #ifdef CONFIG_X86_LOCAL_APIC
  749. find_intel_smp();
  750. #endif
  751. #ifdef CONFIG_VISWS
  752. find_visws_smp();
  753. #endif
  754. }