Browse Source

morphos: new pascal-written internal startup code. also refactored the rtl build process for morphos

git-svn-id: trunk@35054 -
Károly Balogh 8 years ago
parent
commit
f3e33a9dde

+ 2 - 0
.gitattributes

@@ -9298,12 +9298,14 @@ rtl/mipsel/strings.inc svneol=native#text/plain
 rtl/mipsel/stringss.inc svneol=native#text/plain
 rtl/mipsel/stringss.inc svneol=native#text/plain
 rtl/morphos/Makefile svneol=native#text/plain
 rtl/morphos/Makefile svneol=native#text/plain
 rtl/morphos/Makefile.fpc svneol=native#text/plain
 rtl/morphos/Makefile.fpc svneol=native#text/plain
+rtl/morphos/buildrtl.pp svneol=native#text/plain
 rtl/morphos/doslibd.inc svneol=native#text/plain
 rtl/morphos/doslibd.inc svneol=native#text/plain
 rtl/morphos/doslibf.inc svneol=native#text/plain
 rtl/morphos/doslibf.inc svneol=native#text/plain
 rtl/morphos/emuld.inc svneol=native#text/plain
 rtl/morphos/emuld.inc svneol=native#text/plain
 rtl/morphos/execd.inc svneol=native#text/plain
 rtl/morphos/execd.inc svneol=native#text/plain
 rtl/morphos/execf.inc svneol=native#text/plain
 rtl/morphos/execf.inc svneol=native#text/plain
 rtl/morphos/prt0.as svneol=native#text/plain
 rtl/morphos/prt0.as svneol=native#text/plain
+rtl/morphos/si_prc.pp svneol=native#text/plain
 rtl/morphos/system.pp svneol=native#text/plain
 rtl/morphos/system.pp svneol=native#text/plain
 rtl/morphos/timerd.inc svneol=native#text/plain
 rtl/morphos/timerd.inc svneol=native#text/plain
 rtl/morphos/timerf.inc svneol=native#text/plain
 rtl/morphos/timerf.inc svneol=native#text/plain

+ 1 - 1
compiler/systems.pas

