syscall.inc 5.2 KB

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