ataints.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /*
  2. * arch/m68k/atari/ataints.c -- Atari Linux interrupt handling code
  3. *
  4. * 5/2/94 Roman Hodek:
  5. * Added support for TT interrupts; setup for TT SCU (may someone has
  6. * twiddled there and we won't get the right interrupts :-()
  7. *
  8. * Major change: The device-independent code in m68k/ints.c didn't know
  9. * about non-autovec ints yet. It hardcoded the number of possible ints to
  10. * 7 (IRQ1...IRQ7). But the Atari has lots of non-autovec ints! I made the
  11. * number of possible ints a constant defined in interrupt.h, which is
  12. * 47 for the Atari. So we can call request_irq() for all Atari interrupts
  13. * just the normal way. Additionally, all vectors >= 48 are initialized to
  14. * call trap() instead of inthandler(). This must be changed here, too.
  15. *
  16. * 1995-07-16 Lars Brinkhoff <f93labr@dd.chalmers.se>:
  17. * Corrected a bug in atari_add_isr() which rejected all SCC
  18. * interrupt sources if there were no TT MFP!
  19. *
  20. * 12/13/95: New interface functions atari_level_triggered_int() and
  21. * atari_register_vme_int() as support for level triggered VME interrupts.
  22. *
  23. * 02/12/96: (Roman)
  24. * Total rewrite of Atari interrupt handling, for new scheme see comments
  25. * below.
  26. *
  27. * 1996-09-03 lars brinkhoff <f93labr@dd.chalmers.se>:
  28. * Added new function atari_unregister_vme_int(), and
  29. * modified atari_register_vme_int() as well as IS_VALID_INTNO()
  30. * to work with it.
  31. *
  32. * This file is subject to the terms and conditions of the GNU General Public
  33. * License. See the file COPYING in the main directory of this archive
  34. * for more details.
  35. *
  36. */
  37. #include <linux/types.h>
  38. #include <linux/kernel.h>
  39. #include <linux/kernel_stat.h>
  40. #include <linux/init.h>
  41. #include <linux/seq_file.h>
  42. #include <asm/system.h>
  43. #include <asm/traps.h>
  44. #include <asm/atarihw.h>
  45. #include <asm/atariints.h>
  46. #include <asm/atari_stdma.h>
  47. #include <asm/irq.h>
  48. #include <asm/entry.h>
  49. /*
  50. * Atari interrupt handling scheme:
  51. * --------------------------------
  52. *
  53. * All interrupt source have an internal number (defined in
  54. * <asm/atariints.h>): Autovector interrupts are 1..7, then follow ST-MFP,
  55. * TT-MFP, SCC, and finally VME interrupts. Vector numbers for the latter can
  56. * be allocated by atari_register_vme_int().
  57. *
  58. * Each interrupt can be of three types:
  59. *
  60. * - SLOW: The handler runs with all interrupts enabled, except the one it
  61. * was called by (to avoid reentering). This should be the usual method.
  62. * But it is currently possible only for MFP ints, since only the MFP
  63. * offers an easy way to mask interrupts.
  64. *
  65. * - FAST: The handler runs with all interrupts disabled. This should be used
  66. * only for really fast handlers, that just do actions immediately
  67. * necessary, and let the rest do a bottom half or task queue.
  68. *
  69. * - PRIORITIZED: The handler can be interrupted by higher-level ints
  70. * (greater IPL, no MFP priorities!). This is the method of choice for ints
  71. * which should be slow, but are not from a MFP.
  72. *
  73. * The feature of more than one handler for one int source is still there, but
  74. * only applicable if all handers are of the same type. To not slow down
  75. * processing of ints with only one handler by the chaining feature, the list
  76. * calling function atari_call_irq_list() is only plugged in at the time the
  77. * second handler is registered.
  78. *
  79. * Implementation notes: For fast-as-possible int handling, there are separate
  80. * entry points for each type (slow/fast/prio). The assembler handler calls
  81. * the irq directly in the usual case, no C wrapper is involved. In case of
  82. * multiple handlers, atari_call_irq_list() is registered as handler and calls
  83. * in turn the real irq's. To ease access from assembler level to the irq
  84. * function pointer and accompanying data, these two are stored in a separate
  85. * array, irq_handler[]. The rest of data (type, name) are put into a second
  86. * array, irq_param, that is accessed from C only. For each slow interrupt (32
  87. * in all) there are separate handler functions, which makes it possible to
  88. * hard-code the MFP register address and value, are necessary to mask the
  89. * int. If there'd be only one generic function, lots of calculations would be
  90. * needed to determine MFP register and int mask from the vector number :-(
  91. *
  92. * Furthermore, slow ints may not lower the IPL below its previous value
  93. * (before the int happened). This is needed so that an int of class PRIO, on
  94. * that this int may be stacked, cannot be reentered. This feature is
  95. * implemented as follows: If the stack frame format is 1 (throwaway), the int
  96. * is not stacked, and the IPL is anded with 0xfbff, resulting in a new level
  97. * 2, which still blocks the HSYNC, but no interrupts of interest. If the
  98. * frame format is 0, the int is nested, and the old IPL value can be found in
  99. * the sr copy in the frame.
  100. */
  101. #define NUM_INT_SOURCES (8 + NUM_ATARI_SOURCES)
  102. typedef void (*asm_irq_handler)(void);
  103. struct irqhandler {
  104. irqreturn_t (*handler)(int, void *, struct pt_regs *);
  105. void *dev_id;
  106. };
  107. struct irqparam {
  108. unsigned long flags;
  109. const char *devname;
  110. };
  111. /*
  112. * Array with irq's and their parameter data. This array is accessed from low
  113. * level assembler code, so an element size of 8 allows usage of index scaling
  114. * addressing mode.
  115. */
  116. static struct irqhandler irq_handler[NUM_INT_SOURCES];
  117. /*
  118. * This array hold the rest of parameters of int handlers: type
  119. * (slow,fast,prio) and the name of the handler. These values are only
  120. * accessed from C
  121. */
  122. static struct irqparam irq_param[NUM_INT_SOURCES];
  123. /*
  124. * Bitmap for free interrupt vector numbers
  125. * (new vectors starting from 0x70 can be allocated by
  126. * atari_register_vme_int())
  127. */
  128. static int free_vme_vec_bitmap;
  129. /* check for valid int number (complex, sigh...) */
  130. #define IS_VALID_INTNO(n) \
  131. ((n) > 0 && \
  132. /* autovec and ST-MFP ok anyway */ \
  133. (((n) < TTMFP_SOURCE_BASE) || \
  134. /* TT-MFP ok if present */ \
  135. ((n) >= TTMFP_SOURCE_BASE && (n) < SCC_SOURCE_BASE && \
  136. ATARIHW_PRESENT(TT_MFP)) || \
  137. /* SCC ok if present and number even */ \
  138. ((n) >= SCC_SOURCE_BASE && (n) < VME_SOURCE_BASE && \
  139. !((n) & 1) && ATARIHW_PRESENT(SCC)) || \
  140. /* greater numbers ok if they are registered VME vectors */ \
  141. ((n) >= VME_SOURCE_BASE && (n) < VME_SOURCE_BASE + VME_MAX_SOURCES && \
  142. free_vme_vec_bitmap & (1 << ((n) - VME_SOURCE_BASE)))))
  143. /*
  144. * Here start the assembler entry points for interrupts
  145. */
  146. #define IRQ_NAME(nr) atari_slow_irq_##nr##_handler(void)
  147. #define BUILD_SLOW_IRQ(n) \
  148. asmlinkage void IRQ_NAME(n); \
  149. /* Dummy function to allow asm with operands. */ \
  150. void atari_slow_irq_##n##_dummy (void) { \
  151. __asm__ (__ALIGN_STR "\n" \
  152. "atari_slow_irq_" #n "_handler:\t" \
  153. " addl %6,%5\n" /* preempt_count() += HARDIRQ_OFFSET */ \
  154. SAVE_ALL_INT "\n" \
  155. GET_CURRENT(%%d0) "\n" \
  156. " andb #~(1<<(%c3&7)),%a4:w\n" /* mask this interrupt */ \
  157. /* get old IPL from stack frame */ \
  158. " bfextu %%sp@(%c2){#5,#3},%%d0\n" \
  159. " movew %%sr,%%d1\n" \
  160. " bfins %%d0,%%d1{#21,#3}\n" \
  161. " movew %%d1,%%sr\n" /* set IPL = previous value */ \
  162. " addql #1,%a0\n" \
  163. " lea %a1,%%a0\n" \
  164. " pea %%sp@\n" /* push addr of frame */ \
  165. " movel %%a0@(4),%%sp@-\n" /* push handler data */ \
  166. " pea (%c3+8)\n" /* push int number */ \
  167. " movel %%a0@,%%a0\n" \
  168. " jbsr %%a0@\n" /* call the handler */ \
  169. " addql #8,%%sp\n" \
  170. " addql #4,%%sp\n" \
  171. " orw #0x0600,%%sr\n" \
  172. " andw #0xfeff,%%sr\n" /* set IPL = 6 again */ \
  173. " orb #(1<<(%c3&7)),%a4:w\n" /* now unmask the int again */ \
  174. " jbra ret_from_interrupt\n" \
  175. : : "i" (&kstat_cpu(0).irqs[n+8]), "i" (&irq_handler[n+8]), \
  176. "n" (PT_OFF_SR), "n" (n), \
  177. "i" (n & 8 ? (n & 16 ? &tt_mfp.int_mk_a : &mfp.int_mk_a) \
  178. : (n & 16 ? &tt_mfp.int_mk_b : &mfp.int_mk_b)), \
  179. "m" (preempt_count()), "di" (HARDIRQ_OFFSET) \
  180. ); \
  181. for (;;); /* fake noreturn */ \
  182. }
  183. BUILD_SLOW_IRQ(0);
  184. BUILD_SLOW_IRQ(1);
  185. BUILD_SLOW_IRQ(2);
  186. BUILD_SLOW_IRQ(3);
  187. BUILD_SLOW_IRQ(4);
  188. BUILD_SLOW_IRQ(5);
  189. BUILD_SLOW_IRQ(6);
  190. BUILD_SLOW_IRQ(7);
  191. BUILD_SLOW_IRQ(8);
  192. BUILD_SLOW_IRQ(9);
  193. BUILD_SLOW_IRQ(10);
  194. BUILD_SLOW_IRQ(11);
  195. BUILD_SLOW_IRQ(12);
  196. BUILD_SLOW_IRQ(13);
  197. BUILD_SLOW_IRQ(14);
  198. BUILD_SLOW_IRQ(15);
  199. BUILD_SLOW_IRQ(16);
  200. BUILD_SLOW_IRQ(17);
  201. BUILD_SLOW_IRQ(18);
  202. BUILD_SLOW_IRQ(19);
  203. BUILD_SLOW_IRQ(20);
  204. BUILD_SLOW_IRQ(21);
  205. BUILD_SLOW_IRQ(22);
  206. BUILD_SLOW_IRQ(23);
  207. BUILD_SLOW_IRQ(24);
  208. BUILD_SLOW_IRQ(25);
  209. BUILD_SLOW_IRQ(26);
  210. BUILD_SLOW_IRQ(27);
  211. BUILD_SLOW_IRQ(28);
  212. BUILD_SLOW_IRQ(29);
  213. BUILD_SLOW_IRQ(30);
  214. BUILD_SLOW_IRQ(31);
  215. asm_irq_handler slow_handlers[32] = {
  216. [0] = atari_slow_irq_0_handler,
  217. [1] = atari_slow_irq_1_handler,
  218. [2] = atari_slow_irq_2_handler,
  219. [3] = atari_slow_irq_3_handler,
  220. [4] = atari_slow_irq_4_handler,
  221. [5] = atari_slow_irq_5_handler,
  222. [6] = atari_slow_irq_6_handler,
  223. [7] = atari_slow_irq_7_handler,
  224. [8] = atari_slow_irq_8_handler,
  225. [9] = atari_slow_irq_9_handler,
  226. [10] = atari_slow_irq_10_handler,
  227. [11] = atari_slow_irq_11_handler,
  228. [12] = atari_slow_irq_12_handler,
  229. [13] = atari_slow_irq_13_handler,
  230. [14] = atari_slow_irq_14_handler,
  231. [15] = atari_slow_irq_15_handler,
  232. [16] = atari_slow_irq_16_handler,
  233. [17] = atari_slow_irq_17_handler,
  234. [18] = atari_slow_irq_18_handler,
  235. [19] = atari_slow_irq_19_handler,
  236. [20] = atari_slow_irq_20_handler,
  237. [21] = atari_slow_irq_21_handler,
  238. [22] = atari_slow_irq_22_handler,
  239. [23] = atari_slow_irq_23_handler,
  240. [24] = atari_slow_irq_24_handler,
  241. [25] = atari_slow_irq_25_handler,
  242. [26] = atari_slow_irq_26_handler,
  243. [27] = atari_slow_irq_27_handler,
  244. [28] = atari_slow_irq_28_handler,
  245. [29] = atari_slow_irq_29_handler,
  246. [30] = atari_slow_irq_30_handler,
  247. [31] = atari_slow_irq_31_handler
  248. };
  249. asmlinkage void atari_fast_irq_handler( void );
  250. asmlinkage void atari_prio_irq_handler( void );
  251. /* Dummy function to allow asm with operands. */
  252. void atari_fast_prio_irq_dummy (void) {
  253. __asm__ (__ALIGN_STR "\n"
  254. "atari_fast_irq_handler:\n\t"
  255. "orw #0x700,%%sr\n" /* disable all interrupts */
  256. "atari_prio_irq_handler:\n\t"
  257. "addl %3,%2\n\t" /* preempt_count() += HARDIRQ_OFFSET */
  258. SAVE_ALL_INT "\n\t"
  259. GET_CURRENT(%%d0) "\n\t"
  260. /* get vector number from stack frame and convert to source */
  261. "bfextu %%sp@(%c1){#4,#10},%%d0\n\t"
  262. "subw #(0x40-8),%%d0\n\t"
  263. "jpl 1f\n\t"
  264. "addw #(0x40-8-0x18),%%d0\n"
  265. "1:\tlea %a0,%%a0\n\t"
  266. "addql #1,%%a0@(%%d0:l:4)\n\t"
  267. "lea irq_handler,%%a0\n\t"
  268. "lea %%a0@(%%d0:l:8),%%a0\n\t"
  269. "pea %%sp@\n\t" /* push frame address */
  270. "movel %%a0@(4),%%sp@-\n\t" /* push handler data */
  271. "movel %%d0,%%sp@-\n\t" /* push int number */
  272. "movel %%a0@,%%a0\n\t"
  273. "jsr %%a0@\n\t" /* and call the handler */
  274. "addql #8,%%sp\n\t"
  275. "addql #4,%%sp\n\t"
  276. "jbra ret_from_interrupt"
  277. : : "i" (&kstat_cpu(0).irqs), "n" (PT_OFF_FORMATVEC),
  278. "m" (preempt_count()), "di" (HARDIRQ_OFFSET)
  279. );
  280. for (;;);
  281. }
  282. /* GK:
  283. * HBL IRQ handler for Falcon. Nobody needs it :-)
  284. * ++andreas: raise ipl to disable further HBLANK interrupts.
  285. */
  286. asmlinkage void falcon_hblhandler(void);
  287. asm(".text\n"
  288. __ALIGN_STR "\n\t"
  289. "falcon_hblhandler:\n\t"
  290. "orw #0x200,%sp@\n\t" /* set saved ipl to 2 */
  291. "rte");
  292. /* Defined in entry.S; only increments 'num_spurious' */
  293. asmlinkage void bad_interrupt(void);
  294. extern void atari_microwire_cmd( int cmd );
  295. extern int atari_SCC_reset_done;
  296. /*
  297. * void atari_init_IRQ (void)
  298. *
  299. * Parameters: None
  300. *
  301. * Returns: Nothing
  302. *
  303. * This function should be called during kernel startup to initialize
  304. * the atari IRQ handling routines.
  305. */
  306. void __init atari_init_IRQ(void)
  307. {
  308. int i;
  309. /* initialize the vector table */
  310. for (i = 0; i < NUM_INT_SOURCES; ++i) {
  311. vectors[IRQ_SOURCE_TO_VECTOR(i)] = bad_interrupt;
  312. }
  313. /* Initialize the MFP(s) */
  314. #ifdef ATARI_USE_SOFTWARE_EOI
  315. mfp.vec_adr = 0x48; /* Software EOI-Mode */
  316. #else
  317. mfp.vec_adr = 0x40; /* Automatic EOI-Mode */
  318. #endif
  319. mfp.int_en_a = 0x00; /* turn off MFP-Ints */
  320. mfp.int_en_b = 0x00;
  321. mfp.int_mk_a = 0xff; /* no Masking */
  322. mfp.int_mk_b = 0xff;
  323. if (ATARIHW_PRESENT(TT_MFP)) {
  324. #ifdef ATARI_USE_SOFTWARE_EOI
  325. tt_mfp.vec_adr = 0x58; /* Software EOI-Mode */
  326. #else
  327. tt_mfp.vec_adr = 0x50; /* Automatic EOI-Mode */
  328. #endif
  329. tt_mfp.int_en_a = 0x00; /* turn off MFP-Ints */
  330. tt_mfp.int_en_b = 0x00;
  331. tt_mfp.int_mk_a = 0xff; /* no Masking */
  332. tt_mfp.int_mk_b = 0xff;
  333. }
  334. if (ATARIHW_PRESENT(SCC) && !atari_SCC_reset_done) {
  335. scc.cha_a_ctrl = 9;
  336. MFPDELAY();
  337. scc.cha_a_ctrl = (char) 0xc0; /* hardware reset */
  338. }
  339. if (ATARIHW_PRESENT(SCU)) {
  340. /* init the SCU if present */
  341. tt_scu.sys_mask = 0x10; /* enable VBL (for the cursor) and
  342. * disable HSYNC interrupts (who
  343. * needs them?) MFP and SCC are
  344. * enabled in VME mask
  345. */
  346. tt_scu.vme_mask = 0x60; /* enable MFP and SCC ints */
  347. }
  348. else {
  349. /* If no SCU and no Hades, the HSYNC interrupt needs to be
  350. * disabled this way. (Else _inthandler in kernel/sys_call.S
  351. * gets overruns)
  352. */
  353. if (!MACH_IS_HADES)
  354. vectors[VEC_INT2] = falcon_hblhandler;
  355. }
  356. if (ATARIHW_PRESENT(PCM_8BIT) && ATARIHW_PRESENT(MICROWIRE)) {
  357. /* Initialize the LM1992 Sound Controller to enable
  358. the PSG sound. This is misplaced here, it should
  359. be in an atasound_init(), that doesn't exist yet. */
  360. atari_microwire_cmd(MW_LM1992_PSG_HIGH);
  361. }
  362. stdma_init();
  363. /* Initialize the PSG: all sounds off, both ports output */
  364. sound_ym.rd_data_reg_sel = 7;
  365. sound_ym.wd_data = 0xff;
  366. }
  367. static irqreturn_t atari_call_irq_list( int irq, void *dev_id, struct pt_regs *fp )
  368. {
  369. irq_node_t *node;
  370. for (node = (irq_node_t *)dev_id; node; node = node->next)
  371. node->handler(irq, node->dev_id, fp);
  372. return IRQ_HANDLED;
  373. }
  374. /*
  375. * atari_request_irq : add an interrupt service routine for a particular
  376. * machine specific interrupt source.
  377. * If the addition was successful, it returns 0.
  378. */
  379. int atari_request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
  380. unsigned long flags, const char *devname, void *dev_id)
  381. {
  382. int vector;
  383. unsigned long oflags = flags;
  384. /*
  385. * The following is a hack to make some PCI card drivers work,
  386. * which set the SA_SHIRQ flag.
  387. */
  388. flags &= ~SA_SHIRQ;
  389. if (flags == SA_INTERRUPT) {
  390. printk ("%s: SA_INTERRUPT changed to IRQ_TYPE_SLOW for %s\n",
  391. __FUNCTION__, devname);
  392. flags = IRQ_TYPE_SLOW;
  393. }
  394. if (flags < IRQ_TYPE_SLOW || flags > IRQ_TYPE_PRIO) {
  395. printk ("%s: Bad irq type 0x%lx <0x%lx> requested from %s\n",
  396. __FUNCTION__, flags, oflags, devname);
  397. return -EINVAL;
  398. }
  399. if (!IS_VALID_INTNO(irq)) {
  400. printk ("%s: Unknown irq %d requested from %s\n",
  401. __FUNCTION__, irq, devname);
  402. return -ENXIO;
  403. }
  404. vector = IRQ_SOURCE_TO_VECTOR(irq);
  405. /*
  406. * Check type/source combination: slow ints are (currently)
  407. * only possible for MFP-interrupts.
  408. */
  409. if (flags == IRQ_TYPE_SLOW &&
  410. (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE)) {
  411. printk ("%s: Slow irq requested for non-MFP source %d from %s\n",
  412. __FUNCTION__, irq, devname);
  413. return -EINVAL;
  414. }
  415. if (vectors[vector] == bad_interrupt) {
  416. /* int has no handler yet */
  417. irq_handler[irq].handler = handler;
  418. irq_handler[irq].dev_id = dev_id;
  419. irq_param[irq].flags = flags;
  420. irq_param[irq].devname = devname;
  421. vectors[vector] =
  422. (flags == IRQ_TYPE_SLOW) ? slow_handlers[irq-STMFP_SOURCE_BASE] :
  423. (flags == IRQ_TYPE_FAST) ? atari_fast_irq_handler :
  424. atari_prio_irq_handler;
  425. /* If MFP int, also enable and umask it */
  426. atari_turnon_irq(irq);
  427. atari_enable_irq(irq);
  428. return 0;
  429. }
  430. else if (irq_param[irq].flags == flags) {
  431. /* old handler is of same type -> handlers can be chained */
  432. irq_node_t *node;
  433. unsigned long flags;
  434. local_irq_save(flags);
  435. if (irq_handler[irq].handler != atari_call_irq_list) {
  436. /* Only one handler yet, make a node for this first one */
  437. if (!(node = new_irq_node()))
  438. return -ENOMEM;
  439. node->handler = irq_handler[irq].handler;
  440. node->dev_id = irq_handler[irq].dev_id;
  441. node->devname = irq_param[irq].devname;
  442. node->next = NULL;
  443. irq_handler[irq].handler = atari_call_irq_list;
  444. irq_handler[irq].dev_id = node;
  445. irq_param[irq].devname = "chained";
  446. }
  447. if (!(node = new_irq_node()))
  448. return -ENOMEM;
  449. node->handler = handler;
  450. node->dev_id = dev_id;
  451. node->devname = devname;
  452. /* new handlers are put in front of the queue */
  453. node->next = irq_handler[irq].dev_id;
  454. irq_handler[irq].dev_id = node;
  455. local_irq_restore(flags);
  456. return 0;
  457. } else {
  458. printk ("%s: Irq %d allocated by other type int (call from %s)\n",
  459. __FUNCTION__, irq, devname);
  460. return -EBUSY;
  461. }
  462. }
  463. void atari_free_irq(unsigned int irq, void *dev_id)
  464. {
  465. unsigned long flags;
  466. int vector;
  467. irq_node_t **list, *node;
  468. if (!IS_VALID_INTNO(irq)) {
  469. printk("%s: Unknown irq %d\n", __FUNCTION__, irq);
  470. return;
  471. }
  472. vector = IRQ_SOURCE_TO_VECTOR(irq);
  473. if (vectors[vector] == bad_interrupt)
  474. goto not_found;
  475. local_irq_save(flags);
  476. if (irq_handler[irq].handler != atari_call_irq_list) {
  477. /* It's the only handler for the interrupt */
  478. if (irq_handler[irq].dev_id != dev_id) {
  479. local_irq_restore(flags);
  480. goto not_found;
  481. }
  482. irq_handler[irq].handler = NULL;
  483. irq_handler[irq].dev_id = NULL;
  484. irq_param[irq].devname = NULL;
  485. vectors[vector] = bad_interrupt;
  486. /* If MFP int, also disable it */
  487. atari_disable_irq(irq);
  488. atari_turnoff_irq(irq);
  489. local_irq_restore(flags);
  490. return;
  491. }
  492. /* The interrupt is chained, find the irq on the list */
  493. for(list = (irq_node_t **)&irq_handler[irq].dev_id; *list; list = &(*list)->next) {
  494. if ((*list)->dev_id == dev_id) break;
  495. }
  496. if (!*list) {
  497. local_irq_restore(flags);
  498. goto not_found;
  499. }
  500. (*list)->handler = NULL; /* Mark it as free for reallocation */
  501. *list = (*list)->next;
  502. /* If there's now only one handler, unchain the interrupt, i.e. plug in
  503. * the handler directly again and omit atari_call_irq_list */
  504. node = (irq_node_t *)irq_handler[irq].dev_id;
  505. if (node && !node->next) {
  506. irq_handler[irq].handler = node->handler;
  507. irq_handler[irq].dev_id = node->dev_id;
  508. irq_param[irq].devname = node->devname;
  509. node->handler = NULL; /* Mark it as free for reallocation */
  510. }
  511. local_irq_restore(flags);
  512. return;
  513. not_found:
  514. printk("%s: tried to remove invalid irq\n", __FUNCTION__);
  515. return;
  516. }
  517. /*
  518. * atari_register_vme_int() returns the number of a free interrupt vector for
  519. * hardware with a programmable int vector (probably a VME board).
  520. */
  521. unsigned long atari_register_vme_int(void)
  522. {
  523. int i;
  524. for(i = 0; i < 32; i++)
  525. if((free_vme_vec_bitmap & (1 << i)) == 0)
  526. break;
  527. if(i == 16)
  528. return 0;
  529. free_vme_vec_bitmap |= 1 << i;
  530. return (VME_SOURCE_BASE + i);
  531. }
  532. void atari_unregister_vme_int(unsigned long irq)
  533. {
  534. if(irq >= VME_SOURCE_BASE && irq < VME_SOURCE_BASE + VME_MAX_SOURCES) {
  535. irq -= VME_SOURCE_BASE;
  536. free_vme_vec_bitmap &= ~(1 << irq);
  537. }
  538. }
  539. int show_atari_interrupts(struct seq_file *p, void *v)
  540. {
  541. int i;
  542. for (i = 0; i < NUM_INT_SOURCES; ++i) {
  543. if (vectors[IRQ_SOURCE_TO_VECTOR(i)] == bad_interrupt)
  544. continue;
  545. if (i < STMFP_SOURCE_BASE)
  546. seq_printf(p, "auto %2d: %10u ",
  547. i, kstat_cpu(0).irqs[i]);
  548. else
  549. seq_printf(p, "vec $%02x: %10u ",
  550. IRQ_SOURCE_TO_VECTOR(i),
  551. kstat_cpu(0).irqs[i]);
  552. if (irq_handler[i].handler != atari_call_irq_list) {
  553. seq_printf(p, "%s\n", irq_param[i].devname);
  554. }
  555. else {
  556. irq_node_t *n;
  557. for( n = (irq_node_t *)irq_handler[i].dev_id; n; n = n->next ) {
  558. seq_printf(p, "%s\n", n->devname);
  559. if (n->next)
  560. seq_puts(p, " " );
  561. }
  562. }
  563. }
  564. if (num_spurious)
  565. seq_printf(p, "spurio.: %10u\n", num_spurious);
  566. return 0;
  567. }