Jelajahi Sumber

* little fixes in prep of x86_64 port.

git-svn-id: trunk@6979 -
marco 18 tahun lalu
induk
melakukan
793ef9fdf1
4 mengubah file dengan 81 tambahan dan 32 penghapusan
  1. 2 2
      rtl/bsd/bunxsysc.inc
  2. 16 3
      rtl/bsd/ossysc.inc
  3. 62 27
      rtl/bsd/x86_64/syscall.inc
  4. 1 0
      rtl/bsd/x86_64/syscallh.inc

+ 2 - 2
rtl/bsd/bunxsysc.inc

@@ -538,7 +538,7 @@ function Fppread(fd: cint; buf: pchar; nbytes : size_t; offset:Toff): ssize_t; [
 begin
   
  	{$ifdef CPU64}
-	    Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,TSysParam(OffSet});
+	    Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,TSysParam(OffSet));
 	{$else}
            Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,
            {$ifdef 64bitfs}
@@ -556,7 +556,7 @@ function Fppwrite(fd: cint;buf:pchar; nbytes : size_t; offset:Toff): ssize_t; [p
 
 begin
  	{$ifdef CPU64}
-           Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,TSysParam(OffSet});
+           Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,TSysParam(OffSet));
 	{$else}
            Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,
 	  // ,0  = possible alignment here.

+ 16 - 3
rtl/bsd/ossysc.inc

@@ -71,23 +71,36 @@ FreeBSD: same implementation as NetBSD.
 }
 
 begin
-  Fplseek:=do_syscall(syscall_nr___syscall,syscall_nr_lseek,0,TSysParam(fd),0,lo(Offset),{0} hi(offset),Whence);
+  {$ifdef CPU64}
+    Fplseek:=do_syscall(syscall_nr___syscall,syscall_nr_lseek,TSysParam(fd),0,Offset,whence);
+  {$else}
+    Fplseek:=do_syscall(syscall_nr___syscall,syscall_nr_lseek,0,TSysParam(fd),0,lo(Offset),{0} hi(offset),Whence);
+  {$endif}
 end;
 
 function Fpftruncate(fd : cint; flength : off_t): cint; [public, alias : 'FPC_SYSC_FTRUNCATE'];
 
 begin
- Fpftruncate:=Do_syscall(syscall_nr___syscall,syscall_nr_ftruncate,0,fd,0,lo(flength),hi(flength));
+ {$ifdef CPU64}
+   Fpftruncate:=Do_syscall(syscall_nr___syscall,syscall_nr_ftruncate, fd  ,0   ,flength);
+ {$else}
+   Fpftruncate:=Do_syscall(syscall_nr___syscall,syscall_nr_ftruncate,0,fd,0,lo(flength),hi(flength));
+ {$endif}
+
 end;
 
 
 Function Fpmmap(start:pointer;len:size_t;prot:cint;flags:cint;fd:cint;offst:off_t):pointer; [public, alias:  'FPC_SYSC_MMAP'];
 
 begin
