2
0

syscall.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {No debugging for syslinux include !}
  12. {$IFDEF SYS_LINUX}
  13. {$UNDEF SYSCALL_DEBUG}
  14. {$ENDIF SYS_LINUX}
  15. { This variable is needed in syscall.inc assembler code }
  16. var
  17. fpc_threadvar_relocate_proc : TRelocateThreadVarHandler; public name 'FPC_THREADVAR_RELOCATE';
  18. {$define THREADVAR_RELOCATED_ALREADY_DEFINED}
  19. {*****************************************************************************
  20. --- Main:The System Call Self ---
  21. *****************************************************************************}
  22. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  23. {
  24. This function puts the registers in place, does the call, and then
  25. copies back the registers as they are after the SysCall.
  26. }
  27. var
  28. temp, retaddress: longint;
  29. asm
  30. mr r0,r3
  31. sc
  32. bns .LDone
  33. lis r10,(fpc_threadvar_relocate_proc)@ha
  34. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  35. cmpwi r10,0
  36. bne .LThreaded
  37. lis r4,(Errno+4)@ha
  38. stw r3,(Errno+4)@l(r4)
  39. b .LFailed
  40. .LThreaded:
  41. stw r3,temp
  42. mflr r3
  43. mtctr r10
  44. lis r4,(errno)@ha
  45. stw r3,retaddress
  46. lwz r3,(errno)@l(r4)
  47. bctrl
  48. lwz r4,temp
  49. lwz r5,retaddress
  50. stw r4,0(r3)
  51. mtlr r5
  52. .LFailed:
  53. li r3,-1
  54. .LDone:
  55. end;
  56. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  57. {
  58. This function puts the registers in place, does the call, and then
  59. copies back the registers as they are after the SysCall.
  60. }
  61. var
  62. temp, retaddress: longint;
  63. asm
  64. mr r0,r3
  65. mr r3,r4
  66. sc
  67. bns .LDone
  68. lis r10,(fpc_threadvar_relocate_proc)@ha
  69. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  70. cmpwi r10,0
  71. bne .LThreaded
  72. lis r4,(Errno+4)@ha
  73. stw r3,(Errno+4)@l(r4)
  74. b .LFailed
  75. .LThreaded:
  76. stw r3,temp
  77. mflr r3
  78. mtctr r10
  79. lis r4,(errno)@ha
  80. stw r3,retaddress
  81. lwz r3,(errno)@l(r4)
  82. bctrl
  83. lwz r4,temp
  84. lwz r5,retaddress
  85. stw r4,0(r3)
  86. mtlr r5
  87. .LFailed:
  88. li r3,-1
  89. .LDone:
  90. end;
  91. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  92. {
  93. This function puts the registers in place, does the call, and then
  94. copies back the registers as they are after the SysCall.
  95. }
  96. var
  97. temp, retaddress: longint;
  98. asm
  99. mr r0,r3
  100. mr r3,r4
  101. mr r4,r5
  102. sc
  103. bns .LDone
  104. lis r10,(fpc_threadvar_relocate_proc)@ha
  105. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  106. cmpwi r10,0
  107. bne .LThreaded
  108. lis r4,(Errno+4)@ha
  109. stw r3,(Errno+4)@l(r4)
  110. b .LFailed
  111. .LThreaded:
  112. stw r3,temp
  113. mflr r3
  114. mtctr r10
  115. lis r4,(errno)@ha
  116. stw r3,retaddress
  117. lwz r3,(errno)@l(r4)
  118. bctrl
  119. lwz r4,temp
  120. lwz r5,retaddress
  121. stw r4,0(r3)
  122. mtlr r5
  123. .LFailed:
  124. li r3,-1
  125. .LDone:
  126. end;
  127. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  128. {
  129. This function puts the registers in place, does the call, and then
  130. copies back the registers as they are after the SysCall.
  131. }
  132. var
  133. temp, retaddress: longint;
  134. asm
  135. mr r0,r3
  136. mr r3,r4
  137. mr r4,r5
  138. mr r5,r6
  139. sc
  140. bns .LDone
  141. lis r10,(fpc_threadvar_relocate_proc)@ha
  142. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  143. cmpwi r10,0
  144. bne .LThreaded
  145. lis r4,(Errno+4)@ha
  146. stw r3,(Errno+4)@l(r4)
  147. b .LFailed
  148. .LThreaded:
  149. stw r3,temp
  150. mflr r3
  151. mtctr r10
  152. lis r4,(errno)@ha
  153. stw r3,retaddress
  154. lwz r3,(errno)@l(r4)
  155. bctrl
  156. lwz r4,temp
  157. lwz r5,retaddress
  158. stw r4,0(r3)
  159. mtlr r5
  160. .LFailed:
  161. li r3,-1
  162. .LDone:
  163. end;
  164. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  165. {
  166. This function puts the registers in place, does the call, and then
  167. copies back the registers as they are after the SysCall.
  168. }
  169. var
  170. temp, retaddress: longint;
  171. asm
  172. mr r0,r3
  173. mr r3,r4
  174. mr r4,r5
  175. mr r5,r6
  176. mr r6,r7
  177. sc
  178. bns .LDone
  179. lis r10,(fpc_threadvar_relocate_proc)@ha
  180. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  181. cmpwi r10,0
  182. bne .LThreaded
  183. lis r4,(Errno+4)@ha
  184. stw r3,(Errno+4)@l(r4)
  185. b .LFailed
  186. .LThreaded:
  187. stw r3,temp
  188. mflr r3
  189. mtctr r10
  190. lis r4,(errno)@ha
  191. stw r3,retaddress
  192. lwz r3,(errno)@l(r4)
  193. bctrl
  194. lwz r4,temp
  195. lwz r5,retaddress
  196. stw r4,0(r3)
  197. mtlr r5
  198. .LFailed:
  199. li r3,-1
  200. .LDone:
  201. end;
  202. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  203. {
  204. This function puts the registers in place, does the call, and then
  205. copies back the registers as they are after the SysCall.
  206. }
  207. var
  208. temp, retaddress: longint;
  209. asm
  210. mr r0,r3
  211. mr r3,r4
  212. mr r4,r5
  213. mr r5,r6
  214. mr r6,r7
  215. mr r7,r8
  216. sc
  217. bns .LDone
  218. lis r10,(fpc_threadvar_relocate_proc)@ha
  219. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  220. cmpwi r10,0
  221. bne .LThreaded
  222. lis r4,(Errno+4)@ha
  223. stw r3,(Errno+4)@l(r4)
  224. b .LFailed
  225. .LThreaded:
  226. stw r3,temp
  227. mflr r3
  228. mtctr r10
  229. lis r4,(errno)@ha
  230. stw r3,retaddress
  231. lwz r3,(errno)@l(r4)
  232. bctrl
  233. lwz r4,temp
  234. lwz r5,retaddress
  235. stw r4,0(r3)
  236. mtlr r5
  237. .LFailed:
  238. li r3,-1
  239. .LDone:
  240. end;
  241. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  242. {
  243. This function puts the registers in place, does the call, and then
  244. copies back the registers as they are after the SysCall.
  245. }
  246. var
  247. temp, retaddress: longint;
  248. asm
  249. mr r0,r3
  250. mr r3,r4
  251. mr r4,r5
  252. mr r5,r6
  253. mr r6,r7
  254. mr r7,r8
  255. mr r8,r9
  256. sc
  257. bns .LDone
  258. lis r10,(fpc_threadvar_relocate_proc)@ha
  259. lwz r10,(fpc_threadvar_relocate_proc)@l(r10)
  260. cmpwi r10,0
  261. bne .LThreaded
  262. lis r4,(Errno+4)@ha
  263. stw r3,(Errno+4)@l(r4)
  264. b .LFailed
  265. .LThreaded:
  266. stw r3,temp
  267. mflr r3
  268. mtctr r10
  269. lis r4,(errno)@ha
  270. stw r3,retaddress
  271. lwz r3,(errno)@l(r4)
  272. bctrl
  273. lwz r4,temp
  274. lwz r5,retaddress
  275. stw r4,0(r3)
  276. mtlr r5
  277. .LFailed:
  278. li r3,-1
  279. .LDone:
  280. end;