Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: entry64.S,v 1.7 2002/02/09 19:49:31 davem Exp $ |
| 2 | * entry64.S: Solaris syscall emulation entry point. |
| 3 | * |
| 4 | * Copyright (C) 1996,1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 5 | * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu) |
| 6 | * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx) |
| 7 | */ |
| 8 | |
| 9 | #include <linux/errno.h> |
| 10 | |
| 11 | #include <asm/head.h> |
| 12 | #include <asm/asi.h> |
| 13 | #include <asm/smp.h> |
| 14 | #include <asm/ptrace.h> |
| 15 | #include <asm/page.h> |
| 16 | #include <asm/signal.h> |
| 17 | #include <asm/pgtable.h> |
| 18 | #include <asm/processor.h> |
| 19 | #include <asm/thread_info.h> |
| 20 | |
| 21 | #include "conv.h" |
| 22 | |
| 23 | #define NR_SYSCALLS 256 |
| 24 | |
| 25 | .text |
| 26 | solaris_syscall_trace: |
David S. Miller | 8d8a647 | 2005-07-10 16:55:48 -0700 | [diff] [blame] | 27 | add %sp, PTREGS_OFF, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | call syscall_trace |
David S. Miller | 8d8a647 | 2005-07-10 16:55:48 -0700 | [diff] [blame] | 29 | mov 0, %o1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | srl %i0, 0, %o0 |
| 31 | mov %i4, %o4 |
| 32 | srl %i1, 0, %o1 |
| 33 | mov %i5, %o5 |
| 34 | andcc %l3, 1, %g0 |
| 35 | be,pt %icc, 2f |
| 36 | srl %i2, 0, %o2 |
| 37 | b,pt %xcc, 2f |
| 38 | add %sp, PTREGS_OFF, %o0 |
| 39 | |
| 40 | solaris_sucks: |
| 41 | /* Solaris is a big system which needs to be able to do all the things |
| 42 | * in Inf+1 different ways */ |
| 43 | add %i6, 0x5c, %o0 |
| 44 | mov %i0, %g1 |
| 45 | mov %i1, %i0 |
| 46 | mov %i2, %i1 |
| 47 | srl %o0, 0, %o0 |
| 48 | mov %i3, %i2 |
| 49 | movrz %g1, 256, %g1 /* Ensure we don't loop forever */ |
| 50 | mov %i4, %i3 |
| 51 | mov %i5, %i4 |
| 52 | ba,pt %xcc, solaris_sparc_syscall |
| 53 | exen: lduwa [%o0] ASI_S, %i5 |
| 54 | |
| 55 | exenf: ba,pt %xcc, solaris_sparc_syscall |
| 56 | clr %i5 |
| 57 | |
| 58 | /* For shared binaries, binfmt_elf32 already sets up personality |
| 59 | and exec_domain. This is to handle static binaries as well */ |
| 60 | solaris_reg: |
| 61 | call solaris_register |
| 62 | nop |
| 63 | ba,pt %xcc, 1f |
| 64 | mov %i4, %o4 |
| 65 | |
| 66 | linux_syscall_for_solaris: |
| 67 | sethi %hi(sys_call_table32), %l6 |
| 68 | or %l6, %lo(sys_call_table32), %l6 |
| 69 | sll %l3, 2, %l4 |
| 70 | ba,pt %xcc, 10f |
| 71 | lduw [%l6 + %l4], %l3 |
| 72 | |
| 73 | /* Solaris system calls enter here... */ |
| 74 | .align 32 |
| 75 | .globl solaris_sparc_syscall, entry64_personality_patch |
| 76 | solaris_sparc_syscall: |
| 77 | entry64_personality_patch: |
| 78 | ldub [%g4 + 0x0], %l0 |
| 79 | cmp %g1, 255 |
| 80 | bg,pn %icc, solaris_unimplemented |
| 81 | srl %g1, 0, %g1 |
| 82 | sethi %hi(solaris_sys_table), %l7 |
| 83 | or %l7, %lo(solaris_sys_table), %l7 |
| 84 | brz,pn %g1, solaris_sucks |
| 85 | mov %i4, %o4 |
| 86 | sll %g1, 2, %l4 |
| 87 | cmp %l0, 1 |
| 88 | bne,pn %icc, solaris_reg |
| 89 | 1: srl %i0, 0, %o0 |
| 90 | lduw [%l7 + %l4], %l3 |
| 91 | srl %i1, 0, %o1 |
| 92 | ldx [%g6 + TI_FLAGS], %l5 |
| 93 | cmp %l3, NR_SYSCALLS |
| 94 | bleu,a,pn %xcc, linux_syscall_for_solaris |
| 95 | nop |
| 96 | andcc %l3, 1, %g0 |
| 97 | bne,a,pn %icc, 10f |
| 98 | add %sp, PTREGS_OFF, %o0 |
| 99 | 10: srl %i2, 0, %o2 |
| 100 | mov %i5, %o5 |
| 101 | andn %l3, 3, %l7 |
| 102 | andcc %l5, _TIF_SYSCALL_TRACE, %g0 |
| 103 | bne,pn %icc, solaris_syscall_trace |
| 104 | mov %i0, %l5 |
| 105 | 2: call %l7 |
| 106 | srl %i3, 0, %o3 |
| 107 | ret_from_solaris: |
| 108 | stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] |
| 109 | ldx [%g6 + TI_FLAGS], %l6 |
| 110 | sra %o0, 0, %o0 |
| 111 | mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2 |
| 112 | ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3 |
| 113 | cmp %o0, -ERESTART_RESTARTBLOCK |
| 114 | sllx %g2, 32, %g2 |
| 115 | bgeu,pn %xcc, 1f |
| 116 | andcc %l6, _TIF_SYSCALL_TRACE, %l6 |
| 117 | |
| 118 | /* System call success, clear Carry condition code. */ |
| 119 | andn %g3, %g2, %g3 |
| 120 | stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] |
| 121 | bne,pn %icc, solaris_syscall_trace2 |
| 122 | ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 |
| 123 | andcc %l1, 1, %g0 |
| 124 | bne,pn %icc, 2f |
| 125 | clr %l6 |
| 126 | add %l1, 0x4, %l2 |
| 127 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc |
| 128 | call rtrap |
| 129 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4 |
| 130 | |
| 131 | /* When tnpc & 1, this comes from setcontext and we don't want to advance pc */ |
| 132 | 2: andn %l1, 3, %l1 |
| 133 | call rtrap |
| 134 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc&~3 |
| 135 | |
| 136 | 1: |
| 137 | /* System call failure, set Carry condition code. |
| 138 | * Also, get abs(errno) to return to the process. |
| 139 | */ |
| 140 | sub %g0, %o0, %o0 |
| 141 | or %g3, %g2, %g3 |
| 142 | cmp %o0, ERANGE /* 0-ERANGE are identity mapped */ |
| 143 | bleu,pt %icc, 1f |
| 144 | cmp %o0, EMEDIUMTYPE |
| 145 | bgu,pn %icc, 1f |
| 146 | sethi %hi(solaris_err_table), %l6 |
| 147 | sll %o0, 2, %o0 |
| 148 | or %l6, %lo(solaris_err_table), %l6 |
| 149 | ldsw [%l6 + %o0], %o0 |
| 150 | 1: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] |
| 151 | mov 1, %l6 |
| 152 | stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] |
| 153 | bne,pn %icc, solaris_syscall_trace2 |
| 154 | ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 |
| 155 | andcc %l1, 1, %g0 |
| 156 | bne,pn %icc, 2b |
| 157 | add %l1, 0x4, %l2 |
| 158 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc |
| 159 | call rtrap |
| 160 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4 |
| 161 | |
| 162 | solaris_syscall_trace2: |
David S. Miller | 8d8a647 | 2005-07-10 16:55:48 -0700 | [diff] [blame] | 163 | add %sp, PTREGS_OFF, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | call syscall_trace |
David S. Miller | 8d8a647 | 2005-07-10 16:55:48 -0700 | [diff] [blame] | 165 | mov 1, %o1 |
| 166 | add %l1, 0x4, %l2 /* npc = npc+4 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | andcc %l1, 1, %g0 |
| 168 | bne,pn %icc, 2b |
| 169 | nop |
| 170 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] |
| 171 | call rtrap |
| 172 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] |
| 173 | |
| 174 | /* This one is tricky, so that's why we do it in assembly */ |
| 175 | .globl solaris_sigsuspend |
| 176 | solaris_sigsuspend: |
| 177 | call do_sol_sigsuspend |
| 178 | nop |
| 179 | brlz,pn %o0, ret_from_solaris |
| 180 | nop |
| 181 | call sys_sigsuspend |
| 182 | stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] |
David S. Miller | 2d7d5f0 | 2006-01-19 02:42:49 -0800 | [diff] [blame] | 183 | b,pt %xcc, ret_from_solaris |
| 184 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
| 186 | .globl solaris_getpid |
| 187 | solaris_getpid: |
| 188 | call sys_getppid |
| 189 | nop |
| 190 | call sys_getpid |
| 191 | stx %o0, [%sp + PTREGS_OFF + PT_V9_I1] |
| 192 | b,pt %xcc, ret_from_solaris |
| 193 | nop |
| 194 | |
| 195 | .globl solaris_getuid |
| 196 | solaris_getuid: |
| 197 | call sys_geteuid |
| 198 | nop |
| 199 | call sys_getuid |
| 200 | stx %o1, [%sp + PTREGS_OFF + PT_V9_I1] |
| 201 | b,pt %xcc, ret_from_solaris |
| 202 | nop |
| 203 | |
| 204 | .globl solaris_getgid |
| 205 | solaris_getgid: |
| 206 | call sys_getegid |
| 207 | nop |
| 208 | call sys_getgid |
| 209 | stx %o1, [%sp + PTREGS_OFF + PT_V9_I1] |
| 210 | b,pt %xcc, ret_from_solaris |
| 211 | nop |
| 212 | |
| 213 | .globl solaris_unimplemented |
| 214 | solaris_unimplemented: |
| 215 | call do_sol_unimplemented |
| 216 | add %sp, PTREGS_OFF, %o0 |
| 217 | ba,pt %xcc, ret_from_solaris |
| 218 | nop |
| 219 | |
David S. Miller | 4d000d5 | 2006-03-04 23:23:56 -0800 | [diff] [blame] | 220 | .section __ex_table,"a" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | .align 4 |
| 222 | .word exen, exenf |
| 223 | |