mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 02:27:56 +02:00
- killed tsyscallregs
This commit is contained in:
parent
ad42d353e1
commit
3f4d98624f
@ -175,92 +175,12 @@ asm
|
||||
end;
|
||||
|
||||
|
||||
// Old style syscall:
|
||||
// Better use ktrace/strace/gdb for debugging.
|
||||
Procedure FpSysCall(callnr:longint;var regs : SysCallregs);assembler;
|
||||
{
|
||||
This function puts the registers in place, does the call, and then
|
||||
copies back the registers as they are after the SysCall.
|
||||
}
|
||||
asm
|
||||
stmfd r13!,{r4-r6}
|
||||
ldr r2,[r1,#4]
|
||||
ldr r3,[r1,#8]
|
||||
ldr r4,[r1,#12]
|
||||
ldr r5,[r1,#16]
|
||||
ldr r6,[r1,#20]
|
||||
ldr r1,[r1]
|
||||
swi #0x900071
|
||||
cmn r0,#126
|
||||
bls .LDone
|
||||
ldr r1,.LErrno
|
||||
rsb r0,r0,#0
|
||||
str r0,[r1]
|
||||
mvn r0,#0
|
||||
b .LDone
|
||||
.LErrno:
|
||||
.word Errno
|
||||
.LDone:
|
||||
ldmfd r13!,{r4-r6}
|
||||
end;
|
||||
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
Const
|
||||
DoSysCallDebug : Boolean = False;
|
||||
|
||||
var
|
||||
LastCnt,
|
||||
LastEax,
|
||||
LastCall : longint;
|
||||
DebugTxt : string[20];
|
||||
{$ENDIF}
|
||||
|
||||
Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
|
||||
{
|
||||
This function serves as an interface to do_SysCall.
|
||||
If the SysCall returned a negative number, it returns -1, and puts the
|
||||
SysCall result in errno. Otherwise, it returns the SysCall return value
|
||||
}
|
||||
begin
|
||||
FpSysCall(callnr,regs);
|
||||
if regs.reg1<0 then
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
If DoSysCallDebug then
|
||||
debugtxt:=' syscall error: ';
|
||||
{$endif}
|
||||
ErrNo:=-regs.reg1;
|
||||
SysCall:=-1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
debugtxt:=' syscall returned: ';
|
||||
{$endif}
|
||||
SysCall:=regs.reg1;
|
||||
errno:=0
|
||||
end;
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
begin
|
||||
inc(lastcnt);
|
||||
if (callnr<>lastcall) or (regs.reg1<>lasteax) then
|
||||
begin
|
||||
if lastcnt>1 then
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax,' (',lastcnt,'x)');
|
||||
lastcall:=callnr;
|
||||
lasteax:=regs.reg1;
|
||||
lastcnt:=0;
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.4 2004-01-20 21:01:57 florian
|
||||
Revision 1.5 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.4 2004/01/20 21:01:57 florian
|
||||
* fixed setjump
|
||||
* fixed syscalls
|
||||
|
||||
|
@ -257,91 +257,13 @@ end;
|
||||
{$UNDEF SYSCALL_DEBUG}
|
||||
{$ENDIF SYS_LINUX}
|
||||
|
||||
{*****************************************************************************
|
||||
--- Main:The System Call Self ---
|
||||
*****************************************************************************}
|
||||
|
||||
Procedure FpSysCall( callnr:TSysParam;var regs : SysCallregs );assembler; {$ifndef VER1_0} oldfpccall; {$endif}
|
||||
{
|
||||
This function puts the registers in place, does the call, and then
|
||||
copies back the registers as they are after the SysCall.
|
||||
}
|
||||
{$ASMMODE ATT}
|
||||
{$define fpc_syscall_ok}
|
||||
asm
|
||||
{ load the registers... }
|
||||
movl 12(%ebp),%eax
|
||||
movl 4(%eax),%ebx
|
||||
movl 8(%eax),%ecx
|
||||
movl 12(%eax),%edx
|
||||
movl 16(%eax),%esi
|
||||
movl 20(%eax),%edi
|
||||
{ set the call number }
|
||||
movl 8(%ebp),%eax
|
||||
{ Go ! }
|
||||
int $0x80
|
||||
{ Put back the registers... }
|
||||
pushl %eax
|
||||
movl 12(%ebp),%eax
|
||||
movl %edi,20(%eax)
|
||||
movl %esi,16(%eax)
|
||||
movl %edx,12(%eax)
|
||||
movl %ecx,8(%eax)
|
||||
movl %ebx,4(%eax)
|
||||
popl %ebx
|
||||
movl %ebx,(%eax)
|
||||
end;
|
||||
|
||||
{$ASMMODE DEFAULT}
|
||||
|
||||
Function SysCall( callnr:longint;var regs : SysCallregs ):longint; {$ifndef VER1_0} oldfpccall; {$endif}
|
||||
{
|
||||
This function serves as an interface to do_SysCall.
|
||||
If the SysCall returned a negative number, it returns -1, and puts the
|
||||
SysCall result in errno. Otherwise, it returns the SysCall return value
|
||||
}
|
||||
begin
|
||||
FpSysCall(callnr,regs);
|
||||
if regs.reg1<0 then
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
If DoSysCallDebug then
|
||||
debugtxt:=' syscall error: ';
|
||||
{$endif}
|
||||
setErrNo(-regs.reg1);
|
||||
SysCall:=-1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
debugtxt:=' syscall returned: ';
|
||||
{$endif}
|
||||
SysCall:=regs.reg1;
|
||||
seterrno(0);
|
||||
end;
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
begin
|
||||
inc(lastcnt);
|
||||
if (callnr<>lastcall) or (regs.reg1<>lasteax) then
|
||||
begin
|
||||
if lastcnt>1 then
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax,' (',lastcnt,'x)');
|
||||
lastcall:=callnr;
|
||||
lasteax:=regs.reg1;
|
||||
lastcnt:=0;
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.10 2004-01-06 21:32:53 peter
|
||||
Revision 1.11 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.10 2004/01/06 21:32:53 peter
|
||||
* use relocate_proc
|
||||
|
||||
Revision 1.9 2003/09/14 20:15:01 marco
|
||||
|
@ -27,23 +27,8 @@ Type
|
||||
%edx %d3 r5 third argumens
|
||||
%esi %d3 r6 fourth argument
|
||||
%edi %d4 r7 fifth argument
|
||||
|
||||
That is why we define a special type, with only these arguments
|
||||
To make it processor independent, we don't give any system dependent
|
||||
names, but the rather abstract reg1,reg2 etc;
|
||||
}
|
||||
|
||||
SysCallRegs = record
|
||||
reg1,
|
||||
reg2,
|
||||
reg3,
|
||||
reg4,
|
||||
reg5,
|
||||
reg6 : longint;
|
||||
end;
|
||||
PSysCallRegs= ^SysCallRegs;
|
||||
TSysCallRegs= SysCallRegs;
|
||||
|
||||
timezone = packed record
|
||||
minuteswest,dsttime:longint;
|
||||
end;
|
||||
@ -62,7 +47,10 @@ Const // generated by statmacr.c
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.7 2004-02-06 21:17:41 daniel
|
||||
Revision 1.8 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.7 2004/02/06 21:17:41 daniel
|
||||
* Revert back to longint (it broke make cycle)
|
||||
|
||||
Revision 1.6 2004/02/06 15:58:21 florian
|
||||
|
@ -292,88 +292,13 @@ asm
|
||||
.LDone:
|
||||
end;
|
||||
|
||||
// Old style syscall:
|
||||
// Better use ktrace/strace/gdb for debugging.
|
||||
|
||||
Procedure FpSysCall( callnr:longint;var regs : SysCallregs );assembler;
|
||||
{
|
||||
This function puts the registers in place, does the call, and then
|
||||
copies back the registers as they are after the SysCall.
|
||||
}
|
||||
asm
|
||||
{ load the registers... }
|
||||
lwz r5, 12(r4)
|
||||
lwz r6, 16(r4)
|
||||
lwz r7, 20(r4)
|
||||
mr r0, r3
|
||||
lwz r3, 4(r4)
|
||||
mr r8, r4
|
||||
lwz r4, 8(r4)
|
||||
{ Go ! }
|
||||
sc
|
||||
bns .Lsyscall_ok
|
||||
.Lsyscall_ok:
|
||||
{ Put back the registers... }
|
||||
stw r3, 0(r8)
|
||||
end;
|
||||
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
Const
|
||||
DoSysCallDebug : Boolean = False;
|
||||
|
||||
var
|
||||
LastCnt,
|
||||
LastEax,
|
||||
LastCall : longint;
|
||||
DebugTxt : string[20];
|
||||
{$ENDIF}
|
||||
|
||||
Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
|
||||
{
|
||||
This function serves as an interface to do_SysCall.
|
||||
If the SysCall returned a negative number, it returns -1, and puts the
|
||||
SysCall result in errno. Otherwise, it returns the SysCall return value
|
||||
}
|
||||
begin
|
||||
FpSysCall(callnr,regs);
|
||||
if regs.reg1<0 then
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
If DoSysCallDebug then
|
||||
debugtxt:=' syscall error: ';
|
||||
{$endif}
|
||||
ErrNo:=-regs.reg1;
|
||||
SysCall:=-1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
debugtxt:=' syscall returned: ';
|
||||
{$endif}
|
||||
SysCall:=regs.reg1;
|
||||
errno:=0
|
||||
end;
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
begin
|
||||
inc(lastcnt);
|
||||
if (callnr<>lastcall) or (regs.reg1<>lasteax) then
|
||||
begin
|
||||
if lastcnt>1 then
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax,' (',lastcnt,'x)');
|
||||
lastcall:=callnr;
|
||||
lasteax:=regs.reg1;
|
||||
lastcnt:=0;
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.11 2003-12-28 20:55:10 jonas
|
||||
Revision 1.12 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.11 2003/12/28 20:55:10 jonas
|
||||
* fixed result of failed syscalls (no extra neg is needed)
|
||||
+ support multi-threaded programs
|
||||
|
||||
|
@ -267,89 +267,12 @@ asm
|
||||
end;
|
||||
|
||||
|
||||
// Old style syscall:
|
||||
// Better use ktrace/strace/gdb for debugging.
|
||||
|
||||
Procedure FpSysCall( callnr:longint;var regs : SysCallregs );assembler;
|
||||
{
|
||||
This function puts the registers in place, does the call, and then
|
||||
copies back the registers as they are after the SysCall.
|
||||
}
|
||||
asm
|
||||
or %i0,%g0,%g1
|
||||
ld [%i1],%o0
|
||||
ld [%i1+4],%o1
|
||||
ld [%i1+8],%o2
|
||||
ld [%i1+12],%o3
|
||||
ld [%i1+16],%o4
|
||||
{ Go ! }
|
||||
ta 0x10
|
||||
{ Put back the registers... }
|
||||
st %o0,[%i1]
|
||||
st %o1,[%i1+4]
|
||||
st %o2,[%i1+8]
|
||||
st %o3,[%i1+12]
|
||||
st %o4,[%i1+16]
|
||||
end;
|
||||
|
||||
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
Const
|
||||
DoSysCallDebug : Boolean = False;
|
||||
|
||||
var
|
||||
LastCnt,
|
||||
LastEax,
|
||||
LastCall : longint;
|
||||
DebugTxt : string[20];
|
||||
{$ENDIF}
|
||||
|
||||
Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
|
||||
{
|
||||
This function serves as an interface to do_SysCall.
|
||||
If the SysCall returned a negative number, it returns -1, and puts the
|
||||
SysCall result in errno. Otherwise, it returns the SysCall return value
|
||||
}
|
||||
begin
|
||||
FpSysCall(callnr,regs);
|
||||
if regs.reg1<0 then
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
If DoSysCallDebug then
|
||||
debugtxt:=' syscall error: ';
|
||||
{$endif}
|
||||
ErrNo:=-regs.reg1;
|
||||
SysCall:=-1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
debugtxt:=' syscall returned: ';
|
||||
{$endif}
|
||||
SysCall:=regs.reg1;
|
||||
errno:=0
|
||||
end;
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
begin
|
||||
inc(lastcnt);
|
||||
if (callnr<>lastcall) or (regs.reg1<>lasteax) then
|
||||
begin
|
||||
if lastcnt>1 then
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax,' (',lastcnt,'x)');
|
||||
lastcall:=callnr;
|
||||
lasteax:=regs.reg1;
|
||||
lastcnt:=0;
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.10 2004-01-05 17:22:03 peter
|
||||
Revision 1.11 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.10 2004/01/05 17:22:03 peter
|
||||
* removed asmmode direct
|
||||
|
||||
Revision 1.9 2003/08/11 13:19:08 mazen
|
||||
|
@ -25,15 +25,6 @@
|
||||
%esi %d3 r6 fourth argument
|
||||
%edi %d4 r7 fifth argument
|
||||
|
||||
That is why we define a special type, with only these arguments
|
||||
To make it processor independent, we don't give any system dependent
|
||||
names, but the rather abstract reg1,reg2 etc;
|
||||
|
||||
SysCallRegs=record
|
||||
reg1,reg2,reg3,reg4,reg5,reg6 : longint;
|
||||
end;
|
||||
PSysCallRegs=^SysCallRegs;
|
||||
TSysCallRegs=SysCallRegs;
|
||||
}
|
||||
|
||||
{
|
||||
@ -141,7 +132,10 @@
|
||||
}
|
||||
{
|
||||
$Log$
|
||||
Revision 1.13 2004-01-11 09:56:20 jonas
|
||||
Revision 1.14 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.13 2004/01/11 09:56:20 jonas
|
||||
* moved tstatfs from systypes.inc to ptypes.inc to fix make cycle with
|
||||
-dFPC_USE_LIBC (systypes.inc is now completely commented out)
|
||||
|
||||
|
@ -40,7 +40,6 @@ Const
|
||||
|
||||
Function SocketCall(SockCallNr,a1,a2,a3,a4,a5,a6:longint):longint;
|
||||
var
|
||||
// Regs:SysCallRegs;
|
||||
Args:array[1..6] of longint;
|
||||
begin
|
||||
{$IFNDEF BSD}
|
||||
@ -272,7 +271,10 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.8 2003-09-14 20:15:01 marco
|
||||
Revision 1.9 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.8 2003/09/14 20:15:01 marco
|
||||
* Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
|
||||
|
||||
Revision 1.7 2003/03/23 17:47:15 armin
|
||||
|
@ -232,79 +232,13 @@ end;
|
||||
{$UNDEF SYSCALL_DEBUG}
|
||||
{$ENDIF SYS_LINUX}
|
||||
|
||||
{*****************************************************************************
|
||||
--- Main:The System Call Self ---
|
||||
*****************************************************************************}
|
||||
|
||||
Procedure FpSysCall( callnr:TSysParam;var regs : SysCallregs );assembler;
|
||||
{
|
||||
This function puts the registers in place, does the call, and then
|
||||
copies back the registers as they are after the SysCall.
|
||||
}
|
||||
{$define fpc_syscall_ok}
|
||||
asm
|
||||
pushq %rdi
|
||||
movq sysnr, %rax { Syscall number -> rax. }
|
||||
movq 8(%rdi),%rsi { load paras }
|
||||
movq 16(%rdi),%rdx
|
||||
movq 24(%rdi),%r10
|
||||
movq 32(%rdi),%r8
|
||||
movq (%rdi),%rdi
|
||||
syscall { Do the system call. }
|
||||
popq %rdi
|
||||
movq %rax,(%rdi)
|
||||
end;
|
||||
|
||||
{$ASMMODE DEFAULT}
|
||||
|
||||
Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
|
||||
{
|
||||
This function serves as an interface to do_SysCall.
|
||||
If the SysCall returned a negative number, it returns -1, and puts the
|
||||
SysCall result in errno. Otherwise, it returns the SysCall return value
|
||||
}
|
||||
begin
|
||||
FpSysCall(callnr,regs);
|
||||
if regs.reg1>=$fffffffffffff001 then
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
If DoSysCallDebug then
|
||||
debugtxt:=' syscall error: ';
|
||||
{$endif}
|
||||
setErrNo(-regs.reg1);
|
||||
SysCall:=-1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
debugtxt:=' syscall returned: ';
|
||||
{$endif}
|
||||
SysCall:=regs.reg1;
|
||||
seterrno(0);
|
||||
end;
|
||||
{$IFDEF SYSCALL_DEBUG}
|
||||
if DoSysCallDebug then
|
||||
begin
|
||||
inc(lastcnt);
|
||||
if (callnr<>lastcall) or (regs.reg1<>lasteax) then
|
||||
begin
|
||||
if lastcnt>1 then
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax,' (',lastcnt,'x)');
|
||||
lastcall:=callnr;
|
||||
lasteax:=regs.reg1;
|
||||
lastcnt:=0;
|
||||
writeln(sys_nr_txt[lastcall],debugtxt,lasteax);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2004-02-06 15:58:21 florian
|
||||
Revision 1.4 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.3 2004/02/06 15:58:21 florian
|
||||
* fixed x86-64 assembler problems
|
||||
|
||||
Revision 1.2 2004/02/05 01:16:12 florian
|
||||
|
@ -260,16 +260,8 @@ Const
|
||||
|
||||
function ipccall(Call,First,Second,Third : Longint; P : Pointer) : longint;
|
||||
|
||||
{$ifndef bsd}
|
||||
//Var SR : SysCallRegs;
|
||||
{$endif}
|
||||
begin
|
||||
{$IFNDEF bsd}
|
||||
{ SR.Reg2:=Call;
|
||||
SR.reg3:=first;
|
||||
SR.reg4:=second;
|
||||
SR.Reg5:=third;
|
||||
SR.Reg6:=Longint(P); }
|
||||
ipccall:=do_syscall(syscall_nr_ipc,call,first,second,third,longint(P));
|
||||
{$Endif}
|
||||
ipcerror:=fpgetErrno;
|
||||
@ -372,7 +364,10 @@ end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.6 2003-11-16 14:09:25 marco
|
||||
Revision 1.7 2004-02-06 23:06:16 florian
|
||||
- killed tsyscallregs
|
||||
|
||||
Revision 1.6 2003/11/16 14:09:25 marco
|
||||
* few things renamed
|
||||
|
||||
Revision 1.5 2003/09/14 20:15:01 marco
|
||||
|
Loading…
Reference in New Issue
Block a user