syscall.inc 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. mov %i0,%g1
  26. ta 0x10
  27. bcc .LSyscOK
  28. nop
  29. sethi %hi(fpc_threadvar_relocate_proc),%o2
  30. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  31. ld [%o2],%o3
  32. subcc %o3,%g0,%g0
  33. bne .LThread
  34. nop
  35. sethi %hi(Errno+4),%o2
  36. ba .LNoThread
  37. or %o2,%lo(Errno+4),%o2
  38. .LThread:
  39. sethi %hi(Errno),%o0
  40. ld [%o3],%o1
  41. or %o0,%lo(Errno),%o0
  42. call %o1
  43. .LNoThread:
  44. st %o0,[%o2]
  45. mov -1,%o0
  46. .LSyscOK:
  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. mov %i0,%g1
  56. mov %i1,%o0
  57. ta 0x10
  58. bcc .LSyscOK
  59. nop
  60. sethi %hi(fpc_threadvar_relocate_proc),%o2
  61. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  62. ld [%o2],%o3
  63. subcc %o3,%g0,%g0
  64. bne .LThread
  65. nop
  66. sethi %hi(Errno+4),%o2
  67. ba .LNoThread
  68. or %o2,%lo(Errno+4),%o2
  69. .LThread:
  70. sethi %hi(Errno),%o0
  71. ld [%o3],%o1
  72. or %o0,%lo(Errno),%o0
  73. call %o1
  74. .LNoThread:
  75. st %o0,[%o2]
  76. mov -1,%o0
  77. .LSyscOK:
  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. mov %i0,%g1
  87. mov %i1,%o0
  88. mov %i2,%o1
  89. ta 0x10
  90. bcc .LSyscOK
  91. nop
  92. sethi %hi(fpc_threadvar_relocate_proc),%o2
  93. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  94. ld [%o2],%o3
  95. subcc %o3,%g0,%g0
  96. bne .LThread
  97. nop
  98. sethi %hi(Errno+4),%o2
  99. ba .LNoThread
  100. or %o2,%lo(Errno+4),%o2
  101. .LThread:
  102. sethi %hi(Errno),%o0
  103. ld [%o3],%o1
  104. or %o0,%lo(Errno),%o0
  105. call %o1
  106. .LNoThread:
  107. st %o0,[%o2]
  108. mov -1,%o0
  109. .LSyscOK:
  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. mov %i0,%g1
  119. mov %i1,%o0
  120. mov %i2,%o1
  121. mov %i3,%o2
  122. ta 0x10
  123. bcc .LSyscOK
  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 %o3,%g0,%g0
  129. bne .LThread
  130. nop
  131. sethi %hi(Errno+4),%o2
  132. ba .LNoThread
  133. or %o2,%lo(Errno+4),%o2
  134. .LThread:
  135. sethi %hi(Errno),%o0
  136. ld [%o3],%o1
  137. or %o0,%lo(Errno),%o0
  138. call %o1
  139. .LNoThread:
  140. st %o0,[%o2]
  141. mov -1,%o0
  142. .LSyscOK:
  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. mov %i0,%g1
  152. mov %i1,%o0
  153. mov %i2,%o1
  154. mov %i3,%o2
  155. mov %i4,%o3
  156. ta 0x10
  157. bcc .LSyscOK
  158. nop
  159. sethi %hi(fpc_threadvar_relocate_proc),%o2
  160. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  161. ld [%o2],%o3
  162. subcc %o3,%g0,%g0
  163. bne .LThread
  164. nop
  165. sethi %hi(Errno+4),%o2
  166. ba .LNoThread
  167. or %o2,%lo(Errno+4),%o2
  168. .LThread:
  169. sethi %hi(Errno),%o0
  170. ld [%o3],%o1
  171. or %o0,%lo(Errno),%o0
  172. call %o1
  173. .LNoThread:
  174. st %o0,[%o2]
  175. mov -1,%o0
  176. .LSyscOK:
  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. mov %i0,%g1
  186. mov %i1,%o0
  187. mov %i2,%o1
  188. mov %i3,%o2
  189. mov %i4,%o3
  190. mov %i5,%o4
  191. ta 0x10
  192. bcc .LSyscOK
  193. nop
  194. sethi %hi(fpc_threadvar_relocate_proc),%o2
  195. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  196. ld [%o2],%o3
  197. subcc %o3,%g0,%g0
  198. bne .LThread
  199. nop
  200. sethi %hi(Errno+4),%o2
  201. ba .LNoThread
  202. or %o2,%lo(Errno+4),%o2
  203. .LThread:
  204. sethi %hi(Errno),%o0
  205. ld [%o3],%o1
  206. or %o0,%lo(Errno),%o0
  207. call %o1
  208. .LNoThread:
  209. st %o0,[%o2]
  210. mov -1,%o0
  211. .LSyscOK:
  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. mov %i0,%g1
  221. mov %i1,%o0
  222. mov %i2,%o1
  223. mov %i3,%o2
  224. mov %i4,%o3
  225. ld [%i6+92],%o5
  226. mov %i5,%o4
  227. ta 0x10
  228. bcc .LSyscOK
  229. nop
  230. sethi %hi(fpc_threadvar_relocate_proc),%o2
  231. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  232. ld [%o2],%o3
  233. subcc %o3,%g0,%g0
  234. bne .LThread
  235. nop
  236. sethi %hi(Errno+4),%o2
  237. ba .LNoThread
  238. or %o2,%lo(Errno+4),%o2
  239. .LThread:
  240. sethi %hi(Errno),%o0
  241. ld [%o3],%o1
  242. or %o0,%lo(Errno),%o0
  243. call %o1
  244. .LNoThread:
  245. st %o0,[%o2]
  246. mov -1,%o0
  247. .LSyscOK:
  248. mov %o0,%i0
  249. end;
  250. {
  251. $Log$
  252. Revision 1.13 2004-07-02 19:29:19 peter
  253. * fixed errno setting
  254. Revision 1.12 2004/06/30 21:15:51 florian
  255. * first syscall fix
  256. Revision 1.11 2004/02/06 23:06:16 florian
  257. - killed tsyscallregs
  258. Revision 1.10 2004/01/05 17:22:03 peter
  259. * removed asmmode direct
  260. Revision 1.9 2003/08/11 13:19:08 mazen
  261. + added assembler mode directive to use direct assembler reader
  262. Revision 1.8 2003/07/06 22:08:05 peter
  263. * fix setting return value
  264. Revision 1.7 2003/07/06 20:40:10 peter
  265. * wrong return reg
  266. Revision 1.6 2003/07/03 21:03:57 peter
  267. * syscalls implemented
  268. Revision 1.5 2003/06/02 22:05:03 mazen
  269. * fixing naming conflict in public clause of
  270. FPC_SYSCALL? definition
  271. Revision 1.4 2003/05/23 22:36:39 florian
  272. * fixed compilation of sparc system unit
  273. Revision 1.3 2003/01/05 21:32:35 mazen
  274. * fixing several bugs compiling the RTL
  275. Revision 1.2 2002/12/24 21:30:20 mazen
  276. - some writeln(s) removed in compiler
  277. + many files added to RTL
  278. * some errors fixed in RTL
  279. Revision 1.1 2002/11/15 12:08:37 mazen
  280. + SPARC support added based on PowerPc sources
  281. Revision 1.1 2002/11/09 20:32:14 marco
  282. * powerpc version. Threadsafe errno access not yet done.
  283. Revision 1.1 2002/10/14 19:39:44 peter
  284. * syscall moved into seperate include
  285. }