Ver código fonte

* cleanup, removing debug code removed and fixing file headers
* cprt0 updates

git-svn-id: trunk@1713 -

tom_at_work 20 anos atrás
pai
commit
940f953e8b

+ 96 - 126
rtl/linux/powerpc64/cprt0.as

@@ -1,137 +1,107 @@
-/* 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.  */
-   
 .macro LOAD_64BIT_VAL ra, value 
-	addis           \ra, 0, \value@highest
-	ori             \ra,\ra,\value@higher
-	sldi            \ra,\ra,32
-	oris            \ra,\ra,\value@h
-	ori             \ra,\ra,\value@l	
+    lis             \ra,\value@highest
+    ori             \ra,\ra,\value@higher
+    sldi            \ra,\ra,32
+    oris            \ra,\ra,\value@h
+    ori             \ra,\ra,\value@l    
 .endm
 
-.macro FUNCTION_PROLOG fn
-	.section	".text"
-	.align	2
-	.globl	\fn
-	.section	".opd", "aw"
-	.align	3
-	\fn:
-	.quad	.\fn, .TOC.@tocbase, 0
-	.previous
-	.size	\fn, 24
-	.type	\fn, @function	
-	.globl	.\fn
-.\fn:
-.endm
+    .section ".rodata"
+    .align  3
+start_addresses:
+    .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
+  /*     function descriptors so don't need JUMPTARGET */
+    .quad   main_stub
+    .quad   __libc_csu_init
+    .quad   __libc_csu_fini
+    .size   start_adresses, .-start_addresses
 
-.macro FUNCTION_EPILOG fn
-	.long	0
-	.byte	0, 12, 0, 0, 0, 0, 0, 0
-	.type	.\fn, @function
-	.size	.\fn,.-.\fn
-.endm
+    .section ".text"
+    .align 2
+    .global _start
+    .section ".opd","aw"
+    .align 3
+_start:
+    .quad ._start,.TOC.@tocbase,0
+    .previous
 
-.macro PRINTMSG msg len
-	lis	4, \msg@highest
-	ori	4, 4, \msg@higher
-	sldi	4, 4, 32
-	oris	4, 4, \msg@h
-	ori	4, 4, \msg@l	
-	li	5, \len	
-	li	0,4
-	li	3,1
-	sc
-.endm
-	/* 
-	cprt0 pascal entry
-	*/
-FUNCTION_PROLOG _start
-
-	mr 	26, 1
-	/* Set up an initial stack frame, and clear the LR */
-	clrrdi  1, 1, 5       /* align r1 */
-	li      0, 0          
-	stdu    1,-48(1)      
-	mtlr    0             
-	std     0, 0(1)       /* r1 = pointer to NULL value */
-
-	/* store argument count (= 0(r1) )*/
-	ld      3, 0(26)
-	LOAD_64BIT_VAL 10, operatingsystem_parameter_argc
-	stw     3, 0(10)
-	/* calculate argument vector address and store (= 8(r1) + 8 ) */
-	addi    4, 26, 8
-	LOAD_64BIT_VAL 10, operatingsystem_parameter_argv
-	std     4, 0(10)
-	/* store environment pointer (= argv + (argc+1)* 8 ) */
-	addi    5, 3, 1
-	sldi    5, 5, 3
-	add     5, 4, 5
-	LOAD_64BIT_VAL 10, operatingsystem_parameter_envp
-	std     5, 0(10)
-	
-	bl	.__libc_init_first
-	nop
-	
-	lis	3, _dl_fini@highest
-	ori	3, 3, _dl_fini@higher
-	sldi	3,3,32
-	oris	3, 3, _dl_fini@h
-	ori	3, 3, _dl_fini@l
-
-	bl      .PASCALMAIN
-	nop
-	ori     0, 0, 0
-
-	/* directly jump to exit procedure, not via the function pointer */
-	b       _haltproc
-	
-	.align  3
-
-	.global ._haltproc
-	.section        ".opd", "aw"
-	.align 3
-._haltproc:
-	.quad   _haltproc, .TOC.@tocbase, 0
-	.previous
-	.size ._haltproc, 24
-	.global _haltproc
+    .global ._start
+._start:
+    mr  9,1
+    /* Set up an initial stack frame, and clear the LR.  */
+    clrrdi  1,1,4
+    li  0,0
+    stdu    1,-128(1)
+    mtlr    0
+    std 0,0(1)
+
+ /* put the address of start_addresses in r8...  *
+  * PPC64 ABI uses R13 for thread local, so we leave it alone */
+        LOAD_64BIT_VAL 8, start_addresses
+    
+    b   .__libc_start_main
+    nop
+
+    .section ".opd","aw"
+    .align 3
+main_stub:
+    .quad .main_stub,.TOC.@tocbase,0
+    .previous
+        .globl  .main_stub
+        .type   .main_stub,@function
+.main_stub:
+        mflr    0
+        std     0,16(1)
+    stdu    1,-128(1)
+
+        LOAD_64BIT_VAL 8, operatingsystem_parameter_argc
+    stw     3,0(8)
+
+        LOAD_64BIT_VAL 8, operatingsystem_parameter_argv
+    std     4,0(8)
+
+        LOAD_64BIT_VAL 8, operatingsystem_parameter_envp
+    std     5,0(8)
 
