syscall.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. movq %rsi, %rdi { shift arg1 - arg5. }
  19. movq %rdx, %rsi
  20. movq %rcx, %rdx
  21. movq %r8, %r10
  22. movq %r9, %r8
  23. syscall { Do the system call. }
  24. cmpq $-4095, %rax { Check %rax for error. }
  25. jnae .LSyscOK { Jump to error handler if error. }
  26. negq %rax
  27. movq %rax,%rdx
  28. movq FPC_THREADVAR_RELOCATE,%rax
  29. testq %rax,%rax
  30. jne .LThread
  31. movq %rdx,Errno+4
  32. jmp .LNoThread
  33. .LThread:
  34. pushq %rdx
  35. pushq Errno
  36. call *%rax
  37. popq %rdx
  38. movq %rdx,(%rax)
  39. .LNoThread:
  40. movq $-1,%rax
  41. .LSyscOK:
  42. end;
  43. function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  44. asm
  45. movq sysnr, %rax { Syscall number -> rax. }
  46. movq param1, %rdi { shift arg1 - arg5. }
  47. syscall { Do the system call. }
  48. cmpq $-4095, %rax { Check %rax for error. }
  49. jnae .LSyscOK { Jump to error handler if error. }
  50. negq %rax
  51. movq %rax,%rdx
  52. movq FPC_THREADVAR_RELOCATE,%rax
  53. testq %rax,%rax
  54. jne .LThread
  55. movq %rdx,Errno+4
  56. jmp .LNoThread
  57. .LThread:
  58. pushq %rdx
  59. pushq Errno
  60. call *%rax
  61. popq %rdx
  62. movq %rdx,(%rax)
  63. .LNoThread:
  64. movq $-1,%rax
  65. .LSyscOK:
  66. end;
  67. function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  68. asm
  69. movq sysnr, %rax { Syscall number -> rax. }
  70. movq param1, %rdi { shift arg1 - arg5. }
  71. movq param2, %rsi
  72. syscall { Do the system call. }
  73. cmpq $-4095, %rax { Check %rax for error. }
  74. jnae .LSyscOK { Jump to error handler if error. }
  75. negq %rax
  76. movq %rax,%rdx
  77. movq FPC_THREADVAR_RELOCATE,%rax
  78. testq %rax,%rax
  79. jne .LThread
  80. movq %rdx,Errno+4
  81. jmp .LNoThread
  82. .LThread:
  83. pushq %rdx
  84. pushq Errno
  85. call *%rax
  86. popq %rdx
  87. movq %rdx,(%rax)
  88. .LNoThread:
  89. movq $-1,%rax
  90. .LSyscOK:
  91. end;
  92. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  93. asm
  94. movq sysnr, %rax { Syscall number -> rax. }
  95. movq param1, %rdi { shift arg1 - arg5. }
  96. movq param2, %rsi
  97. movq param3, %rdx
  98. syscall { Do the system call. }
  99. cmpq $-4095, %rax { Check %rax for error. }
  100. jnae .LSyscOK { Jump to error handler if error. }
  101. negq %rax
  102. movq %rax,%rdx
  103. movq FPC_THREADVAR_RELOCATE,%rax
  104. testq %rax,%rax
  105. jne .LThread
  106. movq %rdx,Errno+4
  107. jmp .LNoThread
  108. .LThread:
  109. pushq %rdx
  110. pushq Errno
  111. call *%rax
  112. popq %rdx
  113. movq %rdx,(%rax)
  114. .LNoThread:
  115. movq $-1,%rax
  116. .LSyscOK:
  117. end;
  118. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  119. asm
  120. movq sysnr, %rax { Syscall number -> rax. }
  121. movq param1, %rdi { shift arg1 - arg5. }
  122. movq param2, %rsi
  123. movq param3, %rdx
  124. movq param4, %r10
  125. syscall { Do the system call. }
  126. cmpq $-4095, %rax { Check %rax for error. }
  127. jnae .LSyscOK { Jump to error handler if error. }
  128. negq %rax
  129. movq %rax,%rdx
  130. movq FPC_THREADVAR_RELOCATE,%rax
  131. testq %rax,%rax
  132. jne .LThread
  133. movq %rdx,Errno+4
  134. jmp .LNoThread
  135. .LThread:
  136. pushq %rdx
  137. pushq Errno
  138. call *%rax
  139. popq %rdx
  140. movq %rdx,(%rax)
  141. .LNoThread:
  142. movq $-1,%rax
  143. .LSyscOK:
  144. end;
  145. function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  146. asm
  147. movq sysnr, %rax { Syscall number -> rax. }
  148. movq param1, %rdi { shift arg1 - arg5. }
  149. movq param2, %rsi
  150. movq param3, %rdx
  151. movq param4, %r10
  152. movq param5, %r8
  153. syscall { Do the system call. }
  154. cmpq $-4095, %rax { Check %rax for error. }
  155. jnae .LSyscOK { Jump to error handler if error. }
  156. negq %rax
  157. movq %rax,%rdx
  158. movq FPC_THREADVAR_RELOCATE,%rax
  159. testq %rax,%rax
  160. jne .LThread
  161. movq %rdx,Errno+4
  162. jmp .LNoThread
  163. .LThread:
  164. pushq %rdx
  165. pushq Errno
  166. call *%rax
  167. popq %rdx
  168. movq %rdx,(%rax)
  169. .LNoThread:
  170. movq $-1,%rax
  171. .LSyscOK:
  172. end;
  173. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  174. asm
  175. movq sysnr, %rax { Syscall number -> rax. }
  176. movq param1, %rdi { shift arg1 - arg5. }
  177. movq param2, %rsi
  178. movq param3, %rdx
  179. movq param4, %r10
  180. movq param5, %r8
  181. movq param6, %r9
  182. syscall { Do the system call. }
  183. cmpq $-4095, %rax { Check %rax for error. }
  184. jnae .LSyscOK { Jump to error handler if error. }
  185. negq %rax
  186. movq %rax,%rdx
  187. movq FPC_THREADVAR_RELOCATE,%rax
  188. testq %rax,%rax
  189. jne .LThread
  190. movq %rdx,Errno+4
  191. jmp .LNoThread
  192. .LThread:
  193. pushq %rdx
  194. pushq Errno
  195. call *%rax
  196. popq %rdx
  197. movq %rdx,(%rax)
  198. .LNoThread:
  199. movq $-1,%rax
  200. .LSyscOK:
  201. end;
  202. {No debugging for syslinux include !}
  203. {$IFDEF SYS_LINUX}
  204. {$UNDEF SYSCALL_DEBUG}
  205. {$ENDIF SYS_LINUX}
  206. {
  207. $Log$
  208. Revision 1.5 2004-04-22 17:17:23 peter
  209. * x86-64 fixes
  210. Revision 1.4 2004/02/06 23:06:16 florian
  211. - killed tsyscallregs
  212. Revision 1.3 2004/02/06 15:58:21 florian
  213. * fixed x86-64 assembler problems
  214. Revision 1.2 2004/02/05 01:16:12 florian
  215. + completed x86-64/linux system unit
  216. Revision 1.1 2003/04/30 22:11:06 florian
  217. + for a lot of x86-64 dependend files mostly dummies added
  218. }