syscall.inc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 ATT}
  15. function FpSysCall(sysnr:TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL0'];
  16. asm
  17. { load the registers... }
  18. movl sysnr,%eax
  19. int $0x80
  20. testl %eax,%eax
  21. jns .LSyscOK
  22. negl %eax
  23. {$ifdef VER1_0}
  24. movl %eax,Errno
  25. {$else}
  26. movl %eax,%edx
  27. movl fpc_threadvar_relocate_proc,%eax
  28. testl %eax,%eax
  29. jne .LThread
  30. movl %edx,Errno+4
  31. jmp .LNoThread
  32. .LThread:
  33. pushl %edx
  34. pushl Errno
  35. call *%eax
  36. popl %edx
  37. movl %edx,(%eax)
  38. .LNoThread:
  39. {$endif}
  40. movl $-1,%eax
  41. .LSyscOK:
  42. end;
  43. function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL1'];
  44. asm
  45. { load the registers... }
  46. movl sysnr,%eax
  47. movl param1,%ebx
  48. int $0x80
  49. testl %eax,%eax
  50. jns .LSyscOK
  51. negl %eax
  52. {$ifdef VER1_0}
  53. movl %eax,Errno
  54. {$else}
  55. movl %eax,%edx
  56. movl fpc_threadvar_relocate_proc,%eax
  57. testl %eax,%eax
  58. jne .LThread
  59. movl %edx,Errno+4
  60. jmp .LNoThread
  61. .LThread:
  62. pushl %edx
  63. pushl Errno
  64. call *%eax
  65. popl %edx
  66. movl %edx,(%eax)
  67. .LNoThread:
  68. {$endif}
  69. movl $-1,%eax
  70. .LSyscOK:
  71. end;
  72. function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif} [public,alias:'FPC_SYSCALL2'];
  73. asm
  74. { load the registers... }
  75. movl sysnr,%eax
  76. movl param1,%ebx
  77. movl param2,%ecx
  78. int $0x80
  79. testl %eax,%eax
  80. jns .LSyscOK
  81. negl %eax
  82. {$ifdef VER1_0}
  83. movl %eax,Errno
  84. {$else}
  85. movl %eax,%edx
  86. movl fpc_threadvar_relocate_proc,%eax
  87. testl %eax,%eax
  88. jne .LThread
  89. movl %edx,Errno+4
  90. jmp .LNoThread
  91. .LThread:
  92. pushl %edx
  93. pushl Errno
  94. call *%eax
  95. popl %edx
  96. movl %edx,(%eax)
  97. .LNoThread:
  98. {$endif}
  99. movl $-1,%eax
  100. .LSyscOK:
  101. end;
  102. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif} [public,alias:'FPC_SYSCALL3'];
  103. asm
  104. { load the registers... }
  105. movl sysnr,%eax
  106. movl param1,%ebx
  107. movl param2,%ecx
  108. movl param3,%edx
  109. int $0x80
  110. testl %eax,%eax
  111. jns .LSyscOK
  112. negl %eax
  113. {$ifdef VER1_0}
  114. movl %eax,Errno
  115. {$else}
  116. movl %eax,%edx
  117. movl fpc_threadvar_relocate_proc,%eax
  118. testl %eax,%eax
  119. jne .LThread
  120. movl %edx,Errno+4
  121. jmp .LNoThread
  122. .LThread:
  123. pushl %edx
  124. pushl Errno
  125. call *%eax
  126. popl %edx
  127. movl %edx,(%eax)
  128. .LNoThread:
  129. {$endif}
  130. movl $-1,%eax
  131. .LSyscOK:
  132. end;
  133. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif} [public,alias:'FPC_SYSCALL4'];
  134. asm
  135. { load the registers... }
  136. movl sysnr,%eax
  137. movl param1,%ebx
  138. movl param2,%ecx
  139. movl param3,%edx
  140. movl param4,%esi
  141. int $0x80
  142. testl %eax,%eax
  143. jns .LSyscOK
  144. negl %eax
  145. {$ifdef VER1_0}
  146. movl %eax,Errno
  147. {$else}
  148. movl %eax,%edx
  149. movl fpc_threadvar_relocate_proc,%eax
  150. testl %eax,%eax
  151. jne .LThread
  152. movl %edx,Errno+4
  153. jmp .LNoThread
  154. .LThread:
  155. pushl %edx
  156. pushl Errno
  157. call *%eax
  158. popl %edx
  159. movl %edx,(%eax)
  160. .LNoThread:
  161. {$endif}
  162. movl $-1,%eax
  163. .LSyscOK:
  164. end;
  165. function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL5'];
  166. asm
  167. { load the registers... }
  168. movl sysnr,%eax
  169. movl param1,%ebx
  170. movl param2,%ecx
  171. movl param3,%edx
  172. movl param4,%esi
  173. movl param5,%edi
  174. int $0x80
  175. testl %eax,%eax
  176. jns .LSyscOK
  177. negl %eax
  178. {$ifdef VER1_0}
  179. movl %eax,Errno
  180. {$else}
  181. movl %eax,%edx
  182. movl fpc_threadvar_relocate_proc,%eax
  183. testl %eax,%eax
  184. jne .LThread
  185. movl %edx,Errno+4
  186. jmp .LNoThread
  187. .LThread:
  188. pushl %edx
  189. pushl Errno
  190. call *%eax
  191. popl %edx
  192. movl %edx,(%eax)
  193. .LNoThread:
  194. {$endif}
  195. movl $-1,%eax
  196. .LSyscOK:
  197. end;
  198. {$ifdef notsupported}
  199. { Only 5 params are pushed, so it'll not work as expected (PFV) }
  200. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL6'];
  201. asm
  202. { load the registers... }
  203. movl sysnr,%eax
  204. movl param1,%ebx
  205. movl param2,%ecx
  206. movl param3,%edx
  207. movl param4,%esi
  208. movl param5,%edi
  209. int $0x80
  210. testl %eax,%eax
  211. jns .LSyscOK
  212. negl %eax
  213. {$ifdef VER1_0}
  214. movl %eax,Errno
  215. {$else}
  216. movl %eax,%edx
  217. movl fpc_threadvar_relocate_proc,%eax
  218. testl %eax,%eax
  219. jne .LThread
  220. movl %edx,Errno+4
  221. jmp .LNoThread
  222. .LThread:
  223. pushl %edx
  224. pushl Errno
  225. call *%eax
  226. popl %edx
  227. movl %edx,(%eax)
  228. .LNoThread:
  229. {$endif}
  230. movl $-1,%eax
  231. .LSyscOK:
  232. end;
  233. {$endif notsupported}
  234. {No debugging for syslinux include !}
  235. {$IFDEF SYS_LINUX}
  236. {$UNDEF SYSCALL_DEBUG}
  237. {$ENDIF SYS_LINUX}
  238. {
  239. $Log$
  240. Revision 1.11 2004-02-06 23:06:16 florian
  241. - killed tsyscallregs
  242. Revision 1.10 2004/01/06 21:32:53 peter
  243. * use relocate_proc
  244. Revision 1.9 2003/09/14 20:15:01 marco
  245. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  246. Revision 1.7 2002/12/24 19:45:59 peter
  247. * only set errno when syscall fails
  248. Revision 1.6 2002/12/23 21:17:53 peter
  249. * MT fix
  250. Revision 1.5 2002/12/23 20:56:32 peter
  251. * Reset Errno to 0 if call is successfull
  252. * Fix broken 1.0.x Errno which does not have threadvar
  253. Revision 1.4 2002/12/18 20:41:33 peter
  254. * Threadvar support for Errno
  255. * Fixed syscall error return check
  256. * Uncommented Syscall with 6 parameters, only 5 were really set
  257. Revision 1.3 2002/12/18 16:46:37 marco
  258. * Some mods.
  259. Revision 1.2 2002/11/16 15:37:47 marco
  260. * TSysParam + result moved to -h
  261. Revision 1.1 2002/11/12 13:31:32 marco
  262. * New syscall.inc
  263. }