mpparse_32.c 31 KB

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