syscall.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 by Florian Klaempfl,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {No debugging for syslinux include !}
  13. {$IFDEF SYS_LINUX}
  14. {$UNDEF SYSCALL_DEBUG}
  15. {$ENDIF SYS_LINUX}
  16. {*****************************************************************************
  17. --- Main:The System Call Self ---
  18. *****************************************************************************}
  19. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  20. {
  21. This function puts the registers in place, does the call, and then
  22. copies back the registers as they are after the SysCall.
  23. }
  24. asm
  25. swi #0x900071
  26. cmn r0,#126
  27. bls .LDone
  28. rsb r4,r0,#0
  29. ldr r2,.Lthread_var
  30. ldr r2,[r2]
  31. ldr r0,.LErrno
  32. cmp r2,#0
  33. bne .LThread
  34. str r4,[r0,#4]
  35. mvn r0,#0
  36. b .LDone
  37. .LThread:
  38. mov pc,r2
  39. str r4,[r0]
  40. mvn r0,#0
  41. b .LDone
  42. .LErrno:
  43. .word Errno
  44. .Lthread_var:
  45. .word fpc_threadvar_relocate_proc
  46. .LDone:
  47. end ['r4'];
  48. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  49. {
  50. This function puts the registers in place, does the call, and then
  51. copies back the registers as they are after the SysCall.
  52. }
  53. asm
  54. swi #0x900071
  55. cmn r0,#126
  56. bls .LDone
  57. rsb r4,r0,#0
  58. ldr r2,.Lthread_var
  59. ldr r2,[r2]
  60. ldr r0,.LErrno
  61. cmp r2,#0
  62. bne .LThread
  63. str r4,[r0,#4]
  64. mvn r0,#0
  65. b .LDone
  66. .LThread:
  67. mov pc,r2
  68. str r4,[r0]
  69. mvn r0,#0
  70. b .LDone
  71. .LErrno:
  72. .word Errno
  73. .Lthread_var:
  74. .word fpc_threadvar_relocate_proc
  75. .LDone:
  76. end ['r4'];
  77. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  78. {
  79. This function puts the registers in place, does the call, and then
  80. copies back the registers as they are after the SysCall.
  81. }
  82. asm
  83. swi #0x900071
  84. cmn r0,#126
  85. bls .LDone
  86. rsb r4,r0,#0
  87. ldr r2,.Lthread_var
  88. ldr r2,[r2]
  89. ldr r0,.LErrno
  90. cmp r2,#0
  91. bne .LThread
  92. str r4,[r0,#4]
  93. mvn r0,#0
  94. b .LDone
  95. .LThread:
  96. mov pc,r2
  97. str r4,[r0]
  98. mvn r0,#0
  99. b .LDone
  100. .LErrno:
  101. .word Errno
  102. .Lthread_var:
  103. .word fpc_threadvar_relocate_proc
  104. .LDone:
  105. end ['r4'];
  106. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  107. {
  108. This function puts the registers in place, does the call, and then
  109. copies back the registers as they are after the SysCall.
  110. }
  111. asm
  112. swi #0x900071
  113. cmn r0,#126
  114. bls .LDone
  115. rsb r4,r0,#0
  116. ldr r2,.Lthread_var
  117. ldr r2,[r2]
  118. ldr r0,.LErrno
  119. cmp r2,#0
  120. bne .LThread
  121. str r4,[r0,#4]
  122. mvn r0,#0
  123. b .LDone
  124. .LThread:
  125. mov pc,r2
  126. str r4,[r0]
  127. mvn r0,#0
  128. b .LDone
  129. .LErrno:
  130. .word Errno
  131. .Lthread_var:
  132. .word fpc_threadvar_relocate_proc
  133. .LDone:
  134. end ['r4'];
  135. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  136. {
  137. This function puts the registers in place, does the call, and then
  138. copies back the registers as they are after the SysCall.
  139. }
  140. asm
  141. ldr r4,param4
  142. swi #0x900071
  143. cmn r0,#126
  144. bls .LDone
  145. rsb r4,r0,#0
  146. ldr r2,.Lthread_var
  147. ldr r2,[r2]
  148. ldr r0,.LErrno
  149. cmp r2,#0
  150. bne .LThread
  151. str r4,[r0,#4]
  152. mvn r0,#0
  153. b .LDone
  154. .LThread:
  155. mov pc,r2
  156. str r4,[r0]
  157. mvn r0,#0
  158. b .LDone
  159. .LErrno:
  160. .word Errno
  161. .Lthread_var:
  162. .word fpc_threadvar_relocate_proc
  163. .LDone:
  164. end ['r4'];
  165. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  166. {
  167. This function puts the registers in place, does the call, and then
  168. copies back the registers as they are after the SysCall.
  169. }
  170. asm
  171. ldr r5,param5
  172. ldr r4,param4
  173. swi #0x900071
  174. cmn r0,#126
  175. bls .LDone
  176. rsb r4,r0,#0
  177. ldr r2,.Lthread_var
  178. ldr r2,[r2]
  179. ldr r0,.LErrno
  180. cmp r2,#0
  181. bne .LThread
  182. str r4,[r0,#4]
  183. mvn r0,#0
  184. b .LDone
  185. .LThread:
  186. mov pc,r2
  187. str r4,[r0]
  188. mvn r0,#0
  189. b .LDone
  190. .LErrno:
  191. .word Errno
  192. .Lthread_var:
  193. .word fpc_threadvar_relocate_proc
  194. .LDone:
  195. end ['r4','r5'];
  196. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  197. {
  198. This function puts the registers in place, does the call, and then
  199. copies back the registers as they are after the SysCall.
  200. }
  201. asm
  202. ldr r6,param6
  203. ldr r5,param5
  204. ldr r4,param4
  205. swi #0x900071
  206. cmn r0,#126
  207. bls .LDone
  208. rsb r4,r0,#0
  209. ldr r2,.Lthread_var
  210. ldr r2,[r2]
  211. ldr r0,.LErrno
  212. cmp r2,#0
  213. bne .LThread
  214. str r4,[r0,#4]
  215. mvn r0,#0
  216. b .LDone
  217. .LThread:
  218. mov pc,r2
  219. str r4,[r0]
  220. mvn r0,#0
  221. b .LDone
  222. .LErrno:
  223. .word Errno
  224. .Lthread_var:
  225. .word fpc_threadvar_relocate_proc
  226. .LDone:
  227. end ['r4','r5','r6'];
  228. {
  229. $Log$
  230. Revision 1.6 2005-01-04 14:13:58 florian
  231. * fixed error handling of system calls
  232. Revision 1.5 2004/02/06 23:06:16 florian
  233. - killed tsyscallregs
  234. Revision 1.4 2004/01/20 21:01:57 florian
  235. * fixed setjump
  236. * fixed syscalls
  237. Revision 1.3 2003/12/29 19:24:12 florian
  238. + introduced PtrInt and PtrUInt
  239. * made strscan 64 bit safe
  240. Revision 1.2 2003/12/03 17:34:12 florian
  241. + started to implement arm syscalls
  242. Revision 1.1 2003/08/28 00:08:29 florian
  243. * syscall skeleton
  244. }