syscall.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. Linux powerpc syscall wrapper implementation
  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. { This variable is needed in syscall.inc assembler code }
  13. var
  14. fpc_threadvar_relocate_proc : TRelocateThreadVarHandler; public name 'FPC_THREADVAR_RELOCATE';
  15. {$define THREADVAR_RELOCATED_ALREADY_DEFINED}
  16. {*****************************************************************************
  17. --- Main:The System Call Self ---
  18. *****************************************************************************}
  19. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  20. {
  21. This function puts the registers in place, does the call, and then
  22. copies back the registers as they are after the SysCall.
  23. }
  24. var
  25. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  26. remove after 3.0.2 is the minimum bootstrap version }
  27. dummy: array[1..4] of ptruint;
  28. retaddress: ptruint;
  29. asm
  30. mr r0, r3
  31. sc
  32. bns .LDone
  33. mflr r4
  34. std r4, retaddress
  35. bl seterrno
  36. nop
  37. ld r4, retaddress
  38. li r3, -1
  39. mtlr r4
  40. .LDone:
  41. end;
  42. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  43. {
  44. This function puts the registers in place, does the call, and then
  45. copies back the registers as they are after the SysCall.
  46. }
  47. var
  48. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  49. remove after 3.0.2 is the minimum bootstrap version }
  50. dummy: array[1..4] of ptruint;
  51. retaddress: ptruint;
  52. asm
  53. mr r0, r3
  54. mr r3, r4
  55. sc
  56. bns .LDone
  57. mflr r4
  58. std r4, retaddress
  59. bl seterrno
  60. nop
  61. ld r4, retaddress
  62. li r3, -1
  63. mtlr r4
  64. .LDone:
  65. end;
  66. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  67. {
  68. This function puts the registers in place, does the call, and then
  69. copies back the registers as they are after the SysCall.
  70. }
  71. var
  72. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  73. remove after 3.0.2 is the minimum bootstrap version }
  74. dummy: array[1..4] of ptruint;
  75. retaddress: ptruint;
  76. asm
  77. mr r0, r3
  78. mr r3, r4
  79. mr r4, r5
  80. sc
  81. bns .LDone
  82. mflr r4
  83. std r4, retaddress
  84. bl seterrno
  85. nop
  86. ld r4, retaddress
  87. li r3, -1
  88. mtlr r4
  89. .LDone:
  90. end;
  91. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  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. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  98. remove after 3.0.2 is the minimum bootstrap version }
  99. dummy: array[1..4] of ptruint;
  100. retaddress: ptruint;
  101. asm
  102. mr r0, r3
  103. mr r3, r4
  104. mr r4, r5
  105. mr r5, r6
  106. sc
  107. bns .LDone
  108. mflr r4
  109. std r4, retaddress
  110. bl seterrno
  111. nop
  112. ld r4, retaddress
  113. li r3, -1
  114. mtlr r4
  115. .LDone:
  116. end;
  117. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  118. {
  119. This function puts the registers in place, does the call, and then
  120. copies back the registers as they are after the SysCall.
  121. }
  122. var
  123. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  124. remove after 3.0.2 is the minimum bootstrap version }
  125. dummy: array[1..4] of ptruint;
  126. retaddress: ptruint;
  127. asm
  128. mr r0, r3
  129. mr r3, r4
  130. mr r4, r5
  131. mr r5, r6
  132. mr r6, r7
  133. sc
  134. bns .LDone
  135. mflr r4
  136. std r4, retaddress
  137. bl seterrno
  138. nop
  139. ld r4, retaddress
  140. li r3, -1
  141. mtlr r4
  142. .LDone:
  143. end;
  144. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  145. {
  146. This function puts the registers in place, does the call, and then
  147. copies back the registers as they are after the SysCall.
  148. }
  149. var
  150. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  151. remove after 3.0.2 is the minimum bootstrap version }
  152. dummy: array[1..4] of ptruint;
  153. retaddress: ptruint;
  154. asm
  155. mr r0, r3
  156. mr r3, r4
  157. mr r4, r5
  158. mr r5, r6
  159. mr r6, r7
  160. mr r7, r8
  161. sc
  162. bns .LDone
  163. mflr r4
  164. std r4, retaddress
  165. bl seterrno
  166. nop
  167. ld r4, retaddress
  168. li r3, -1
  169. mtlr r4
  170. .LDone:
  171. end;
  172. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  173. {
  174. This function puts the registers in place, does the call, and then
  175. copies back the registers as they are after the SysCall.
  176. }
  177. var
  178. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  179. remove after 3.0.2 is the minimum bootstrap version }
  180. dummy: array[1..4] of ptruint;
  181. retaddress: ptruint;
  182. asm
  183. mr r0, r3
  184. mr r3, r4
  185. mr r4, r5
  186. mr r5, r6
  187. mr r6, r7
  188. mr r7, r8
  189. mr r8, r9
  190. sc
  191. bns .LDone
  192. mflr r4
  193. std r4, retaddress
  194. bl seterrno
  195. nop
  196. ld r4, retaddress
  197. li r3, -1
  198. mtlr r4
  199. .LDone:
  200. end;
  201. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL7'];
  202. {
  203. This function puts the registers in place, does the call, and then
  204. copies back the registers as they are after the SysCall.
  205. }
  206. var
  207. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  208. remove after 3.0.2 is the minimum bootstrap version }
  209. dummy: array[1..4] of ptruint;
  210. retaddress: ptruint;
  211. asm
  212. mr r0,r3
  213. mr r3,r4
  214. mr r4,r5
  215. mr r5,r6
  216. mr r6,r7
  217. mr r7,r8
  218. mr r8,r9
  219. mr r9,r10
  220. sc
  221. bns .LDone
  222. mflr r4
  223. std r4, retaddress
  224. bl seterrno
  225. nop
  226. ld r4, retaddress
  227. li r3, -1
  228. mtlr r4
  229. .LDone:
  230. end;