1 /* 1 /* 2 * linux/arch/nios2/kernel/entry.S !! 2 * arch/alpha/kernel/entry.S 3 * 3 * 4 * Copyright (C) 2013-2014 Altera Corporation !! 4 * Kernel entry-points. 5 * Copyright (C) 2009, Wind River Systems Inc << 6 * << 7 * Implemented by fredrik.markstrom@gmail.com << 8 * << 9 * Copyright (C) 1999-2002, Greg Ungerer (ger << 10 * Copyright (C) 1998 D. Jeff Dionne <jeff@li << 11 * Kenneth Albanowski <kja << 12 * Copyright (C) 2000 Lineo Inc. (www.lineo. << 13 * Copyright (C) 2004 Microtronix Datacom Lt << 14 * << 15 * This file is subject to the terms and condi << 16 * License. See the file "COPYING" in the mai << 17 * for more details. << 18 * << 19 * Linux/m68k support by Hamish Macdonald << 20 * << 21 * 68060 fixes by Jesper Skov << 22 * ColdFire support by Greg Ungerer (gerg@snap << 23 * 5307 fixes by David W. Miller << 24 * linux 2.4 support David McCullough <davidm@s << 25 */ 5 */ 26 6 27 #include <linux/sys.h> !! 7 #include <linux/config.h> 28 #include <linux/linkage.h> !! 8 #include <asm/asm_offsets.h> 29 #include <asm/asm-offsets.h> << 30 #include <asm/asm-macros.h> << 31 #include <asm/thread_info.h> 9 #include <asm/thread_info.h> >> 10 #include <asm/pal.h> 32 #include <asm/errno.h> 11 #include <asm/errno.h> 33 #include <asm/setup.h> << 34 #include <asm/entry.h> << 35 #include <asm/unistd.h> 12 #include <asm/unistd.h> 36 #include <asm/processor.h> << 37 13 38 .macro GET_THREAD_INFO reg !! 14 .text 39 .if THREAD_SIZE & 0xffff0000 !! 15 .set noat 40 andhi \reg, sp, %hi(~(THREAD_SIZE-1) << 41 .else << 42 addi \reg, r0, %lo(~(THREAD_SIZE-1) << 43 and \reg, \reg, sp << 44 .endif << 45 .endm << 46 16 47 .macro kuser_cmpxchg_check !! 17 /* Stack offsets. */ 48 /* !! 18 #define SP_OFF 184 49 * Make sure our user space atomic hel !! 19 #define SWITCH_STACK_SIZE 320 50 * interrupted in a critical region. << 51 * ea-4 = address of interrupted insn << 52 * sp = saved regs. << 53 * cmpxchg_ldw = first critical insn, << 54 * If ea <= cmpxchg_stw and ea > cmpxc << 55 * cmpxchg_ldw + 4. << 56 */ << 57 /* et = cmpxchg_stw + 4 */ << 58 movui et, (KUSER_BASE + 4 + (cmpxchg << 59 bgtu ea, et, 1f << 60 << 61 subi et, et, (cmpxchg_stw - cmpxchg << 62 bltu ea, et, 1f << 63 stw et, PT_EA(sp) /* fix up EA * << 64 mov ea, et << 65 1: << 66 .endm << 67 << 68 .section .rodata << 69 .align 4 << 70 exception_table: << 71 .word unhandled_exception /* 0 - << 72 .word unhandled_exception /* 1 - << 73 .word external_interrupt /* 2 - << 74 .word handle_trap /* 3 - << 75 << 76 .word instruction_trap /* 4 - << 77 .word handle_illegal /* 5 - << 78 .word handle_unaligned /* 6 - << 79 .word handle_unaligned /* 7 - << 80 << 81 .word handle_diverror /* 8 - << 82 .word protection_exception_ba /* 9 - << 83 .word protection_exception_instr /* 10 << 84 .word protection_exception_ba /* 11 << 85 << 86 .word unhandled_exception /* 12 << 87 .word protection_exception_pte /* 13 << 88 .word protection_exception_pte /* 14 << 89 .word protection_exception_pte /* 15 << 90 << 91 .word unhandled_exception /* 16 << 92 << 93 trap_table: << 94 .word handle_system_call /* 0 << 95 .word handle_trap_1 /* 1 << 96 .word handle_trap_2 /* 2 << 97 .word handle_trap_3 /* 3 << 98 .word handle_trap_reserved /* 4 << 99 .word handle_trap_reserved /* 5 << 100 .word handle_trap_reserved /* 6 << 101 .word handle_trap_reserved /* 7 << 102 .word handle_trap_reserved /* 8 << 103 .word handle_trap_reserved /* 9 << 104 .word handle_trap_reserved /* 10 << 105 .word handle_trap_reserved /* 11 << 106 .word handle_trap_reserved /* 12 << 107 .word handle_trap_reserved /* 13 << 108 .word handle_trap_reserved /* 14 << 109 .word handle_trap_reserved /* 15 << 110 .word handle_trap_reserved /* 16 << 111 .word handle_trap_reserved /* 17 << 112 .word handle_trap_reserved /* 18 << 113 .word handle_trap_reserved /* 19 << 114 .word handle_trap_reserved /* 20 << 115 .word handle_trap_reserved /* 21 << 116 .word handle_trap_reserved /* 22 << 117 .word handle_trap_reserved /* 23 << 118 .word handle_trap_reserved /* 24 << 119 .word handle_trap_reserved /* 25 << 120 .word handle_trap_reserved /* 26 << 121 .word handle_trap_reserved /* 27 << 122 .word handle_trap_reserved /* 28 << 123 .word handle_trap_reserved /* 29 << 124 #ifdef CONFIG_KGDB << 125 .word handle_kgdb_breakpoint /* 30 << 126 #else << 127 .word instruction_trap << 128 #endif << 129 .word handle_breakpoint /* 31 << 130 20 131 .text !! 21 /* 132 .set noat !! 22 * This defines the normal kernel pt-regs layout. 133 .set nobreak !! 23 * >> 24 * regs 9-15 preserved by C code >> 25 * regs 16-18 saved by PAL-code >> 26 * regs 29-30 saved and set up by PAL-code >> 27 * JRP - Save regs 16-18 in a special area of the stack, so that >> 28 * the palcode-provided values are available to the signal handler. >> 29 */ 134 30 135 ENTRY(inthandler) !! 31 #define SAVE_ALL \ 136 SAVE_ALL !! 32 subq $sp, SP_OFF, $sp; \ >> 33 stq $0, 0($sp); \ >> 34 stq $1, 8($sp); \ >> 35 stq $2, 16($sp); \ >> 36 stq $3, 24($sp); \ >> 37 stq $4, 32($sp); \ >> 38 stq $28, 144($sp); \ >> 39 lda $2, alpha_mv; \ >> 40 stq $5, 40($sp); \ >> 41 stq $6, 48($sp); \ >> 42 stq $7, 56($sp); \ >> 43 stq $8, 64($sp); \ >> 44 stq $19, 72($sp); \ >> 45 stq $20, 80($sp); \ >> 46 stq $21, 88($sp); \ >> 47 ldq $2, HAE_CACHE($2); \ >> 48 stq $22, 96($sp); \ >> 49 stq $23, 104($sp); \ >> 50 stq $24, 112($sp); \ >> 51 stq $25, 120($sp); \ >> 52 stq $26, 128($sp); \ >> 53 stq $27, 136($sp); \ >> 54 stq $2, 152($sp); \ >> 55 stq $16, 160($sp); \ >> 56 stq $17, 168($sp); \ >> 57 stq $18, 176($sp) >> 58 >> 59 #define RESTORE_ALL \ >> 60 lda $19, alpha_mv; \ >> 61 ldq $0, 0($sp); \ >> 62 ldq $1, 8($sp); \ >> 63 ldq $2, 16($sp); \ >> 64 ldq $3, 24($sp); \ >> 65 ldq $21, 152($sp); \ >> 66 ldq $20, HAE_CACHE($19); \ >> 67 ldq $4, 32($sp); \ >> 68 ldq $5, 40($sp); \ >> 69 ldq $6, 48($sp); \ >> 70 ldq $7, 56($sp); \ >> 71 subq $20, $21, $20; \ >> 72 ldq $8, 64($sp); \ >> 73 beq $20, 99f; \ >> 74 ldq $20, HAE_REG($19); \ >> 75 stq $21, HAE_CACHE($19); \ >> 76 stq $21, 0($20); \ >> 77 ldq $0, 0($sp); \ >> 78 ldq $1, 8($sp); \ >> 79 99:; \ >> 80 ldq $19, 72($sp); \ >> 81 ldq $20, 80($sp); \ >> 82 ldq $21, 88($sp); \ >> 83 ldq $22, 96($sp); \ >> 84 ldq $23, 104($sp); \ >> 85 ldq $24, 112($sp); \ >> 86 ldq $25, 120($sp); \ >> 87 ldq $26, 128($sp); \ >> 88 ldq $27, 136($sp); \ >> 89 ldq $28, 144($sp); \ >> 90 addq $sp, SP_OFF, $sp 137 91 138 kuser_cmpxchg_check !! 92 /* >> 93 * Non-syscall kernel entry points. >> 94 */ 139 95 140 /* Clear EH bit before we get a new ex !! 96 .align 4 141 * and after we have saved it to the e !! 97 .globl entInt 142 * whether it's trap, tlb-miss or inte !! 98 .ent entInt 143 * estatus is not updated the next exc !! 99 entInt: 144 */ !! 100 SAVE_ALL 145 rdctl r24, status !! 101 lda $8, 0x3fff 146 movi r9, %lo(~STATUS_EH) !! 102 lda $26, ret_from_sys_call 147 and r24, r24, r9 !! 103 bic $sp, $8, $8 148 wrctl status, r24 !! 104 mov $sp, $19 149 !! 105 jsr $31, do_entInt 150 /* Read cause and vector and branch to !! 106 .end entInt 151 mov r4, sp !! 107 152 rdctl r5, exception !! 108 .align 4 153 movia r9, exception_table !! 109 .globl entArith 154 add r24, r9, r5 !! 110 .ent entArith 155 ldw r24, 0(r24) !! 111 entArith: 156 jmp r24 !! 112 SAVE_ALL 157 !! 113 lda $8, 0x3fff 158 !! 114 lda $26, ret_from_sys_call 159 /********************************************* !! 115 bic $sp, $8, $8 160 * Handle traps !! 116 mov $sp, $18 161 ********************************************* !! 117 jsr $31, do_entArith 162 */ !! 118 .end entArith 163 ENTRY(handle_trap) !! 119 164 ldwio r24, -4(ea) /* instruction !! 120 .align 4 165 srli r24, r24, 4 !! 121 .globl entMM 166 andi r24, r24, 0x7c !! 122 .ent entMM 167 movia r9,trap_table !! 123 entMM: 168 add r24, r24, r9 !! 124 SAVE_ALL 169 ldw r24, 0(r24) !! 125 /* save $9 - $15 so the inline exception code can manipulate them. */ 170 jmp r24 !! 126 subq $sp, 56, $sp 171 !! 127 stq $9, 0($sp) 172 !! 128 stq $10, 8($sp) 173 /********************************************* !! 129 stq $11, 16($sp) 174 * Handle system calls !! 130 stq $12, 24($sp) 175 ********************************************* !! 131 stq $13, 32($sp) 176 */ !! 132 stq $14, 40($sp) 177 ENTRY(handle_system_call) !! 133 stq $15, 48($sp) 178 /* Enable interrupts */ !! 134 addq $sp, 56, $19 179 rdctl r10, status !! 135 /* handle the fault */ 180 ori r10, r10, STATUS_PIE !! 136 lda $8, 0x3fff 181 wrctl status, r10 !! 137 bic $sp, $8, $8 182 !! 138 jsr $26, do_page_fault 183 /* Reload registers destroyed by commo !! 139 /* reload the registers after the exception code played. */ 184 ldw r4, PT_R4(sp) !! 140 ldq $9, 0($sp) 185 ldw r5, PT_R5(sp) !! 141 ldq $10, 8($sp) 186 !! 142 ldq $11, 16($sp) 187 local_restart: !! 143 ldq $12, 24($sp) 188 stw r2, PT_ORIG_R2(sp) !! 144 ldq $13, 32($sp) 189 /* Check that the requested system cal !! 145 ldq $14, 40($sp) 190 movui r1, __NR_syscalls !! 146 ldq $15, 48($sp) 191 bgeu r2, r1, ret_invsyscall !! 147 addq $sp, 56, $sp 192 slli r1, r2, 2 !! 148 /* finish up the syscall as normal. */ 193 movhi r11, %hiadj(sys_call_table) !! 149 br ret_from_sys_call 194 add r1, r1, r11 !! 150 .end entMM 195 ldw r1, %lo(sys_call_table)(r1) !! 151 196 !! 152 .align 4 197 /* Check if we are being traced */ !! 153 .globl entIF 198 GET_THREAD_INFO r11 !! 154 .ent entIF 199 ldw r11,TI_FLAGS(r11) !! 155 entIF: 200 BTBNZ r11,r11,TIF_SYSCALL_TRACE,trac !! 156 SAVE_ALL 201 !! 157 lda $8, 0x3fff 202 /* Execute the system call */ !! 158 lda $26, ret_from_sys_call 203 callr r1 !! 159 bic $sp, $8, $8 204 !! 160 mov $sp, $17 205 /* If the syscall returns a negative r !! 161 jsr $31, do_entIF 206 * Set r7 to 1 to indicate error, !! 162 .end entIF 207 * Negate r2 to get a positive error !! 163 208 * If the syscall returns zero or a po !! 164 .align 4 209 * Set r7 to 0. !! 165 .globl entUna 210 * The sigreturn system calls will ski !! 166 .ent entUna 211 * adding to register ra. To avoid des !! 167 entUna: 212 */ !! 168 lda $sp, -256($sp) 213 translate_rc_and_ret: !! 169 stq $0, 0($sp) 214 movi r1, 0 !! 170 ldq $0, 256($sp) /* get PS */ 215 bge r2, zero, 3f !! 171 stq $1, 8($sp) 216 ldw r1, PT_ORIG_R2(sp) !! 172 stq $2, 16($sp) 217 addi r1, r1, 1 !! 173 stq $3, 24($sp) 218 beq r1, zero, 3f !! 174 and $0, 8, $0 /* user mode? */ 219 sub r2, zero, r2 !! 175 stq $4, 32($sp) 220 movi r1, 1 !! 176 bne $0, entUnaUser /* yup -> do user-level unaligned fault */ 221 3: !! 177 stq $5, 40($sp) 222 stw r2, PT_R2(sp) !! 178 stq $6, 48($sp) 223 stw r1, PT_R7(sp) !! 179 stq $7, 56($sp) 224 end_translate_rc_and_ret: !! 180 stq $8, 64($sp) 225 !! 181 stq $9, 72($sp) 226 ret_from_exception: !! 182 stq $10, 80($sp) 227 ldw r1, PT_ESTATUS(sp) !! 183 stq $11, 88($sp) 228 /* if so, skip resched, signals */ !! 184 stq $12, 96($sp) 229 TSTBNZ r1, r1, ESTATUS_EU, Luser_retu !! 185 stq $13, 104($sp) >> 186 stq $14, 112($sp) >> 187 stq $15, 120($sp) >> 188 /* 16-18 PAL-saved */ >> 189 stq $19, 152($sp) >> 190 stq $20, 160($sp) >> 191 stq $21, 168($sp) >> 192 stq $22, 176($sp) >> 193 stq $23, 184($sp) >> 194 stq $24, 192($sp) >> 195 stq $25, 200($sp) >> 196 stq $26, 208($sp) >> 197 stq $27, 216($sp) >> 198 stq $28, 224($sp) >> 199 stq $gp, 232($sp) >> 200 lda $8, 0x3fff >> 201 stq $31, 248($sp) >> 202 bic $sp, $8, $8 >> 203 jsr $26, do_entUna >> 204 ldq $0, 0($sp) >> 205 ldq $1, 8($sp) >> 206 ldq $2, 16($sp) >> 207 ldq $3, 24($sp) >> 208 ldq $4, 32($sp) >> 209 ldq $5, 40($sp) >> 210 ldq $6, 48($sp) >> 211 ldq $7, 56($sp) >> 212 ldq $8, 64($sp) >> 213 ldq $9, 72($sp) >> 214 ldq $10, 80($sp) >> 215 ldq $11, 88($sp) >> 216 ldq $12, 96($sp) >> 217 ldq $13, 104($sp) >> 218 ldq $14, 112($sp) >> 219 ldq $15, 120($sp) >> 220 /* 16-18 PAL-saved */ >> 221 ldq $19, 152($sp) >> 222 ldq $20, 160($sp) >> 223 ldq $21, 168($sp) >> 224 ldq $22, 176($sp) >> 225 ldq $23, 184($sp) >> 226 ldq $24, 192($sp) >> 227 ldq $25, 200($sp) >> 228 ldq $26, 208($sp) >> 229 ldq $27, 216($sp) >> 230 ldq $28, 224($sp) >> 231 ldq $gp, 232($sp) >> 232 lda $sp, 256($sp) >> 233 call_pal PAL_rti >> 234 .end entUna >> 235 >> 236 .align 4 >> 237 .ent entUnaUser >> 238 entUnaUser: >> 239 ldq $0, 0($sp) /* restore original $0 */ >> 240 lda $sp, 256($sp) /* pop entUna's stack frame */ >> 241 SAVE_ALL /* setup normal kernel stack */ >> 242 lda $sp, -56($sp) >> 243 stq $9, 0($sp) >> 244 stq $10, 8($sp) >> 245 stq $11, 16($sp) >> 246 stq $12, 24($sp) >> 247 stq $13, 32($sp) >> 248 stq $14, 40($sp) >> 249 stq $15, 48($sp) >> 250 lda $8, 0x3fff >> 251 addq $sp, 56, $19 >> 252 bic $sp, $8, $8 >> 253 jsr $26, do_entUnaUser >> 254 ldq $9, 0($sp) >> 255 ldq $10, 8($sp) >> 256 ldq $11, 16($sp) >> 257 ldq $12, 24($sp) >> 258 ldq $13, 32($sp) >> 259 ldq $14, 40($sp) >> 260 ldq $15, 48($sp) >> 261 lda $sp, 56($sp) >> 262 br ret_from_sys_call >> 263 .end entUnaUser >> 264 >> 265 .align 4 >> 266 .globl entDbg >> 267 .ent entDbg >> 268 entDbg: >> 269 SAVE_ALL >> 270 lda $8, 0x3fff >> 271 lda $26, ret_from_sys_call >> 272 bic $sp, $8, $8 >> 273 mov $sp, $16 >> 274 jsr $31, do_entDbg >> 275 .end entDbg >> 276 >> 277 /* >> 278 * The system call entry point is special. Most importantly, it looks >> 279 * like a function call to userspace as far as clobbered registers. We >> 280 * do preserve the argument registers (for syscall restarts) and $26 >> 281 * (for leaf syscall functions). >> 282 * >> 283 * So much for theory. We don't take advantage of this yet. >> 284 * >> 285 * Note that a0-a2 are not saved by PALcode as with the other entry points. >> 286 */ 230 287 >> 288 .align 4 >> 289 .globl entSys >> 290 .globl ret_from_sys_call >> 291 .ent entSys >> 292 entSys: >> 293 SAVE_ALL >> 294 lda $8, 0x3fff >> 295 bic $sp, $8, $8 >> 296 lda $4, NR_SYSCALLS($31) >> 297 stq $16, SP_OFF+24($sp) >> 298 lda $5, sys_call_table >> 299 lda $27, sys_ni_syscall >> 300 cmpult $0, $4, $4 >> 301 ldl $3, TI_FLAGS($8) >> 302 stq $17, SP_OFF+32($sp) >> 303 s8addq $0, $5, $5 >> 304 stq $18, SP_OFF+40($sp) >> 305 blbs $3, strace >> 306 beq $4, 1f >> 307 ldq $27, 0($5) >> 308 1: jsr $26, ($27), alpha_ni_syscall >> 309 ldgp $gp, 0($26) >> 310 blt $0, $syscall_error /* the call failed */ >> 311 stq $0, 0($sp) >> 312 stq $31, 72($sp) /* a3=0 => no error */ >> 313 >> 314 .align 4 >> 315 ret_from_sys_call: >> 316 cmovne $26, 0, $19 /* $19 = 0 => non-restartable */ >> 317 ldq $0, SP_OFF($sp) >> 318 and $0, 8, $0 >> 319 beq $0, restore_all >> 320 ret_from_reschedule: >> 321 /* Make sure need_resched and sigpending don't change between >> 322 sampling and the rti. */ >> 323 lda $16, 7 >> 324 call_pal PAL_swpipl >> 325 ldl $5, TI_FLAGS($8) >> 326 and $5, _TIF_WORK_MASK, $2 >> 327 bne $5, work_pending 231 restore_all: 328 restore_all: 232 rdctl r10, status << 233 andi r10, r10, %lo(~STATUS_PIE) << 234 wrctl status, r10 << 235 RESTORE_ALL 329 RESTORE_ALL 236 eret !! 330 call_pal PAL_rti 237 << 238 /* If the syscall number was invalid r << 239 ret_invsyscall: << 240 movi r2, -ENOSYS << 241 br translate_rc_and_ret << 242 << 243 /* This implements the same as above, << 244 * do_syscall_trace_enter and do_sysca << 245 * syscall in order for utilities like << 246 */ << 247 traced_system_call: << 248 SAVE_SWITCH_STACK << 249 call do_syscall_trace_enter << 250 RESTORE_SWITCH_STACK << 251 << 252 /* Create system call register argumen << 253 arguments on stack are already in p << 254 of pt_regs. */ << 255 ldw r2, PT_R2(sp) << 256 ldw r4, PT_R4(sp) << 257 ldw r5, PT_R5(sp) << 258 ldw r6, PT_R6(sp) << 259 ldw r7, PT_R7(sp) << 260 << 261 /* Fetch the syscall function. */ << 262 movui r1, __NR_syscalls << 263 bgeu r2, r1, traced_invsyscall << 264 slli r1, r2, 2 << 265 movhi r11,%hiadj(sys_call_table) << 266 add r1, r1, r11 << 267 ldw r1, %lo(sys_call_table)(r1) << 268 << 269 callr r1 << 270 << 271 /* If the syscall returns a negative r << 272 * Set r7 to 1 to indicate error, << 273 * Negate r2 to get a positive error << 274 * If the syscall returns zero or a po << 275 * Set r7 to 0. << 276 * The sigreturn system calls will ski << 277 * adding to register ra. To avoid des << 278 */ << 279 translate_rc_and_ret2: << 280 movi r1, 0 << 281 bge r2, zero, 4f << 282 ldw r1, PT_ORIG_R2(sp) << 283 addi r1, r1, 1 << 284 beq r1, zero, 4f << 285 sub r2, zero, r2 << 286 movi r1, 1 << 287 4: << 288 stw r2, PT_R2(sp) << 289 stw r1, PT_R7(sp) << 290 end_translate_rc_and_ret2: << 291 SAVE_SWITCH_STACK << 292 call do_syscall_trace_exit << 293 RESTORE_SWITCH_STACK << 294 br ret_from_exception << 295 << 296 /* If the syscall number was invalid r << 297 traced_invsyscall: << 298 movi r2, -ENOSYS << 299 br translate_rc_and_ret2 << 300 << 301 Luser_return: << 302 GET_THREAD_INFO r11 << 303 ldw r10, TI_FLAGS(r11) << 304 ANDI32 r11, r10, _TIF_WORK_MASK << 305 beq r11, r0, restore_all << 306 BTBZ r1, r10, TIF_NEED_RESCHED, Lsi << 307 << 308 /* Reschedule work */ << 309 call schedule << 310 br ret_from_exception << 311 << 312 Lsignal_return: << 313 ANDI32 r1, r10, _TIF_SIGPENDING | _TI << 314 beq r1, r0, restore_all << 315 mov r4, sp /* pt_ << 316 SAVE_SWITCH_STACK << 317 call do_notify_resume << 318 beq r2, r0, no_work_pending << 319 RESTORE_SWITCH_STACK << 320 /* prepare restart syscall here withou << 321 ldw r2, PT_R2(sp) /* reload sysc << 322 ldw r4, PT_R4(sp) /* reload sysc << 323 ldw r5, PT_R5(sp) << 324 ldw r6, PT_R6(sp) << 325 ldw r7, PT_R7(sp) << 326 ldw r8, PT_R8(sp) << 327 ldw r9, PT_R9(sp) << 328 br local_restart /* restart sys << 329 << 330 no_work_pending: << 331 RESTORE_SWITCH_STACK << 332 br ret_from_exception << 333 << 334 /********************************************* << 335 * Handle external interrupts. << 336 ********************************************* << 337 */ << 338 /* << 339 * This is the generic interrupt handler (for << 340 * sources). It figures out the vector number << 341 * interrupt service routine directly. << 342 */ << 343 external_interrupt: << 344 rdctl r12, ipending << 345 rdctl r9, ienable << 346 and r12, r12, r9 << 347 /* skip if no interrupt is pending */ << 348 beq r12, r0, ret_from_interrupt << 349 331 >> 332 .align 3 >> 333 $syscall_error: 350 /* 334 /* 351 * Process an external hardware interr !! 335 * Some system calls (e.g., ptrace) can return arbitrary >> 336 * values which might normally be mistaken as error numbers. >> 337 * Those functions must zero $0 (v0) directly in the stack >> 338 * frame to indicate that a negative return value wasn't an >> 339 * error number.. 352 */ 340 */ >> 341 ldq $19, 0($sp) /* old syscall nr (zero if success) */ >> 342 beq $19, $ret_success 353 343 354 addi ea, ea, -4 /* re-issue th !! 344 ldq $20, 72($sp) /* .. and this a3 */ 355 stw ea, PT_EA(sp) !! 345 subq $31, $0, $0 /* with error in v0 */ 356 2: movi r4, %lo(-1) /* Start from !! 346 addq $31, 1, $1 /* set a3 for errno return */ 357 highes !! 347 stq $0, 0($sp) 358 /* This is the !! 348 mov $31, $26 /* tell "ret_from_sys_call" we can restart */ 359 1: andi r10, r12, 1 /* Isolate bit !! 349 stq $1, 72($sp) /* a3 for return */ 360 srli r12, r12, 1 /* shift count !! 350 br ret_from_sys_call 361 multip !! 351 362 addi r4, r4, 1 !! 352 $ret_success: 363 beq r10, r0, 1b !! 353 stq $0, 0($sp) 364 mov r5, sp /* Setup pt_re !! 354 stq $31, 72($sp) /* a3=0 => no error */ 365 call do_IRQ !! 355 br ret_from_sys_call 366 rdctl r12, ipending /* check again !! 356 .end entSys 367 rdctl r9, ienable /* Isolate pos !! 357 368 and r12, r12, r9 !! 358 /* 369 bne r12, r0, 2b !! 359 * Do all cleanup when returning from all interrupts and system calls. 370 /* br ret_from_interrupt */ /* fall !! 360 * 371 !! 361 * Arguments: 372 ENTRY(ret_from_interrupt) !! 362 * $5: TI_FLAGS. 373 ldw r1, PT_ESTATUS(sp) /* che !! 363 * $8: current. 374 TSTBNZ r1, r1, ESTATUS_EU, Luser_retu !! 364 * $19: The old syscall number, or zero if this is not a return 375 !! 365 * from a syscall that errored and is possibly restartable. 376 #ifdef CONFIG_PREEMPTION !! 366 * $20: Error indication. 377 GET_THREAD_INFO r1 !! 367 */ 378 ldw r4, TI_PREEMPT_COUNT(r1) !! 368 379 bne r4, r0, restore_all !! 369 .align 4 380 ldw r4, TI_FLAGS(r1) !! 370 .ent work_pending 381 BTBZ r10, r4, TIF_NEED_RESCHED, res !! 371 work_pending: 382 ldw r4, PT_ESTATUS(sp) /* ? I !! 372 and $5, _TIF_NEED_RESCHED, $2 383 andi r10, r4, ESTATUS_EPIE !! 373 beq $2, $work_notifysig 384 beq r10, r0, restore_all !! 374 385 call preempt_schedule_irq !! 375 $work_resched: 386 #endif !! 376 subq $sp, 16, $sp >> 377 stq $19, 0($sp) /* save syscall nr */ >> 378 stq $20, 8($sp) /* and error indication (a3) */ >> 379 jsr $26, schedule >> 380 ldq $19, 0($sp) >> 381 ldq $20, 8($sp) >> 382 addq $sp, 16, $sp >> 383 /* Make sure need_resched and sigpending don't change between >> 384 sampling and the rti. */ >> 385 lda $16, 7 >> 386 call_pal PAL_swpipl >> 387 ldl $5, TI_FLAGS($8) >> 388 and $5, _TIF_WORK_MASK, $2 >> 389 beq $2, restore_all >> 390 and $5, _TIF_NEED_RESCHED, $2 >> 391 bne $2, $work_resched >> 392 >> 393 $work_notifysig: >> 394 mov $sp, $17 >> 395 br $1, do_switch_stack >> 396 mov $5, $21 >> 397 mov $sp, $18 >> 398 mov $31, $16 >> 399 jsr $26, do_notify_resume >> 400 bsr $1, undo_switch_stack 387 br restore_all 401 br restore_all >> 402 .end work_pending 388 403 389 /********************************************* !! 404 /* 390 * A few syscall wrappers !! 405 * PTRACE syscall handler 391 ********************************************* !! 406 */ 392 */ << 393 /* << 394 * int clone(unsigned long clone_flags, unsign << 395 * int __user * parent_tidptr, in << 396 * int tls_val) << 397 */ << 398 ENTRY(sys_clone) << 399 SAVE_SWITCH_STACK << 400 subi sp, sp, 4 /* make space for tl << 401 stw r8, 0(sp) /* pass tls pointer << 402 call nios2_clone << 403 addi sp, sp, 4 << 404 RESTORE_SWITCH_STACK << 405 ret << 406 << 407 ENTRY(sys_rt_sigreturn) << 408 SAVE_SWITCH_STACK << 409 mov r4, sp << 410 call do_rt_sigreturn << 411 RESTORE_SWITCH_STACK << 412 addi ra, ra, (end_translate_rc_and_ << 413 ret << 414 << 415 /********************************************* << 416 * A few other wrappers and stubs << 417 ********************************************* << 418 */ << 419 protection_exception_pte: << 420 rdctl r6, pteaddr << 421 slli r6, r6, 10 << 422 call do_page_fault << 423 br ret_from_exception << 424 << 425 protection_exception_ba: << 426 rdctl r6, badaddr << 427 call do_page_fault << 428 br ret_from_exception << 429 << 430 protection_exception_instr: << 431 call handle_supervisor_instr << 432 br ret_from_exception << 433 << 434 handle_breakpoint: << 435 call breakpoint_c << 436 br ret_from_exception << 437 << 438 #ifdef CONFIG_NIOS2_ALIGNMENT_TRAP << 439 handle_unaligned: << 440 SAVE_SWITCH_STACK << 441 call handle_unaligned_c << 442 RESTORE_SWITCH_STACK << 443 br ret_from_exception << 444 #else << 445 handle_unaligned: << 446 call handle_unaligned_c << 447 br ret_from_exception << 448 #endif << 449 407 450 handle_illegal: !! 408 .align 4 451 call handle_illegal_c !! 409 .ent strace 452 br ret_from_exception !! 410 strace: 453 !! 411 /* set up signal stack, call syscall_trace */ 454 handle_diverror: !! 412 bsr $1, do_switch_stack 455 call handle_diverror_c !! 413 jsr $26, syscall_trace 456 br ret_from_exception !! 414 bsr $1, undo_switch_stack 457 !! 415 458 #ifdef CONFIG_KGDB !! 416 /* get the system call number and the arguments back.. */ 459 handle_kgdb_breakpoint: !! 417 ldq $0, 0($sp) 460 call kgdb_breakpoint_c !! 418 ldq $16, SP_OFF+24($sp) 461 br ret_from_exception !! 419 ldq $17, SP_OFF+32($sp) 462 #endif !! 420 ldq $18, SP_OFF+40($sp) >> 421 ldq $19, 72($sp) >> 422 ldq $20, 80($sp) >> 423 ldq $21, 88($sp) >> 424 >> 425 /* get the system call pointer.. */ >> 426 lda $1, NR_SYSCALLS($31) >> 427 lda $2, sys_call_table >> 428 lda $27, alpha_ni_syscall >> 429 cmpult $0, $1, $1 >> 430 s8addq $0, $2, $2 >> 431 beq $1, 1f >> 432 ldq $27, 0($2) >> 433 1: jsr $26, ($27), sys_gettimeofday >> 434 ldgp $gp, 0($26) >> 435 >> 436 /* check return.. */ >> 437 blt $0, $strace_error /* the call failed */ >> 438 stq $31, 72($sp) /* a3=0 => no error */ >> 439 $strace_success: >> 440 stq $0, 0($sp) /* save return value */ >> 441 >> 442 bsr $1, do_switch_stack >> 443 jsr $26, syscall_trace >> 444 bsr $1, undo_switch_stack >> 445 br $31, ret_from_sys_call >> 446 >> 447 .align 3 >> 448 $strace_error: >> 449 ldq $19, 0($sp) /* old syscall nr (zero if success) */ >> 450 beq $19, $strace_success >> 451 ldq $20, 72($sp) /* .. and this a3 */ >> 452 >> 453 subq $31, $0, $0 /* with error in v0 */ >> 454 addq $31, 1, $1 /* set a3 for errno return */ >> 455 stq $0, 0($sp) >> 456 stq $1, 72($sp) /* a3 for return */ >> 457 >> 458 bsr $1, do_switch_stack >> 459 mov $19, $9 /* save old syscall number */ >> 460 mov $20, $10 /* save old a3 */ >> 461 jsr $26, syscall_trace >> 462 mov $9, $19 >> 463 mov $10, $20 >> 464 bsr $1, undo_switch_stack >> 465 >> 466 mov $31, $26 /* tell "ret_from_sys_call" we can restart */ >> 467 br ret_from_sys_call >> 468 .end strace >> 469 >> 470 /* >> 471 * Save and restore the switch stack -- aka the balance of the user context. >> 472 */ 463 473 464 handle_trap_1: !! 474 .align 4 465 call handle_trap_1_c !! 475 .ent do_switch_stack 466 br ret_from_exception !! 476 do_switch_stack: >> 477 lda $sp, -SWITCH_STACK_SIZE($sp) >> 478 stq $9, 0($sp) >> 479 stq $10, 8($sp) >> 480 stq $11, 16($sp) >> 481 stq $12, 24($sp) >> 482 stq $13, 32($sp) >> 483 stq $14, 40($sp) >> 484 stq $15, 48($sp) >> 485 stq $26, 56($sp) >> 486 stt $f0, 64($sp) >> 487 stt $f1, 72($sp) >> 488 stt $f2, 80($sp) >> 489 stt $f3, 88($sp) >> 490 stt $f4, 96($sp) >> 491 stt $f5, 104($sp) >> 492 stt $f6, 112($sp) >> 493 stt $f7, 120($sp) >> 494 stt $f8, 128($sp) >> 495 stt $f9, 136($sp) >> 496 stt $f10, 144($sp) >> 497 stt $f11, 152($sp) >> 498 stt $f12, 160($sp) >> 499 stt $f13, 168($sp) >> 500 stt $f14, 176($sp) >> 501 stt $f15, 184($sp) >> 502 stt $f16, 192($sp) >> 503 stt $f17, 200($sp) >> 504 stt $f18, 208($sp) >> 505 stt $f19, 216($sp) >> 506 stt $f20, 224($sp) >> 507 stt $f21, 232($sp) >> 508 stt $f22, 240($sp) >> 509 stt $f23, 248($sp) >> 510 stt $f24, 256($sp) >> 511 stt $f25, 264($sp) >> 512 stt $f26, 272($sp) >> 513 stt $f27, 280($sp) >> 514 mf_fpcr $f0 # get fpcr >> 515 stt $f28, 288($sp) >> 516 stt $f29, 296($sp) >> 517 stt $f30, 304($sp) >> 518 stt $f0, 312($sp) # save fpcr in slot of $f31 >> 519 ldt $f0, 64($sp) # dont let "do_switch_stack" change fp state. >> 520 ret $31, ($1), 1 >> 521 .end do_switch_stack >> 522 >> 523 .align 4 >> 524 .ent undo_switch_stack >> 525 undo_switch_stack: >> 526 ldq $9, 0($sp) >> 527 ldq $10, 8($sp) >> 528 ldq $11, 16($sp) >> 529 ldq $12, 24($sp) >> 530 ldq $13, 32($sp) >> 531 ldq $14, 40($sp) >> 532 ldq $15, 48($sp) >> 533 ldq $26, 56($sp) >> 534 ldt $f30, 312($sp) # get saved fpcr >> 535 ldt $f0, 64($sp) >> 536 ldt $f1, 72($sp) >> 537 ldt $f2, 80($sp) >> 538 ldt $f3, 88($sp) >> 539 mt_fpcr $f30 # install saved fpcr >> 540 ldt $f4, 96($sp) >> 541 ldt $f5, 104($sp) >> 542 ldt $f6, 112($sp) >> 543 ldt $f7, 120($sp) >> 544 ldt $f8, 128($sp) >> 545 ldt $f9, 136($sp) >> 546 ldt $f10, 144($sp) >> 547 ldt $f11, 152($sp) >> 548 ldt $f12, 160($sp) >> 549 ldt $f13, 168($sp) >> 550 ldt $f14, 176($sp) >> 551 ldt $f15, 184($sp) >> 552 ldt $f16, 192($sp) >> 553 ldt $f17, 200($sp) >> 554 ldt $f18, 208($sp) >> 555 ldt $f19, 216($sp) >> 556 ldt $f20, 224($sp) >> 557 ldt $f21, 232($sp) >> 558 ldt $f22, 240($sp) >> 559 ldt $f23, 248($sp) >> 560 ldt $f24, 256($sp) >> 561 ldt $f25, 264($sp) >> 562 ldt $f26, 272($sp) >> 563 ldt $f27, 280($sp) >> 564 ldt $f28, 288($sp) >> 565 ldt $f29, 296($sp) >> 566 ldt $f30, 304($sp) >> 567 lda $sp, SWITCH_STACK_SIZE($sp) >> 568 ret $31, ($1), 1 >> 569 .end undo_switch_stack >> 570 >> 571 /* >> 572 * The meat of the context switch code. >> 573 */ >> 574 >> 575 .align 4 >> 576 .globl alpha_switch_to >> 577 .ent alpha_switch_to >> 578 alpha_switch_to: >> 579 .prologue 0 >> 580 bsr $1, do_switch_stack >> 581 call_pal PAL_swpctx >> 582 lda $8, 0x3fff >> 583 bsr $1, undo_switch_stack >> 584 bic $sp, $8, $8 >> 585 mov $17, $0 >> 586 ret >> 587 .end alpha_switch_to 467 588 468 handle_trap_2: !! 589 /* 469 call handle_trap_2_c !! 590 * New processes begin life here. 470 br ret_from_exception !! 591 */ 471 592 472 handle_trap_3: !! 593 .globl ret_from_fork 473 handle_trap_reserved: !! 594 .align 4 474 call handle_trap_3_c !! 595 .ent ret_from_fork 475 br ret_from_exception !! 596 ret_from_fork: >> 597 lda $26, ret_from_sys_call >> 598 mov $17, $16 >> 599 jmp $31, schedule_tail >> 600 .end ret_from_fork 476 601 477 /* 602 /* 478 * Beware - when entering resume, prev (the cu !! 603 * kernel_thread(fn, arg, clone_flags) 479 * in r4, next (the new task) is in r5, don't << 480 * registers. << 481 */ 604 */ 482 ENTRY(resume) !! 605 .align 4 >> 606 .globl kernel_thread >> 607 .ent kernel_thread >> 608 kernel_thread: >> 609 /* We can be called from a module. */ >> 610 ldgp $gp, 0($27) >> 611 .prologue 1 >> 612 subq $sp, SP_OFF+6*8, $sp >> 613 br $1, 2f /* load start address */ >> 614 >> 615 /* We've now "returned" from a fake system call. */ >> 616 unop >> 617 blt $0, 1f /* error? */ >> 618 ldi $1, 0x3fff >> 619 beq $20, 1f /* parent or child? */ >> 620 >> 621 bic $sp, $1, $8 /* in child. */ >> 622 jsr $26, ($27) >> 623 ldgp $gp, 0($26) >> 624 mov $0, $16 >> 625 mov $31, $26 >> 626 jmp $31, sys_exit >> 627 >> 628 1: ret /* in parent. */ >> 629 >> 630 .align 4 >> 631 2: /* Fake a system call stack frame, as we can't do system calls >> 632 from kernel space. Note that we store FN and ARG as they >> 633 need to be set up in the child for the call. Also store $8 >> 634 and $26 for use in the parent. */ >> 635 stq $31, SP_OFF($sp) /* ps */ >> 636 stq $1, SP_OFF+8($sp) /* pc */ >> 637 stq $gp, SP_OFF+16($sp) /* gp */ >> 638 stq $16, 136($sp) /* $27; FN for child */ >> 639 stq $17, SP_OFF+24($sp) /* $16; ARG for child */ >> 640 stq $8, 64($sp) /* $8 */ >> 641 stq $26, 128($sp) /* $26 */ >> 642 /* Avoid the HAE being gratuitously wrong, to avoid restoring it. */ >> 643 ldq $2, alpha_mv+HAE_CACHE >> 644 stq $2, 152($sp) /* HAE */ >> 645 >> 646 /* Shuffle FLAGS to the front; add CLONE_VM. */ >> 647 ldi $1, CLONE_VM|CLONE_UNTRACED >> 648 or $18, $1, $16 >> 649 bsr $26, sys_clone >> 650 >> 651 /* We don't actually care for a3 success widgetry in the kernel. >> 652 Not for positive errno values. */ >> 653 stq $0, 0($sp) /* $0 */ >> 654 br restore_all >> 655 .end kernel_thread 483 656 484 rdctl r7, status !! 657 /* 485 stw r7, TASK_THREAD + THREAD_KPSR( !! 658 * execve(path, argv, envp) >> 659 */ >> 660 .align 4 >> 661 .globl execve >> 662 .ent execve >> 663 execve: >> 664 /* We can be called from a module. */ >> 665 ldgp $gp, 0($27) >> 666 lda $sp, -(32+SIZEOF_PT_REGS+8)($sp) >> 667 .frame $sp, 32+SIZEOF_PT_REGS+8, $26, 0 >> 668 stq $26, 0($sp) >> 669 stq $16, 8($sp) >> 670 stq $17, 16($sp) >> 671 stq $18, 24($sp) >> 672 .prologue 1 >> 673 >> 674 lda $16, 32($sp) >> 675 lda $17, 0 >> 676 lda $18, SIZEOF_PT_REGS >> 677 bsr $26, memset !samegp >> 678 >> 679 /* Avoid the HAE being gratuitously wrong, which would cause us >> 680 to do the whole turn off interrupts thing and restore it. */ >> 681 ldq $2, alpha_mv+HAE_CACHE >> 682 stq $2, 152+32($sp) >> 683 >> 684 ldq $16, 8($sp) >> 685 ldq $17, 16($sp) >> 686 ldq $18, 24($sp) >> 687 lda $19, 32($sp) >> 688 bsr $26, do_execve !samegp >> 689 >> 690 ldq $26, 0($sp) >> 691 bne $0, 1f /* error! */ >> 692 >> 693 /* Move the temporary pt_regs struct from its current location >> 694 to the top of the kernel stack frame. See copy_thread for >> 695 details for a normal process. */ >> 696 lda $16, 0x4000 - SIZEOF_PT_REGS($8) >> 697 lda $17, 32($sp) >> 698 lda $18, SIZEOF_PT_REGS >> 699 bsr $26, memmove !samegp >> 700 >> 701 /* Take that over as our new stack frame and visit userland! */ >> 702 lda $sp, 0x4000 - SIZEOF_PT_REGS($8) >> 703 br $31, ret_from_sys_call 486 704 487 andi r7, r7, %lo(~STATUS_PIE) !! 705 1: lda $sp, 32+SIZEOF_PT_REGS+8($sp) 488 wrctl status, r7 !! 706 ret >> 707 .end execve 489 708 490 SAVE_SWITCH_STACK !! 709 491 stw sp, TASK_THREAD + THREAD_KSP(r !! 710 /* 492 ldw sp, TASK_THREAD + THREAD_KSP(r !! 711 * Special system calls. Most of these are special in that they either 493 movia r24, _current_thread !! 712 * have to play switch_stack games or in some way use the pt_regs struct. 494 GET_THREAD_INFO r1 !! 713 */ 495 stw r1, 0(r24) !! 714 .align 4 496 RESTORE_SWITCH_STACK !! 715 .globl sys_fork >> 716 .ent sys_fork >> 717 sys_fork: >> 718 .prologue 0 >> 719 mov $sp, $21 >> 720 bsr $1, do_switch_stack >> 721 bis $31, SIGCHLD, $16 >> 722 mov $31, $17 >> 723 mov $31, $18 >> 724 mov $31, $19 >> 725 mov $31, $20 >> 726 jsr $26, alpha_clone >> 727 bsr $1, undo_switch_stack >> 728 ret >> 729 .end sys_fork 497 730 498 ldw r7, TASK_THREAD + THREAD_KPSR( !! 731 .align 4 499 wrctl status, r7 !! 732 .globl sys_clone >> 733 .ent sys_clone >> 734 sys_clone: >> 735 .prologue 0 >> 736 mov $sp, $21 >> 737 bsr $1, do_switch_stack >> 738 /* $16, $17, $18, $19, $20 come from the user. */ >> 739 jsr $26, alpha_clone >> 740 bsr $1, undo_switch_stack 500 ret 741 ret >> 742 .end sys_clone 501 743 502 ENTRY(ret_from_fork) !! 744 .align 4 503 call schedule_tail !! 745 .globl sys_vfork 504 br ret_from_exception !! 746 .ent sys_vfork >> 747 sys_vfork: >> 748 .prologue 0 >> 749 mov $sp, $16 >> 750 bsr $1, do_switch_stack >> 751 jsr $26, alpha_vfork >> 752 bsr $1, undo_switch_stack >> 753 ret >> 754 .end sys_vfork 505 755 506 ENTRY(ret_from_kernel_thread) !! 756 .align 4 507 call schedule_tail !! 757 .globl sys_sigreturn 508 mov r4,r17 /* arg */ !! 758 .ent sys_sigreturn 509 callr r16 /* function */ !! 759 sys_sigreturn: 510 br ret_from_exception !! 760 .prologue 0 >> 761 mov $sp, $17 >> 762 lda $18, -SWITCH_STACK_SIZE($sp) >> 763 lda $sp, -SWITCH_STACK_SIZE($sp) >> 764 jsr $26, do_sigreturn >> 765 br $1, undo_switch_stack >> 766 br ret_from_sys_call >> 767 .end sys_sigreturn >> 768 >> 769 .align 4 >> 770 .globl sys_rt_sigreturn >> 771 .ent sys_rt_sigreturn >> 772 sys_rt_sigreturn: >> 773 .prologue 0 >> 774 mov $sp, $17 >> 775 lda $18, -SWITCH_STACK_SIZE($sp) >> 776 lda $sp, -SWITCH_STACK_SIZE($sp) >> 777 jsr $26, do_rt_sigreturn >> 778 br $1, undo_switch_stack >> 779 br ret_from_sys_call >> 780 .end sys_rt_sigreturn >> 781 >> 782 .align 4 >> 783 .globl sys_sigsuspend >> 784 .ent sys_sigsuspend >> 785 sys_sigsuspend: >> 786 .prologue 0 >> 787 mov $sp, $17 >> 788 br $1, do_switch_stack >> 789 mov $sp, $18 >> 790 subq $sp, 16, $sp >> 791 stq $26, 0($sp) >> 792 jsr $26, do_sigsuspend >> 793 ldq $26, 0($sp) >> 794 lda $sp, SWITCH_STACK_SIZE+16($sp) >> 795 ret >> 796 .end sys_sigsuspend 511 797 512 /* !! 798 .align 4 513 * Kernel user helpers. !! 799 .globl sys_rt_sigsuspend 514 * !! 800 .ent sys_rt_sigsuspend 515 * Each segment is 64-byte aligned and will be !! 801 sys_rt_sigsuspend: 516 * New segments (if ever needed) must be added !! 802 .prologue 0 517 * This mechanism should be used only for thin !! 803 mov $sp, $18 518 * justified, and not be abused freely. !! 804 br $1, do_switch_stack 519 * !! 805 mov $sp, $19 520 */ !! 806 subq $sp, 16, $sp >> 807 stq $26, 0($sp) >> 808 jsr $26, do_rt_sigsuspend >> 809 ldq $26, 0($sp) >> 810 lda $sp, SWITCH_STACK_SIZE+16($sp) >> 811 ret >> 812 .end sys_rt_sigsuspend 521 813 522 /* Filling pads with undefined instructions. !! 814 .align 4 523 .macro kuser_pad sym size !! 815 .globl sys_sethae 524 .if ((. - \sym) & 3) !! 816 .ent sys_sethae 525 .rept (4 - (. - \sym) & 3) !! 817 sys_sethae: 526 .byte 0 !! 818 .prologue 0 527 .endr !! 819 stq $16, 152($sp) 528 .endif !! 820 ret 529 .rept ((\size - (. - \sym)) / 4) !! 821 .end sys_sethae 530 .word 0xdeadbeef << 531 .endr << 532 .endm << 533 << 534 .align 6 << 535 .globl __kuser_helper_start << 536 __kuser_helper_start: << 537 822 538 __kuser_helper_version: !! 823 .align 4 539 .word ((__kuser_helper_end - __kuser !! 824 .globl osf_getpriority >> 825 .ent osf_getpriority >> 826 osf_getpriority: >> 827 lda $sp, -16($sp) >> 828 stq $26, 0($sp) >> 829 .prologue 0 >> 830 >> 831 jsr $26, sys_getpriority >> 832 >> 833 ldq $26, 0($sp) >> 834 blt $0, 1f >> 835 >> 836 /* Return value is the unbiased priority, i.e. 20 - prio. >> 837 This does result in negative return values, so signal >> 838 no error by writing into the R0 slot. */ >> 839 lda $1, 20 >> 840 stq $31, 16($sp) >> 841 subl $1, $0, $0 >> 842 unop 540 843 541 __kuser_cmpxchg: !! 844 1: lda $sp, 16($sp) 542 /* !! 845 ret 543 * r4 pointer to exchange variable !! 846 .end osf_getpriority 544 * r5 old value !! 847 545 * r6 new value !! 848 .align 4 546 */ !! 849 .globl sys_getxuid 547 cmpxchg_ldw: !! 850 .ent sys_getxuid 548 ldw r2, 0(r4) !! 851 sys_getxuid: 549 sub r2, r2, r5 !! 852 .prologue 0 550 bne r2, zero, cmpxchg_ret !! 853 ldq $2, TI_TASK($8) >> 854 ldl $0, TASK_UID($2) >> 855 ldl $1, TASK_EUID($2) >> 856 stq $1, 80($sp) >> 857 ret >> 858 .end sys_getxuid 551 859 552 /* We had a match, store the new value !! 860 .align 4 553 cmpxchg_stw: !! 861 .globl sys_getxgid 554 stw r6, 0(r4) !! 862 .ent sys_getxgid 555 cmpxchg_ret: !! 863 sys_getxgid: >> 864 .prologue 0 >> 865 ldq $2, TI_TASK($8) >> 866 ldl $0, TASK_GID($2) >> 867 ldl $1, TASK_EGID($2) >> 868 stq $1, 80($sp) 556 ret 869 ret >> 870 .end sys_getxgid 557 871 558 kuser_pad __kuser_cmpxchg, 64 !! 872 .align 4 >> 873 .globl sys_getxpid >> 874 .ent sys_getxpid >> 875 sys_getxpid: >> 876 .prologue 0 >> 877 ldq $2, TI_TASK($8) >> 878 >> 879 /* See linux/kernel/timer.c sys_getppid for discussion >> 880 about this loop. */ >> 881 ldq $3, TASK_REAL_PARENT($2) >> 882 1: ldl $1, TASK_TGID($3) >> 883 #ifdef CONFIG_SMP >> 884 mov $3, $4 >> 885 mb >> 886 ldq $3, TASK_REAL_PARENT($2) >> 887 cmpeq $3, $4, $4 >> 888 beq $4, 1b >> 889 #endif >> 890 stq $1, 80($sp) >> 891 ldl $0, TASK_TGID($2) >> 892 ret >> 893 .end sys_getxpid 559 894 560 .globl __kuser_sigtramp !! 895 .align 4 561 __kuser_sigtramp: !! 896 .globl sys_pipe 562 movi r2, __NR_rt_sigreturn !! 897 .ent sys_pipe 563 trap !! 898 sys_pipe: >> 899 lda $sp, -16($sp) >> 900 stq $26, 0($sp) >> 901 .prologue 0 >> 902 >> 903 lda $16, 8($sp) >> 904 jsr $26, do_pipe >> 905 >> 906 ldq $26, 0($sp) >> 907 bne $0, 1f >> 908 >> 909 /* The return values are in $0 and $20. */ >> 910 ldl $1, 12($sp) >> 911 ldl $0, 8($sp) 564 912 565 kuser_pad __kuser_sigtramp, 64 !! 913 stq $1, 80+16($sp) >> 914 1: lda $sp, 16($sp) >> 915 ret >> 916 .end sys_pipe 566 917 567 .globl __kuser_helper_end !! 918 .align 4 568 __kuser_helper_end: !! 919 .globl sys_ptrace >> 920 .ent sys_ptrace >> 921 sys_ptrace: >> 922 .prologue 0 >> 923 mov $sp, $20 >> 924 jmp $31, do_sys_ptrace >> 925 .end sys_ptrace >> 926 >> 927 .align 4 >> 928 .globl alpha_ni_syscall >> 929 .ent alpha_ni_syscall >> 930 alpha_ni_syscall: >> 931 .prologue 0 >> 932 /* Special because it also implements overflow handling via >> 933 syscall number 0. And if you recall, zero is a special >> 934 trigger for "not an error". Store large non-zero there. */ >> 935 lda $0, -ENOSYS >> 936 unop >> 937 stq $0, 0($sp) >> 938 ret >> 939 .end alpha_ni_syscall
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.