syscall.inc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. {$define FPC_SYSTEM_HAS_FPFORK}
  17. {
  18. behaviour of result of fork on sparc/linux is different than on other
  19. linux flavours
  20. }
  21. function Fpfork : pid_t; [public, alias : 'FPC_SYSC_FORK'];assembler;
  22. asm
  23. mov 2,%g1
  24. ta 0x10
  25. bcc .LSyscOK
  26. nop
  27. mov %o0,%l0
  28. sethi %hi(fpc_threadvar_relocate_proc),%o2
  29. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  30. ld [%o2],%o3
  31. subcc %o3,%g0,%g0
  32. bne .LThread
  33. nop
  34. sethi %hi(Errno+4),%o0
  35. ba .LNoThread
  36. or %o0,%lo(Errno+4),%o0
  37. .LThread:
  38. sethi %hi(Errno),%o0
  39. or %o0,%lo(Errno),%o0
  40. call %o3
  41. ld [%o0],%o0
  42. .LNoThread:
  43. st %l0,[%o0]
  44. ba .LReturn
  45. mov -1,%i0
  46. .LSyscOK:
  47. // o1 contains 1 in the parent
  48. // and 0 in the child
  49. sub %o1, 1, %o1
  50. and %o0, %o1, %i0
  51. .LReturn:
  52. end;
  53. {$define FPC_SYSTEM_HAS_FPPIPE}
  54. Function fppipe(var fildes : tfildes):cint;assembler;
  55. {
  56. This function puts the registers in place, does the call, and then
  57. copies back the registers as they are after the SysCall.
  58. }
  59. asm
  60. mov 42,%g1
  61. mov %i0,%o0
  62. ta 0x10
  63. bcc .LSyscOK
  64. nop
  65. mov %o0,%l0
  66. sethi %hi(fpc_threadvar_relocate_proc),%o2
  67. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  68. ld [%o2],%o3
  69. subcc %o3,%g0,%g0
  70. bne .LThread
  71. nop
  72. sethi %hi(Errno+4),%o0
  73. ba .LNoThread
  74. or %o0,%lo(Errno+4),%o0
  75. .LThread:
  76. sethi %hi(Errno),%o0
  77. or %o0,%lo(Errno),%o0
  78. call %o3
  79. ld [%o0],%o0
  80. .LNoThread:
  81. st %l0,[%o0]
  82. mov -1,%o0
  83. .LSyscOK:
  84. st [%i0],%o0
  85. st [%i0+4],%o1
  86. end;
  87. {*****************************************************************************
  88. --- Main:The System Call Self ---
  89. *****************************************************************************}
  90. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  91. {
  92. This function puts the registers in place, does the call, and then
  93. copies back the registers as they are after the SysCall.
  94. }
  95. asm
  96. mov %i0,%g1
  97. ta 0x10
  98. bcc .LSyscOK
  99. nop
  100. mov %o0,%l0
  101. sethi %hi(fpc_threadvar_relocate_proc),%o2
  102. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  103. ld [%o2],%o3
  104. subcc %o3,%g0,%g0
  105. bne .LThread
  106. nop
  107. sethi %hi(Errno+4),%o0
  108. ba .LNoThread
  109. or %o0,%lo(Errno+4),%o0
  110. .LThread:
  111. sethi %hi(Errno),%o0
  112. or %o0,%lo(Errno),%o0
  113. call %o3
  114. ld [%o0],%o0
  115. .LNoThread:
  116. st %l0,[%o0]
  117. mov -1,%o0
  118. .LSyscOK:
  119. mov %o0,%i0
  120. end;
  121. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  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. asm
  127. mov %i0,%g1
  128. mov %i1,%o0
  129. ta 0x10
  130. bcc .LSyscOK
  131. nop
  132. mov %o0,%l0
  133. sethi %hi(fpc_threadvar_relocate_proc),%o2
  134. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  135. ld [%o2],%o3
  136. subcc %o3,%g0,%g0
  137. bne .LThread
  138. nop
  139. sethi %hi(Errno+4),%o0
  140. ba .LNoThread
  141. or %o0,%lo(Errno+4),%o0
  142. .LThread:
  143. sethi %hi(Errno),%o0
  144. or %o0,%lo(Errno),%o0
  145. call %o3
  146. ld [%o0],%o0
  147. .LNoThread:
  148. st %l0,[%o0]
  149. mov -1,%o0
  150. .LSyscOK:
  151. mov %o0,%i0
  152. end;
  153. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  154. {
  155. This function puts the registers in place, does the call, and then
  156. copies back the registers as they are after the SysCall.
  157. }
  158. asm
  159. mov %i0,%g1
  160. mov %i1,%o0
  161. mov %i2,%o1
  162. ta 0x10
  163. bcc .LSyscOK
  164. nop
  165. mov %o0,%l0
  166. sethi %hi(fpc_threadvar_relocate_proc),%o2
  167. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  168. ld [%o2],%o3
  169. subcc %o3,%g0,%g0
  170. bne .LThread
  171. nop
  172. sethi %hi(Errno+4),%o0
  173. ba .LNoThread
  174. or %o0,%lo(Errno+4),%o0
  175. .LThread:
  176. sethi %hi(Errno),%o0
  177. or %o0,%lo(Errno),%o0
  178. call %o3
  179. ld [%o0],%o0
  180. .LNoThread:
  181. st %l0,[%o0]
  182. mov -1,%o0
  183. .LSyscOK:
  184. mov %o0,%i0
  185. end;
  186. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  187. {
  188. This function puts the registers in place, does the call, and then
  189. copies back the registers as they are after the SysCall.
  190. }
  191. asm
  192. mov %i0,%g1
  193. mov %i1,%o0
  194. mov %i2,%o1
  195. mov %i3,%o2
  196. ta 0x10
  197. bcc .LSyscOK
  198. nop
  199. mov %o0,%l0
  200. sethi %hi(fpc_threadvar_relocate_proc),%o2
  201. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  202. ld [%o2],%o3
  203. subcc %o3,%g0,%g0
  204. bne .LThread
  205. nop
  206. sethi %hi(Errno+4),%o2
  207. ba .LNoThread
  208. or %o2,%lo(Errno+4),%o2
  209. .LThread:
  210. sethi %hi(Errno),%o0
  211. ld [%o3],%o1
  212. or %o0,%lo(Errno),%o0
  213. call %o1
  214. nop
  215. .LNoThread:
  216. st %o0,[%o2]
  217. mov -1,%o0
  218. .LSyscOK:
  219. mov %o0,%i0
  220. end;
  221. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  222. {
  223. This function puts the registers in place, does the call, and then
  224. copies back the registers as they are after the SysCall.
  225. }
  226. asm
  227. mov %i0,%g1
  228. mov %i1,%o0
  229. mov %i2,%o1
  230. mov %i3,%o2
  231. mov %i4,%o3
  232. ta 0x10
  233. bcc .LSyscOK
  234. nop
  235. mov %o0,%l0
  236. sethi %hi(fpc_threadvar_relocate_proc),%o2
  237. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  238. ld [%o2],%o3
  239. subcc %o3,%g0,%g0
  240. bne .LThread
  241. nop
  242. sethi %hi(Errno+4),%o0
  243. ba .LNoThread
  244. or %o0,%lo(Errno+4),%o0
  245. .LThread:
  246. sethi %hi(Errno),%o0
  247. or %o0,%lo(Errno),%o0
  248. call %o3
  249. ld [%o0],%o0
  250. .LNoThread:
  251. st %l0,[%o0]
  252. mov -1,%o0
  253. .LSyscOK:
  254. mov %o0,%i0
  255. end;
  256. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  257. {
  258. This function puts the registers in place, does the call, and then
  259. copies back the registers as they are after the SysCall.
  260. }
  261. asm
  262. mov %i0,%g1
  263. mov %i1,%o0
  264. mov %i2,%o1
  265. mov %i3,%o2
  266. mov %i4,%o3
  267. mov %i5,%o4
  268. ta 0x10
  269. bcc .LSyscOK
  270. nop
  271. mov %o0,%l0
  272. sethi %hi(fpc_threadvar_relocate_proc),%o2
  273. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  274. ld [%o2],%o3
  275. subcc %o3,%g0,%g0
  276. bne .LThread
  277. nop
  278. sethi %hi(Errno+4),%o0
  279. ba .LNoThread
  280. or %o0,%lo(Errno+4),%o0
  281. .LThread:
  282. sethi %hi(Errno),%o0
  283. or %o0,%lo(Errno),%o0
  284. call %o3
  285. ld [%o0],%o0
  286. .LNoThread:
  287. st %l0,[%o0]
  288. mov -1,%o0
  289. .LSyscOK:
  290. mov %o0,%i0
  291. end;
  292. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  293. {
  294. This function puts the registers in place, does the call, and then
  295. copies back the registers as they are after the SysCall.
  296. }
  297. asm
  298. mov %i0,%g1
  299. mov %i1,%o0
  300. mov %i2,%o1
  301. mov %i3,%o2
  302. mov %i4,%o3
  303. ld [%i6+92],%o5
  304. mov %i5,%o4
  305. ta 0x10
  306. bcc .LSyscOK
  307. nop
  308. mov %o0,%l0
  309. sethi %hi(fpc_threadvar_relocate_proc),%o2
  310. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  311. ld [%o2],%o3
  312. subcc %o3,%g0,%g0
  313. bne .LThread
  314. nop
  315. sethi %hi(Errno+4),%o0
  316. ba .LNoThread
  317. or %o0,%lo(Errno+4),%o0
  318. .LThread:
  319. sethi %hi(Errno),%o0
  320. or %o0,%lo(Errno),%o0
  321. call %o3
  322. ld [%o0],%o0
  323. .LNoThread:
  324. st %l0,[%o0]
  325. mov -1,%o0
  326. .LSyscOK:
  327. mov %o0,%i0
  328. end;
  329. {
  330. $Log$
  331. Revision 1.18 2005-03-03 20:13:44 florian
  332. + sparc specific pipe implementation
  333. Revision 1.17 2005/02/14 17:13:30 peter
  334. * truncate log
  335. }