@@ -326,7 +326,7 @@ interface
        systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android;
        systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android;
 
 
        systems_internal_sysinit = [system_i386_linux,system_i386_win32,system_x86_64_win64,
        systems_internal_sysinit = [system_i386_linux,system_i386_win32,system_x86_64_win64,
-                                   system_powerpc64_linux]+systems_darwin;
+                                   system_powerpc64_linux,system_powerpc_morphos]+systems_darwin;
 
 
        { all systems that use garbage collection for reference-counted types }
        { all systems that use garbage collection for reference-counted types }
        systems_garbage_collected_managed_types = [
        systems_garbage_collected_managed_types = [

+ 12 - 2
compiler/systems/t_morph.pas

@@ -43,6 +43,7 @@ implementation
        public
        public
           constructor Create; override;
           constructor Create; override;
           procedure SetDefaultInfo; override;
           procedure SetDefaultInfo; override;
+          procedure InitSysInitUnitName; override;
           function  MakeExecutable:boolean; override;
           function  MakeExecutable:boolean; override;
        end;
        end;
 
 
@@ -79,6 +80,12 @@ begin
 end;
 end;
 
 
 
 
+Procedure TLinkerMorphOS.InitSysInitUnitName;
+begin
+  sysinitunit:='si_prc';
+end;
+
+
 Function TLinkerMorphOS.WriteResponseFile(isdll:boolean) : Boolean;
 Function TLinkerMorphOS.WriteResponseFile(isdll:boolean) : Boolean;
 Var
 Var
   linkres  : TLinkRes;
   linkres  : TLinkRes;
@@ -113,8 +120,11 @@ begin
 
 
   LinkRes.Add('INPUT (');
   LinkRes.Add('INPUT (');
   { add objectfiles, start with prt0 always }
   { add objectfiles, start with prt0 always }
-  s:=FindObjectFile('prt0','',false);
-  LinkRes.AddFileName(s);
+  if not (target_info.system in systems_internal_sysinit) then
+    begin
+      s:=FindObjectFile('prt0','',false);
+      LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
+    end;
   while not ObjectFiles.Empty do
   while not ObjectFiles.Empty do
    begin
    begin
     s:=ObjectFiles.GetFirst;
     s:=ObjectFiles.GetFirst;

File diff suppressed because it is too large
+ 184 - 444
rtl/morphos/Makefile


+ 30 - 139
rtl/morphos/Makefile.fpc

@@ -6,23 +6,20 @@
 main=rtl
 main=rtl
 
 
 [target]
 [target]
-loaders=prt0
-units=$(SYSTEMUNIT) uuchar objpas macpas iso7185 extpas strings \
-      fpintres dos heaptrc ctypes \
-      sysutils classes fgl math typinfo \
-      charset cpall getopts \
-      types rtlconsts sysconst \
-      character athreads
-#      exec timer doslib utility hardware inputevent keymap graphics layers 
-#      intuition aboxlib mui 
-# these units are here, because they depend on system interface units above
-#      kvm \
-# disabled temporarily because it doesn't build
-#     sockets \
-# these can be moved to packages later
-#      clipboard datatypes asl ahi tinygl get9 muihelper
-#implicitunits=exeinfo\
-implicitunits=cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 \
+#loaders=prt0
+units=$(SYSTEMUNIT) heaptrc uuchar objpas macpas iso7185 extpas buildrtl cpall
+
+#      fpintres dos heaptrc ctypes \
+#      sysutils classes fgl math typinfo \
+#      charset cpall getopts \
+#      types rtlconsts sysconst \
+#      character athreads
+
+implicitunits=$(SYSINITUNITS) athreads dos sysutils \
+      ctypes strings rtlconsts sysconst math types \
+      typinfo fgl classes charset character getopts \
+      fpintres \
+      cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 \
       cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 \
       cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 \
       unicodedata unicodenumtable
       unicodedata unicodenumtable
 
 
@@ -33,6 +30,7 @@ nortl=y
 
 
 [install]
 [install]
 fpcpackage=y
 fpcpackage=y
+buildunit=buildrtl
 
 
 [default]
 [default]
 fpcdir=../..
 fpcdir=../..
@@ -52,6 +50,7 @@ PROCINC=$(RTL)/$(CPU_TARGET)
 AMIINC=$(RTL)/amicommon
 AMIINC=$(RTL)/amicommon
 UNITPREFIX=rtl
 UNITPREFIX=rtl
 SYSTEMUNIT=system
 SYSTEMUNIT=system
+SYSINITUNITS=si_prc
 
 
 # Use new feature from 1.0.5 version
 # Use new feature from 1.0.5 version
 # that generates release PPU files
 # that generates release PPU files
@@ -62,7 +61,6 @@ endif
 
 
 # Paths
 # Paths
 OBJPASDIR=$(RTL)/objpas
 OBJPASDIR=$(RTL)/objpas
-GRAPHDIR=$(INC)/graph
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
@@ -96,133 +94,26 @@ SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
 $(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS)
 $(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS)
         $(COMPILER) -Us -Sg $(SYSTEMUNIT).pp $(REDIR)
         $(COMPILER) -Us -Sg $(SYSTEMUNIT).pp $(REDIR)
 
 
-objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp $(REDIR)
-
-strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
-                   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
-                   $(SYSTEMUNIT)$(PPUEXT)
-
-#
-# System Dependent Units
-#
-
-#ports$(PPUEXT) : ports.pas objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-
-#doscalls$(PPUEXT) : doscalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-
-#
-# TP7 Compatible RTL Units
-#
-
-dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
-               $(SYSTEMUNIT)$(PPUEXT)
-
-#
-# Delphi Compatible Units
-#
-
-sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
-                    objpas$(PPUEXT) dos$(PPUEXT) sysconst$(PPUEXT)
-        $(COMPILER) -Fi$(OBJPASDIR)/sysutils $(AMIINC)/sysutils.pp
-
-classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
-                   sysutils$(PPUEXT) rtlconsts$(PPUEXT) typinfo$(PPUEXT) types$(PPUEXT) fgl$(PPUEXT)
-        $(COMPILER) -Fi$(OBJPASDIR)/classes $(AMIINC)/classes.pp
-
-character$(PPUEXT) : sysutils$(PPUEXT) $(OBJPASDIR)/character.pas objpas$(PPUEXT) rtlconsts$(PPUEXT) 
-        $(COMPILER) $(OBJPASDIR)/character.pas
-
-fgl$(PPUEXT) : $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) sysutils$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/fgl.pp
-
-typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
-        $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp $(REDIR)
-
-math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/math.pp $(REDIR)
-
-types$(PPUEXT) : $(OBJPASDIR/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/types.pp
-
-rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp
-        $(COMPILER) $(OBJPASDIR)/rtlconsts.pp
-
-sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/sysconst.pp
-
-#
-# Mac Pascal Model
-#
-
-macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT)
-        $(COMPILER) $(INC)/macpas.pp $(REDIR)
-
-#
-# Other system-independent RTL Units
-#
-
-getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
-
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) -Sg $(INC)/heaptrc.pp $(REDIR)
         $(COMPILER) -Sg $(INC)/heaptrc.pp $(REDIR)
 
 
