syscall.inc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  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. {$define FPC_SYSTEM_HAS_FPFORK}
  16. {
  17. behaviour of result of fork on sparc/linux is different than on other
  18. linux flavours
  19. }
  20. function Fpfork : pid_t; [public, alias : 'FPC_SYSC_FORK'];assembler;
  21. asm
  22. mov 2,%g1
  23. ta 0x10
  24. bcc .LSyscOK
  25. nop
  26. mov %o0,%l0
  27. sethi %hi(fpc_threadvar_relocate_proc),%o2
  28. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  29. ld [%o2],%o3
  30. subcc %o3,%g0,%g0
  31. bne .LThread
  32. nop
  33. sethi %hi(Errno+4),%o0
  34. ba .LNoThread
  35. or %o0,%lo(Errno+4),%o0
  36. .LThread:
  37. sethi %hi(Errno),%o0
  38. or %o0,%lo(Errno),%o0
  39. call %o3
  40. ld [%o0],%o0
  41. .LNoThread:
  42. st %l0,[%o0]
  43. ba .LReturn
  44. mov -1,%i0
  45. .LSyscOK:
  46. // o1 contains 1 in the parent
  47. // and 0 in the child
  48. sub %o1, 1, %o1
  49. and %o0, %o1, %i0
  50. .LReturn:
  51. end;
  52. {*****************************************************************************
  53. --- Main:The System Call Self ---
  54. *****************************************************************************}
  55. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  56. {
  57. This function puts the registers in place, does the call, and then
  58. copies back the registers as they are after the SysCall.
  59. }
  60. asm
  61. mov %i0,%g1
  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. mov %o0,%i0
  85. end;
  86. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  87. {
  88. This function puts the registers in place, does the call, and then
  89. copies back the registers as they are after the SysCall.
  90. }
  91. asm
  92. mov %i0,%g1
  93. mov %i1,%o0
  94. ta 0x10
  95. bcc .LSyscOK
  96. nop
  97. mov %o0,%l0
  98. sethi %hi(fpc_threadvar_relocate_proc),%o2
  99. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  100. ld [%o2],%o3
  101. subcc %o3,%g0,%g0
  102. bne .LThread
  103. nop
  104. sethi %hi(Errno+4),%o0
  105. ba .LNoThread
  106. or %o0,%lo(Errno+4),%o0
  107. .LThread:
  108. sethi %hi(Errno),%o0
  109. or %o0,%lo(Errno),%o0
  110. call %o3
  111. ld [%o0],%o0
  112. .LNoThread:
  113. st %l0,[%o0]
  114. mov -1,%o0
  115. .LSyscOK:
  116. mov %o0,%i0
  117. end;
  118. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  119. {
  120. This function puts the registers in place, does the call, and then
  121. copies back the registers as they are after the SysCall.
  122. }
  123. asm
  124. mov %i0,%g1
  125. mov %i1,%o0
  126. mov %i2,%o1
  127. ta 0x10
  128. bcc .LSyscOK
  129. nop
  130. mov %o0,%l0
  131. sethi %hi(fpc_threadvar_relocate_proc),%o2
  132. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  133. ld [%o2],%o3
  134. subcc %o3,%g0,%g0
  135. bne .LThread
  136. nop
  137. sethi %hi(Errno+4),%o0
  138. ba .LNoThread
  139. or %o0,%lo(Errno+4),%o0
  140. .LThread:
  141. sethi %hi(Errno),%o0
  142. or %o0,%lo(Errno),%o0
  143. call %o3
  144. ld [%o0],%o0
  145. .LNoThread:
  146. st %l0,[%o0]
  147. mov -1,%o0
  148. .LSyscOK:
  149. mov %o0,%i0
  150. end;
  151. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  152. {
  153. This function puts the registers in place, does the call, and then
  154. copies back the registers as they are after the SysCall.
  155. }
  156. asm
  157. mov %i0,%g1
  158. mov %i1,%o0
  159. mov %i2,%o1
  160. mov %i3,%o2
  161. ta 0x10
  162. bcc .LSyscOK
  163. nop
  164. mov %o0,%l0
  165. sethi %hi(fpc_threadvar_relocate_proc),%o2
  166. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  167. ld [%o2],%o3
  168. subcc %o3,%g0,%g0
  169. bne .LThread
  170. nop
  171. sethi %hi(Errno+4),%o2
  172. ba .LNoThread
  173. or %o2,%lo(Errno+4),%o2
  174. .LThread:
  175. sethi %hi(Errno),%o0
  176. ld [%o3],%o1
  177. or %o0,%lo(Errno),%o0
  178. call %o1
  179. nop
  180. .LNoThread:
  181. st %o0,[%o2]
  182. mov -1,%o0
  183. .LSyscOK:
  184. mov %o0,%i0
  185. end;
  186. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  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. mov %i4,%o3
  197. ta 0x10
  198. bcc .LSyscOK
  199. nop
  200. mov %o0,%l0
  201. sethi %hi(fpc_threadvar_relocate_proc),%o2
  202. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  203. ld [%o2],%o3
  204. subcc %o3,%g0,%g0
  205. bne .LThread
  206. nop
  207. sethi %hi(Errno+4),%o0
  208. ba .LNoThread
  209. or %o0,%lo(Errno+4),%o0
  210. .LThread:
  211. sethi %hi(Errno),%o0
  212. or %o0,%lo(Errno),%o0
  213. call %o3
  214. ld [%o0],%o0
  215. .LNoThread:
  216. st %l0,[%o0]
  217. mov -1,%o0
  218. .LSyscOK:
  219. mov %o0,%i0
  220. end;
  221. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  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. mov %i5,%o4
  233. ta 0x10
  234. bcc .LSyscOK
  235. nop
  236. mov %o0,%l0
  237. sethi %hi(fpc_threadvar_relocate_proc),%o2
  238. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  239. ld [%o2],%o3
  240. subcc %o3,%g0,%g0
  241. bne .LThread
  242. nop
  243. sethi %hi(Errno+4),%o0
  244. ba .LNoThread
  245. or %o0,%lo(Errno+4),%o0
  246. .LThread:
  247. sethi %hi(Errno),%o0
  248. or %o0,%lo(Errno),%o0
  249. call %o3
  250. ld [%o0],%o0
  251. .LNoThread:
  252. st %l0,[%o0]
  253. mov -1,%o0
  254. .LSyscOK:
  255. mov %o0,%i0
  256. end;
  257. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  258. {
  259. This function puts the registers in place, does the call, and then
  260. copies back the registers as they are after the SysCall.
  261. }
  262. asm
  263. mov %i0,%g1
  264. mov %i1,%o0
  265. mov %i2,%o1
  266. mov %i3,%o2
  267. mov %i4,%o3
  268. ld [%i6+92],%o5
  269. mov %i5,%o4
  270. ta 0x10
  271. bcc .LSyscOK
  272. nop
  273. mov %o0,%l0
  274. sethi %hi(fpc_threadvar_relocate_proc),%o2
  275. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  276. ld [%o2],%o3
  277. subcc %o3,%g0,%g0
  278. bne .LThread
  279. nop
  280. sethi %hi(Errno+4),%o0
  281. ba .LNoThread
  282. or %o0,%lo(Errno+4),%o0
  283. .LThread:
  284. sethi %hi(Errno),%o0
  285. or %o0,%lo(Errno),%o0
  286. call %o3
  287. ld [%o0],%o0
  288. .LNoThread:
  289. st %l0,[%o0]
  290. mov -1,%o0
  291. .LSyscOK:
  292. mov %o0,%i0
  293. end;