syscall.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. { This variable is needed in syscall.inc assembler code }
  15. var
  16. fpc_threadvar_relocate_proc : TRelocateThreadVarHandler; public name 'FPC_THREADVAR_RELOCATE';
  17. {$define THREADVAR_RELOCATED_ALREADY_DEFINED}
  18. {$define FPC_SYSTEM_HAS_FPFORK}
  19. {
  20. behaviour of result of fork on sparc/linux is different than on other
  21. linux flavours
  22. }
  23. function Fpfork : pid_t; [public, alias : 'FPC_SYSC_FORK'];assembler;
  24. asm
  25. li $2,4002
  26. syscall
  27. nop
  28. beq $7,$0,.LDone
  29. nop
  30. move $a0,$2
  31. jal SetErrno
  32. nop
  33. li $2,-1
  34. .LDone:
  35. end;
  36. {*****************************************************************************
  37. --- Main:The System Call Self ---
  38. *****************************************************************************}
  39. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  40. {
  41. This function puts the registers in place, does the call, and then
  42. copies back the registers as they are after the SysCall.
  43. }
  44. asm
  45. move $v0,$a0
  46. syscall
  47. nop
  48. beq $7,$0,.LDone
  49. nop
  50. move $a0,$2
  51. jal SetErrno
  52. nop
  53. li $2,-1
  54. .LDone:
  55. end;
  56. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  57. {
  58. This function puts the registers in place, does the call, and then
  59. copies back the registers as they are after the SysCall.
  60. }
  61. asm
  62. move $v0,$a0
  63. move $a0,$a1
  64. syscall
  65. nop
  66. beq $7,$0,.LDone
  67. nop
  68. move $a0,$2
  69. jal SetErrno
  70. nop
  71. li $2,-1
  72. .LDone:
  73. end;
  74. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  75. {
  76. This function puts the registers in place, does the call, and then
  77. copies back the registers as they are after the SysCall.
  78. }
  79. asm
  80. move $v0,$a0
  81. move $a0,$a1
  82. move $a1,$a2
  83. syscall
  84. nop
  85. beq $7,$0,.LDone
  86. nop
  87. move $a0,$2
  88. jal SetErrno
  89. nop
  90. li $2,-1
  91. .LDone:
  92. end;
  93. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  94. {
  95. This function puts the registers in place, does the call, and then
  96. copies back the registers as they are after the SysCall.
  97. }
  98. asm
  99. move $v0,$a0
  100. move $a0,$a1
  101. move $a1,$a2
  102. move $a2,$a3
  103. syscall
  104. nop
  105. beq $7,$0,.LDone
  106. nop
  107. move $a0,$2
  108. jal SetErrno
  109. nop
  110. li $2,-1
  111. .LDone:
  112. end;
  113. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  114. {
  115. This function puts the registers in place, does the call, and then
  116. copies back the registers as they are after the SysCall.
  117. }
  118. asm
  119. move $v0,$a0
  120. move $a0,$a1
  121. move $a1,$a2
  122. move $a2,$a3
  123. lw $a3,param4
  124. syscall
  125. nop
  126. beq $7,$0,.LDone
  127. nop
  128. move $a0,$2
  129. jal SetErrno
  130. nop
  131. li $2,-1
  132. .LDone:
  133. end;
  134. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  135. {
  136. This function puts the registers in place, does the call, and then
  137. copies back the registers as they are after the SysCall.
  138. }
  139. asm
  140. move $v0,$a0
  141. move $a0,$a1
  142. move $a1,$a2
  143. move $a2,$a3
  144. lw $a3,param4
  145. lw $t0,param5
  146. sw $t0,16($sp)
  147. syscall
  148. nop
  149. beq $7,$0,.LDone
  150. nop
  151. move $a0,$2
  152. jal SetErrno
  153. nop
  154. li $2,-1
  155. .LDone:
  156. end;
  157. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  158. {
  159. This function puts the registers in place, does the call, and then
  160. copies back the registers as they are after the SysCall.
  161. }
  162. asm
  163. move $v0,$a0
  164. move $a0,$a1
  165. move $a1,$a2
  166. move $a2,$a3
  167. lw $a3,param4
  168. lw $t0,param5
  169. sw $t0,16($sp)
  170. lw $t0,param6
  171. sw $t0,20($sp)
  172. syscall
  173. nop
  174. beq $7,$0,.LDone
  175. nop
  176. move $a0,$2
  177. jal SetErrno
  178. nop
  179. li $2,-1
  180. .LDone:
  181. end;