syscall.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Marco van de Voort
  4. Syscall functions for i386 *BSD.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. These functions are the same over all three BSDs, except that some have a
  18. 32-bit Errno, and some a 16-bit}
  19. {$ifdef NetBSD}
  20. {$UNDEF ErrnoWord}
  21. {$endif}
  22. {$ifdef FreeBSD}
  23. {$DEFINE ErrnoWord}
  24. {$endif}
  25. procedure actualsyscall; assembler; {inline requires a dummy push IIRC}
  26. asm
  27. int $0x80
  28. jb .LErrorcode
  29. ret
  30. .LErrorcode:
  31. {$ifdef ErrnoWord}
  32. movw %bx,Errno
  33. {$else}
  34. movl %ebx,Errno
  35. {$endif}
  36. // mov $-1,%eax
  37. end;
  38. function Do_SysCall(sysnr:LONGINT):longint; assembler; [public,alias:'FPC_DOSYS0'];
  39. asm
  40. movl sysnr,%eax
  41. call actualsyscall
  42. end;
  43. function Do_SysCall(sysnr,param1:longint):longint; assembler;[public,alias:'FPC_DOSYS1'];
  44. asm
  45. movl sysnr,%eax
  46. pushl Param1
  47. call actualsyscall
  48. addl $4,%esp
  49. end;
  50. function Do_SysCall(sysnr,param1:integer):longint; assembler;[public,alias:'FPC_DOSYS1w'];
  51. asm
  52. movl sysnr,%eax
  53. pushw Param1
  54. call actualsyscall
  55. add $2,%esp
  56. end;
  57. function Do_SysCall(sysnr,param1,param2:LONGINT):longint; assembler; [public,alias:'FPC_DOSYS2'];
  58. asm
  59. movl sysnr,%eax
  60. pushl param2
  61. pushl Param1
  62. call actualsyscall
  63. addl $8,%esp
  64. end;
  65. function Do_SysCall(sysnr,param1,param2,param3:LONGINT):longint; assembler;[public,alias:'FPC_DOSYS3'];
  66. asm
  67. movl sysnr,%eax
  68. pushl param3
  69. pushl param2
  70. pushl Param1
  71. call actualsyscall
  72. addl $12,%esp
  73. end;
  74. function Do_SysCall(sysnr,param1,param2,param3,param4:LONGINT):longint; assembler;[public,alias:'FPC_DOSYS4'];
  75. asm
  76. movl sysnr,%eax
  77. pushl param4
  78. pushl param3
  79. pushl param2
  80. pushl Param1
  81. call actualsyscall
  82. addl $16,%esp
  83. end;
  84. function Do_SysCall(sysnr,param1,param2,param3,param4,param5:LONGINT):longint; assembler;[public,alias:'FPC_DOSYS5'];
  85. asm
  86. movl sysnr,%eax
  87. pushl param5
  88. pushl param4
  89. pushl param3
  90. pushl param2
  91. pushl Param1
  92. call actualsyscall
  93. addl $20,%esp
  94. end;
  95. function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:LONGINT):longint; assembler;[public,alias:'FPC_DOSYS6'];
  96. asm
  97. movl sysnr,%eax
  98. pushl param6
  99. pushl param5
  100. pushl param4
  101. pushl param3
  102. pushl param2
  103. pushl Param1
  104. call actualsyscall
  105. addl $24,%esp
  106. end;
  107. function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:LONGINT):longint; assembler; [public,alias:'FPC_DOSYS7'];
  108. asm
  109. movl sysnr,%eax
  110. pushl param7
  111. pushl param6
  112. pushl param5
  113. pushl param4
  114. pushl param3
  115. pushl param2
  116. pushl Param1
  117. call actualsyscall
  118. addl $28,%esp
  119. end;
  120. {
  121. $Log:
  122. }