syscall.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Perform syscall with 0..6 arguments.
  4. If syscall return value is negative, negate it, set errno, and return -1.
  5. Written by Edmund Grimley Evans in 2015 and released into the public domain.
  6. }
  7. function FpSysCall(sysnr:TSysParam):TSysResult;
  8. assembler; nostackframe; [public,alias:'FPC_SYSCALL0'];
  9. asm
  10. mov w8,w0
  11. svc #0
  12. tbz x0,#63,.Ldone
  13. str x30,[sp,#-16]!
  14. neg x0,x0
  15. bl seterrno
  16. ldr x30,[sp],#16
  17. mov x0,#-1
  18. .Ldone:
  19. end;
  20. function FpSysCall(sysnr,param1:TSysParam):TSysResult;
  21. assembler; nostackframe; [public,alias:'FPC_SYSCALL1'];
  22. asm
  23. mov w8,w0
  24. mov x0,x1
  25. svc #0
  26. tbz x0,#63,.Ldone
  27. str x30,[sp,#-16]!
  28. neg x0,x0
  29. bl seterrno
  30. ldr x30,[sp],#16
  31. mov x0,#-1
  32. .Ldone:
  33. end;
  34. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult;
  35. assembler; nostackframe; [public,alias:'FPC_SYSCALL2'];
  36. asm
  37. mov w8,w0
  38. mov x0,x1
  39. mov x1,x2
  40. svc #0
  41. tbz x0,#63,.Ldone
  42. str x30,[sp,#-16]!
  43. neg x0,x0
  44. bl seterrno
  45. ldr x30,[sp],#16
  46. mov x0,#-1
  47. .Ldone:
  48. end;
  49. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult;
  50. assembler; nostackframe; [public,alias:'FPC_SYSCALL3'];
  51. asm
  52. mov w8,w0
  53. mov x0,x1
  54. mov x1,x2
  55. mov x2,x3
  56. svc #0
  57. tbz x0,#63,.Ldone
  58. str x30,[sp,#-16]!
  59. neg x0,x0
  60. bl seterrno
  61. ldr x30,[sp],#16
  62. mov x0,#-1
  63. .Ldone:
  64. end;
  65. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult;
  66. assembler; nostackframe; [public,alias:'FPC_SYSCALL4'];
  67. asm
  68. mov w8,w0
  69. mov x0,x1
  70. mov x1,x2
  71. mov x2,x3
  72. mov x3,x4
  73. svc #0
  74. tbz x0,#63,.Ldone
  75. str x30,[sp,#-16]!
  76. neg x0,x0
  77. bl seterrno
  78. ldr x30,[sp],#16
  79. mov x0,#-1
  80. .Ldone:
  81. end;
  82. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult;
  83. assembler; nostackframe; [public,alias:'FPC_SYSCALL5'];
  84. asm
  85. mov w8,w0
  86. mov x0,x1
  87. mov x1,x2
  88. mov x2,x3
  89. mov x3,x4
  90. mov x4,x5
  91. svc #0
  92. tbz x0,#63,.Ldone
  93. str x30,[sp,#-16]!
  94. neg x0,x0
  95. bl seterrno
  96. ldr x30,[sp],#16
  97. mov x0,#-1
  98. .Ldone:
  99. end;
  100. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult;
  101. assembler; nostackframe; [public,alias:'FPC_SYSCALL6'];
  102. asm
  103. mov w8,w0
  104. mov x0,x1
  105. mov x1,x2
  106. mov x2,x3
  107. mov x3,x4
  108. mov x4,x5
  109. mov x5,x6
  110. svc #0
  111. tbz x0,#63,.Ldone
  112. str x30,[sp,#-16]!
  113. neg x0,x0
  114. bl seterrno
  115. ldr x30,[sp],#16
  116. mov x0,#-1
  117. .Ldone:
  118. end;