+        LOAD_64BIT_VAL 8, ___fpc_ret
+    std 1,0(8)
+
+    bl  .PASCALMAIN
+    nop
+
+    b   ._haltproc
+
+    .section ".opd","aw"
+    .align 3
 _haltproc:
-	/* exit call */
-	li      0, 1
-	sc
-	b       _haltproc
-
-	/* Define a symbol for the first piece of initialized data.  */
-	.section ".data"
-	.globl  __data_start
+    .quad ._haltproc,.TOC.@tocbase,0
+    .previous
+    
+        .globl  ._haltproc
+        .type   ._haltproc,@function
+._haltproc:
+        LOAD_64BIT_VAL 8, ___fpc_reg
+    ld  1,0(8)
+        addi    1,1,128
+        ld      0,16(1)
+        mtlr    0
+        blr
+
+#        li      0,1          /* exit call */
+#        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
 
-.text
-	.comm operatingsystem_parameter_argc, 4
-	.comm operatingsystem_parameter_argv, 8
-	.comm operatingsystem_parameter_envp, 8
+___fpc_ret:                             /* return address to libc */
+        .quad   0
 
+
+.text
+        .comm operatingsystem_parameter_argc,4
+        .comm operatingsystem_parameter_argv,8
+        .comm operatingsystem_parameter_envp,8

+ 10 - 51
rtl/linux/powerpc64/sighnd.inc

@@ -1,6 +1,6 @@
 {
     This file is part of the Free Pascal run time library.
-    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    Copyright (c) 2005 by Thomas Schatzl,
     member of the Free Pascal development team.
 
     Signal handler is arch dependant due to processor to language
@@ -15,56 +15,21 @@
 
  **********************************************************************}
 
-
-procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
+procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; context: PUContext); cdecl;
 var
   res : word;
-  fpustate : dword;
-  {$IFDEF EXCDEBUG}
-  p : pbyte;
-  i, j : integer;
-  {$ENDIF}
 begin
   res:=0;
-  {$IFDEF EXCDEBUG}
-  writeln('signaltorunerror');
-  { dump SigContext }    
-  p := pbyte(SigContext);
-  for j := 0 to sizeof(TSigContext) div 8 do begin
-    for i := 0 to 7 do begin
-      write(hexstr(p^, 2));
-      inc(p);
-    end;
-    write('  ');
-  end;
-  writeln;
-  {$ENDIF}
 
-  { SigContext is actally a pointer to a ucontext structure. 
-  So we do some ugly pointer casting to get it right again.
-  
-  See also in the *kernel* sources arch/ppc64/kernel/signal.c, 
-  function setup_rt_sigframe() }
-    
-  SigContext := @(PUContext(SigContext)^.uc_mcontext);
-  
   { exception flags are turned off by kernel }
   fpc_enable_ppc_fpu_exceptions;
   case sig of
     SIGFPE :
