syscall.inc 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. member of the Free Pascal development team.
  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. {*****************************************************************************
  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. asm
  25. or %i0,%g0,%g1
  26. ta 0x10
  27. bcc .LSyscOK0
  28. nop
  29. sethi %hi(fpc_threadvar_relocate_proc),%o0
  30. or %o0,%lo(fpc_threadvar_relocate_proc),%o0
  31. ld [%o0],%o7
  32. subcc %o7,%g0,%g0
  33. bne .LThread0
  34. nop
  35. sethi %hi(Errno+4),%o0
  36. ba .LNoThread0
  37. or %o0,%lo(Errno+4),%o0
  38. .LThread0:
  39. sethi %hi(Errno),%o0
  40. ld [%o7],%o1
  41. or %o0,%lo(Errno),%o0
  42. call %o1
  43. .LNoThread0:
  44. st %i0,[%o0]
  45. mov -1,%o0
  46. .LSyscOK0:
  47. mov %o0,%i0
  48. end;
  49. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  50. {
  51. This function puts the registers in place, does the call, and then
  52. copies back the registers as they are after the SysCall.
  53. }
  54. asm
  55. or %i0,%g0,%g1
  56. or %i1,%g0,%o0
  57. ta 0x10
  58. bcc .LSyscOK1
  59. nop
  60. sethi %hi(fpc_threadvar_relocate_proc),%o0
  61. or %o0,%lo(fpc_threadvar_relocate_proc),%o0
  62. ld [%o0],%o7
  63. subcc %o7,%g0,%g0
  64. bne .LThread1
  65. nop
  66. sethi %hi(Errno+4),%o0
  67. ba .LNoThread1
  68. or %o0,%lo(Errno+4),%o0
  69. .LThread1:
  70. sethi %hi(Errno),%o0
  71. ld [%o7],%o1
  72. or %o0,%lo(Errno),%o0
  73. call %o1
  74. .LNoThread1:
  75. st %i0,[%o0]
  76. mov -1,%o0
  77. .LSyscOK1:
  78. mov %o0,%i0
  79. end;
  80. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  81. {
  82. This function puts the registers in place, does the call, and then
  83. copies back the registers as they are after the SysCall.
  84. }
  85. asm
  86. or %i0,%g0,%g1
  87. or %i1,%g0,%o0
  88. or %i2,%g0,%o1
  89. ta 0x10
  90. bcc .LSyscOK2
  91. nop
  92. sethi %hi(fpc_threadvar_relocate_proc),%o0
  93. or %o0,%lo(fpc_threadvar_relocate_proc),%o0
  94. ld [%o0],%o7
  95. subcc %o7,%g0,%g0
  96. bne .LThread2
  97. nop
  98. sethi %hi(Errno+4),%o0
  99. ba .LNoThread2
  100. or %o0,%lo(Errno+4),%o0
  101. .LThread2:
  102. sethi %hi(Errno),%o0
  103. ld [%o7],%o1
  104. or %o0,%lo(Errno),%o0
  105. call %o1
  106. .LNoThread2:
  107. st %i0,[%o0]
  108. mov -1,%o0
  109. .LSyscOK2:
  110. mov %o0,%i0
  111. end;
  112. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  113. {
  114. This function puts the registers in place, does the call, and then
  115. copies back the registers as they are after the SysCall.
  116. }
  117. asm
  118. or %i0,%g0,%g1
  119. or %i1,%g0,%o0
  120. or %i2,%g0,%o1
  121. or %i3,%g0,%o2
  122. ta 0x10
  123. bcc .LSyscOK3
  124. nop
  125. sethi %hi(fpc_threadvar_relocate_proc),%o2
  126. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  127. ld [%o2],%o3
  128. subcc %o7,%g0,%g0
  129. bne .LThread3
  130. nop
  131. sethi %hi(Errno+4),%o2
  132. ba .LNoThread3
  133. or %o2,%lo(Errno+4),%o2
  134. .LThread3:
  135. sethi %hi(Errno),%o2
  136. ld [%o3],%o1
  137. or %o2,%lo(Errno),%o2
  138. call %o1
  139. .LNoThread3:
  140. st %o0,[%o2]
  141. mov -1,%o0
  142. .LSyscOK3:
  143. mov %o0,%i0
  144. end;
  145. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  146. {
  147. This function puts the registers in place, does the call, and then
  148. copies back the registers as they are after the SysCall.
  149. }
  150. asm
  151. or %i0,%g0,%g1
  152. or %i1,%g0,%o0
  153. or %i2,%g0,%o1
  154. or %i3,%g0,%o2
  155. or %i4,%g0,%o3
  156. ta 0x10
  157. bcc .LSyscOK4
  158. nop
  159. sethi %hi(fpc_threadvar_relocate_proc),%o0
  160. or %o0,%lo(fpc_threadvar_relocate_proc),%o0
  161. ld [%o0],%o7
  162. subcc %o7,%g0,%g0
  163. bne .LThread4
  164. nop
  165. sethi %hi(Errno+4),%o0
  166. ba .LNoThread4
  167. or %o0,%lo(Errno+4),%o0
  168. .LThread4:
  169. sethi %hi(Errno),%o0
  170. ld [%o7],%o1
  171. or %o0,%lo(Errno),%o0
  172. call %o1
  173. .LNoThread4:
  174. st %i0,[%o0]
  175. mov -1,%o0
  176. .LSyscOK4:
  177. mov %o0,%i0
  178. end;
  179. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  180. {
  181. This function puts the registers in place, does the call, and then
  182. copies back the registers as they are after the SysCall.
  183. }
  184. asm
  185. or %i0,%g0,%g1
  186. or %i1,%g0,%o0
  187. or %i2,%g0,%o1
  188. or %i3,%g0,%o2
  189. or %i4,%g0,%o3
  190. or %i5,%g0,%o4
  191. ta 0x10
  192. bcc .LSyscOK5
  193. nop
  194. sethi %hi(fpc_threadvar_relocate_proc),%o0
  195. or %o0,%lo(fpc_threadvar_relocate_proc),%o0
  196. ld [%o0],%o7
  197. subcc %o7,%g0,%g0
  198. bne .LThread5
  199. nop
  200. sethi %hi(Errno+4),%o0
  201. ba .LNoThread5
  202. or %o0,%lo(Errno+4),%o0
  203. .LThread5:
  204. sethi %hi(Errno),%o0
  205. ld [%o7],%o1
  206. or %o0,%lo(Errno),%o0
  207. call %o1
  208. .LNoThread5:
  209. st %i0,[%o0]
  210. mov -1,%o0
  211. .LSyscOK5:
  212. mov %o0,%i0
  213. end;
  214. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  215. {
  216. This function puts the registers in place, does the call, and then
  217. copies back the registers as they are after the SysCall.
  218. }
  219. asm
  220. or %i0,%g0,%g1
  221. or %i1,%g0,%o0
  222. or %i2,%g0,%o1
  223. or %i3,%g0,%o2
  224. or %i4,%g0,%o3
  225. ld [%i6+92],%o5
  226. or %i5,%g0,%o4
  227. ta 0x10
  228. bcc .LSyscOK6
  229. nop
  230. sethi %hi(fpc_threadvar_relocate_proc),%o0
  231. or %o0,%lo(fpc_threadvar_relocate_proc),%o0
  232. ld [%o0],%o7
  233. subcc %o7,%g0,%g0
  234. bne .LThread6
  235. nop
  236. sethi %hi(Errno+4),%o0
  237. ba .LNoThread6
  238. or %o0,%lo(Errno+4),%o0
  239. .LThread6:
  240. sethi %hi(Errno),%o0
  241. ld [%o7],%o1
  242. or %o0,%lo(Errno),%o0
  243. call %o1
  244. .LNoThread6:
  245. st %i0,[%o0]
  246. mov -1,%o0
  247. .LSyscOK6:
  248. mov %o0,%i0
  249. end;
  250. {
  251. $Log$
  252. Revision 1.12 2004-06-30 21:15:51 florian
  253. * first syscall fix
  254. Revision 1.11 2004/02/06 23:06:16 florian
  255. - killed tsyscallregs
  256. Revision 1.10 2004/01/05 17:22:03 peter
  257. * removed asmmode direct
  258. Revision 1.9 2003/08/11 13:19:08 mazen
  259. + added assembler mode directive to use direct assembler reader
  260. Revision 1.8 2003/07/06 22:08:05 peter
  261. * fix setting return value
  262. Revision 1.7 2003/07/06 20:40:10 peter
  263. * wrong return reg
  264. Revision 1.6 2003/07/03 21:03:57 peter
  265. * syscalls implemented
  266. Revision 1.5 2003/06/02 22:05:03 mazen
  267. * fixing naming conflict in public clause of
  268. FPC_SYSCALL? definition
  269. Revision 1.4 2003/05/23 22:36:39 florian
  270. * fixed compilation of sparc system unit
  271. Revision 1.3 2003/01/05 21:32:35 mazen
  272. * fixing several bugs compiling the RTL
  273. Revision 1.2 2002/12/24 21:30:20 mazen
  274. - some writeln(s) removed in compiler
  275. + many files added to RTL
  276. * some errors fixed in RTL
  277. Revision 1.1 2002/11/15 12:08:37 mazen
  278. + SPARC support added based on PowerPc sources
  279. Revision 1.1 2002/11/09 20:32:14 marco
  280. * powerpc version. Threadsafe errno access not yet done.
  281. Revision 1.1 2002/10/14 19:39:44 peter
  282. * syscall moved into seperate include
  283. }