irq.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* $Id: irq.c,v 1.4 2005/01/04 12:22:28 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/irq.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #define mask_irq(irq_nr) (*R_VECT_MASK_CLR = 1 << (irq_nr));
  18. #define unmask_irq(irq_nr) (*R_VECT_MASK_SET = 1 << (irq_nr));
  19. /* don't use set_int_vector, it bypasses the linux interrupt handlers. it is
  20. * global just so that the kernel gdb can use it.
  21. */
  22. void
  23. set_int_vector(int n, irqvectptr addr)
  24. {
  25. etrax_irv->v[n + 0x20] = (irqvectptr)addr;
  26. }
  27. /* the breakpoint vector is obviously not made just like the normal irq handlers
  28. * but needs to contain _code_ to jump to addr.
  29. *
  30. * the BREAK n instruction jumps to IBR + n * 8
  31. */
  32. void
  33. set_break_vector(int n, irqvectptr addr)
  34. {
  35. unsigned short *jinstr = (unsigned short *)&etrax_irv->v[n*2];
  36. unsigned long *jaddr = (unsigned long *)(jinstr + 1);
  37. /* if you don't know what this does, do not touch it! */
  38. *jinstr = 0x0d3f;
  39. *jaddr = (unsigned long)addr;
  40. /* 00000026 <clrlop+1a> 3f0d82000000 jump 0x82 */
  41. }
  42. /*
  43. * This builds up the IRQ handler stubs using some ugly macros in irq.h
  44. *
  45. * These macros create the low-level assembly IRQ routines that do all
  46. * the operations that are needed. They are also written to be fast - and to
  47. * disable interrupts as little as humanly possible.
  48. *
  49. */
  50. /* IRQ0 and 1 are special traps */
  51. void hwbreakpoint(void);
  52. void IRQ1_interrupt(void);
  53. BUILD_TIMER_IRQ(2, 0x04) /* the timer interrupt is somewhat special */
  54. BUILD_IRQ(3, 0x08)
  55. BUILD_IRQ(4, 0x10)
  56. BUILD_IRQ(5, 0x20)
  57. BUILD_IRQ(6, 0x40)
  58. BUILD_IRQ(7, 0x80)
  59. BUILD_IRQ(8, 0x100)
  60. BUILD_IRQ(9, 0x200)
  61. BUILD_IRQ(10, 0x400)
  62. BUILD_IRQ(11, 0x800)
  63. BUILD_IRQ(12, 0x1000)
  64. BUILD_IRQ(13, 0x2000)
  65. void mmu_bus_fault(void); /* IRQ 14 is the bus fault interrupt */
  66. void multiple_interrupt(void); /* IRQ 15 is the multiple IRQ interrupt */
  67. BUILD_IRQ(16, 0x10000)
  68. BUILD_IRQ(17, 0x20000)
  69. BUILD_IRQ(18, 0x40000)
  70. BUILD_IRQ(19, 0x80000)
  71. BUILD_IRQ(20, 0x100000)
  72. BUILD_IRQ(21, 0x200000)
  73. BUILD_IRQ(22, 0x400000)
  74. BUILD_IRQ(23, 0x800000)
  75. BUILD_IRQ(24, 0x1000000)
  76. BUILD_IRQ(25, 0x2000000)
  77. /* IRQ 26-30 are reserved */
  78. BUILD_IRQ(31, 0x80000000)
  79. /*
  80. * Pointers to the low-level handlers
  81. */
  82. static void (*interrupt[NR_IRQS])(void) = {
  83. NULL, NULL, IRQ2_interrupt, IRQ3_interrupt,
  84. IRQ4_interrupt, IRQ5_interrupt, IRQ6_interrupt, IRQ7_interrupt,
  85. IRQ8_interrupt, IRQ9_interrupt, IRQ10_interrupt, IRQ11_interrupt,
  86. IRQ12_interrupt, IRQ13_interrupt, NULL, NULL,
  87. IRQ16_interrupt, IRQ17_interrupt, IRQ18_interrupt, IRQ19_interrupt,
  88. IRQ20_interrupt, IRQ21_interrupt, IRQ22_interrupt, IRQ23_interrupt,
  89. IRQ24_interrupt, IRQ25_interrupt, NULL, NULL, NULL, NULL, NULL,
  90. IRQ31_interrupt
  91. };
  92. static void enable_crisv10_irq(unsigned int irq);
  93. static unsigned int startup_crisv10_irq(unsigned int irq)
  94. {
  95. enable_crisv10_irq(irq);
  96. return 0;
  97. }
  98. #define shutdown_crisv10_irq disable_crisv10_irq
  99. static void enable_crisv10_irq(unsigned int irq)
  100. {
  101. unmask_irq(irq);
  102. }
  103. static void disable_crisv10_irq(unsigned int irq)
  104. {
  105. mask_irq(irq);
  106. }
  107. static void ack_crisv10_irq(unsigned int irq)
  108. {
  109. }
  110. static void end_crisv10_irq(unsigned int irq)
  111. {
  112. }
  113. static struct hw_interrupt_type crisv10_irq_type = {
  114. .typename = "CRISv10",
  115. .startup = startup_crisv10_irq,
  116. .shutdown = shutdown_crisv10_irq,
  117. .enable = enable_crisv10_irq,
  118. .disable = disable_crisv10_irq,
  119. .ack = ack_crisv10_irq,
  120. .end = end_crisv10_irq,
  121. .set_affinity = NULL
  122. };
  123. void weird_irq(void);
  124. void system_call(void); /* from entry.S */
  125. void do_sigtrap(void); /* from entry.S */
  126. void gdb_handle_breakpoint(void); /* from entry.S */
  127. /* init_IRQ() is called by start_kernel and is responsible for fixing IRQ masks and
  128. setting the irq vector table.
  129. */
  130. void __init
  131. init_IRQ(void)
  132. {
  133. int i;
  134. /* clear all interrupt masks */
  135. #ifndef CONFIG_SVINTO_SIM
  136. *R_IRQ_MASK0_CLR = 0xffffffff;
  137. *R_IRQ_MASK1_CLR = 0xffffffff;
  138. *R_IRQ_MASK2_CLR = 0xffffffff;
  139. #endif
  140. *R_VECT_MASK_CLR = 0xffffffff;
  141. for (i = 0; i < 256; i++)
  142. etrax_irv->v[i] = weird_irq;
  143. /* Initialize IRQ handler descriptiors. */
  144. for(i = 2; i < NR_IRQS; i++) {
  145. irq_desc[i].chip = &crisv10_irq_type;
  146. set_int_vector(i, interrupt[i]);
  147. }
  148. /* the entries in the break vector contain actual code to be
  149. executed by the associated break handler, rather than just a jump
  150. address. therefore we need to setup a default breakpoint handler
  151. for all breakpoints */
  152. for (i = 0; i < 16; i++)
  153. set_break_vector(i, do_sigtrap);
  154. /* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
  155. set_int_vector(15, multiple_interrupt);
  156. /* 0 and 1 which are special breakpoint/NMI traps */
  157. set_int_vector(0, hwbreakpoint);
  158. set_int_vector(1, IRQ1_interrupt);
  159. /* and irq 14 which is the mmu bus fault handler */
  160. set_int_vector(14, mmu_bus_fault);
  161. /* setup the system-call trap, which is reached by BREAK 13 */
  162. set_break_vector(13, system_call);
  163. /* setup a breakpoint handler for debugging used for both user and
  164. kernel mode debugging (which is why it is not inside an ifdef
  165. CONFIG_ETRAX_KGDB) */
  166. set_break_vector(8, gdb_handle_breakpoint);
  167. #ifdef CONFIG_ETRAX_KGDB
  168. /* setup kgdb if its enabled, and break into the debugger */
  169. kgdb_init();
  170. breakpoint();
  171. #endif
  172. }