syscall.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. function get_got : pointer;assembler;{$ifndef FPC_PIC}nostackframe;{$endif} forward;
  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. {$ifdef FPC_PIC}
  24. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  25. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  26. call get_got
  27. nop
  28. {$endif FPC_PIC}
  29. mov 2,%g1
  30. ta 0x10
  31. bcc .LSyscOK
  32. nop
  33. mov %o0,%l0
  34. sethi %hi(fpc_threadvar_relocate_proc),%o2
  35. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  36. {$ifdef FPC_PIC}
  37. ld [%o2+%l7],%o2
  38. {$endif FPC_PIC}
  39. ld [%o2],%o3
  40. cmp %o3,0
  41. bne .LThread
  42. nop
  43. {$ifndef FPC_PIC}
  44. sethi %hi(Errno+4),%o0
  45. ba .LNoThread
  46. or %o0,%lo(Errno+4),%o0
  47. {$else FPC_PIC}
  48. sethi %hi(Errno),%o0
  49. or %o0,%lo(Errno),%o0
  50. ld [%o0+%l7],%o0
  51. ba .LNoThread
  52. add %o0,4,%o0
  53. {$endif FPC_PIC}
  54. .LThread:
  55. sethi %hi(Errno),%o0
  56. or %o0,%lo(Errno),%o0
  57. {$ifdef FPC_PIC}
  58. ld [%o0+%l7],%o0
  59. {$endif FPC_PIC}
  60. call %o3
  61. ld [%o0],%o0
  62. .LNoThread:
  63. st %l0,[%o0]
  64. ba .LReturn
  65. mov -1,%i0
  66. .LSyscOK:
  67. // o1 contains 1 in the parent
  68. // and 0 in the child
  69. sub %o1, 1, %o1
  70. and %o0, %o1, %i0
  71. .LReturn:
  72. end;
  73. {*****************************************************************************
  74. --- Main:The System Call Self ---
  75. *****************************************************************************}
  76. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  77. {
  78. This function puts the registers in place, does the call, and then
  79. copies back the registers as they are after the SysCall.
  80. }
  81. asm
  82. {$ifdef FPC_PIC}
  83. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  84. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  85. call get_got
  86. nop
  87. {$endif FPC_PIC}
  88. mov %i0,%g1
  89. ta 0x10
  90. bcc .LSyscOK
  91. nop
  92. mov %o0,%l0
  93. sethi %hi(fpc_threadvar_relocate_proc),%o2
  94. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  95. {$ifdef FPC_PIC}
  96. ld [%o2+%l7],%o2
  97. {$endif FPC_PIC}
  98. ld [%o2],%o3
  99. cmp %o3,0
  100. bne .LThread
  101. nop
  102. {$ifndef FPC_PIC}
  103. sethi %hi(Errno+4),%o0
  104. ba .LNoThread
  105. or %o0,%lo(Errno+4),%o0
  106. {$else FPC_PIC}
  107. sethi %hi(Errno),%o0
  108. or %o0,%lo(Errno),%o0
  109. ld [%o0+%l7],%o0
  110. ba .LNoThread
  111. add %o0,4,%o0
  112. {$endif FPC_PIC}
  113. .LThread:
  114. sethi %hi(Errno),%o0
  115. or %o0,%lo(Errno),%o0
  116. {$ifdef FPC_PIC}
  117. ld [%o0+%l7],%o0
  118. {$endif FPC_PIC}
  119. call %o3
  120. ld [%o0],%o0
  121. .LNoThread:
  122. st %l0,[%o0]
  123. mov -1,%o0
  124. .LSyscOK:
  125. mov %o0,%i0
  126. end;
  127. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  128. {
  129. This function puts the registers in place, does the call, and then
  130. copies back the registers as they are after the SysCall.
  131. }
  132. asm
  133. {$ifdef FPC_PIC}
  134. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  135. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  136. call get_got
  137. nop
  138. {$endif FPC_PIC}
  139. mov %i0,%g1
  140. mov %i1,%o0
  141. ta 0x10
  142. bcc .LSyscOK
  143. nop
  144. mov %o0,%l0
  145. sethi %hi(fpc_threadvar_relocate_proc),%o2
  146. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  147. {$ifdef FPC_PIC}
  148. ld [%o2+%l7],%o2
  149. {$endif FPC_PIC}
  150. ld [%o2],%o3
  151. cmp %o3,0
  152. bne .LThread
  153. nop
  154. {$ifndef FPC_PIC}
  155. sethi %hi(Errno+4),%o0
  156. ba .LNoThread
  157. or %o0,%lo(Errno+4),%o0
  158. {$else FPC_PIC}
  159. sethi %hi(Errno),%o0
  160. or %o0,%lo(Errno),%o0
  161. ld [%o0+%l7],%o0
  162. ba .LNoThread
  163. add %o0,4,%o0
  164. {$endif FPC_PIC}
  165. .LThread:
  166. sethi %hi(Errno),%o0
  167. or %o0,%lo(Errno),%o0
  168. {$ifdef FPC_PIC}
  169. ld [%o0+%l7],%o0
  170. {$endif FPC_PIC}
  171. call %o3
  172. ld [%o0],%o0
  173. .LNoThread:
  174. st %l0,[%o0]
  175. mov -1,%o0
  176. .LSyscOK:
  177. mov %o0,%i0
  178. end;
  179. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  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. {$ifdef FPC_PIC}
  186. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  187. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  188. call get_got
  189. nop
  190. {$endif FPC_PIC}
  191. mov %i0,%g1
  192. mov %i1,%o0
  193. mov %i2,%o1
  194. ta 0x10
  195. bcc .LSyscOK
  196. nop
  197. mov %o0,%l0
  198. sethi %hi(fpc_threadvar_relocate_proc),%o2
  199. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  200. {$ifdef FPC_PIC}
  201. ld [%o2+%l7],%o2
  202. {$endif FPC_PIC}
  203. ld [%o2],%o3
  204. cmp %o3,0
  205. bne .LThread
  206. nop
  207. {$ifndef FPC_PIC}
  208. sethi %hi(Errno+4),%o0
  209. ba .LNoThread
  210. or %o0,%lo(Errno+4),%o0
  211. {$else FPC_PIC}
  212. sethi %hi(Errno),%o0
  213. or %o0,%lo(Errno),%o0
  214. ld [%o0+%l7],%o0
  215. ba .LNoThread
  216. add %o0,4,%o0
  217. {$endif FPC_PIC}
  218. .LThread:
  219. sethi %hi(Errno),%o0
  220. or %o0,%lo(Errno),%o0
  221. {$ifdef FPC_PIC}
  222. ld [%o0+%l7],%o0
  223. {$endif FPC_PIC}
  224. call %o3
  225. ld [%o0],%o0
  226. .LNoThread:
  227. st %l0,[%o0]
  228. mov -1,%o0
  229. .LSyscOK:
  230. mov %o0,%i0
  231. end;
  232. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  233. {
  234. This function puts the registers in place, does the call, and then
  235. copies back the registers as they are after the SysCall.
  236. }
  237. asm
  238. {$ifdef FPC_PIC}
  239. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  240. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  241. call get_got
  242. nop
  243. {$endif FPC_PIC}
  244. mov %i0,%g1
  245. mov %i1,%o0
  246. mov %i2,%o1
  247. mov %i3,%o2
  248. ta 0x10
  249. bcc .LSyscOK
  250. nop
  251. mov %o0,%l0
  252. sethi %hi(fpc_threadvar_relocate_proc),%o2
  253. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  254. {$ifdef FPC_PIC}
  255. ld [%o2+%l7],%o2
  256. {$endif FPC_PIC}
  257. ld [%o2],%o3
  258. cmp %o3,0
  259. bne .LThread
  260. nop
  261. {$ifndef FPC_PIC}
  262. sethi %hi(Errno+4),%o0
  263. ba .LNoThread
  264. or %o0,%lo(Errno+4),%o0
  265. {$else FPC_PIC}
  266. sethi %hi(Errno),%o0
  267. or %o0,%lo(Errno),%o0
  268. ld [%o0+%l7],%o0
  269. ba .LNoThread
  270. add %o0,4,%o0
  271. {$endif FPC_PIC}
  272. .LThread:
  273. sethi %hi(Errno),%o0
  274. or %o0,%lo(Errno),%o0
  275. {$ifdef FPC_PIC}
  276. ld [%o0+%l7],%o0
  277. {$endif FPC_PIC}
  278. call %o3
  279. ld [%o0],%o0
  280. .LNoThread:
  281. st %l0,[%o0]
  282. mov -1,%o0
  283. .LSyscOK:
  284. mov %o0,%i0
  285. end;
  286. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  287. {
  288. This function puts the registers in place, does the call, and then
  289. copies back the registers as they are after the SysCall.
  290. }
  291. asm
  292. {$ifdef FPC_PIC}
  293. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  294. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  295. call get_got
  296. nop
  297. {$endif FPC_PIC}
  298. mov %i0,%g1
  299. mov %i1,%o0
  300. mov %i2,%o1
  301. mov %i3,%o2
  302. mov %i4,%o3
  303. ta 0x10
  304. bcc .LSyscOK
  305. nop
  306. mov %o0,%l0
  307. sethi %hi(fpc_threadvar_relocate_proc),%o2
  308. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  309. {$ifdef FPC_PIC}
  310. ld [%o2+%l7],%o2
  311. {$endif FPC_PIC}
  312. ld [%o2],%o3
  313. cmp %o3,0
  314. bne .LThread
  315. nop
  316. {$ifndef FPC_PIC}
  317. sethi %hi(Errno+4),%o0
  318. ba .LNoThread
  319. or %o0,%lo(Errno+4),%o0
  320. {$else FPC_PIC}
  321. sethi %hi(Errno),%o0
  322. or %o0,%lo(Errno),%o0
  323. ld [%o0+%l7],%o0
  324. ba .LNoThread
  325. add %o0,4,%o0
  326. {$endif FPC_PIC}
  327. .LThread:
  328. sethi %hi(Errno),%o0
  329. or %o0,%lo(Errno),%o0
  330. {$ifdef FPC_PIC}
  331. ld [%o0+%l7],%o0
  332. {$endif FPC_PIC}
  333. call %o3
  334. ld [%o0],%o0
  335. .LNoThread:
  336. st %l0,[%o0]
  337. mov -1,%o0
  338. .LSyscOK:
  339. mov %o0,%i0
  340. end;
  341. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  342. {
  343. This function puts the registers in place, does the call, and then
  344. copies back the registers as they are after the SysCall.
  345. }
  346. asm
  347. {$ifdef FPC_PIC}
  348. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  349. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  350. call get_got
  351. nop
  352. {$endif FPC_PIC}
  353. mov %i0,%g1
  354. mov %i1,%o0
  355. mov %i2,%o1
  356. mov %i3,%o2
  357. mov %i4,%o3
  358. mov %i5,%o4
  359. ta 0x10
  360. bcc .LSyscOK
  361. nop
  362. mov %o0,%l0
  363. sethi %hi(fpc_threadvar_relocate_proc),%o2
  364. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  365. {$ifdef FPC_PIC}
  366. ld [%o2+%l7],%o2
  367. {$endif FPC_PIC}
  368. ld [%o2],%o3
  369. cmp %o3,0
  370. bne .LThread
  371. nop
  372. {$ifndef FPC_PIC}
  373. sethi %hi(Errno+4),%o0
  374. ba .LNoThread
  375. or %o0,%lo(Errno+4),%o0
  376. {$else FPC_PIC}
  377. sethi %hi(Errno),%o0
  378. or %o0,%lo(Errno),%o0
  379. ld [%o0+%l7],%o0
  380. ba .LNoThread
  381. add %o0,4,%o0
  382. {$endif FPC_PIC}
  383. .LThread:
  384. sethi %hi(Errno),%o0
  385. or %o0,%lo(Errno),%o0
  386. {$ifdef FPC_PIC}
  387. ld [%o0+%l7],%o0
  388. {$endif FPC_PIC}
  389. call %o3
  390. ld [%o0],%o0
  391. .LNoThread:
  392. st %l0,[%o0]
  393. mov -1,%o0
  394. .LSyscOK:
  395. mov %o0,%i0
  396. end;
  397. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  398. {
  399. This function puts the registers in place, does the call, and then
  400. copies back the registers as they are after the SysCall.
  401. }
  402. asm
  403. {$ifdef FPC_PIC}
  404. sethi %hi(_GLOBAL_OFFSET_TABLE_ -8),%l7
  405. or %l7,%lo(_GLOBAL_OFFSET_TABLE_ -4),%l7
  406. call get_got
  407. nop
  408. {$endif FPC_PIC}
  409. mov %i0,%g1
  410. mov %i1,%o0
  411. mov %i2,%o1
  412. mov %i3,%o2
  413. mov %i4,%o3
  414. ld [%i6+92],%o5
  415. mov %i5,%o4
  416. ta 0x10
  417. bcc .LSyscOK
  418. nop
  419. mov %o0,%l0
  420. sethi %hi(fpc_threadvar_relocate_proc),%o2
  421. or %o2,%lo(fpc_threadvar_relocate_proc),%o2
  422. {$ifdef FPC_PIC}
  423. ld [%o2+%l7],%o2
  424. {$endif FPC_PIC}
  425. ld [%o2],%o3
  426. cmp %o3,0
  427. bne .LThread
  428. nop
  429. {$ifndef FPC_PIC}
  430. sethi %hi(Errno+4),%o0
  431. ba .LNoThread
  432. or %o0,%lo(Errno+4),%o0
  433. {$else FPC_PIC}
  434. sethi %hi(Errno),%o0
  435. or %o0,%lo(Errno),%o0
  436. ld [%o0+%l7],%o0
  437. ba .LNoThread
  438. add %o0,4,%o0
  439. {$endif FPC_PIC}
  440. .LThread:
  441. sethi %hi(Errno),%o0
  442. or %o0,%lo(Errno),%o0
  443. {$ifdef FPC_PIC}
  444. ld [%o0+%l7],%o0
  445. {$endif FPC_PIC}
  446. call %o3
  447. ld [%o0],%o0
  448. .LNoThread:
  449. st %l0,[%o0]
  450. mov -1,%o0
  451. .LSyscOK:
  452. mov %o0,%i0
  453. end;