syscall.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.1 2003-01-08 22:32:28 marco
  75. * Small fixes and quick merge with 1.0.x. At least the compiler builds now,
  76. but it could crash hard, since there are lots of unimplemented funcs.
  77. Revision 1.1.2.2 2001/08/15 01:08:25 carl
  78. * added SysCall(0 routine here as well as argument declarations
  79. Revision 1.1.2.1 2001/07/13 03:16:03 carl
  80. + static kernel call interface (CPU specific)
  81. }