Browse Source

+ first implementation of sparc64-linux startup code, partly dummies

git-svn-id: trunk@36512 -
florian 8 years ago
parent
commit
278d33f611

+ 4 - 0
.gitattributes

@@ -9369,6 +9369,10 @@ rtl/linux/sparc/sighndh.inc svneol=native#text/plain
 rtl/linux/sparc/stat.inc svneol=native#text/plain
 rtl/linux/sparc/stat.inc svneol=native#text/plain
 rtl/linux/sparc/syscall.inc svneol=native#text/plain
 rtl/linux/sparc/syscall.inc svneol=native#text/plain
 rtl/linux/sparc/syscallh.inc svneol=native#text/plain
 rtl/linux/sparc/syscallh.inc svneol=native#text/plain
+rtl/linux/sparc64/si_c.inc svneol=native#text/plain
+rtl/linux/sparc64/si_dll.inc svneol=native#text/plain
+rtl/linux/sparc64/si_g.inc svneol=native#text/plain
+rtl/linux/sparc64/si_prc.inc svneol=native#text/plain
 rtl/linux/sparc64/stat.inc svneol=native#text/plain
 rtl/linux/sparc64/stat.inc svneol=native#text/plain
 rtl/linux/sparcgen/sysnr.inc svneol=native#text/plain
 rtl/linux/sparcgen/sysnr.inc svneol=native#text/plain
 rtl/linux/suuid.inc svneol=native#text/plain
 rtl/linux/suuid.inc svneol=native#text/plain

+ 51 - 0
rtl/linux/sparc64/si_c.inc

@@ -0,0 +1,51 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, members 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.
+
+ **********************************************************************}
+
+var
+  libc_environ: pchar; external name '__environ';
+  libc_fpu_control: word; external name '__fpu_control';
+  libc_init_proc: procedure; external name '_init';
+  libc_fini_proc: procedure; external name '_fini';
+
+procedure libc_atexit; external name '__libc_atexit';
+procedure libc_exit(ec : longint); external name '__libc_exit';
+procedure libc_init; external name '__libc_init';
+procedure libc_setfpucw; external name '__setfpucw';
+procedure libc_start_main; external name '__libc_start_main';
+
+const
+  BIAS = 2047;
+
+function fpc_getgot : pointer; [external name 'FPC_GETGOT'];
+
+{******************************************************************************
+                          C library start/halt
+ ******************************************************************************}
+
+procedure _FPC_libc_start; assembler; nostackframe; public name '_start';
+  asm
+  end;
+
+procedure _FPC_libc_haltproc(e: longint); cdecl; public name '_haltproc';
+  begin
+    libc_exit(e);
+    { try to exit_group }
+    while true do
+      asm
+        ld     e,%o0
+        mov     188, %g1
+        ta      0x6d
+      end;
+  end;
+

+ 42 - 0
rtl/linux/sparc64/si_dll.inc

@@ -0,0 +1,42 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, members 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.
+
+ **********************************************************************}
+
+{******************************************************************************
+                        Shared library start/halt
+ ******************************************************************************}
+
+procedure _FPC_shared_lib_start(argc : dword;argv,envp : pointer); cdecl; public name 'FPC_SHARED_LIB_START'; public name '_start';
+  begin
+    operatingsystem_parameter_argc:=argc;    { Copy the argument count      }
+    operatingsystem_parameter_argv:=argv;    { Copy the argument pointer    }
+    operatingsystem_parameter_envp:=envp;    { Copy the environment pointer }
+    initialstkptr:=get_frame;
+
+    PASCALMAIN;
+  end;
+
+
+{ this routine is only called when the halt() routine of the RTL embedded in
+  the shared library is called }
+procedure _FPC_shared_lib_haltproc(e:longint); cdecl; public name '_haltproc';
+  begin
+    { try to exit_group }
+    while true do
+      asm
+        ld     e,%o0
+        mov     188, %g1
+        ta      0x6d
+      end;
+  end;
+

+ 35 - 0
rtl/linux/sparc64/si_g.inc

@@ -0,0 +1,35 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, members 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.
+
+ **********************************************************************}
+
+var
+  gmon_etext: pointer; external name '_etext';
+  gmon_monstarted: longint = 0;
+
+procedure gmon_monstartup; external name 'monstartup';
+procedure gmon_mcleanup; external name '_mcleanup';
+
+procedure libc_atexit; external name '__libc_atexit';
+procedure libc_exit(ec : longint); external name '__libc_exit';
+procedure libc_init; external name '__libc_init';
+procedure libc_setfpucw; external name '__setfpucw';
+procedure libc_start_main; external name '__libc_start_main';
+
+{******************************************************************************
+                       Process + profiling start/halt
+ ******************************************************************************}
+
+procedure _FPC_proc_gprof_start; assembler; nostackframe; public name '_start';
+  asm
+  end;
+

+ 98 - 0
rtl/linux/sparc64/si_prc.inc

@@ -0,0 +1,98 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, members 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.
+
+ **********************************************************************}
+
+{******************************************************************************
+                          Process start/halt
+ ******************************************************************************}
+
+var
+  dlexitproc : pointer;
+
+const
+  BIAS = 2047;
+
+function fpc_getgot : pointer; [external name 'FPC_GETGOT'];
+
+procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
+  asm
+    { first stack frame }
+    mov	%g0, %fp
+    { space for arguments }
+    sub	%sp, 6*8, %sp
+{$ifdef FPC_PIC}
+    call FPC_GETGOT
+    nop
+{$endif FPC_PIC}
+    { extract argc }
+    ldx	[%sp+BIAS+22*8], %o2
+{$ifdef FPC_PIC}
+{$else FPC_PIC}
+    sethi	%hi(operatingsystem_parameter_argc),%o1
+    or	%o1,%lo(operatingsystem_parameter_argc),%o1
+{$endif FPC_PIC}
+    stx	%o2, [%o1]
+    { extract argv }
+{$ifdef FPC_PIC}
+{$else FPC_PIC}
+    add	%sp, BIAS+23*8, %o0
+    sethi	%hi(operatingsystem_parameter_argv),%o1
+    or	%o1,%lo(operatingsystem_parameter_argv),%o1
+{$endif FPC_PIC}
+    stx	%o0, [%o1]
+
+    { envp=argv+(argc+1)*8 }
+    inc     %o2
+    sllx     %o2, 8, %o2
+    add	%o2, %o0, %o2
+{$ifdef FPC_PIC}
+{$else FPC_PIC}
+    sethi	%hi(operatingsystem_parameter_envp),%o1
+    or	%o1,%lo(operatingsystem_parameter_envp),%o1
+{$endif FPC_PIC}
+    stx	%o2, [%o1]
+
+    { Save initial stackpointer }
+{$ifdef FPC_PIC}
+{$else FPC_PIC}
+    sethi	%hi(initialstkptr),%o1
+    or	%o1,%lo(initialstkptr),%o1
+{$endif FPC_PIC}
+    stx	%sp, [%o1]
+
+    { Call main program }
+    call	PASCALMAIN
+    nop
+
+    { we shuld never return here }
+    unimp
+  end;
+
+
+procedure _FPC_dynamic_proc_start; assembler; nostackframe; public name '_dynamic_start';
+  asm
+  end;
+
+
+procedure _FPC_proc_haltproc(e:longint); cdecl; public name '_haltproc';
+  begin
+    if assigned(dlexitproc) then
+      TProcedure(dlexitproc);
+    { try to exit_group }
+    while true do
+      asm
+        ld      e,%o0
+        mov     188, %g1
+        ta      0x6d
+      end;
+  end;