2
0

syscall.inc 7.4 KB

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