syscall.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. Copyright (c) 1998-2000 by Florian Klaempfl
  3. This include implements the actual system call for the
  4. intel BeOS 80x86 platform.
  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. }
  18. type
  19. SysCallArgs = packed record
  20. param: array[1..8] of cint;
  21. End;
  22. procedure sys_call; external name 'sys_call';
  23. function Do_SysCall( callnr:longint;var regs : SysCallArgs ): longint;assembler;
  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. Function SysCall( callnr:longint;var args : SysCallArgs ):longint;
  51. {
  52. This function serves as an interface to do_SysCall.
  53. If the SysCall returned a negative number, it returns -1, and puts the
  54. SysCall result in errno. Otherwise, it returns the SysCall return value
  55. }
  56. var
  57. funcresult : longint;
  58. begin
  59. funcresult:=do_SysCall(callnr,args);
  60. if funcresult<0 then
  61. begin
  62. ErrNo:=funcresult;
  63. SysCall:=-1;
  64. end
  65. else
  66. begin
  67. SysCall:=funcresult;
  68. errno:=0
  69. end;
  70. end;