Browse Source

* Finished Linux (and rest syscalls) roughly. Some things still need to be
tested, and checked (off_t calls specially)

marco 25 years ago
parent
commit
d2efb9cfae
3 changed files with 98 additions and 53 deletions
  1. 66 38
      rtl/bsd/linux.pp
  2. 13 5
      rtl/bsd/problems.txt
  3. 19 10
      rtl/bsd/syscalls.inc

+ 66 - 38
rtl/bsd/linux.pp

@@ -578,8 +578,10 @@ Function  Dup(var oldfile,newfile:file):Boolean;
 Function  Dup2(oldfile,newfile:longint):Boolean;
 Function  Dup2(var oldfile,newfile:text):Boolean;
 Function  Dup2(var oldfile,newfile:file):Boolean;
+{
 Function  Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:PTimeVal):longint;
 Function  Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:Longint):longint;
+}
 Function  SelectText(var T:Text;TimeOut :PTimeVal):Longint;
 
 {**************************
@@ -633,9 +635,9 @@ Procedure SigSuspend(Mask:Sigset);
 //Function  Signal(Signum:Integer;Handler:SignalHandler):SignalHandler;
 Function  Kill(Pid:longint;Sig:integer):integer;
 Procedure SigRaise(Sig:integer);
-Function  Alarm(Sec : Longint) : longint;
+{Function  Alarm(Sec : Longint) : longint;
 Procedure Pause;
-
+}
 {**************************
   IOCtl/Termios Functions
 ***************************}
@@ -696,7 +698,9 @@ function MMap(const m:tmmapargs):longint;
      Port IO functions
 ***************************}
 
+{
 Function  IOperm (From,Num : Cardinal; Value : Longint) : boolean;
+}
 {$IFDEF I386}
 Procedure WritePort (Port : Longint; Value : Byte);
 Procedure WritePort (Port : Longint; Value : Word);
@@ -2127,24 +2131,28 @@ begin
   Dup2:=Dup2(filerec(oldfile).handle,filerec(newfile).handle);
 end;
 
-{
+
 Function Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:PTimeVal):longint;
 {
   Select checks whether the file descriptor sets in readfs/writefs/exceptfs
   have changed.
 }
 Var
-  SelectArray : Array[1..5] of longint;
-  Sr : Syscallregs;
+  Retval : LONGINT;
 begin
-  SelectArray[1]:=n;
-  SelectArray[2]:=longint(Readfds);
-  Selectarray[3]:=longint(Writefds);
-  selectarray[4]:=longint(exceptfds);
-  Selectarray[5]:=longint(TimeOut);
-  sr.reg2:=longint(@selectarray);
-  Select:=SysCall(Syscall_nr_select,sr);
-  LinuxError:=Errno;
+ asm
+  pushl TimeOut
+  pushl exceptfds
+  pushl writefds
+  pushl readfds
+  pushl n
+  mov   $93,%eax
+  int   $0x80
+  addl  $20,%esp
+  mov   %eax,retval
+ end;
+ Select:=checkreturnvalue(retval,retval);
+ LinuxError:=Errno;
 end;
 
 Function  Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:Longint):longint;
@@ -2167,7 +2175,7 @@ begin
    end;
   Select:=Select(N,Readfds,WriteFds,ExceptFds,p);
 end;
-}
+
 
 
 Function SelectText(var T:Text;TimeOut :PTimeval):Longint;
@@ -2603,7 +2611,7 @@ begin
   or   STAT_IFIFO,%ebx
   push %ebx
   push %ecx
-  mov  $14,$eax
+  mov  $14,%eax
   int  $0x80
   addl $12,%esp
   mov  %eax,retval
@@ -2887,7 +2895,7 @@ begin
  asm
   push Sig
   push Pid
-  mov  $37,$eax
+  mov  $37,%eax
   int  $0x80
   addl $8,%esp
   mov  %eax,retval
@@ -2912,14 +2920,12 @@ begin
   push oldact
   push act
   push signum
-  mov  $46,$eax
+  mov  $46,%eax
   int  $0x80
   addl $12,%esp
   mov  %eax,retval
  end;
- SigAction:=checkreturnvalue(retval,retval);
- if kill<0 THEN
-  Kill:=0; 
+ checkreturnvalue(retval,retval);
  LinuxError:=Errno;
 end;
 
@@ -2944,7 +2950,7 @@ begin
    addl  $12,%esp
    mov  %eax,retval
   end;
- SigProcMask:=checkreturnvalue(retval,retval);
+ checkreturnvalue(retval,retval);
  LinuxError:=Errno;
 end;
 
@@ -2962,6 +2968,7 @@ begin
    mov  $52,%eax
    int  $0x80
    addl $4,%esp
+   mov  %eax,retval
   end;
   sigpending:=checkreturnvalue(retval,dummy);
   LinuxError:=Errno;
@@ -3016,6 +3023,7 @@ begin
   Kill(GetPid,Sig);
 end;
 
+{
 Function  Alarm(Sec : Longint) : longint;
 
 Var Sr : Syscallregs;
@@ -3032,7 +3040,7 @@ Var Sr : Syscallregs;
 begin
   syscall(syscall_nr_pause,sr);
 end;
-
+}
 {******************************************************************************
                          IOCtl and Termios calls
 ******************************************************************************}
@@ -3046,13 +3054,19 @@ Function IOCtl(Handle,Ndx: Longint;Data: Pointer):boolean;
   data is function-dependent.
 }
 var
-  sr: SysCallRegs;
+  retval  : longint;
 begin
