syscall.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. // Under BeOS, we use stdcall for this line because the default calling convention in 1.9
  20. // is register instead of stdcall. But assembler is already written, so i used the stdcall
  21. // calling convention !
  22. function Do_SysCall( callnr : longint; var regs : SysCallArgs ): longint; stdcall; assembler; [public, alias : 'FPC_SYSCALL'];
  23. {
  24. This routine sets up the parameters on the stack, all the parameters
  25. are in reverse order on the stack (like C parameter passing).
  26. }
  27. asm
  28. { load the parameters... }
  29. movl regs,%eax
  30. movl 24(%eax),%ebx
  31. pushl %ebx
  32. movl 20(%eax),%ebx
  33. pushl %ebx
  34. movl 16(%eax),%ebx
  35. pushl %ebx
  36. movl 12(%eax),%ebx
  37. pushl %ebx
  38. movl 8(%eax),%ebx
  39. pushl %ebx
  40. movl 4(%eax),%ebx
  41. pushl %ebx
  42. movl 0(%eax),%ebx
  43. pushl %ebx
  44. { set the call number }
  45. movl callnr,%eax
  46. call sys_call
  47. addl $28,%esp
  48. end;
  49. // Under BeOS, we use stdcall for this line because the default calling convention in 1.9
  50. // is register instead of stdcall. But assembler is already written, so i used the stdcall
  51. // calling convention ! Maybe don't needed here. But to be sure...
  52. Function SysCall( callnr:longint;var args : SysCallArgs ):longint; stdcall;
  53. {
  54. This function serves as an interface to do_SysCall.
  55. If the SysCall returned a negative number, it returns -1, and puts the
  56. SysCall result in errno. Otherwise, it returns the SysCall return value
  57. }
  58. var
  59. funcresult : longint;
  60. begin
  61. funcresult := do_SysCall(callnr, args);
  62. if funcresult < 0 then
  63. begin
  64. errno := funcresult;
  65. SysCall := - 1;
  66. end
  67. else
  68. begin
  69. SysCall := funcresult;
  70. errno := 0;
  71. end;
  72. end;