syscall.inc 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {
  2. $Id: syscall.inc,v 1.1 2003/01/08 22:32:28 marco Exp $
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This include implements the actual system call for the
  5. intel BeOS 80x86 platform.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. MA 02110-1301, USA.
  18. ****************************************************************************
  19. }
  20. // Under BeOS, we use stdcall for this line because the default calling convention in 1.9
  21. // is register instead of stdcall. But assembler is already written, so i used the stdcall
  22. // calling convention !
  23. function Do_SysCall( callnr : longint; var regs : SysCallArgs ): longint; stdcall; assembler; [public, alias : 'FPC_SYSCALL'];
  24. {
  25. This routine sets up the parameters on the stack, all the parameters
  26. are in reverse order on the stack (like C parameter passing).
  27. }
  28. asm
  29. { load the parameters... }
  30. movl regs,%eax
  31. movl 24(%eax),%ebx
  32. pushl %ebx
  33. movl 20(%eax),%ebx
  34. pushl %ebx
  35. movl 16(%eax),%ebx
  36. pushl %ebx
  37. movl 12(%eax),%ebx
  38. pushl %ebx
  39. movl 8(%eax),%ebx
  40. pushl %ebx
  41. movl 4(%eax),%ebx
  42. pushl %ebx
  43. movl 0(%eax),%ebx
  44. pushl %ebx
  45. { set the call number }
  46. movl callnr,%eax
  47. call sys_call
  48. addl $28,%esp
  49. end;
  50. // Under BeOS, we use stdcall for this line because the default calling convention in 1.9
  51. // is register instead of stdcall. But assembler is already written, so i used the stdcall
  52. // calling convention ! Maybe don't needed here. But to be sure...
  53. Function SysCall( callnr:longint;var args : SysCallArgs ):longint; stdcall;
  54. {
  55. This function serves as an interface to do_SysCall.
  56. If the SysCall returned a negative number, it returns -1, and puts the
  57. SysCall result in errno. Otherwise, it returns the SysCall return value
  58. }
  59. var
  60. funcresult : longint;
  61. begin
  62. funcresult := do_SysCall(callnr, args);
  63. if funcresult < 0 then
  64. begin
  65. errno := funcresult;
  66. SysCall := - 1;
  67. end
  68. else
  69. begin
  70. SysCall := funcresult;
  71. errno := 0;
  72. end;
  73. end;