-      begin
-        { ugly typecast to get the FPSCR register contents }
-        fpustate := DWord(PDWord(@SigContext^.fp_regs[PT_FPSCR])^);
-        {$IFDEF EXCDEBUG}
-        writeln('fpustate = ', hexstr(fpustate, sizeof(fpustate)*2));
-        {$ENDIF}
-        { distinguish between the different FPU exceptions }
-        if (fpustate and ppc_fpu_underflow) <> 0 then
-          res := 206
-        else if (fpustate and ppc_fpu_overflow) <> 0 then
-          res := 205
-        else if (fpustate and ppc_fpu_divbyzero) <> 0 then
-          res := 200
+      { distuingish between different FPU exceptions }
+      case (SigInfo^.si_code) of
+        FPE_FLTDIV : res := 200;
+        FPE_FLTOVF : res := 205;
+        FPE_FLTUND : res := 206;
         else
           res := 207;
       end;
@@ -74,20 +39,14 @@ begin
     SIGSEGV :
       res:=216;
   end;
-  {$IFDEF EXCDEBUG}
-  writeln('sig = ', sig);
-  writeln('siginfo = ', hexstr(ptrint(siginfo), sizeof(siginfo)*2));
-  writeln('sigcontext = ', hexstr(ptrint(sigcontext), sizeof(sigcontext)*2));
 
-  writeln('sigcontext...signal = ', hexstr(sigcontext^.signal, 16));
-  
-  writeln('sigcontext^...regs = ', hexstr(ptrint(sigcontext^.regs), 16));
-  {$ENDIF}
   { reenable signal }
   reenable_signal(sig);
 
   { handle error }
   if res<>0 then
-    HandleErrorAddrFrame(res, Pointer(SigContext^.gp_regs[PT_NIP]), Pointer(SigContext^.gp_regs[PT_R1]));
+    HandleErrorAddrFrame(res,
+      Pointer(context^.uc_mcontext.gp_regs[PT_NIP]),
+      Pointer(context^.uc_mcontext.gp_regs[PT_R1]));
 end;
 

+ 9 - 4
rtl/linux/powerpc64/sighndh.inc

@@ -1,8 +1,13 @@
 {
     This file is part of the Free Pascal run time library.
-    Copyright (c) 2005 by Thomas Schatzl
+    Copyright (c) 2005 by Thomas Schatzl,
+    member of the FreePascal development team
 
-    TSigContext and associated structures
+    TSigContext and associated structures.
+
+    See also in the *kernel* sources arch/ppc64/kernel/signal.c, 
+    function setup_rt_sigframe()  for more information about the 
+    passed structures.
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -160,7 +165,7 @@ type
     uc_stack : stack_t;
     uc_sigmask : _sigset_t;
     __unused : array[0..14] of _sigset_t; { Allow for uc_sigmask growth }
-    uc_mcontext : TSigContext;             { last for extensibility }
+    uc_mcontext : TSigContext;            { last for extensibility }
   end;
 
-  PSigContext = ^TSigContext;
+  PSigContext = ^TUContext;

+ 1 - 1
rtl/linux/powerpc64/syscall.inc

@@ -1,6 +1,6 @@
 {
     This file is part of the Free Pascal run time library.
-    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    Copyright (c) 2005 by Thomas Schatzl,
     member of the Free Pascal development team.
 
     See the file COPYING.FPC, included in this distribution,

+ 8 - 17
rtl/linux/powerpc64/syscallh.inc

@@ -1,28 +1,19 @@
 {
-    Copyright (c) 2002 by Marco van de Voort
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Thomas Schatzl,
+    member of the Free Pascal development team.
 
-    Header for syscall in system unit for powerpc *nix.
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+    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.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
+ **********************************************************************}
 }
 
-Type
-
+type
   TSysResult = Int64;   // all platforms, cint=32-bit.
                         // On platforms with off_t =64-bit, people should
                         // use int64, and typecast all calls that don't

+ 15 - 3
rtl/linux/powerpc64/sysnr.inc

@@ -1,3 +1,18 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Thomas Schatzl,
+    member of the Free Pascal development team.
+
+    This file contains the system call numbers.
+
+    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.
+
+ **********************************************************************}
 { 
   Automatically converted by H2Pas 1.0.0 from 
   /usr/include/asm-ppc64/unistd.h
@@ -5,9 +20,6 @@
     unistd.h
 }
 
-
-{* This file contains the system call numbers. }
-
 const
   syscall_nr_exit = 1;  
   syscall_nr_fork = 2;