syscall.inc 8.2 KB

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