syscall.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2009 by Michael Van Canneyt and David Zhang
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {No debugging for syslinux include !}
  11. {$IFDEF SYS_LINUX}
  12. {$UNDEF SYSCALL_DEBUG}
  13. {$ENDIF SYS_LINUX}
  14. {$define FPC_SYSTEM_HAS_FPFORK}
  15. {
  16. behaviour of result of fork on sparc/linux is different than on other
  17. linux flavours
  18. }
  19. function Fpfork : pid_t; [public, alias : 'FPC_SYSC_FORK'];assembler;
  20. asm
  21. li $2,4002
  22. syscall
  23. nop
  24. beq $7,$0,.LDone
  25. nop
  26. move $a0,$2
  27. jal SetErrno
  28. nop
  29. li $2,-1
  30. .LDone:
  31. end;
  32. {*****************************************************************************
  33. --- Main:The System Call Self ---
  34. *****************************************************************************}
  35. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  36. {
  37. This function puts the registers in place, does the call, and then
  38. copies back the registers as they are after the SysCall.
  39. }
  40. asm
  41. move $v0,$a0
  42. syscall
  43. nop
  44. beq $7,$0,.LDone
  45. nop
  46. move $a0,$2
  47. jal SetErrno
  48. nop
  49. li $2,-1
  50. .LDone:
  51. end;
  52. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  53. {
  54. This function puts the registers in place, does the call, and then
  55. copies back the registers as they are after the SysCall.
  56. }
  57. asm
  58. move $v0,$a0
  59. move $a0,$a1
  60. syscall
  61. nop
  62. beq $7,$0,.LDone
  63. nop
  64. move $a0,$2
  65. jal SetErrno
  66. nop
  67. li $2,-1
  68. .LDone:
  69. end;
  70. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  71. {
  72. This function puts the registers in place, does the call, and then
  73. copies back the registers as they are after the SysCall.
  74. }
  75. asm
  76. move $v0,$a0
  77. move $a0,$a1
  78. move $a1,$a2
  79. syscall
  80. nop
  81. beq $7,$0,.LDone
  82. nop
  83. move $a0,$2
  84. jal SetErrno
  85. nop
  86. li $2,-1
  87. .LDone:
  88. end;
  89. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  90. {
  91. This function puts the registers in place, does the call, and then
  92. copies back the registers as they are after the SysCall.
  93. }
  94. asm
  95. move $v0,$a0
  96. move $a0,$a1
  97. move $a1,$a2
  98. move $a2,$a3
  99. syscall
  100. nop
  101. beq $7,$0,.LDone
  102. nop
  103. move $a0,$2
  104. jal SetErrno
  105. nop
  106. li $2,-1
  107. .LDone:
  108. end;
  109. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  110. {
  111. This function puts the registers in place, does the call, and then
  112. copies back the registers as they are after the SysCall.
  113. }
  114. asm
  115. move $v0,$a0
  116. move $a0,$a1
  117. move $a1,$a2
  118. move $a2,$a3
  119. lw $a3,param4
  120. syscall
  121. nop
  122. beq $7,$0,.LDone
  123. nop
  124. move $a0,$2
  125. jal SetErrno
  126. nop
  127. li $2,-1
  128. .LDone:
  129. end;
  130. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  131. {
  132. This function puts the registers in place, does the call, and then
  133. copies back the registers as they are after the SysCall.
  134. }
  135. asm
  136. move $v0,$a0
  137. move $a0,$a1
  138. move $a1,$a2
  139. move $a2,$a3
  140. lw $a3,param4
  141. lw $t0,param5
  142. sw $t0,16($sp)
  143. syscall
  144. nop
  145. beq $7,$0,.LDone
  146. nop
  147. move $a0,$2
  148. jal SetErrno
  149. nop
  150. li $2,-1
  151. .LDone:
  152. end;
  153. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  154. {
  155. This function puts the registers in place, does the call, and then
  156. copies back the registers as they are after the SysCall.
  157. }
  158. asm
  159. move $v0,$a0
  160. move $a0,$a1
  161. move $a1,$a2
  162. move $a2,$a3
  163. lw $a3,param4
  164. lw $t0,param5
  165. sw $t0,16($sp)
  166. lw $t0,param6
  167. sw $t0,20($sp)
  168. syscall
  169. nop
  170. beq $7,$0,.LDone
  171. nop
  172. move $a0,$2
  173. jal SetErrno
  174. nop
  175. li $2,-1
  176. .LDone:
  177. end;