blob: a504c65d999022f9b39a79a12f7ccc61a82c6d17 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
2 * File: arch/blackfin/mach-common/entry.S
3 * Based on:
4 * Author: Linus Torvalds
5 *
6 * Created: ?
7 * Description: contains the system-call and fault low-level handling routines.
8 * This also contains the timer-interrupt handler, as well as all
9 * interrupts and faults that can result in a task-switch.
10 *
11 * Modified:
12 * Copyright 2004-2006 Analog Devices Inc.
13 *
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
Robin Getz2ebcade2007-10-09 17:24:30 +080032/* NOTE: This code handles signal-recognition, which happens every time
Bryan Wu1394f032007-05-06 14:50:22 -070033 * after a timer-interrupt and after each system call.
34 */
35
Mike Frysinger9cb07b22007-11-21 16:45:08 +080036#include <linux/init.h>
Bryan Wu1394f032007-05-06 14:50:22 -070037#include <linux/linkage.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080038#include <linux/unistd.h>
Bryan Wu1394f032007-05-06 14:50:22 -070039#include <asm/blackfin.h>
Bryan Wu1394f032007-05-06 14:50:22 -070040#include <asm/errno.h>
41#include <asm/thread_info.h> /* TIF_NEED_RESCHED */
42#include <asm/asm-offsets.h>
Robin Getz669b7922007-06-21 16:34:08 +080043#include <asm/trace.h>
Bryan Wu1394f032007-05-06 14:50:22 -070044
45#include <asm/mach-common/context.S>
46
Mike Frysingerf0b5d122007-08-05 17:03:59 +080047#if defined(CONFIG_BFIN_SCRATCH_REG_RETN)
48# define EX_SCRATCH_REG RETN
49#elif defined(CONFIG_BFIN_SCRATCH_REG_RETE)
50# define EX_SCRATCH_REG RETE
51#else
52# define EX_SCRATCH_REG CYCLES
53#endif
54
Robin Getzb3f8b922007-10-10 17:28:27 +080055#if ANOMALY_05000281
56ENTRY(_safe_speculative_execution)
57 NOP;
58 NOP;
59 NOP;
60 jump _safe_speculative_execution;
61ENDPROC(_safe_speculative_execution)
62#endif
63
Bryan Wu1394f032007-05-06 14:50:22 -070064#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
65.section .l1.text
66#else
67.text
68#endif
69
70/* Slightly simplified and streamlined entry point for CPLB misses.
71 * This one does not lower the level to IRQ5, and thus can be used to
72 * patch up CPLB misses on the kernel stack.
73 */
Mike Frysinger1aafd902007-07-25 11:19:14 +080074#if ANOMALY_05000261
Robin Getzf26fbc42007-11-12 22:21:30 +080075#define _ex_dviol _ex_workaround_261
76#define _ex_dmiss _ex_workaround_261
77#define _ex_dmult _ex_workaround_261
78
79ENTRY(_ex_workaround_261)
Bryan Wu1394f032007-05-06 14:50:22 -070080 /*
81 * Work around an anomaly: if we see a new DCPLB fault, return
82 * without doing anything. Then, if we get the same fault again,
83 * handle it.
84 */
Robin Getzf26fbc42007-11-12 22:21:30 +080085 P4 = R7; /* Store EXCAUSE */
Bryan Wu1394f032007-05-06 14:50:22 -070086 p5.l = _last_cplb_fault_retx;
87 p5.h = _last_cplb_fault_retx;
88 r7 = [p5];
89 r6 = retx;
90 [p5] = r6;
91 cc = r6 == r7;
Mike Frysinger8d6c2422007-11-21 15:53:49 +080092 if !cc jump _bfin_return_from_exception;
Bryan Wu1394f032007-05-06 14:50:22 -070093 /* fall through */
Robin Getzf26fbc42007-11-12 22:21:30 +080094 R7 = P4;
95 R6 = 0x26; /* Data CPLB Miss */
96 cc = R6 == R7;
97 if cc jump _ex_dcplb_miss (BP);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080098 R6 = 0x23; /* Data CPLB Miss */
99 cc = R6 == R7;
100 if cc jump _ex_dcplb_viol (BP);
Robin Getzf26fbc42007-11-12 22:21:30 +0800101 /* Handle 0x23 Data CPLB Protection Violation
102 * and Data CPLB Multiple Hits - Linux Trap Zero
103 */
104 jump _ex_trap_c;
105ENDPROC(_ex_workaround_261)
Bryan Wu1394f032007-05-06 14:50:22 -0700106
Robin Getzf26fbc42007-11-12 22:21:30 +0800107#else
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800108#ifdef CONFIG_MPU
109#define _ex_dviol _ex_dcplb_viol
110#else
Robin Getzf26fbc42007-11-12 22:21:30 +0800111#define _ex_dviol _ex_trap_c
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800112#endif
Robin Getzf26fbc42007-11-12 22:21:30 +0800113#define _ex_dmiss _ex_dcplb_miss
114#define _ex_dmult _ex_trap_c
115#endif
116
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800117
118ENTRY(_ex_dcplb_viol)
Robin Getzf26fbc42007-11-12 22:21:30 +0800119ENTRY(_ex_dcplb_miss)
120ENTRY(_ex_icplb_miss)
Bryan Wu1394f032007-05-06 14:50:22 -0700121 (R7:6,P5:4) = [sp++];
122 ASTAT = [sp++];
123 SAVE_ALL_SYS
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800124#ifdef CONFIG_MPU
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800125 /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
126 * will change the stack pointer. */
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800127 R0 = SEQSTAT;
128 R1 = SP;
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800129#endif
130 DEBUG_HWTRACE_SAVE(p5, r7)
131#ifdef CONFIG_MPU
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800132 sp += -12;
133 call _cplb_hdr;
134 sp += 12;
135 CC = R0 == 0;
136 IF !CC JUMP _handle_bad_cplb;
137#else
Bryan Wu1394f032007-05-06 14:50:22 -0700138 call __cplb_hdr;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800139#endif
Mike Frysinger80f31c82008-02-02 15:47:24 +0800140 DEBUG_HWTRACE_RESTORE(p5, r7)
Bryan Wu1394f032007-05-06 14:50:22 -0700141 RESTORE_ALL_SYS
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800142 SP = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700143 rtx;
Robin Getzf26fbc42007-11-12 22:21:30 +0800144ENDPROC(_ex_icplb_miss)
Bryan Wu1394f032007-05-06 14:50:22 -0700145
Bryan Wu1394f032007-05-06 14:50:22 -0700146ENTRY(_ex_syscall)
Bryan Wu1394f032007-05-06 14:50:22 -0700147 (R7:6,P5:4) = [sp++];
148 ASTAT = [sp++];
149 raise 15; /* invoked by TRAP #0, for sys call */
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800150 sp = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700151 rtx
Mike Frysinger51be24c2007-06-11 15:31:30 +0800152ENDPROC(_ex_syscall)
Bryan Wu1394f032007-05-06 14:50:22 -0700153
Bryan Wu1394f032007-05-06 14:50:22 -0700154ENTRY(_ex_soft_bp)
155 r7 = retx;
156 r7 += -2;
157 retx = r7;
158 jump.s _ex_trap_c;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800159ENDPROC(_ex_soft_bp)
Bryan Wu1394f032007-05-06 14:50:22 -0700160
161ENTRY(_ex_single_step)
162 r7 = retx;
163 r6 = reti;
164 cc = r7 == r6;
Mike Frysinger8d6c2422007-11-21 15:53:49 +0800165 if cc jump _bfin_return_from_exception
Bryan Wu1394f032007-05-06 14:50:22 -0700166 r7 = syscfg;
167 bitclr (r7, 0);
168 syscfg = R7;
169
170 p5.l = lo(IPEND);
171 p5.h = hi(IPEND);
172 r6 = [p5];
173 cc = bittst(r6, 5);
174 if !cc jump _ex_trap_c;
175 p4.l = lo(EVT5);
176 p4.h = hi(EVT5);
177 r6.h = _exception_to_level5;
178 r6.l = _exception_to_level5;
179 r7 = [p4];
180 cc = r6 == r7;
181 if !cc jump _ex_trap_c;
Mike Frysinger46c87c32007-11-21 16:15:48 +0800182ENDPROC(_ex_single_step)
Bryan Wu1394f032007-05-06 14:50:22 -0700183
Mike Frysinger8d6c2422007-11-21 15:53:49 +0800184ENTRY(_bfin_return_from_exception)
Mike Frysinger1aafd902007-07-25 11:19:14 +0800185#if ANOMALY_05000257
Michael Hennerich8af10b72007-05-21 18:09:09 +0800186 R7=LC0;
187 LC0=R7;
188 R7=LC1;
189 LC1=R7;
190#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700191 (R7:6,P5:4) = [sp++];
192 ASTAT = [sp++];
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800193 sp = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700194 rtx;
Mike Frysinger46c87c32007-11-21 16:15:48 +0800195ENDPROC(_bfin_return_from_exception)
Bryan Wu1394f032007-05-06 14:50:22 -0700196
197ENTRY(_handle_bad_cplb)
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800198 DEBUG_HWTRACE_RESTORE(p5, r7)
Bryan Wu1394f032007-05-06 14:50:22 -0700199 /* To get here, we just tried and failed to change a CPLB
200 * so, handle things in trap_c (C code), by lowering to
201 * IRQ5, just like we normally do. Since this is not a
202 * "normal" return path, we have a do alot of stuff to
203 * the stack to get ready so, we can fall through - we
204 * need to make a CPLB exception look like a normal exception
205 */
206
Bryan Wu1394f032007-05-06 14:50:22 -0700207 RESTORE_ALL_SYS
208 [--sp] = ASTAT;
Mike Frysinger80f31c82008-02-02 15:47:24 +0800209 [--sp] = (R7:6,P5:4);
Bryan Wu1394f032007-05-06 14:50:22 -0700210
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800211ENTRY(_ex_replaceable)
212 nop;
213
Bryan Wu1394f032007-05-06 14:50:22 -0700214ENTRY(_ex_trap_c)
Robin Getz2ebcade2007-10-09 17:24:30 +0800215 /* Make sure we are not in a double fault */
216 p4.l = lo(IPEND);
217 p4.h = hi(IPEND);
218 r7 = [p4];
219 CC = BITTST (r7, 5);
220 if CC jump _double_fault;
221
Bryan Wu1394f032007-05-06 14:50:22 -0700222 /* Call C code (trap_c) to handle the exception, which most
223 * likely involves sending a signal to the current process.
224 * To avoid double faults, lower our priority to IRQ5 first.
225 */
226 P5.h = _exception_to_level5;
227 P5.l = _exception_to_level5;
228 p4.l = lo(EVT5);
229 p4.h = hi(EVT5);
230 [p4] = p5;
231 csync;
232
233 /* Disable all interrupts, but make sure level 5 is enabled so
234 * we can switch to that level. Save the old mask. */
235 cli r6;
236 p4.l = _excpt_saved_imask;
237 p4.h = _excpt_saved_imask;
238 [p4] = r6;
239 r6 = 0x3f;
240 sti r6;
241
242 /* Save the excause into a circular buffer, in case the instruction
243 * which caused this excecptions causes others.
244 */
245 P5.l = _in_ptr_excause;
246 P5.h = _in_ptr_excause;
247 R7 = [P5];
248 R7 += 4;
249 R6 = 0xF;
250 R7 = R7 & R6;
251 [P5] = R7;
252 R6.l = _excause_circ_buf;
253 R6.h = _excause_circ_buf;
254 R7 = R7 + R6;
255 p5 = R7;
256 R6 = SEQSTAT;
257 [P5] = R6;
258
Bryan Wu1394f032007-05-06 14:50:22 -0700259 (R7:6,P5:4) = [sp++];
260 ASTAT = [sp++];
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800261 SP = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700262 raise 5;
263 rtx;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800264ENDPROC(_ex_trap_c)
Bryan Wu1394f032007-05-06 14:50:22 -0700265
Robin Getz2ebcade2007-10-09 17:24:30 +0800266/* We just realized we got an exception, while we were processing a different
267 * exception. This is a unrecoverable event, so crash
268 */
269ENTRY(_double_fault)
270 /* Turn caches & protection off, to ensure we don't get any more
271 * double exceptions
272 */
273
274 P4.L = LO(IMEM_CONTROL);
275 P4.H = HI(IMEM_CONTROL);
276
277 R5 = [P4]; /* Control Register*/
278 BITCLR(R5,ENICPLB_P);
279 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
280 .align 8;
281 [P4] = R5;
282 SSYNC;
283
284 P4.L = LO(DMEM_CONTROL);
285 P4.H = HI(DMEM_CONTROL);
286 R5 = [P4];
287 BITCLR(R5,ENDCPLB_P);
288 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
289 .align 8;
290 [P4] = R5;
291 SSYNC;
292
293 /* Fix up the stack */
294 (R7:6,P5:4) = [sp++];
295 ASTAT = [sp++];
296 SP = EX_SCRATCH_REG;
297
298 /* We should be out of the exception stack, and back down into
299 * kernel or user space stack
300 */
301 SAVE_ALL_SYS
302
303 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
304 SP += -12;
305 call _double_fault_c;
306 SP += 12;
307.L_double_fault_panic:
308 JUMP .L_double_fault_panic
309
310ENDPROC(_double_fault)
311
Bryan Wu1394f032007-05-06 14:50:22 -0700312ENTRY(_exception_to_level5)
313 SAVE_ALL_SYS
314
315 /* Restore interrupt mask. We haven't pushed RETI, so this
316 * doesn't enable interrupts until we return from this handler. */
317 p4.l = _excpt_saved_imask;
318 p4.h = _excpt_saved_imask;
319 r6 = [p4];
320 sti r6;
321
322 /* Restore the hardware error vector. */
323 P5.h = _evt_ivhw;
324 P5.l = _evt_ivhw;
325 p4.l = lo(EVT5);
326 p4.h = hi(EVT5);
327 [p4] = p5;
328 csync;
329
330 p2.l = lo(IPEND);
331 p2.h = hi(IPEND);
332 csync;
333 r0 = [p2]; /* Read current IPEND */
334 [sp + PT_IPEND] = r0; /* Store IPEND */
335
336 /* Pop the excause from the circular buffer and push it on the stack
337 * (in the right place - if you change the location of SEQSTAT, you
338 * must change this offset.
339 */
340.L_excep_to_5_again:
341 P5.l = _out_ptr_excause;
342 P5.h = _out_ptr_excause;
343 R7 = [P5];
344 R7 += 4;
345 R6 = 0xF;
346 R7 = R7 & R6;
347 [P5] = R7;
348 R6.l = _excause_circ_buf;
349 R6.h = _excause_circ_buf;
350 R7 = R7 + R6;
351 P5 = R7;
352 R1 = [P5];
Robin Getz6f3ed702007-12-21 17:48:07 +0800353 [SP + PT_SEQSTAT] = r1;
Bryan Wu1394f032007-05-06 14:50:22 -0700354
355 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
356 SP += -12;
357 call _trap_c;
358 SP += 12;
359
360 /* See if anything else is in the exception buffer
361 * if there is, process it
362 */
363 P5.l = _out_ptr_excause;
364 P5.h = _out_ptr_excause;
365 P4.l = _in_ptr_excause;
366 P4.h = _in_ptr_excause;
367 R6 = [P5];
368 R7 = [P4];
369 CC = R6 == R7;
370 if ! CC JUMP .L_excep_to_5_again
371
372 call _ret_from_exception;
373 RESTORE_ALL_SYS
374 rti;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800375ENDPROC(_exception_to_level5)
Bryan Wu1394f032007-05-06 14:50:22 -0700376
377ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
378 /* Since the kernel stack can be anywhere, it's not guaranteed to be
379 * covered by a CPLB. Switch to an exception stack; use RETN as a
380 * scratch register (for want of a better option).
381 */
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800382 EX_SCRATCH_REG = sp;
Bryan Wu1394f032007-05-06 14:50:22 -0700383 sp.l = _exception_stack_top;
384 sp.h = _exception_stack_top;
385 /* Try to deal with syscalls quickly. */
386 [--sp] = ASTAT;
Mike Frysinger80f31c82008-02-02 15:47:24 +0800387 [--sp] = (R7:6,P5:4);
Bryan Wu1394f032007-05-06 14:50:22 -0700388 r7 = SEQSTAT; /* reason code is in bit 5:0 */
389 r6.l = lo(SEQSTAT_EXCAUSE);
390 r6.h = hi(SEQSTAT_EXCAUSE);
391 r7 = r7 & r6;
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800392 p5.h = _ex_table;
393 p5.l = _ex_table;
Bryan Wu1394f032007-05-06 14:50:22 -0700394 p4 = r7;
395 p5 = p5 + (p4 << 2);
396 p4 = [p5];
397 jump (p4);
398
399.Lbadsys:
400 r7 = -ENOSYS; /* signextending enough */
401 [sp + PT_R0] = r7; /* return value from system call */
402 jump .Lsyscall_really_exit;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800403ENDPROC(_trap)
Bryan Wu1394f032007-05-06 14:50:22 -0700404
405ENTRY(_kernel_execve)
406 link SIZEOF_PTREGS;
407 p0 = sp;
408 r3 = SIZEOF_PTREGS / 4;
409 r4 = 0(x);
4100:
411 [p0++] = r4;
412 r3 += -1;
413 cc = r3 == 0;
414 if !cc jump 0b (bp);
415
416 p0 = sp;
417 sp += -16;
418 [sp + 12] = p0;
419 call _do_execve;
420 SP += 16;
421 cc = r0 == 0;
422 if ! cc jump 1f;
423 /* Success. Copy our temporary pt_regs to the top of the kernel
424 * stack and do a normal exception return.
425 */
426 r1 = sp;
427 r0 = (-KERNEL_STACK_SIZE) (x);
428 r1 = r1 & r0;
429 p2 = r1;
430 p3 = [p2];
431 r0 = KERNEL_STACK_SIZE - 4 (z);
432 p1 = r0;
433 p1 = p1 + p2;
434
435 p0 = fp;
436 r4 = [p0--];
437 r3 = SIZEOF_PTREGS / 4;
4380:
439 r4 = [p0--];
440 [p1--] = r4;
441 r3 += -1;
442 cc = r3 == 0;
443 if ! cc jump 0b (bp);
444
445 r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
446 p1 = r0;
447 p1 = p1 + p2;
448 sp = p1;
449 r0 = syscfg;
450 [SP + PT_SYSCFG] = r0;
451 [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
452
453 RESTORE_CONTEXT;
454 rti;
4551:
456 unlink;
457 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800458ENDPROC(_kernel_execve)
Bryan Wu1394f032007-05-06 14:50:22 -0700459
460ENTRY(_system_call)
461 /* Store IPEND */
462 p2.l = lo(IPEND);
463 p2.h = hi(IPEND);
464 csync;
465 r0 = [p2];
466 [sp + PT_IPEND] = r0;
467
468 /* Store RETS for now */
469 r0 = rets;
470 [sp + PT_RESERVED] = r0;
471 /* Set the stack for the current process */
472 r7 = sp;
473 r6.l = lo(ALIGN_PAGE_MASK);
474 r6.h = hi(ALIGN_PAGE_MASK);
475 r7 = r7 & r6; /* thread_info */
476 p2 = r7;
477 p2 = [p2];
478
479 [p2+(TASK_THREAD+THREAD_KSP)] = sp;
480
481 /* Check the System Call */
482 r7 = __NR_syscall;
483 /* System call number is passed in P0 */
484 r6 = p0;
485 cc = r6 < r7;
486 if ! cc jump .Lbadsys;
487
488 /* are we tracing syscalls?*/
489 r7 = sp;
490 r6.l = lo(ALIGN_PAGE_MASK);
491 r6.h = hi(ALIGN_PAGE_MASK);
492 r7 = r7 & r6;
493 p2 = r7;
494 r7 = [p2+TI_FLAGS];
495 CC = BITTST(r7,TIF_SYSCALL_TRACE);
496 if CC JUMP _sys_trace;
497
498 /* Execute the appropriate system call */
499
500 p4 = p0;
501 p5.l = _sys_call_table;
502 p5.h = _sys_call_table;
503 p5 = p5 + (p4 << 2);
504 r0 = [sp + PT_R0];
505 r1 = [sp + PT_R1];
506 r2 = [sp + PT_R2];
507 p5 = [p5];
508
509 [--sp] = r5;
510 [--sp] = r4;
511 [--sp] = r3;
512 SP += -12;
513 call (p5);
514 SP += 24;
515 [sp + PT_R0] = r0;
516
517.Lresume_userspace:
518 r7 = sp;
519 r4.l = lo(ALIGN_PAGE_MASK);
520 r4.h = hi(ALIGN_PAGE_MASK);
521 r7 = r7 & r4; /* thread_info->flags */
522 p5 = r7;
523.Lresume_userspace_1:
524 /* Disable interrupts. */
525 [--sp] = reti;
526 reti = [sp++];
527
528 r7 = [p5 + TI_FLAGS];
529 r4.l = lo(_TIF_WORK_MASK);
530 r4.h = hi(_TIF_WORK_MASK);
531 r7 = r7 & r4;
532
533.Lsyscall_resched:
534 cc = BITTST(r7, TIF_NEED_RESCHED);
535 if !cc jump .Lsyscall_sigpending;
536
537 /* Reenable interrupts. */
538 [--sp] = reti;
539 r0 = [sp++];
540
541 SP += -12;
542 call _schedule;
543 SP += 12;
544
545 jump .Lresume_userspace_1;
546
547.Lsyscall_sigpending:
548 cc = BITTST(r7, TIF_RESTORE_SIGMASK);
549 if cc jump .Lsyscall_do_signals;
550 cc = BITTST(r7, TIF_SIGPENDING);
551 if !cc jump .Lsyscall_really_exit;
552.Lsyscall_do_signals:
553 /* Reenable interrupts. */
554 [--sp] = reti;
555 r0 = [sp++];
556
557 r0 = sp;
558 SP += -12;
559 call _do_signal;
560 SP += 12;
561
562.Lsyscall_really_exit:
563 r5 = [sp + PT_RESERVED];
564 rets = r5;
565 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800566ENDPROC(_system_call)
Bryan Wu1394f032007-05-06 14:50:22 -0700567
568_sys_trace:
569 call _syscall_trace;
570
571 /* Execute the appropriate system call */
572
573 p4 = [SP + PT_P0];
574 p5.l = _sys_call_table;
575 p5.h = _sys_call_table;
576 p5 = p5 + (p4 << 2);
577 r0 = [sp + PT_R0];
578 r1 = [sp + PT_R1];
579 r2 = [sp + PT_R2];
580 r3 = [sp + PT_R3];
581 r4 = [sp + PT_R4];
582 r5 = [sp + PT_R5];
583 p5 = [p5];
584
585 [--sp] = r5;
586 [--sp] = r4;
587 [--sp] = r3;
588 SP += -12;
589 call (p5);
590 SP += 24;
591 [sp + PT_R0] = r0;
592
593 call _syscall_trace;
594 jump .Lresume_userspace;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800595ENDPROC(_sys_trace)
Bryan Wu1394f032007-05-06 14:50:22 -0700596
597ENTRY(_resume)
598 /*
599 * Beware - when entering resume, prev (the current task) is
600 * in r0, next (the new task) is in r1.
601 */
602 p0 = r0;
603 p1 = r1;
604 [--sp] = rets;
605 [--sp] = fp;
606 [--sp] = (r7:4, p5:3);
607
608 /* save usp */
609 p2 = usp;
610 [p0+(TASK_THREAD+THREAD_USP)] = p2;
611
612 /* save current kernel stack pointer */
613 [p0+(TASK_THREAD+THREAD_KSP)] = sp;
614
615 /* save program counter */
616 r1.l = _new_old_task;
617 r1.h = _new_old_task;
618 [p0+(TASK_THREAD+THREAD_PC)] = r1;
619
620 /* restore the kernel stack pointer */
621 sp = [p1+(TASK_THREAD+THREAD_KSP)];
622
623 /* restore user stack pointer */
624 p0 = [p1+(TASK_THREAD+THREAD_USP)];
625 usp = p0;
626
627 /* restore pc */
628 p0 = [p1+(TASK_THREAD+THREAD_PC)];
629 jump (p0);
630
631 /*
632 * Following code actually lands up in a new (old) task.
633 */
634
635_new_old_task:
636 (r7:4, p5:3) = [sp++];
637 fp = [sp++];
638 rets = [sp++];
639
640 /*
641 * When we come out of resume, r0 carries "old" task, becuase we are
642 * in "new" task.
643 */
644 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800645ENDPROC(_resume)
Bryan Wu1394f032007-05-06 14:50:22 -0700646
647ENTRY(_ret_from_exception)
648 p2.l = lo(IPEND);
649 p2.h = hi(IPEND);
650
651 csync;
652 r0 = [p2];
653 [sp + PT_IPEND] = r0;
654
6551:
Robin Getzd5c4b5e2007-12-21 17:49:53 +0800656 r2 = LO(~0x37) (Z);
Bryan Wu1394f032007-05-06 14:50:22 -0700657 r0 = r2 & r0;
658 cc = r0 == 0;
659 if !cc jump 4f; /* if not return to user mode, get out */
660
661 /* Make sure any pending system call or deferred exception
662 * return in ILAT for this process to get executed, otherwise
663 * in case context switch happens, system call of
664 * first process (i.e in ILAT) will be carried
665 * forward to the switched process
666 */
667
668 p2.l = lo(ILAT);
669 p2.h = hi(ILAT);
670 r0 = [p2];
671 r1 = (EVT_IVG14 | EVT_IVG15) (z);
672 r0 = r0 & r1;
673 cc = r0 == 0;
674 if !cc jump 5f;
675
676 /* Set the stack for the current process */
677 r7 = sp;
678 r4.l = lo(ALIGN_PAGE_MASK);
679 r4.h = hi(ALIGN_PAGE_MASK);
680 r7 = r7 & r4; /* thread_info->flags */
681 p5 = r7;
682 r7 = [p5 + TI_FLAGS];
683 r4.l = lo(_TIF_WORK_MASK);
684 r4.h = hi(_TIF_WORK_MASK);
685 r7 = r7 & r4;
686 cc = r7 == 0;
687 if cc jump 4f;
688
689 p0.l = lo(EVT15);
690 p0.h = hi(EVT15);
691 p1.l = _schedule_and_signal;
692 p1.h = _schedule_and_signal;
693 [p0] = p1;
694 csync;
695 raise 15; /* raise evt14 to do signal or reschedule */
6964:
697 r0 = syscfg;
698 bitclr(r0, 0);
699 syscfg = r0;
7005:
701 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800702ENDPROC(_ret_from_exception)
Bryan Wu1394f032007-05-06 14:50:22 -0700703
704ENTRY(_return_from_int)
705 /* If someone else already raised IRQ 15, do nothing. */
706 csync;
707 p2.l = lo(ILAT);
708 p2.h = hi(ILAT);
709 r0 = [p2];
710 cc = bittst (r0, EVT_IVG15_P);
711 if cc jump 2f;
712
713 /* if not return to user mode, get out */
714 p2.l = lo(IPEND);
715 p2.h = hi(IPEND);
716 r0 = [p2];
717 r1 = 0x17(Z);
718 r2 = ~r1;
719 r2.h = 0;
720 r0 = r2 & r0;
721 r1 = 1;
722 r1 = r0 - r1;
723 r2 = r0 & r1;
724 cc = r2 == 0;
725 if !cc jump 2f;
726
727 /* Lower the interrupt level to 15. */
728 p0.l = lo(EVT15);
729 p0.h = hi(EVT15);
730 p1.l = _schedule_and_signal_from_int;
731 p1.h = _schedule_and_signal_from_int;
732 [p0] = p1;
733 csync;
Mike Frysinger1aafd902007-07-25 11:19:14 +0800734#if ANOMALY_05000281
Robin Getzb3f8b922007-10-10 17:28:27 +0800735 r0.l = _safe_speculative_execution;
736 r0.h = _safe_speculative_execution;
Bryan Wu1394f032007-05-06 14:50:22 -0700737 reti = r0;
738#endif
739 r0 = 0x801f (z);
740 STI r0;
741 raise 15; /* raise evt15 to do signal or reschedule */
742 rti;
7432:
744 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800745ENDPROC(_return_from_int)
Bryan Wu1394f032007-05-06 14:50:22 -0700746
747ENTRY(_lower_to_irq14)
Mike Frysinger1aafd902007-07-25 11:19:14 +0800748#if ANOMALY_05000281
Robin Getzb3f8b922007-10-10 17:28:27 +0800749 r0.l = _safe_speculative_execution;
750 r0.h = _safe_speculative_execution;
Bryan Wu1394f032007-05-06 14:50:22 -0700751 reti = r0;
752#endif
753 r0 = 0x401f;
754 sti r0;
755 raise 14;
756 rti;
757ENTRY(_evt14_softirq)
758#ifdef CONFIG_DEBUG_HWERR
759 r0 = 0x3f;
760 sti r0;
761#else
762 cli r0;
763#endif
764 [--sp] = RETI;
765 SP += 4;
766 rts;
767
768_schedule_and_signal_from_int:
769 /* To end up here, vector 15 was changed - so we have to change it
770 * back.
771 */
772 p0.l = lo(EVT15);
773 p0.h = hi(EVT15);
774 p1.l = _evt_system_call;
775 p1.h = _evt_system_call;
776 [p0] = p1;
777 csync;
Bernd Schmidtc8244982007-05-21 18:09:33 +0800778
779 /* Set orig_p0 to -1 to indicate this isn't the end of a syscall. */
780 r0 = -1 (x);
781 [sp + PT_ORIG_P0] = r0;
782
Bryan Wu1394f032007-05-06 14:50:22 -0700783 p1 = rets;
784 [sp + PT_RESERVED] = p1;
785
786 p0.l = _irq_flags;
787 p0.h = _irq_flags;
788 r0 = [p0];
789 sti r0;
790
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800791 r0 = sp;
792 sp += -12;
793 call _finish_atomic_sections;
794 sp += 12;
Bryan Wu1394f032007-05-06 14:50:22 -0700795 jump.s .Lresume_userspace;
796
797_schedule_and_signal:
798 SAVE_CONTEXT_SYSCALL
799 /* To end up here, vector 15 was changed - so we have to change it
800 * back.
801 */
802 p0.l = lo(EVT15);
803 p0.h = hi(EVT15);
804 p1.l = _evt_system_call;
805 p1.h = _evt_system_call;
806 [p0] = p1;
807 csync;
808 p0.l = 1f;
809 p0.h = 1f;
810 [sp + PT_RESERVED] = P0;
811 call .Lresume_userspace;
8121:
813 RESTORE_CONTEXT
814 rti;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800815ENDPROC(_lower_to_irq14)
Bryan Wu1394f032007-05-06 14:50:22 -0700816
817/* Make sure when we start, that the circular buffer is initialized properly
818 * R0 and P0 are call clobbered, so we can use them here.
819 */
820ENTRY(_init_exception_buff)
821 r0 = 0;
822 p0.h = _in_ptr_excause;
823 p0.l = _in_ptr_excause;
824 [p0] = r0;
825 p0.h = _out_ptr_excause;
826 p0.l = _out_ptr_excause;
827 [p0] = r0;
828 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800829ENDPROC(_init_exception_buff)
Bryan Wu1394f032007-05-06 14:50:22 -0700830
Robin Getz518039b2007-07-25 11:03:28 +0800831/* We handle this 100% in exception space - to reduce overhead
832 * Only potiential problem is if the software buffer gets swapped out of the
833 * CPLB table - then double fault. - so we don't let this happen in other places
834 */
835#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
836ENTRY(_ex_trace_buff_full)
837 [--sp] = P3;
838 [--sp] = P2;
839 [--sp] = LC0;
840 [--sp] = LT0;
841 [--sp] = LB0;
842 P5.L = _trace_buff_offset;
843 P5.H = _trace_buff_offset;
844 P3 = [P5]; /* trace_buff_offset */
845 P5.L = lo(TBUFSTAT);
846 P5.H = hi(TBUFSTAT);
847 R7 = [P5];
848 R7 <<= 1; /* double, since we need to read twice */
849 LC0 = R7;
850 R7 <<= 2; /* need to shift over again,
851 * to get the number of bytes */
852 P5.L = lo(TBUF);
853 P5.H = hi(TBUF);
854 R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
855
856 P2 = R7;
857 P3 = P3 + P2;
858 R7 = P3;
859 R7 = R7 & R6;
860 P3 = R7;
861 P2.L = _trace_buff_offset;
862 P2.H = _trace_buff_offset;
863 [P2] = P3;
864
865 P2.L = _software_trace_buff;
866 P2.H = _software_trace_buff;
867
868 LSETUP (.Lstart, .Lend) LC0;
869.Lstart:
870 R7 = [P5]; /* read TBUF */
871 P4 = P3 + P2;
872 [P4] = R7;
873 P3 += -4;
874 R7 = P3;
875 R7 = R7 & R6;
876.Lend:
877 P3 = R7;
878
879 LB0 = [sp++];
880 LT0 = [sp++];
881 LC0 = [sp++];
882 P2 = [sp++];
883 P3 = [sp++];
Mike Frysinger8d6c2422007-11-21 15:53:49 +0800884 jump _bfin_return_from_exception;
Robin Getz337d3902007-10-09 17:31:46 +0800885ENDPROC(_ex_trace_buff_full)
Robin Getz518039b2007-07-25 11:03:28 +0800886
887#if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
888.data
889#else
890.section .l1.data.B
Robin Getz337d3902007-10-09 17:31:46 +0800891#endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
Robin Getz518039b2007-07-25 11:03:28 +0800892ENTRY(_trace_buff_offset)
893 .long 0;
894ALIGN
895ENTRY(_software_trace_buff)
896 .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
897 .long 0
898 .endr
Robin Getz337d3902007-10-09 17:31:46 +0800899#endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
900
901#if CONFIG_EARLY_PRINTK
Mike Frysinger9cb07b22007-11-21 16:45:08 +0800902__INIT
Robin Getz337d3902007-10-09 17:31:46 +0800903ENTRY(_early_trap)
904 SAVE_ALL_SYS
905 trace_buffer_stop(p0,r0);
906
907 /* Turn caches off, to ensure we don't get double exceptions */
908
909 P4.L = LO(IMEM_CONTROL);
910 P4.H = HI(IMEM_CONTROL);
911
912 R5 = [P4]; /* Control Register*/
913 BITCLR(R5,ENICPLB_P);
914 CLI R1;
915 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
916 .align 8;
917 [P4] = R5;
918 SSYNC;
919
920 P4.L = LO(DMEM_CONTROL);
921 P4.H = HI(DMEM_CONTROL);
922 R5 = [P4];
923 BITCLR(R5,ENDCPLB_P);
924 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
925 .align 8;
926 [P4] = R5;
927 SSYNC;
928 STI R1;
929
930 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
931 r1 = RETX;
932
933 SP += -12;
934 call _early_trap_c;
935 SP += 12;
936ENDPROC(_early_trap)
Mike Frysinger9cb07b22007-11-21 16:45:08 +0800937__FINIT
Robin Getz337d3902007-10-09 17:31:46 +0800938#endif /* CONFIG_EARLY_PRINTK */
Robin Getz518039b2007-07-25 11:03:28 +0800939
Bryan Wu1394f032007-05-06 14:50:22 -0700940/*
941 * Put these in the kernel data section - that should always be covered by
942 * a CPLB. This is needed to ensure we don't get double fault conditions
943 */
944
945#ifdef CONFIG_SYSCALL_TAB_L1
946.section .l1.data
947#else
948.data
949#endif
Robin Getzf26fbc42007-11-12 22:21:30 +0800950
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800951ENTRY(_ex_table)
Bryan Wu1394f032007-05-06 14:50:22 -0700952 /* entry for each EXCAUSE[5:0]
Mike Frysinger9401e612007-07-12 11:50:43 +0800953 * This table must be in sync with the table in ./kernel/traps.c
Bryan Wu1394f032007-05-06 14:50:22 -0700954 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
955 */
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800956 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
Bryan Wu1394f032007-05-06 14:50:22 -0700957 .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800958 .long _ex_replaceable /* 0x02 - User Defined */
Mike Frysinger9401e612007-07-12 11:50:43 +0800959 .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
Robin Getz9f336a52007-10-29 18:23:28 +0800960 .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800961 .long _ex_replaceable /* 0x05 - User Defined */
962 .long _ex_replaceable /* 0x06 - User Defined */
963 .long _ex_replaceable /* 0x07 - User Defined */
964 .long _ex_replaceable /* 0x08 - User Defined */
965 .long _ex_replaceable /* 0x09 - User Defined */
966 .long _ex_replaceable /* 0x0A - User Defined */
967 .long _ex_replaceable /* 0x0B - User Defined */
968 .long _ex_replaceable /* 0x0C - User Defined */
969 .long _ex_replaceable /* 0x0D - User Defined */
970 .long _ex_replaceable /* 0x0E - User Defined */
971 .long _ex_replaceable /* 0x0F - User Defined */
Bryan Wu1394f032007-05-06 14:50:22 -0700972 .long _ex_single_step /* 0x10 - HW Single step */
Robin Getz518039b2007-07-25 11:03:28 +0800973#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
974 .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
975#else
Bryan Wu1394f032007-05-06 14:50:22 -0700976 .long _ex_trap_c /* 0x11 - Trace Buffer Full */
Robin Getz518039b2007-07-25 11:03:28 +0800977#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700978 .long _ex_trap_c /* 0x12 - Reserved */
979 .long _ex_trap_c /* 0x13 - Reserved */
980 .long _ex_trap_c /* 0x14 - Reserved */
981 .long _ex_trap_c /* 0x15 - Reserved */
982 .long _ex_trap_c /* 0x16 - Reserved */
983 .long _ex_trap_c /* 0x17 - Reserved */
984 .long _ex_trap_c /* 0x18 - Reserved */
985 .long _ex_trap_c /* 0x19 - Reserved */
986 .long _ex_trap_c /* 0x1A - Reserved */
987 .long _ex_trap_c /* 0x1B - Reserved */
988 .long _ex_trap_c /* 0x1C - Reserved */
989 .long _ex_trap_c /* 0x1D - Reserved */
990 .long _ex_trap_c /* 0x1E - Reserved */
991 .long _ex_trap_c /* 0x1F - Reserved */
992 .long _ex_trap_c /* 0x20 - Reserved */
993 .long _ex_trap_c /* 0x21 - Undefined Instruction */
994 .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
Robin Getzf26fbc42007-11-12 22:21:30 +0800995 .long _ex_dviol /* 0x23 - Data CPLB Protection Violation */
Bryan Wu1394f032007-05-06 14:50:22 -0700996 .long _ex_trap_c /* 0x24 - Data access misaligned */
997 .long _ex_trap_c /* 0x25 - Unrecoverable Event */
Robin Getzf26fbc42007-11-12 22:21:30 +0800998 .long _ex_dmiss /* 0x26 - Data CPLB Miss */
999 .long _ex_dmult /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
Bryan Wu1394f032007-05-06 14:50:22 -07001000 .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
1001 .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
1002 .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
Robin Getzf26fbc42007-11-12 22:21:30 +08001003 .long _ex_trap_c /* 0x2B - Instruction CPLB protection Violation */
1004 .long _ex_icplb_miss /* 0x2C - Instruction CPLB miss */
Bryan Wu1394f032007-05-06 14:50:22 -07001005 .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
1006 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1007 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1008 .long _ex_trap_c /* 0x2F - Reserved */
1009 .long _ex_trap_c /* 0x30 - Reserved */
1010 .long _ex_trap_c /* 0x31 - Reserved */
1011 .long _ex_trap_c /* 0x32 - Reserved */
1012 .long _ex_trap_c /* 0x33 - Reserved */
1013 .long _ex_trap_c /* 0x34 - Reserved */
1014 .long _ex_trap_c /* 0x35 - Reserved */
1015 .long _ex_trap_c /* 0x36 - Reserved */
1016 .long _ex_trap_c /* 0x37 - Reserved */
1017 .long _ex_trap_c /* 0x38 - Reserved */
1018 .long _ex_trap_c /* 0x39 - Reserved */
1019 .long _ex_trap_c /* 0x3A - Reserved */
1020 .long _ex_trap_c /* 0x3B - Reserved */
1021 .long _ex_trap_c /* 0x3C - Reserved */
1022 .long _ex_trap_c /* 0x3D - Reserved */
1023 .long _ex_trap_c /* 0x3E - Reserved */
1024 .long _ex_trap_c /* 0x3F - Reserved */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001025END(_ex_table)
Bryan Wu1394f032007-05-06 14:50:22 -07001026
Bryan Wu1394f032007-05-06 14:50:22 -07001027ENTRY(_sys_call_table)
Bryan Wu0b95f222007-09-23 00:51:32 +08001028 .long _sys_restart_syscall /* 0 */
Bryan Wu1394f032007-05-06 14:50:22 -07001029 .long _sys_exit
1030 .long _sys_fork
1031 .long _sys_read
1032 .long _sys_write
1033 .long _sys_open /* 5 */
1034 .long _sys_close
1035 .long _sys_ni_syscall /* old waitpid */
1036 .long _sys_creat
1037 .long _sys_link
1038 .long _sys_unlink /* 10 */
1039 .long _sys_execve
1040 .long _sys_chdir
1041 .long _sys_time
1042 .long _sys_mknod
1043 .long _sys_chmod /* 15 */
1044 .long _sys_chown /* chown16 */
1045 .long _sys_ni_syscall /* old break syscall holder */
1046 .long _sys_ni_syscall /* old stat */
1047 .long _sys_lseek
1048 .long _sys_getpid /* 20 */
1049 .long _sys_mount
1050 .long _sys_ni_syscall /* old umount */
1051 .long _sys_setuid
1052 .long _sys_getuid
1053 .long _sys_stime /* 25 */
1054 .long _sys_ptrace
1055 .long _sys_alarm
1056 .long _sys_ni_syscall /* old fstat */
1057 .long _sys_pause
1058 .long _sys_ni_syscall /* old utime */ /* 30 */
1059 .long _sys_ni_syscall /* old stty syscall holder */
1060 .long _sys_ni_syscall /* old gtty syscall holder */
1061 .long _sys_access
1062 .long _sys_nice
1063 .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1064 .long _sys_sync
1065 .long _sys_kill
1066 .long _sys_rename
1067 .long _sys_mkdir
1068 .long _sys_rmdir /* 40 */
1069 .long _sys_dup
1070 .long _sys_pipe
1071 .long _sys_times
1072 .long _sys_ni_syscall /* old prof syscall holder */
1073 .long _sys_brk /* 45 */
1074 .long _sys_setgid
1075 .long _sys_getgid
1076 .long _sys_ni_syscall /* old sys_signal */
1077 .long _sys_geteuid /* geteuid16 */
1078 .long _sys_getegid /* getegid16 */ /* 50 */
1079 .long _sys_acct
1080 .long _sys_umount /* recycled never used phys() */
1081 .long _sys_ni_syscall /* old lock syscall holder */
1082 .long _sys_ioctl
1083 .long _sys_fcntl /* 55 */
1084 .long _sys_ni_syscall /* old mpx syscall holder */
1085 .long _sys_setpgid
1086 .long _sys_ni_syscall /* old ulimit syscall holder */
1087 .long _sys_ni_syscall /* old old uname */
1088 .long _sys_umask /* 60 */
1089 .long _sys_chroot
1090 .long _sys_ustat
1091 .long _sys_dup2
1092 .long _sys_getppid
1093 .long _sys_getpgrp /* 65 */
1094 .long _sys_setsid
1095 .long _sys_ni_syscall /* old sys_sigaction */
1096 .long _sys_sgetmask
1097 .long _sys_ssetmask
1098 .long _sys_setreuid /* setreuid16 */ /* 70 */
1099 .long _sys_setregid /* setregid16 */
1100 .long _sys_ni_syscall /* old sys_sigsuspend */
1101 .long _sys_ni_syscall /* old sys_sigpending */
1102 .long _sys_sethostname
1103 .long _sys_setrlimit /* 75 */
1104 .long _sys_ni_syscall /* old getrlimit */
1105 .long _sys_getrusage
1106 .long _sys_gettimeofday
1107 .long _sys_settimeofday
1108 .long _sys_getgroups /* getgroups16 */ /* 80 */
1109 .long _sys_setgroups /* setgroups16 */
1110 .long _sys_ni_syscall /* old_select */
1111 .long _sys_symlink
1112 .long _sys_ni_syscall /* old lstat */
1113 .long _sys_readlink /* 85 */
1114 .long _sys_uselib
1115 .long _sys_ni_syscall /* sys_swapon */
1116 .long _sys_reboot
1117 .long _sys_ni_syscall /* old_readdir */
1118 .long _sys_ni_syscall /* sys_mmap */ /* 90 */
1119 .long _sys_munmap
1120 .long _sys_truncate
1121 .long _sys_ftruncate
1122 .long _sys_fchmod
1123 .long _sys_fchown /* fchown16 */ /* 95 */
1124 .long _sys_getpriority
1125 .long _sys_setpriority
1126 .long _sys_ni_syscall /* old profil syscall holder */
1127 .long _sys_statfs
1128 .long _sys_fstatfs /* 100 */
1129 .long _sys_ni_syscall
1130 .long _sys_ni_syscall /* old sys_socketcall */
1131 .long _sys_syslog
1132 .long _sys_setitimer
1133 .long _sys_getitimer /* 105 */
1134 .long _sys_newstat
1135 .long _sys_newlstat
1136 .long _sys_newfstat
1137 .long _sys_ni_syscall /* old uname */
1138 .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
1139 .long _sys_vhangup
1140 .long _sys_ni_syscall /* obsolete idle() syscall */
1141 .long _sys_ni_syscall /* vm86old for i386 */
1142 .long _sys_wait4
1143 .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
1144 .long _sys_sysinfo
1145 .long _sys_ni_syscall /* old sys_ipc */
1146 .long _sys_fsync
1147 .long _sys_ni_syscall /* old sys_sigreturn */
1148 .long _sys_clone /* 120 */
1149 .long _sys_setdomainname
1150 .long _sys_newuname
1151 .long _sys_ni_syscall /* old sys_modify_ldt */
1152 .long _sys_adjtimex
1153 .long _sys_ni_syscall /* 125 */ /* sys_mprotect */
1154 .long _sys_ni_syscall /* old sys_sigprocmask */
1155 .long _sys_ni_syscall /* old "creat_module" */
1156 .long _sys_init_module
1157 .long _sys_delete_module
1158 .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
1159 .long _sys_quotactl
1160 .long _sys_getpgid
1161 .long _sys_fchdir
1162 .long _sys_bdflush
1163 .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
1164 .long _sys_personality
1165 .long _sys_ni_syscall /* for afs_syscall */
1166 .long _sys_setfsuid /* setfsuid16 */
1167 .long _sys_setfsgid /* setfsgid16 */
1168 .long _sys_llseek /* 140 */
1169 .long _sys_getdents
1170 .long _sys_ni_syscall /* sys_select */
1171 .long _sys_flock
1172 .long _sys_ni_syscall /* sys_msync */
1173 .long _sys_readv /* 145 */
1174 .long _sys_writev
1175 .long _sys_getsid
1176 .long _sys_fdatasync
1177 .long _sys_sysctl
1178 .long _sys_ni_syscall /* 150 */ /* sys_mlock */
1179 .long _sys_ni_syscall /* sys_munlock */
1180 .long _sys_ni_syscall /* sys_mlockall */
1181 .long _sys_ni_syscall /* sys_munlockall */
1182 .long _sys_sched_setparam
1183 .long _sys_sched_getparam /* 155 */
1184 .long _sys_sched_setscheduler
1185 .long _sys_sched_getscheduler
1186 .long _sys_sched_yield
1187 .long _sys_sched_get_priority_max
1188 .long _sys_sched_get_priority_min /* 160 */
1189 .long _sys_sched_rr_get_interval
1190 .long _sys_nanosleep
Bryan Wu0b95f222007-09-23 00:51:32 +08001191 .long _sys_mremap
Bryan Wu1394f032007-05-06 14:50:22 -07001192 .long _sys_setresuid /* setresuid16 */
1193 .long _sys_getresuid /* getresuid16 */ /* 165 */
1194 .long _sys_ni_syscall /* for vm86 */
1195 .long _sys_ni_syscall /* old "query_module" */
1196 .long _sys_ni_syscall /* sys_poll */
Bryan Wu0b95f222007-09-23 00:51:32 +08001197 .long _sys_nfsservctl
Bryan Wu1394f032007-05-06 14:50:22 -07001198 .long _sys_setresgid /* setresgid16 */ /* 170 */
1199 .long _sys_getresgid /* getresgid16 */
1200 .long _sys_prctl
1201 .long _sys_rt_sigreturn
1202 .long _sys_rt_sigaction
1203 .long _sys_rt_sigprocmask /* 175 */
1204 .long _sys_rt_sigpending
1205 .long _sys_rt_sigtimedwait
1206 .long _sys_rt_sigqueueinfo
1207 .long _sys_rt_sigsuspend
1208 .long _sys_pread64 /* 180 */
1209 .long _sys_pwrite64
1210 .long _sys_lchown /* lchown16 */
1211 .long _sys_getcwd
1212 .long _sys_capget
1213 .long _sys_capset /* 185 */
1214 .long _sys_sigaltstack
1215 .long _sys_sendfile
1216 .long _sys_ni_syscall /* streams1 */
1217 .long _sys_ni_syscall /* streams2 */
1218 .long _sys_vfork /* 190 */
1219 .long _sys_getrlimit
1220 .long _sys_mmap2
1221 .long _sys_truncate64
1222 .long _sys_ftruncate64
1223 .long _sys_stat64 /* 195 */
1224 .long _sys_lstat64
1225 .long _sys_fstat64
1226 .long _sys_chown
1227 .long _sys_getuid
1228 .long _sys_getgid /* 200 */
1229 .long _sys_geteuid
1230 .long _sys_getegid
1231 .long _sys_setreuid
1232 .long _sys_setregid
1233 .long _sys_getgroups /* 205 */
1234 .long _sys_setgroups
1235 .long _sys_fchown
1236 .long _sys_setresuid
1237 .long _sys_getresuid
1238 .long _sys_setresgid /* 210 */
1239 .long _sys_getresgid
1240 .long _sys_lchown
1241 .long _sys_setuid
1242 .long _sys_setgid
1243 .long _sys_setfsuid /* 215 */
1244 .long _sys_setfsgid
1245 .long _sys_pivot_root
1246 .long _sys_ni_syscall /* sys_mincore */
1247 .long _sys_ni_syscall /* sys_madvise */
1248 .long _sys_getdents64 /* 220 */
1249 .long _sys_fcntl64
1250 .long _sys_ni_syscall /* reserved for TUX */
1251 .long _sys_ni_syscall
1252 .long _sys_gettid
Bryan Wu0b95f222007-09-23 00:51:32 +08001253 .long _sys_readahead /* 225 */
Bryan Wu1394f032007-05-06 14:50:22 -07001254 .long _sys_setxattr
1255 .long _sys_lsetxattr
1256 .long _sys_fsetxattr
1257 .long _sys_getxattr
1258 .long _sys_lgetxattr /* 230 */
1259 .long _sys_fgetxattr
1260 .long _sys_listxattr
1261 .long _sys_llistxattr
1262 .long _sys_flistxattr
1263 .long _sys_removexattr /* 235 */
1264 .long _sys_lremovexattr
1265 .long _sys_fremovexattr
1266 .long _sys_tkill
1267 .long _sys_sendfile64
1268 .long _sys_futex /* 240 */
1269 .long _sys_sched_setaffinity
1270 .long _sys_sched_getaffinity
1271 .long _sys_ni_syscall /* sys_set_thread_area */
1272 .long _sys_ni_syscall /* sys_get_thread_area */
1273 .long _sys_io_setup /* 245 */
1274 .long _sys_io_destroy
1275 .long _sys_io_getevents
1276 .long _sys_io_submit
1277 .long _sys_io_cancel
1278 .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
1279 .long _sys_ni_syscall /* sys_freec_hugepages */
1280 .long _sys_exit_group
1281 .long _sys_lookup_dcookie
1282 .long _sys_bfin_spinlock
1283 .long _sys_epoll_create /* 255 */
1284 .long _sys_epoll_ctl
1285 .long _sys_epoll_wait
1286 .long _sys_ni_syscall /* remap_file_pages */
1287 .long _sys_set_tid_address
1288 .long _sys_timer_create /* 260 */
1289 .long _sys_timer_settime
1290 .long _sys_timer_gettime
1291 .long _sys_timer_getoverrun
1292 .long _sys_timer_delete
1293 .long _sys_clock_settime /* 265 */
1294 .long _sys_clock_gettime
1295 .long _sys_clock_getres
1296 .long _sys_clock_nanosleep
1297 .long _sys_statfs64
1298 .long _sys_fstatfs64 /* 270 */
1299 .long _sys_tgkill
1300 .long _sys_utimes
1301 .long _sys_fadvise64_64
1302 .long _sys_ni_syscall /* vserver */
1303 .long _sys_ni_syscall /* 275, mbind */
1304 .long _sys_ni_syscall /* get_mempolicy */
1305 .long _sys_ni_syscall /* set_mempolicy */
1306 .long _sys_mq_open
1307 .long _sys_mq_unlink
1308 .long _sys_mq_timedsend /* 280 */
1309 .long _sys_mq_timedreceive
1310 .long _sys_mq_notify
1311 .long _sys_mq_getsetattr
1312 .long _sys_ni_syscall /* kexec_load */
1313 .long _sys_waitid /* 285 */
1314 .long _sys_add_key
1315 .long _sys_request_key
1316 .long _sys_keyctl
1317 .long _sys_ioprio_set
1318 .long _sys_ioprio_get /* 290 */
1319 .long _sys_inotify_init
1320 .long _sys_inotify_add_watch
1321 .long _sys_inotify_rm_watch
1322 .long _sys_ni_syscall /* migrate_pages */
1323 .long _sys_openat /* 295 */
1324 .long _sys_mkdirat
1325 .long _sys_mknodat
1326 .long _sys_fchownat
1327 .long _sys_futimesat
1328 .long _sys_fstatat64 /* 300 */
1329 .long _sys_unlinkat
1330 .long _sys_renameat
1331 .long _sys_linkat
1332 .long _sys_symlinkat
1333 .long _sys_readlinkat /* 305 */
1334 .long _sys_fchmodat
1335 .long _sys_faccessat
1336 .long _sys_pselect6
1337 .long _sys_ppoll
1338 .long _sys_unshare /* 310 */
1339 .long _sys_sram_alloc
1340 .long _sys_sram_free
1341 .long _sys_dma_memcpy
1342 .long _sys_accept
1343 .long _sys_bind /* 315 */
1344 .long _sys_connect
1345 .long _sys_getpeername
1346 .long _sys_getsockname
1347 .long _sys_getsockopt
1348 .long _sys_listen /* 320 */
1349 .long _sys_recv
1350 .long _sys_recvfrom
1351 .long _sys_recvmsg
1352 .long _sys_send
1353 .long _sys_sendmsg /* 325 */
1354 .long _sys_sendto
1355 .long _sys_setsockopt
1356 .long _sys_shutdown
1357 .long _sys_socket
1358 .long _sys_socketpair /* 330 */
1359 .long _sys_semctl
1360 .long _sys_semget
1361 .long _sys_semop
1362 .long _sys_msgctl
1363 .long _sys_msgget /* 335 */
1364 .long _sys_msgrcv
1365 .long _sys_msgsnd
1366 .long _sys_shmat
1367 .long _sys_shmctl
1368 .long _sys_shmdt /* 340 */
1369 .long _sys_shmget
Bryan Wu0b95f222007-09-23 00:51:32 +08001370 .long _sys_splice
1371 .long _sys_sync_file_range
1372 .long _sys_tee
1373 .long _sys_vmsplice /* 345 */
1374 .long _sys_epoll_pwait
1375 .long _sys_utimensat
1376 .long _sys_signalfd
Bryan Wu2f775db2008-03-06 16:04:58 -07001377 .long _sys_timerfd_create
Bryan Wu0b95f222007-09-23 00:51:32 +08001378 .long _sys_eventfd /* 350 */
1379 .long _sys_pread64
1380 .long _sys_pwrite64
1381 .long _sys_fadvise64
1382 .long _sys_set_robust_list
1383 .long _sys_get_robust_list /* 355 */
1384 .long _sys_fallocate
Bernd Schmidtfc975512008-01-27 19:56:43 +08001385 .long _sys_semtimedop
Bryan Wu2f775db2008-03-06 16:04:58 -07001386 .long _sys_timerfd_settime
1387 .long _sys_timerfd_gettime
1388
Bryan Wu1394f032007-05-06 14:50:22 -07001389 .rept NR_syscalls-(.-_sys_call_table)/4
1390 .long _sys_ni_syscall
1391 .endr
1392_excpt_saved_imask:
1393 .long 0;
1394
1395_exception_stack:
1396 .rept 1024
1397 .long 0;
1398 .endr
1399_exception_stack_top:
1400
Mike Frysinger1aafd902007-07-25 11:19:14 +08001401#if ANOMALY_05000261
Bryan Wu1394f032007-05-06 14:50:22 -07001402/* Used by the assembly entry point to work around an anomaly. */
1403_last_cplb_fault_retx:
1404 .long 0;
1405#endif
1406/*
1407 * Single instructions can have multiple faults, which need to be
1408 * handled by traps.c, in irq5. We store the exception cause to ensure
1409 * we don't miss a double fault condition
1410 */
1411ENTRY(_in_ptr_excause)
1412 .long 0;
1413ENTRY(_out_ptr_excause)
1414 .long 0;
1415ALIGN
1416ENTRY(_excause_circ_buf)
1417 .rept 4
1418 .long 0
1419 .endr