mpparse_32.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. /*
  2. * Intel Multiprocessor Specification 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. * Paul Diefenbaugh: Added full ACPI support
  14. */
  15. #include <linux/mm.h>
  16. #include <linux/init.h>
  17. #include <linux/acpi.h>
  18. #include <linux/delay.h>
  19. #include <linux/bootmem.h>
  20. #include <linux/kernel_stat.h>
  21. #include <linux/mc146818rtc.h>
  22. #include <linux/bitops.h>
  23. #include <asm/smp.h>
  24. #include <asm/acpi.h>
  25. #include <asm/mtrr.h>
  26. #include <asm/mpspec.h>
  27. #include <asm/io_apic.h>
  28. #include <asm/bios_ebda.h>
  29. #include <mach_apic.h>
  30. #include <mach_apicdef.h>
  31. #include <mach_mpparse.h>
  32. /* Have we found an MP table */
  33. int smp_found_config;
  34. unsigned int __cpuinitdata maxcpus = NR_CPUS;
  35. /*
  36. * Various Linux-internal data structures created from the
  37. * MP-table.
  38. */
  39. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  40. int mp_bus_id_to_type [MAX_MP_BUSSES];
  41. #endif
  42. DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
  43. int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
  44. static int mp_current_pci_id;
  45. /* I/O APIC entries */
  46. struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
  47. /* # of MP IRQ source entries */
  48. struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
  49. /* MP IRQ source entries */
  50. int mp_irq_entries;
  51. int nr_ioapics;
  52. int pic_mode;
  53. unsigned int def_to_bigsmp = 0;
  54. /* Processor that is doing the boot up */
  55. unsigned int boot_cpu_physical_apicid = -1U;
  56. /* Make it easy to share the UP and SMP code: */
  57. #ifndef CONFIG_X86_SMP
  58. unsigned int num_processors;
  59. unsigned disabled_cpus __cpuinitdata;
  60. #endif
  61. /* Make it easy to share the UP and SMP code: */
  62. #ifndef CONFIG_X86_SMP
  63. physid_mask_t phys_cpu_present_map;
  64. #endif
  65. #ifndef CONFIG_SMP
  66. DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID;
  67. #endif
  68. /*
  69. * Intel MP BIOS table parsing routines:
  70. */
  71. /*
  72. * Checksum an MP configuration block.
  73. */
  74. static int __init mpf_checksum(unsigned char *mp, int len)
  75. {
  76. int sum = 0;
  77. while (len--)
  78. sum += *mp++;
  79. return sum & 0xFF;
  80. }
  81. #ifdef CONFIG_X86_NUMAQ
  82. /*
  83. * Have to match translation table entries to main table entries by counter
  84. * hence the mpc_record variable .... can't see a less disgusting way of
  85. * doing this ....
  86. */
  87. static int mpc_record;
  88. static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __cpuinitdata;
  89. #endif
  90. static void __cpuinit generic_processor_info(int apicid, int version)
  91. {
  92. int cpu;
  93. cpumask_t tmp_map;
  94. physid_mask_t phys_cpu;
  95. /*
  96. * Validate version
  97. */
  98. if (version == 0x0) {
  99. printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! "
  100. "fixing up to 0x10. (tell your hw vendor)\n",
  101. version);
  102. version = 0x10;
  103. }
  104. apic_version[apicid] = version;
  105. phys_cpu = apicid_to_cpu_present(apicid);
  106. physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu);
  107. if (num_processors >= NR_CPUS) {
  108. printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
  109. " Processor ignored.\n", NR_CPUS);
  110. return;
  111. }
  112. if (num_processors >= maxcpus) {
  113. printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
  114. " Processor ignored.\n", maxcpus);
  115. return;
  116. }
  117. num_processors++;
  118. cpus_complement(tmp_map, cpu_present_map);
  119. cpu = first_cpu(tmp_map);
  120. if (apicid == boot_cpu_physical_apicid)
  121. /*
  122. * x86_bios_cpu_apicid is required to have processors listed
  123. * in same order as logical cpu numbers. Hence the first
  124. * entry is BSP, and so on.
  125. */
  126. cpu = 0;
  127. /*
  128. * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
  129. * but we need to work other dependencies like SMP_SUSPEND etc
  130. * before this can be done without some confusion.
  131. * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
  132. * - Ashok Raj <ashok.raj@intel.com>
  133. */
  134. if (num_processors > 8) {
  135. switch (boot_cpu_data.x86_vendor) {
  136. case X86_VENDOR_INTEL:
  137. if (!APIC_XAPIC(version)) {
  138. def_to_bigsmp = 0;
  139. break;
  140. }
  141. /* If P4 and above fall through */
  142. case X86_VENDOR_AMD:
  143. def_to_bigsmp = 1;
  144. }
  145. }
  146. #ifdef CONFIG_SMP
  147. /* are we being called early in kernel startup? */
  148. if (x86_cpu_to_apicid_early_ptr) {
  149. u16 *cpu_to_apicid = x86_cpu_to_apicid_early_ptr;
  150. u16 *bios_cpu_apicid = x86_bios_cpu_apicid_early_ptr;
  151. cpu_to_apicid[cpu] = apicid;
  152. bios_cpu_apicid[cpu] = apicid;
  153. } else {
  154. per_cpu(x86_cpu_to_apicid, cpu) = apicid;
  155. per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
  156. }
  157. #endif
  158. cpu_set(cpu, cpu_possible_map);
  159. cpu_set(cpu, cpu_present_map);
  160. }
  161. static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
  162. {
  163. int apicid;
  164. if (!(m->mpc_cpuflag & CPU_ENABLED)) {
  165. disabled_cpus++;
  166. return;
  167. }
  168. #ifdef CONFIG_X86_NUMAQ
  169. apicid = mpc_apic_id(m, translation_table[mpc_record]);
  170. #else
  171. Dprintk("Processor #%d %u:%u APIC version %d\n",
  172. m->mpc_apicid,
  173. (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  174. (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  175. m->mpc_apicver);
  176. apicid = m->mpc_apicid;
  177. #endif
  178. if (m->mpc_featureflag&(1<<0))
  179. Dprintk(" Floating point unit present.\n");
  180. if (m->mpc_featureflag&(1<<7))
  181. Dprintk(" Machine Exception supported.\n");
  182. if (m->mpc_featureflag&(1<<8))
  183. Dprintk(" 64 bit compare & exchange supported.\n");
  184. if (m->mpc_featureflag&(1<<9))
  185. Dprintk(" Internal APIC present.\n");
  186. if (m->mpc_featureflag&(1<<11))
  187. Dprintk(" SEP present.\n");
  188. if (m->mpc_featureflag&(1<<12))
  189. Dprintk(" MTRR present.\n");
  190. if (m->mpc_featureflag&(1<<13))
  191. Dprintk(" PGE present.\n");
  192. if (m->mpc_featureflag&(1<<14))
  193. Dprintk(" MCA present.\n");
  194. if (m->mpc_featureflag&(1<<15))
  195. Dprintk(" CMOV present.\n");
  196. if (m->mpc_featureflag&(1<<16))
  197. Dprintk(" PAT present.\n");
  198. if (m->mpc_featureflag&(1<<17))
  199. Dprintk(" PSE present.\n");
  200. if (m->mpc_featureflag&(1<<18))
  201. Dprintk(" PSN present.\n");
  202. if (m->mpc_featureflag&(1<<19))
  203. Dprintk(" Cache Line Flush Instruction present.\n");
  204. /* 20 Reserved */
  205. if (m->mpc_featureflag&(1<<21))
  206. Dprintk(" Debug Trace and EMON Store present.\n");
  207. if (m->mpc_featureflag&(1<<22))
  208. Dprintk(" ACPI Thermal Throttle Registers present.\n");
  209. if (m->mpc_featureflag&(1<<23))
  210. Dprintk(" MMX present.\n");
  211. if (m->mpc_featureflag&(1<<24))
  212. Dprintk(" FXSR present.\n");
  213. if (m->mpc_featureflag&(1<<25))
  214. Dprintk(" XMM present.\n");
  215. if (m->mpc_featureflag&(1<<26))
  216. Dprintk(" Willamette New Instructions present.\n");
  217. if (m->mpc_featureflag&(1<<27))
  218. Dprintk(" Self Snoop present.\n");
  219. if (m->mpc_featureflag&(1<<28))
  220. Dprintk(" HT present.\n");
  221. if (m->mpc_featureflag&(1<<29))
  222. Dprintk(" Thermal Monitor present.\n");
  223. /* 30, 31 Reserved */
  224. if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
  225. Dprintk(" Bootup CPU\n");
  226. boot_cpu_physical_apicid = m->mpc_apicid;
  227. }
  228. generic_processor_info(apicid, m->mpc_apicver);
  229. }
  230. static void __init MP_bus_info (struct mpc_config_bus *m)
  231. {
  232. char str[7];
  233. memcpy(str, m->mpc_bustype, 6);
  234. str[6] = 0;
  235. #ifdef CONFIG_X86_NUMAQ
  236. mpc_oem_bus_info(m, str, translation_table[mpc_record]);
  237. #else
  238. Dprintk("Bus #%d is %s\n", m->mpc_busid, str);
  239. #endif
  240. #if MAX_MP_BUSSES < 256
  241. if (m->mpc_busid >= MAX_MP_BUSSES) {
  242. printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
  243. " is too large, max. supported is %d\n",
  244. m->mpc_busid, str, MAX_MP_BUSSES - 1);
  245. return;
  246. }
  247. #endif
  248. set_bit(m->mpc_busid, mp_bus_not_pci);
  249. if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI)-1) == 0) {
  250. #ifdef CONFIG_X86_NUMAQ
  251. mpc_oem_pci_bus(m, translation_table[mpc_record]);
  252. #endif
  253. clear_bit(m->mpc_busid, mp_bus_not_pci);
  254. mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
  255. mp_current_pci_id++;
  256. #if defined(CONFIG_EISA) || defined (CONFIG_MCA)
  257. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI;
  258. } else if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
  259. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
  260. } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA)-1) == 0) {
  261. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA;
  262. } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
  263. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
  264. } else {
  265. printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
  266. #endif
  267. }
  268. }
  269. static int bad_ioapic(unsigned long address)
  270. {
  271. if (nr_ioapics >= MAX_IO_APICS) {
  272. printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
  273. "(found %d)\n", MAX_IO_APICS, nr_ioapics);
  274. panic("Recompile kernel with bigger MAX_IO_APICS!\n");
  275. }
  276. if (!address) {
  277. printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
  278. " found in table, skipping!\n");
  279. return 1;
  280. }
  281. return 0;
  282. }
  283. static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
  284. {
  285. if (!(m->mpc_flags & MPC_APIC_USABLE))
  286. return;
  287. printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n",
  288. m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr);
  289. if (bad_ioapic(m->mpc_apicaddr))
  290. return;
  291. mp_ioapics[nr_ioapics] = *m;
  292. nr_ioapics++;
  293. }
  294. static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
  295. {
  296. mp_irqs [mp_irq_entries] = *m;
  297. Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
  298. " IRQ %02x, APIC ID %x, APIC INT %02x\n",
  299. m->mpc_irqtype, m->mpc_irqflag & 3,
  300. (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
  301. m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
  302. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  303. panic("Max # of irq sources exceeded!!\n");
  304. }
  305. static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
  306. {
  307. Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
  308. " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
  309. m->mpc_irqtype, m->mpc_irqflag & 3,
  310. (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
  311. m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
  312. }
  313. #ifdef CONFIG_X86_NUMAQ
  314. static void __init MP_translation_info (struct mpc_config_translation *m)
  315. {
  316. printk(KERN_INFO "Translation: record %d, type %d, quad %d, global %d, local %d\n", mpc_record, m->trans_type, m->trans_quad, m->trans_global, m->trans_local);
  317. if (mpc_record >= MAX_MPC_ENTRY)
  318. printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n");
  319. else
  320. translation_table[mpc_record] = m; /* stash this for later */
  321. if (m->trans_quad < MAX_NUMNODES && !node_online(m->trans_quad))
  322. node_set_online(m->trans_quad);
  323. }
  324. /*
  325. * Read/parse the MPC oem tables
  326. */
  327. static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, \
  328. unsigned short oemsize)
  329. {
  330. int count = sizeof (*oemtable); /* the header size */
  331. unsigned char *oemptr = ((unsigned char *)oemtable)+count;
  332. mpc_record = 0;
  333. printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n", oemtable);
  334. if (memcmp(oemtable->oem_signature,MPC_OEM_SIGNATURE,4))
  335. {
  336. printk(KERN_WARNING "SMP mpc oemtable: bad signature [%c%c%c%c]!\n",
  337. oemtable->oem_signature[0],
  338. oemtable->oem_signature[1],
  339. oemtable->oem_signature[2],
  340. oemtable->oem_signature[3]);
  341. return;
  342. }
  343. if (mpf_checksum((unsigned char *)oemtable,oemtable->oem_length))
  344. {
  345. printk(KERN_WARNING "SMP oem mptable: checksum error!\n");
  346. return;
  347. }
  348. while (count < oemtable->oem_length) {
  349. switch (*oemptr) {
  350. case MP_TRANSLATION:
  351. {
  352. struct mpc_config_translation *m=
  353. (struct mpc_config_translation *)oemptr;
  354. MP_translation_info(m);
  355. oemptr += sizeof(*m);
  356. count += sizeof(*m);
  357. ++mpc_record;
  358. break;
  359. }
  360. default:
  361. {
  362. printk(KERN_WARNING "Unrecognised OEM table entry type! - %d\n", (int) *oemptr);
  363. return;
  364. }
  365. }
  366. }
  367. }
  368. static inline void mps_oem_check(struct mp_config_table *mpc, char *oem,
  369. char *productid)
  370. {
  371. if (strncmp(oem, "IBM NUMA", 8))
  372. printk("Warning! May not be a NUMA-Q system!\n");
  373. if (mpc->mpc_oemptr)
  374. smp_read_mpc_oem((struct mp_config_oemtable *) mpc->mpc_oemptr,
  375. mpc->mpc_oemsize);
  376. }
  377. #endif /* CONFIG_X86_NUMAQ */
  378. /*
  379. * Read/parse the MPC
  380. */
  381. static int __init smp_read_mpc(struct mp_config_table *mpc)
  382. {
  383. char str[16];
  384. char oem[10];
  385. int count=sizeof(*mpc);
  386. unsigned char *mpt=((unsigned char *)mpc)+count;
  387. if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
  388. printk(KERN_ERR "SMP mptable: bad signature [0x%x]!\n",
  389. *(u32 *)mpc->mpc_signature);
  390. return 0;
  391. }
  392. if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
  393. printk(KERN_ERR "SMP mptable: checksum error!\n");
  394. return 0;
  395. }
  396. if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
  397. printk(KERN_ERR "SMP mptable: bad table version (%d)!!\n",
  398. mpc->mpc_spec);
  399. return 0;
  400. }
  401. if (!mpc->mpc_lapic) {
  402. printk(KERN_ERR "SMP mptable: null local APIC address!\n");
  403. return 0;
  404. }
  405. memcpy(oem,mpc->mpc_oem,8);
  406. oem[8]=0;
  407. printk(KERN_INFO "OEM ID: %s ",oem);
  408. memcpy(str,mpc->mpc_productid,12);
  409. str[12]=0;
  410. printk("Product ID: %s ",str);
  411. mps_oem_check(mpc, oem, str);
  412. printk("APIC at: 0x%X\n", mpc->mpc_lapic);
  413. /*
  414. * Save the local APIC address (it might be non-default) -- but only
  415. * if we're not using ACPI.
  416. */
  417. if (!acpi_lapic)
  418. mp_lapic_addr = mpc->mpc_lapic;
  419. /*
  420. * Now process the configuration blocks.
  421. */
  422. #ifdef CONFIG_X86_NUMAQ
  423. mpc_record = 0;
  424. #endif
  425. while (count < mpc->mpc_length) {
  426. switch(*mpt) {
  427. case MP_PROCESSOR:
  428. {
  429. struct mpc_config_processor *m=
  430. (struct mpc_config_processor *)mpt;
  431. /* ACPI may have already provided this data */
  432. if (!acpi_lapic)
  433. MP_processor_info(m);
  434. mpt += sizeof(*m);
  435. count += sizeof(*m);
  436. break;
  437. }
  438. case MP_BUS:
  439. {
  440. struct mpc_config_bus *m=
  441. (struct mpc_config_bus *)mpt;
  442. MP_bus_info(m);
  443. mpt += sizeof(*m);
  444. count += sizeof(*m);
  445. break;
  446. }
  447. case MP_IOAPIC:
  448. {
  449. struct mpc_config_ioapic *m=
  450. (struct mpc_config_ioapic *)mpt;
  451. MP_ioapic_info(m);
  452. mpt+=sizeof(*m);
  453. count+=sizeof(*m);
  454. break;
  455. }
  456. case MP_INTSRC:
  457. {
  458. struct mpc_config_intsrc *m=
  459. (struct mpc_config_intsrc *)mpt;
  460. MP_intsrc_info(m);
  461. mpt+=sizeof(*m);
  462. count+=sizeof(*m);
  463. break;
  464. }
  465. case MP_LINTSRC:
  466. {
  467. struct mpc_config_lintsrc *m=
  468. (struct mpc_config_lintsrc *)mpt;
  469. MP_lintsrc_info(m);
  470. mpt+=sizeof(*m);
  471. count+=sizeof(*m);
  472. break;
  473. }
  474. default:
  475. {
  476. count = mpc->mpc_length;
  477. break;
  478. }
  479. }
  480. #ifdef CONFIG_X86_NUMAQ
  481. ++mpc_record;
  482. #endif
  483. }
  484. setup_apic_routing();
  485. if (!num_processors)
  486. printk(KERN_ERR "SMP mptable: no processors registered!\n");
  487. return num_processors;
  488. }
  489. static int __init ELCR_trigger(unsigned int irq)
  490. {
  491. unsigned int port;
  492. port = 0x4d0 + (irq >> 3);
  493. return (inb(port) >> (irq & 7)) & 1;
  494. }
  495. static void __init construct_default_ioirq_mptable(int mpc_default_type)
  496. {
  497. struct mpc_config_intsrc intsrc;
  498. int i;
  499. int ELCR_fallback = 0;
  500. intsrc.mpc_type = MP_INTSRC;
  501. intsrc.mpc_irqflag = 0; /* conforming */
  502. intsrc.mpc_srcbus = 0;
  503. intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
  504. intsrc.mpc_irqtype = mp_INT;
  505. /*
  506. * If true, we have an ISA/PCI system with no IRQ entries
  507. * in the MP table. To prevent the PCI interrupts from being set up
  508. * incorrectly, we try to use the ELCR. The sanity check to see if
  509. * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
  510. * never be level sensitive, so we simply see if the ELCR agrees.
  511. * If it does, we assume it's valid.
  512. */
  513. if (mpc_default_type == 5) {
  514. printk(KERN_INFO "ISA/PCI bus type with no IRQ information... falling back to ELCR\n");
  515. if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
  516. printk(KERN_WARNING "ELCR contains invalid data... not using ELCR\n");
  517. else {
  518. printk(KERN_INFO "Using ELCR to identify PCI interrupts\n");
  519. ELCR_fallback = 1;
  520. }
  521. }
  522. for (i = 0; i < 16; i++) {
  523. switch (mpc_default_type) {
  524. case 2:
  525. if (i == 0 || i == 13)
  526. continue; /* IRQ0 & IRQ13 not connected */
  527. /* fall through */
  528. default:
  529. if (i == 2)
  530. continue; /* IRQ2 is never connected */
  531. }
  532. if (ELCR_fallback) {
  533. /*
  534. * If the ELCR indicates a level-sensitive interrupt, we
  535. * copy that information over to the MP table in the
  536. * irqflag field (level sensitive, active high polarity).
  537. */
  538. if (ELCR_trigger(i))
  539. intsrc.mpc_irqflag = 13;
  540. else
  541. intsrc.mpc_irqflag = 0;
  542. }
  543. intsrc.mpc_srcbusirq = i;
  544. intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
  545. MP_intsrc_info(&intsrc);
  546. }
  547. intsrc.mpc_irqtype = mp_ExtINT;
  548. intsrc.mpc_srcbusirq = 0;
  549. intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */
  550. MP_intsrc_info(&intsrc);
  551. }
  552. static inline void __init construct_default_ISA_mptable(int mpc_default_type)
  553. {
  554. struct mpc_config_processor processor;
  555. struct mpc_config_bus bus;
  556. struct mpc_config_ioapic ioapic;
  557. struct mpc_config_lintsrc lintsrc;
  558. int linttypes[2] = { mp_ExtINT, mp_NMI };
  559. int i;
  560. /*
  561. * local APIC has default address
  562. */
  563. mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
  564. /*
  565. * 2 CPUs, numbered 0 & 1.
  566. */
  567. processor.mpc_type = MP_PROCESSOR;
  568. /* Either an integrated APIC or a discrete 82489DX. */
  569. processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
  570. processor.mpc_cpuflag = CPU_ENABLED;
  571. processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
  572. (boot_cpu_data.x86_model << 4) |
  573. boot_cpu_data.x86_mask;
  574. processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
  575. processor.mpc_reserved[0] = 0;
  576. processor.mpc_reserved[1] = 0;
  577. for (i = 0; i < 2; i++) {
  578. processor.mpc_apicid = i;
  579. MP_processor_info(&processor);
  580. }
  581. bus.mpc_type = MP_BUS;
  582. bus.mpc_busid = 0;
  583. switch (mpc_default_type) {
  584. default:
  585. printk("???\n");
  586. printk(KERN_ERR "Unknown standard configuration %d\n",
  587. mpc_default_type);
  588. /* fall through */
  589. case 1:
  590. case 5:
  591. memcpy(bus.mpc_bustype, "ISA ", 6);
  592. break;
  593. case 2:
  594. case 6:
  595. case 3:
  596. memcpy(bus.mpc_bustype, "EISA ", 6);
  597. break;
  598. case 4:
  599. case 7:
  600. memcpy(bus.mpc_bustype, "MCA ", 6);
  601. }
  602. MP_bus_info(&bus);
  603. if (mpc_default_type > 4) {
  604. bus.mpc_busid = 1;
  605. memcpy(bus.mpc_bustype, "PCI ", 6);
  606. MP_bus_info(&bus);
  607. }
  608. ioapic.mpc_type = MP_IOAPIC;
  609. ioapic.mpc_apicid = 2;
  610. ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
  611. ioapic.mpc_flags = MPC_APIC_USABLE;
  612. ioapic.mpc_apicaddr = 0xFEC00000;
  613. MP_ioapic_info(&ioapic);
  614. /*
  615. * We set up most of the low 16 IO-APIC pins according to MPS rules.
  616. */
  617. construct_default_ioirq_mptable(mpc_default_type);
  618. lintsrc.mpc_type = MP_LINTSRC;
  619. lintsrc.mpc_irqflag = 0; /* conforming */
  620. lintsrc.mpc_srcbusid = 0;
  621. lintsrc.mpc_srcbusirq = 0;
  622. lintsrc.mpc_destapic = MP_APIC_ALL;
  623. for (i = 0; i < 2; i++) {
  624. lintsrc.mpc_irqtype = linttypes[i];
  625. lintsrc.mpc_destapiclint = i;
  626. MP_lintsrc_info(&lintsrc);
  627. }
  628. }
  629. static struct intel_mp_floating *mpf_found;
  630. /*
  631. * Scan the memory blocks for an SMP configuration block.
  632. */
  633. void __init get_smp_config (void)
  634. {
  635. struct intel_mp_floating *mpf = mpf_found;
  636. /*
  637. * ACPI supports both logical (e.g. Hyper-Threading) and physical
  638. * processors, where MPS only supports physical.
  639. */
  640. if (acpi_lapic && acpi_ioapic) {
  641. printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
  642. return;
  643. }
  644. else if (acpi_lapic)
  645. printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
  646. printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
  647. if (mpf->mpf_feature2 & (1<<7)) {
  648. printk(KERN_INFO " IMCR and PIC compatibility mode.\n");
  649. pic_mode = 1;
  650. } else {
  651. printk(KERN_INFO " Virtual Wire compatibility mode.\n");
  652. pic_mode = 0;
  653. }
  654. /*
  655. * Now see if we need to read further.
  656. */
  657. if (mpf->mpf_feature1 != 0) {
  658. printk(KERN_INFO "Default MP configuration #%d\n", mpf->mpf_feature1);
  659. construct_default_ISA_mptable(mpf->mpf_feature1);
  660. } else if (mpf->mpf_physptr) {
  661. /*
  662. * Read the physical hardware table. Anything here will
  663. * override the defaults.
  664. */
  665. if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
  666. smp_found_config = 0;
  667. printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
  668. printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
  669. return;
  670. }
  671. /*
  672. * If there are no explicit MP IRQ entries, then we are
  673. * broken. We set up most of the low 16 IO-APIC pins to
  674. * ISA defaults and hope it will work.
  675. */
  676. if (!mp_irq_entries) {
  677. struct mpc_config_bus bus;
  678. printk(KERN_ERR "BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)\n");
  679. bus.mpc_type = MP_BUS;
  680. bus.mpc_busid = 0;
  681. memcpy(bus.mpc_bustype, "ISA ", 6);
  682. MP_bus_info(&bus);
  683. construct_default_ioirq_mptable(0);
  684. }
  685. } else
  686. BUG();
  687. printk(KERN_INFO "Processors: %d\n", num_processors);
  688. /*
  689. * Only use the first configuration found.
  690. */
  691. }
  692. static int __init smp_scan_config (unsigned long base, unsigned long length)
  693. {
  694. unsigned long *bp = phys_to_virt(base);
  695. struct intel_mp_floating *mpf;
  696. printk(KERN_INFO "Scan SMP from %p for %ld bytes.\n", bp,length);
  697. if (sizeof(*mpf) != 16)
  698. printk("Error: MPF size\n");
  699. while (length > 0) {
  700. mpf = (struct intel_mp_floating *)bp;
  701. if ((*bp == SMP_MAGIC_IDENT) &&
  702. (mpf->mpf_length == 1) &&
  703. !mpf_checksum((unsigned char *)bp, 16) &&
  704. ((mpf->mpf_specification == 1)
  705. || (mpf->mpf_specification == 4)) ) {
  706. smp_found_config = 1;
  707. printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n",
  708. mpf, virt_to_phys(mpf));
  709. reserve_bootmem(virt_to_phys(mpf), PAGE_SIZE,
  710. BOOTMEM_DEFAULT);
  711. if (mpf->mpf_physptr) {
  712. /*
  713. * We cannot access to MPC table to compute
  714. * table size yet, as only few megabytes from
  715. * the bottom is mapped now.
  716. * PC-9800's MPC table places on the very last
  717. * of physical memory; so that simply reserving
  718. * PAGE_SIZE from mpg->mpf_physptr yields BUG()
  719. * in reserve_bootmem.
  720. */
  721. unsigned long size = PAGE_SIZE;
  722. unsigned long end = max_low_pfn * PAGE_SIZE;
  723. if (mpf->mpf_physptr + size > end)
  724. size = end - mpf->mpf_physptr;
  725. reserve_bootmem(mpf->mpf_physptr, size,
  726. BOOTMEM_DEFAULT);
  727. }
  728. mpf_found = mpf;
  729. return 1;
  730. }
  731. bp += 4;
  732. length -= 16;
  733. }
  734. return 0;
  735. }
  736. void __init find_smp_config (void)
  737. {
  738. unsigned int address;
  739. /*
  740. * FIXME: Linux assumes you have 640K of base ram..
  741. * this continues the error...
  742. *
  743. * 1) Scan the bottom 1K for a signature
  744. * 2) Scan the top 1K of base RAM
  745. * 3) Scan the 64K of bios
  746. */
  747. if (smp_scan_config(0x0,0x400) ||
  748. smp_scan_config(639*0x400,0x400) ||
  749. smp_scan_config(0xF0000,0x10000))
  750. return;
  751. /*
  752. * If it is an SMP machine we should know now, unless the
  753. * configuration is in an EISA/MCA bus machine with an
  754. * extended bios data area.
  755. *
  756. * there is a real-mode segmented pointer pointing to the
  757. * 4K EBDA area at 0x40E, calculate and scan it here.
  758. *
  759. * NOTE! There are Linux loaders that will corrupt the EBDA
  760. * area, and as such this kind of SMP config may be less
  761. * trustworthy, simply because the SMP table may have been
  762. * stomped on during early boot. These loaders are buggy and
  763. * should be fixed.
  764. *
  765. * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
  766. */
  767. address = get_bios_ebda();
  768. if (address)
  769. smp_scan_config(address, 0x400);
  770. }
  771. /* --------------------------------------------------------------------------
  772. ACPI-based MP Configuration
  773. -------------------------------------------------------------------------- */
  774. #ifdef CONFIG_ACPI
  775. void __init mp_register_lapic_address(u64 address)
  776. {
  777. mp_lapic_addr = (unsigned long) address;
  778. set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
  779. if (boot_cpu_physical_apicid == -1U)
  780. boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
  781. Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
  782. }
  783. void __cpuinit mp_register_lapic (u8 id, u8 enabled)
  784. {
  785. if (MAX_APICS - id <= 0) {
  786. printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
  787. id, MAX_APICS);
  788. return;
  789. }
  790. if (!enabled) {
  791. ++disabled_cpus;
  792. return;
  793. }
  794. generic_processor_info(id, GET_APIC_VERSION(apic_read(APIC_LVR)));
  795. }
  796. #ifdef CONFIG_X86_IO_APIC
  797. #define MP_ISA_BUS 0
  798. #define MP_MAX_IOAPIC_PIN 127
  799. static struct mp_ioapic_routing {
  800. int apic_id;
  801. int gsi_base;
  802. int gsi_end;
  803. u32 pin_programmed[4];
  804. } mp_ioapic_routing[MAX_IO_APICS];
  805. static int mp_find_ioapic (int gsi)
  806. {
  807. int i = 0;
  808. /* Find the IOAPIC that manages this GSI. */
  809. for (i = 0; i < nr_ioapics; i++) {
  810. if ((gsi >= mp_ioapic_routing[i].gsi_base)
  811. && (gsi <= mp_ioapic_routing[i].gsi_end))
  812. return i;
  813. }
  814. printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
  815. return -1;
  816. }
  817. static u8 uniq_ioapic_id(u8 id)
  818. {
  819. if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
  820. !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
  821. return io_apic_get_unique_id(nr_ioapics, id);
  822. else
  823. return id;
  824. }
  825. void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
  826. {
  827. int idx = 0;
  828. if (bad_ioapic(address))
  829. return;
  830. idx = nr_ioapics;
  831. mp_ioapics[idx].mpc_type = MP_IOAPIC;
  832. mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
  833. mp_ioapics[idx].mpc_apicaddr = address;
  834. set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
  835. mp_ioapics[idx].mpc_apicid = uniq_ioapic_id(id);
  836. mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
  837. /*
  838. * Build basic GSI lookup table to facilitate gsi->io_apic lookups
  839. * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
  840. */
  841. mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
  842. mp_ioapic_routing[idx].gsi_base = gsi_base;
  843. mp_ioapic_routing[idx].gsi_end = gsi_base +
  844. io_apic_get_redir_entries(idx);
  845. printk("IOAPIC[%d]: apic_id %d, version %d, address 0x%x, "
  846. "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid,
  847. mp_ioapics[idx].mpc_apicver,
  848. mp_ioapics[idx].mpc_apicaddr,
  849. mp_ioapic_routing[idx].gsi_base,
  850. mp_ioapic_routing[idx].gsi_end);
  851. nr_ioapics++;
  852. }
  853. void __init
  854. mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
  855. {
  856. struct mpc_config_intsrc intsrc;
  857. int ioapic = -1;
  858. int pin = -1;
  859. /*
  860. * Convert 'gsi' to 'ioapic.pin'.
  861. */
  862. ioapic = mp_find_ioapic(gsi);
  863. if (ioapic < 0)
  864. return;
  865. pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  866. /*
  867. * TBD: This check is for faulty timer entries, where the override
  868. * erroneously sets the trigger to level, resulting in a HUGE
  869. * increase of timer interrupts!
  870. */
  871. if ((bus_irq == 0) && (trigger == 3))
  872. trigger = 1;
  873. intsrc.mpc_type = MP_INTSRC;
  874. intsrc.mpc_irqtype = mp_INT;
  875. intsrc.mpc_irqflag = (trigger << 2) | polarity;
  876. intsrc.mpc_srcbus = MP_ISA_BUS;
  877. intsrc.mpc_srcbusirq = bus_irq; /* IRQ */
  878. intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid; /* APIC ID */
  879. intsrc.mpc_dstirq = pin; /* INTIN# */
  880. Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n",
  881. intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
  882. (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
  883. intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
  884. mp_irqs[mp_irq_entries] = intsrc;
  885. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  886. panic("Max # of irq sources exceeded!\n");
  887. }
  888. int es7000_plat;
  889. void __init mp_config_acpi_legacy_irqs (void)
  890. {
  891. struct mpc_config_intsrc intsrc;
  892. int i = 0;
  893. int ioapic = -1;
  894. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  895. /*
  896. * Fabricate the legacy ISA bus (bus #31).
  897. */
  898. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  899. #endif
  900. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  901. Dprintk("Bus #%d is ISA\n", MP_ISA_BUS);
  902. /*
  903. * Older generations of ES7000 have no legacy identity mappings
  904. */
  905. if (es7000_plat == 1)
  906. return;
  907. /*
  908. * Locate the IOAPIC that manages the ISA IRQs (0-15).
  909. */
  910. ioapic = mp_find_ioapic(0);
  911. if (ioapic < 0)
  912. return;
  913. intsrc.mpc_type = MP_INTSRC;
  914. intsrc.mpc_irqflag = 0; /* Conforming */
  915. intsrc.mpc_srcbus = MP_ISA_BUS;
  916. intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
  917. /*
  918. * Use the default configuration for the IRQs 0-15. Unless
  919. * overridden by (MADT) interrupt source override entries.
  920. */
  921. for (i = 0; i < 16; i++) {
  922. int idx;
  923. for (idx = 0; idx < mp_irq_entries; idx++) {
  924. struct mpc_config_intsrc *irq = mp_irqs + idx;
  925. /* Do we already have a mapping for this ISA IRQ? */
  926. if (irq->mpc_srcbus == MP_ISA_BUS && irq->mpc_srcbusirq == i)
  927. break;
  928. /* Do we already have a mapping for this IOAPIC pin */
  929. if ((irq->mpc_dstapic == intsrc.mpc_dstapic) &&
  930. (irq->mpc_dstirq == i))
  931. break;
  932. }
  933. if (idx != mp_irq_entries) {
  934. printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
  935. continue; /* IRQ already used */
  936. }
  937. intsrc.mpc_irqtype = mp_INT;
  938. intsrc.mpc_srcbusirq = i; /* Identity mapped */
  939. intsrc.mpc_dstirq = i;
  940. Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
  941. "%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
  942. (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
  943. intsrc.mpc_srcbusirq, intsrc.mpc_dstapic,
  944. intsrc.mpc_dstirq);
  945. mp_irqs[mp_irq_entries] = intsrc;
  946. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  947. panic("Max # of irq sources exceeded!\n");
  948. }
  949. }
  950. #define MAX_GSI_NUM 4096
  951. #define IRQ_COMPRESSION_START 64
  952. int mp_register_gsi(u32 gsi, int triggering, int polarity)
  953. {
  954. int ioapic = -1;
  955. int ioapic_pin = 0;
  956. int idx, bit = 0;
  957. static int pci_irq = IRQ_COMPRESSION_START;
  958. /*
  959. * Mapping between Global System Interrupts, which
  960. * represent all possible interrupts, and IRQs
  961. * assigned to actual devices.
  962. */
  963. static int gsi_to_irq[MAX_GSI_NUM];
  964. /* Don't set up the ACPI SCI because it's already set up */
  965. if (acpi_gbl_FADT.sci_interrupt == gsi)
  966. return gsi;
  967. ioapic = mp_find_ioapic(gsi);
  968. if (ioapic < 0) {
  969. printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
  970. return gsi;
  971. }
  972. ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  973. if (ioapic_renumber_irq)
  974. gsi = ioapic_renumber_irq(ioapic, gsi);
  975. /*
  976. * Avoid pin reprogramming. PRTs typically include entries
  977. * with redundant pin->gsi mappings (but unique PCI devices);
  978. * we only program the IOAPIC on the first.
  979. */
  980. bit = ioapic_pin % 32;
  981. idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
  982. if (idx > 3) {
  983. printk(KERN_ERR "Invalid reference to IOAPIC pin "
  984. "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
  985. ioapic_pin);
  986. return gsi;
  987. }
  988. if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
  989. Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
  990. mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
  991. return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
  992. }
  993. mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
  994. /*
  995. * For GSI >= 64, use IRQ compression
  996. */
  997. if ((gsi >= IRQ_COMPRESSION_START)
  998. && (triggering == ACPI_LEVEL_SENSITIVE)) {
  999. /*
  1000. * For PCI devices assign IRQs in order, avoiding gaps
  1001. * due to unused I/O APIC pins.
  1002. */
  1003. int irq = gsi;
  1004. if (gsi < MAX_GSI_NUM) {
  1005. /*
  1006. * Retain the VIA chipset work-around (gsi > 15), but
  1007. * avoid a problem where the 8254 timer (IRQ0) is setup
  1008. * via an override (so it's not on pin 0 of the ioapic),
  1009. * and at the same time, the pin 0 interrupt is a PCI
  1010. * type. The gsi > 15 test could cause these two pins
  1011. * to be shared as IRQ0, and they are not shareable.
  1012. * So test for this condition, and if necessary, avoid
  1013. * the pin collision.
  1014. */
  1015. gsi = pci_irq++;
  1016. /*
  1017. * Don't assign IRQ used by ACPI SCI
  1018. */
  1019. if (gsi == acpi_gbl_FADT.sci_interrupt)
  1020. gsi = pci_irq++;
  1021. gsi_to_irq[irq] = gsi;
  1022. } else {
  1023. printk(KERN_ERR "GSI %u is too high\n", gsi);
  1024. return gsi;
  1025. }
  1026. }
  1027. io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
  1028. triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
  1029. polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
  1030. return gsi;
  1031. }
  1032. #endif /* CONFIG_X86_IO_APIC */
  1033. #endif /* CONFIG_ACPI */