syscall.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 ATT}
  14. function FpSysCall(sysnr:TSysParam):TSysResult; assembler; oldfpccall;[public,alias:'FPC_SYSCALL0'];
  15. asm
  16. { load the registers... }
  17. movl sysnr,%eax
  18. int $0x80
  19. cmpl $-4095,%eax
  20. jb .LSyscOK
  21. negl %eax
  22. {$ifdef REGCALL}
  23. movl fpc_threadvar_relocate_proc,%ecx
  24. testl %ecx,%ecx
  25. jne .LThread
  26. movl %eax,Errno+4
  27. jmp .LNoThread
  28. .LThread:
  29. movl %eax,%ebx
  30. movl Errno,%eax
  31. call *%ecx
  32. movl %ebx,(%eax)
  33. .LNoThread:
  34. {$else}
  35. movl %eax,%edx
  36. movl fpc_threadvar_relocate_proc,%eax
  37. testl %eax,%eax
  38. jne .LThread
  39. movl %edx,Errno+4
  40. jmp .LNoThread
  41. .LThread:
  42. pushl %edx
  43. pushl Errno
  44. call *%eax
  45. popl %edx
  46. movl %edx,(%eax)
  47. .LNoThread:
  48. {$endif REGCALL}
  49. movl $-1,%eax
  50. .LSyscOK:
  51. end;
  52. function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler; oldfpccall;[public,alias:'FPC_SYSCALL1'];
  53. asm
  54. { load the registers... }
  55. movl sysnr,%eax
  56. movl param1,%ebx
  57. int $0x80
  58. cmpl $-4095,%eax
  59. jb .LSyscOK
  60. negl %eax
  61. {$ifdef REGCALL}
  62. movl fpc_threadvar_relocate_proc,%ecx
  63. testl %ecx,%ecx
  64. jne .LThread
  65. movl %eax,Errno+4
  66. jmp .LNoThread
  67. .LThread:
  68. movl %eax,%ebx
  69. movl Errno,%eax
  70. call *%ecx
  71. movl %ebx,(%eax)
  72. .LNoThread:
  73. {$else}
  74. movl %eax,%edx
  75. movl fpc_threadvar_relocate_proc,%eax
  76. testl %eax,%eax
  77. jne .LThread
  78. movl %edx,Errno+4
  79. jmp .LNoThread
  80. .LThread:
  81. pushl %edx
  82. pushl Errno
  83. call *%eax
  84. popl %edx
  85. movl %edx,(%eax)
  86. .LNoThread:
  87. {$endif REGCALL}
  88. movl $-1,%eax
  89. .LSyscOK:
  90. end;
  91. function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler; oldfpccall; [public,alias:'FPC_SYSCALL2'];
  92. asm
  93. { load the registers... }
  94. movl sysnr,%eax
  95. movl param1,%ebx
  96. movl param2,%ecx
  97. int $0x80
  98. cmpl $-4095,%eax
  99. jb .LSyscOK
  100. negl %eax
  101. {$ifdef REGCALL}
  102. movl fpc_threadvar_relocate_proc,%ecx
  103. testl %ecx,%ecx
  104. jne .LThread
  105. movl %eax,Errno+4
  106. jmp .LNoThread
  107. .LThread:
  108. movl %eax,%ebx
  109. movl Errno,%eax
  110. call *%ecx
  111. movl %ebx,(%eax)
  112. .LNoThread:
  113. {$else}
  114. movl %eax,%edx
  115. movl fpc_threadvar_relocate_proc,%eax
  116. testl %eax,%eax
  117. jne .LThread
  118. movl %edx,Errno+4
  119. jmp .LNoThread
  120. .LThread:
  121. pushl %edx
  122. pushl Errno
  123. call *%eax
  124. popl %edx
  125. movl %edx,(%eax)
  126. .LNoThread:
  127. {$endif REGCALL}
  128. movl $-1,%eax
  129. .LSyscOK:
  130. end;
  131. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler; oldfpccall; [public,alias:'FPC_SYSCALL3'];
  132. asm
  133. { load the registers... }
  134. movl sysnr,%eax
  135. movl param1,%ebx
  136. movl param2,%ecx
  137. movl param3,%edx
  138. int $0x80
  139. cmpl $-4095,%eax
  140. jb .LSyscOK
  141. negl %eax
  142. {$ifdef REGCALL}
  143. movl fpc_threadvar_relocate_proc,%ecx
  144. testl %ecx,%ecx
  145. jne .LThread
  146. movl %eax,Errno+4
  147. jmp .LNoThread
  148. .LThread:
  149. movl %eax,%ebx
  150. movl Errno,%eax
  151. call *%ecx
  152. movl %ebx,(%eax)
  153. .LNoThread:
  154. {$else}
  155. movl %eax,%edx
  156. movl fpc_threadvar_relocate_proc,%eax
  157. testl %eax,%eax
  158. jne .LThread
  159. movl %edx,Errno+4
  160. jmp .LNoThread
  161. .LThread:
  162. pushl %edx
  163. pushl Errno
  164. call *%eax
  165. popl %edx
  166. movl %edx,(%eax)
  167. .LNoThread:
  168. {$endif REGCALL}
  169. movl $-1,%eax
  170. .LSyscOK:
  171. end;
  172. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler; oldfpccall; [public,alias:'FPC_SYSCALL4'];
  173. asm
  174. { load the registers... }
  175. movl sysnr,%eax
  176. movl param1,%ebx
  177. movl param2,%ecx
  178. movl param3,%edx
  179. movl param4,%esi
  180. int $0x80
  181. cmpl $-4095,%eax
  182. jb .LSyscOK
  183. negl %eax
  184. {$ifdef REGCALL}
  185. movl fpc_threadvar_relocate_proc,%ecx
  186. testl %ecx,%ecx
  187. jne .LThread
  188. movl %eax,Errno+4
  189. jmp .LNoThread
  190. .LThread:
  191. movl %eax,%ebx
  192. movl Errno,%eax
  193. call *%ecx
  194. movl %ebx,(%eax)
  195. .LNoThread:
  196. {$else}
  197. movl %eax,%edx
  198. movl fpc_threadvar_relocate_proc,%eax
  199. testl %eax,%eax
  200. jne .LThread
  201. movl %edx,Errno+4
  202. jmp .LNoThread
  203. .LThread:
  204. pushl %edx
  205. pushl Errno
  206. call *%eax
  207. popl %edx
  208. movl %edx,(%eax)
  209. .LNoThread:
  210. {$endif REGCALL}
  211. movl $-1,%eax
  212. .LSyscOK:
  213. end;
  214. function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler; oldfpccall;[public,alias:'FPC_SYSCALL5'];
  215. asm
  216. { load the registers... }
  217. movl sysnr,%eax
  218. movl param1,%ebx
  219. movl param2,%ecx
  220. movl param3,%edx
  221. movl param4,%esi
  222. movl param5,%edi
  223. int $0x80
  224. cmpl $-4095,%eax
  225. jb .LSyscOK
  226. negl %eax
  227. {$ifdef REGCALL}
  228. movl fpc_threadvar_relocate_proc,%ecx
  229. testl %ecx,%ecx
  230. jne .LThread
  231. movl %eax,Errno+4
  232. jmp .LNoThread
  233. .LThread:
  234. movl %eax,%ebx
  235. movl Errno,%eax
  236. call *%ecx
  237. movl %ebx,(%eax)
  238. .LNoThread:
  239. {$else}
  240. movl %eax,%edx
  241. movl fpc_threadvar_relocate_proc,%eax
  242. testl %eax,%eax
  243. jne .LThread
  244. movl %edx,Errno+4
  245. jmp .LNoThread
  246. .LThread:
  247. pushl %edx
  248. pushl Errno
  249. call *%eax
  250. popl %edx
  251. movl %edx,(%eax)
  252. .LNoThread:
  253. {$endif REGCALL}
  254. movl $-1,%eax
  255. .LSyscOK:
  256. end;
  257. {$ifdef notsupported}
  258. { Only 5 params are pushed, so it'll not work as expected (PFV) }
  259. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler; oldfpccall;[public,alias:'FPC_SYSCALL6'];
  260. asm
  261. { load the registers... }
  262. movl sysnr,%eax
  263. movl param1,%ebx
  264. movl param2,%ecx
  265. movl param3,%edx
  266. movl param4,%esi
  267. movl param5,%edi
  268. int $0x80
  269. cmpl $-4095,%eax
  270. jb .LSyscOK
  271. negl %eax
  272. {$ifdef REGCALL}
  273. movl fpc_threadvar_relocate_proc,%ecx
  274. testl %ecx,%ecx
  275. jne .LThread
  276. movl %eax,Errno+4
  277. jmp .LNoThread
  278. .LThread:
  279. movl %eax,%ebx
  280. movl Errno,%eax
  281. call *%ecx
  282. movl %ebx,(%eax)
  283. .LNoThread:
  284. {$else}
  285. movl %eax,%edx
  286. movl fpc_threadvar_relocate_proc,%eax
  287. testl %eax,%eax
  288. jne .LThread
  289. movl %edx,Errno+4
  290. jmp .LNoThread
  291. .LThread:
  292. pushl %edx
  293. pushl Errno
  294. call *%eax
  295. popl %edx
  296. movl %edx,(%eax)
  297. .LNoThread:
  298. {$endif REGCALL}
  299. movl $-1,%eax
  300. .LSyscOK:
  301. end;
  302. {$endif notsupported}
  303. {No debugging for syslinux include !}
  304. {$IFDEF SYS_LINUX}
  305. {$UNDEF SYSCALL_DEBUG}
  306. {$ENDIF SYS_LINUX}