entry64.S 5.2 KB

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