Paul Mundt | 336f1d3 | 2008-05-19 19:39:33 +0900 | [diff] [blame] | 1 | /* |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 2 | * Copyright (C) 1999, 2000, 2002 Niibe Yutaka |
Paul Mundt | 336f1d3 | 2008-05-19 19:39:33 +0900 | [diff] [blame] | 3 | * Copyright (C) 2003 - 2008 Paul Mundt |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 4 | * |
| 5 | * This file is subject to the terms and conditions of the GNU General Public |
| 6 | * License. See the file "COPYING" in the main directory of this archive |
| 7 | * for more details. |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | ! NOTE: |
| 12 | ! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address |
| 13 | ! to be jumped is too far, but it causes illegal slot exception. |
| 14 | |
| 15 | /* |
| 16 | * entry.S contains the system-call and fault low-level handling routines. |
| 17 | * This also contains the timer-interrupt handler, as well as all interrupts |
| 18 | * and faults that can result in a task-switch. |
| 19 | * |
| 20 | * NOTE: This code handles signal-recognition, which happens every time |
| 21 | * after a timer-interrupt and after each system call. |
| 22 | * |
| 23 | * NOTE: This code uses a convention that instructions in the delay slot |
| 24 | * of a transfer-control instruction are indented by an extra space, thus: |
| 25 | * |
| 26 | * jmp @k0 ! control-transfer instruction |
| 27 | * ldc k1, ssr ! delay slot |
| 28 | * |
| 29 | * Stack layout in 'ret_from_syscall': |
| 30 | * ptrace needs to have all regs on the stack. |
| 31 | * if the order here is changed, it needs to be |
| 32 | * updated in ptrace.c and ptrace.h |
| 33 | * |
| 34 | * r0 |
| 35 | * ... |
| 36 | * r15 = stack pointer |
| 37 | * spc |
| 38 | * pr |
| 39 | * ssr |
| 40 | * gbr |
| 41 | * mach |
| 42 | * macl |
| 43 | * syscall # |
| 44 | * |
| 45 | */ |
Matt Fleming | cafb0dd | 2009-08-02 22:40:11 +0100 | [diff] [blame] | 46 | #include <asm/dwarf.h> |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 47 | |
| 48 | #if defined(CONFIG_PREEMPT) |
Stuart Menefy | fd78a76 | 2009-07-29 23:01:24 +0900 | [diff] [blame] | 49 | # define preempt_stop() cli ; TRACE_IRQS_OFF |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 50 | #else |
| 51 | # define preempt_stop() |
| 52 | # define resume_kernel __restore_all |
| 53 | #endif |
| 54 | |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 55 | |
| 56 | .align 2 |
| 57 | ENTRY(exception_error) |
| 58 | ! |
Stuart Menefy | fd78a76 | 2009-07-29 23:01:24 +0900 | [diff] [blame] | 59 | TRACE_IRQS_ON |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 60 | sti |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 61 | mov.l 1f, r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 62 | jmp @r0 |
| 63 | nop |
| 64 | |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 65 | .align 2 |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 66 | 1: .long do_exception_error |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 67 | |
| 68 | .align 2 |
| 69 | ret_from_exception: |
Matt Fleming | cafb0dd | 2009-08-02 22:40:11 +0100 | [diff] [blame] | 70 | CFI_STARTPROC simple |
| 71 | CFI_DEF_CFA r14, 0 |
| 72 | CFI_REL_OFFSET 17, 64 |
Matt Fleming | 1426982 | 2010-01-27 20:05:20 +0000 | [diff] [blame] | 73 | CFI_REL_OFFSET 15, 60 |
Matt Fleming | cafb0dd | 2009-08-02 22:40:11 +0100 | [diff] [blame] | 74 | CFI_REL_OFFSET 14, 56 |
Matt Fleming | 1426982 | 2010-01-27 20:05:20 +0000 | [diff] [blame] | 75 | CFI_REL_OFFSET 13, 52 |
| 76 | CFI_REL_OFFSET 12, 48 |
| 77 | CFI_REL_OFFSET 11, 44 |
| 78 | CFI_REL_OFFSET 10, 40 |
| 79 | CFI_REL_OFFSET 9, 36 |
| 80 | CFI_REL_OFFSET 8, 32 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 81 | preempt_stop() |
| 82 | ENTRY(ret_from_irq) |
| 83 | ! |
| 84 | mov #OFF_SR, r0 |
| 85 | mov.l @(r0,r15), r0 ! get status register |
| 86 | shll r0 |
| 87 | shll r0 ! kernel space? |
| 88 | get_current_thread_info r8, r0 |
| 89 | bt resume_kernel ! Yes, it's from kernel, go back soon |
| 90 | |
| 91 | #ifdef CONFIG_PREEMPT |
| 92 | bra resume_userspace |
| 93 | nop |
| 94 | ENTRY(resume_kernel) |
Carmelo Amoroso | 323b8c4 | 2008-09-05 14:42:16 +0900 | [diff] [blame] | 95 | cli |
Matt Fleming | f3a8308 | 2009-08-18 11:35:09 +0900 | [diff] [blame] | 96 | TRACE_IRQS_OFF |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 97 | mov.l @(TI_PRE_COUNT,r8), r0 ! current_thread_info->preempt_count |
| 98 | tst r0, r0 |
| 99 | bf noresched |
| 100 | need_resched: |
| 101 | mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags |
| 102 | tst #_TIF_NEED_RESCHED, r0 ! need_resched set? |
| 103 | bt noresched |
| 104 | |
| 105 | mov #OFF_SR, r0 |
| 106 | mov.l @(r0,r15), r0 ! get status register |
Stuart Menefy | fea966f | 2009-08-24 17:09:53 +0900 | [diff] [blame] | 107 | shlr r0 |
| 108 | and #(0xf0>>1), r0 ! interrupts off (exception path)? |
| 109 | cmp/eq #(0xf0>>1), r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 110 | bt noresched |
Thomas Gleixner | 00d1a39 | 2013-09-17 18:53:09 +0000 | [diff] [blame] | 111 | mov.l 1f, r0 |
Carmelo Amoroso | 323b8c4 | 2008-09-05 14:42:16 +0900 | [diff] [blame] | 112 | jsr @r0 ! call preempt_schedule_irq |
Paul Mundt | afbfb52 | 2006-12-04 18:17:28 +0900 | [diff] [blame] | 113 | nop |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 114 | bra need_resched |
| 115 | nop |
Paul Mundt | afbfb52 | 2006-12-04 18:17:28 +0900 | [diff] [blame] | 116 | |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 117 | noresched: |
| 118 | bra __restore_all |
| 119 | nop |
| 120 | |
| 121 | .align 2 |
Thomas Gleixner | 00d1a39 | 2013-09-17 18:53:09 +0000 | [diff] [blame] | 122 | 1: .long preempt_schedule_irq |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 123 | #endif |
| 124 | |
| 125 | ENTRY(resume_userspace) |
| 126 | ! r8: current_thread_info |
| 127 | cli |
Paul Mundt | 457b646 | 2009-10-14 15:50:28 +0900 | [diff] [blame] | 128 | TRACE_IRQS_OFF |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 129 | mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags |
Matt Fleming | c652d78 | 2009-07-06 20:16:33 +0900 | [diff] [blame] | 130 | tst #(_TIF_WORK_MASK & 0xff), r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 131 | bt/s __restore_all |
| 132 | tst #_TIF_NEED_RESCHED, r0 |
| 133 | |
| 134 | .align 2 |
| 135 | work_pending: |
| 136 | ! r0: current_thread_info->flags |
| 137 | ! r8: current_thread_info |
| 138 | ! t: result of "tst #_TIF_NEED_RESCHED, r0" |
| 139 | bf/s work_resched |
Al Viro | 5e071e2 | 2012-09-18 17:04:37 +0900 | [diff] [blame] | 140 | tst #(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME), r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 141 | work_notifysig: |
| 142 | bt/s __restore_all |
| 143 | mov r15, r4 |
| 144 | mov r12, r5 ! set arg1(save_r0) |
| 145 | mov r0, r6 |
Paul Mundt | 6330c04 | 2012-01-10 16:30:37 +0900 | [diff] [blame] | 146 | sti |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 147 | mov.l 2f, r1 |
| 148 | mov.l 3f, r0 |
| 149 | jmp @r1 |
| 150 | lds r0, pr |
| 151 | work_resched: |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 152 | mov.l 1f, r1 |
| 153 | jsr @r1 ! schedule |
| 154 | nop |
| 155 | cli |
Stuart Menefy | fd78a76 | 2009-07-29 23:01:24 +0900 | [diff] [blame] | 156 | TRACE_IRQS_OFF |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 157 | ! |
| 158 | mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags |
Matt Fleming | c652d78 | 2009-07-06 20:16:33 +0900 | [diff] [blame] | 159 | tst #(_TIF_WORK_MASK & 0xff), r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 160 | bt __restore_all |
| 161 | bra work_pending |
| 162 | tst #_TIF_NEED_RESCHED, r0 |
| 163 | |
| 164 | .align 2 |
| 165 | 1: .long schedule |
| 166 | 2: .long do_notify_resume |
Stuart MENEFY | 0b1689c | 2008-07-17 13:08:40 +0100 | [diff] [blame] | 167 | 3: .long resume_userspace |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 168 | |
| 169 | .align 2 |
| 170 | syscall_exit_work: |
| 171 | ! r0: current_thread_info->flags |
| 172 | ! r8: current_thread_info |
Matt Fleming | c652d78 | 2009-07-06 20:16:33 +0900 | [diff] [blame] | 173 | tst #(_TIF_WORK_SYSCALL_MASK & 0xff), r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 174 | bt/s work_pending |
| 175 | tst #_TIF_NEED_RESCHED, r0 |
Stuart Menefy | fd78a76 | 2009-07-29 23:01:24 +0900 | [diff] [blame] | 176 | TRACE_IRQS_ON |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 177 | sti |
Yuichi Nakamura | 1322b9d | 2007-11-10 19:21:34 +0900 | [diff] [blame] | 178 | mov r15, r4 |
Paul Mundt | ab99c73 | 2008-07-30 19:55:30 +0900 | [diff] [blame] | 179 | mov.l 8f, r0 ! do_syscall_trace_leave |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 180 | jsr @r0 |
| 181 | nop |
| 182 | bra resume_userspace |
| 183 | nop |
| 184 | |
| 185 | .align 2 |
| 186 | syscall_trace_entry: |
| 187 | ! Yes it is traced. |
Yuichi Nakamura | 1322b9d | 2007-11-10 19:21:34 +0900 | [diff] [blame] | 188 | mov r15, r4 |
Paul Mundt | ab99c73 | 2008-07-30 19:55:30 +0900 | [diff] [blame] | 189 | mov.l 7f, r11 ! Call do_syscall_trace_enter which notifies |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 190 | jsr @r11 ! superior (will chomp R[0-7]) |
| 191 | nop |
Paul Mundt | ab99c73 | 2008-07-30 19:55:30 +0900 | [diff] [blame] | 192 | mov.l r0, @(OFF_R0,r15) ! Save return value |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 193 | ! Reload R0-R4 from kernel stack, where the |
| 194 | ! parent may have modified them using |
| 195 | ! ptrace(POKEUSR). (Note that R0-R2 are |
| 196 | ! used by the system call handler directly |
| 197 | ! from the kernel stack anyway, so don't need |
| 198 | ! to be reloaded here.) This allows the parent |
| 199 | ! to rewrite system calls and args on the fly. |
| 200 | mov.l @(OFF_R4,r15), r4 ! arg0 |
| 201 | mov.l @(OFF_R5,r15), r5 |
| 202 | mov.l @(OFF_R6,r15), r6 |
| 203 | mov.l @(OFF_R7,r15), r7 ! arg3 |
| 204 | mov.l @(OFF_R3,r15), r3 ! syscall_nr |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 205 | ! |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 206 | mov.l 2f, r10 ! Number of syscalls |
| 207 | cmp/hs r10, r3 |
| 208 | bf syscall_call |
| 209 | mov #-ENOSYS, r0 |
| 210 | bra syscall_exit |
| 211 | mov.l r0, @(OFF_R0,r15) ! Return value |
| 212 | |
| 213 | __restore_all: |
Matt Fleming | f3a8308 | 2009-08-18 11:35:09 +0900 | [diff] [blame] | 214 | mov #OFF_SR, r0 |
| 215 | mov.l @(r0,r15), r0 ! get status register |
| 216 | |
| 217 | shlr2 r0 |
| 218 | and #0x3c, r0 |
| 219 | cmp/eq #0x3c, r0 |
| 220 | bt 1f |
| 221 | TRACE_IRQS_ON |
| 222 | bra 2f |
| 223 | nop |
| 224 | 1: |
| 225 | TRACE_IRQS_OFF |
| 226 | 2: |
| 227 | mov.l 3f, r0 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 228 | jmp @r0 |
| 229 | nop |
| 230 | |
| 231 | .align 2 |
Matt Fleming | f3a8308 | 2009-08-18 11:35:09 +0900 | [diff] [blame] | 232 | 3: .long restore_all |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 233 | |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 234 | .align 2 |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 235 | syscall_badsys: ! Bad syscall number |
Hideo Saito | 561c2bc | 2008-05-15 13:30:05 +0900 | [diff] [blame] | 236 | get_current_thread_info r8, r0 |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 237 | mov #-ENOSYS, r0 |
| 238 | bra resume_userspace |
| 239 | mov.l r0, @(OFF_R0,r15) ! Return value |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 240 | |
| 241 | /* |
| 242 | * The main debug trap handler. |
| 243 | * |
| 244 | * r8=TRA (not the trap number!) |
| 245 | * |
| 246 | * Note: This assumes that the trapa value is left in its original |
| 247 | * form (without the shlr2 shift) so the calculation for the jump |
| 248 | * call table offset remains a simple in place mask. |
| 249 | */ |
| 250 | debug_trap: |
| 251 | mov r8, r0 |
| 252 | and #(0xf << 2), r0 |
| 253 | mov.l 1f, r8 |
| 254 | add r0, r8 |
| 255 | mov.l @r8, r8 |
Paul Mundt | 336f1d3 | 2008-05-19 19:39:33 +0900 | [diff] [blame] | 256 | jsr @r8 |
| 257 | nop |
| 258 | bra __restore_all |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 259 | nop |
Matt Fleming | cafb0dd | 2009-08-02 22:40:11 +0100 | [diff] [blame] | 260 | CFI_ENDPROC |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 261 | |
| 262 | .align 2 |
| 263 | 1: .long debug_trap_table |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 264 | |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 265 | /* |
| 266 | * Syscall interface: |
| 267 | * |
| 268 | * Syscall #: R3 |
| 269 | * Arguments #0 to #3: R4--R7 |
| 270 | * Arguments #4 to #6: R0, R1, R2 |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 271 | * TRA: (number of arguments + ABI revision) x 4 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 272 | * |
| 273 | * This code also handles delegating other traps to the BIOS/gdb stub |
| 274 | * according to: |
| 275 | * |
| 276 | * Trap number |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 277 | * (TRA>>2) Purpose |
| 278 | * -------- ------- |
| 279 | * 0x00-0x0f original SH-3/4 syscall ABI (not in general use). |
| 280 | * 0x10-0x1f general SH-3/4 syscall ABI. |
| 281 | * 0x20-0x2f syscall ABI for SH-2 parts. |
| 282 | * 0x30-0x3f debug traps used by the kernel. |
| 283 | * 0x40-0xff Not supported by all parts, so left unhandled. |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 284 | * |
| 285 | * Note: When we're first called, the TRA value must be shifted |
| 286 | * right 2 bits in order to get the value that was used as the "trapa" |
| 287 | * argument. |
| 288 | */ |
| 289 | |
| 290 | .align 2 |
| 291 | .globl ret_from_fork |
| 292 | ret_from_fork: |
| 293 | mov.l 1f, r8 |
| 294 | jsr @r8 |
| 295 | mov r0, r4 |
| 296 | bra syscall_exit |
| 297 | nop |
Al Viro | 7147e21 | 2012-10-14 01:41:42 -0400 | [diff] [blame] | 298 | |
| 299 | .align 2 |
| 300 | .globl ret_from_kernel_thread |
| 301 | ret_from_kernel_thread: |
| 302 | mov.l 1f, r8 |
| 303 | jsr @r8 |
| 304 | mov r0, r4 |
| 305 | mov.l @(OFF_R5,r15), r5 ! fn |
| 306 | jsr @r5 |
| 307 | mov.l @(OFF_R4,r15), r4 ! arg |
| 308 | bra syscall_exit |
| 309 | nop |
| 310 | |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 311 | .align 2 |
| 312 | 1: .long schedule_tail |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 313 | |
| 314 | /* |
| 315 | * The poorly named main trapa decode and dispatch routine, for |
| 316 | * system calls and debug traps through their respective jump tables. |
| 317 | */ |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 318 | ENTRY(system_call) |
Matt Fleming | 0b93048 | 2009-08-02 22:33:26 +0100 | [diff] [blame] | 319 | setup_frame_reg |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 320 | #if !defined(CONFIG_CPU_SH2) |
| 321 | mov.l 1f, r9 |
| 322 | mov.l @r9, r8 ! Read from TRA (Trap Address) Register |
| 323 | #endif |
Paul Mundt | ab6e570 | 2008-12-11 18:46:46 +0900 | [diff] [blame] | 324 | |
| 325 | mov #OFF_TRA, r10 |
| 326 | add r15, r10 |
| 327 | mov.l r8, @r10 ! set TRA value to tra |
| 328 | |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 329 | /* |
| 330 | * Check the trap type |
| 331 | */ |
| 332 | mov #((0x20 << 2) - 1), r9 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 333 | cmp/hi r9, r8 |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 334 | bt/s debug_trap ! it's a debug trap.. |
Paul Mundt | ab6e570 | 2008-12-11 18:46:46 +0900 | [diff] [blame] | 335 | nop |
| 336 | |
Stuart Menefy | fd78a76 | 2009-07-29 23:01:24 +0900 | [diff] [blame] | 337 | TRACE_IRQS_ON |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 338 | sti |
Paul Mundt | afbfb52 | 2006-12-04 18:17:28 +0900 | [diff] [blame] | 339 | |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 340 | ! |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 341 | get_current_thread_info r8, r10 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 342 | mov.l @(TI_FLAGS,r8), r8 |
Matt Fleming | c652d78 | 2009-07-06 20:16:33 +0900 | [diff] [blame] | 343 | mov #(_TIF_WORK_SYSCALL_MASK & 0xff), r10 |
| 344 | mov #(_TIF_WORK_SYSCALL_MASK >> 8), r9 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 345 | tst r10, r8 |
Matt Fleming | c652d78 | 2009-07-06 20:16:33 +0900 | [diff] [blame] | 346 | shll8 r9 |
| 347 | bf syscall_trace_entry |
| 348 | tst r9, r8 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 349 | bf syscall_trace_entry |
| 350 | ! |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 351 | mov.l 2f, r8 ! Number of syscalls |
| 352 | cmp/hs r8, r3 |
| 353 | bt syscall_badsys |
| 354 | ! |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 355 | syscall_call: |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 356 | shll2 r3 ! x4 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 357 | mov.l 3f, r8 ! Load the address of sys_call_table |
Stuart Menefy | e0969e0 | 2006-11-24 13:01:36 +0900 | [diff] [blame] | 358 | add r8, r3 |
| 359 | mov.l @r3, r8 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 360 | jsr @r8 ! jump to specific syscall handler |
| 361 | nop |
| 362 | mov.l @(OFF_R0,r15), r12 ! save r0 |
| 363 | mov.l r0, @(OFF_R0,r15) ! save the return value |
| 364 | ! |
| 365 | syscall_exit: |
| 366 | cli |
Stuart Menefy | fd78a76 | 2009-07-29 23:01:24 +0900 | [diff] [blame] | 367 | TRACE_IRQS_OFF |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 368 | ! |
| 369 | get_current_thread_info r8, r0 |
| 370 | mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags |
Matt Fleming | c652d78 | 2009-07-06 20:16:33 +0900 | [diff] [blame] | 371 | tst #(_TIF_ALLWORK_MASK & 0xff), r0 |
| 372 | mov #(_TIF_ALLWORK_MASK >> 8), r1 |
| 373 | bf syscall_exit_work |
| 374 | shlr8 r0 |
| 375 | tst r0, r1 |
Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 376 | bf syscall_exit_work |
| 377 | bra __restore_all |
| 378 | nop |
| 379 | .align 2 |
| 380 | #if !defined(CONFIG_CPU_SH2) |
| 381 | 1: .long TRA |
| 382 | #endif |
| 383 | 2: .long NR_syscalls |
| 384 | 3: .long sys_call_table |
Paul Mundt | ab99c73 | 2008-07-30 19:55:30 +0900 | [diff] [blame] | 385 | 7: .long do_syscall_trace_enter |
| 386 | 8: .long do_syscall_trace_leave |