浏览代码

+ SPARC support added based on PowerPc sources

mazen 23 年之前
父节点
当前提交
1817fc98e4
共有 6 个文件被更改,包括 395 次插入0 次删除
  1. 18 0
      rtl/linux/sparc/cprt0.as
  2. 18 0
      rtl/linux/sparc/cprt21.as
  3. 18 0
      rtl/linux/sparc/dllprt0.as
  4. 18 0
      rtl/linux/sparc/gprt0.as
  5. 83 0
      rtl/linux/sparc/prt0.as
  6. 240 0
      rtl/linux/sparc/syscall.inc

+ 18 - 0
rtl/linux/sparc/cprt0.as

@@ -0,0 +1,18 @@
+/*
+  $Id$
+*/
+
+/* 
+  $Log$
+  Revision 1.1  2002-11-15 12:08:37  mazen
+  + SPARC support added based on PowerPc sources
+
+  Revision 1.3  2002/09/07 16:01:20  peter
+    * old logs removed and tabs fixed
+
+  Revision 1.2  2002/07/26 17:09:44  florian
+    * log fixed
+
+  Revision 1.1  2002/07/26 17:07:11  florian
+    + dummy implementation to test the makefile
+*/

+ 18 - 0
rtl/linux/sparc/cprt21.as

@@ -0,0 +1,18 @@
+/*
+  $Id$
+*/
+
+/* 
+  $Log$
+  Revision 1.1  2002-11-15 12:08:37  mazen
+  + SPARC support added based on PowerPc sources
+
+  Revision 1.3  2002/09/07 16:01:20  peter
+    * old logs removed and tabs fixed
+
+  Revision 1.2  2002/07/26 17:09:44  florian
+    * log fixed
+
+  Revision 1.1  2002/07/26 17:07:11  florian
+    + dummy implementation to test the makefile
+*/

+ 18 - 0
rtl/linux/sparc/dllprt0.as

@@ -0,0 +1,18 @@
+/*
+  $Id$
+*/
+
+/* 
+  $Log$
+  Revision 1.1  2002-11-15 12:08:37  mazen
+  + SPARC support added based on PowerPc sources
+
+  Revision 1.3  2002/09/07 16:01:20  peter
+    * old logs removed and tabs fixed
+
+  Revision 1.2  2002/07/26 17:09:44  florian
+    * log fixed
+
+  Revision 1.1  2002/07/26 17:07:11  florian
+    + dummy implementation to test the makefile
+*/

+ 18 - 0
rtl/linux/sparc/gprt0.as

@@ -0,0 +1,18 @@
+/*
+  $Id$
+*/
+
+/*
+  $Log$
+  Revision 1.1  2002-11-15 12:08:37  mazen
+  + SPARC support added based on PowerPc sources
+
+  Revision 1.3  2002/09/07 16:01:20  peter
+    * old logs removed and tabs fixed
+
+  Revision 1.2  2002/07/26 17:09:44  florian
+    * log fixed
+
+  Revision 1.1  2002/07/26 17:07:11  florian
+    + dummy implementation to test the makefile
+*/

+ 83 - 0
rtl/linux/sparc/prt0.as

@@ -0,0 +1,83 @@
+/* Startup code for programs linked with GNU libc.
+   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+        .section ".text"
+        .globl  _start
+_start:
+ 	/* Save the stack pointer, in case we're statically linked under Linux.  */
+	mr	9,1
+	/* Set up an initial stack frame, and clear the LR.  */
+	clrrwi	1,1,4
+	li	0,0
+	stwu	1,-16(1)
+	mtlr	0
+	stw	0,0(1)
+	bl	PASCALMAIN
+
+        .globl  _haltproc
+        .type   _haltproc,@function
+_haltproc:
+        li      0,1	         /* exit call */
+	lis	3,U_SYSTEM_EXITCODE@h
+	stw	3,U_SYSTEM_EXITCODE@l(3)
+        sc
+        b	_haltproc
+
+	/* Define a symbol for the first piece of initialized data.  */
+	.section ".data"
+	.globl	__data_start
+__data_start:
+data_start:
+        .globl  ___fpc_brk_addr         /* heap management */
+        .type   ___fpc_brk_addr,@object
+        .size   ___fpc_brk_addr,4
+___fpc_brk_addr:
+        .long   0
+/*
+  $Log$
+  Revision 1.1  2002-11-15 12:08:37  mazen
+  + SPARC support added based on PowerPc sources
+
+  Revision 1.9  2002/09/07 16:01:20  peter
+    * old logs removed and tabs fixed
+
+  Revision 1.8  2002/08/31 21:29:57  florian
+    * several PC related fixes
+
+  Revision 1.7  2002/08/31 16:13:12  florian
+    * made _start global
+
+  Revision 1.6  2002/08/31 14:02:23  florian
+    * r3 renamed to 3
+
+  Revision 1.5  2002/08/31 14:01:28  florian
+    * _haltproc to prt0.as added (Linux/PPC)
+
+  Revision 1.4  2002/08/31 13:11:11  florian
+    * several fixes for Linux/PPC compilation
+
+  Revision 1.3  2002/08/19 21:19:15  florian
+    * small fixes
+
+  Revision 1.2  2002/07/26 17:09:44  florian
+    * log fixed
+
+  Revision 1.1  2002/07/26 16:57:40  florian
+    + initial version, plain copy from glibc/sysdeps/powerpc/elf/start.S
+*/

