scall_64.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:7k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file "COPYING" in the main directory of this archive
  4.  * for more details.
  5.  *
  6.  * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01 by Ralf Baechle
  7.  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8.  * Copyright (C) 2001 MIPS Technologies, Inc.
  9.  */
  10. #include <linux/config.h>
  11. #include <asm/asm.h>
  12. #include <linux/errno.h>
  13. #include <asm/current.h>
  14. #include <asm/mipsregs.h>
  15. #include <asm/regdef.h>
  16. #include <asm/stackframe.h>
  17. #include <asm/unistd.h>
  18. /* This duplicates the definition from <linux/sched.h> */
  19. #define PT_TRACESYS 0x00000002 /* tracing system calls */
  20. /* This duplicates the definition from <asm/signal.h> */
  21. #define SIGILL 4 /* Illegal instruction (ANSI).  */
  22. #ifndef CONFIG_MIPS32_COMPAT
  23. #define handle_sys64 handle_sys
  24. #endif
  25. .align  5
  26. NESTED(handle_sys64, PT_SIZE, sp)
  27. /* When 32-bit compatibility is configured scall_o32.S already did this.  */
  28. #ifndef CONFIG_MIPS32_COMPAT
  29. .set noat
  30. SAVE_SOME
  31. STI
  32. .set at
  33. #endif
  34. ld t1, PT_EPC(sp) # skip syscall on return
  35. subu t0, v0, __NR_Linux # check syscall number
  36. sltiu t0, t0, __NR_Linux_syscalls + 1
  37. daddiu t1, 4 # skip to next instruction
  38. beqz t0, illegal_syscall
  39. sd t1, PT_EPC(sp)
  40. dsll t0, v0, 3 # offset into table
  41. ld t2, (sys_call_table - (__NR_Linux * 8))(t0) # syscall routine
  42. sd a3, PT_R26(sp) # save a3 for syscall restarting
  43. ld t0, TASK_PTRACE($28) # syscall tracing enabled?
  44. andi t0, PT_TRACESYS
  45. bnez t0, trace_a_syscall
  46. jalr t2 # Do The Real Thing (TM)
  47. li t0, -EMAXERRNO - 1 # error?
  48. sltu t0, t0, v0
  49. sd t0, PT_R7(sp) # set error flag
  50. beqz t0, 1f
  51. negu v0 # error
  52. sd v0, PT_R0(sp) # set flag for syscall restarting
  53. 1: sd v0, PT_R2(sp) # result
  54. ret_from_sys_call:
  55. mfc0 t0, CP0_STATUS
  56. xori t0, t0, 1
  57. ori t0, t0, 1
  58. mtc0 t0, CP0_STATUS
  59. ld t2, TASK_NEED_RESCHED($28)
  60. bnez t2, reschedule
  61. lw v0, TASK_SIGPENDING($28)
  62. bnez v0, signal_return
  63. restore_all:
  64. RESTORE_SOME
  65. RESTORE_SP
  66. eret
  67. /* Put this behind restore_all for the sake of the branch prediction.  */
  68. signal_return:
  69. .type signal_return, @function
  70. mfc0 t0, CP0_STATUS
  71. ori t0, t0, 1
  72. mtc0 t0, CP0_STATUS
  73. move a0, zero
  74. move a1, sp
  75. jal do_signal
  76. b restore_all
  77. reschedule:
  78. SAVE_STATIC
  79. jal schedule
  80. b ret_from_sys_call
  81. /* ------------------------------------------------------------------------ */
  82. trace_a_syscall:
  83. SAVE_STATIC
  84. sd t2,PT_R1(sp)
  85. jal syscall_trace
  86. ld t2,PT_R1(sp)
  87. ld a0, PT_R4(sp) # Restore argument registers
  88. ld a1, PT_R5(sp)
  89. ld a2, PT_R6(sp)
  90. ld a3, PT_R7(sp)
  91. jalr t2
  92. li t0, -EMAXERRNO - 1 # error?
  93. sltu t0, t0, v0
  94. sd t0, PT_R7(sp) # set error flag
  95. beqz t0, 1f
  96. negu v0 # error
  97. sd v0, PT_R0(sp) # set flag for syscall restarting
  98. 1: sd v0, PT_R2(sp) # result
  99. jal syscall_trace
  100. j ret_from_sys_call
  101. illegal_syscall:
  102. /* This also isn't a 64-bit syscall, throw an error.  */
  103. li v0, ENOSYS # error
  104. sd v0, PT_R2(sp)
  105. li t0, 1 # set error flag
  106. sd t0, PT_R7(sp)
  107. j ret_from_sys_call
  108. END(handle_sys64)
  109. sys_call_table:
  110. PTR sys_syscall /* 5000 */
  111. PTR sys_exit
  112. PTR sys_fork
  113. PTR sys_read
  114. PTR sys_write
  115. PTR sys_open /* 5005 */
  116. PTR sys_close
  117. PTR sys_waitpid
  118. PTR sys_creat
  119. PTR sys_link
  120. PTR sys_unlink /* 5010 */
  121. PTR sys_execve
  122. PTR sys_chdir
  123. PTR sys_time
  124. PTR sys_mknod
  125. PTR sys_chmod /* 5015 */
  126. PTR sys_lchown
  127. PTR sys_ni_syscall
  128. PTR sys_stat
  129. PTR sys_lseek
  130. PTR sys_getpid /* 5020 */
  131. PTR sys_mount
  132. PTR sys_oldumount
  133. PTR sys_setuid
  134. PTR sys_getuid
  135. PTR sys_stime /* 5025 */
  136. PTR sys_ni_syscall /* ptrace */
  137. PTR sys_alarm
  138. PTR sys_fstat
  139. PTR sys_pause
  140. PTR sys_utime /* 5030 */
  141. PTR sys_ni_syscall
  142. PTR sys_ni_syscall
  143. PTR sys_access
  144. PTR sys_nice
  145. PTR sys_ni_syscall /* 5035 */
  146. PTR sys_sync
  147. PTR sys_kill
  148. PTR sys_rename
  149. PTR sys_mkdir
  150. PTR sys_rmdir /* 5040 */
  151. PTR sys_dup
  152. PTR sys_pipe
  153. PTR sys_times
  154. PTR sys_ni_syscall
  155. PTR sys_brk /* 5045 */
  156. PTR sys_setgid
  157. PTR sys_getgid
  158. PTR sys_ni_syscall /* was signal 2 */
  159. PTR sys_geteuid
  160. PTR sys_getegid /* 5050 */
  161. PTR sys_acct
  162. PTR sys_umount
  163. PTR sys_ni_syscall
  164. PTR sys_ioctl
  165. PTR sys_fcntl /* 5055 */
  166. PTR sys_ni_syscall
  167. PTR sys_setpgid
  168. PTR sys_ni_syscall
  169. PTR sys_ni_syscall
  170. PTR sys_umask /* 5060 */
  171. PTR sys_chroot
  172. PTR sys_ustat
  173. PTR sys_dup2
  174. PTR sys_getppid
  175. PTR sys_getpgrp /* 5065 */
  176. PTR sys_setsid
  177. PTR sys_sigaction
  178. PTR sys_sgetmask
  179. PTR sys_ssetmask
  180. PTR sys_setreuid /* 5070 */
  181. PTR sys_setregid
  182. PTR sys_sigsuspend
  183. PTR sys_sigpending
  184. PTR sys_sethostname
  185. PTR sys_setrlimit /* 5075 */
  186. PTR sys_getrlimit
  187. PTR sys_getrusage
  188. PTR sys_gettimeofday
  189. PTR sys_settimeofday
  190. PTR sys_getgroups /* 5080 */
  191. PTR sys_setgroups
  192. PTR sys_ni_syscall /* old_select */
  193. PTR sys_symlink
  194. PTR sys_lstat
  195. PTR sys_readlink /* 5085 */
  196. PTR sys_uselib
  197. PTR sys_swapon
  198. PTR sys_reboot
  199. PTR sys_ni_syscall /* old_readdir */
  200. PTR sys_mmap /* 5090 */
  201. PTR sys_munmap
  202. PTR sys_truncate
  203. PTR sys_ftruncate
  204. PTR sys_fchmod
  205. PTR sys_fchown /* 5095 */
  206. PTR sys_getpriority
  207. PTR sys_setpriority
  208. PTR sys_ni_syscall
  209. PTR sys_statfs
  210. PTR sys_fstatfs /* 5100 */
  211. PTR sys_ni_syscall /* sys_ioperm */
  212. PTR sys_socketcall
  213. PTR sys_syslog
  214. PTR sys_setitimer
  215. PTR sys_getitimer /* 5105 */
  216. PTR sys_newstat
  217. PTR sys_newlstat
  218. PTR sys_newfstat
  219. PTR sys_ni_syscall
  220. PTR sys_ni_syscall /* sys_ioperm  *//* 5110 */
  221. PTR sys_vhangup
  222. PTR sys_ni_syscall /* was sys_idle  */
  223. PTR sys_ni_syscall /* sys_vm86 */
  224. PTR sys_wait4
  225. PTR sys_swapoff /* 5115 */
  226. PTR sys_sysinfo
  227. PTR sys_ipc
  228. PTR sys_fsync
  229. PTR sys_sigreturn
  230. PTR sys_clone /* 5120 */
  231. PTR sys_setdomainname
  232. PTR sys_newuname
  233. PTR sys_ni_syscall /* sys_modify_ldt */
  234. PTR sys_adjtimex
  235. PTR sys_mprotect /* 5125 */
  236. PTR sys_sigprocmask
  237. PTR sys_create_module
  238. PTR sys_init_module
  239. PTR sys_delete_module
  240. PTR sys_get_kernel_syms  /* 5130 */
  241. PTR sys_quotactl
  242. PTR sys_getpgid
  243. PTR sys_fchdir
  244. PTR sys_bdflush
  245. PTR sys_sysfs /* 5135 */
  246. PTR sys_personality
  247. PTR sys_ni_syscall /* for afs_syscall */
  248. PTR sys_setfsuid
  249. PTR sys_setfsgid
  250. PTR sys_llseek /* 5140 */
  251. PTR sys_getdents
  252. PTR sys_select
  253. PTR sys_flock
  254. PTR sys_msync
  255. PTR sys_readv /* 5145 */
  256. PTR sys_writev
  257. PTR sys_cacheflush
  258. PTR sys_cachectl
  259. PTR sys_sysmips
  260. PTR sys_ni_syscall /* 5150 */
  261. PTR sys_getsid
  262. PTR sys_fdatasync
  263. PTR sys_sysctl
  264. PTR sys_mlock
  265. PTR sys_munlock /* 5155 */
  266. PTR sys_mlockall
  267. PTR sys_munlockall
  268. PTR sys_sched_setparam
  269. PTR sys_sched_getparam
  270. PTR sys_sched_setscheduler /* 5160 */
  271. PTR sys_sched_getscheduler
  272. PTR sys_sched_yield
  273. PTR sys_sched_get_priority_max
  274. PTR sys_sched_get_priority_min
  275. PTR sys_sched_rr_get_interval /* 5165 */
  276. PTR sys_nanosleep
  277. PTR sys_mremap
  278. PTR sys_accept
  279. PTR sys_bind
  280. PTR sys_connect /* 5170 */
  281. PTR sys_getpeername
  282. PTR sys_getsockname
  283. PTR sys_getsockopt
  284. PTR sys_listen
  285. PTR sys_recv /* 5175 */
  286. PTR sys_recvfrom
  287. PTR sys_recvmsg
  288. PTR sys_send
  289. PTR sys_sendmsg
  290. PTR sys_sendto /* 5180 */
  291. PTR sys_setsockopt
  292. PTR sys_shutdown
  293. PTR sys_socket
  294. PTR sys_socketpair
  295. PTR sys_setresuid /* 5185 */
  296. PTR sys_getresuid
  297. PTR sys_query_module
  298. PTR sys_poll
  299. PTR sys_nfsservctl
  300. PTR sys_setresgid /* 5190 */
  301. PTR sys_getresgid
  302. PTR sys_prctl
  303. PTR sys_rt_sigreturn
  304. PTR sys_rt_sigaction
  305. PTR sys_rt_sigprocmask  /* 5195 */
  306. PTR sys_rt_sigpending
  307. PTR sys_rt_sigtimedwait
  308. PTR sys_rt_sigqueueinfo
  309. PTR sys_rt_sigsuspend
  310. PTR sys_pread /* 5200 */
  311. PTR sys_pwrite
  312. PTR sys_chown
  313. PTR sys_getcwd
  314. PTR sys_capget
  315. PTR sys_capset /* 5205 */
  316. PTR sys_sigaltstack
  317. PTR sys_sendfile
  318. PTR sys_ni_syscall
  319. PTR sys_ni_syscall
  320. PTR sys_pivot_root /* 5210 */
  321. PTR sys_mincore
  322. PTR sys_madvise
  323. PTR sys_getdents64