-  sr.reg2:=Handle;
-  sr.reg3:=Ndx;
-  sr.reg4:=Longint(Data);
-  IOCtl:=(SysCall(Syscall_nr_ioctl,sr)=0);
-  LinuxError:=Errno;
+  asm
+    push data
+    push ndx
+    push handle
+    mov  $54,%eax
+    int  $0x80
+    addl $12,%esp
+    mov  %eax,retval
+  end;
+ IOctl:=checkreturnvalue(retval,retval)=0;
+ LinuxError:=Errno;
 end;
 
 
@@ -3671,8 +3685,6 @@ begin
   FillChar(fds,sizeof(fdSet),0);
 end;
 
-
-
 Procedure FD_Clr(fd:longint;var fds:fdSet);
 {
   Remove fd from the set of filedescriptors
@@ -3809,18 +3821,31 @@ end;
 
 function MMap(const m:tmmapargs):longint;
 Var
-  Sr : Syscallregs;
+   Retval : longint;
 begin
-  Sr.reg2:=longint(@m);
-  MMap:=syscall(syscall_nr_mmap,sr);
-  LinuxError:=Errno;
+  asm
+   push $0
+   mov  m,%esi
+   push tmmapargs.offset(%esi)
+   push tmmapargs.fd(%esi)
+   push tmmapargs.flags(%esi)
+   push tmmapargs.prot(%esi)
+   push tmmapargs.size(%esi)
+   push tmmapargs.address(%esi)
+   mov $197,%eax
+   int $0x80
+   addl $28,%esp
+   mov %eax,retval
+ end;
+ checkreturnvalue(retval,retval);
+ LinuxError:=Errno;
 end;
 
 
 {--------------------------------
       Port IO functions
 --------------------------------}
-
+{
 Function  IOperm (From,Num : Cardinal; Value : Longint) : boolean;
 {
   Set permissions on NUM ports starting with port FROM to VALUE
@@ -3836,8 +3861,7 @@ begin
   IOPerm:=Syscall(Syscall_nr_ioperm,sr)=0;
   LinuxError:=Errno;
 end;
-
-
+}
 {$IFDEF I386}
 
 {$asmmode direct}
@@ -4039,7 +4063,11 @@ End.
 
 {
   $Log$
-  Revision 1.2  2000-02-04 12:05:04  marco
+  Revision 1.3  2000-02-04 16:53:26  marco
+   * Finished Linux (and rest syscalls) roughly. Some things still need to be
+    tested, and checked (off_t calls specially)
+
+  Revision 1.2  2000/02/04 12:05:04  marco
    * a few functions added.
 
   Revision 1.1  2000/02/03 17:03:36  marco

+ 13 - 5
rtl/bsd/problems.txt

@@ -1,5 +1,10 @@
 FreeBSD status and notes. (kept on CVS because I work on several places)
 
+At the moment that you are reading this, FPC for FreeBSD is still a dream.
+We are currently working actively on FreeBSD support.
+
+
+
 NI=not implemented yet
 req=required for compiler
 noreq? = probably not required, but not checked.
@@ -8,14 +13,13 @@ syscall   status        comment
 
 ------------------------------------------------------------------------         
 
-Readdir	 NI req	        Three pages code in the linux emulator which uses calls
-		 	we probably can't access :-) GetDents uses the
-		 	same calls tho.
+Readdir	 implemented 
+	   from 
+          scratch, 
+          untested.   
 
 Clone()	 NI noreq	Looks awfully complicated. Should be based on RFork.
 
-Select   NI noreq?      See maillist. Doesn't seem to comply to manpage.
-
 sysinfo  NI noreq       Not supported under BSD, not even by emulator
 uname    NI noreq       "        "       "    "   "   "    "   "
 			(procedure based on this call are also commented
@@ -23,3 +27,7 @@ uname    NI noreq       "        "       "    "   "   "    "   "
 
 signal   NI  noreq?      A *lot* of emulation code.
 alarm    NI  noreq?      Could be possible to port.
+pause 	 NI  noreq?	 Also possible I think. Uses process information	
+			 in linux-emu, that is why I didn't port directly.
+
+IOPERM   NI  noreq?      Concept doesn't exist.

+ 19 - 10
rtl/bsd/syscalls.inc

@@ -374,21 +374,26 @@ end;
 
 Function Sys_ReadDir(p:pdir):pdirent;
 var
-  regs :SysCallregs;
-  dummy:longint;
+    retval : longint;
 begin
-  regs.reg3:=longint(p^.buf);
-  regs.reg2:=p^.fd;
-  regs.reg4:=1;
-  dummy:=SysCall(SysCall_nr_readdir,regs);
-{ the readdir system call returns the number of bytes written }
-  if dummy=0 then 
+ retval:=SIZEOF(dirent) ;
+ asm 
+    mov p,%esi
+    push retval
+    push tdir.buf(%esi)
+    push tdir.fd(%esi)
+    mov  $272,%eax 
+    int  $0x80
+    addl $12,%esp
+    mov  %eax,retval    
+  end; 
+  retval:=checkreturnvalue(retval,retval); 
+  if retval=0 then 
    sys_readdir:=nil 
   else 
    sys_readdir:=p^.buf
 end;
 
-
 {*****************************************************************************
         --- Process:Process & program handling - related calls ---
 *****************************************************************************}
@@ -410,7 +415,11 @@ end;
 
 {
   $Log$
-  Revision 1.4  2000-02-03 17:04:47  marco
+  Revision 1.5  2000-02-04 16:53:26  marco
+   * Finished Linux (and rest syscalls) roughly. Some things still need to be
+    tested, and checked (off_t calls specially)
+
+  Revision 1.4  2000/02/03 17:04:47  marco
    * additions fixes due to port linux
 
   Revision 1.3  2000/02/02 18:07:27  marco