syscall.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  4. member of the Free Pascal development team.
  5. The syscalls for the new RTL, moved to platform dependant dir.
  6. Old linux calling convention is stil kept.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$ASMMODE GAS}
  14. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  15. asm
  16. movq sysnr, %rax { Syscall number -> rax. }
  17. syscall { Do the system call. }
  18. cmpq $-4095, %rax { Check %rax for error. }
  19. jnae .LSyscOK { Jump to error handler if error. }
  20. negq %rax
  21. movq %rax,%rdx
  22. movq fpc_threadvar_relocate_proc,%rax
  23. testq %rax,%rax
  24. jne .LThread
  25. movl %edx,Errno+8
  26. jmp .LNoThread
  27. .LThread:
  28. pushq %rdx
  29. movq Errno,%rdi
  30. call *%rax
  31. popq %rdx
  32. movl %edx,(%rax)
  33. .LNoThread:
  34. movq $-1,%rax
  35. .LSyscOK:
  36. end;
  37. function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  38. asm
  39. movq sysnr, %rax { Syscall number -> rax. }
  40. movq param1, %rdi { shift arg1 - arg5. }
  41. syscall { Do the system call. }
  42. cmpq $-4095, %rax { Check %rax for error. }
  43. jnae .LSyscOK { Jump to error handler if error. }
  44. negq %rax
  45. movq %rax,%rdx
  46. movq fpc_threadvar_relocate_proc,%rax
  47. testq %rax,%rax
  48. jne .LThread
  49. movl %edx,Errno+8
  50. jmp .LNoThread
  51. .LThread:
  52. pushq %rdx
  53. movq Errno,%rdi
  54. call *%rax
  55. popq %rdx
  56. movl %edx,(%rax)
  57. .LNoThread:
  58. movq $-1,%rax
  59. .LSyscOK:
  60. end;
  61. function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  62. asm
  63. movq sysnr, %rax { Syscall number -> rax. }
  64. movq param1, %rdi { shift arg1 - arg5. }
  65. movq param2, %rsi
  66. syscall { Do the system call. }
  67. cmpq $-4095, %rax { Check %rax for error. }
  68. jnae .LSyscOK { Jump to error handler if error. }
  69. negq %rax
  70. movq %rax,%rdx
  71. movq fpc_threadvar_relocate_proc,%rax
  72. testq %rax,%rax
  73. jne .LThread
  74. movl %edx,Errno+8
  75. jmp .LNoThread
  76. .LThread:
  77. pushq %rdx
  78. movq Errno,%rdi
  79. call *%rax
  80. popq %rdx
  81. movl %edx,(%rax)
  82. .LNoThread:
  83. movq $-1,%rax
  84. .LSyscOK:
  85. end;
  86. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  87. asm
  88. movq sysnr, %rax { Syscall number -> rax. }
  89. movq param1, %rdi { shift arg1 - arg5. }
  90. movq param2, %rsi
  91. movq param3, %rdx
  92. syscall { Do the system call. }
  93. cmpq $-4095, %rax { Check %rax for error. }
  94. jnae .LSyscOK { Jump to error handler if error. }
  95. negq %rax
  96. movq %rax,%rdx
  97. movq fpc_threadvar_relocate_proc,%rax
  98. testq %rax,%rax
  99. jne .LThread
  100. movl %edx,Errno+8
  101. jmp .LNoThread
  102. .LThread:
  103. pushq %rdx
  104. movq Errno,%rdi
  105. call *%rax
  106. popq %rdx
  107. movl %edx,(%rax)
  108. .LNoThread:
  109. movq $-1,%rax
  110. .LSyscOK:
  111. end;
  112. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  113. asm
  114. movq sysnr, %rax { Syscall number -> rax. }
  115. movq param1, %rdi { shift arg1 - arg5. }
  116. movq param2, %rsi
  117. movq param3, %rdx
  118. movq param4, %r10
  119. syscall { Do the system call. }
  120. cmpq $-4095, %rax { Check %rax for error. }
  121. jnae .LSyscOK { Jump to error handler if error. }
  122. negq %rax
  123. movq %rax,%rdx
  124. movq fpc_threadvar_relocate_proc,%rax
  125. testq %rax,%rax
  126. jne .LThread
  127. movl %edx,Errno+8
  128. jmp .LNoThread
  129. .LThread:
  130. pushq %rdx
  131. movq Errno,%rdi
  132. call *%rax
  133. popq %rdx
  134. movl %edx,(%rax)
  135. .LNoThread:
  136. movq $-1,%rax
  137. .LSyscOK:
  138. end;
  139. function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  140. asm
  141. movq sysnr, %rax { Syscall number -> rax. }
  142. movq param1, %rdi { shift arg1 - arg5. }
  143. movq param2, %rsi
  144. movq param3, %rdx
  145. movq param4, %r10
  146. movq param5, %r8
  147. syscall { Do the system call. }
  148. cmpq $-4095, %rax { Check %rax for error. }
  149. jnae .LSyscOK { Jump to error handler if error. }
  150. negq %rax
  151. movq %rax,%rdx
  152. movq fpc_threadvar_relocate_proc,%rax
  153. testq %rax,%rax
  154. jne .LThread
  155. movl %edx,Errno+8
  156. jmp .LNoThread
  157. .LThread:
  158. pushq %rdx
  159. movq Errno,%rdi
  160. call *%rax
  161. popq %rdx
  162. movl %edx,(%rax)
  163. .LNoThread:
  164. movq $-1,%rax
  165. .LSyscOK:
  166. end;
  167. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  168. asm
  169. movq sysnr, %rax { Syscall number -> rax. }
  170. movq param1, %rdi { shift arg1 - arg5. }
  171. movq param2, %rsi
  172. movq param3, %rdx
  173. movq param4, %r10
  174. movq param5, %r8
  175. movq param6, %r9
  176. syscall { Do the system call. }
  177. cmpq $-4095, %rax { Check %rax for error. }
  178. jnae .LSyscOK { Jump to error handler if error. }
  179. negq %rax
  180. movq %rax,%rdx
  181. movq fpc_threadvar_relocate_proc,%rax
  182. testq %rax,%rax
  183. jne .LThread
  184. movl %edx,Errno+8
  185. jmp .LNoThread
  186. .LThread:
  187. pushq %rdx
  188. movq Errno,%rdi
  189. call *%rax
  190. popq %rdx
  191. movl %edx,(%rax)
  192. .LNoThread:
  193. movq $-1,%rax
  194. .LSyscOK:
  195. end;
  196. {No debugging for syslinux include !}
  197. {$IFDEF SYS_LINUX}
  198. {$UNDEF SYSCALL_DEBUG}
  199. {$ENDIF SYS_LINUX}