blob: 76c42d3b5e857d83a1baecd52e7fc0d8ad3ccacb [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>
Bernd Schmidt5d750b92008-04-25 05:02:33 +080041#include <asm/fixed_code.h>
Bryan Wu1394f032007-05-06 14:50:22 -070042#include <asm/thread_info.h> /* TIF_NEED_RESCHED */
43#include <asm/asm-offsets.h>
Robin Getz669b7922007-06-21 16:34:08 +080044#include <asm/trace.h>
Bryan Wu1394f032007-05-06 14:50:22 -070045
Bryan Wu639f6572008-08-27 10:51:02 +080046#include <asm/context.S>
Bryan Wu1394f032007-05-06 14:50:22 -070047
Mike Frysingerf0b5d122007-08-05 17:03:59 +080048#if defined(CONFIG_BFIN_SCRATCH_REG_RETN)
49# define EX_SCRATCH_REG RETN
50#elif defined(CONFIG_BFIN_SCRATCH_REG_RETE)
51# define EX_SCRATCH_REG RETE
52#else
53# define EX_SCRATCH_REG CYCLES
54#endif
55
Bryan Wu1394f032007-05-06 14:50:22 -070056#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
57.section .l1.text
58#else
59.text
60#endif
61
62/* Slightly simplified and streamlined entry point for CPLB misses.
63 * This one does not lower the level to IRQ5, and thus can be used to
64 * patch up CPLB misses on the kernel stack.
65 */
Mike Frysinger1aafd902007-07-25 11:19:14 +080066#if ANOMALY_05000261
Robin Getzf26fbc42007-11-12 22:21:30 +080067#define _ex_dviol _ex_workaround_261
68#define _ex_dmiss _ex_workaround_261
69#define _ex_dmult _ex_workaround_261
70
71ENTRY(_ex_workaround_261)
Bryan Wu1394f032007-05-06 14:50:22 -070072 /*
73 * Work around an anomaly: if we see a new DCPLB fault, return
74 * without doing anything. Then, if we get the same fault again,
75 * handle it.
76 */
Robin Getzf26fbc42007-11-12 22:21:30 +080077 P4 = R7; /* Store EXCAUSE */
Bryan Wu1394f032007-05-06 14:50:22 -070078 p5.l = _last_cplb_fault_retx;
79 p5.h = _last_cplb_fault_retx;
80 r7 = [p5];
81 r6 = retx;
82 [p5] = r6;
83 cc = r6 == r7;
Mike Frysinger8d6c2422007-11-21 15:53:49 +080084 if !cc jump _bfin_return_from_exception;
Bryan Wu1394f032007-05-06 14:50:22 -070085 /* fall through */
Robin Getzf26fbc42007-11-12 22:21:30 +080086 R7 = P4;
87 R6 = 0x26; /* Data CPLB Miss */
88 cc = R6 == R7;
89 if cc jump _ex_dcplb_miss (BP);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080090 R6 = 0x23; /* Data CPLB Miss */
91 cc = R6 == R7;
92 if cc jump _ex_dcplb_viol (BP);
Robin Getzf26fbc42007-11-12 22:21:30 +080093 /* Handle 0x23 Data CPLB Protection Violation
94 * and Data CPLB Multiple Hits - Linux Trap Zero
95 */
96 jump _ex_trap_c;
97ENDPROC(_ex_workaround_261)
Bryan Wu1394f032007-05-06 14:50:22 -070098
Robin Getzf26fbc42007-11-12 22:21:30 +080099#else
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800100#ifdef CONFIG_MPU
101#define _ex_dviol _ex_dcplb_viol
102#else
Robin Getzf26fbc42007-11-12 22:21:30 +0800103#define _ex_dviol _ex_trap_c
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800104#endif
Robin Getzf26fbc42007-11-12 22:21:30 +0800105#define _ex_dmiss _ex_dcplb_miss
106#define _ex_dmult _ex_trap_c
107#endif
108
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800109
110ENTRY(_ex_dcplb_viol)
Robin Getzf26fbc42007-11-12 22:21:30 +0800111ENTRY(_ex_dcplb_miss)
112ENTRY(_ex_icplb_miss)
Bryan Wu1394f032007-05-06 14:50:22 -0700113 (R7:6,P5:4) = [sp++];
114 ASTAT = [sp++];
115 SAVE_ALL_SYS
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800116#ifdef CONFIG_MPU
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800117 /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
118 * will change the stack pointer. */
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800119 R0 = SEQSTAT;
120 R1 = SP;
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800121#endif
122 DEBUG_HWTRACE_SAVE(p5, r7)
123#ifdef CONFIG_MPU
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800124 sp += -12;
125 call _cplb_hdr;
126 sp += 12;
127 CC = R0 == 0;
128 IF !CC JUMP _handle_bad_cplb;
129#else
Bryan Wu1394f032007-05-06 14:50:22 -0700130 call __cplb_hdr;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800131#endif
Robin Getz0c7a6b22008-10-08 16:27:12 +0800132
133#ifdef CONFIG_DEBUG_DOUBLEFAULT
134 /* While we were processing this, did we double fault? */
135 r7 = SEQSTAT; /* reason code is in bit 5:0 */
136 r6.l = lo(SEQSTAT_EXCAUSE);
137 r6.h = hi(SEQSTAT_EXCAUSE);
138 r7 = r7 & r6;
139 r6 = 0x25;
140 CC = R7 == R6;
141 if CC JUMP _double_fault;
142#endif
143
Mike Frysinger80f31c82008-02-02 15:47:24 +0800144 DEBUG_HWTRACE_RESTORE(p5, r7)
Bryan Wu1394f032007-05-06 14:50:22 -0700145 RESTORE_ALL_SYS
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800146 SP = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700147 rtx;
Robin Getzf26fbc42007-11-12 22:21:30 +0800148ENDPROC(_ex_icplb_miss)
Bryan Wu1394f032007-05-06 14:50:22 -0700149
Bryan Wu1394f032007-05-06 14:50:22 -0700150ENTRY(_ex_syscall)
Bryan Wu1394f032007-05-06 14:50:22 -0700151 raise 15; /* invoked by TRAP #0, for sys call */
Robin Getz0c7a6b22008-10-08 16:27:12 +0800152 jump.s _bfin_return_from_exception;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800153ENDPROC(_ex_syscall)
Bryan Wu1394f032007-05-06 14:50:22 -0700154
Bryan Wu1394f032007-05-06 14:50:22 -0700155ENTRY(_ex_soft_bp)
156 r7 = retx;
157 r7 += -2;
158 retx = r7;
159 jump.s _ex_trap_c;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800160ENDPROC(_ex_soft_bp)
Bryan Wu1394f032007-05-06 14:50:22 -0700161
162ENTRY(_ex_single_step)
Bernd Schmidt0893f122008-05-07 11:41:26 +0800163 /* If we just returned from an interrupt, the single step event is
164 for the RTI instruction. */
Bryan Wu1394f032007-05-06 14:50:22 -0700165 r7 = retx;
166 r6 = reti;
167 cc = r7 == r6;
Bernd Schmidt0893f122008-05-07 11:41:26 +0800168 if cc jump _bfin_return_from_exception;
169
Jie Zhang5400c5a2008-08-05 17:33:38 +0800170#ifdef CONFIG_KGDB
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800171 /* Don't do single step in hardware exception handler */
172 p5.l = lo(IPEND);
173 p5.h = hi(IPEND);
174 r6 = [p5];
Sonic Zhangd6a29892008-08-05 18:28:26 +0800175 cc = bittst(r6, 4);
176 if cc jump _bfin_return_from_exception;
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800177 cc = bittst(r6, 5);
178 if cc jump _bfin_return_from_exception;
179
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800180 /* skip single step if current interrupt priority is higher than
181 * that of the first instruction, from which gdb starts single step */
182 r6 >>= 6;
183 r7 = 10;
184.Lfind_priority_start:
185 cc = bittst(r6, 0);
186 if cc jump .Lfind_priority_done;
187 r6 >>= 1;
188 r7 += -1;
189 cc = r7 == 0;
190 if cc jump .Lfind_priority_done;
191 jump.s .Lfind_priority_start;
192.Lfind_priority_done:
Sonic Zhanga5ac0122008-10-13 14:07:19 +0800193 p4.l = _kgdb_single_step;
194 p4.h = _kgdb_single_step;
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800195 r6 = [p4];
196 cc = r6 == 0;
197 if cc jump .Ldo_single_step;
198 r6 += -1;
199 cc = r6 < r7;
Sonic Zhangd6a29892008-08-05 18:28:26 +0800200 if cc jump 1f;
Sonic Zhang0d1cdd72008-07-26 18:54:38 +0800201.Ldo_single_step:
Sonic Zhangd6a29892008-08-05 18:28:26 +0800202#else
Bernd Schmidt0893f122008-05-07 11:41:26 +0800203 /* If we were in user mode, do the single step normally. */
Jie Zhang5400c5a2008-08-05 17:33:38 +0800204 p5.l = lo(IPEND);
205 p5.h = hi(IPEND);
Bernd Schmidt0893f122008-05-07 11:41:26 +0800206 r6 = [p5];
207 r7 = 0xffe0 (z);
208 r7 = r7 & r6;
209 cc = r7 == 0;
Jie Zhang5400c5a2008-08-05 17:33:38 +0800210 if !cc jump 1f;
Sonic Zhangd6a29892008-08-05 18:28:26 +0800211#endif
Bernd Schmidt0893f122008-05-07 11:41:26 +0800212
Jie Zhang5400c5a2008-08-05 17:33:38 +0800213 /* Single stepping only a single instruction, so clear the trace
214 * bit here. */
215 r7 = syscfg;
216 bitclr (r7, 0);
217 syscfg = R7;
218 jump _ex_trap_c;
219
2201:
Bernd Schmidt0893f122008-05-07 11:41:26 +0800221 /*
222 * We were in an interrupt handler. By convention, all of them save
223 * SYSCFG with their first instruction, so by checking whether our
224 * RETX points at the entry point, we can determine whether to allow
225 * a single step, or whether to clear SYSCFG.
226 *
227 * First, find out the interrupt level and the event vector for it.
228 */
229 p5.l = lo(EVT0);
230 p5.h = hi(EVT0);
231 p5 += -4;
2322:
233 r7 = rot r7 by -1;
234 p5 += 4;
235 if !cc jump 2b;
236
237 /* What we actually do is test for the _second_ instruction in the
238 * IRQ handler. That way, if there are insns following the restore
239 * of SYSCFG after leaving the handler, we will not turn off SYSCFG
240 * for them. */
241
242 r7 = [p5];
243 r7 += 2;
244 r6 = RETX;
245 cc = R7 == R6;
246 if !cc jump _bfin_return_from_exception;
247
Bryan Wu1394f032007-05-06 14:50:22 -0700248 r7 = syscfg;
249 bitclr (r7, 0);
250 syscfg = R7;
251
Jie Zhang5400c5a2008-08-05 17:33:38 +0800252 /* Fall through to _bfin_return_from_exception. */
Mike Frysinger46c87c32007-11-21 16:15:48 +0800253ENDPROC(_ex_single_step)
Bryan Wu1394f032007-05-06 14:50:22 -0700254
Mike Frysinger8d6c2422007-11-21 15:53:49 +0800255ENTRY(_bfin_return_from_exception)
Mike Frysinger1aafd902007-07-25 11:19:14 +0800256#if ANOMALY_05000257
Michael Hennerich8af10b72007-05-21 18:09:09 +0800257 R7=LC0;
258 LC0=R7;
259 R7=LC1;
260 LC1=R7;
261#endif
Robin Getz0c7a6b22008-10-08 16:27:12 +0800262
263#ifdef CONFIG_DEBUG_DOUBLEFAULT
264 /* While we were processing the current exception,
265 * did we cause another, and double fault?
266 */
267 r7 = SEQSTAT; /* reason code is in bit 5:0 */
268 r6.l = lo(SEQSTAT_EXCAUSE);
269 r6.h = hi(SEQSTAT_EXCAUSE);
270 r7 = r7 & r6;
271 r6 = 0x25;
272 CC = R7 == R6;
273 if CC JUMP _double_fault;
274
275 /* Did we cause a HW error? */
276 p5.l = lo(ILAT);
277 p5.h = hi(ILAT);
278 r6 = [p5];
279 r7 = 0x20; /* Did I just cause anther HW error? */
280 r7 = r7 & r1;
281 CC = R7 == R6;
282 if CC JUMP _double_fault;
283#endif
284
Bryan Wu1394f032007-05-06 14:50:22 -0700285 (R7:6,P5:4) = [sp++];
286 ASTAT = [sp++];
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800287 sp = EX_SCRATCH_REG;
Bryan Wu1394f032007-05-06 14:50:22 -0700288 rtx;
Mike Frysinger46c87c32007-11-21 16:15:48 +0800289ENDPROC(_bfin_return_from_exception)
Bryan Wu1394f032007-05-06 14:50:22 -0700290
291ENTRY(_handle_bad_cplb)
Bernd Schmidt2a0c4fd2008-04-23 07:17:34 +0800292 DEBUG_HWTRACE_RESTORE(p5, r7)
Bryan Wu1394f032007-05-06 14:50:22 -0700293 /* To get here, we just tried and failed to change a CPLB
294 * so, handle things in trap_c (C code), by lowering to
295 * IRQ5, just like we normally do. Since this is not a
296 * "normal" return path, we have a do alot of stuff to
297 * the stack to get ready so, we can fall through - we
298 * need to make a CPLB exception look like a normal exception
299 */
300
Bryan Wu1394f032007-05-06 14:50:22 -0700301 RESTORE_ALL_SYS
302 [--sp] = ASTAT;
Mike Frysinger80f31c82008-02-02 15:47:24 +0800303 [--sp] = (R7:6,P5:4);
Bryan Wu1394f032007-05-06 14:50:22 -0700304
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800305ENTRY(_ex_replaceable)
306 nop;
307
Bryan Wu1394f032007-05-06 14:50:22 -0700308ENTRY(_ex_trap_c)
Robin Getz2ebcade2007-10-09 17:24:30 +0800309 /* Make sure we are not in a double fault */
310 p4.l = lo(IPEND);
311 p4.h = hi(IPEND);
312 r7 = [p4];
313 CC = BITTST (r7, 5);
314 if CC jump _double_fault;
315
Bryan Wu1394f032007-05-06 14:50:22 -0700316 /* Call C code (trap_c) to handle the exception, which most
317 * likely involves sending a signal to the current process.
318 * To avoid double faults, lower our priority to IRQ5 first.
319 */
320 P5.h = _exception_to_level5;
321 P5.l = _exception_to_level5;
322 p4.l = lo(EVT5);
323 p4.h = hi(EVT5);
324 [p4] = p5;
325 csync;
326
Robin Getz0c7a6b22008-10-08 16:27:12 +0800327#ifndef CONFIG_DEBUG_DOUBLEFAULT
328 /*
329 * Save these registers, as they are only valid in exception context
330 * (where we are now - as soon as we defer to IRQ5, they can change)
331 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
332 * but they are not very interesting, so don't save them
333 */
334
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800335 p4.l = lo(DCPLB_FAULT_ADDR);
336 p4.h = hi(DCPLB_FAULT_ADDR);
337 r7 = [p4];
338 p5.h = _saved_dcplb_fault_addr;
339 p5.l = _saved_dcplb_fault_addr;
340 [p5] = r7;
341
342 r7 = [p4 + (ICPLB_FAULT_ADDR - DCPLB_FAULT_ADDR)];
343 p5.h = _saved_icplb_fault_addr;
344 p5.l = _saved_icplb_fault_addr;
345 [p5] = r7;
346
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800347 r6 = retx;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800348 p4.l = _saved_retx;
349 p4.h = _saved_retx;
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800350 [p4] = r6;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800351#endif
Bernd Schmidt0893f122008-05-07 11:41:26 +0800352 r6 = SYSCFG;
353 [p4 + 4] = r6;
354 BITCLR(r6, 0);
355 SYSCFG = r6;
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800356
Bryan Wu1394f032007-05-06 14:50:22 -0700357 /* Disable all interrupts, but make sure level 5 is enabled so
358 * we can switch to that level. Save the old mask. */
359 cli r6;
Bernd Schmidt0893f122008-05-07 11:41:26 +0800360 [p4 + 8] = r6;
361
362 p4.l = lo(SAFE_USER_INSTRUCTION);
363 p4.h = hi(SAFE_USER_INSTRUCTION);
364 retx = p4;
365
Bryan Wu1394f032007-05-06 14:50:22 -0700366 r6 = 0x3f;
367 sti r6;
368
Bryan Wu1394f032007-05-06 14:50:22 -0700369 raise 5;
Robin Getz0c7a6b22008-10-08 16:27:12 +0800370 jump.s _bfin_return_from_exception;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800371ENDPROC(_ex_trap_c)
Bryan Wu1394f032007-05-06 14:50:22 -0700372
Robin Getz2ebcade2007-10-09 17:24:30 +0800373/* We just realized we got an exception, while we were processing a different
374 * exception. This is a unrecoverable event, so crash
375 */
376ENTRY(_double_fault)
Robin Getz0c7a6b22008-10-08 16:27:12 +0800377 /* Turn caches & protection off, to ensure we don't get any more
378 * double exceptions
379 */
Robin Getz2ebcade2007-10-09 17:24:30 +0800380
Robin Getz0c7a6b22008-10-08 16:27:12 +0800381 P4.L = LO(IMEM_CONTROL);
382 P4.H = HI(IMEM_CONTROL);
Robin Getz2ebcade2007-10-09 17:24:30 +0800383
Robin Getz0c7a6b22008-10-08 16:27:12 +0800384 R5 = [P4]; /* Control Register*/
385 BITCLR(R5,ENICPLB_P);
386 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
387 .align 8;
388 [P4] = R5;
389 SSYNC;
Robin Getz2ebcade2007-10-09 17:24:30 +0800390
Robin Getz0c7a6b22008-10-08 16:27:12 +0800391 P4.L = LO(DMEM_CONTROL);
392 P4.H = HI(DMEM_CONTROL);
393 R5 = [P4];
394 BITCLR(R5,ENDCPLB_P);
395 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
396 .align 8;
397 [P4] = R5;
398 SSYNC;
Robin Getz2ebcade2007-10-09 17:24:30 +0800399
Robin Getz0c7a6b22008-10-08 16:27:12 +0800400 /* Fix up the stack */
401 (R7:6,P5:4) = [sp++];
402 ASTAT = [sp++];
403 SP = EX_SCRATCH_REG;
Robin Getz2ebcade2007-10-09 17:24:30 +0800404
Robin Getz0c7a6b22008-10-08 16:27:12 +0800405 /* We should be out of the exception stack, and back down into
406 * kernel or user space stack
407 */
408 SAVE_ALL_SYS
Robin Getz2ebcade2007-10-09 17:24:30 +0800409
Bernd Schmidtddb3f002008-05-07 11:41:26 +0800410 /* The dumping functions expect the return address in the RETI
411 * slot. */
412 r6 = retx;
413 [sp + PT_PC] = r6;
414
Robin Getz0c7a6b22008-10-08 16:27:12 +0800415 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
416 SP += -12;
417 call _double_fault_c;
418 SP += 12;
Robin Getz2ebcade2007-10-09 17:24:30 +0800419.L_double_fault_panic:
420 JUMP .L_double_fault_panic
421
422ENDPROC(_double_fault)
423
Bryan Wu1394f032007-05-06 14:50:22 -0700424ENTRY(_exception_to_level5)
425 SAVE_ALL_SYS
426
Robin Getz0c7a6b22008-10-08 16:27:12 +0800427 p4.l = _saved_retx;
428 p4.h = _saved_retx;
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800429 r6 = [p4];
430 [sp + PT_PC] = r6;
431
Bernd Schmidt0893f122008-05-07 11:41:26 +0800432 r6 = [p4 + 4];
433 [sp + PT_SYSCFG] = r6;
434
Bryan Wu1394f032007-05-06 14:50:22 -0700435 /* Restore interrupt mask. We haven't pushed RETI, so this
436 * doesn't enable interrupts until we return from this handler. */
Bernd Schmidt0893f122008-05-07 11:41:26 +0800437 r6 = [p4 + 8];
Bryan Wu1394f032007-05-06 14:50:22 -0700438 sti r6;
439
440 /* Restore the hardware error vector. */
441 P5.h = _evt_ivhw;
442 P5.l = _evt_ivhw;
443 p4.l = lo(EVT5);
444 p4.h = hi(EVT5);
445 [p4] = p5;
446 csync;
447
448 p2.l = lo(IPEND);
449 p2.h = hi(IPEND);
450 csync;
451 r0 = [p2]; /* Read current IPEND */
452 [sp + PT_IPEND] = r0; /* Store IPEND */
453
Bryan Wu1394f032007-05-06 14:50:22 -0700454 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
455 SP += -12;
456 call _trap_c;
457 SP += 12;
458
Robin Getz0c7a6b22008-10-08 16:27:12 +0800459#ifdef CONFIG_DEBUG_DOUBLEFAULT
460 /* Grab ILAT */
461 p2.l = lo(ILAT);
462 p2.h = hi(ILAT);
463 r0 = [p2];
464 r1 = 0x20; /* Did I just cause anther HW error? */
465 r0 = r0 & r1;
466 CC = R0 == R1;
467 if CC JUMP _double_fault;
468#endif
469
Bryan Wu1394f032007-05-06 14:50:22 -0700470 call _ret_from_exception;
471 RESTORE_ALL_SYS
472 rti;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800473ENDPROC(_exception_to_level5)
Bryan Wu1394f032007-05-06 14:50:22 -0700474
475ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
476 /* Since the kernel stack can be anywhere, it's not guaranteed to be
477 * covered by a CPLB. Switch to an exception stack; use RETN as a
478 * scratch register (for want of a better option).
479 */
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800480 EX_SCRATCH_REG = sp;
Bryan Wu1394f032007-05-06 14:50:22 -0700481 sp.l = _exception_stack_top;
482 sp.h = _exception_stack_top;
483 /* Try to deal with syscalls quickly. */
484 [--sp] = ASTAT;
Mike Frysinger80f31c82008-02-02 15:47:24 +0800485 [--sp] = (R7:6,P5:4);
Robin Getz0c7a6b22008-10-08 16:27:12 +0800486
Michael Hennerich5e9e7682008-10-09 12:31:03 +0800487#if ANOMALY_05000283 || ANOMALY_05000315
488 cc = r7 == r7;
489 p5.h = HI(CHIPID);
490 p5.l = LO(CHIPID);
491 if cc jump 1f;
492 r7.l = W[p5];
4931:
494#endif
495
Robin Getz0c7a6b22008-10-08 16:27:12 +0800496#ifdef CONFIG_DEBUG_DOUBLEFAULT
497 /*
498 * Save these registers, as they are only valid in exception context
499 * (where we are now - as soon as we defer to IRQ5, they can change)
500 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
501 * but they are not very interesting, so don't save them
502 */
503
504 p4.l = lo(DCPLB_FAULT_ADDR);
505 p4.h = hi(DCPLB_FAULT_ADDR);
506 r7 = [p4];
507 p5.h = _saved_dcplb_fault_addr;
508 p5.l = _saved_dcplb_fault_addr;
509 [p5] = r7;
510
511 r7 = [p4 + (ICPLB_FAULT_ADDR - DCPLB_FAULT_ADDR)];
512 p5.h = _saved_icplb_fault_addr;
513 p5.l = _saved_icplb_fault_addr;
514 [p5] = r7;
515
516 p4.l = _saved_retx;
517 p4.h = _saved_retx;
518 r6 = retx;
519 [p4] = r6;
520
Bryan Wu1394f032007-05-06 14:50:22 -0700521 r7 = SEQSTAT; /* reason code is in bit 5:0 */
Robin Getz0c7a6b22008-10-08 16:27:12 +0800522 p4.l = _saved_seqstat;
523 p4.h = _saved_seqstat;
524 [p4] = r7;
525#else
526 r7 = SEQSTAT; /* reason code is in bit 5:0 */
527#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700528 r6.l = lo(SEQSTAT_EXCAUSE);
529 r6.h = hi(SEQSTAT_EXCAUSE);
530 r7 = r7 & r6;
Mike Frysinger1ffe6642007-08-05 17:14:04 +0800531 p5.h = _ex_table;
532 p5.l = _ex_table;
Bryan Wu1394f032007-05-06 14:50:22 -0700533 p4 = r7;
534 p5 = p5 + (p4 << 2);
535 p4 = [p5];
536 jump (p4);
537
538.Lbadsys:
539 r7 = -ENOSYS; /* signextending enough */
540 [sp + PT_R0] = r7; /* return value from system call */
541 jump .Lsyscall_really_exit;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800542ENDPROC(_trap)
Bryan Wu1394f032007-05-06 14:50:22 -0700543
544ENTRY(_kernel_execve)
545 link SIZEOF_PTREGS;
546 p0 = sp;
547 r3 = SIZEOF_PTREGS / 4;
548 r4 = 0(x);
5490:
550 [p0++] = r4;
551 r3 += -1;
552 cc = r3 == 0;
553 if !cc jump 0b (bp);
554
555 p0 = sp;
556 sp += -16;
557 [sp + 12] = p0;
558 call _do_execve;
559 SP += 16;
560 cc = r0 == 0;
561 if ! cc jump 1f;
562 /* Success. Copy our temporary pt_regs to the top of the kernel
563 * stack and do a normal exception return.
564 */
565 r1 = sp;
566 r0 = (-KERNEL_STACK_SIZE) (x);
567 r1 = r1 & r0;
568 p2 = r1;
569 p3 = [p2];
570 r0 = KERNEL_STACK_SIZE - 4 (z);
571 p1 = r0;
572 p1 = p1 + p2;
573
574 p0 = fp;
575 r4 = [p0--];
576 r3 = SIZEOF_PTREGS / 4;
5770:
578 r4 = [p0--];
579 [p1--] = r4;
580 r3 += -1;
581 cc = r3 == 0;
582 if ! cc jump 0b (bp);
583
584 r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
585 p1 = r0;
586 p1 = p1 + p2;
587 sp = p1;
588 r0 = syscfg;
589 [SP + PT_SYSCFG] = r0;
590 [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
591
592 RESTORE_CONTEXT;
593 rti;
5941:
595 unlink;
596 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800597ENDPROC(_kernel_execve)
Bryan Wu1394f032007-05-06 14:50:22 -0700598
599ENTRY(_system_call)
600 /* Store IPEND */
601 p2.l = lo(IPEND);
602 p2.h = hi(IPEND);
603 csync;
604 r0 = [p2];
605 [sp + PT_IPEND] = r0;
606
607 /* Store RETS for now */
608 r0 = rets;
609 [sp + PT_RESERVED] = r0;
610 /* Set the stack for the current process */
611 r7 = sp;
612 r6.l = lo(ALIGN_PAGE_MASK);
613 r6.h = hi(ALIGN_PAGE_MASK);
614 r7 = r7 & r6; /* thread_info */
615 p2 = r7;
616 p2 = [p2];
617
618 [p2+(TASK_THREAD+THREAD_KSP)] = sp;
619
620 /* Check the System Call */
621 r7 = __NR_syscall;
622 /* System call number is passed in P0 */
623 r6 = p0;
624 cc = r6 < r7;
625 if ! cc jump .Lbadsys;
626
627 /* are we tracing syscalls?*/
628 r7 = sp;
629 r6.l = lo(ALIGN_PAGE_MASK);
630 r6.h = hi(ALIGN_PAGE_MASK);
631 r7 = r7 & r6;
632 p2 = r7;
633 r7 = [p2+TI_FLAGS];
634 CC = BITTST(r7,TIF_SYSCALL_TRACE);
635 if CC JUMP _sys_trace;
636
637 /* Execute the appropriate system call */
638
639 p4 = p0;
640 p5.l = _sys_call_table;
641 p5.h = _sys_call_table;
642 p5 = p5 + (p4 << 2);
643 r0 = [sp + PT_R0];
644 r1 = [sp + PT_R1];
645 r2 = [sp + PT_R2];
646 p5 = [p5];
647
648 [--sp] = r5;
649 [--sp] = r4;
650 [--sp] = r3;
651 SP += -12;
652 call (p5);
653 SP += 24;
654 [sp + PT_R0] = r0;
655
656.Lresume_userspace:
657 r7 = sp;
658 r4.l = lo(ALIGN_PAGE_MASK);
659 r4.h = hi(ALIGN_PAGE_MASK);
660 r7 = r7 & r4; /* thread_info->flags */
661 p5 = r7;
662.Lresume_userspace_1:
663 /* Disable interrupts. */
664 [--sp] = reti;
665 reti = [sp++];
666
667 r7 = [p5 + TI_FLAGS];
668 r4.l = lo(_TIF_WORK_MASK);
669 r4.h = hi(_TIF_WORK_MASK);
670 r7 = r7 & r4;
671
672.Lsyscall_resched:
673 cc = BITTST(r7, TIF_NEED_RESCHED);
674 if !cc jump .Lsyscall_sigpending;
675
676 /* Reenable interrupts. */
677 [--sp] = reti;
678 r0 = [sp++];
679
680 SP += -12;
681 call _schedule;
682 SP += 12;
683
684 jump .Lresume_userspace_1;
685
686.Lsyscall_sigpending:
687 cc = BITTST(r7, TIF_RESTORE_SIGMASK);
688 if cc jump .Lsyscall_do_signals;
689 cc = BITTST(r7, TIF_SIGPENDING);
690 if !cc jump .Lsyscall_really_exit;
691.Lsyscall_do_signals:
692 /* Reenable interrupts. */
693 [--sp] = reti;
694 r0 = [sp++];
695
696 r0 = sp;
697 SP += -12;
698 call _do_signal;
699 SP += 12;
700
701.Lsyscall_really_exit:
702 r5 = [sp + PT_RESERVED];
703 rets = r5;
704 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800705ENDPROC(_system_call)
Bryan Wu1394f032007-05-06 14:50:22 -0700706
707_sys_trace:
708 call _syscall_trace;
709
710 /* Execute the appropriate system call */
711
712 p4 = [SP + PT_P0];
713 p5.l = _sys_call_table;
714 p5.h = _sys_call_table;
715 p5 = p5 + (p4 << 2);
716 r0 = [sp + PT_R0];
717 r1 = [sp + PT_R1];
718 r2 = [sp + PT_R2];
719 r3 = [sp + PT_R3];
720 r4 = [sp + PT_R4];
721 r5 = [sp + PT_R5];
722 p5 = [p5];
723
724 [--sp] = r5;
725 [--sp] = r4;
726 [--sp] = r3;
727 SP += -12;
728 call (p5);
729 SP += 24;
730 [sp + PT_R0] = r0;
731
732 call _syscall_trace;
733 jump .Lresume_userspace;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800734ENDPROC(_sys_trace)
Bryan Wu1394f032007-05-06 14:50:22 -0700735
736ENTRY(_resume)
737 /*
738 * Beware - when entering resume, prev (the current task) is
739 * in r0, next (the new task) is in r1.
740 */
741 p0 = r0;
742 p1 = r1;
743 [--sp] = rets;
744 [--sp] = fp;
745 [--sp] = (r7:4, p5:3);
746
747 /* save usp */
748 p2 = usp;
749 [p0+(TASK_THREAD+THREAD_USP)] = p2;
750
751 /* save current kernel stack pointer */
752 [p0+(TASK_THREAD+THREAD_KSP)] = sp;
753
754 /* save program counter */
755 r1.l = _new_old_task;
756 r1.h = _new_old_task;
757 [p0+(TASK_THREAD+THREAD_PC)] = r1;
758
759 /* restore the kernel stack pointer */
760 sp = [p1+(TASK_THREAD+THREAD_KSP)];
761
762 /* restore user stack pointer */
763 p0 = [p1+(TASK_THREAD+THREAD_USP)];
764 usp = p0;
765
766 /* restore pc */
767 p0 = [p1+(TASK_THREAD+THREAD_PC)];
768 jump (p0);
769
770 /*
771 * Following code actually lands up in a new (old) task.
772 */
773
774_new_old_task:
775 (r7:4, p5:3) = [sp++];
776 fp = [sp++];
777 rets = [sp++];
778
779 /*
780 * When we come out of resume, r0 carries "old" task, becuase we are
781 * in "new" task.
782 */
783 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800784ENDPROC(_resume)
Bryan Wu1394f032007-05-06 14:50:22 -0700785
786ENTRY(_ret_from_exception)
787 p2.l = lo(IPEND);
788 p2.h = hi(IPEND);
789
790 csync;
791 r0 = [p2];
792 [sp + PT_IPEND] = r0;
793
7941:
Robin Getzd5c4b5e2007-12-21 17:49:53 +0800795 r2 = LO(~0x37) (Z);
Bryan Wu1394f032007-05-06 14:50:22 -0700796 r0 = r2 & r0;
797 cc = r0 == 0;
798 if !cc jump 4f; /* if not return to user mode, get out */
799
800 /* Make sure any pending system call or deferred exception
801 * return in ILAT for this process to get executed, otherwise
802 * in case context switch happens, system call of
803 * first process (i.e in ILAT) will be carried
804 * forward to the switched process
805 */
806
807 p2.l = lo(ILAT);
808 p2.h = hi(ILAT);
809 r0 = [p2];
810 r1 = (EVT_IVG14 | EVT_IVG15) (z);
811 r0 = r0 & r1;
812 cc = r0 == 0;
813 if !cc jump 5f;
814
815 /* Set the stack for the current process */
816 r7 = sp;
817 r4.l = lo(ALIGN_PAGE_MASK);
818 r4.h = hi(ALIGN_PAGE_MASK);
819 r7 = r7 & r4; /* thread_info->flags */
820 p5 = r7;
821 r7 = [p5 + TI_FLAGS];
822 r4.l = lo(_TIF_WORK_MASK);
823 r4.h = hi(_TIF_WORK_MASK);
824 r7 = r7 & r4;
825 cc = r7 == 0;
826 if cc jump 4f;
827
828 p0.l = lo(EVT15);
829 p0.h = hi(EVT15);
830 p1.l = _schedule_and_signal;
831 p1.h = _schedule_and_signal;
832 [p0] = p1;
833 csync;
834 raise 15; /* raise evt14 to do signal or reschedule */
8354:
836 r0 = syscfg;
837 bitclr(r0, 0);
838 syscfg = r0;
8395:
840 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800841ENDPROC(_ret_from_exception)
Bryan Wu1394f032007-05-06 14:50:22 -0700842
843ENTRY(_return_from_int)
844 /* If someone else already raised IRQ 15, do nothing. */
845 csync;
846 p2.l = lo(ILAT);
847 p2.h = hi(ILAT);
848 r0 = [p2];
849 cc = bittst (r0, EVT_IVG15_P);
850 if cc jump 2f;
851
852 /* if not return to user mode, get out */
853 p2.l = lo(IPEND);
854 p2.h = hi(IPEND);
855 r0 = [p2];
856 r1 = 0x17(Z);
857 r2 = ~r1;
858 r2.h = 0;
859 r0 = r2 & r0;
860 r1 = 1;
861 r1 = r0 - r1;
862 r2 = r0 & r1;
863 cc = r2 == 0;
864 if !cc jump 2f;
865
866 /* Lower the interrupt level to 15. */
867 p0.l = lo(EVT15);
868 p0.h = hi(EVT15);
869 p1.l = _schedule_and_signal_from_int;
870 p1.h = _schedule_and_signal_from_int;
871 [p0] = p1;
872 csync;
Mike Frysinger1aafd902007-07-25 11:19:14 +0800873#if ANOMALY_05000281
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800874 r0.l = lo(SAFE_USER_INSTRUCTION);
875 r0.h = hi(SAFE_USER_INSTRUCTION);
Bryan Wu1394f032007-05-06 14:50:22 -0700876 reti = r0;
877#endif
878 r0 = 0x801f (z);
879 STI r0;
880 raise 15; /* raise evt15 to do signal or reschedule */
881 rti;
8822:
883 rts;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800884ENDPROC(_return_from_int)
Bryan Wu1394f032007-05-06 14:50:22 -0700885
886ENTRY(_lower_to_irq14)
Mike Frysinger1aafd902007-07-25 11:19:14 +0800887#if ANOMALY_05000281
Bernd Schmidt5d750b92008-04-25 05:02:33 +0800888 r0.l = lo(SAFE_USER_INSTRUCTION);
889 r0.h = hi(SAFE_USER_INSTRUCTION);
Bryan Wu1394f032007-05-06 14:50:22 -0700890 reti = r0;
891#endif
892 r0 = 0x401f;
893 sti r0;
894 raise 14;
895 rti;
896ENTRY(_evt14_softirq)
897#ifdef CONFIG_DEBUG_HWERR
898 r0 = 0x3f;
899 sti r0;
900#else
901 cli r0;
902#endif
903 [--sp] = RETI;
904 SP += 4;
905 rts;
906
907_schedule_and_signal_from_int:
908 /* To end up here, vector 15 was changed - so we have to change it
909 * back.
910 */
911 p0.l = lo(EVT15);
912 p0.h = hi(EVT15);
913 p1.l = _evt_system_call;
914 p1.h = _evt_system_call;
915 [p0] = p1;
916 csync;
Bernd Schmidtc8244982007-05-21 18:09:33 +0800917
918 /* Set orig_p0 to -1 to indicate this isn't the end of a syscall. */
919 r0 = -1 (x);
920 [sp + PT_ORIG_P0] = r0;
921
Bryan Wu1394f032007-05-06 14:50:22 -0700922 p1 = rets;
923 [sp + PT_RESERVED] = p1;
924
925 p0.l = _irq_flags;
926 p0.h = _irq_flags;
927 r0 = [p0];
928 sti r0;
929
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800930 r0 = sp;
931 sp += -12;
932 call _finish_atomic_sections;
933 sp += 12;
Bryan Wu1394f032007-05-06 14:50:22 -0700934 jump.s .Lresume_userspace;
935
936_schedule_and_signal:
937 SAVE_CONTEXT_SYSCALL
938 /* To end up here, vector 15 was changed - so we have to change it
939 * back.
940 */
941 p0.l = lo(EVT15);
942 p0.h = hi(EVT15);
943 p1.l = _evt_system_call;
944 p1.h = _evt_system_call;
945 [p0] = p1;
946 csync;
947 p0.l = 1f;
948 p0.h = 1f;
949 [sp + PT_RESERVED] = P0;
950 call .Lresume_userspace;
9511:
952 RESTORE_CONTEXT
953 rti;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800954ENDPROC(_lower_to_irq14)
Bryan Wu1394f032007-05-06 14:50:22 -0700955
Robin Getz518039b2007-07-25 11:03:28 +0800956/* We handle this 100% in exception space - to reduce overhead
957 * Only potiential problem is if the software buffer gets swapped out of the
958 * CPLB table - then double fault. - so we don't let this happen in other places
959 */
960#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
961ENTRY(_ex_trace_buff_full)
962 [--sp] = P3;
963 [--sp] = P2;
964 [--sp] = LC0;
965 [--sp] = LT0;
966 [--sp] = LB0;
967 P5.L = _trace_buff_offset;
968 P5.H = _trace_buff_offset;
969 P3 = [P5]; /* trace_buff_offset */
970 P5.L = lo(TBUFSTAT);
971 P5.H = hi(TBUFSTAT);
972 R7 = [P5];
973 R7 <<= 1; /* double, since we need to read twice */
974 LC0 = R7;
975 R7 <<= 2; /* need to shift over again,
976 * to get the number of bytes */
977 P5.L = lo(TBUF);
978 P5.H = hi(TBUF);
979 R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
980
981 P2 = R7;
982 P3 = P3 + P2;
983 R7 = P3;
984 R7 = R7 & R6;
985 P3 = R7;
986 P2.L = _trace_buff_offset;
987 P2.H = _trace_buff_offset;
988 [P2] = P3;
989
990 P2.L = _software_trace_buff;
991 P2.H = _software_trace_buff;
992
993 LSETUP (.Lstart, .Lend) LC0;
994.Lstart:
995 R7 = [P5]; /* read TBUF */
996 P4 = P3 + P2;
997 [P4] = R7;
998 P3 += -4;
999 R7 = P3;
1000 R7 = R7 & R6;
1001.Lend:
1002 P3 = R7;
1003
1004 LB0 = [sp++];
1005 LT0 = [sp++];
1006 LC0 = [sp++];
1007 P2 = [sp++];
1008 P3 = [sp++];
Mike Frysinger8d6c2422007-11-21 15:53:49 +08001009 jump _bfin_return_from_exception;
Robin Getz337d3902007-10-09 17:31:46 +08001010ENDPROC(_ex_trace_buff_full)
Robin Getz518039b2007-07-25 11:03:28 +08001011
1012#if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
1013.data
1014#else
1015.section .l1.data.B
Robin Getz337d3902007-10-09 17:31:46 +08001016#endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
Robin Getz518039b2007-07-25 11:03:28 +08001017ENTRY(_trace_buff_offset)
1018 .long 0;
1019ALIGN
1020ENTRY(_software_trace_buff)
1021 .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
1022 .long 0
1023 .endr
Robin Getz337d3902007-10-09 17:31:46 +08001024#endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
1025
1026#if CONFIG_EARLY_PRINTK
Mike Frysinger9cb07b22007-11-21 16:45:08 +08001027__INIT
Robin Getz337d3902007-10-09 17:31:46 +08001028ENTRY(_early_trap)
1029 SAVE_ALL_SYS
1030 trace_buffer_stop(p0,r0);
1031
Michael Hennerich5e9e7682008-10-09 12:31:03 +08001032#if ANOMALY_05000283 || ANOMALY_05000315
1033 cc = r5 == r5;
1034 p4.h = HI(CHIPID);
1035 p4.l = LO(CHIPID);
1036 if cc jump 1f;
1037 r5.l = W[p4];
10381:
1039#endif
1040
Robin Getz337d3902007-10-09 17:31:46 +08001041 /* Turn caches off, to ensure we don't get double exceptions */
1042
1043 P4.L = LO(IMEM_CONTROL);
1044 P4.H = HI(IMEM_CONTROL);
1045
1046 R5 = [P4]; /* Control Register*/
1047 BITCLR(R5,ENICPLB_P);
1048 CLI R1;
1049 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
1050 .align 8;
1051 [P4] = R5;
1052 SSYNC;
1053
1054 P4.L = LO(DMEM_CONTROL);
1055 P4.H = HI(DMEM_CONTROL);
1056 R5 = [P4];
1057 BITCLR(R5,ENDCPLB_P);
1058 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
1059 .align 8;
1060 [P4] = R5;
1061 SSYNC;
1062 STI R1;
1063
1064 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
1065 r1 = RETX;
1066
1067 SP += -12;
1068 call _early_trap_c;
1069 SP += 12;
1070ENDPROC(_early_trap)
Mike Frysinger9cb07b22007-11-21 16:45:08 +08001071__FINIT
Robin Getz337d3902007-10-09 17:31:46 +08001072#endif /* CONFIG_EARLY_PRINTK */
Robin Getz518039b2007-07-25 11:03:28 +08001073
Bryan Wu1394f032007-05-06 14:50:22 -07001074/*
1075 * Put these in the kernel data section - that should always be covered by
1076 * a CPLB. This is needed to ensure we don't get double fault conditions
1077 */
1078
1079#ifdef CONFIG_SYSCALL_TAB_L1
1080.section .l1.data
1081#else
1082.data
1083#endif
Robin Getzf26fbc42007-11-12 22:21:30 +08001084
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001085ENTRY(_ex_table)
Bryan Wu1394f032007-05-06 14:50:22 -07001086 /* entry for each EXCAUSE[5:0]
Mike Frysinger9401e612007-07-12 11:50:43 +08001087 * This table must be in sync with the table in ./kernel/traps.c
Bryan Wu1394f032007-05-06 14:50:22 -07001088 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
1089 */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001090 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
Bryan Wu1394f032007-05-06 14:50:22 -07001091 .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */
Sonic Zhanga5ac0122008-10-13 14:07:19 +08001092#ifdef CONFIG_KGDB
1093 .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection
1094 and break signal trap */
1095#else
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001096 .long _ex_replaceable /* 0x02 - User Defined */
Sonic Zhanga5ac0122008-10-13 14:07:19 +08001097#endif
Mike Frysinger9401e612007-07-12 11:50:43 +08001098 .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
Robin Getz9f336a52007-10-29 18:23:28 +08001099 .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001100 .long _ex_replaceable /* 0x05 - User Defined */
1101 .long _ex_replaceable /* 0x06 - User Defined */
1102 .long _ex_replaceable /* 0x07 - User Defined */
1103 .long _ex_replaceable /* 0x08 - User Defined */
1104 .long _ex_replaceable /* 0x09 - User Defined */
1105 .long _ex_replaceable /* 0x0A - User Defined */
1106 .long _ex_replaceable /* 0x0B - User Defined */
1107 .long _ex_replaceable /* 0x0C - User Defined */
1108 .long _ex_replaceable /* 0x0D - User Defined */
1109 .long _ex_replaceable /* 0x0E - User Defined */
1110 .long _ex_replaceable /* 0x0F - User Defined */
Bryan Wu1394f032007-05-06 14:50:22 -07001111 .long _ex_single_step /* 0x10 - HW Single step */
Robin Getz518039b2007-07-25 11:03:28 +08001112#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1113 .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
1114#else
Bryan Wu1394f032007-05-06 14:50:22 -07001115 .long _ex_trap_c /* 0x11 - Trace Buffer Full */
Robin Getz518039b2007-07-25 11:03:28 +08001116#endif
Bryan Wu1394f032007-05-06 14:50:22 -07001117 .long _ex_trap_c /* 0x12 - Reserved */
1118 .long _ex_trap_c /* 0x13 - Reserved */
1119 .long _ex_trap_c /* 0x14 - Reserved */
1120 .long _ex_trap_c /* 0x15 - Reserved */
1121 .long _ex_trap_c /* 0x16 - Reserved */
1122 .long _ex_trap_c /* 0x17 - Reserved */
1123 .long _ex_trap_c /* 0x18 - Reserved */
1124 .long _ex_trap_c /* 0x19 - Reserved */
1125 .long _ex_trap_c /* 0x1A - Reserved */
1126 .long _ex_trap_c /* 0x1B - Reserved */
1127 .long _ex_trap_c /* 0x1C - Reserved */
1128 .long _ex_trap_c /* 0x1D - Reserved */
1129 .long _ex_trap_c /* 0x1E - Reserved */
1130 .long _ex_trap_c /* 0x1F - Reserved */
1131 .long _ex_trap_c /* 0x20 - Reserved */
1132 .long _ex_trap_c /* 0x21 - Undefined Instruction */
1133 .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
Robin Getzf26fbc42007-11-12 22:21:30 +08001134 .long _ex_dviol /* 0x23 - Data CPLB Protection Violation */
Bryan Wu1394f032007-05-06 14:50:22 -07001135 .long _ex_trap_c /* 0x24 - Data access misaligned */
1136 .long _ex_trap_c /* 0x25 - Unrecoverable Event */
Robin Getzf26fbc42007-11-12 22:21:30 +08001137 .long _ex_dmiss /* 0x26 - Data CPLB Miss */
1138 .long _ex_dmult /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
Bryan Wu1394f032007-05-06 14:50:22 -07001139 .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
1140 .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
1141 .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
Robin Getzf26fbc42007-11-12 22:21:30 +08001142 .long _ex_trap_c /* 0x2B - Instruction CPLB protection Violation */
1143 .long _ex_icplb_miss /* 0x2C - Instruction CPLB miss */
Bryan Wu1394f032007-05-06 14:50:22 -07001144 .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
1145 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1146 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1147 .long _ex_trap_c /* 0x2F - Reserved */
1148 .long _ex_trap_c /* 0x30 - Reserved */
1149 .long _ex_trap_c /* 0x31 - Reserved */
1150 .long _ex_trap_c /* 0x32 - Reserved */
1151 .long _ex_trap_c /* 0x33 - Reserved */
1152 .long _ex_trap_c /* 0x34 - Reserved */
1153 .long _ex_trap_c /* 0x35 - Reserved */
1154 .long _ex_trap_c /* 0x36 - Reserved */
1155 .long _ex_trap_c /* 0x37 - Reserved */
1156 .long _ex_trap_c /* 0x38 - Reserved */
1157 .long _ex_trap_c /* 0x39 - Reserved */
1158 .long _ex_trap_c /* 0x3A - Reserved */
1159 .long _ex_trap_c /* 0x3B - Reserved */
1160 .long _ex_trap_c /* 0x3C - Reserved */
1161 .long _ex_trap_c /* 0x3D - Reserved */
1162 .long _ex_trap_c /* 0x3E - Reserved */
1163 .long _ex_trap_c /* 0x3F - Reserved */
Mike Frysinger1ffe6642007-08-05 17:14:04 +08001164END(_ex_table)
Bryan Wu1394f032007-05-06 14:50:22 -07001165
Bryan Wu1394f032007-05-06 14:50:22 -07001166ENTRY(_sys_call_table)
Bryan Wu0b95f222007-09-23 00:51:32 +08001167 .long _sys_restart_syscall /* 0 */
Bryan Wu1394f032007-05-06 14:50:22 -07001168 .long _sys_exit
1169 .long _sys_fork
1170 .long _sys_read
1171 .long _sys_write
1172 .long _sys_open /* 5 */
1173 .long _sys_close
1174 .long _sys_ni_syscall /* old waitpid */
1175 .long _sys_creat
1176 .long _sys_link
1177 .long _sys_unlink /* 10 */
1178 .long _sys_execve
1179 .long _sys_chdir
1180 .long _sys_time
1181 .long _sys_mknod
1182 .long _sys_chmod /* 15 */
1183 .long _sys_chown /* chown16 */
1184 .long _sys_ni_syscall /* old break syscall holder */
1185 .long _sys_ni_syscall /* old stat */
1186 .long _sys_lseek
1187 .long _sys_getpid /* 20 */
1188 .long _sys_mount
1189 .long _sys_ni_syscall /* old umount */
1190 .long _sys_setuid
1191 .long _sys_getuid
1192 .long _sys_stime /* 25 */
1193 .long _sys_ptrace
1194 .long _sys_alarm
1195 .long _sys_ni_syscall /* old fstat */
1196 .long _sys_pause
1197 .long _sys_ni_syscall /* old utime */ /* 30 */
1198 .long _sys_ni_syscall /* old stty syscall holder */
1199 .long _sys_ni_syscall /* old gtty syscall holder */
1200 .long _sys_access
1201 .long _sys_nice
1202 .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1203 .long _sys_sync
1204 .long _sys_kill
1205 .long _sys_rename
1206 .long _sys_mkdir
1207 .long _sys_rmdir /* 40 */
1208 .long _sys_dup
1209 .long _sys_pipe
1210 .long _sys_times
1211 .long _sys_ni_syscall /* old prof syscall holder */
1212 .long _sys_brk /* 45 */
1213 .long _sys_setgid
1214 .long _sys_getgid
1215 .long _sys_ni_syscall /* old sys_signal */
1216 .long _sys_geteuid /* geteuid16 */
1217 .long _sys_getegid /* getegid16 */ /* 50 */
1218 .long _sys_acct
1219 .long _sys_umount /* recycled never used phys() */
1220 .long _sys_ni_syscall /* old lock syscall holder */
1221 .long _sys_ioctl
1222 .long _sys_fcntl /* 55 */
1223 .long _sys_ni_syscall /* old mpx syscall holder */
1224 .long _sys_setpgid
1225 .long _sys_ni_syscall /* old ulimit syscall holder */
1226 .long _sys_ni_syscall /* old old uname */
1227 .long _sys_umask /* 60 */
1228 .long _sys_chroot
1229 .long _sys_ustat
1230 .long _sys_dup2
1231 .long _sys_getppid
1232 .long _sys_getpgrp /* 65 */
1233 .long _sys_setsid
1234 .long _sys_ni_syscall /* old sys_sigaction */
1235 .long _sys_sgetmask
1236 .long _sys_ssetmask
1237 .long _sys_setreuid /* setreuid16 */ /* 70 */
1238 .long _sys_setregid /* setregid16 */
1239 .long _sys_ni_syscall /* old sys_sigsuspend */
1240 .long _sys_ni_syscall /* old sys_sigpending */
1241 .long _sys_sethostname
1242 .long _sys_setrlimit /* 75 */
1243 .long _sys_ni_syscall /* old getrlimit */
1244 .long _sys_getrusage
1245 .long _sys_gettimeofday
1246 .long _sys_settimeofday
1247 .long _sys_getgroups /* getgroups16 */ /* 80 */
1248 .long _sys_setgroups /* setgroups16 */
1249 .long _sys_ni_syscall /* old_select */
1250 .long _sys_symlink
1251 .long _sys_ni_syscall /* old lstat */
1252 .long _sys_readlink /* 85 */
1253 .long _sys_uselib
1254 .long _sys_ni_syscall /* sys_swapon */
1255 .long _sys_reboot
1256 .long _sys_ni_syscall /* old_readdir */
1257 .long _sys_ni_syscall /* sys_mmap */ /* 90 */
1258 .long _sys_munmap
1259 .long _sys_truncate
1260 .long _sys_ftruncate
1261 .long _sys_fchmod
1262 .long _sys_fchown /* fchown16 */ /* 95 */
1263 .long _sys_getpriority
1264 .long _sys_setpriority
1265 .long _sys_ni_syscall /* old profil syscall holder */
1266 .long _sys_statfs
1267 .long _sys_fstatfs /* 100 */
1268 .long _sys_ni_syscall
1269 .long _sys_ni_syscall /* old sys_socketcall */
1270 .long _sys_syslog
1271 .long _sys_setitimer
1272 .long _sys_getitimer /* 105 */
1273 .long _sys_newstat
1274 .long _sys_newlstat
1275 .long _sys_newfstat
1276 .long _sys_ni_syscall /* old uname */
1277 .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
1278 .long _sys_vhangup
1279 .long _sys_ni_syscall /* obsolete idle() syscall */
1280 .long _sys_ni_syscall /* vm86old for i386 */
1281 .long _sys_wait4
1282 .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
1283 .long _sys_sysinfo
1284 .long _sys_ni_syscall /* old sys_ipc */
1285 .long _sys_fsync
1286 .long _sys_ni_syscall /* old sys_sigreturn */
1287 .long _sys_clone /* 120 */
1288 .long _sys_setdomainname
1289 .long _sys_newuname
1290 .long _sys_ni_syscall /* old sys_modify_ldt */
1291 .long _sys_adjtimex
1292 .long _sys_ni_syscall /* 125 */ /* sys_mprotect */
1293 .long _sys_ni_syscall /* old sys_sigprocmask */
1294 .long _sys_ni_syscall /* old "creat_module" */
1295 .long _sys_init_module
1296 .long _sys_delete_module
1297 .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
1298 .long _sys_quotactl
1299 .long _sys_getpgid
1300 .long _sys_fchdir
1301 .long _sys_bdflush
1302 .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
1303 .long _sys_personality
1304 .long _sys_ni_syscall /* for afs_syscall */
1305 .long _sys_setfsuid /* setfsuid16 */
1306 .long _sys_setfsgid /* setfsgid16 */
1307 .long _sys_llseek /* 140 */
1308 .long _sys_getdents
1309 .long _sys_ni_syscall /* sys_select */
1310 .long _sys_flock
1311 .long _sys_ni_syscall /* sys_msync */
1312 .long _sys_readv /* 145 */
1313 .long _sys_writev
1314 .long _sys_getsid
1315 .long _sys_fdatasync
1316 .long _sys_sysctl
1317 .long _sys_ni_syscall /* 150 */ /* sys_mlock */
1318 .long _sys_ni_syscall /* sys_munlock */
1319 .long _sys_ni_syscall /* sys_mlockall */
1320 .long _sys_ni_syscall /* sys_munlockall */
1321 .long _sys_sched_setparam
1322 .long _sys_sched_getparam /* 155 */
1323 .long _sys_sched_setscheduler
1324 .long _sys_sched_getscheduler
1325 .long _sys_sched_yield
1326 .long _sys_sched_get_priority_max
1327 .long _sys_sched_get_priority_min /* 160 */
1328 .long _sys_sched_rr_get_interval
1329 .long _sys_nanosleep
Bryan Wu0b95f222007-09-23 00:51:32 +08001330 .long _sys_mremap
Bryan Wu1394f032007-05-06 14:50:22 -07001331 .long _sys_setresuid /* setresuid16 */
1332 .long _sys_getresuid /* getresuid16 */ /* 165 */
1333 .long _sys_ni_syscall /* for vm86 */
1334 .long _sys_ni_syscall /* old "query_module" */
1335 .long _sys_ni_syscall /* sys_poll */
Bryan Wu0b95f222007-09-23 00:51:32 +08001336 .long _sys_nfsservctl
Bryan Wu1394f032007-05-06 14:50:22 -07001337 .long _sys_setresgid /* setresgid16 */ /* 170 */
1338 .long _sys_getresgid /* getresgid16 */
1339 .long _sys_prctl
1340 .long _sys_rt_sigreturn
1341 .long _sys_rt_sigaction
1342 .long _sys_rt_sigprocmask /* 175 */
1343 .long _sys_rt_sigpending
1344 .long _sys_rt_sigtimedwait
1345 .long _sys_rt_sigqueueinfo
1346 .long _sys_rt_sigsuspend
1347 .long _sys_pread64 /* 180 */
1348 .long _sys_pwrite64
1349 .long _sys_lchown /* lchown16 */
1350 .long _sys_getcwd
1351 .long _sys_capget
1352 .long _sys_capset /* 185 */
1353 .long _sys_sigaltstack
1354 .long _sys_sendfile
1355 .long _sys_ni_syscall /* streams1 */
1356 .long _sys_ni_syscall /* streams2 */
1357 .long _sys_vfork /* 190 */
1358 .long _sys_getrlimit
1359 .long _sys_mmap2
1360 .long _sys_truncate64
1361 .long _sys_ftruncate64
1362 .long _sys_stat64 /* 195 */
1363 .long _sys_lstat64
1364 .long _sys_fstat64
1365 .long _sys_chown
1366 .long _sys_getuid
1367 .long _sys_getgid /* 200 */
1368 .long _sys_geteuid
1369 .long _sys_getegid
1370 .long _sys_setreuid
1371 .long _sys_setregid
1372 .long _sys_getgroups /* 205 */
1373 .long _sys_setgroups
1374 .long _sys_fchown
1375 .long _sys_setresuid
1376 .long _sys_getresuid
1377 .long _sys_setresgid /* 210 */
1378 .long _sys_getresgid
1379 .long _sys_lchown
1380 .long _sys_setuid
1381 .long _sys_setgid
1382 .long _sys_setfsuid /* 215 */
1383 .long _sys_setfsgid
1384 .long _sys_pivot_root
1385 .long _sys_ni_syscall /* sys_mincore */
1386 .long _sys_ni_syscall /* sys_madvise */
1387 .long _sys_getdents64 /* 220 */
1388 .long _sys_fcntl64
1389 .long _sys_ni_syscall /* reserved for TUX */
1390 .long _sys_ni_syscall
1391 .long _sys_gettid
Bryan Wu0b95f222007-09-23 00:51:32 +08001392 .long _sys_readahead /* 225 */
Bryan Wu1394f032007-05-06 14:50:22 -07001393 .long _sys_setxattr
1394 .long _sys_lsetxattr
1395 .long _sys_fsetxattr
1396 .long _sys_getxattr
1397 .long _sys_lgetxattr /* 230 */
1398 .long _sys_fgetxattr
1399 .long _sys_listxattr
1400 .long _sys_llistxattr
1401 .long _sys_flistxattr
1402 .long _sys_removexattr /* 235 */
1403 .long _sys_lremovexattr
1404 .long _sys_fremovexattr
1405 .long _sys_tkill
1406 .long _sys_sendfile64
1407 .long _sys_futex /* 240 */
1408 .long _sys_sched_setaffinity
1409 .long _sys_sched_getaffinity
1410 .long _sys_ni_syscall /* sys_set_thread_area */
1411 .long _sys_ni_syscall /* sys_get_thread_area */
1412 .long _sys_io_setup /* 245 */
1413 .long _sys_io_destroy
1414 .long _sys_io_getevents
1415 .long _sys_io_submit
1416 .long _sys_io_cancel
1417 .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
1418 .long _sys_ni_syscall /* sys_freec_hugepages */
1419 .long _sys_exit_group
1420 .long _sys_lookup_dcookie
1421 .long _sys_bfin_spinlock
1422 .long _sys_epoll_create /* 255 */
1423 .long _sys_epoll_ctl
1424 .long _sys_epoll_wait
1425 .long _sys_ni_syscall /* remap_file_pages */
1426 .long _sys_set_tid_address
1427 .long _sys_timer_create /* 260 */
1428 .long _sys_timer_settime
1429 .long _sys_timer_gettime
1430 .long _sys_timer_getoverrun
1431 .long _sys_timer_delete
1432 .long _sys_clock_settime /* 265 */
1433 .long _sys_clock_gettime
1434 .long _sys_clock_getres
1435 .long _sys_clock_nanosleep
1436 .long _sys_statfs64
1437 .long _sys_fstatfs64 /* 270 */
1438 .long _sys_tgkill
1439 .long _sys_utimes
1440 .long _sys_fadvise64_64
1441 .long _sys_ni_syscall /* vserver */
1442 .long _sys_ni_syscall /* 275, mbind */
1443 .long _sys_ni_syscall /* get_mempolicy */
1444 .long _sys_ni_syscall /* set_mempolicy */
1445 .long _sys_mq_open
1446 .long _sys_mq_unlink
1447 .long _sys_mq_timedsend /* 280 */
1448 .long _sys_mq_timedreceive
1449 .long _sys_mq_notify
1450 .long _sys_mq_getsetattr
1451 .long _sys_ni_syscall /* kexec_load */
1452 .long _sys_waitid /* 285 */
1453 .long _sys_add_key
1454 .long _sys_request_key
1455 .long _sys_keyctl
1456 .long _sys_ioprio_set
1457 .long _sys_ioprio_get /* 290 */
1458 .long _sys_inotify_init
1459 .long _sys_inotify_add_watch
1460 .long _sys_inotify_rm_watch
1461 .long _sys_ni_syscall /* migrate_pages */
1462 .long _sys_openat /* 295 */
1463 .long _sys_mkdirat
1464 .long _sys_mknodat
1465 .long _sys_fchownat
1466 .long _sys_futimesat
1467 .long _sys_fstatat64 /* 300 */
1468 .long _sys_unlinkat
1469 .long _sys_renameat
1470 .long _sys_linkat
1471 .long _sys_symlinkat
1472 .long _sys_readlinkat /* 305 */
1473 .long _sys_fchmodat
1474 .long _sys_faccessat
1475 .long _sys_pselect6
1476 .long _sys_ppoll
1477 .long _sys_unshare /* 310 */
1478 .long _sys_sram_alloc
1479 .long _sys_sram_free
1480 .long _sys_dma_memcpy
1481 .long _sys_accept
1482 .long _sys_bind /* 315 */
1483 .long _sys_connect
1484 .long _sys_getpeername
1485 .long _sys_getsockname
1486 .long _sys_getsockopt
1487 .long _sys_listen /* 320 */
1488 .long _sys_recv
1489 .long _sys_recvfrom
1490 .long _sys_recvmsg
1491 .long _sys_send
1492 .long _sys_sendmsg /* 325 */
1493 .long _sys_sendto
1494 .long _sys_setsockopt
1495 .long _sys_shutdown
1496 .long _sys_socket
1497 .long _sys_socketpair /* 330 */
1498 .long _sys_semctl
1499 .long _sys_semget
1500 .long _sys_semop
1501 .long _sys_msgctl
1502 .long _sys_msgget /* 335 */
1503 .long _sys_msgrcv
1504 .long _sys_msgsnd
1505 .long _sys_shmat
1506 .long _sys_shmctl
1507 .long _sys_shmdt /* 340 */
1508 .long _sys_shmget
Bryan Wu0b95f222007-09-23 00:51:32 +08001509 .long _sys_splice
1510 .long _sys_sync_file_range
1511 .long _sys_tee
1512 .long _sys_vmsplice /* 345 */
1513 .long _sys_epoll_pwait
1514 .long _sys_utimensat
1515 .long _sys_signalfd
Bryan Wu2f775db2008-03-06 16:04:58 -07001516 .long _sys_timerfd_create
Bryan Wu0b95f222007-09-23 00:51:32 +08001517 .long _sys_eventfd /* 350 */
1518 .long _sys_pread64
1519 .long _sys_pwrite64
1520 .long _sys_fadvise64
1521 .long _sys_set_robust_list
1522 .long _sys_get_robust_list /* 355 */
1523 .long _sys_fallocate
Bernd Schmidtfc975512008-01-27 19:56:43 +08001524 .long _sys_semtimedop
Bryan Wu2f775db2008-03-06 16:04:58 -07001525 .long _sys_timerfd_settime
1526 .long _sys_timerfd_gettime
Bryan Wua4b7b6d2008-08-14 15:40:19 +08001527 .long _sys_signalfd4 /* 360 */
1528 .long _sys_eventfd2
1529 .long _sys_epoll_create1
1530 .long _sys_dup3
1531 .long _sys_pipe2
1532 .long _sys_inotify_init1 /* 365 */
Bryan Wu2f775db2008-03-06 16:04:58 -07001533
Bryan Wu1394f032007-05-06 14:50:22 -07001534 .rept NR_syscalls-(.-_sys_call_table)/4
1535 .long _sys_ni_syscall
1536 .endr
Robin Getz0c7a6b22008-10-08 16:27:12 +08001537END(_sys_call_table)
Bryan Wu1394f032007-05-06 14:50:22 -07001538
1539_exception_stack:
1540 .rept 1024
1541 .long 0;
1542 .endr
1543_exception_stack_top:
1544
Mike Frysinger1aafd902007-07-25 11:19:14 +08001545#if ANOMALY_05000261
Bryan Wu1394f032007-05-06 14:50:22 -07001546/* Used by the assembly entry point to work around an anomaly. */
1547_last_cplb_fault_retx:
1548 .long 0;
1549#endif