-  Fpmmap:=pointer(longint(do_syscall(syscall_nr_mmap,TSysParam(Start),Len,Prot,Flags,fd,
+ {$ifdef CPU64}
+  Fpmmap:=pointer(ptruint(do__syscall(TSysParam(syscall_nr_mmap),TSysParam(Start),TSysParam(Len),TSysParam(Prot),TSysParam(Flags),TSysParam(fd),TSysParam(offst),0,0)));
+{$else}
+  Fpmmap:=pointer(ptruint(do_syscall(syscall_nr_mmap,TSysParam(Start),Len,Prot,Flags,fd,
         {$ifdef FPC_BIG_ENDIAN}    hi(offst),lo(offst){$endif}
         {$ifdef FPC_LITTLE_ENDIAN} lo(offst),hi(offst){$endif},0
         )));
+{$endif}
 end;
 
 {$endif}

+ 62 - 27
rtl/bsd/x86_64/syscall.inc

@@ -22,16 +22,16 @@
 - More 6 and 7 param dosyscall because of the __syscall problem
 }
 
-{$ASMMODE GAS}
+{ASMMODE GAS}
 
-function do_sysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
+function fpsysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -44,11 +44,11 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
-function do_sysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
+function fpsysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
@@ -56,7 +56,7 @@ asm
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -69,11 +69,11 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
-function do_sysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
+function fpsysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
@@ -83,7 +83,7 @@ asm
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -96,11 +96,11 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
-function do_sysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
+function fpsysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
@@ -111,7 +111,7 @@ asm
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -124,11 +124,11 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
-function do_sysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
+function fpsysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
@@ -140,7 +140,7 @@ asm
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -153,11 +153,11 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
-function do_sysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
+function fpsysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
@@ -170,7 +170,7 @@ asm
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -183,12 +183,12 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
 
-function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
+function fpsysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
 
 asm
   movq sysnr, %rax        { Syscall number -> rax.  }
@@ -202,7 +202,7 @@ asm
   syscall                 { Do the system call. }
   jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
   movq  %rax,%rcx
-  movq  FPC_THREADVAR_RELOCATE,%rax
+  movq  fpc_threadvar_relocate_proc,%rax
   testq %rax,%rax
   jne   .LThread
   movq  %rcx,Errno+8
@@ -215,16 +215,51 @@ asm
   movq  %rcx,(%rax)
 .LNoThread:
   movq  $-1,%rax
-  movq  rax,%rdx
+  movq  %rax,%rdx
 .LSyscOK:
 end;
 
+function fpsysCall(sysnr,param1,param2,param3,param4,param5,param6,param7 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL7'];
+
+asm
+  mov param7,%rax
+  pushq %rax
+  movq sysnr, %rax        { Syscall number -> rax.  }
+  movq param1, %rdi         { shift arg1 - arg6. }
+  movq param2, %rsi
+  movq param3, %rdx
+  movq param4, %r10
+  movq param5, %r8
+  movq param6, %r9
+  mov %rcx,%r10
+  syscall                 { Do the system call. }
+  jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
+  movq  %rax,%rcx
+  movq  fpc_threadvar_relocate_proc,%rax
+  testq %rax,%rax
+  jne   .LThread
+  movq  %rcx,Errno+8
+  jmp   .LNoThread
+.LThread:
+  pushq %rcx
+  pushq Errno
+  call  *%rax
+  popq  %rcx
+  movq  %rcx,(%rax)
+.LNoThread:
+  movq  $-1,%rax
+  movq  %rax,%rdx
+.LSyscOK:
+  popq %rax
+end;
+
+
 procedure actualsyscall; assembler; {inline requires a dummy push IIRC}
     asm
      syscall
      jge .LSyscOK            { branch to exit if ok, errorhandler otherwise}
      movq  %rax,%rcx
-     movq  FPC_THREADVAR_RELOCATE,%rax
+     movq  fpc_threadvar_relocate_proc,%rax
      testq %rax,%rax
      jne   .LThread
      movq  %rcx,Errno+8
@@ -237,11 +272,12 @@ procedure actualsyscall; assembler; {inline requires a dummy push IIRC}
      movq  %rcx,(%rax)
    .LNoThread:
      movq  $-1,%rax
-     movq  rax,%rdx
+     movq  %rax,%rdx
    .LSyscOK:
 end;
 
-function do__sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7,Param8:TSysParam):TSysResult; oldfpccall; external name 'FPC_DOSYS8';
+
+function fp_sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7,Param8:TSysParam):TSysResult; assembler;assembler;[public,alias:'FPC_DOSYS8'];
 // Hmm, we have to do something different :)
 
 asm
@@ -249,10 +285,9 @@ asm
   push %rax
   movq param7,%rax
   push %rax
-  movq $syscall_nr__syscall,  %rax
+  movq $198,  %rax
   mov %rcx,%r10
   call actualsyscall
   add $16,%rsp
 end;
 
-

+ 1 - 0
rtl/bsd/x86_64/syscallh.inc

@@ -39,6 +39,7 @@ function do_sysCall(sysnr,param1,param2,param3:TSysParam):TSysResult;oldfpccall;
 function do_sysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult;oldfpccall; external name 'FPC_DOSYS4';
 function do_sysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; oldfpccall;  external name 'FPC_DOSYS5';
 function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):int64;oldfpccall;  external name 'FPC_DOSYS6';
+function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:TSysParam):int64;oldfpccall;  external name 'FPC_DOSYS7';
 
 // special
 function do__sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7,Param8:TSysParam):TSysResult; oldfpccall;  external name 'FPC_DOSYS8';