-#lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
-#lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT)
-
-charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)
-
-cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) charset$(PPUEXT)
-        $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas
-
-fpintres$(PPUEXT) : $(INC)/fpintres.pp $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $(INC)/fpintres.pp
-
-#
-# Other system-dependent RTL Units
-#
-
-athreadss$(PPUEXT) : $(AMIINC)/athreads.pp $(SYSTEMUNIT)$(PPUEXT)
-
-#exec$(PPUEXT)    : exec.pp execf.inc execd.inc
-
-#timer$(PPUEXT)   : timer.pp timerd.inc timerf.inc
-
-#utility$(PPUEXT) : utility.pp exec$(PPUEXT) utilf.inc utild1.inc utild2.inc
-
-#doslib$(PPUEXT)  : doslib.pp exec$(PPUEXT) timer$(PPUEXT) doslibd.inc doslibf.inc
+uuchar$(PPUEXT): $(SYSTEMUNIT)$(PPUEXT) $(INC)/uuchar.pp heaptrc$(PPUEXT)
+        $(COMPILER) $(INC)/uuchar.pp
 
 
-#hardware$(PPUEXT): hardware.pas exec$(PPUEXT)
-
-#inputevent$(PPUEXT): inputevent.pas exec$(PPUEXT) timer$(PPUEXT) utility$(PPUEXT)
-
-#graphics$(PPUEXT): graphics.pas exec$(PPUEXT) utility$(PPUEXT) hardware$(PPUEXT)
-
-#layers$(PPUEXT)  : layers.pas exec$(PPUEXT) graphics$(PPUEXT) utility$(PPUEXT)
-
-#intuition$(PPUEXT): intuition.pas exec$(PPUEXT) graphics$(PPUEXT) utility$(PPUEXT) \
-#                    inputevent$(PPUEXT) timer$(PPUEXT) layers$(PPUEXT)
-
-#aboxlib$(PPUEXT): aboxlib.pas
-
-#clipboard$(PPUEXT): clipboard.pas exec$(PPUEXT)
-
-#datatype$(PPUEXT): datatypes.pas exec$(PPUEXT) doslib$(PPUEXT) intuition$(PPUEXT) \
-#                   utility$(PPUEXT) graphics$(PPUEXT)
-
-#asl$(PPUEXT): asl.pas exec$(PPUEXT) graphics$(PPUEXT) utility$(PPUEXT)
-
-#ahi$(PPUEXT): ahi.pas exec$(PPUEXT) utility$(PPUEXT)
-
-#mui$(PPUEXT): mui.pas exec$(PPUEXT) utility$(PPUEXT) intuition$(PPUEXT) graphics$(PPUEXT)
-
-#tinygl$(PPUEXT): tinygl.pp exec$(PPUEXT)
+objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
+        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp $(REDIR)
 
 
-#get9$(PPUEXT): get9.pas exec$(PPUEXT)
+macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) buildrtl$(PPUEXT) heaptrc$(PPUEXT)
+        $(COMPILER) $(INC)/macpas.pp
 
 
-#muihelper$(PPUEXT): muihelper.pas intuition$(PPUEXT) mui$(PPUEXT) doslib$(PPUEXT) utility$(PPUEXT)
+iso7185$(PPUEXT) : $(INC)/iso7185.pp buildrtl$(PPUEXT) heaptrc$(PPUEXT)
+        $(COMPILER) $(INC)/iso7185.pp
 
 
-#kvm$(PPUEXT) : kvm.pp
+extpas$(PPUEXT) : $(INC)/extpas.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) heaptrc$(PPUEXT)
+        $(COMPILER) $(INC)/extpas.pp
 
 
-ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
+buildrtl$(PPUEXT): buildrtl.pp system$(PPUEXT) objpas$(PPUEXT) heaptrc$(PPUEXT)
+        $(COMPILER) -Fi$(OBJPASDIR)/sysutils -Fi$(OBJPASDIR)/classes -Fu$(PROCINC) -Fu$(AMIINC) -I$(INC) -Fu$(INC) -Fu$(OBJPASDIR) buildrtl
 
 
+cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) objpas$(PPUEXT) heaptrc$(PPUEXT)
+        $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas

