2
0

syscall.inc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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),%o0
  172. ba .LNoThread
  173. or %o0,%lo(Errno+4),%o0
  174. .LThread:
  175. sethi %hi(Errno),%o0
  176. or %o0,%lo(Errno),%o0
  177. call %o3
  178. ld [%o0],%o0
  179. .LNoThread:
  180. st %l0,[%o0]
  181. mov -1,%o0
  182. .LSyscOK:
  183. mov %o0,%i0
  184. end;
  185. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  186. {
  187. This function puts the registers in place, does the call, and then
  188. copies back the registers as they are after the SysCall.
  189. }
  190. asm
  191. mov %i0,%g1
  192. mov %i1,%o0
  193. mov %i2,%o1
  194. mov %i3,%o2
  195. mov %i4,%o3
  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),%o0
  207. ba .LNoThread
  208. or %o0,%lo(Errno+4),%o0
  209. .LThread:
  210. sethi %hi(Errno),%o0
  211. or %o0,%lo(Errno),%o0
  212. call %o3
  213. ld [%o0],%o0
  214. .LNoThread:
  215. st %l0,[%o0]
  216. mov -1,%o0
  217. .LSyscOK:
  218. mov %o0,%i0
  219. end;
  220. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  221. {
  222. This function puts the registers in place, does the call, and then
  223. copies back the registers as they are after the SysCall.
  224. }
  225. asm
  226. mov %i0,%g1
  227. mov %i1,%o0
  228. mov %i2,%o1
  229. mov %i3,%o2
  230. mov %i4,%o3
  231. mov %i5,%o4
  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,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  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. ld [%i6+92],%o5
  268. mov %i5,%o4
  269. ta 0x10
  270. bcc .LSyscOK
  271. nop
  272. mov %o0,%l0
  273. sethi %hi(fpc_threadvar_relocate_proc),%o2
  274. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  275. ld [%o2],%o3
  276. subcc %o3,%g0,%g0
  277. bne .LThread
  278. nop
  279. sethi %hi(Errno+4),%o0
  280. ba .LNoThread
  281. or %o0,%lo(Errno+4),%o0
  282. .LThread:
  283. sethi %hi(Errno),%o0
  284. or %o0,%lo(Errno),%o0
  285. call %o3
  286. ld [%o0],%o0
  287. .LNoThread:
  288. st %l0,[%o0]
  289. mov -1,%o0
  290. .LSyscOK:
  291. mov %o0,%i0
  292. end;