irq.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* $Id: irq.c,v 1.2 2004/06/09 05:30:27 starvik Exp $
  2. *
  3. * linux/arch/cris/kernel/irq.c
  4. *
  5. * Copyright (c) 2000-2002 Axis Communications AB
  6. *
  7. * Authors: Bjorn Wesen (bjornw@axis.com)
  8. *
  9. * This file contains the interrupt vectors and some
  10. * helper functions
  11. *
  12. */
  13. #include <asm/irq.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/config.h>
  17. irqvectptr irq_shortcuts[NR_IRQS]; /* vector of shortcut jumps after the irq prologue */
  18. /* don't use set_int_vector, it bypasses the linux interrupt handlers. it is
  19. * global just so that the kernel gdb can use it.
  20. */
  21. void
  22. set_int_vector(int n, irqvectptr addr)
  23. {
  24. etrax_irv->v[n + 0x20] = (irqvectptr)addr;
  25. }
  26. /* the breakpoint vector is obviously not made just like the normal irq handlers
  27. * but needs to contain _code_ to jump to addr.
  28. *
  29. * the BREAK n instruction jumps to IBR + n * 8
  30. */
  31. void
  32. set_break_vector(int n, irqvectptr addr)
  33. {
  34. unsigned short *jinstr = (unsigned short *)&etrax_irv->v[n*2];
  35. unsigned long *jaddr = (unsigned long *)(jinstr + 1);
  36. /* if you don't know what this does, do not touch it! */
  37. *jinstr = 0x0d3f;
  38. *jaddr = (unsigned long)addr;
  39. /* 00000026 <clrlop+1a> 3f0d82000000 jump 0x82 */
  40. }
  41. /*
  42. * This builds up the IRQ handler stubs using some ugly macros in irq.h
  43. *
  44. * These macros create the low-level assembly IRQ routines that do all
  45. * the operations that are needed. They are also written to be fast - and to
  46. * disable interrupts as little as humanly possible.
  47. *
  48. */
  49. /* IRQ0 and 1 are special traps */
  50. void hwbreakpoint(void);
  51. void IRQ1_interrupt(void);
  52. BUILD_TIMER_IRQ(2, 0x04) /* the timer interrupt is somewhat special */
  53. BUILD_IRQ(3, 0x08)
  54. BUILD_IRQ(4, 0x10)
  55. BUILD_IRQ(5, 0x20)
  56. BUILD_IRQ(6, 0x40)
  57. BUILD_IRQ(7, 0x80)
  58. BUILD_IRQ(8, 0x100)
  59. BUILD_IRQ(9, 0x200)
  60. BUILD_IRQ(10, 0x400)
  61. BUILD_IRQ(11, 0x800)
  62. BUILD_IRQ(12, 0x1000)
  63. BUILD_IRQ(13, 0x2000)
  64. void mmu_bus_fault(void); /* IRQ 14 is the bus fault interrupt */
  65. void multiple_interrupt(void); /* IRQ 15 is the multiple IRQ interrupt */
  66. BUILD_IRQ(16, 0x10000)
  67. BUILD_IRQ(17, 0x20000)
  68. BUILD_IRQ(18, 0x40000)
  69. BUILD_IRQ(19, 0x80000)
  70. BUILD_IRQ(20, 0x100000)
  71. BUILD_IRQ(21, 0x200000)
  72. BUILD_IRQ(22, 0x400000)
  73. BUILD_IRQ(23, 0x800000)
  74. BUILD_IRQ(24, 0x1000000)
  75. BUILD_IRQ(25, 0x2000000)
  76. /* IRQ 26-30 are reserved */
  77. BUILD_IRQ(31, 0x80000000)
  78. /*
  79. * Pointers to the low-level handlers
  80. */
  81. static void (*interrupt[NR_IRQS])(void) = {
  82. NULL, NULL, IRQ2_interrupt, IRQ3_interrupt,
  83. IRQ4_interrupt, IRQ5_interrupt, IRQ6_interrupt, IRQ7_interrupt,
  84. IRQ8_interrupt, IRQ9_interrupt, IRQ10_interrupt, IRQ11_interrupt,
  85. IRQ12_interrupt, IRQ13_interrupt, NULL, NULL,
  86. IRQ16_interrupt, IRQ17_interrupt, IRQ18_interrupt, IRQ19_interrupt,
  87. IRQ20_interrupt, IRQ21_interrupt, IRQ22_interrupt, IRQ23_interrupt,
  88. IRQ24_interrupt, IRQ25_interrupt, NULL, NULL, NULL, NULL, NULL,
  89. IRQ31_interrupt
  90. };
  91. static void (*bad_interrupt[NR_IRQS])(void) = {
  92. NULL, NULL,
  93. NULL, bad_IRQ3_interrupt,
  94. bad_IRQ4_interrupt, bad_IRQ5_interrupt,
  95. bad_IRQ6_interrupt, bad_IRQ7_interrupt,
  96. bad_IRQ8_interrupt, bad_IRQ9_interrupt,
  97. bad_IRQ10_interrupt, bad_IRQ11_interrupt,
  98. bad_IRQ12_interrupt, bad_IRQ13_interrupt,
  99. NULL, NULL,
  100. bad_IRQ16_interrupt, bad_IRQ17_interrupt,
  101. bad_IRQ18_interrupt, bad_IRQ19_interrupt,
  102. bad_IRQ20_interrupt, bad_IRQ21_interrupt,
  103. bad_IRQ22_interrupt, bad_IRQ23_interrupt,
  104. bad_IRQ24_interrupt, bad_IRQ25_interrupt,
  105. NULL, NULL, NULL, NULL, NULL,
  106. bad_IRQ31_interrupt
  107. };
  108. void arch_setup_irq(int irq)
  109. {
  110. set_int_vector(irq, interrupt[irq]);
  111. }
  112. void arch_free_irq(int irq)
  113. {
  114. set_int_vector(irq, bad_interrupt[irq]);
  115. }
  116. void weird_irq(void);
  117. void system_call(void); /* from entry.S */
  118. void do_sigtrap(void); /* from entry.S */
  119. void gdb_handle_breakpoint(void); /* from entry.S */
  120. /* init_IRQ() is called by start_kernel and is responsible for fixing IRQ masks and
  121. setting the irq vector table to point to bad_interrupt ptrs.
  122. */
  123. void __init
  124. init_IRQ(void)
  125. {
  126. int i;
  127. /* clear all interrupt masks */
  128. #ifndef CONFIG_SVINTO_SIM
  129. *R_IRQ_MASK0_CLR = 0xffffffff;
  130. *R_IRQ_MASK1_CLR = 0xffffffff;
  131. *R_IRQ_MASK2_CLR = 0xffffffff;
  132. #endif
  133. *R_VECT_MASK_CLR = 0xffffffff;
  134. /* clear the shortcut entry points */
  135. for(i = 0; i < NR_IRQS; i++)
  136. irq_shortcuts[i] = NULL;
  137. for (i = 0; i < 256; i++)
  138. etrax_irv->v[i] = weird_irq;
  139. /* the entries in the break vector contain actual code to be
  140. executed by the associated break handler, rather than just a jump
  141. address. therefore we need to setup a default breakpoint handler
  142. for all breakpoints */
  143. for (i = 0; i < 16; i++)
  144. set_break_vector(i, do_sigtrap);
  145. /* set all etrax irq's to the bad handlers */
  146. for (i = 2; i < NR_IRQS; i++)
  147. set_int_vector(i, bad_interrupt[i]);
  148. /* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
  149. set_int_vector(15, multiple_interrupt);
  150. /* 0 and 1 which are special breakpoint/NMI traps */
  151. set_int_vector(0, hwbreakpoint);
  152. set_int_vector(1, IRQ1_interrupt);
  153. /* and irq 14 which is the mmu bus fault handler */
  154. set_int_vector(14, mmu_bus_fault);
  155. /* setup the system-call trap, which is reached by BREAK 13 */
  156. set_break_vector(13, system_call);
  157. /* setup a breakpoint handler for debugging used for both user and
  158. kernel mode debugging (which is why it is not inside an ifdef
  159. CONFIG_ETRAX_KGDB) */
  160. set_break_vector(8, gdb_handle_breakpoint);
  161. #ifdef CONFIG_ETRAX_KGDB
  162. /* setup kgdb if its enabled, and break into the debugger */
  163. kgdb_init();
  164. breakpoint();
  165. #endif
  166. }