2
0

syscall.inc 6.1 KB

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