+ 17 - 0
rtl/morphos/buildrtl.pp

@@ -0,0 +1,17 @@
+unit buildrtl;
+
+  interface
+
+    uses
+      si_prc,
+      athreads, dos, sysutils,
+
+      ctypes, strings,
+      rtlconsts, sysconst, math, types,
+      typinfo, fgl, classes,
+      charset, character, getopts,
+      fpintres;
+
+  implementation
+
+end.

+ 1 - 7
rtl/morphos/prt0.as

@@ -76,7 +76,7 @@ _exit:
 
 
 _initproc:
 _initproc:
         mflr 0
         mflr 0
-        stw  0,4(1)     
+        stw  0,4(1)
         stwu 1,-128(1)
         stwu 1,-128(1)
         stw 13,52(1)
         stw 13,52(1)
         stw 14,56(1)
         stw 14,56(1)
@@ -150,11 +150,6 @@ _ExecBase:
 OriginalStkPtr:
 OriginalStkPtr:
         .long 0
         .long 0
 
 
-        .globl OriginalLinkRegister
-        .align 4
-OriginalLinkRegister:
-        .long 0
-
         .globl returnValue
         .globl returnValue
         .align 4
         .align 4
 returnValue:
 returnValue:
@@ -180,4 +175,3 @@ stackSwap:
         .size __abox__,4
         .size __abox__,4
 __abox__:
 __abox__:
         .long 1
         .long 1
-

+ 37 - 0
rtl/morphos/si_prc.pp

@@ -0,0 +1,37 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2016 by the Free Pascal development team
+
+    System Entry point for MorphOS, 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
+
+const
+  abox_signature: dword = 1; public name '__abox__';
+
+var
+  ExecBase: Pointer; public name '_ExecBase';
+  realExecBase: Pointer absolute $4;
+
+function PascalSysInit: longint; external name 'PASCALSYSINIT';
+
+function _FPC_proc_start: longint; public name '_start';
+begin
+  ExecBase:=realExecBase;
+  _FPC_proc_start:=PascalSysInit;
+end;
+
+end.

+ 40 - 0
rtl/morphos/system.pp

@@ -24,6 +24,7 @@ unit System;
 interface
 interface
 
 
 {$define FPC_IS_SYSTEM}
 {$define FPC_IS_SYSTEM}
+{$define PASCAL_SYSINIT}
 
 
 {$I systemh.inc}
 {$I systemh.inc}
 {$I osdebugh.inc}
 {$I osdebugh.inc}
@@ -114,7 +115,18 @@ type
                        Misc. System Dependent Functions
                        Misc. System Dependent Functions
 *****************************************************************************}
 *****************************************************************************}
 
 
+{$IFDEF PASCAL_SYSINIT}
+var
+  sysinit_jmpbuf: jmp_buf;
+
+procedure haltproc(e:longint);
+begin
+  longjmp(sysinit_jmpbuf,1);
+end;
+
+{$ELSE}
 procedure haltproc(e:longint);cdecl;external name '_haltproc';
 procedure haltproc(e:longint);cdecl;external name '_haltproc';
+{$ENDIF}
 
 
 procedure System_exit;
 procedure System_exit;
 var
 var
@@ -241,6 +253,34 @@ begin
   result := stklen;
   result := stklen;
 end;
 end;
 
 
+{$IFDEF PASCAL_SYSINIT}
+procedure PascalMain; external name 'PASCALMAIN';
+
+procedure PascalSysInitCallMain;
+begin
+  if setjmp(sysinit_jmpbuf) = 0 then
+    PascalMain;
+end;
+
+function PascalSysInit: LongInt; public name 'PASCALSYSINIT';
+var
+  sst: TStackSwapStruct;
+  newStack: Pointer;
+  newStackAligned: Pointer;
+begin
+  newStack:=AllocVecTaskPooled(InitialStkLen+16);
+  newStackAligned:=align(newStack,16);
+
+  sst.stk_Lower:=newStackAligned;
+  sst.stk_Upper:=newStackAligned+InitialStkLen;
+  sst.stk_Pointer:=newStackAligned+InitialStkLen;
+
+  NewPPCStackSwap(@sst,@PascalSysInitCallMain,nil);
+
+  FreeVecTaskPooled(newStack);
+  result:=ExitCode;
+end;
+{$ENDIF}
 
 
 begin
 begin
   IsConsole := TRUE;
   IsConsole := TRUE;

Some files were not shown because too many files changed in this diff