entry64.S 5.2 KB

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