Browse Source

amiga: proof-of-concept untested implementation for OS4/PowerPC Pascal startup code

git-svn-id: trunk@35076 -
Károly Balogh 8 years ago
parent
commit
eb6fe91208
2 changed files with 62 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 61 0
      rtl/amiga/powerpc/si_prc.pp

+ 1 - 0
.gitattributes

@@ -8336,6 +8336,7 @@ rtl/amiga/powerpc/doslibf.inc svneol=native#text/plain
 rtl/amiga/powerpc/execd.inc svneol=native#text/plain
 rtl/amiga/powerpc/execd.inc svneol=native#text/plain
 rtl/amiga/powerpc/execf.inc svneol=native#text/plain
 rtl/amiga/powerpc/execf.inc svneol=native#text/plain
 rtl/amiga/powerpc/prt0.as svneol=native#text/plain
 rtl/amiga/powerpc/prt0.as svneol=native#text/plain
+rtl/amiga/powerpc/si_prc.pp svneol=native#text/plain
 rtl/amiga/powerpc/utild1.inc svneol=native#text/plain
 rtl/amiga/powerpc/utild1.inc svneol=native#text/plain
 rtl/amiga/powerpc/utild2.inc svneol=native#text/plain
 rtl/amiga/powerpc/utild2.inc svneol=native#text/plain
 rtl/amiga/powerpc/utilf.inc svneol=native#text/plain
 rtl/amiga/powerpc/utilf.inc svneol=native#text/plain

+ 61 - 0
rtl/amiga/powerpc/si_prc.pp

@@ -0,0 +1,61 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2016 by the Free Pascal development team
+
+    System Entry point for AmigaOS4/PowerPC, Pascal only programs
+
+    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.
+
+ **********************************************************************}
+
+unit si_prc;
+
+interface
+
+implementation
+
+var
+  AOS_ExecBase: Pointer; public name '_ExecBase';
+  IExec: Pointer; public name '_IExec';
+  realExecBase: Pointer absolute $4;
+  StkLen: LongInt; external name '__stklen';
+  StackCookie: LongInt; external name '__stack_cookie';
+  sysinit_jmpbuf: jmp_buf;
+  ExitCode: LongInt;
+
+{ the definitions in there need AOS_Execbase and IExec }
+{$include execd.inc}
+{$include execf.inc}
+
+procedure PascalMain; external name 'PASCALMAIN';
+
+
+{ this function must be the first in this unit which contains code }
+function _FPC_proc_start: longint; cdecl; public name '_start';
+begin
+  AOS_ExecBase:=realExecBase;
+  IExec:=nil;
+  newStack:=nil;
+
+  { The StackCookie check is only here so the symbol is referenced and
+    doesn't get striped out }
+  if StackCookie > 0 then
+    if setjmp(sysinit_jmpbuf) = 0 then
+      PascalMain;
+
+  _FPC_proc_start:=ExitCode;
+end;
+
+procedure _FPC_proc_halt(_ExitCode: longint); cdecl; public name '_haltproc';
+begin
+  ExitCode:=_ExitCode;
+  longjmp(sysinit_jmpbuf,1);
+end;
+
+
+end.