1 /* $Id: irq.c,v 1.4 2005/01/04 12:22:28 starvik Exp $
3 * linux/arch/cris/kernel/irq.c
5 * Copyright (c) 2000-2002 Axis Communications AB
7 * Authors: Bjorn Wesen (bjornw@axis.com)
9 * This file contains the interrupt vectors and some
15 #include <linux/irq.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/config.h>
20 #define mask_irq(irq_nr) (*R_VECT_MASK_CLR = 1 << (irq_nr));
21 #define unmask_irq(irq_nr) (*R_VECT_MASK_SET = 1 << (irq_nr));
23 /* don't use set_int_vector, it bypasses the linux interrupt handlers. it is
24 * global just so that the kernel gdb can use it.
28 set_int_vector(int n, irqvectptr addr)
30 etrax_irv->v[n + 0x20] = (irqvectptr)addr;
33 /* the breakpoint vector is obviously not made just like the normal irq handlers
34 * but needs to contain _code_ to jump to addr.
36 * the BREAK n instruction jumps to IBR + n * 8
40 set_break_vector(int n, irqvectptr addr)
42 unsigned short *jinstr = (unsigned short *)&etrax_irv->v[n*2];
43 unsigned long *jaddr = (unsigned long *)(jinstr + 1);
45 /* if you don't know what this does, do not touch it! */
48 *jaddr = (unsigned long)addr;
50 /* 00000026 <clrlop+1a> 3f0d82000000 jump 0x82 */
54 * This builds up the IRQ handler stubs using some ugly macros in irq.h
56 * These macros create the low-level assembly IRQ routines that do all
57 * the operations that are needed. They are also written to be fast - and to
58 * disable interrupts as little as humanly possible.
62 /* IRQ0 and 1 are special traps */
63 void hwbreakpoint(void);
64 void IRQ1_interrupt(void);
65 BUILD_TIMER_IRQ(2, 0x04) /* the timer interrupt is somewhat special */
77 void mmu_bus_fault(void); /* IRQ 14 is the bus fault interrupt */
78 void multiple_interrupt(void); /* IRQ 15 is the multiple IRQ interrupt */
79 BUILD_IRQ(16, 0x10000)
80 BUILD_IRQ(17, 0x20000)
81 BUILD_IRQ(18, 0x40000)
82 BUILD_IRQ(19, 0x80000)
83 BUILD_IRQ(20, 0x100000)
84 BUILD_IRQ(21, 0x200000)
85 BUILD_IRQ(22, 0x400000)
86 BUILD_IRQ(23, 0x800000)
87 BUILD_IRQ(24, 0x1000000)
88 BUILD_IRQ(25, 0x2000000)
89 /* IRQ 26-30 are reserved */
90 BUILD_IRQ(31, 0x80000000)
93 * Pointers to the low-level handlers
96 static void (*interrupt[NR_IRQS])(void) = {
97 NULL, NULL, IRQ2_interrupt, IRQ3_interrupt,
98 IRQ4_interrupt, IRQ5_interrupt, IRQ6_interrupt, IRQ7_interrupt,
99 IRQ8_interrupt, IRQ9_interrupt, IRQ10_interrupt, IRQ11_interrupt,
100 IRQ12_interrupt, IRQ13_interrupt, NULL, NULL,
101 IRQ16_interrupt, IRQ17_interrupt, IRQ18_interrupt, IRQ19_interrupt,
102 IRQ20_interrupt, IRQ21_interrupt, IRQ22_interrupt, IRQ23_interrupt,
103 IRQ24_interrupt, IRQ25_interrupt, NULL, NULL, NULL, NULL, NULL,
107 static void enable_crisv10_irq(unsigned int irq);
109 static unsigned int startup_crisv10_irq(unsigned int irq)
111 enable_crisv10_irq(irq);
115 #define shutdown_crisv10_irq disable_crisv10_irq
117 static void enable_crisv10_irq(unsigned int irq)
122 static void disable_crisv10_irq(unsigned int irq)
127 static void ack_crisv10_irq(unsigned int irq)
131 static void end_crisv10_irq(unsigned int irq)
135 static struct hw_interrupt_type crisv10_irq_type = {
136 .typename = "CRISv10",
137 .startup = startup_crisv10_irq,
138 .shutdown = shutdown_crisv10_irq,
139 .enable = enable_crisv10_irq,
140 .disable = disable_crisv10_irq,
141 .ack = ack_crisv10_irq,
142 .end = end_crisv10_irq,
146 void weird_irq(void);
147 void system_call(void); /* from entry.S */
148 void do_sigtrap(void); /* from entry.S */
149 void gdb_handle_breakpoint(void); /* from entry.S */
151 /* init_IRQ() is called by start_kernel and is responsible for fixing IRQ masks and
152 setting the irq vector table.
160 /* clear all interrupt masks */
162 #ifndef CONFIG_SVINTO_SIM
163 *R_IRQ_MASK0_CLR = 0xffffffff;
164 *R_IRQ_MASK1_CLR = 0xffffffff;
165 *R_IRQ_MASK2_CLR = 0xffffffff;
168 *R_VECT_MASK_CLR = 0xffffffff;
170 for (i = 0; i < 256; i++)
171 etrax_irv->v[i] = weird_irq;
173 /* Initialize IRQ handler descriptiors. */
174 for(i = 2; i < NR_IRQS; i++) {
175 irq_desc[i].handler = &crisv10_irq_type;
176 set_int_vector(i, interrupt[i]);
179 /* the entries in the break vector contain actual code to be
180 executed by the associated break handler, rather than just a jump
181 address. therefore we need to setup a default breakpoint handler
182 for all breakpoints */
184 for (i = 0; i < 16; i++)
185 set_break_vector(i, do_sigtrap);
187 /* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
189 set_int_vector(15, multiple_interrupt);
191 /* 0 and 1 which are special breakpoint/NMI traps */
193 set_int_vector(0, hwbreakpoint);
194 set_int_vector(1, IRQ1_interrupt);
196 /* and irq 14 which is the mmu bus fault handler */
198 set_int_vector(14, mmu_bus_fault);
200 /* setup the system-call trap, which is reached by BREAK 13 */
202 set_break_vector(13, system_call);
204 /* setup a breakpoint handler for debugging used for both user and
205 kernel mode debugging (which is why it is not inside an ifdef
206 CONFIG_ETRAX_KGDB) */
207 set_break_vector(8, gdb_handle_breakpoint);
209 #ifdef CONFIG_ETRAX_KGDB
210 /* setup kgdb if its enabled, and break into the debugger */