syscall.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 by Florian Klaempfl,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {No debugging for syslinux include !}
  13. {$IFDEF SYS_LINUX}
  14. {$UNDEF SYSCALL_DEBUG}
  15. {$ENDIF SYS_LINUX}
  16. {*****************************************************************************
  17. --- Main:The System Call Self ---
  18. *****************************************************************************}
  19. function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
  20. {
  21. This function puts the registers in place, does the call, and then
  22. copies back the registers as they are after the SysCall.
  23. }
  24. asm
  25. end;
  26. function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
  27. {
  28. This function puts the registers in place, does the call, and then
  29. copies back the registers as they are after the SysCall.
  30. }
  31. asm
  32. end;
  33. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
  34. {
  35. This function puts the registers in place, does the call, and then
  36. copies back the registers as they are after the SysCall.
  37. }
  38. asm
  39. end;
  40. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
  41. {
  42. This function puts the registers in place, does the call, and then
  43. copies back the registers as they are after the SysCall.
  44. }
  45. asm
  46. end;
  47. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
  48. {
  49. This function puts the registers in place, does the call, and then
  50. copies back the registers as they are after the SysCall.
  51. }
  52. asm
  53. end;
  54. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
  55. {
  56. This function puts the registers in place, does the call, and then
  57. copies back the registers as they are after the SysCall.
  58. }
  59. asm
  60. end;
  61. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
  62. {
  63. This function puts the registers in place, does the call, and then
  64. copies back the registers as they are after the SysCall.
  65. }
  66. asm
  67. end;
  68. // Old style syscall:
  69. // Better use ktrace/strace/gdb for debugging.
  70. Procedure FpSysCall( callnr:longint;var regs : SysCallregs );assembler;
  71. {
  72. This function puts the registers in place, does the call, and then
  73. copies back the registers as they are after the SysCall.
  74. }
  75. asm
  76. end;
  77. {$IFDEF SYSCALL_DEBUG}
  78. Const
  79. DoSysCallDebug : Boolean = False;
  80. var
  81. LastCnt,
  82. LastEax,
  83. LastCall : longint;
  84. DebugTxt : string[20];
  85. {$ENDIF}
  86. Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
  87. {
  88. This function serves as an interface to do_SysCall.
  89. If the SysCall returned a negative number, it returns -1, and puts the
  90. SysCall result in errno. Otherwise, it returns the SysCall return value
  91. }
  92. begin
  93. FpSysCall(callnr,regs);
  94. if regs.reg1<0 then
  95. begin
  96. {$IFDEF SYSCALL_DEBUG}
  97. If DoSysCallDebug then
  98. debugtxt:=' syscall error: ';
  99. {$endif}
  100. ErrNo:=-regs.reg1;
  101. SysCall:=-1;
  102. end
  103. else
  104. begin
  105. {$IFDEF SYSCALL_DEBUG}
  106. if DoSysCallDebug then
  107. debugtxt:=' syscall returned: ';
  108. {$endif}
  109. SysCall:=regs.reg1;
  110. errno:=0
  111. end;
  112. {$IFDEF SYSCALL_DEBUG}
  113. if DoSysCallDebug then
  114. begin
  115. inc(lastcnt);
  116. if (callnr<>lastcall) or (regs.reg1<>lasteax) then
  117. begin
  118. if lastcnt>1 then
  119. writeln(sys_nr_txt[lastcall],debugtxt,lasteax,' (',lastcnt,'x)');
  120. lastcall:=callnr;
  121. lasteax:=regs.reg1;
  122. lastcnt:=0;
  123. writeln(sys_nr_txt[lastcall],debugtxt,lasteax);
  124. end;
  125. end;
  126. {$endif}
  127. end;
  128. {
  129. $Log$
  130. Revision 1.1 2003-08-28 00:08:29 florian
  131. * syscall skeleton
  132. }