syscall.inc 6.4 KB

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