syscall.inc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. {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. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  30. remove after 3.0.2 is the minimum bootstrap version }
  31. dummy: array[1..4] of ptruint;
  32. retaddress: ptruint;
  33. asm
  34. mr r0, r3
  35. sc
  36. bns .LDone
  37. mflr r4
  38. std r4, retaddress
  39. bl seterrno
  40. nop
  41. ld r4, retaddress
  42. li r3, -1
  43. mtlr r4
  44. .LDone:
  45. end;
  46. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  47. {
  48. This function puts the registers in place, does the call, and then
  49. copies back the registers as they are after the SysCall.
  50. }
  51. var
  52. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  53. remove after 3.0.2 is the minimum bootstrap version }
  54. dummy: array[1..4] of ptruint;
  55. retaddress: ptruint;
  56. asm
  57. mr r0, r3
  58. mr r3, r4
  59. sc
  60. bns .LDone
  61. mflr r4
  62. std r4, retaddress
  63. bl seterrno
  64. nop
  65. ld r4, retaddress
  66. li r3, -1
  67. mtlr r4
  68. .LDone:
  69. end;
  70. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  71. {
  72. This function puts the registers in place, does the call, and then
  73. copies back the registers as they are after the SysCall.
  74. }
  75. var
  76. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  77. remove after 3.0.2 is the minimum bootstrap version }
  78. dummy: array[1..4] of ptruint;
  79. retaddress: ptruint;
  80. asm
  81. mr r0, r3
  82. mr r3, r4
  83. mr r4, r5
  84. sc
  85. bns .LDone
  86. mflr r4
  87. std r4, retaddress
  88. bl seterrno
  89. nop
  90. ld r4, retaddress
  91. li r3, -1
  92. mtlr r4
  93. .LDone:
  94. end;
  95. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  96. {
  97. This function puts the registers in place, does the call, and then
  98. copies back the registers as they are after the SysCall.
  99. }
  100. var
  101. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  102. remove after 3.0.2 is the minimum bootstrap version }
  103. dummy: array[1..4] of ptruint;
  104. retaddress: ptruint;
  105. asm
  106. mr r0, r3
  107. mr r3, r4
  108. mr r4, r5
  109. mr r5, r6
  110. sc
  111. bns .LDone
  112. mflr r4
  113. std r4, retaddress
  114. bl seterrno
  115. nop
  116. ld r4, retaddress
  117. li r3, -1
  118. mtlr r4
  119. .LDone:
  120. end;
  121. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  122. {
  123. This function puts the registers in place, does the call, and then
  124. copies back the registers as they are after the SysCall.
  125. }
  126. var
  127. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  128. remove after 3.0.2 is the minimum bootstrap version }
  129. dummy: array[1..4] of ptruint;
  130. retaddress: ptruint;
  131. asm
  132. mr r0, r3
  133. mr r3, r4
  134. mr r4, r5
  135. mr r5, r6
  136. mr r6, r7
  137. sc
  138. bns .LDone
  139. mflr r4
  140. std r4, retaddress
  141. bl seterrno
  142. nop
  143. ld r4, retaddress
  144. li r3, -1
  145. mtlr r4
  146. .LDone:
  147. end;
  148. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  149. {
  150. This function puts the registers in place, does the call, and then
  151. copies back the registers as they are after the SysCall.
  152. }
  153. var
  154. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  155. remove after 3.0.2 is the minimum bootstrap version }
  156. dummy: array[1..4] of ptruint;
  157. retaddress: ptruint;
  158. asm
  159. mr r0, r3
  160. mr r3, r4
  161. mr r4, r5
  162. mr r5, r6
  163. mr r6, r7
  164. mr r7, r8
  165. sc
  166. bns .LDone
  167. mflr r4
  168. std r4, retaddress
  169. bl seterrno
  170. nop
  171. ld r4, retaddress
  172. li r3, -1
  173. mtlr r4
  174. .LDone:
  175. end;
  176. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  177. {
  178. This function puts the registers in place, does the call, and then
  179. copies back the registers as they are after the SysCall.
  180. }
  181. var
  182. { workaround for incomplete linkage area reservation by FPC 3.0.0 and earlier,
  183. remove after 3.0.2 is the minimum bootstrap version }
  184. dummy: array[1..4] of ptruint;
  185. retaddress: ptruint;
  186. asm
  187. mr r0, r3
  188. mr r3, r4
  189. mr r4, r5
  190. mr r5, r6
  191. mr r6, r7
  192. mr r7, r8
  193. mr r8, r9
  194. sc
  195. bns .LDone
  196. mflr r4
  197. std r4, retaddress
  198. bl seterrno
  199. nop
  200. ld r4, retaddress
  201. li r3, -1
  202. mtlr r4
  203. .LDone:
  204. end;