2
0

syscall.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. {
  2. $Id$
  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. type
  20. SysCallArgs = packed record
  21. param: array[1..8] of cint;
  22. End;
  23. procedure sys_call; external name 'sys_call';
  24. function Do_SysCall( callnr:longint;var regs : SysCallArgs ): longint;assembler;
  25. {
  26. This routine sets up the parameters on the stack, all the parameters
  27. are in reverse order on the stack (like C parameter passing).
  28. }
  29. asm
  30. { load the parameters... }
  31. movl regs,%eax
  32. movl 24(%eax),%ebx
  33. pushl %ebx
  34. movl 20(%eax),%ebx
  35. pushl %ebx
  36. movl 16(%eax),%ebx
  37. pushl %ebx
  38. movl 12(%eax),%ebx
  39. pushl %ebx
  40. movl 8(%eax),%ebx
  41. pushl %ebx
  42. movl 4(%eax),%ebx
  43. pushl %ebx
  44. movl 0(%eax),%ebx
  45. pushl %ebx
  46. { set the call number }
  47. movl callnr,%eax
  48. call sys_call
  49. addl $28,%esp
  50. end;
  51. Function SysCall( callnr:longint;var args : SysCallArgs ):longint;
  52. {
  53. This function serves as an interface to do_SysCall.
  54. If the SysCall returned a negative number, it returns -1, and puts the
  55. SysCall result in errno. Otherwise, it returns the SysCall return value
  56. }
  57. var
  58. funcresult : longint;
  59. begin
  60. funcresult:=do_SysCall(callnr,args);
  61. if funcresult<0 then
  62. begin
  63. ErrNo:=funcresult;
  64. SysCall:=-1;
  65. end
  66. else
  67. begin
  68. SysCall:=funcresult;
  69. errno:=0
  70. end;
  71. end;
  72. {
  73. $Log$
  74. Revision 1.2 2005-02-14 17:13:21 peter
  75. * truncate log
  76. }