Browse Source

+ startup code skeleton for MIPS64

florian 3 years ago
parent
commit
c1ef094457

+ 1 - 1
compiler/systems.pas

@@ -391,7 +391,7 @@ interface
 
        systems_internal_sysinit = [system_i386_win32,system_x86_64_win64,
                                    system_i386_linux,system_powerpc64_linux,system_sparc64_linux,system_x86_64_linux,
-                                   system_xtensa_linux,
+                                   system_xtensa_linux,system_mips64_linux,system_mips64el_linux,
                                    system_m68k_atari,system_m68k_palmos,system_m68k_sinclairql,
                                    system_i386_haiku,system_x86_64_haiku,
                                    system_i386_openbsd,system_x86_64_openbsd,

+ 9 - 1
rtl/linux/Makefile

@@ -387,6 +387,14 @@ ifeq ($(ARCH),riscv64)
 override LOADERS=
 SYSINIT_UNITS=si_prc si_dll si_c si_g
 endif
+ifeq ($(ARCH),mips64)
+override LOADERS=
+SYSINIT_UNITS=si_prc si_dll si_c si_g
+endif
+ifeq ($(ARCH),mips64el)
+override LOADERS=
+SYSINIT_UNITS=si_prc si_dll si_c si_g
+endif
 ifeq ($(ARCH),mipsel)
 override FPCOPT+=-Ur
 endif
@@ -3863,7 +3871,7 @@ ifdef CREATESHARED
 override FPCOPT+=-Cg
 endif
 ifneq ($(filter $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),)
-ifneq ($(filter $(CPU_TARGET),x86_64 mips mipsel riscv64 powerpc64),)
+ifneq ($(filter $(CPU_TARGET),x86_64 mips mipsel mips64 mips64el riscv64 powerpc64),)
 override FPCOPT+=-Cg
 endif
 endif

+ 10 - 0
rtl/linux/Makefile.fpc

@@ -102,6 +102,16 @@ override LOADERS=
 SYSINIT_UNITS=si_prc si_dll si_c si_g
 endif
 
+ifeq ($(ARCH),mips64)
+override LOADERS=
+SYSINIT_UNITS=si_prc si_dll si_c si_g
+endif
+
+ifeq ($(ARCH),mips64el)
+override LOADERS=
+SYSINIT_UNITS=si_prc si_dll si_c si_g
+endif
+
 # mipsel reuses mips files by including so some file names exist
 # twice, this causes the compiler to find sometimes wrong files and it tries
 # to recompile rtl units. To prevent this, compile always as release PPUs, this

+ 45 - 0
rtl/linux/mips64/si_c.inc

@@ -0,0 +1,45 @@
+{
+    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';
+
+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
+    { try to exit_group }
+    while true do
+      asm
+      end;
+  end;
+

+ 39 - 0
rtl/linux/mips64/si_dll.inc

@@ -0,0 +1,39 @@
+{
+    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
+      end;
+  end;
+

+ 35 - 0
rtl/linux/mips64/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;
+

+ 37 - 0
rtl/linux/mips64/si_prc.inc

@@ -0,0 +1,37 @@
+{
+    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;
+
+procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
+  asm
+  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 }
+  end;

+ 15 - 0
rtl/linux/mips64el/si_c.inc

@@ -0,0 +1,15 @@
+{
+   This file is part of the Free Pascal run time library.
+   Copyright (c) 2022 by Florian Klaempfl
+   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.
+
+**********************************************************************}
+
+{$I ../mips64/si_c.inc}

+ 15 - 0
rtl/linux/mips64el/si_dll.inc

@@ -0,0 +1,15 @@
+{
+   This file is part of the Free Pascal run time library.
+   Copyright (c) 2022 by Florian Klaempfl
+   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.
+
+**********************************************************************}
+
+{$I ../mips64/si_dll.inc}

+ 15 - 0
rtl/linux/mips64el/si_g.inc

@@ -0,0 +1,15 @@
+{
+   This file is part of the Free Pascal run time library.
+   Copyright (c) 2022 by Florian Klaempfl
+   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.
+
+**********************************************************************}
+
+{$I ../mips64/si_g.inc}

+ 15 - 0
rtl/linux/mips64el/si_prc.inc

@@ -0,0 +1,15 @@
+{
+   This file is part of the Free Pascal run time library.
+   Copyright (c) 2022 by Florian Klaempfl
+   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.
+
+**********************************************************************}
+
+{$I ../mips64/si_prc.inc}

+ 6 - 0
rtl/mips64el/makefile.cpu

@@ -0,0 +1,6 @@
+#
+# Here we set processor dependent include file names.
+#
+
+CPUNAMES=mips64el math set cpuh
+CPUINCNAMES=$(addsuffix .inc,$(CPUNAMES))

+ 15 - 0
rtl/mips64el/mips64el.inc

@@ -0,0 +1,15 @@
+{
+   This file is part of the Free Pascal run time library.
+   Copyright (c) 2022 by Florian Klaempfl
+   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.
+
+**********************************************************************}
+
+{$I ../mips64/mips64.inc}