irq.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. /*
  2. * Low-Level PCI Support for PC -- Routing of Interrupts
  3. *
  4. * (c) 1999--2000 Martin Mares <mj@ucw.cz>
  5. */
  6. #include <linux/config.h>
  7. #include <linux/types.h>
  8. #include <linux/kernel.h>
  9. #include <linux/pci.h>
  10. #include <linux/init.h>
  11. #include <linux/slab.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/irq.h>
  14. #include <linux/dmi.h>
  15. #include <asm/io.h>
  16. #include <asm/smp.h>
  17. #include <asm/io_apic.h>
  18. #include <asm/hw_irq.h>
  19. #include <linux/acpi.h>
  20. #include "pci.h"
  21. #define PIRQ_SIGNATURE (('$' << 0) + ('P' << 8) + ('I' << 16) + ('R' << 24))
  22. #define PIRQ_VERSION 0x0100
  23. static int broken_hp_bios_irq9;
  24. static int acer_tm360_irqrouting;
  25. static struct irq_routing_table *pirq_table;
  26. static int pirq_enable_irq(struct pci_dev *dev);
  27. /*
  28. * Never use: 0, 1, 2 (timer, keyboard, and cascade)
  29. * Avoid using: 13, 14 and 15 (FP error and IDE).
  30. * Penalize: 3, 4, 6, 7, 12 (known ISA uses: serial, floppy, parallel and mouse)
  31. */
  32. unsigned int pcibios_irq_mask = 0xfff8;
  33. static int pirq_penalty[16] = {
  34. 1000000, 1000000, 1000000, 1000, 1000, 0, 1000, 1000,
  35. 0, 0, 0, 0, 1000, 100000, 100000, 100000
  36. };
  37. struct irq_router {
  38. char *name;
  39. u16 vendor, device;
  40. int (*get)(struct pci_dev *router, struct pci_dev *dev, int pirq);
  41. int (*set)(struct pci_dev *router, struct pci_dev *dev, int pirq, int new);
  42. };
  43. struct irq_router_handler {
  44. u16 vendor;
  45. int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
  46. };
  47. int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL;
  48. void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
  49. /*
  50. * Check passed address for the PCI IRQ Routing Table signature
  51. * and perform checksum verification.
  52. */
  53. static inline struct irq_routing_table * pirq_check_routing_table(u8 *addr)
  54. {
  55. struct irq_routing_table *rt;
  56. int i;
  57. u8 sum;
  58. rt = (struct irq_routing_table *) addr;
  59. if (rt->signature != PIRQ_SIGNATURE ||
  60. rt->version != PIRQ_VERSION ||
  61. rt->size % 16 ||
  62. rt->size < sizeof(struct irq_routing_table))
  63. return NULL;
  64. sum = 0;
  65. for (i=0; i < rt->size; i++)
  66. sum += addr[i];
  67. if (!sum) {
  68. DBG("PCI: Interrupt Routing Table found at 0x%p\n", rt);
  69. return rt;
  70. }
  71. return NULL;
  72. }
  73. /*
  74. * Search 0xf0000 -- 0xfffff for the PCI IRQ Routing Table.
  75. */
  76. static struct irq_routing_table * __init pirq_find_routing_table(void)
  77. {
  78. u8 *addr;
  79. struct irq_routing_table *rt;
  80. if (pirq_table_addr) {
  81. rt = pirq_check_routing_table((u8 *) __va(pirq_table_addr));
  82. if (rt)
  83. return rt;
  84. printk(KERN_WARNING "PCI: PIRQ table NOT found at pirqaddr\n");
  85. }
  86. for(addr = (u8 *) __va(0xf0000); addr < (u8 *) __va(0x100000); addr += 16) {
  87. rt = pirq_check_routing_table(addr);
  88. if (rt)
  89. return rt;
  90. }
  91. return NULL;
  92. }
  93. /*
  94. * If we have a IRQ routing table, use it to search for peer host
  95. * bridges. It's a gross hack, but since there are no other known
  96. * ways how to get a list of buses, we have to go this way.
  97. */
  98. static void __init pirq_peer_trick(void)
  99. {
  100. struct irq_routing_table *rt = pirq_table;
  101. u8 busmap[256];
  102. int i;
  103. struct irq_info *e;
  104. memset(busmap, 0, sizeof(busmap));
  105. for(i=0; i < (rt->size - sizeof(struct irq_routing_table)) / sizeof(struct irq_info); i++) {
  106. e = &rt->slots[i];
  107. #ifdef DEBUG
  108. {
  109. int j;
  110. DBG("%02x:%02x slot=%02x", e->bus, e->devfn/8, e->slot);
  111. for(j=0; j<4; j++)
  112. DBG(" %d:%02x/%04x", j, e->irq[j].link, e->irq[j].bitmap);
  113. DBG("\n");
  114. }
  115. #endif
  116. busmap[e->bus] = 1;
  117. }
  118. for(i = 1; i < 256; i++) {
  119. if (!busmap[i] || pci_find_bus(0, i))
  120. continue;
  121. if (pci_scan_bus(i, &pci_root_ops, NULL))
  122. printk(KERN_INFO "PCI: Discovered primary peer bus %02x [IRQ]\n", i);
  123. }
  124. pcibios_last_bus = -1;
  125. }
  126. /*
  127. * Code for querying and setting of IRQ routes on various interrupt routers.
  128. */
  129. void eisa_set_level_irq(unsigned int irq)
  130. {
  131. unsigned char mask = 1 << (irq & 7);
  132. unsigned int port = 0x4d0 + (irq >> 3);
  133. unsigned char val;
  134. static u16 eisa_irq_mask;
  135. if (irq >= 16 || (1 << irq) & eisa_irq_mask)
  136. return;
  137. eisa_irq_mask |= (1 << irq);
  138. printk("PCI: setting IRQ %u as level-triggered\n", irq);
  139. val = inb(port);
  140. if (!(val & mask)) {
  141. DBG(" -> edge");
  142. outb(val | mask, port);
  143. }
  144. }
  145. /*
  146. * Common IRQ routing practice: nybbles in config space,
  147. * offset by some magic constant.
  148. */
  149. static unsigned int read_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr)
  150. {
  151. u8 x;
  152. unsigned reg = offset + (nr >> 1);
  153. pci_read_config_byte(router, reg, &x);
  154. return (nr & 1) ? (x >> 4) : (x & 0xf);
  155. }
  156. static void write_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr, unsigned int val)
  157. {
  158. u8 x;
  159. unsigned reg = offset + (nr >> 1);
  160. pci_read_config_byte(router, reg, &x);
  161. x = (nr & 1) ? ((x & 0x0f) | (val << 4)) : ((x & 0xf0) | val);
  162. pci_write_config_byte(router, reg, x);
  163. }
  164. /*
  165. * ALI pirq entries are damn ugly, and completely undocumented.
  166. * This has been figured out from pirq tables, and it's not a pretty
  167. * picture.
  168. */
  169. static int pirq_ali_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  170. {
  171. static unsigned char irqmap[16] = { 0, 9, 3, 10, 4, 5, 7, 6, 1, 11, 0, 12, 0, 14, 0, 15 };
  172. return irqmap[read_config_nybble(router, 0x48, pirq-1)];
  173. }
  174. static int pirq_ali_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  175. {
  176. static unsigned char irqmap[16] = { 0, 8, 0, 2, 4, 5, 7, 6, 0, 1, 3, 9, 11, 0, 13, 15 };
  177. unsigned int val = irqmap[irq];
  178. if (val) {
  179. write_config_nybble(router, 0x48, pirq-1, val);
  180. return 1;
  181. }
  182. return 0;
  183. }
  184. /*
  185. * The Intel PIIX4 pirq rules are fairly simple: "pirq" is
  186. * just a pointer to the config space.
  187. */
  188. static int pirq_piix_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  189. {
  190. u8 x;
  191. pci_read_config_byte(router, pirq, &x);
  192. return (x < 16) ? x : 0;
  193. }
  194. static int pirq_piix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  195. {
  196. pci_write_config_byte(router, pirq, irq);
  197. return 1;
  198. }
  199. /*
  200. * The VIA pirq rules are nibble-based, like ALI,
  201. * but without the ugly irq number munging.
  202. * However, PIRQD is in the upper instead of lower 4 bits.
  203. */
  204. static int pirq_via_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  205. {
  206. return read_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq);
  207. }
  208. static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  209. {
  210. write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq);
  211. return 1;
  212. }
  213. /*
  214. * The VIA pirq rules are nibble-based, like ALI,
  215. * but without the ugly irq number munging.
  216. * However, for 82C586, nibble map is different .
  217. */
  218. static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  219. {
  220. static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
  221. return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
  222. }
  223. static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  224. {
  225. static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
  226. write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
  227. return 1;
  228. }
  229. /*
  230. * ITE 8330G pirq rules are nibble-based
  231. * FIXME: pirqmap may be { 1, 0, 3, 2 },
  232. * 2+3 are both mapped to irq 9 on my system
  233. */
  234. static int pirq_ite_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  235. {
  236. static unsigned char pirqmap[4] = { 1, 0, 2, 3 };
  237. return read_config_nybble(router,0x43, pirqmap[pirq-1]);
  238. }
  239. static int pirq_ite_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  240. {
  241. static unsigned char pirqmap[4] = { 1, 0, 2, 3 };
  242. write_config_nybble(router, 0x43, pirqmap[pirq-1], irq);
  243. return 1;
  244. }
  245. /*
  246. * OPTI: high four bits are nibble pointer..
  247. * I wonder what the low bits do?
  248. */
  249. static int pirq_opti_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  250. {
  251. return read_config_nybble(router, 0xb8, pirq >> 4);
  252. }
  253. static int pirq_opti_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  254. {
  255. write_config_nybble(router, 0xb8, pirq >> 4, irq);
  256. return 1;
  257. }
  258. /*
  259. * Cyrix: nibble offset 0x5C
  260. * 0x5C bits 7:4 is INTB bits 3:0 is INTA
  261. * 0x5D bits 7:4 is INTD bits 3:0 is INTC
  262. */
  263. static int pirq_cyrix_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  264. {
  265. return read_config_nybble(router, 0x5C, (pirq-1)^1);
  266. }
  267. static int pirq_cyrix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  268. {
  269. write_config_nybble(router, 0x5C, (pirq-1)^1, irq);
  270. return 1;
  271. }
  272. /*
  273. * PIRQ routing for SiS 85C503 router used in several SiS chipsets.
  274. * We have to deal with the following issues here:
  275. * - vendors have different ideas about the meaning of link values
  276. * - some onboard devices (integrated in the chipset) have special
  277. * links and are thus routed differently (i.e. not via PCI INTA-INTD)
  278. * - different revision of the router have a different layout for
  279. * the routing registers, particularly for the onchip devices
  280. *
  281. * For all routing registers the common thing is we have one byte
  282. * per routeable link which is defined as:
  283. * bit 7 IRQ mapping enabled (0) or disabled (1)
  284. * bits [6:4] reserved (sometimes used for onchip devices)
  285. * bits [3:0] IRQ to map to
  286. * allowed: 3-7, 9-12, 14-15
  287. * reserved: 0, 1, 2, 8, 13
  288. *
  289. * The config-space registers located at 0x41/0x42/0x43/0x44 are
  290. * always used to route the normal PCI INT A/B/C/D respectively.
  291. * Apparently there are systems implementing PCI routing table using
  292. * link values 0x01-0x04 and others using 0x41-0x44 for PCI INTA..D.
  293. * We try our best to handle both link mappings.
  294. *
  295. * Currently (2003-05-21) it appears most SiS chipsets follow the
  296. * definition of routing registers from the SiS-5595 southbridge.
  297. * According to the SiS 5595 datasheets the revision id's of the
  298. * router (ISA-bridge) should be 0x01 or 0xb0.
  299. *
  300. * Furthermore we've also seen lspci dumps with revision 0x00 and 0xb1.
  301. * Looks like these are used in a number of SiS 5xx/6xx/7xx chipsets.
  302. * They seem to work with the current routing code. However there is
  303. * some concern because of the two USB-OHCI HCs (original SiS 5595
  304. * had only one). YMMV.
  305. *
  306. * Onchip routing for router rev-id 0x01/0xb0 and probably 0x00/0xb1:
  307. *
  308. * 0x61: IDEIRQ:
  309. * bits [6:5] must be written 01
  310. * bit 4 channel-select primary (0), secondary (1)
  311. *
  312. * 0x62: USBIRQ:
  313. * bit 6 OHCI function disabled (0), enabled (1)
  314. *
  315. * 0x6a: ACPI/SCI IRQ: bits 4-6 reserved
  316. *
  317. * 0x7e: Data Acq. Module IRQ - bits 4-6 reserved
  318. *
  319. * We support USBIRQ (in addition to INTA-INTD) and keep the
  320. * IDE, ACPI and DAQ routing untouched as set by the BIOS.
  321. *
  322. * Currently the only reported exception is the new SiS 65x chipset
  323. * which includes the SiS 69x southbridge. Here we have the 85C503
  324. * router revision 0x04 and there are changes in the register layout
  325. * mostly related to the different USB HCs with USB 2.0 support.
  326. *
  327. * Onchip routing for router rev-id 0x04 (try-and-error observation)
  328. *
  329. * 0x60/0x61/0x62/0x63: 1xEHCI and 3xOHCI (companion) USB-HCs
  330. * bit 6-4 are probably unused, not like 5595
  331. */
  332. #define PIRQ_SIS_IRQ_MASK 0x0f
  333. #define PIRQ_SIS_IRQ_DISABLE 0x80
  334. #define PIRQ_SIS_USB_ENABLE 0x40
  335. static int pirq_sis_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  336. {
  337. u8 x;
  338. int reg;
  339. reg = pirq;
  340. if (reg >= 0x01 && reg <= 0x04)
  341. reg += 0x40;
  342. pci_read_config_byte(router, reg, &x);
  343. return (x & PIRQ_SIS_IRQ_DISABLE) ? 0 : (x & PIRQ_SIS_IRQ_MASK);
  344. }
  345. static int pirq_sis_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  346. {
  347. u8 x;
  348. int reg;
  349. reg = pirq;
  350. if (reg >= 0x01 && reg <= 0x04)
  351. reg += 0x40;
  352. pci_read_config_byte(router, reg, &x);
  353. x &= ~(PIRQ_SIS_IRQ_MASK | PIRQ_SIS_IRQ_DISABLE);
  354. x |= irq ? irq: PIRQ_SIS_IRQ_DISABLE;
  355. pci_write_config_byte(router, reg, x);
  356. return 1;
  357. }
  358. /*
  359. * VLSI: nibble offset 0x74 - educated guess due to routing table and
  360. * config space of VLSI 82C534 PCI-bridge/router (1004:0102)
  361. * Tested on HP OmniBook 800 covering PIRQ 1, 2, 4, 8 for onboard
  362. * devices, PIRQ 3 for non-pci(!) soundchip and (untested) PIRQ 6
  363. * for the busbridge to the docking station.
  364. */
  365. static int pirq_vlsi_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  366. {
  367. if (pirq > 8) {
  368. printk(KERN_INFO "VLSI router pirq escape (%d)\n", pirq);
  369. return 0;
  370. }
  371. return read_config_nybble(router, 0x74, pirq-1);
  372. }
  373. static int pirq_vlsi_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  374. {
  375. if (pirq > 8) {
  376. printk(KERN_INFO "VLSI router pirq escape (%d)\n", pirq);
  377. return 0;
  378. }
  379. write_config_nybble(router, 0x74, pirq-1, irq);
  380. return 1;
  381. }
  382. /*
  383. * ServerWorks: PCI interrupts mapped to system IRQ lines through Index
  384. * and Redirect I/O registers (0x0c00 and 0x0c01). The Index register
  385. * format is (PCIIRQ## | 0x10), e.g.: PCIIRQ10=0x1a. The Redirect
  386. * register is a straight binary coding of desired PIC IRQ (low nibble).
  387. *
  388. * The 'link' value in the PIRQ table is already in the correct format
  389. * for the Index register. There are some special index values:
  390. * 0x00 for ACPI (SCI), 0x01 for USB, 0x02 for IDE0, 0x04 for IDE1,
  391. * and 0x03 for SMBus.
  392. */
  393. static int pirq_serverworks_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  394. {
  395. outb_p(pirq, 0xc00);
  396. return inb(0xc01) & 0xf;
  397. }
  398. static int pirq_serverworks_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  399. {
  400. outb_p(pirq, 0xc00);
  401. outb_p(irq, 0xc01);
  402. return 1;
  403. }
  404. /* Support for AMD756 PCI IRQ Routing
  405. * Jhon H. Caicedo <jhcaiced@osso.org.co>
  406. * Jun/21/2001 0.2.0 Release, fixed to use "nybble" functions... (jhcaiced)
  407. * Jun/19/2001 Alpha Release 0.1.0 (jhcaiced)
  408. * The AMD756 pirq rules are nibble-based
  409. * offset 0x56 0-3 PIRQA 4-7 PIRQB
  410. * offset 0x57 0-3 PIRQC 4-7 PIRQD
  411. */
  412. static int pirq_amd756_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  413. {
  414. u8 irq;
  415. irq = 0;
  416. if (pirq <= 4)
  417. {
  418. irq = read_config_nybble(router, 0x56, pirq - 1);
  419. }
  420. printk(KERN_INFO "AMD756: dev %04x:%04x, router pirq : %d get irq : %2d\n",
  421. dev->vendor, dev->device, pirq, irq);
  422. return irq;
  423. }
  424. static int pirq_amd756_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  425. {
  426. printk(KERN_INFO "AMD756: dev %04x:%04x, router pirq : %d SET irq : %2d\n",
  427. dev->vendor, dev->device, pirq, irq);
  428. if (pirq <= 4)
  429. {
  430. write_config_nybble(router, 0x56, pirq - 1, irq);
  431. }
  432. return 1;
  433. }
  434. #ifdef CONFIG_PCI_BIOS
  435. static int pirq_bios_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  436. {
  437. struct pci_dev *bridge;
  438. int pin = pci_get_interrupt_pin(dev, &bridge);
  439. return pcibios_set_irq_routing(bridge, pin, irq);
  440. }
  441. #endif
  442. static __init int intel_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  443. {
  444. static struct pci_device_id pirq_440gx[] = {
  445. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0) },
  446. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_2) },
  447. { },
  448. };
  449. /* 440GX has a proprietary PIRQ router -- don't use it */
  450. if (pci_dev_present(pirq_440gx))
  451. return 0;
  452. switch(device)
  453. {
  454. case PCI_DEVICE_ID_INTEL_82371FB_0:
  455. case PCI_DEVICE_ID_INTEL_82371SB_0:
  456. case PCI_DEVICE_ID_INTEL_82371AB_0:
  457. case PCI_DEVICE_ID_INTEL_82371MX:
  458. case PCI_DEVICE_ID_INTEL_82443MX_0:
  459. case PCI_DEVICE_ID_INTEL_82801AA_0:
  460. case PCI_DEVICE_ID_INTEL_82801AB_0:
  461. case PCI_DEVICE_ID_INTEL_82801BA_0:
  462. case PCI_DEVICE_ID_INTEL_82801BA_10:
  463. case PCI_DEVICE_ID_INTEL_82801CA_0:
  464. case PCI_DEVICE_ID_INTEL_82801CA_12:
  465. case PCI_DEVICE_ID_INTEL_82801DB_0:
  466. case PCI_DEVICE_ID_INTEL_82801E_0:
  467. case PCI_DEVICE_ID_INTEL_82801EB_0:
  468. case PCI_DEVICE_ID_INTEL_ESB_1:
  469. case PCI_DEVICE_ID_INTEL_ICH6_0:
  470. case PCI_DEVICE_ID_INTEL_ICH6_1:
  471. case PCI_DEVICE_ID_INTEL_ICH7_0:
  472. case PCI_DEVICE_ID_INTEL_ICH7_1:
  473. case PCI_DEVICE_ID_INTEL_ICH7_30:
  474. case PCI_DEVICE_ID_INTEL_ICH7_31:
  475. case PCI_DEVICE_ID_INTEL_ESB2_0:
  476. r->name = "PIIX/ICH";
  477. r->get = pirq_piix_get;
  478. r->set = pirq_piix_set;
  479. return 1;
  480. }
  481. return 0;
  482. }
  483. static __init int via_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  484. {
  485. /* FIXME: We should move some of the quirk fixup stuff here */
  486. if (router->device == PCI_DEVICE_ID_VIA_82C686 &&
  487. device == PCI_DEVICE_ID_VIA_82C586_0) {
  488. /* Asus k7m bios wrongly reports 82C686A as 586-compatible */
  489. device = PCI_DEVICE_ID_VIA_82C686;
  490. }
  491. switch(device)
  492. {
  493. case PCI_DEVICE_ID_VIA_82C586_0:
  494. r->name = "VIA";
  495. r->get = pirq_via586_get;
  496. r->set = pirq_via586_set;
  497. return 1;
  498. case PCI_DEVICE_ID_VIA_82C596:
  499. case PCI_DEVICE_ID_VIA_82C686:
  500. case PCI_DEVICE_ID_VIA_8231:
  501. /* FIXME: add new ones for 8233/5 */
  502. r->name = "VIA";
  503. r->get = pirq_via_get;
  504. r->set = pirq_via_set;
  505. return 1;
  506. }
  507. return 0;
  508. }
  509. static __init int vlsi_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  510. {
  511. switch(device)
  512. {
  513. case PCI_DEVICE_ID_VLSI_82C534:
  514. r->name = "VLSI 82C534";
  515. r->get = pirq_vlsi_get;
  516. r->set = pirq_vlsi_set;
  517. return 1;
  518. }
  519. return 0;
  520. }
  521. static __init int serverworks_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  522. {
  523. switch(device)
  524. {
  525. case PCI_DEVICE_ID_SERVERWORKS_OSB4:
  526. case PCI_DEVICE_ID_SERVERWORKS_CSB5:
  527. r->name = "ServerWorks";
  528. r->get = pirq_serverworks_get;
  529. r->set = pirq_serverworks_set;
  530. return 1;
  531. }
  532. return 0;
  533. }
  534. static __init int sis_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  535. {
  536. if (device != PCI_DEVICE_ID_SI_503)
  537. return 0;
  538. r->name = "SIS";
  539. r->get = pirq_sis_get;
  540. r->set = pirq_sis_set;
  541. return 1;
  542. }
  543. static __init int cyrix_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  544. {
  545. switch(device)
  546. {
  547. case PCI_DEVICE_ID_CYRIX_5520:
  548. r->name = "NatSemi";
  549. r->get = pirq_cyrix_get;
  550. r->set = pirq_cyrix_set;
  551. return 1;
  552. }
  553. return 0;
  554. }
  555. static __init int opti_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  556. {
  557. switch(device)
  558. {
  559. case PCI_DEVICE_ID_OPTI_82C700:
  560. r->name = "OPTI";
  561. r->get = pirq_opti_get;
  562. r->set = pirq_opti_set;
  563. return 1;
  564. }
  565. return 0;
  566. }
  567. static __init int ite_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  568. {
  569. switch(device)
  570. {
  571. case PCI_DEVICE_ID_ITE_IT8330G_0:
  572. r->name = "ITE";
  573. r->get = pirq_ite_get;
  574. r->set = pirq_ite_set;
  575. return 1;
  576. }
  577. return 0;
  578. }
  579. static __init int ali_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  580. {
  581. switch(device)
  582. {
  583. case PCI_DEVICE_ID_AL_M1533:
  584. case PCI_DEVICE_ID_AL_M1563:
  585. printk("PCI: Using ALI IRQ Router\n");
  586. r->name = "ALI";
  587. r->get = pirq_ali_get;
  588. r->set = pirq_ali_set;
  589. return 1;
  590. }
  591. return 0;
  592. }
  593. static __init int amd_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  594. {
  595. switch(device)
  596. {
  597. case PCI_DEVICE_ID_AMD_VIPER_740B:
  598. r->name = "AMD756";
  599. break;
  600. case PCI_DEVICE_ID_AMD_VIPER_7413:
  601. r->name = "AMD766";
  602. break;
  603. case PCI_DEVICE_ID_AMD_VIPER_7443:
  604. r->name = "AMD768";
  605. break;
  606. default:
  607. return 0;
  608. }
  609. r->get = pirq_amd756_get;
  610. r->set = pirq_amd756_set;
  611. return 1;
  612. }
  613. static __initdata struct irq_router_handler pirq_routers[] = {
  614. { PCI_VENDOR_ID_INTEL, intel_router_probe },
  615. { PCI_VENDOR_ID_AL, ali_router_probe },
  616. { PCI_VENDOR_ID_ITE, ite_router_probe },
  617. { PCI_VENDOR_ID_VIA, via_router_probe },
  618. { PCI_VENDOR_ID_OPTI, opti_router_probe },
  619. { PCI_VENDOR_ID_SI, sis_router_probe },
  620. { PCI_VENDOR_ID_CYRIX, cyrix_router_probe },
  621. { PCI_VENDOR_ID_VLSI, vlsi_router_probe },
  622. { PCI_VENDOR_ID_SERVERWORKS, serverworks_router_probe },
  623. { PCI_VENDOR_ID_AMD, amd_router_probe },
  624. /* Someone with docs needs to add the ATI Radeon IGP */
  625. { 0, NULL }
  626. };
  627. static struct irq_router pirq_router;
  628. static struct pci_dev *pirq_router_dev;
  629. /*
  630. * FIXME: should we have an option to say "generic for
  631. * chipset" ?
  632. */
  633. static void __init pirq_find_router(struct irq_router *r)
  634. {
  635. struct irq_routing_table *rt = pirq_table;
  636. struct irq_router_handler *h;
  637. #ifdef CONFIG_PCI_BIOS
  638. if (!rt->signature) {
  639. printk(KERN_INFO "PCI: Using BIOS for IRQ routing\n");
  640. r->set = pirq_bios_set;
  641. r->name = "BIOS";
  642. return;
  643. }
  644. #endif
  645. /* Default unless a driver reloads it */
  646. r->name = "default";
  647. r->get = NULL;
  648. r->set = NULL;
  649. DBG("PCI: Attempting to find IRQ router for %04x:%04x\n",
  650. rt->rtr_vendor, rt->rtr_device);
  651. pirq_router_dev = pci_find_slot(rt->rtr_bus, rt->rtr_devfn);
  652. if (!pirq_router_dev) {
  653. DBG("PCI: Interrupt router not found at %02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
  654. return;
  655. }
  656. for( h = pirq_routers; h->vendor; h++) {
  657. /* First look for a router match */
  658. if (rt->rtr_vendor == h->vendor && h->probe(r, pirq_router_dev, rt->rtr_device))
  659. break;
  660. /* Fall back to a device match */
  661. if (pirq_router_dev->vendor == h->vendor && h->probe(r, pirq_router_dev, pirq_router_dev->device))
  662. break;
  663. }
  664. printk(KERN_INFO "PCI: Using IRQ router %s [%04x/%04x] at %s\n",
  665. pirq_router.name,
  666. pirq_router_dev->vendor,
  667. pirq_router_dev->device,
  668. pci_name(pirq_router_dev));
  669. }
  670. static struct irq_info *pirq_get_info(struct pci_dev *dev)
  671. {
  672. struct irq_routing_table *rt = pirq_table;
  673. int entries = (rt->size - sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
  674. struct irq_info *info;
  675. for (info = rt->slots; entries--; info++)
  676. if (info->bus == dev->bus->number && PCI_SLOT(info->devfn) == PCI_SLOT(dev->devfn))
  677. return info;
  678. return NULL;
  679. }
  680. static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
  681. {
  682. u8 pin;
  683. struct irq_info *info;
  684. int i, pirq, newirq;
  685. int irq = 0;
  686. u32 mask;
  687. struct irq_router *r = &pirq_router;
  688. struct pci_dev *dev2 = NULL;
  689. char *msg = NULL;
  690. /* Find IRQ pin */
  691. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  692. if (!pin) {
  693. DBG(" -> no interrupt pin\n");
  694. return 0;
  695. }
  696. pin = pin - 1;
  697. /* Find IRQ routing entry */
  698. if (!pirq_table)
  699. return 0;
  700. DBG("IRQ for %s[%c]", pci_name(dev), 'A' + pin);
  701. info = pirq_get_info(dev);
  702. if (!info) {
  703. DBG(" -> not found in routing table\n");
  704. return 0;
  705. }
  706. pirq = info->irq[pin].link;
  707. mask = info->irq[pin].bitmap;
  708. if (!pirq) {
  709. DBG(" -> not routed\n");
  710. return 0;
  711. }
  712. DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask, pirq_table->exclusive_irqs);
  713. mask &= pcibios_irq_mask;
  714. /* Work around broken HP Pavilion Notebooks which assign USB to
  715. IRQ 9 even though it is actually wired to IRQ 11 */
  716. if (broken_hp_bios_irq9 && pirq == 0x59 && dev->irq == 9) {
  717. dev->irq = 11;
  718. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
  719. r->set(pirq_router_dev, dev, pirq, 11);
  720. }
  721. /* same for Acer Travelmate 360, but with CB and irq 11 -> 10 */
  722. if (acer_tm360_irqrouting && dev->irq == 11 && dev->vendor == PCI_VENDOR_ID_O2) {
  723. pirq = 0x68;
  724. mask = 0x400;
  725. dev->irq = r->get(pirq_router_dev, dev, pirq);
  726. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  727. }
  728. /*
  729. * Find the best IRQ to assign: use the one
  730. * reported by the device if possible.
  731. */
  732. newirq = dev->irq;
  733. if (!((1 << newirq) & mask)) {
  734. if ( pci_probe & PCI_USE_PIRQ_MASK) newirq = 0;
  735. else printk(KERN_WARNING "PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n", newirq, pci_name(dev));
  736. }
  737. if (!newirq && assign) {
  738. for (i = 0; i < 16; i++) {
  739. if (!(mask & (1 << i)))
  740. continue;
  741. if (pirq_penalty[i] < pirq_penalty[newirq] && can_request_irq(i, SA_SHIRQ))
  742. newirq = i;
  743. }
  744. }
  745. DBG(" -> newirq=%d", newirq);
  746. /* Check if it is hardcoded */
  747. if ((pirq & 0xf0) == 0xf0) {
  748. irq = pirq & 0xf;
  749. DBG(" -> hardcoded IRQ %d\n", irq);
  750. msg = "Hardcoded";
  751. } else if ( r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \
  752. ((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask)) ) {
  753. DBG(" -> got IRQ %d\n", irq);
  754. msg = "Found";
  755. } else if (newirq && r->set && (dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) {
  756. DBG(" -> assigning IRQ %d", newirq);
  757. if (r->set(pirq_router_dev, dev, pirq, newirq)) {
  758. eisa_set_level_irq(newirq);
  759. DBG(" ... OK\n");
  760. msg = "Assigned";
  761. irq = newirq;
  762. }
  763. }
  764. if (!irq) {
  765. DBG(" ... failed\n");
  766. if (newirq && mask == (1 << newirq)) {
  767. msg = "Guessed";
  768. irq = newirq;
  769. } else
  770. return 0;
  771. }
  772. printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq, pci_name(dev));
  773. /* Update IRQ for all devices with the same pirq value */
  774. while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) {
  775. pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin);
  776. if (!pin)
  777. continue;
  778. pin--;
  779. info = pirq_get_info(dev2);
  780. if (!info)
  781. continue;
  782. if (info->irq[pin].link == pirq) {
  783. /* We refuse to override the dev->irq information. Give a warning! */
  784. if ( dev2->irq && dev2->irq != irq && \
  785. (!(pci_probe & PCI_USE_PIRQ_MASK) || \
  786. ((1 << dev2->irq) & mask)) ) {
  787. #ifndef CONFIG_PCI_MSI
  788. printk(KERN_INFO "IRQ routing conflict for %s, have irq %d, want irq %d\n",
  789. pci_name(dev2), dev2->irq, irq);
  790. #endif
  791. continue;
  792. }
  793. dev2->irq = irq;
  794. pirq_penalty[irq]++;
  795. if (dev != dev2)
  796. printk(KERN_INFO "PCI: Sharing IRQ %d with %s\n", irq, pci_name(dev2));
  797. }
  798. }
  799. return 1;
  800. }
  801. static void __init pcibios_fixup_irqs(void)
  802. {
  803. struct pci_dev *dev = NULL;
  804. u8 pin;
  805. DBG("PCI: IRQ fixup\n");
  806. while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
  807. /*
  808. * If the BIOS has set an out of range IRQ number, just ignore it.
  809. * Also keep track of which IRQ's are already in use.
  810. */
  811. if (dev->irq >= 16) {
  812. DBG("%s: ignoring bogus IRQ %d\n", pci_name(dev), dev->irq);
  813. dev->irq = 0;
  814. }
  815. /* If the IRQ is already assigned to a PCI device, ignore its ISA use penalty */
  816. if (pirq_penalty[dev->irq] >= 100 && pirq_penalty[dev->irq] < 100000)
  817. pirq_penalty[dev->irq] = 0;
  818. pirq_penalty[dev->irq]++;
  819. }
  820. dev = NULL;
  821. while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
  822. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  823. #ifdef CONFIG_X86_IO_APIC
  824. /*
  825. * Recalculate IRQ numbers if we use the I/O APIC.
  826. */
  827. if (io_apic_assign_pci_irqs)
  828. {
  829. int irq;
  830. if (pin) {
  831. pin--; /* interrupt pins are numbered starting from 1 */
  832. irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, PCI_SLOT(dev->devfn), pin);
  833. /*
  834. * Busses behind bridges are typically not listed in the MP-table.
  835. * In this case we have to look up the IRQ based on the parent bus,
  836. * parent slot, and pin number. The SMP code detects such bridged
  837. * busses itself so we should get into this branch reliably.
  838. */
  839. if (irq < 0 && dev->bus->parent) { /* go back to the bridge */
  840. struct pci_dev * bridge = dev->bus->self;
  841. pin = (pin + PCI_SLOT(dev->devfn)) % 4;
  842. irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
  843. PCI_SLOT(bridge->devfn), pin);
  844. if (irq >= 0)
  845. printk(KERN_WARNING "PCI: using PPB %s[%c] to get irq %d\n",
  846. pci_name(bridge), 'A' + pin, irq);
  847. }
  848. if (irq >= 0) {
  849. if (use_pci_vector() &&
  850. !platform_legacy_irq(irq))
  851. irq = IO_APIC_VECTOR(irq);
  852. printk(KERN_INFO "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n",
  853. pci_name(dev), 'A' + pin, irq);
  854. dev->irq = irq;
  855. }
  856. }
  857. }
  858. #endif
  859. /*
  860. * Still no IRQ? Try to lookup one...
  861. */
  862. if (pin && !dev->irq)
  863. pcibios_lookup_irq(dev, 0);
  864. }
  865. }
  866. /*
  867. * Work around broken HP Pavilion Notebooks which assign USB to
  868. * IRQ 9 even though it is actually wired to IRQ 11
  869. */
  870. static int __init fix_broken_hp_bios_irq9(struct dmi_system_id *d)
  871. {
  872. if (!broken_hp_bios_irq9) {
  873. broken_hp_bios_irq9 = 1;
  874. printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", d->ident);
  875. }
  876. return 0;
  877. }
  878. /*
  879. * Work around broken Acer TravelMate 360 Notebooks which assign
  880. * Cardbus to IRQ 11 even though it is actually wired to IRQ 10
  881. */
  882. static int __init fix_acer_tm360_irqrouting(struct dmi_system_id *d)
  883. {
  884. if (!acer_tm360_irqrouting) {
  885. acer_tm360_irqrouting = 1;
  886. printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", d->ident);
  887. }
  888. return 0;
  889. }
  890. static struct dmi_system_id __initdata pciirq_dmi_table[] = {
  891. {
  892. .callback = fix_broken_hp_bios_irq9,
  893. .ident = "HP Pavilion N5400 Series Laptop",
  894. .matches = {
  895. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  896. DMI_MATCH(DMI_BIOS_VERSION, "GE.M1.03"),
  897. DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook Model GE"),
  898. DMI_MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736"),
  899. },
  900. },
  901. {
  902. .callback = fix_acer_tm360_irqrouting,
  903. .ident = "Acer TravelMate 36x Laptop",
  904. .matches = {
  905. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  906. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  907. },
  908. },
  909. { }
  910. };
  911. static int __init pcibios_irq_init(void)
  912. {
  913. DBG("PCI: IRQ init\n");
  914. if (pcibios_enable_irq || raw_pci_ops == NULL)
  915. return 0;
  916. dmi_check_system(pciirq_dmi_table);
  917. pirq_table = pirq_find_routing_table();
  918. #ifdef CONFIG_PCI_BIOS
  919. if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN))
  920. pirq_table = pcibios_get_irq_routing_table();
  921. #endif
  922. if (pirq_table) {
  923. pirq_peer_trick();
  924. pirq_find_router(&pirq_router);
  925. if (pirq_table->exclusive_irqs) {
  926. int i;
  927. for (i=0; i<16; i++)
  928. if (!(pirq_table->exclusive_irqs & (1 << i)))
  929. pirq_penalty[i] += 100;
  930. }
  931. /* If we're using the I/O APIC, avoid using the PCI IRQ routing table */
  932. if (io_apic_assign_pci_irqs)
  933. pirq_table = NULL;
  934. }
  935. pcibios_enable_irq = pirq_enable_irq;
  936. pcibios_fixup_irqs();
  937. return 0;
  938. }
  939. subsys_initcall(pcibios_irq_init);
  940. static void pirq_penalize_isa_irq(int irq, int active)
  941. {
  942. /*
  943. * If any ISAPnP device reports an IRQ in its list of possible
  944. * IRQ's, we try to avoid assigning it to PCI devices.
  945. */
  946. if (irq < 16) {
  947. if (active)
  948. pirq_penalty[irq] += 1000;
  949. else
  950. pirq_penalty[irq] += 100;
  951. }
  952. }
  953. void pcibios_penalize_isa_irq(int irq, int active)
  954. {
  955. #ifdef CONFIG_ACPI
  956. if (!acpi_noirq)
  957. acpi_penalize_isa_irq(irq, active);
  958. else
  959. #endif
  960. pirq_penalize_isa_irq(irq, active);
  961. }
  962. static int pirq_enable_irq(struct pci_dev *dev)
  963. {
  964. u8 pin;
  965. struct pci_dev *temp_dev;
  966. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  967. if (pin && !pcibios_lookup_irq(dev, 1) && !dev->irq) {
  968. char *msg = "";
  969. pin--; /* interrupt pins are numbered starting from 1 */
  970. if (io_apic_assign_pci_irqs) {
  971. int irq;
  972. irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, PCI_SLOT(dev->devfn), pin);
  973. /*
  974. * Busses behind bridges are typically not listed in the MP-table.
  975. * In this case we have to look up the IRQ based on the parent bus,
  976. * parent slot, and pin number. The SMP code detects such bridged
  977. * busses itself so we should get into this branch reliably.
  978. */
  979. temp_dev = dev;
  980. while (irq < 0 && dev->bus->parent) { /* go back to the bridge */
  981. struct pci_dev * bridge = dev->bus->self;
  982. pin = (pin + PCI_SLOT(dev->devfn)) % 4;
  983. irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
  984. PCI_SLOT(bridge->devfn), pin);
  985. if (irq >= 0)
  986. printk(KERN_WARNING "PCI: using PPB %s[%c] to get irq %d\n",
  987. pci_name(bridge), 'A' + pin, irq);
  988. dev = bridge;
  989. }
  990. dev = temp_dev;
  991. if (irq >= 0) {
  992. #ifdef CONFIG_PCI_MSI
  993. if (!platform_legacy_irq(irq))
  994. irq = IO_APIC_VECTOR(irq);
  995. #endif
  996. printk(KERN_INFO "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n",
  997. pci_name(dev), 'A' + pin, irq);
  998. dev->irq = irq;
  999. return 0;
  1000. } else
  1001. msg = " Probably buggy MP table.";
  1002. } else if (pci_probe & PCI_BIOS_IRQ_SCAN)
  1003. msg = "";
  1004. else
  1005. msg = " Please try using pci=biosirq.";
  1006. /* With IDE legacy devices the IRQ lookup failure is not a problem.. */
  1007. if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE && !(dev->class & 0x5))
  1008. return 0;
  1009. printk(KERN_WARNING "PCI: No IRQ known for interrupt pin %c of device %s.%s\n",
  1010. 'A' + pin, pci_name(dev), msg);
  1011. }
  1012. return 0;
  1013. }
  1014. int pci_vector_resources(int last, int nr_released)
  1015. {
  1016. int count = nr_released;
  1017. int next = last;
  1018. int offset = (last % 8);
  1019. while (next < FIRST_SYSTEM_VECTOR) {
  1020. next += 8;
  1021. #ifdef CONFIG_X86_64
  1022. if (next == IA32_SYSCALL_VECTOR)
  1023. continue;
  1024. #else
  1025. if (next == SYSCALL_VECTOR)
  1026. continue;
  1027. #endif
  1028. count++;
  1029. if (next >= FIRST_SYSTEM_VECTOR) {
  1030. if (offset%8) {
  1031. next = FIRST_DEVICE_VECTOR + offset;
  1032. offset++;
  1033. continue;
  1034. }
  1035. count--;
  1036. }
  1037. }
  1038. return count;
  1039. }