+ 240 - 0
rtl/linux/sparc/syscall.inc

@@ -0,0 +1,240 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{No debugging for syslinux include !}
+{$IFDEF SYS_LINUX}
+  {$UNDEF SYSCALL_DEBUG}
+{$ENDIF SYS_LINUX}
+
+
+Type
+
+  TSysResult = Longint; // all platforms, cint=32-bit.
+			// On platforms with off_t =64-bit, people should
+			// use int64, and typecast all other calls to cint.
+
+// I don't think this is going to work on several platforms 64-bit machines
+// don't have only 64-bit params.
+
+  TSysParam  = Longint; 
+
+{*****************************************************************************
+                     --- Main:The System Call Self ---
+*****************************************************************************}
+
+function Do_SysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
+{
+  This function puts the registers in place, does the call, and then
+  copies back the registers as they are after the SysCall.
+}
+asm
+  mr  r0,r3
+  sc
+  bnslr
+  neg   r3, r3
+  lis   r4,Errno@ha
+  stw   r3,Errno@l(r4)
+  li    r3,-1
+end;
+
+function Do_SysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
+{
+  This function puts the registers in place, does the call, and then
+  copies back the registers as they are after the SysCall.
+}
+asm
+  mr  r0,r3
+  mr  r3,r4   
+  sc
+  bnslr
+  neg   r3, r3
+  lis   r4,Errno@ha
+  stw   r3,Errno@l(r4)
+  li    r3,-1
+end;
+
+
+function Do_SysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
+{
+  This function puts the registers in place, does the call, and then
+  copies back the registers as they are after the SysCall.
+}
+asm
+  mr  r0,r3
+  mr  r3,r4   
+  mr  r4,r5
+  sc
+   bnslr
+   neg   r3, r3
+   lis   r4,Errno@ha
+   stw   r3,Errno@l(r4)
+   li    r3,-1
+end;
+
+function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
+{
+  This function puts the registers in place, does the call, and then
+  copies back the registers as they are after the SysCall.
+}
+asm
+  mr  r0,r3
+  mr  r3,r4   
+  mr  r4,r5
+  mr  r5,r6
+  sc 
+   bnslr
+   neg   r3, r3
+   lis   r4,Errno@ha
+   stw   r3,Errno@l(r4)
+   li    r3,-1
+
+end;
+
+
+function Do_SysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
+{
+  This function puts the registers in place, does the call, and then
+  copies back the registers as they are after the SysCall.
+}
+asm
+  mr  r0,r3
+  mr  r3,r4   
+  mr  r4,r5
+  mr  r5,r6
+  mr  r6,r7
+  sc 
+   bnslr
+   neg   r3, r3
+   lis   r4,Errno@ha
+   stw   r3,Errno@l(r4)
+   li    r3,-1
+end;
+
+function Do_SysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
+{
+  This function puts the registers in place, does the call, and then
+  copies back the registers as they are after the SysCall.
+}
+asm
+  mr  r0,r3
+  mr  r3,r4   
+  mr  r4,r5
+  mr  r5,r6
+  mr  r6,r7
+  mr  r7,r8
+  sc 
+   bnslr
+   neg   r3, r3
+   lis   r4,Errno@ha
+   stw   r3,Errno@l(r4)
+   li    r3,-1
+end;
+
+// Old style syscall:
+// Better use ktrace/strace/gdb for debugging.
+
+Procedure Do_SysCall( 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)
+  stw  r4, regs
+  lwz  r4, 8(r4)
+{ Go ! }
+  sc
+  nop
+{ Put back the registers... }
+  lwz    r8, regs
+  stw    r3, 0(r8)
+  stw    r4, 4(r8)
+  stw    r5, 8(r8)
+  stw    r6, 12(r8)
+  stw    r7, 16(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
+  do_SysCall(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.1  2002-11-15 12:08:37  mazen
+  + SPARC support added based on PowerPc sources
+
+  Revision 1.1  2002/11/09 20:32:14  marco
+   * powerpc version. Threadsafe errno access not yet done.
+
+  Revision 1.1  2002/10/14 19:39:44  peter
+    * syscall moved into seperate include
+
+}
+