blob: 1c3d2c5bb0bb873fcec8f65eb48379279e479c65 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Contains the system-call and fault low-level handling routines.
3 * This also contains the timer-interrupt handler, as well as all
4 * interrupts and faults that can result in a task-switch.
Bryan Wu1394f032007-05-06 14:50:22 -07005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Copyright 2005-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07007 *
Robin Getz96f10502009-09-24 14:11:24 +00008 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07009 */
10
Robin Getz2ebcade2007-10-09 17:24:30 +080011/* NOTE: This code handles signal-recognition, which happens every time
Bryan Wu1394f032007-05-06 14:50:22 -070012 * after a timer-interrupt and after each system call.
13 */
14
Mike Frysinger9cb07b22007-11-21 16:45:08 +080015#include <linux/init.h>
Bryan Wu1394f032007-05-06 14:50:22 -070016#include <linux/linkage.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080017#include <linux/unistd.h>
Bryan Wu1394f032007-05-06 14:50:22 -070018#include <asm/blackfin.h>
Bryan Wu1394f032007-05-06 14:50:22 -070019#include <asm/errno.h>
Bernd Schmidt5d750b92008-04-25 05:02:33 +080020#include <asm/fixed_code.h>
Bryan Wu1394f032007-05-06 14:50:22 -070021#include <asm/thread_info.h> /* TIF_NEED_RESCHED */
22#include <asm/asm-offsets.h>
Robin Getz669b7922007-06-21 16:34:08 +080023#include <asm/trace.h>
Robin Getz16aadcb2009-06-09 01:18:41 +000024#include <asm/traps.h>
Bryan Wu1394f032007-05-06 14:50:22 -070025
Bryan Wu639f6572008-08-27 10:51:02 +080026#include <asm/context.S>
Bryan Wu1394f032007-05-06 14:50:22 -070027
Mike Frysingerf0b5d122007-08-05 17:03:59 +080028
Bryan Wu1394f032007-05-06 14:50:22 -070029#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
30.section .l1.text
31#else
32.text
33#endif
34
35/* Slightly simplified and streamlined entry point for CPLB misses.
36 * This one does not lower the level to IRQ5, and thus can be used to
37 * patch up CPLB misses on the kernel stack.
38 */
Mike Frysinger1aafd902007-07-25 11:19:14 +080039#if ANOMALY_05000261
Robin Getzf26fbc42007-11-12 22:21:30 +080040#define _ex_dviol _ex_workaround_261
41#define _ex_dmiss _ex_workaround_261
42#define _ex_dmult _ex_workaround_261
43
44ENTRY(_ex_workaround_261)
Bryan Wu1394f032007-05-06 14:50:22 -070045 /*
46 * Work around an anomaly: if we see a new DCPLB fault, return
47 * without doing anything. Then, if we get the same fault again,
48 * handle it.
49 */
Robin Getzf26fbc42007-11-12 22:21:30 +080050 P4 = R7; /* Store EXCAUSE */
Graf Yang6b3087c2009-01-07 23:14:39 +080051
52 GET_PDA(p5, r7);
53 r7 = [p5 + PDA_LFRETX];
Bryan Wu1394f032007-05-06 14:50:22 -070054 r6 = retx;
Graf Yang6b3087c2009-01-07 23:14:39 +080055 [p5 + PDA_LFRETX] = r6;
Bryan Wu1394f032007-05-06 14:50:22 -070056 cc = r6 == r7;
Mike Frysinger8d6c2422007-11-21 15:53:49 +080057 if !cc jump _bfin_return_from_exception;
Bryan Wu1394f032007-05-06 14:50:22 -070058 /* fall through */
Robin Getzf26fbc42007-11-12 22:21:30 +080059 R7 = P4;
Robin Getz16aadcb2009-06-09 01:18:41 +000060 R6 = VEC_CPLB_M; /* Data CPLB Miss */
Robin Getzf26fbc42007-11-12 22:21:30 +080061 cc = R6 == R7;
62 if cc jump _ex_dcplb_miss (BP);
Robin Getz16aadcb2009-06-09 01:18:41 +000063#ifdef CONFIG_MPU
64 R6 = VEC_CPLB_VL; /* Data CPLB Violation */
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080065 cc = R6 == R7;
66 if cc jump _ex_dcplb_viol (BP);
Robin Getz16aadcb2009-06-09 01:18:41 +000067#endif
68 /* Handle Data CPLB Protection Violation
Robin Getzf26fbc42007-11-12 22:21:30 +080069 * and Data CPLB Multiple Hits - Linux Trap Zero
70 */
71 jump _ex_trap_c;
72ENDPROC(_ex_workaround_261)
Bryan Wu1394f032007-05-06 14:50:22 -070073
Robin Getzf26fbc42007-11-12 22:21:30 +080074#else
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080075#ifdef CONFIG_MPU
76#define _ex_dviol _ex_dcplb_viol
77#else
Robin Getzf26fbc42007-11-12 22:21:30 +080078#define _ex_dviol _ex_trap_c
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080079#endif
Robin Getzf26fbc42007-11-12 22:21:30 +080080#define _ex_dmiss _ex_dcplb_miss
81#define _ex_dmult _ex_trap_c
82#endif
83
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080084
85ENTRY(_ex_dcplb_viol)
Robin Getzf26fbc42007-11-12 22:21:30 +080086ENTRY(_ex_dcplb_miss)
87ENTRY(_ex_icplb_miss)
Bryan Wu1394f032007-05-06 14:50:22 -070088 (R7:6,P5:4) = [sp++];
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080089 /* We leave the previously pushed ASTAT on the stack. */
90 SAVE_CONTEXT_CPLB
91
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +080092 /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
93 * will change the stack pointer. */
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080094 R0 = SEQSTAT;
95 R1 = SP;
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080096
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +080097 DEBUG_HWTRACE_SAVE(p5, r7)
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080098
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080099 sp += -12;
100 call _cplb_hdr;
101 sp += 12;
102 CC = R0 == 0;
103 IF !CC JUMP _handle_bad_cplb;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800104
105#ifdef CONFIG_DEBUG_DOUBLEFAULT
106 /* While we were processing this, did we double fault? */
107 r7 = SEQSTAT; /* reason code is in bit 5:0 */
108 r6.l = lo(SEQSTAT_EXCAUSE);
109 r6.h = hi(SEQSTAT_EXCAUSE);
110 r7 = r7 & r6;
111 r6 = 0x25;
112 CC = R7 == R6;
113 if CC JUMP _double_fault;
114#endif
115
Mike Frysinger80f31c82008-02-02 15:47:24 +0800116 DEBUG_HWTRACE_RESTORE(p5, r7)
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +0800117 RESTORE_CONTEXT_CPLB
118 ASTAT = [SP++];
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800119 SP = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700120 rtx;
Robin Getzf26fbc42007-11-12 22:21:30 +0800121ENDPROC(_ex_icplb_miss)
Bryan Wu1394f032007-05-06 14:50:22 -0700122
Bryan Wu1394f032007-05-06 14:50:22 -0700123ENTRY(_ex_syscall)
Bryan Wu1394f032007-05-06 14:50:22 -0700124 raise 15; /* invoked by TRAP #0, for sys call */
Robin Getz0c7a6b22008-10-08 16:27:12 +0800125 jump.s _bfin_return_from_exception;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800126ENDPROC(_ex_syscall)
Bryan Wu1394f032007-05-06 14:50:22 -0700127
Bryan Wu1394f032007-05-06 14:50:22 -0700128ENTRY(_ex_single_step)
Bernd Schmidt0893f122008-05-07 11:41:26 +0800129 /* If we just returned from an interrupt, the single step event is
130 for the RTI instruction. */
Bryan Wu1394f032007-05-06 14:50:22 -0700131 r7 = retx;
132 r6 = reti;
133 cc = r7 == r6;
Bernd Schmidt0893f122008-05-07 11:41:26 +0800134 if cc jump _bfin_return_from_exception;
135
Jie Zhang5400c5a2008-08-05 17:33:38 +0800136#ifdef CONFIG_KGDB
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800137 /* Don't do single step in hardware exception handler */
138 p5.l = lo(IPEND);
139 p5.h = hi(IPEND);
140 r6 = [p5];
Sonic Zhangd6a29892008-08-05 18:28:26 +0800141 cc = bittst(r6, 4);
142 if cc jump _bfin_return_from_exception;
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800143 cc = bittst(r6, 5);
144 if cc jump _bfin_return_from_exception;
145
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800146 /* skip single step if current interrupt priority is higher than
147 * that of the first instruction, from which gdb starts single step */
148 r6 >>= 6;
149 r7 = 10;
150.Lfind_priority_start:
151 cc = bittst(r6, 0);
152 if cc jump .Lfind_priority_done;
153 r6 >>= 1;
154 r7 += -1;
155 cc = r7 == 0;
156 if cc jump .Lfind_priority_done;
157 jump.s .Lfind_priority_start;
158.Lfind_priority_done:
Sonic Zhanga5ac0122008-10-13 14:07:19 +0800159 p4.l = _kgdb_single_step;
160 p4.h = _kgdb_single_step;
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800161 r6 = [p4];
162 cc = r6 == 0;
163 if cc jump .Ldo_single_step;
164 r6 += -1;
165 cc = r6 < r7;
Sonic Zhangd6a29892008-08-05 18:28:26 +0800166 if cc jump 1f;
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800167.Ldo_single_step:
Sonic Zhangd6a29892008-08-05 18:28:26 +0800168#else
Bernd Schmidt0893f122008-05-07 11:41:26 +0800169 /* If we were in user mode, do the single step normally. */
Jie Zhang5400c5a2008-08-05 17:33:38 +0800170 p5.l = lo(IPEND);
171 p5.h = hi(IPEND);
Bernd Schmidt0893f122008-05-07 11:41:26 +0800172 r6 = [p5];
173 r7 = 0xffe0 (z);
174 r7 = r7 & r6;
175 cc = r7 == 0;
Jie Zhang5400c5a2008-08-05 17:33:38 +0800176 if !cc jump 1f;
Sonic Zhangd6a29892008-08-05 18:28:26 +0800177#endif
Robin Getzb9a38992009-05-18 18:33:26 +0000178#ifdef CONFIG_EXACT_HWERR
179 /* Read the ILAT, and to check to see if the process we are
180 * single stepping caused a previous hardware error
181 * If so, do not single step, (which lowers to IRQ5, and makes
182 * us miss the error).
183 */
184 p5.l = lo(ILAT);
185 p5.h = hi(ILAT);
186 r7 = [p5];
187 cc = bittst(r7, EVT_IVHW_P);
188 if cc jump 1f;
189#endif
Jie Zhang5400c5a2008-08-05 17:33:38 +0800190 /* Single stepping only a single instruction, so clear the trace
191 * bit here. */
192 r7 = syscfg;
Robin Getz19976602009-06-17 15:18:18 +0000193 bitclr (r7, SYSCFG_SSSTEP_P);
Jie Zhang5400c5a2008-08-05 17:33:38 +0800194 syscfg = R7;
195 jump _ex_trap_c;
196
1971:
Bernd Schmidt0893f122008-05-07 11:41:26 +0800198 /*
199 * We were in an interrupt handler. By convention, all of them save
200 * SYSCFG with their first instruction, so by checking whether our
201 * RETX points at the entry point, we can determine whether to allow
202 * a single step, or whether to clear SYSCFG.
203 *
204 * First, find out the interrupt level and the event vector for it.
205 */
206 p5.l = lo(EVT0);
207 p5.h = hi(EVT0);
208 p5 += -4;
2092:
210 r7 = rot r7 by -1;
211 p5 += 4;
212 if !cc jump 2b;
213
214 /* What we actually do is test for the _second_ instruction in the
215 * IRQ handler. That way, if there are insns following the restore
216 * of SYSCFG after leaving the handler, we will not turn off SYSCFG
217 * for them. */
218
219 r7 = [p5];
220 r7 += 2;
221 r6 = RETX;
222 cc = R7 == R6;
223 if !cc jump _bfin_return_from_exception;
224
Bryan Wu1394f032007-05-06 14:50:22 -0700225 r7 = syscfg;
Robin Getz19976602009-06-17 15:18:18 +0000226 bitclr (r7, SYSCFG_SSSTEP_P); /* Turn off single step */
Bryan Wu1394f032007-05-06 14:50:22 -0700227 syscfg = R7;
228
Jie Zhang5400c5a2008-08-05 17:33:38 +0800229 /* Fall through to _bfin_return_from_exception. */
Mike Frysinger46c87c32007-11-21 16:15:48 +0800230ENDPROC(_ex_single_step)
Bryan Wu1394f032007-05-06 14:50:22 -0700231
Mike Frysinger8d6c2422007-11-21 15:53:49 +0800232ENTRY(_bfin_return_from_exception)
Mike Frysinger1aafd902007-07-25 11:19:14 +0800233#if ANOMALY_05000257
Michael Hennerich8af10b72007-05-21 18:09:09 +0800234 R7=LC0;
235 LC0=R7;
236 R7=LC1;
237 LC1=R7;
238#endif
Robin Getz0c7a6b22008-10-08 16:27:12 +0800239
240#ifdef CONFIG_DEBUG_DOUBLEFAULT
241 /* While we were processing the current exception,
242 * did we cause another, and double fault?
243 */
244 r7 = SEQSTAT; /* reason code is in bit 5:0 */
245 r6.l = lo(SEQSTAT_EXCAUSE);
246 r6.h = hi(SEQSTAT_EXCAUSE);
247 r7 = r7 & r6;
Robin Getz16aadcb2009-06-09 01:18:41 +0000248 r6 = VEC_UNCOV;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800249 CC = R7 == R6;
250 if CC JUMP _double_fault;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800251#endif
252
Bryan Wu1394f032007-05-06 14:50:22 -0700253 (R7:6,P5:4) = [sp++];
254 ASTAT = [sp++];
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800255 sp = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700256 rtx;
Mike Frysinger46c87c32007-11-21 16:15:48 +0800257ENDPROC(_bfin_return_from_exception)
Bryan Wu1394f032007-05-06 14:50:22 -0700258
259ENTRY(_handle_bad_cplb)
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800260 DEBUG_HWTRACE_RESTORE(p5, r7)
Bryan Wu1394f032007-05-06 14:50:22 -0700261 /* To get here, we just tried and failed to change a CPLB
262 * so, handle things in trap_c (C code), by lowering to
263 * IRQ5, just like we normally do. Since this is not a
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300264 * "normal" return path, we have a do a lot of stuff to
Bryan Wu1394f032007-05-06 14:50:22 -0700265 * the stack to get ready so, we can fall through - we
266 * need to make a CPLB exception look like a normal exception
267 */
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +0800268 RESTORE_CONTEXT_CPLB
269 /* ASTAT is still on the stack, where it is needed. */
Mike Frysinger80f31c82008-02-02 15:47:24 +0800270 [--sp] = (R7:6,P5:4);
Bryan Wu1394f032007-05-06 14:50:22 -0700271
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800272ENTRY(_ex_replaceable)
273 nop;
274
Bryan Wu1394f032007-05-06 14:50:22 -0700275ENTRY(_ex_trap_c)
Robin Getzae4f0732009-06-22 02:02:16 +0000276 /* The only thing that has been saved in this context is
277 * (R7:6,P5:4), ASTAT & SP - don't use anything else
278 */
279
280 GET_PDA(p5, r6);
281
Robin Getz2ebcade2007-10-09 17:24:30 +0800282 /* Make sure we are not in a double fault */
283 p4.l = lo(IPEND);
284 p4.h = hi(IPEND);
285 r7 = [p4];
286 CC = BITTST (r7, 5);
287 if CC jump _double_fault;
Robin Getzae4f0732009-06-22 02:02:16 +0000288 [p5 + PDA_EXIPEND] = r7;
Robin Getz2ebcade2007-10-09 17:24:30 +0800289
Bryan Wu1394f032007-05-06 14:50:22 -0700290 /* Call C code (trap_c) to handle the exception, which most
291 * likely involves sending a signal to the current process.
292 * To avoid double faults, lower our priority to IRQ5 first.
293 */
Robin Getzae4f0732009-06-22 02:02:16 +0000294 r7.h = _exception_to_level5;
295 r7.l = _exception_to_level5;
Bryan Wu1394f032007-05-06 14:50:22 -0700296 p4.l = lo(EVT5);
297 p4.h = hi(EVT5);
Robin Getzae4f0732009-06-22 02:02:16 +0000298 [p4] = r7;
Bryan Wu1394f032007-05-06 14:50:22 -0700299 csync;
300
Robin Getz0c7a6b22008-10-08 16:27:12 +0800301 /*
302 * Save these registers, as they are only valid in exception context
303 * (where we are now - as soon as we defer to IRQ5, they can change)
304 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
305 * but they are not very interesting, so don't save them
306 */
307
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800308 p4.l = lo(DCPLB_FAULT_ADDR);
309 p4.h = hi(DCPLB_FAULT_ADDR);
310 r7 = [p4];
Graf Yang6b3087c2009-01-07 23:14:39 +0800311 [p5 + PDA_DCPLB] = r7;
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800312
Graf Yang6b3087c2009-01-07 23:14:39 +0800313 p4.l = lo(ICPLB_FAULT_ADDR);
314 p4.h = hi(ICPLB_FAULT_ADDR);
315 r6 = [p4];
316 [p5 + PDA_ICPLB] = r6;
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800317
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800318 r6 = retx;
Graf Yang6b3087c2009-01-07 23:14:39 +0800319 [p5 + PDA_RETX] = r6;
Graf Yang01b9f4b2009-07-22 11:56:24 +0000320
321 r6 = SEQSTAT;
322 [p5 + PDA_SEQSTAT] = r6;
323
Robin Getz19976602009-06-17 15:18:18 +0000324 /* Save the state of single stepping */
Bernd Schmidt0893f122008-05-07 11:41:26 +0800325 r6 = SYSCFG;
Graf Yang6b3087c2009-01-07 23:14:39 +0800326 [p5 + PDA_SYSCFG] = r6;
Robin Getz19976602009-06-17 15:18:18 +0000327 /* Clear it while we handle the exception in IRQ5 mode */
328 BITCLR(r6, SYSCFG_SSSTEP_P);
Bernd Schmidt0893f122008-05-07 11:41:26 +0800329 SYSCFG = r6;
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800330
Robin Getzae4f0732009-06-22 02:02:16 +0000331 /* Save the current IMASK, since we change in order to jump to level 5 */
Bryan Wu1394f032007-05-06 14:50:22 -0700332 cli r6;
Graf Yang6b3087c2009-01-07 23:14:39 +0800333 [p5 + PDA_EXIMASK] = r6;
Bernd Schmidt0893f122008-05-07 11:41:26 +0800334
335 p4.l = lo(SAFE_USER_INSTRUCTION);
336 p4.h = hi(SAFE_USER_INSTRUCTION);
337 retx = p4;
338
Robin Getzae4f0732009-06-22 02:02:16 +0000339 /* Disable all interrupts, but make sure level 5 is enabled so
340 * we can switch to that level.
341 */
Bryan Wu1394f032007-05-06 14:50:22 -0700342 r6 = 0x3f;
343 sti r6;
344
Robin Getzae4f0732009-06-22 02:02:16 +0000345 /* In case interrupts are disabled IPEND[4] (global interrupt disable bit)
346 * clear it (re-enabling interrupts again) by the special sequence of pushing
347 * RETI onto the stack. This way we can lower ourselves to IVG5 even if the
348 * exception was taken after the interrupt handler was called but before it
349 * got a chance to enable global interrupts itself.
350 */
351 [--sp] = reti;
352 sp += 4;
353
Bryan Wu1394f032007-05-06 14:50:22 -0700354 raise 5;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800355 jump.s _bfin_return_from_exception;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800356ENDPROC(_ex_trap_c)
Bryan Wu1394f032007-05-06 14:50:22 -0700357
Robin Getz2ebcade2007-10-09 17:24:30 +0800358/* We just realized we got an exception, while we were processing a different
Mike Frysinger33c86912008-11-18 17:48:22 +0800359 * exception. This is a unrecoverable event, so crash.
360 * Note: this cannot be ENTRY() as we jump here with "if cc jump" ...
Robin Getz2ebcade2007-10-09 17:24:30 +0800361 */
Robin Getz19976602009-06-17 15:18:18 +0000362ENTRY(_double_fault)
Robin Getz0c7a6b22008-10-08 16:27:12 +0800363 /* Turn caches & protection off, to ensure we don't get any more
364 * double exceptions
365 */
Robin Getz2ebcade2007-10-09 17:24:30 +0800366
Robin Getz0c7a6b22008-10-08 16:27:12 +0800367 P4.L = LO(IMEM_CONTROL);
368 P4.H = HI(IMEM_CONTROL);
Robin Getz2ebcade2007-10-09 17:24:30 +0800369
Robin Getz0c7a6b22008-10-08 16:27:12 +0800370 R5 = [P4]; /* Control Register*/
371 BITCLR(R5,ENICPLB_P);
Yi Lieb7bd9c2009-08-07 01:20:58 +0000372 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
Robin Getz0c7a6b22008-10-08 16:27:12 +0800373 [P4] = R5;
374 SSYNC;
Robin Getz2ebcade2007-10-09 17:24:30 +0800375
Robin Getz0c7a6b22008-10-08 16:27:12 +0800376 P4.L = LO(DMEM_CONTROL);
377 P4.H = HI(DMEM_CONTROL);
378 R5 = [P4];
379 BITCLR(R5,ENDCPLB_P);
Yi Lieb7bd9c2009-08-07 01:20:58 +0000380 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
Robin Getz0c7a6b22008-10-08 16:27:12 +0800381 [P4] = R5;
382 SSYNC;
Robin Getz2ebcade2007-10-09 17:24:30 +0800383
Robin Getz0c7a6b22008-10-08 16:27:12 +0800384 /* Fix up the stack */
385 (R7:6,P5:4) = [sp++];
386 ASTAT = [sp++];
387 SP = EX_SCRATCH_REG;
Robin Getz2ebcade2007-10-09 17:24:30 +0800388
Robin Getz0c7a6b22008-10-08 16:27:12 +0800389 /* We should be out of the exception stack, and back down into
390 * kernel or user space stack
391 */
392 SAVE_ALL_SYS
Robin Getz2ebcade2007-10-09 17:24:30 +0800393
Bernd Schmidtddb3f002008-05-07 11:41:26 +0800394 /* The dumping functions expect the return address in the RETI
395 * slot. */
396 r6 = retx;
397 [sp + PT_PC] = r6;
398
Robin Getz0c7a6b22008-10-08 16:27:12 +0800399 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
400 SP += -12;
Barry Songd86bfb12010-01-07 04:11:17 +0000401 pseudo_long_call _double_fault_c, p5;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800402 SP += 12;
Robin Getz2ebcade2007-10-09 17:24:30 +0800403.L_double_fault_panic:
404 JUMP .L_double_fault_panic
405
406ENDPROC(_double_fault)
407
Bryan Wu1394f032007-05-06 14:50:22 -0700408ENTRY(_exception_to_level5)
409 SAVE_ALL_SYS
410
Robin Getzae4f0732009-06-22 02:02:16 +0000411 GET_PDA(p5, r7); /* Fetch current PDA */
412 r6 = [p5 + PDA_RETX];
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800413 [sp + PT_PC] = r6;
414
Robin Getzae4f0732009-06-22 02:02:16 +0000415 r6 = [p5 + PDA_SYSCFG];
Bernd Schmidt0893f122008-05-07 11:41:26 +0800416 [sp + PT_SYSCFG] = r6;
417
Graf Yang01b9f4b2009-07-22 11:56:24 +0000418 r6 = [p5 + PDA_SEQSTAT]; /* Read back seqstat */
419 [sp + PT_SEQSTAT] = r6;
420
Bryan Wu1394f032007-05-06 14:50:22 -0700421 /* Restore the hardware error vector. */
Robin Getzae4f0732009-06-22 02:02:16 +0000422 r7.h = _evt_ivhw;
423 r7.l = _evt_ivhw;
Bryan Wu1394f032007-05-06 14:50:22 -0700424 p4.l = lo(EVT5);
425 p4.h = hi(EVT5);
Robin Getzae4f0732009-06-22 02:02:16 +0000426 [p4] = r7;
Bryan Wu1394f032007-05-06 14:50:22 -0700427 csync;
428
Robin Getzae4f0732009-06-22 02:02:16 +0000429#ifdef CONFIG_DEBUG_DOUBLEFAULT
430 /* Now that we have the hardware error vector programmed properly
431 * we can re-enable interrupts (IPEND[4]), so if the _trap_c causes
432 * another hardware error, we can catch it (self-nesting).
433 */
434 [--sp] = reti;
435 sp += 4;
436#endif
437
438 r7 = [p5 + PDA_EXIPEND] /* Read the IPEND from the Exception state */
439 [sp + PT_IPEND] = r7; /* Store IPEND onto the stack */
Bryan Wu1394f032007-05-06 14:50:22 -0700440
Bryan Wu1394f032007-05-06 14:50:22 -0700441 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
442 SP += -12;
Barry Songd86bfb12010-01-07 04:11:17 +0000443 pseudo_long_call _trap_c, p4;
Bryan Wu1394f032007-05-06 14:50:22 -0700444 SP += 12;
445
Robin Getzae4f0732009-06-22 02:02:16 +0000446 /* If interrupts were off during the exception (IPEND[4] = 1), turn them off
447 * before we return.
448 */
449 CC = BITTST(r7, EVT_IRPTEN_P)
450 if !CC jump 1f;
451 /* this will load a random value into the reti register - but that is OK,
452 * since we do restore it to the correct value in the 'RESTORE_ALL_SYS' macro
453 */
454 sp += -4;
455 reti = [sp++];
4561:
457 /* restore the interrupt mask (IMASK) */
458 r6 = [p5 + PDA_EXIMASK];
459 sti r6;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800460
Bryan Wu1394f032007-05-06 14:50:22 -0700461 call _ret_from_exception;
462 RESTORE_ALL_SYS
463 rti;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800464ENDPROC(_exception_to_level5)
Bryan Wu1394f032007-05-06 14:50:22 -0700465
466ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
467 /* Since the kernel stack can be anywhere, it's not guaranteed to be
468 * covered by a CPLB. Switch to an exception stack; use RETN as a
469 * scratch register (for want of a better option).
470 */
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800471 EX_SCRATCH_REG = sp;
Graf Yang6b3087c2009-01-07 23:14:39 +0800472 GET_PDA_SAFE(sp);
Graf Yang01b9f4b2009-07-22 11:56:24 +0000473 sp = [sp + PDA_EXSTACK];
Bryan Wu1394f032007-05-06 14:50:22 -0700474 /* Try to deal with syscalls quickly. */
475 [--sp] = ASTAT;
Mike Frysinger80f31c82008-02-02 15:47:24 +0800476 [--sp] = (R7:6,P5:4);
Robin Getz0c7a6b22008-10-08 16:27:12 +0800477
Robin Getz2943bff2010-02-25 18:16:52 +0000478 ANOMALY_283_315_WORKAROUND(p5, r7)
479
Robin Getzb9a38992009-05-18 18:33:26 +0000480#ifdef CONFIG_EXACT_HWERR
481 /* Make sure all pending read/writes complete. This will ensure any
482 * accesses which could cause hardware errors completes, and signal
483 * the the hardware before we do something silly, like crash the
484 * kernel. We don't need to work around anomaly 05000312, since
485 * we are already atomic
486 */
487 ssync;
488#endif
489
Robin Getz0c7a6b22008-10-08 16:27:12 +0800490#ifdef CONFIG_DEBUG_DOUBLEFAULT
491 /*
492 * Save these registers, as they are only valid in exception context
493 * (where we are now - as soon as we defer to IRQ5, they can change)
494 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
495 * but they are not very interesting, so don't save them
496 */
497
Graf Yang6b3087c2009-01-07 23:14:39 +0800498 GET_PDA(p5, r7);
Robin Getz0c7a6b22008-10-08 16:27:12 +0800499 p4.l = lo(DCPLB_FAULT_ADDR);
500 p4.h = hi(DCPLB_FAULT_ADDR);
501 r7 = [p4];
Graf Yang01b9f4b2009-07-22 11:56:24 +0000502 [p5 + PDA_DF_DCPLB] = r7;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800503
Graf Yang6b3087c2009-01-07 23:14:39 +0800504 p4.l = lo(ICPLB_FAULT_ADDR);
505 p4.h = hi(ICPLB_FAULT_ADDR);
506 r7 = [p4];
Graf Yang01b9f4b2009-07-22 11:56:24 +0000507 [p5 + PDA_DF_ICPLB] = r7;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800508
Graf Yang01b9f4b2009-07-22 11:56:24 +0000509 r7 = retx;
510 [p5 + PDA_DF_RETX] = r7;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800511
Bryan Wu1394f032007-05-06 14:50:22 -0700512 r7 = SEQSTAT; /* reason code is in bit 5:0 */
Graf Yang01b9f4b2009-07-22 11:56:24 +0000513 [p5 + PDA_DF_SEQSTAT] = r7;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800514#else
515 r7 = SEQSTAT; /* reason code is in bit 5:0 */
516#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700517 r6.l = lo(SEQSTAT_EXCAUSE);
518 r6.h = hi(SEQSTAT_EXCAUSE);
519 r7 = r7 & r6;
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800520 p5.h = _ex_table;
521 p5.l = _ex_table;
Bryan Wu1394f032007-05-06 14:50:22 -0700522 p4 = r7;
523 p5 = p5 + (p4 << 2);
524 p4 = [p5];
525 jump (p4);
526
527.Lbadsys:
528 r7 = -ENOSYS; /* signextending enough */
529 [sp + PT_R0] = r7; /* return value from system call */
530 jump .Lsyscall_really_exit;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800531ENDPROC(_trap)
Bryan Wu1394f032007-05-06 14:50:22 -0700532
533ENTRY(_kernel_execve)
534 link SIZEOF_PTREGS;
535 p0 = sp;
536 r3 = SIZEOF_PTREGS / 4;
537 r4 = 0(x);
Graf Yang6b3087c2009-01-07 23:14:39 +0800538.Lclear_regs:
Bryan Wu1394f032007-05-06 14:50:22 -0700539 [p0++] = r4;
540 r3 += -1;
541 cc = r3 == 0;
Graf Yang6b3087c2009-01-07 23:14:39 +0800542 if !cc jump .Lclear_regs (bp);
Bryan Wu1394f032007-05-06 14:50:22 -0700543
544 p0 = sp;
545 sp += -16;
546 [sp + 12] = p0;
Barry Songd86bfb12010-01-07 04:11:17 +0000547 pseudo_long_call _do_execve, p5;
Bryan Wu1394f032007-05-06 14:50:22 -0700548 SP += 16;
549 cc = r0 == 0;
Graf Yang6b3087c2009-01-07 23:14:39 +0800550 if ! cc jump .Lexecve_failed;
Bryan Wu1394f032007-05-06 14:50:22 -0700551 /* Success. Copy our temporary pt_regs to the top of the kernel
552 * stack and do a normal exception return.
553 */
554 r1 = sp;
555 r0 = (-KERNEL_STACK_SIZE) (x);
556 r1 = r1 & r0;
557 p2 = r1;
558 p3 = [p2];
559 r0 = KERNEL_STACK_SIZE - 4 (z);
560 p1 = r0;
561 p1 = p1 + p2;
562
563 p0 = fp;
564 r4 = [p0--];
565 r3 = SIZEOF_PTREGS / 4;
Graf Yang6b3087c2009-01-07 23:14:39 +0800566.Lcopy_regs:
Bryan Wu1394f032007-05-06 14:50:22 -0700567 r4 = [p0--];
568 [p1--] = r4;
569 r3 += -1;
570 cc = r3 == 0;
Graf Yang6b3087c2009-01-07 23:14:39 +0800571 if ! cc jump .Lcopy_regs (bp);
Bryan Wu1394f032007-05-06 14:50:22 -0700572
573 r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
574 p1 = r0;
575 p1 = p1 + p2;
576 sp = p1;
577 r0 = syscfg;
578 [SP + PT_SYSCFG] = r0;
579 [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
580
581 RESTORE_CONTEXT;
582 rti;
Graf Yang6b3087c2009-01-07 23:14:39 +0800583.Lexecve_failed:
Bryan Wu1394f032007-05-06 14:50:22 -0700584 unlink;
585 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800586ENDPROC(_kernel_execve)
Bryan Wu1394f032007-05-06 14:50:22 -0700587
588ENTRY(_system_call)
589 /* Store IPEND */
590 p2.l = lo(IPEND);
591 p2.h = hi(IPEND);
592 csync;
593 r0 = [p2];
594 [sp + PT_IPEND] = r0;
595
596 /* Store RETS for now */
597 r0 = rets;
598 [sp + PT_RESERVED] = r0;
599 /* Set the stack for the current process */
600 r7 = sp;
601 r6.l = lo(ALIGN_PAGE_MASK);
602 r6.h = hi(ALIGN_PAGE_MASK);
603 r7 = r7 & r6; /* thread_info */
604 p2 = r7;
605 p2 = [p2];
606
607 [p2+(TASK_THREAD+THREAD_KSP)] = sp;
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800608#ifdef CONFIG_IPIPE
609 r0 = sp;
610 SP += -12;
Mike Frysinger503f3d32010-11-14 00:02:53 +0000611 pseudo_long_call ___ipipe_syscall_root, p0;
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800612 SP += 12;
613 cc = r0 == 1;
614 if cc jump .Lsyscall_really_exit;
615 cc = r0 == -1;
616 if cc jump .Lresume_userspace;
617 r3 = [sp + PT_R3];
618 r4 = [sp + PT_R4];
619 p0 = [sp + PT_ORIG_P0];
620#endif /* CONFIG_IPIPE */
Bryan Wu1394f032007-05-06 14:50:22 -0700621
Bryan Wu1394f032007-05-06 14:50:22 -0700622 /* are we tracing syscalls?*/
623 r7 = sp;
624 r6.l = lo(ALIGN_PAGE_MASK);
625 r6.h = hi(ALIGN_PAGE_MASK);
626 r7 = r7 & r6;
627 p2 = r7;
628 r7 = [p2+TI_FLAGS];
629 CC = BITTST(r7,TIF_SYSCALL_TRACE);
630 if CC JUMP _sys_trace;
Mike Frysinger600482c2010-02-17 10:44:22 +0000631 CC = BITTST(r7,TIF_SINGLESTEP);
632 if CC JUMP _sys_trace;
Bryan Wu1394f032007-05-06 14:50:22 -0700633
Mike Frysinger9e228ee2010-02-12 07:24:34 +0000634 /* Make sure the system call # is valid */
635 p4 = __NR_syscall;
636 /* System call number is passed in P0 */
637 cc = p4 <= p0;
638 if cc jump .Lbadsys;
639
Bryan Wu1394f032007-05-06 14:50:22 -0700640 /* Execute the appropriate system call */
641
642 p4 = p0;
643 p5.l = _sys_call_table;
644 p5.h = _sys_call_table;
645 p5 = p5 + (p4 << 2);
646 r0 = [sp + PT_R0];
647 r1 = [sp + PT_R1];
648 r2 = [sp + PT_R2];
649 p5 = [p5];
650
651 [--sp] = r5;
652 [--sp] = r4;
653 [--sp] = r3;
654 SP += -12;
655 call (p5);
656 SP += 24;
657 [sp + PT_R0] = r0;
658
659.Lresume_userspace:
660 r7 = sp;
661 r4.l = lo(ALIGN_PAGE_MASK);
662 r4.h = hi(ALIGN_PAGE_MASK);
663 r7 = r7 & r4; /* thread_info->flags */
664 p5 = r7;
665.Lresume_userspace_1:
666 /* Disable interrupts. */
667 [--sp] = reti;
668 reti = [sp++];
669
670 r7 = [p5 + TI_FLAGS];
671 r4.l = lo(_TIF_WORK_MASK);
672 r4.h = hi(_TIF_WORK_MASK);
673 r7 = r7 & r4;
674
675.Lsyscall_resched:
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800676#ifdef CONFIG_IPIPE
677 cc = BITTST(r7, TIF_IRQ_SYNC);
678 if !cc jump .Lsyscall_no_irqsync;
Philippe Gerum9ea77702009-06-22 18:26:07 +0200679 /*
680 * Clear IPEND[4] manually to undo what resume_userspace_1 just did;
681 * we need this so that high priority domain interrupts may still
682 * preempt the current domain while the pipeline log is being played
683 * back.
684 */
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800685 [--sp] = reti;
Philippe Gerum9ea77702009-06-22 18:26:07 +0200686 SP += 4; /* don't merge with next insn to keep the pattern obvious */
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800687 SP += -12;
Mike Frysinger503f3d32010-11-14 00:02:53 +0000688 pseudo_long_call ___ipipe_sync_root, p4;
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800689 SP += 12;
690 jump .Lresume_userspace_1;
691.Lsyscall_no_irqsync:
692#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700693 cc = BITTST(r7, TIF_NEED_RESCHED);
694 if !cc jump .Lsyscall_sigpending;
695
696 /* Reenable interrupts. */
697 [--sp] = reti;
Philippe Gerum9ea77702009-06-22 18:26:07 +0200698 sp += 4;
Bryan Wu1394f032007-05-06 14:50:22 -0700699
700 SP += -12;
Barry Songd86bfb12010-01-07 04:11:17 +0000701 pseudo_long_call _schedule, p4;
Bryan Wu1394f032007-05-06 14:50:22 -0700702 SP += 12;
703
704 jump .Lresume_userspace_1;
705
706.Lsyscall_sigpending:
Bryan Wu1394f032007-05-06 14:50:22 -0700707 cc = BITTST(r7, TIF_SIGPENDING);
Barry Songd1be2e42009-12-08 09:55:37 +0000708 if cc jump .Lsyscall_do_signals;
709 cc = BITTST(r7, TIF_NOTIFY_RESUME);
Bryan Wu1394f032007-05-06 14:50:22 -0700710 if !cc jump .Lsyscall_really_exit;
711.Lsyscall_do_signals:
712 /* Reenable interrupts. */
713 [--sp] = reti;
Philippe Gerum9ea77702009-06-22 18:26:07 +0200714 sp += 4;
Bryan Wu1394f032007-05-06 14:50:22 -0700715
716 r0 = sp;
717 SP += -12;
Barry Songd86bfb12010-01-07 04:11:17 +0000718 pseudo_long_call _do_notify_resume, p5;
Bryan Wu1394f032007-05-06 14:50:22 -0700719 SP += 12;
720
721.Lsyscall_really_exit:
722 r5 = [sp + PT_RESERVED];
723 rets = r5;
724 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800725ENDPROC(_system_call)
Bryan Wu1394f032007-05-06 14:50:22 -0700726
Mike Frysinger47664c12008-10-09 15:32:18 +0800727/* Do not mark as ENTRY() to avoid error in assembler ...
728 * this symbol need not be global anyways, so ...
729 */
Bryan Wu1394f032007-05-06 14:50:22 -0700730_sys_trace:
Mike Frysingere8f263d2010-01-26 07:33:53 +0000731 r0 = sp;
732 pseudo_long_call _syscall_trace_enter, p5;
Bryan Wu1394f032007-05-06 14:50:22 -0700733
Mike Frysinger9e228ee2010-02-12 07:24:34 +0000734 /* Make sure the system call # is valid */
Bryan Wu1394f032007-05-06 14:50:22 -0700735 p4 = [SP + PT_P0];
Mike Frysinger9e228ee2010-02-12 07:24:34 +0000736 p3 = __NR_syscall;
737 cc = p3 <= p4;
738 r0 = -ENOSYS;
739 if cc jump .Lsys_trace_badsys;
740
741 /* Execute the appropriate system call */
Bryan Wu1394f032007-05-06 14:50:22 -0700742 p5.l = _sys_call_table;
743 p5.h = _sys_call_table;
744 p5 = p5 + (p4 << 2);
745 r0 = [sp + PT_R0];
746 r1 = [sp + PT_R1];
747 r2 = [sp + PT_R2];
748 r3 = [sp + PT_R3];
749 r4 = [sp + PT_R4];
750 r5 = [sp + PT_R5];
751 p5 = [p5];
752
753 [--sp] = r5;
754 [--sp] = r4;
755 [--sp] = r3;
756 SP += -12;
757 call (p5);
758 SP += 24;
Mike Frysinger9e228ee2010-02-12 07:24:34 +0000759.Lsys_trace_badsys:
Bryan Wu1394f032007-05-06 14:50:22 -0700760 [sp + PT_R0] = r0;
761
Mike Frysingere8f263d2010-01-26 07:33:53 +0000762 r0 = sp;
763 pseudo_long_call _syscall_trace_leave, p5;
Bryan Wu1394f032007-05-06 14:50:22 -0700764 jump .Lresume_userspace;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800765ENDPROC(_sys_trace)
Bryan Wu1394f032007-05-06 14:50:22 -0700766
767ENTRY(_resume)
768 /*
769 * Beware - when entering resume, prev (the current task) is
770 * in r0, next (the new task) is in r1.
771 */
772 p0 = r0;
773 p1 = r1;
774 [--sp] = rets;
775 [--sp] = fp;
776 [--sp] = (r7:4, p5:3);
777
778 /* save usp */
779 p2 = usp;
780 [p0+(TASK_THREAD+THREAD_USP)] = p2;
781
782 /* save current kernel stack pointer */
783 [p0+(TASK_THREAD+THREAD_KSP)] = sp;
784
785 /* save program counter */
786 r1.l = _new_old_task;
787 r1.h = _new_old_task;
788 [p0+(TASK_THREAD+THREAD_PC)] = r1;
789
790 /* restore the kernel stack pointer */
791 sp = [p1+(TASK_THREAD+THREAD_KSP)];
792
793 /* restore user stack pointer */
794 p0 = [p1+(TASK_THREAD+THREAD_USP)];
795 usp = p0;
796
797 /* restore pc */
798 p0 = [p1+(TASK_THREAD+THREAD_PC)];
799 jump (p0);
800
801 /*
802 * Following code actually lands up in a new (old) task.
803 */
804
805_new_old_task:
806 (r7:4, p5:3) = [sp++];
807 fp = [sp++];
808 rets = [sp++];
809
810 /*
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300811 * When we come out of resume, r0 carries "old" task, because we are
Bryan Wu1394f032007-05-06 14:50:22 -0700812 * in "new" task.
813 */
814 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800815ENDPROC(_resume)
Bryan Wu1394f032007-05-06 14:50:22 -0700816
817ENTRY(_ret_from_exception)
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800818#ifdef CONFIG_IPIPE
Rusty Russelldd17c8f2009-10-29 22:34:15 +0900819 p2.l = _ipipe_percpu_domain;
820 p2.h = _ipipe_percpu_domain;
Philippe Gerumf4e12932009-06-22 18:26:22 +0200821 r0.l = _ipipe_root;
822 r0.h = _ipipe_root;
823 r2 = [p2];
824 cc = r0 == r2;
825 if !cc jump 4f; /* not on behalf of the root domain, get out */
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800826#endif /* CONFIG_IPIPE */
Bryan Wu1394f032007-05-06 14:50:22 -0700827 p2.l = lo(IPEND);
828 p2.h = hi(IPEND);
829
830 csync;
831 r0 = [p2];
832 [sp + PT_IPEND] = r0;
833
8341:
Robin Getzd5c4b5e2007-12-21 17:49:53 +0800835 r2 = LO(~0x37) (Z);
Bryan Wu1394f032007-05-06 14:50:22 -0700836 r0 = r2 & r0;
837 cc = r0 == 0;
838 if !cc jump 4f; /* if not return to user mode, get out */
839
840 /* Make sure any pending system call or deferred exception
841 * return in ILAT for this process to get executed, otherwise
842 * in case context switch happens, system call of
843 * first process (i.e in ILAT) will be carried
844 * forward to the switched process
845 */
846
847 p2.l = lo(ILAT);
848 p2.h = hi(ILAT);
849 r0 = [p2];
850 r1 = (EVT_IVG14 | EVT_IVG15) (z);
851 r0 = r0 & r1;
852 cc = r0 == 0;
853 if !cc jump 5f;
854
855 /* Set the stack for the current process */
856 r7 = sp;
857 r4.l = lo(ALIGN_PAGE_MASK);
858 r4.h = hi(ALIGN_PAGE_MASK);
859 r7 = r7 & r4; /* thread_info->flags */
860 p5 = r7;
861 r7 = [p5 + TI_FLAGS];
862 r4.l = lo(_TIF_WORK_MASK);
863 r4.h = hi(_TIF_WORK_MASK);
864 r7 = r7 & r4;
865 cc = r7 == 0;
866 if cc jump 4f;
867
868 p0.l = lo(EVT15);
869 p0.h = hi(EVT15);
870 p1.l = _schedule_and_signal;
871 p1.h = _schedule_and_signal;
872 [p0] = p1;
873 csync;
Robin Getzb9a38992009-05-18 18:33:26 +0000874 raise 15; /* raise evt15 to do signal or reschedule */
Bryan Wu1394f032007-05-06 14:50:22 -07008754:
876 r0 = syscfg;
Robin Getz19976602009-06-17 15:18:18 +0000877 bitclr(r0, SYSCFG_SSSTEP_P); /* Turn off single step */
Bryan Wu1394f032007-05-06 14:50:22 -0700878 syscfg = r0;
8795:
880 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800881ENDPROC(_ret_from_exception)
Bryan Wu1394f032007-05-06 14:50:22 -0700882
Barry Song33ded952010-08-12 07:56:40 +0000883#if defined(CONFIG_PREEMPT)
884
885ENTRY(_up_to_irq14)
886#if ANOMALY_05000281 || ANOMALY_05000461
887 r0.l = lo(SAFE_USER_INSTRUCTION);
888 r0.h = hi(SAFE_USER_INSTRUCTION);
889 reti = r0;
890#endif
891
892#ifdef CONFIG_DEBUG_HWERR
893 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
894 r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
895#else
896 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
897 r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
898#endif
899 sti r0;
900
901 p0.l = lo(EVT14);
902 p0.h = hi(EVT14);
903 p1.l = _evt_up_evt14;
904 p1.h = _evt_up_evt14;
905 [p0] = p1;
906 csync;
907
908 raise 14;
9091:
910 jump 1b;
911ENDPROC(_up_to_irq14)
912
913ENTRY(_evt_up_evt14)
914#ifdef CONFIG_DEBUG_HWERR
915 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
916 sti r0;
917#else
918 cli r0;
919#endif
920#ifdef CONFIG_TRACE_IRQFLAGS
921 [--sp] = rets;
922 sp += -12;
923 call _trace_hardirqs_off;
924 sp += 12;
925 rets = [sp++];
926#endif
927 [--sp] = RETI;
928 SP += 4;
929
930 /* restore normal evt14 */
931 p0.l = lo(EVT14);
932 p0.h = hi(EVT14);
933 p1.l = _evt_evt14;
934 p1.h = _evt_evt14;
935 [p0] = p1;
936 csync;
937
938 rts;
939ENDPROC(_evt_up_evt14)
940
941#endif
942
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800943#ifdef CONFIG_IPIPE
944
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800945_resume_kernel_from_int:
Philippe Gerum9169b512011-03-17 02:15:24 -0400946 r1 = LO(~0x8000) (Z);
947 r1 = r0 & r1;
948 r0 = 1;
949 r0 = r1 - r0;
950 r2 = r1 & r0;
951 cc = r2 == 0;
952 /* Sync the root stage only from the outer interrupt level. */
953 if !cc jump .Lnosync;
Philippe Gerum9ea77702009-06-22 18:26:07 +0200954 r0.l = ___ipipe_sync_root;
955 r0.h = ___ipipe_sync_root;
Philippe Gerum9169b512011-03-17 02:15:24 -0400956 [--sp] = reti;
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800957 [--sp] = rets;
958 [--sp] = ( r7:4, p5:3 );
959 SP += -12;
960 call ___ipipe_call_irqtail
961 SP += 12;
962 ( r7:4, p5:3 ) = [sp++];
963 rets = [sp++];
Philippe Gerum9169b512011-03-17 02:15:24 -0400964 reti = [sp++];
965.Lnosync:
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800966 rts
Barry Song33ded952010-08-12 07:56:40 +0000967#elif defined(CONFIG_PREEMPT)
968
969_resume_kernel_from_int:
970 /* check preempt_count */
971 r7 = sp;
972 r4.l = lo(ALIGN_PAGE_MASK);
973 r4.h = hi(ALIGN_PAGE_MASK);
974 r7 = r7 & r4;
975 p5 = r7;
976 r7 = [p5 + TI_PREEMPT];
977 cc = r7 == 0x0;
978 if !cc jump .Lreturn_to_kernel;
979.Lneed_schedule:
980 r7 = [p5 + TI_FLAGS];
981 r4.l = lo(_TIF_WORK_MASK);
982 r4.h = hi(_TIF_WORK_MASK);
983 r7 = r7 & r4;
984 cc = BITTST(r7, TIF_NEED_RESCHED);
985 if !cc jump .Lreturn_to_kernel;
986 /*
987 * let schedule done at level 15, otherwise sheduled process will run
988 * at high level and block low level interrupt
989 */
990 r6 = reti; /* save reti */
991 r5.l = .Lkernel_schedule;
992 r5.h = .Lkernel_schedule;
993 reti = r5;
994 rti;
995.Lkernel_schedule:
996 [--sp] = rets;
997 sp += -12;
998 pseudo_long_call _preempt_schedule_irq, p4;
999 sp += 12;
1000 rets = [sp++];
1001
1002 [--sp] = rets;
1003 sp += -12;
1004 /* up to irq14 so that reti after restore_all can return to irq15(kernel) */
1005 pseudo_long_call _up_to_irq14, p4;
1006 sp += 12;
1007 rets = [sp++];
1008
1009 reti = r6; /* restore reti so that origin process can return to interrupted point */
1010
1011 jump .Lneed_schedule;
Philippe Gerum9bd50df2009-03-04 16:52:38 +08001012#else
Barry Song33ded952010-08-12 07:56:40 +00001013
1014#define _resume_kernel_from_int .Lreturn_to_kernel
Philippe Gerum9bd50df2009-03-04 16:52:38 +08001015#endif
1016
Bryan Wu1394f032007-05-06 14:50:22 -07001017ENTRY(_return_from_int)
1018 /* If someone else already raised IRQ 15, do nothing. */
1019 csync;
1020 p2.l = lo(ILAT);
1021 p2.h = hi(ILAT);
1022 r0 = [p2];
1023 cc = bittst (r0, EVT_IVG15_P);
Barry Song33ded952010-08-12 07:56:40 +00001024 if cc jump .Lreturn_to_kernel;
Bryan Wu1394f032007-05-06 14:50:22 -07001025
1026 /* if not return to user mode, get out */
1027 p2.l = lo(IPEND);
1028 p2.h = hi(IPEND);
1029 r0 = [p2];
1030 r1 = 0x17(Z);
1031 r2 = ~r1;
1032 r2.h = 0;
1033 r0 = r2 & r0;
1034 r1 = 1;
1035 r1 = r0 - r1;
1036 r2 = r0 & r1;
1037 cc = r2 == 0;
Philippe Gerum9bd50df2009-03-04 16:52:38 +08001038 if !cc jump _resume_kernel_from_int;
Bryan Wu1394f032007-05-06 14:50:22 -07001039
1040 /* Lower the interrupt level to 15. */
1041 p0.l = lo(EVT15);
1042 p0.h = hi(EVT15);
1043 p1.l = _schedule_and_signal_from_int;
1044 p1.h = _schedule_and_signal_from_int;
1045 [p0] = p1;
1046 csync;
Robin Getzb9a38992009-05-18 18:33:26 +00001047#if ANOMALY_05000281 || ANOMALY_05000461
Bernd Schmidt5d750b92008-04-25 05:02:33 +08001048 r0.l = lo(SAFE_USER_INSTRUCTION);
1049 r0.h = hi(SAFE_USER_INSTRUCTION);
Bryan Wu1394f032007-05-06 14:50:22 -07001050 reti = r0;
1051#endif
1052 r0 = 0x801f (z);
1053 STI r0;
1054 raise 15; /* raise evt15 to do signal or reschedule */
1055 rti;
Barry Song33ded952010-08-12 07:56:40 +00001056.Lreturn_to_kernel:
Bryan Wu1394f032007-05-06 14:50:22 -07001057 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +08001058ENDPROC(_return_from_int)
Bryan Wu1394f032007-05-06 14:50:22 -07001059
1060ENTRY(_lower_to_irq14)
Robin Getzb9a38992009-05-18 18:33:26 +00001061#if ANOMALY_05000281 || ANOMALY_05000461
Bernd Schmidt5d750b92008-04-25 05:02:33 +08001062 r0.l = lo(SAFE_USER_INSTRUCTION);
1063 r0.h = hi(SAFE_USER_INSTRUCTION);
Bryan Wu1394f032007-05-06 14:50:22 -07001064 reti = r0;
1065#endif
Robin Getzb9a38992009-05-18 18:33:26 +00001066
1067#ifdef CONFIG_DEBUG_HWERR
Philippe Gerum9703a732009-06-22 18:23:48 +02001068 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
Robin Getzb9a38992009-05-18 18:33:26 +00001069 r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
1070#else
Philippe Gerum9703a732009-06-22 18:23:48 +02001071 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
Robin Getzb9a38992009-05-18 18:33:26 +00001072 r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
1073#endif
Bryan Wu1394f032007-05-06 14:50:22 -07001074 sti r0;
1075 raise 14;
1076 rti;
Robin Getzb9a38992009-05-18 18:33:26 +00001077ENDPROC(_lower_to_irq14)
1078
Philippe Gerum9703a732009-06-22 18:23:48 +02001079ENTRY(_evt_evt14)
Bryan Wu1394f032007-05-06 14:50:22 -07001080#ifdef CONFIG_DEBUG_HWERR
Robin Getzb9a38992009-05-18 18:33:26 +00001081 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
Bryan Wu1394f032007-05-06 14:50:22 -07001082 sti r0;
1083#else
1084 cli r0;
1085#endif
Yi Li441504d2010-01-19 04:35:28 +00001086#ifdef CONFIG_TRACE_IRQFLAGS
1087 [--sp] = rets;
1088 sp += -12;
1089 call _trace_hardirqs_off;
1090 sp += 12;
1091 rets = [sp++];
1092#endif
Bryan Wu1394f032007-05-06 14:50:22 -07001093 [--sp] = RETI;
1094 SP += 4;
1095 rts;
Philippe Gerum9703a732009-06-22 18:23:48 +02001096ENDPROC(_evt_evt14)
Bryan Wu1394f032007-05-06 14:50:22 -07001097
Robin Getzb9a38992009-05-18 18:33:26 +00001098ENTRY(_schedule_and_signal_from_int)
Bryan Wu1394f032007-05-06 14:50:22 -07001099 /* To end up here, vector 15 was changed - so we have to change it
1100 * back.
1101 */
1102 p0.l = lo(EVT15);
1103 p0.h = hi(EVT15);
1104 p1.l = _evt_system_call;
1105 p1.h = _evt_system_call;
1106 [p0] = p1;
1107 csync;
Bernd Schmidtc8244982007-05-21 18:09:33 +08001108
1109 /* Set orig_p0 to -1 to indicate this isn't the end of a syscall. */
1110 r0 = -1 (x);
1111 [sp + PT_ORIG_P0] = r0;
1112
Bryan Wu1394f032007-05-06 14:50:22 -07001113 p1 = rets;
1114 [sp + PT_RESERVED] = p1;
1115
Yi Li441504d2010-01-19 04:35:28 +00001116#ifdef CONFIG_TRACE_IRQFLAGS
1117 /* trace_hardirqs_on() checks if all irqs are disabled. But here IRQ 15
1118 * is turned on, so disable all irqs. */
1119 cli r0;
1120 sp += -12;
1121 call _trace_hardirqs_on;
1122 sp += 12;
1123#endif
Graf Yang6b3087c2009-01-07 23:14:39 +08001124#ifdef CONFIG_SMP
1125 GET_PDA(p0, r0); /* Fetch current PDA (can't migrate to other CPU here) */
1126 r0 = [p0 + PDA_IRQFLAGS];
1127#else
Mike Frysinger40059782008-11-18 17:48:22 +08001128 p0.l = _bfin_irq_flags;
1129 p0.h = _bfin_irq_flags;
Bryan Wu1394f032007-05-06 14:50:22 -07001130 r0 = [p0];
Graf Yang6b3087c2009-01-07 23:14:39 +08001131#endif
Bryan Wu1394f032007-05-06 14:50:22 -07001132 sti r0;
1133
Mike Frysinger92649492009-08-17 19:05:07 +00001134 /* finish the userspace "atomic" functions for it */
Bob Liub5affb02012-05-16 17:37:24 +08001135 r1.l = lo(FIXED_CODE_END);
1136 r1.h = hi(FIXED_CODE_END);
Mike Frysinger92649492009-08-17 19:05:07 +00001137 r2 = [sp + PT_PC];
1138 cc = r1 <= r2;
1139 if cc jump .Lresume_userspace (bp);
1140
Bernd Schmidt7adfb582007-06-21 11:34:16 +08001141 r0 = sp;
1142 sp += -12;
Barry Songd86bfb12010-01-07 04:11:17 +00001143
1144 pseudo_long_call _finish_atomic_sections, p5;
Bernd Schmidt7adfb582007-06-21 11:34:16 +08001145 sp += 12;
Bryan Wu1394f032007-05-06 14:50:22 -07001146 jump.s .Lresume_userspace;
Robin Getzb9a38992009-05-18 18:33:26 +00001147ENDPROC(_schedule_and_signal_from_int)
Bryan Wu1394f032007-05-06 14:50:22 -07001148
Robin Getzb9a38992009-05-18 18:33:26 +00001149ENTRY(_schedule_and_signal)
Bryan Wu1394f032007-05-06 14:50:22 -07001150 SAVE_CONTEXT_SYSCALL
1151 /* To end up here, vector 15 was changed - so we have to change it
1152 * back.
1153 */
1154 p0.l = lo(EVT15);
1155 p0.h = hi(EVT15);
1156 p1.l = _evt_system_call;
1157 p1.h = _evt_system_call;
1158 [p0] = p1;
1159 csync;
1160 p0.l = 1f;
1161 p0.h = 1f;
1162 [sp + PT_RESERVED] = P0;
1163 call .Lresume_userspace;
11641:
1165 RESTORE_CONTEXT
1166 rti;
Robin Getzb9a38992009-05-18 18:33:26 +00001167ENDPROC(_schedule_and_signal)
Bryan Wu1394f032007-05-06 14:50:22 -07001168
Robin Getz518039b2007-07-25 11:03:28 +08001169/* We handle this 100% in exception space - to reduce overhead
1170 * Only potiential problem is if the software buffer gets swapped out of the
1171 * CPLB table - then double fault. - so we don't let this happen in other places
1172 */
1173#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1174ENTRY(_ex_trace_buff_full)
1175 [--sp] = P3;
1176 [--sp] = P2;
1177 [--sp] = LC0;
1178 [--sp] = LT0;
1179 [--sp] = LB0;
1180 P5.L = _trace_buff_offset;
1181 P5.H = _trace_buff_offset;
1182 P3 = [P5]; /* trace_buff_offset */
1183 P5.L = lo(TBUFSTAT);
1184 P5.H = hi(TBUFSTAT);
1185 R7 = [P5];
1186 R7 <<= 1; /* double, since we need to read twice */
1187 LC0 = R7;
1188 R7 <<= 2; /* need to shift over again,
1189 * to get the number of bytes */
1190 P5.L = lo(TBUF);
1191 P5.H = hi(TBUF);
1192 R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
1193
1194 P2 = R7;
1195 P3 = P3 + P2;
1196 R7 = P3;
1197 R7 = R7 & R6;
1198 P3 = R7;
1199 P2.L = _trace_buff_offset;
1200 P2.H = _trace_buff_offset;
1201 [P2] = P3;
1202
1203 P2.L = _software_trace_buff;
1204 P2.H = _software_trace_buff;
1205
1206 LSETUP (.Lstart, .Lend) LC0;
1207.Lstart:
1208 R7 = [P5]; /* read TBUF */
1209 P4 = P3 + P2;
1210 [P4] = R7;
1211 P3 += -4;
1212 R7 = P3;
1213 R7 = R7 & R6;
1214.Lend:
1215 P3 = R7;
1216
1217 LB0 = [sp++];
1218 LT0 = [sp++];
1219 LC0 = [sp++];
1220 P2 = [sp++];
1221 P3 = [sp++];
Mike Frysinger8d6c2422007-11-21 15:53:49 +08001222 jump _bfin_return_from_exception;
Robin Getz337d3902007-10-09 17:31:46 +08001223ENDPROC(_ex_trace_buff_full)
Robin Getz518039b2007-07-25 11:03:28 +08001224
1225#if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
1226.data
1227#else
1228.section .l1.data.B
Robin Getz337d3902007-10-09 17:31:46 +08001229#endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
Robin Getz518039b2007-07-25 11:03:28 +08001230ENTRY(_trace_buff_offset)
1231 .long 0;
1232ALIGN
1233ENTRY(_software_trace_buff)
1234 .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
1235 .long 0
1236 .endr
Robin Getz337d3902007-10-09 17:31:46 +08001237#endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
1238
Geert Uytterhoevence6da7c2012-02-19 16:11:55 +01001239#ifdef CONFIG_EARLY_PRINTK
Mike Frysinger9cb07b22007-11-21 16:45:08 +08001240__INIT
Robin Getz337d3902007-10-09 17:31:46 +08001241ENTRY(_early_trap)
1242 SAVE_ALL_SYS
1243 trace_buffer_stop(p0,r0);
1244
Robin Getzdedfd5d2009-08-26 15:54:10 +00001245 ANOMALY_283_315_WORKAROUND(p4, r5)
Michael Hennerich5e9e7682008-10-09 12:31:03 +08001246
Robin Getz337d3902007-10-09 17:31:46 +08001247 /* Turn caches off, to ensure we don't get double exceptions */
1248
1249 P4.L = LO(IMEM_CONTROL);
1250 P4.H = HI(IMEM_CONTROL);
1251
1252 R5 = [P4]; /* Control Register*/
1253 BITCLR(R5,ENICPLB_P);
Yi Lieb7bd9c2009-08-07 01:20:58 +00001254 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
Robin Getz337d3902007-10-09 17:31:46 +08001255 [P4] = R5;
1256 SSYNC;
1257
1258 P4.L = LO(DMEM_CONTROL);
1259 P4.H = HI(DMEM_CONTROL);
1260 R5 = [P4];
1261 BITCLR(R5,ENDCPLB_P);
Yi Lieb7bd9c2009-08-07 01:20:58 +00001262 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
Robin Getz337d3902007-10-09 17:31:46 +08001263 [P4] = R5;
1264 SSYNC;
Robin Getz337d3902007-10-09 17:31:46 +08001265
1266 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
1267 r1 = RETX;
1268
1269 SP += -12;
1270 call _early_trap_c;
1271 SP += 12;
1272ENDPROC(_early_trap)
Mike Frysinger9cb07b22007-11-21 16:45:08 +08001273__FINIT
Robin Getz337d3902007-10-09 17:31:46 +08001274#endif /* CONFIG_EARLY_PRINTK */
Robin Getz518039b2007-07-25 11:03:28 +08001275
Bryan Wu1394f032007-05-06 14:50:22 -07001276/*
1277 * Put these in the kernel data section - that should always be covered by
1278 * a CPLB. This is needed to ensure we don't get double fault conditions
1279 */
1280
1281#ifdef CONFIG_SYSCALL_TAB_L1
1282.section .l1.data
1283#else
1284.data
1285#endif
Robin Getzf26fbc42007-11-12 22:21:30 +08001286
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001287ENTRY(_ex_table)
Bryan Wu1394f032007-05-06 14:50:22 -07001288 /* entry for each EXCAUSE[5:0]
Mike Frysinger9401e612007-07-12 11:50:43 +08001289 * This table must be in sync with the table in ./kernel/traps.c
Bryan Wu1394f032007-05-06 14:50:22 -07001290 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
1291 */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001292 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
Jie Zhang3aee91b2009-02-04 16:49:45 +08001293 .long _ex_trap_c /* 0x01 - User Defined - Software breakpoint */
Sonic Zhanga5ac0122008-10-13 14:07:19 +08001294#ifdef CONFIG_KGDB
1295 .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection
1296 and break signal trap */
1297#else
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001298 .long _ex_replaceable /* 0x02 - User Defined */
Sonic Zhanga5ac0122008-10-13 14:07:19 +08001299#endif
Mike Frysinger9401e612007-07-12 11:50:43 +08001300 .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
Robin Getz9f336a52007-10-29 18:23:28 +08001301 .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001302 .long _ex_replaceable /* 0x05 - User Defined */
1303 .long _ex_replaceable /* 0x06 - User Defined */
1304 .long _ex_replaceable /* 0x07 - User Defined */
1305 .long _ex_replaceable /* 0x08 - User Defined */
1306 .long _ex_replaceable /* 0x09 - User Defined */
1307 .long _ex_replaceable /* 0x0A - User Defined */
1308 .long _ex_replaceable /* 0x0B - User Defined */
1309 .long _ex_replaceable /* 0x0C - User Defined */
1310 .long _ex_replaceable /* 0x0D - User Defined */
1311 .long _ex_replaceable /* 0x0E - User Defined */
1312 .long _ex_replaceable /* 0x0F - User Defined */
Bryan Wu1394f032007-05-06 14:50:22 -07001313 .long _ex_single_step /* 0x10 - HW Single step */
Robin Getz518039b2007-07-25 11:03:28 +08001314#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1315 .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
1316#else
Bryan Wu1394f032007-05-06 14:50:22 -07001317 .long _ex_trap_c /* 0x11 - Trace Buffer Full */
Robin Getz518039b2007-07-25 11:03:28 +08001318#endif
Bryan Wu1394f032007-05-06 14:50:22 -07001319 .long _ex_trap_c /* 0x12 - Reserved */
1320 .long _ex_trap_c /* 0x13 - Reserved */
1321 .long _ex_trap_c /* 0x14 - Reserved */
1322 .long _ex_trap_c /* 0x15 - Reserved */
1323 .long _ex_trap_c /* 0x16 - Reserved */
1324 .long _ex_trap_c /* 0x17 - Reserved */
1325 .long _ex_trap_c /* 0x18 - Reserved */
1326 .long _ex_trap_c /* 0x19 - Reserved */
1327 .long _ex_trap_c /* 0x1A - Reserved */
1328 .long _ex_trap_c /* 0x1B - Reserved */
1329 .long _ex_trap_c /* 0x1C - Reserved */
1330 .long _ex_trap_c /* 0x1D - Reserved */
1331 .long _ex_trap_c /* 0x1E - Reserved */
1332 .long _ex_trap_c /* 0x1F - Reserved */
1333 .long _ex_trap_c /* 0x20 - Reserved */
1334 .long _ex_trap_c /* 0x21 - Undefined Instruction */
1335 .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
Robin Getzf26fbc42007-11-12 22:21:30 +08001336 .long _ex_dviol /* 0x23 - Data CPLB Protection Violation */
Bryan Wu1394f032007-05-06 14:50:22 -07001337 .long _ex_trap_c /* 0x24 - Data access misaligned */
1338 .long _ex_trap_c /* 0x25 - Unrecoverable Event */
Robin Getzf26fbc42007-11-12 22:21:30 +08001339 .long _ex_dmiss /* 0x26 - Data CPLB Miss */
1340 .long _ex_dmult /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
Bryan Wu1394f032007-05-06 14:50:22 -07001341 .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
1342 .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
1343 .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
Robin Getzf26fbc42007-11-12 22:21:30 +08001344 .long _ex_trap_c /* 0x2B - Instruction CPLB protection Violation */
1345 .long _ex_icplb_miss /* 0x2C - Instruction CPLB miss */
Bryan Wu1394f032007-05-06 14:50:22 -07001346 .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
1347 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1348 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1349 .long _ex_trap_c /* 0x2F - Reserved */
1350 .long _ex_trap_c /* 0x30 - Reserved */
1351 .long _ex_trap_c /* 0x31 - Reserved */
1352 .long _ex_trap_c /* 0x32 - Reserved */
1353 .long _ex_trap_c /* 0x33 - Reserved */
1354 .long _ex_trap_c /* 0x34 - Reserved */
1355 .long _ex_trap_c /* 0x35 - Reserved */
1356 .long _ex_trap_c /* 0x36 - Reserved */
1357 .long _ex_trap_c /* 0x37 - Reserved */
1358 .long _ex_trap_c /* 0x38 - Reserved */
1359 .long _ex_trap_c /* 0x39 - Reserved */
1360 .long _ex_trap_c /* 0x3A - Reserved */
1361 .long _ex_trap_c /* 0x3B - Reserved */
1362 .long _ex_trap_c /* 0x3C - Reserved */
1363 .long _ex_trap_c /* 0x3D - Reserved */
1364 .long _ex_trap_c /* 0x3E - Reserved */
1365 .long _ex_trap_c /* 0x3F - Reserved */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001366END(_ex_table)
Bryan Wu1394f032007-05-06 14:50:22 -07001367
Bryan Wu1394f032007-05-06 14:50:22 -07001368ENTRY(_sys_call_table)
Bryan Wu0b95f222007-09-23 00:51:32 +08001369 .long _sys_restart_syscall /* 0 */
Bryan Wu1394f032007-05-06 14:50:22 -07001370 .long _sys_exit
Mike Frysinger080bb652012-05-01 00:48:06 -04001371 .long _sys_ni_syscall /* fork */
Bryan Wu1394f032007-05-06 14:50:22 -07001372 .long _sys_read
1373 .long _sys_write
1374 .long _sys_open /* 5 */
1375 .long _sys_close
1376 .long _sys_ni_syscall /* old waitpid */
1377 .long _sys_creat
1378 .long _sys_link
1379 .long _sys_unlink /* 10 */
1380 .long _sys_execve
1381 .long _sys_chdir
1382 .long _sys_time
1383 .long _sys_mknod
1384 .long _sys_chmod /* 15 */
1385 .long _sys_chown /* chown16 */
1386 .long _sys_ni_syscall /* old break syscall holder */
1387 .long _sys_ni_syscall /* old stat */
1388 .long _sys_lseek
1389 .long _sys_getpid /* 20 */
1390 .long _sys_mount
1391 .long _sys_ni_syscall /* old umount */
1392 .long _sys_setuid
1393 .long _sys_getuid
1394 .long _sys_stime /* 25 */
1395 .long _sys_ptrace
1396 .long _sys_alarm
1397 .long _sys_ni_syscall /* old fstat */
1398 .long _sys_pause
1399 .long _sys_ni_syscall /* old utime */ /* 30 */
1400 .long _sys_ni_syscall /* old stty syscall holder */
1401 .long _sys_ni_syscall /* old gtty syscall holder */
1402 .long _sys_access
1403 .long _sys_nice
1404 .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1405 .long _sys_sync
1406 .long _sys_kill
1407 .long _sys_rename
1408 .long _sys_mkdir
1409 .long _sys_rmdir /* 40 */
1410 .long _sys_dup
1411 .long _sys_pipe
1412 .long _sys_times
1413 .long _sys_ni_syscall /* old prof syscall holder */
1414 .long _sys_brk /* 45 */
1415 .long _sys_setgid
1416 .long _sys_getgid
1417 .long _sys_ni_syscall /* old sys_signal */
1418 .long _sys_geteuid /* geteuid16 */
1419 .long _sys_getegid /* getegid16 */ /* 50 */
1420 .long _sys_acct
1421 .long _sys_umount /* recycled never used phys() */
1422 .long _sys_ni_syscall /* old lock syscall holder */
1423 .long _sys_ioctl
1424 .long _sys_fcntl /* 55 */
1425 .long _sys_ni_syscall /* old mpx syscall holder */
1426 .long _sys_setpgid
1427 .long _sys_ni_syscall /* old ulimit syscall holder */
1428 .long _sys_ni_syscall /* old old uname */
1429 .long _sys_umask /* 60 */
1430 .long _sys_chroot
1431 .long _sys_ustat
1432 .long _sys_dup2
1433 .long _sys_getppid
1434 .long _sys_getpgrp /* 65 */
1435 .long _sys_setsid
1436 .long _sys_ni_syscall /* old sys_sigaction */
1437 .long _sys_sgetmask
1438 .long _sys_ssetmask
1439 .long _sys_setreuid /* setreuid16 */ /* 70 */
1440 .long _sys_setregid /* setregid16 */
1441 .long _sys_ni_syscall /* old sys_sigsuspend */
1442 .long _sys_ni_syscall /* old sys_sigpending */
1443 .long _sys_sethostname
1444 .long _sys_setrlimit /* 75 */
1445 .long _sys_ni_syscall /* old getrlimit */
1446 .long _sys_getrusage
1447 .long _sys_gettimeofday
1448 .long _sys_settimeofday
1449 .long _sys_getgroups /* getgroups16 */ /* 80 */
1450 .long _sys_setgroups /* setgroups16 */
1451 .long _sys_ni_syscall /* old_select */
1452 .long _sys_symlink
1453 .long _sys_ni_syscall /* old lstat */
1454 .long _sys_readlink /* 85 */
1455 .long _sys_uselib
1456 .long _sys_ni_syscall /* sys_swapon */
1457 .long _sys_reboot
1458 .long _sys_ni_syscall /* old_readdir */
1459 .long _sys_ni_syscall /* sys_mmap */ /* 90 */
1460 .long _sys_munmap
1461 .long _sys_truncate
1462 .long _sys_ftruncate
1463 .long _sys_fchmod
1464 .long _sys_fchown /* fchown16 */ /* 95 */
1465 .long _sys_getpriority
1466 .long _sys_setpriority
1467 .long _sys_ni_syscall /* old profil syscall holder */
1468 .long _sys_statfs
1469 .long _sys_fstatfs /* 100 */
1470 .long _sys_ni_syscall
1471 .long _sys_ni_syscall /* old sys_socketcall */
1472 .long _sys_syslog
1473 .long _sys_setitimer
1474 .long _sys_getitimer /* 105 */
1475 .long _sys_newstat
1476 .long _sys_newlstat
1477 .long _sys_newfstat
1478 .long _sys_ni_syscall /* old uname */
1479 .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
1480 .long _sys_vhangup
1481 .long _sys_ni_syscall /* obsolete idle() syscall */
1482 .long _sys_ni_syscall /* vm86old for i386 */
1483 .long _sys_wait4
1484 .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
1485 .long _sys_sysinfo
1486 .long _sys_ni_syscall /* old sys_ipc */
1487 .long _sys_fsync
1488 .long _sys_ni_syscall /* old sys_sigreturn */
1489 .long _sys_clone /* 120 */
1490 .long _sys_setdomainname
1491 .long _sys_newuname
1492 .long _sys_ni_syscall /* old sys_modify_ldt */
1493 .long _sys_adjtimex
Mike Frysinger360adee2009-12-15 05:08:36 +00001494 .long _sys_mprotect /* 125 */
Bryan Wu1394f032007-05-06 14:50:22 -07001495 .long _sys_ni_syscall /* old sys_sigprocmask */
1496 .long _sys_ni_syscall /* old "creat_module" */
1497 .long _sys_init_module
1498 .long _sys_delete_module
1499 .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
1500 .long _sys_quotactl
1501 .long _sys_getpgid
1502 .long _sys_fchdir
1503 .long _sys_bdflush
1504 .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
1505 .long _sys_personality
1506 .long _sys_ni_syscall /* for afs_syscall */
1507 .long _sys_setfsuid /* setfsuid16 */
1508 .long _sys_setfsgid /* setfsgid16 */
1509 .long _sys_llseek /* 140 */
1510 .long _sys_getdents
1511 .long _sys_ni_syscall /* sys_select */
1512 .long _sys_flock
Mike Frysinger360adee2009-12-15 05:08:36 +00001513 .long _sys_msync
Bryan Wu1394f032007-05-06 14:50:22 -07001514 .long _sys_readv /* 145 */
1515 .long _sys_writev
1516 .long _sys_getsid
1517 .long _sys_fdatasync
1518 .long _sys_sysctl
Mike Frysinger360adee2009-12-15 05:08:36 +00001519 .long _sys_mlock /* 150 */
1520 .long _sys_munlock
1521 .long _sys_mlockall
1522 .long _sys_munlockall
Bryan Wu1394f032007-05-06 14:50:22 -07001523 .long _sys_sched_setparam
1524 .long _sys_sched_getparam /* 155 */
1525 .long _sys_sched_setscheduler
1526 .long _sys_sched_getscheduler
1527 .long _sys_sched_yield
1528 .long _sys_sched_get_priority_max
1529 .long _sys_sched_get_priority_min /* 160 */
1530 .long _sys_sched_rr_get_interval
1531 .long _sys_nanosleep
Bryan Wu0b95f222007-09-23 00:51:32 +08001532 .long _sys_mremap
Bryan Wu1394f032007-05-06 14:50:22 -07001533 .long _sys_setresuid /* setresuid16 */
1534 .long _sys_getresuid /* getresuid16 */ /* 165 */
1535 .long _sys_ni_syscall /* for vm86 */
1536 .long _sys_ni_syscall /* old "query_module" */
1537 .long _sys_ni_syscall /* sys_poll */
NeilBrownf5b94092011-08-26 18:03:11 -04001538 .long _sys_ni_syscall /* old nfsservctl */
Bryan Wu1394f032007-05-06 14:50:22 -07001539 .long _sys_setresgid /* setresgid16 */ /* 170 */
1540 .long _sys_getresgid /* getresgid16 */
1541 .long _sys_prctl
1542 .long _sys_rt_sigreturn
1543 .long _sys_rt_sigaction
1544 .long _sys_rt_sigprocmask /* 175 */
1545 .long _sys_rt_sigpending
1546 .long _sys_rt_sigtimedwait
1547 .long _sys_rt_sigqueueinfo
1548 .long _sys_rt_sigsuspend
1549 .long _sys_pread64 /* 180 */
1550 .long _sys_pwrite64
1551 .long _sys_lchown /* lchown16 */
1552 .long _sys_getcwd
1553 .long _sys_capget
1554 .long _sys_capset /* 185 */
1555 .long _sys_sigaltstack
1556 .long _sys_sendfile
1557 .long _sys_ni_syscall /* streams1 */
1558 .long _sys_ni_syscall /* streams2 */
1559 .long _sys_vfork /* 190 */
1560 .long _sys_getrlimit
Al Virof8b72562009-11-30 17:37:04 -05001561 .long _sys_mmap_pgoff
Bryan Wu1394f032007-05-06 14:50:22 -07001562 .long _sys_truncate64
1563 .long _sys_ftruncate64
1564 .long _sys_stat64 /* 195 */
1565 .long _sys_lstat64
1566 .long _sys_fstat64
1567 .long _sys_chown
1568 .long _sys_getuid
1569 .long _sys_getgid /* 200 */
1570 .long _sys_geteuid
1571 .long _sys_getegid
1572 .long _sys_setreuid
1573 .long _sys_setregid
1574 .long _sys_getgroups /* 205 */
1575 .long _sys_setgroups
1576 .long _sys_fchown
1577 .long _sys_setresuid
1578 .long _sys_getresuid
1579 .long _sys_setresgid /* 210 */
1580 .long _sys_getresgid
1581 .long _sys_lchown
1582 .long _sys_setuid
1583 .long _sys_setgid
1584 .long _sys_setfsuid /* 215 */
1585 .long _sys_setfsgid
1586 .long _sys_pivot_root
Mike Frysinger360adee2009-12-15 05:08:36 +00001587 .long _sys_mincore
1588 .long _sys_madvise
Bryan Wu1394f032007-05-06 14:50:22 -07001589 .long _sys_getdents64 /* 220 */
1590 .long _sys_fcntl64
1591 .long _sys_ni_syscall /* reserved for TUX */
1592 .long _sys_ni_syscall
1593 .long _sys_gettid
Bryan Wu0b95f222007-09-23 00:51:32 +08001594 .long _sys_readahead /* 225 */
Bryan Wu1394f032007-05-06 14:50:22 -07001595 .long _sys_setxattr
1596 .long _sys_lsetxattr
1597 .long _sys_fsetxattr
1598 .long _sys_getxattr
1599 .long _sys_lgetxattr /* 230 */
1600 .long _sys_fgetxattr
1601 .long _sys_listxattr
1602 .long _sys_llistxattr
1603 .long _sys_flistxattr
1604 .long _sys_removexattr /* 235 */
1605 .long _sys_lremovexattr
1606 .long _sys_fremovexattr
1607 .long _sys_tkill
1608 .long _sys_sendfile64
1609 .long _sys_futex /* 240 */
1610 .long _sys_sched_setaffinity
1611 .long _sys_sched_getaffinity
1612 .long _sys_ni_syscall /* sys_set_thread_area */
1613 .long _sys_ni_syscall /* sys_get_thread_area */
1614 .long _sys_io_setup /* 245 */
1615 .long _sys_io_destroy
1616 .long _sys_io_getevents
1617 .long _sys_io_submit
1618 .long _sys_io_cancel
1619 .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
1620 .long _sys_ni_syscall /* sys_freec_hugepages */
1621 .long _sys_exit_group
1622 .long _sys_lookup_dcookie
1623 .long _sys_bfin_spinlock
1624 .long _sys_epoll_create /* 255 */
1625 .long _sys_epoll_ctl
1626 .long _sys_epoll_wait
1627 .long _sys_ni_syscall /* remap_file_pages */
1628 .long _sys_set_tid_address
1629 .long _sys_timer_create /* 260 */
1630 .long _sys_timer_settime
1631 .long _sys_timer_gettime
1632 .long _sys_timer_getoverrun
1633 .long _sys_timer_delete
1634 .long _sys_clock_settime /* 265 */
1635 .long _sys_clock_gettime
1636 .long _sys_clock_getres
1637 .long _sys_clock_nanosleep
1638 .long _sys_statfs64
1639 .long _sys_fstatfs64 /* 270 */
1640 .long _sys_tgkill
1641 .long _sys_utimes
1642 .long _sys_fadvise64_64
1643 .long _sys_ni_syscall /* vserver */
Mike Frysinger360adee2009-12-15 05:08:36 +00001644 .long _sys_mbind /* 275 */
Bryan Wu1394f032007-05-06 14:50:22 -07001645 .long _sys_ni_syscall /* get_mempolicy */
1646 .long _sys_ni_syscall /* set_mempolicy */
1647 .long _sys_mq_open
1648 .long _sys_mq_unlink
1649 .long _sys_mq_timedsend /* 280 */
1650 .long _sys_mq_timedreceive
1651 .long _sys_mq_notify
1652 .long _sys_mq_getsetattr
1653 .long _sys_ni_syscall /* kexec_load */
1654 .long _sys_waitid /* 285 */
1655 .long _sys_add_key
1656 .long _sys_request_key
1657 .long _sys_keyctl
1658 .long _sys_ioprio_set
1659 .long _sys_ioprio_get /* 290 */
1660 .long _sys_inotify_init
1661 .long _sys_inotify_add_watch
1662 .long _sys_inotify_rm_watch
1663 .long _sys_ni_syscall /* migrate_pages */
1664 .long _sys_openat /* 295 */
1665 .long _sys_mkdirat
1666 .long _sys_mknodat
1667 .long _sys_fchownat
1668 .long _sys_futimesat
1669 .long _sys_fstatat64 /* 300 */
1670 .long _sys_unlinkat
1671 .long _sys_renameat
1672 .long _sys_linkat
1673 .long _sys_symlinkat
1674 .long _sys_readlinkat /* 305 */
1675 .long _sys_fchmodat
1676 .long _sys_faccessat
1677 .long _sys_pselect6
1678 .long _sys_ppoll
1679 .long _sys_unshare /* 310 */
1680 .long _sys_sram_alloc
1681 .long _sys_sram_free
1682 .long _sys_dma_memcpy
1683 .long _sys_accept
1684 .long _sys_bind /* 315 */
1685 .long _sys_connect
1686 .long _sys_getpeername
1687 .long _sys_getsockname
1688 .long _sys_getsockopt
1689 .long _sys_listen /* 320 */
1690 .long _sys_recv
1691 .long _sys_recvfrom
1692 .long _sys_recvmsg
1693 .long _sys_send
1694 .long _sys_sendmsg /* 325 */
1695 .long _sys_sendto
1696 .long _sys_setsockopt
1697 .long _sys_shutdown
1698 .long _sys_socket
1699 .long _sys_socketpair /* 330 */
1700 .long _sys_semctl
1701 .long _sys_semget
1702 .long _sys_semop
1703 .long _sys_msgctl
1704 .long _sys_msgget /* 335 */
1705 .long _sys_msgrcv
1706 .long _sys_msgsnd
1707 .long _sys_shmat
1708 .long _sys_shmctl
1709 .long _sys_shmdt /* 340 */
1710 .long _sys_shmget
Bryan Wu0b95f222007-09-23 00:51:32 +08001711 .long _sys_splice
1712 .long _sys_sync_file_range
1713 .long _sys_tee
1714 .long _sys_vmsplice /* 345 */
1715 .long _sys_epoll_pwait
1716 .long _sys_utimensat
1717 .long _sys_signalfd
Bryan Wu2f775db2008-03-06 16:04:58 -07001718 .long _sys_timerfd_create
Bryan Wu0b95f222007-09-23 00:51:32 +08001719 .long _sys_eventfd /* 350 */
1720 .long _sys_pread64
1721 .long _sys_pwrite64
1722 .long _sys_fadvise64
1723 .long _sys_set_robust_list
1724 .long _sys_get_robust_list /* 355 */
1725 .long _sys_fallocate
Bernd Schmidtfc975512008-01-27 19:56:43 +08001726 .long _sys_semtimedop
Bryan Wu2f775db2008-03-06 16:04:58 -07001727 .long _sys_timerfd_settime
1728 .long _sys_timerfd_gettime
Bryan Wua4b7b6d2008-08-14 15:40:19 +08001729 .long _sys_signalfd4 /* 360 */
1730 .long _sys_eventfd2
1731 .long _sys_epoll_create1
1732 .long _sys_dup3
1733 .long _sys_pipe2
1734 .long _sys_inotify_init1 /* 365 */
Mike Frysinger7a1450f2009-05-26 04:55:38 -04001735 .long _sys_preadv
1736 .long _sys_pwritev
Mike Frysinger61cdd7a2009-06-12 07:30:55 -04001737 .long _sys_rt_tgsigqueueinfo
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001738 .long _sys_perf_event_open
Arnaldo Carvalho de Meloa2e27252009-10-12 23:40:10 -07001739 .long _sys_recvmmsg /* 370 */
Mike Frysingerf3411b12010-08-18 15:25:30 -04001740 .long _sys_fanotify_init
1741 .long _sys_fanotify_mark
1742 .long _sys_prlimit64
Sonic Zhang99a5b282010-09-06 10:16:04 +00001743 .long _sys_cacheflush
Mike Frysingera8d01422011-03-18 04:05:23 -04001744 .long _sys_name_to_handle_at /* 375 */
1745 .long _sys_open_by_handle_at
1746 .long _sys_clock_adjtime
Mike Frysinger4e3d96d2011-03-22 13:41:22 -04001747 .long _sys_syncfs
Eric W. Biederman7b21fdd2011-05-27 19:28:27 -07001748 .long _sys_setns
Mike Frysinger427472c2011-05-23 21:45:42 -04001749 .long _sys_sendmmsg /* 380 */
Mike Frysingerdd47ba12012-01-29 05:32:39 -05001750 .long _sys_process_vm_readv
1751 .long _sys_process_vm_writev
Bryan Wu2f775db2008-03-06 16:04:58 -07001752
Bryan Wu1394f032007-05-06 14:50:22 -07001753 .rept NR_syscalls-(.-_sys_call_table)/4
1754 .long _sys_ni_syscall
1755 .endr
Robin Getz0c7a6b22008-10-08 16:27:12 +08001756END(_sys_call_table)