syscall.inc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1998-2000 Florian P Klaempfl
  4. Copyright (c) 2002 Marco van de Voort
  5. member of the Free Pascal development team.
  6. This include implements the actual system call for the
  7. intel BeOS 80x86 platform.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  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.
  13. **********************************************************************}
  14. // Under BeOS, we use stdcall for this line because the default calling convention in 1.9
  15. // is register instead of stdcall. But assembler is already written, so i used the stdcall
  16. // calling convention !
  17. function Do_SysCall( callnr : longint; var regs : SysCallArgs ): longint; stdcall; assembler; [public, alias : 'FPC_SYSCALL'];
  18. {
  19. This routine sets up the parameters on the stack, all the parameters
  20. are in reverse order on the stack (like C parameter passing).
  21. }
  22. asm
  23. { load the parameters... }
  24. movl regs,%eax
  25. movl 24(%eax),%ebx
  26. pushl %ebx
  27. movl 20(%eax),%ebx
  28. pushl %ebx
  29. movl 16(%eax),%ebx
  30. pushl %ebx
  31. movl 12(%eax),%ebx
  32. pushl %ebx
  33. movl 8(%eax),%ebx
  34. pushl %ebx
  35. movl 4(%eax),%ebx
  36. pushl %ebx
  37. movl 0(%eax),%ebx
  38. pushl %ebx
  39. { set the call number }
  40. movl callnr,%eax
  41. call sys_call
  42. addl $28,%esp
  43. end;
  44. // Under BeOS, we use stdcall for this line because the default calling convention in 1.9
  45. // is register instead of stdcall. But assembler is already written, so i used the stdcall
  46. // calling convention ! Maybe don't needed here. But to be sure...
  47. Function SysCall( callnr:longint;var args : SysCallArgs ):longint; stdcall;
  48. {
  49. This function serves as an interface to do_SysCall.
  50. If the SysCall returned a negative number, it returns -1, and puts the
  51. SysCall result in errno. Otherwise, it returns the SysCall return value
  52. }
  53. var
  54. funcresult : longint;
  55. begin
  56. funcresult := do_SysCall(callnr, args);
  57. if funcresult < 0 then
  58. begin
  59. seterrno(funcresult);
  60. SysCall := - 1;
  61. end
  62. else
  63. begin
  64. SysCall := funcresult;
  65. seterrno(0);
  66. end;
  67. end;