]> git.wh0rd.org - patches.git/blame - bfin-request-exception.patch
sync vapier-m
[patches.git] / bfin-request-exception.patch
CommitLineData
5e993f12 1Index: include/asm-blackfin/irq_handler.h
2===================================================================
3--- include/asm-blackfin/irq_handler.h (revision 3496)
4+++ include/asm-blackfin/irq_handler.h (working copy)
5@@ -18,5 +21,13 @@
6 asmlinkage void evt_soft_int1(void);
7 asmlinkage void evt_system_call(void);
8 asmlinkage void init_exception_buff(void);
9+asmlinkage void trap_c(struct pt_regs *fp);
10+asmlinkage void ex_replaceable(void);
11
12+extern void *ex_table[];
13+extern void return_from_exception(void);
14+
15+extern int bfin_request_exception(unsigned int exception, void (*handler)(void));
16+extern int bfin_free_exception(unsigned int exception, void (*handler)(void));
17+
18 #endif
19Index: arch/blackfin/kernel/traps.c
20===================================================================
21--- arch/blackfin/kernel/traps.c (revision 3496)
22+++ arch/blackfin/kernel/traps.c (working copy)
23@@ -50,8 +50,6 @@
24 CSYNC();
25 }
26
27-asmlinkage void trap_c(struct pt_regs *fp);
28-
29 int kstack_depth_to_print = 48;
30
31 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
32@@ -673,9 +671,8 @@
33 }
34
35 #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
36-asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text));
37+__attribute__((l1_text))
38 #endif
39-
40 asmlinkage int sys_bfin_spinlock(int *spinlock)
41 {
42 int ret = 0;
43@@ -693,6 +690,42 @@
44 return ret;
45 }
46
47+int bfin_request_exception(unsigned int exception, void (*handler)(void))
48+{
49+ void (*curr_handler)(void);
50+
51+ if (exception > 0x3F)
52+ return -EINVAL;
53+
54+ curr_handler = ex_table[exception];
55+
56+ if (curr_handler != ex_replaceable)
57+ return -EBUSY;
58+
59+ ex_table[exception] = handler;
60+
61+ return 0;
62+}
63+EXPORT_SYMBOL(bfin_request_exception);
64+
65+int bfin_free_exception(unsigned int exception, void (*handler)(void))
66+{
67+ void (*curr_handler)(void);
68+
69+ if (exception > 0x3F)
70+ return -EINVAL;
71+
72+ curr_handler = ex_table[exception];
73+
74+ if (curr_handler != handler)
75+ return -EBUSY;
76+
77+ ex_table[exception] = ex_replaceable;
78+
79+ return 0;
80+}
81+EXPORT_SYMBOL(bfin_free_exception);
82+
83 void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
84 {
85 switch (cplb_panic) {
86Index: arch/blackfin/mach-common/entry.S
87===================================================================
88--- arch/blackfin/mach-common/entry.S (revision 3496)
89+++ arch/blackfin/mach-common/entry.S (working copy)
90@@ -135,7 +135,7 @@
91 cc = r6 == r7;
92 if !cc jump _ex_trap_c;
93
94-_return_from_exception:
95+ENTRY(_return_from_exception)
96 DEBUG_START_HWTRACE(p5, r7)
97 #if ANOMALY_05000257
98 R7=LC0;
99@@ -163,6 +163,9 @@
100 [--sp] = ASTAT;
101 [--sp] = (R7:6, P5:4);
102
103+ENTRY(_ex_replaceable)
104+ nop;
105+
106 ENTRY(_ex_trap_c)
107 /* Call C code (trap_c) to handle the exception, which most
108 * likely involves sending a signal to the current process.
109@@ -290,8 +293,8 @@
110 r6.l = lo(SEQSTAT_EXCAUSE);
111 r6.h = hi(SEQSTAT_EXCAUSE);
112 r7 = r7 & r6;
113- p5.h = _extable;
114- p5.l = _extable;
115+ p5.h = _ex_table;
116+ p5.l = _ex_table;
117 p4 = r7;
118 p5 = p5 + (p4 << 2);
119 p4 = [p5];
120@@ -810,28 +813,27 @@
121 #else
122 .data
123 #endif
124-ALIGN
125-_extable:
126+ENTRY(_ex_table)
127 /* entry for each EXCAUSE[5:0]
128 * This table must be in sync with the table in ./kernel/traps.c
129 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
130 */
131- .long _ex_syscall; /* 0x00 - User Defined - Linux Syscall */
132+ .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
133 .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */
134- .long _ex_trap_c /* 0x02 - User Defined */
135+ .long _ex_replaceable /* 0x02 - User Defined */
136 .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
137- .long _ex_trap_c /* 0x04 - User Defined */
138- .long _ex_trap_c /* 0x05 - User Defined */
139- .long _ex_trap_c /* 0x06 - User Defined */
140- .long _ex_trap_c /* 0x07 - User Defined */
141- .long _ex_trap_c /* 0x08 - User Defined */
142- .long _ex_trap_c /* 0x09 - User Defined */
143- .long _ex_trap_c /* 0x0A - User Defined */
144- .long _ex_trap_c /* 0x0B - User Defined */
145- .long _ex_trap_c /* 0x0C - User Defined */
146- .long _ex_trap_c /* 0x0D - User Defined */
147- .long _ex_trap_c /* 0x0E - User Defined */
148- .long _ex_trap_c /* 0x0F - User Defined */
149+ .long _ex_replaceable /* 0x04 - User Defined */
150+ .long _ex_replaceable /* 0x05 - User Defined */
151+ .long _ex_replaceable /* 0x06 - User Defined */
152+ .long _ex_replaceable /* 0x07 - User Defined */
153+ .long _ex_replaceable /* 0x08 - User Defined */
154+ .long _ex_replaceable /* 0x09 - User Defined */
155+ .long _ex_replaceable /* 0x0A - User Defined */
156+ .long _ex_replaceable /* 0x0B - User Defined */
157+ .long _ex_replaceable /* 0x0C - User Defined */
158+ .long _ex_replaceable /* 0x0D - User Defined */
159+ .long _ex_replaceable /* 0x0E - User Defined */
160+ .long _ex_replaceable /* 0x0F - User Defined */
161 .long _ex_single_step /* 0x10 - HW Single step */
162 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
163 .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
164@@ -885,8 +887,8 @@
165 .long _ex_trap_c /* 0x3D - Reserved */
166 .long _ex_trap_c /* 0x3E - Reserved */
167 .long _ex_trap_c /* 0x3F - Reserved */
168+END(_ex_table)
169
170-ALIGN
171 ENTRY(_sys_call_table)
172 .long _sys_ni_syscall /* 0 - old "setup()" system call*/
173 .long _sys_exit