syscalls.S 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* Automatically generated; do not edit */
  2. /*
  3. * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
  4. * The President and Fellows of Harvard College.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. /*
  31. * This file is copied to syscalls.S, and then the actual syscalls are
  32. * appended as lines of the form
  33. * SYSCALL(symbol, number)
  34. *
  35. * Warning: gccs before 3.0 run cpp in -traditional mode on .S files.
  36. * So if you use an older gcc you'll need to change the token pasting
  37. * in SYSCALL().
  38. */
  39. #include <kern/syscall.h>
  40. #include <machine/regdefs.h>
  41. /*
  42. * Definition for each syscall.
  43. * All we do is load the syscall number into v0, the register the
  44. * kernel expects to find it in, and jump to the shared syscall code.
  45. * (Note that the addiu instruction is in the jump's delay slot.)
  46. */
  47. #define SYSCALL(sym, num) \
  48. .set noreorder ; \
  49. .globl sym ; \
  50. .type sym,@function ; \
  51. .ent sym ; \
  52. sym: ; \
  53. j __syscall ; \
  54. addiu v0, $0, SYS_##sym ; \
  55. .end sym ; \
  56. .set reorder
  57. /*
  58. * Now, the shared system call code.
  59. * The MIPS syscall ABI is as follows:
  60. *
  61. * On entry, call number in v0. The rest is like a normal function
  62. * call: four args in a0-a3, the other args on the stack.
  63. *
  64. * On successful return, zero in a3 register; return value in v0
  65. * (v0 and v1 for a 64-bit return value).
  66. *
  67. * On error return, nonzero in a3 register; errno value in v0.
  68. *
  69. * The use of a3 as a return register to hold the success flag is
  70. * gross, but I didn't make it up.
  71. *
  72. * Note that by longstanding Unix convention and POSIX decree, errno
  73. * is not to be set unless the call actually fails.
  74. */
  75. .set noreorder
  76. .text
  77. .type __syscall,@function
  78. .ent __syscall
  79. __syscall:
  80. syscall /* make system call */
  81. beq a3, $0, 1f /* if a3 is zero, call succeeded */
  82. nop /* delay slot */
  83. sw v0, errno /* call failed: store errno */
  84. li v1, -1 /* and force return value to -1 */
  85. li v0, -1
  86. 1:
  87. j ra /* return */
  88. nop /* delay slot */
  89. .end __syscall
  90. .set reorder
  91. SYSCALL(fork, 0)
  92. SYSCALL(vfork, 1)
  93. SYSCALL(execv, 2)
  94. SYSCALL(_exit, 3)
  95. SYSCALL(waitpid, 4)
  96. SYSCALL(getpid, 5)
  97. SYSCALL(getppid, 6)
  98. SYSCALL(sbrk, 7)
  99. SYSCALL(mmap, 8)
  100. SYSCALL(munmap, 9)
  101. SYSCALL(mprotect, 10)
  102. SYSCALL(umask, 17)
  103. SYSCALL(issetugid, 18)
  104. SYSCALL(getresuid, 19)
  105. SYSCALL(setresuid, 20)
  106. SYSCALL(getresgid, 21)
  107. SYSCALL(setresgid, 22)
  108. SYSCALL(getgroups, 23)
  109. SYSCALL(setgroups, 24)
  110. SYSCALL(__getlogin, 25)
  111. SYSCALL(__setlogin, 26)
  112. SYSCALL(kill, 27)
  113. SYSCALL(sigaction, 28)
  114. SYSCALL(sigpending, 29)
  115. SYSCALL(sigprocmask, 30)
  116. SYSCALL(sigsuspend, 31)
  117. SYSCALL(sigreturn, 32)
  118. SYSCALL(open, 45)
  119. SYSCALL(pipe, 46)
  120. SYSCALL(dup, 47)
  121. SYSCALL(dup2, 48)
  122. SYSCALL(close, 49)
  123. SYSCALL(read, 50)
  124. SYSCALL(pread, 51)
  125. SYSCALL(getdirentry, 54)
  126. SYSCALL(write, 55)
  127. SYSCALL(pwrite, 56)
  128. SYSCALL(lseek, 59)
  129. SYSCALL(flock, 60)
  130. SYSCALL(ftruncate, 61)
  131. SYSCALL(fsync, 62)
  132. SYSCALL(fcntl, 63)
  133. SYSCALL(ioctl, 64)
  134. SYSCALL(select, 65)
  135. SYSCALL(poll, 66)
  136. SYSCALL(link, 67)
  137. SYSCALL(remove, 68)
  138. SYSCALL(mkdir, 69)
  139. SYSCALL(rmdir, 70)
  140. SYSCALL(mkfifo, 71)
  141. SYSCALL(rename, 72)
  142. SYSCALL(access, 73)
  143. SYSCALL(chdir, 74)
  144. SYSCALL(fchdir, 75)
  145. SYSCALL(__getcwd, 76)
  146. SYSCALL(symlink, 77)
  147. SYSCALL(readlink, 78)
  148. SYSCALL(mount, 79)
  149. SYSCALL(unmount, 80)
  150. SYSCALL(stat, 81)
  151. SYSCALL(fstat, 82)
  152. SYSCALL(lstat, 83)
  153. SYSCALL(utimes, 84)
  154. SYSCALL(futimes, 85)
  155. SYSCALL(lutimes, 86)
  156. SYSCALL(chmod, 87)
  157. SYSCALL(chown, 88)
  158. SYSCALL(fchmod, 89)
  159. SYSCALL(fchown, 90)
  160. SYSCALL(lchmod, 91)
  161. SYSCALL(lchown, 92)
  162. SYSCALL(socket, 98)
  163. SYSCALL(bind, 99)
  164. SYSCALL(connect, 100)
  165. SYSCALL(listen, 101)
  166. SYSCALL(accept, 102)
  167. SYSCALL(shutdown, 104)
  168. SYSCALL(getsockname, 105)
  169. SYSCALL(getpeername, 106)
  170. SYSCALL(getsockopt, 107)
  171. SYSCALL(setsockopt, 108)
  172. SYSCALL(__time, 113)
  173. SYSCALL(__settime, 114)
  174. SYSCALL(nanosleep, 115)
  175. SYSCALL(sync, 118)
  176. SYSCALL(reboot, 119)