syscall.inc 6.3 KB

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