mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 06:09:22 +02:00
* rtl part of gba port
git-svn-id: trunk@935 -
This commit is contained in:
parent
715d5f1f7f
commit
3134acd506
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -3370,6 +3370,11 @@ rtl/freebsd/unxsockh.inc svneol=native#text/plain
|
|||||||
rtl/freebsd/unxsysc.inc svneol=native#text/plain
|
rtl/freebsd/unxsysc.inc svneol=native#text/plain
|
||||||
rtl/freebsd/x86_64/bsyscall.inc svneol=native#text/plain
|
rtl/freebsd/x86_64/bsyscall.inc svneol=native#text/plain
|
||||||
rtl/freebsd/x86_64/prt0.as -text
|
rtl/freebsd/x86_64/prt0.as -text
|
||||||
|
rtl/gba/Makefile.fpc svneol=native#text/plain
|
||||||
|
rtl/gba/prt0.as -text
|
||||||
|
rtl/gba/sysgba.pp svneol=native#text/plain
|
||||||
|
rtl/gba/system.pp svneol=native#text/plain
|
||||||
|
rtl/gba/unix.pp svneol=native#text/plain
|
||||||
rtl/go32v2/Makefile svneol=native#text/plain
|
rtl/go32v2/Makefile svneol=native#text/plain
|
||||||
rtl/go32v2/Makefile.fpc svneol=native#text/plain
|
rtl/go32v2/Makefile.fpc svneol=native#text/plain
|
||||||
rtl/go32v2/classes.pp svneol=native#text/plain
|
rtl/go32v2/classes.pp svneol=native#text/plain
|
||||||
|
279
rtl/gba/Makefile.fpc
Normal file
279
rtl/gba/Makefile.fpc
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
#
|
||||||
|
# Makefile.fpc for Free Pascal GBA RTL
|
||||||
|
#
|
||||||
|
|
||||||
|
[package]
|
||||||
|
main=rtl
|
||||||
|
|
||||||
|
[target]
|
||||||
|
loaders=prt0
|
||||||
|
units=$(SYSTEMUNIT) unixtype ctypes baseunix strings objpas macpas syscall unixutil \
|
||||||
|
heaptrc lineinfo \
|
||||||
|
sysutils typinfo math \
|
||||||
|
charset getopts \
|
||||||
|
errors \
|
||||||
|
types dateutils sysconst \
|
||||||
|
cthreads classes strutils rtlconsts dos objects
|
||||||
|
|
||||||
|
rsts=math typinfo sysconst rtlconsts
|
||||||
|
|
||||||
|
[require]
|
||||||
|
nortl=y
|
||||||
|
|
||||||
|
[clean]
|
||||||
|
units=sysgba gba
|
||||||
|
|
||||||
|
[install]
|
||||||
|
fpcpackage=y
|
||||||
|
|
||||||
|
[default]
|
||||||
|
fpcdir=../..
|
||||||
|
target=gba
|
||||||
|
|
||||||
|
[compiler]
|
||||||
|
includedir=$(INC) $(PROCINC) $(UNIXINC) $(CPU_TARGET)
|
||||||
|
sourcedir=$(INC) $(PROCINC) $(UNIXINC) $(CPU_TARGET)
|
||||||
|
targetdir=.
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
libname=libfprtl.so
|
||||||
|
libversion=2.0.0
|
||||||
|
libunits=$(SYSTEMUNIT) objpas strings \
|
||||||
|
unix ports \
|
||||||
|
dos crt objects printer \
|
||||||
|
sysutils typinfo math \
|
||||||
|
cpu mmx getopts heaptrc \
|
||||||
|
errors
|
||||||
|
|
||||||
|
[prerules]
|
||||||
|
RTL=..
|
||||||
|
INC=$(RTL)/inc
|
||||||
|
PROCINC=$(RTL)/$(CPU_TARGET)
|
||||||
|
UNIXINC=$(RTL)/unix
|
||||||
|
|
||||||
|
ifeq ($(CPU_TARGET),i386)
|
||||||
|
CRT21=cprt21 gprt21
|
||||||
|
CPU_UNITS=x86 ports cpu mmx graph
|
||||||
|
else
|
||||||
|
CPU_UNITS=
|
||||||
|
endif
|
||||||
|
|
||||||
|
UNITPREFIX=rtl
|
||||||
|
|
||||||
|
ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
|
||||||
|
SYSTEMUNIT=system
|
||||||
|
LINUXUNIT1=
|
||||||
|
ifeq ($(CPU_TARGET),i386)
|
||||||
|
CPU_UNITS+=oldlinux
|
||||||
|
endif
|
||||||
|
LINUXUNIT2=linux
|
||||||
|
else
|
||||||
|
SYSTEMUNIT=sysgba
|
||||||
|
LINUXUNIT1=gba
|
||||||
|
LINUXUNIT2=
|
||||||
|
override FPCOPT+=-dUNIX
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Use new feature from 1.0.5 version
|
||||||
|
# that generates release PPU files
|
||||||
|
# which will not be recompiled
|
||||||
|
ifdef RELEASE
|
||||||
|
override FPCOPT+=-Ur
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Paths
|
||||||
|
OBJPASDIR=$(RTL)/objpas
|
||||||
|
#GRAPHDIR=$(INC)/graph
|
||||||
|
|
||||||
|
# Use new graph unit ?
|
||||||
|
# NEWGRAPH=YES
|
||||||
|
# Use LibGGI ?
|
||||||
|
# Use
|
||||||
|
#
|
||||||
|
ifndef USELIBGGI
|
||||||
|
USELIBGGI=NO
|
||||||
|
endif
|
||||||
|
|
||||||
|
[rules]
|
||||||
|
# Get the $(SYSTEMUNIT) independent include file names.
|
||||||
|
# This will set the following variables :
|
||||||
|
# SYSINCNAMES
|
||||||
|
include $(INC)/makefile.inc
|
||||||
|
SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
|
||||||
|
|
||||||
|
# Get the processor dependent include file names.
|
||||||
|
# This will set the following variables :
|
||||||
|
# CPUINCNAMES
|
||||||
|
include $(PROCINC)/makefile.cpu
|
||||||
|
SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
|
||||||
|
|
||||||
|
# Put $(SYSTEMUNIT) unit dependencies together.
|
||||||
|
SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Loaders
|
||||||
|
#
|
||||||
|
|
||||||
|
prt0$(OEXT) : $(CPU_TARGET)/prt0.as
|
||||||
|
$(AS) -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) $(CPU_TARGET)/prt0.as
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# $(SYSTEMUNIT) Units ($(SYSTEMUNIT), Objpas, Strings)
|
||||||
|
#
|
||||||
|
|
||||||
|
$(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS)
|
||||||
|
$(COMPILER) -Us -Sg $(SYSTEMUNIT).pp
|
||||||
|
|
||||||
|
objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
|
||||||
|
|
||||||
|
dateutils$(PPUEXT): $(OBJPASDIR)/dateutils.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutils.pp
|
||||||
|
|
||||||
|
strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
|
||||||
|
$(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
|
||||||
|
$(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#
|
||||||
|
# $(SYSTEMUNIT) Dependent Units
|
||||||
|
#
|
||||||
|
|
||||||
|
#unix$(PPUEXT) : unix.pp strings$(PPUEXT) baseunix$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
|
||||||
|
# unxconst.inc $(UNIXINC)/timezone.inc $(SYSTEMUNIT)$(PPUEXT) \
|
||||||
|
# unxfunc.inc
|
||||||
|
|
||||||
|
unixtype$(PPUEXT) : $(UNIXINC)/unixtype.pp ptypes.inc $(UNIXINC)/ctypes.inc $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
baseunix$(PPUEXT) : errno.inc ptypes.inc $(UNIXINC)/ctypes.inc \
|
||||||
|
$(UNIXINC)/bunxh.inc \
|
||||||
|
bunxsysc.inc $(CPU_TARGET)/syscallh.inc $(CPU_TARGET)/sysnr.inc \
|
||||||
|
ostypes.inc osmacro.inc $(UNIXINC)/gensigset.inc \
|
||||||
|
$(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
ports$(PPUEXT) : ports.pp unix$(PPUEXT) objpas$(PPUEXT)
|
||||||
|
|
||||||
|
#dl$(PPUEXT) : $(UNIXINC)/dl.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#dynlibs$(PPUEXT) : $(INC)/dynlibs.pp $(UNIXINC)/dynlibs.inc dl$(PPUEXT) objpas$(PPUEXT)
|
||||||
|
|
||||||
|
#
|
||||||
|
# TP7 Compatible RTL Units
|
||||||
|
#
|
||||||
|
|
||||||
|
dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
|
||||||
|
unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#crt$(PPUEXT) : crt.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
objects$(PPUEXT) : $(INC)/objects.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#printer$(PPUEXT) : printer.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Graph
|
||||||
|
#
|
||||||
|
#include $(GRAPHDIR)/makefile.inc
|
||||||
|
#GRAPHINCDEPS=$(addprefix $(GRAPHDIR)/,$(GRAPHINCNAMES))
|
||||||
|
|
||||||
|
#graph$(PPUEXT) : graph.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
|
||||||
|
# $(GRAPHINCDEPS) $(UNIXINC)/graph16.inc
|
||||||
|
# $(COMPILER) -I$(GRAPHDIR) $(UNIXINC)/graph.pp
|
||||||
|
|
||||||
|
#ggigraph$(PPUEXT) : $(UNIXINC)/ggigraph.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
|
||||||
|
# $(GRAPHINCDEPS)
|
||||||
|
# $(COMPILER) -I$(GRAPHDIR) $(UNIXINC)/ggigraph.pp
|
||||||
|
|
||||||
|
#
|
||||||
|
# Delphi Compatible Units
|
||||||
|
#
|
||||||
|
|
||||||
|
sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
|
||||||
|
objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT) sysconst$(PPUEXT)
|
||||||
|
$(COMPILER) -Fi$(OBJPASDIR)/sysutils $(UNIXINC)/sysutils.pp
|
||||||
|
|
||||||
|
classes$(PPUEXT) : $(UNIXINC)/classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
|
||||||
|
sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT)
|
||||||
|
$(COMPILER) -Fi$(OBJPASDIR)/classes $(UNIXINC)/classes.pp
|
||||||
|
|
||||||
|
typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT) sysutils$(PPUEXT) rtlconsts$(PPUEXT)
|
||||||
|
$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp
|
||||||
|
|
||||||
|
math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
|
||||||
|
$(COMPILER) $(OBJPASDIR)/math.pp
|
||||||
|
|
||||||
|
gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
|
||||||
|
$(COMPILER) $(OBJPASDIR)/gettext.pp
|
||||||
|
|
||||||
|
#varutils$(PPUEXT) : $(OBJPASDIR)/cvarutil.inc $(OBJPASDIR)/varutils.inc \
|
||||||
|
# $(OBJPASDIR)/varutilh.inc varutils.pp sysutils$(PPUEXT)
|
||||||
|
# $(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/varutils.pp
|
||||||
|
|
||||||
|
#variants$(PPUEXT) : $(INC)/variants.pp sysutils$(PPUEXT) sysconst$(PPUEXT) varutils$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT)
|
||||||
|
# $(COMPILER) -Fi$(INC) $(INC)/variants.pp
|
||||||
|
|
||||||
|
types$(PPUEXT) : $(OBJPASDIR)/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
$(COMPILER) $(OBJPASDIR)/types.pp
|
||||||
|
|
||||||
|
sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
$(COMPILER) $(OBJPASDIR)/sysconst.pp
|
||||||
|
|
||||||
|
rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
$(COMPILER) $(OBJPASDIR)/rtlconsts.pp
|
||||||
|
|
||||||
|
strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
|
||||||
|
sysutils$(PPUEXT)
|
||||||
|
$(COMPILER) $(OBJPASDIR)/strutils.pp
|
||||||
|
|
||||||
|
#
|
||||||
|
# Mac Pascal Model
|
||||||
|
#
|
||||||
|
|
||||||
|
#macpas$(PPUEXT) : $(INC)/macpas.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
# $(COMPILER) $(INC)/macpas.pp $(REDIR)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Other $(SYSTEMUNIT)-independent RTL Units
|
||||||
|
#
|
||||||
|
|
||||||
|
cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
$(COMPILER) -Sg $(INC)/heaptrc.pp
|
||||||
|
|
||||||
|
lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#ucomplex$(PPUEXT) : $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Other $(SYSTEMUNIT)-dependent RTL Units
|
||||||
|
#
|
||||||
|
|
||||||
|
#sockets$(PPUEXT) : sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
|
||||||
|
# unixsock.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
errors$(PPUEXT) : errors.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#ipc$(PPUEXT) : ipc.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#terminfo$(PPUEXT) : terminfo.pp unix$(PPUEXT)
|
||||||
|
|
||||||
|
callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
cmem$(PPUEXT) : $(INC)/cmem.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
||||||
|
#cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT)
|
||||||
|
|
||||||
|
#gpm$(PPUEXT): gpm.pp unix$(PPUEXT) baseunix$(PPUEXT) sockets$(PPUEXT)
|
||||||
|
|
||||||
|
ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
|
||||||
|
|
159
rtl/gba/fpc4gba.txt
Normal file
159
rtl/gba/fpc4gba.txt
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
+-------------------------------------+
|
||||||
|
| Let's build a gba compiler with fpc |
|
||||||
|
+-------------------------------------+
|
||||||
|
| Author: Francesco Lombardi |
|
||||||
|
| Release date: 2005.08.09 |
|
||||||
|
+-------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
Tools needed
|
||||||
|
------------
|
||||||
|
-FPC compiler for your platform, ver 2.0.0 (http://www.freepascal.org/)
|
||||||
|
-FPC sources, ver 2.0.0 (http://www.freepascal.org/)
|
||||||
|
-MSYS (http://www.mingw.org/msys.shtml)
|
||||||
|
-An emulator with integrated debugger or, at least, a memory viewer, like
|
||||||
|
Boycott Advance (http://www.ngemu.com/gba/bca.php main site does not work)
|
||||||
|
or Visual Boy Advance Development version (http://vba.ngemu.com/)
|
||||||
|
|
||||||
|
|
||||||
|
Foreword
|
||||||
|
--------
|
||||||
|
I'l use MSYS, because I'm confortable with POSIX-like ambient. It is a fork of
|
||||||
|
cygwin, but more friendly for win32 users. However, feel free to use dos prompt
|
||||||
|
if you like it. Remember that MSYS includes GNU Make utility, that is needed in
|
||||||
|
order to build freepascal.
|
||||||
|
In the source files provided with this package, you can find occasionally some
|
||||||
|
comments, that explain the changes made.
|
||||||
|
|
||||||
|
|
||||||
|
Preparing all things
|
||||||
|
--------------------
|
||||||
|
Install fpc compiler as usual in a directory of your choice (eg. c:\fpc);
|
||||||
|
extract fpc sources in fpc binaries directory (eg. c:\fpc\source). If you
|
||||||
|
decided for MSYS, install it.
|
||||||
|
|
||||||
|
|
||||||
|
Compiler modification
|
||||||
|
---------------------
|
||||||
|
Copy the files you found in "Compiler" directory of this package, following this
|
||||||
|
scheme:
|
||||||
|
- t_gba.pas in %FreePascal%\source\compiler\systems
|
||||||
|
- i_gba.pas in %FreePascal%\source\compiler\systems
|
||||||
|
- cputarg.pas in %FreePascal%\source\compiler\arm
|
||||||
|
- compiler.pas in %FreePascal%\source\compiler
|
||||||
|
- systems.pas in %FreePascal%\source\compiler
|
||||||
|
Now open msys (or a dos prompt), go to %FreePascal%\source\compiler and run
|
||||||
|
"make PPC_TARGET=arm".
|
||||||
|
Go to %FreePascal%\bin\i386-win32, make a new directory 'arm-gba' and copy here
|
||||||
|
the new generated file ppcarm.exe. Extract and copy here the files in
|
||||||
|
win32_arm_binutils.zip (ls.exe, ld.exe, objcopy.exe and cygwin1.dll). Now add
|
||||||
|
'%FreePascal%\bin\i386-win32\arm-gba' in the search path.
|
||||||
|
|
||||||
|
|
||||||
|
FPCMake modification
|
||||||
|
--------------------
|
||||||
|
Copy the files you found in "FPCMake" directory of this package in the directory
|
||||||
|
|
||||||
|
%FreePascal%\source\utils\fpcm
|
||||||
|
|
||||||
|
In msys (or a dos prompt), go to %FreePascal%\source\utils\fpcm and run
|
||||||
|
"make". Go to %FreePascal%\bin\i386-win32 and copy here the new generated file
|
||||||
|
fpcmake.exe. This utility is useful when you try to build the rtl, because it
|
||||||
|
generates all makefiles starting from a smuch more simple makefile.fpc.
|
||||||
|
|
||||||
|
|
||||||
|
RTL Modification
|
||||||
|
----------------
|
||||||
|
Go in %FreePascal%\source\rtl, make a copy of 'linux' directory and rename it
|
||||||
|
'gba'. Go in the new created 'gba' and delete all subdirectories, except 'arm'.
|
||||||
|
Delete the files system.pp, syslinux.pp, makefile and makefile.fpc. Go in 'arm'
|
||||||
|
subdirectory and delete all .as files.
|
||||||
|
Copy the files you found in "RTL" directory of this package, following this
|
||||||
|
scheme:
|
||||||
|
- system.pp in %FreePascal%\source\rtl\gba
|
||||||
|
- sysgba.pp in %FreePascal%\source\rtl\gba
|
||||||
|
- makefile.fpc in %FreePascal%\source\rtl\gba
|
||||||
|
- prt0.as in %FreePascal%\source\rtl\gba\arm
|
||||||
|
- unix.pp in %FreePascal%\source\rtl\unix
|
||||||
|
|
||||||
|
Go to %FreePascal%\source\rtl, open makefile.fpc and add a new target:
|
||||||
|
|
||||||
|
...
|
||||||
|
...
|
||||||
|
[target]
|
||||||
|
...
|
||||||
|
dirs_gba=gba
|
||||||
|
|
||||||
|
In msys (or a dos prompt), go to %FreePascal%\source\rtl and run
|
||||||
|
"fpcmake -Tall -r -w": this command rebuild all makefiles. Now do a "make
|
||||||
|
distclean", then run 'make CPU_TARGET=arm OS_TARGET=gba PP=ppcarm OPT="-Tgba"'
|
||||||
|
At the end of the compiling, you can find a new directory:
|
||||||
|
|
||||||
|
%FreePascal%\source\rtl\units\arm-gba
|
||||||
|
|
||||||
|
Copy the directory 'arm-gba' and all its content in
|
||||||
|
|
||||||
|
%FreePascal%\units
|
||||||
|
|
||||||
|
|
||||||
|
Ending
|
||||||
|
------
|
||||||
|
Now you can try to compile some pascal code, like the examples in the package:
|
||||||
|
|
||||||
|
ppcarm -Tgba -n -Fuc:\fpc\units\arm-gba gba.pp
|
||||||
|
|
||||||
|
Look at compile.bat. It produces a gba.gba file, but if you try to run on a gba
|
||||||
|
emu, it does not work (you must see if 0x04000000 address contains 0x0403).
|
||||||
|
|
||||||
|
At this point you can try a trick: remove from gba.s the following lines:
|
||||||
|
|
||||||
|
line Asm Code
|
||||||
|
---- --------
|
||||||
|
...
|
||||||
|
[22] bl FPC_INITIALIZEUNITS
|
||||||
|
...
|
||||||
|
[40] bl FPC_DO_EXIT
|
||||||
|
...
|
||||||
|
[57] .globl THREADVARLIST_P$GBA
|
||||||
|
[58] THREADVARLIST_P$GBA:
|
||||||
|
[59] .long 0
|
||||||
|
[60] .Le1:
|
||||||
|
[61] .size THREADVARLIST_P$GBA, .Le1 - THREADVARLIST_P$GBA
|
||||||
|
[62] .balign 4
|
||||||
|
[63] .globl FPC_THREADVARTABLES
|
||||||
|
[64] FPC_THREADVARTABLES:
|
||||||
|
[65] .long 2
|
||||||
|
[66] .long THREADVARLIST_SYSTEM
|
||||||
|
[67] .long THREADVARLIST_P$GBA
|
||||||
|
[68] .Le2:
|
||||||
|
[69] .size FPC_THREADVARTABLES, .Le2 - FPC_THREADVARTABLES
|
||||||
|
[70] .balign 4
|
||||||
|
[71] .globl FPC_RESOURCESTRINGTABLES
|
||||||
|
[72] FPC_RESOURCESTRINGTABLES:
|
||||||
|
[73] .long 0
|
||||||
|
[74] .Le3:
|
||||||
|
[75] .size FPC_RESOURCESTRINGTABLES, .Le3 - FPC_RESOURCESTRINGTABLES
|
||||||
|
[76] .balign 4
|
||||||
|
[77] .globl INITFINAL
|
||||||
|
[78] INITFINAL:
|
||||||
|
[79] .long 1,0
|
||||||
|
[80] .long INIT$_SYSTEM
|
||||||
|
[81] .long FINALIZE$_SYSTEM
|
||||||
|
[82] .Le4:
|
||||||
|
[83] .size INITFINAL, .Le4 - INITFINAL
|
||||||
|
[84] .balign 4
|
||||||
|
|
||||||
|
This 'garbage' (sorry fpk ^_^) is initialization code added from fpc compiler,
|
||||||
|
but interferes with our initialization code.
|
||||||
|
Now run compile2.bat; the gba.gba file runs fine in the emu (flags correctly
|
||||||
|
set, rom header good).
|
||||||
|
|
||||||
|
|
||||||
|
Next steps?
|
||||||
|
-----------
|
||||||
|
Well, we need some further rtl hacking to handle fpc initialization code, that's
|
||||||
|
beyond my knowledge. You can try to download a pdf with fpc internals
|
||||||
|
(comparch.pdf) for more infos, but I think that an help from fpk & friends could
|
||||||
|
be better ^_^
|
||||||
|
About prt0.s: the file provided works fine for our initial purposes, but someday
|
||||||
|
we must use a startup file more advanced for handle all gba capabilities.
|
101
rtl/gba/prt0.as
Normal file
101
rtl/gba/prt0.as
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
@********************************************************************
|
||||||
|
@* crt0.s *
|
||||||
|
@ This file is a hack. It is not meant for serious work. *
|
||||||
|
@********************************************************************
|
||||||
|
.TEXT
|
||||||
|
|
||||||
|
.GLOBAL _start
|
||||||
|
_start:
|
||||||
|
.ALIGN
|
||||||
|
.CODE 32
|
||||||
|
@ Start Vector
|
||||||
|
rom_header: b rom_header_end
|
||||||
|
|
||||||
|
@ Nintendo Logo Character Data (8000004h)
|
||||||
|
.byte 0x24,0xff,0xae,0x51,0x69,0x9a,0xa2,0x21
|
||||||
|
.byte 0x3d,0x84,0x82,0x0a,0x84,0xe4,0x09,0xad
|
||||||
|
.byte 0x11,0x24,0x8b,0x98,0xc0,0x81,0x7f,0x21
|
||||||
|
.byte 0xa3,0x52,0xbe,0x19,0x93,0x09,0xce,0x20
|
||||||
|
.byte 0x10,0x46,0x4a,0x4a,0xf8,0x27,0x31,0xec
|
||||||
|
.byte 0x58,0xc7,0xe8,0x33,0x82,0xe3,0xce,0xbf
|
||||||
|
.byte 0x85,0xf4,0xdf,0x94,0xce,0x4b,0x09,0xc1
|
||||||
|
.byte 0x94,0x56,0x8a,0xc0,0x13,0x72,0xa7,0xfc
|
||||||
|
.byte 0x9f,0x84,0x4d,0x73,0xa3,0xca,0x9a,0x61
|
||||||
|
.byte 0x58,0x97,0xa3,0x27,0xfc,0x03,0x98,0x76
|
||||||
|
.byte 0x23,0x1d,0xc7,0x61,0x03,0x04,0xae,0x56
|
||||||
|
.byte 0xbf,0x38,0x84,0x00,0x40,0xa7,0x0e,0xfd
|
||||||
|
.byte 0xff,0x52,0xfe,0x03,0x6f,0x95,0x30,0xf1
|
||||||
|
.byte 0x97,0xfb,0xc0,0x85,0x60,0xd6,0x80,0x25
|
||||||
|
.byte 0xa9,0x63,0xbe,0x03,0x01,0x4e,0x38,0xe2
|
||||||
|
.byte 0xf9,0xa2,0x34,0xff,0xbb,0x3e,0x03,0x44
|
||||||
|
.byte 0x78,0x00,0x90,0xcb,0x88,0x11,0x3a,0x94
|
||||||
|
.byte 0x65,0xc0,0x7c,0x63,0x87,0xf0,0x3c,0xaf
|
||||||
|
.byte 0xd6,0x25,0xe4,0x8b,0x38,0x0a,0xac,0x72
|
||||||
|
.byte 0x21,0xd4,0xf8,0x07
|
||||||
|
|
||||||
|
@ Software Titles (80000A0h)
|
||||||
|
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
.byte 0x00,0x00,0x00,0x00
|
||||||
|
|
||||||
|
@ Initial Code (80000ACh)
|
||||||
|
.byte 0x00,0x00,0x00,0x00
|
||||||
|
|
||||||
|
@ Maker Code (80000B0h)
|
||||||
|
.byte 0x30,0x31
|
||||||
|
|
||||||
|
@ Fixed Value (80000B2h)
|
||||||
|
.byte 0x96
|
||||||
|
|
||||||
|
@ Main Unit Code (80000B3h)
|
||||||
|
.byte 0x00
|
||||||
|
|
||||||
|
@ Device Type (80000B4h)
|
||||||
|
.byte 0x00
|
||||||
|
|
||||||
|
@ Unused Data (7Byte) (80000B5h)
|
||||||
|
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
|
||||||
|
@ Software Version No (80000BCh)
|
||||||
|
.byte 0x00
|
||||||
|
|
||||||
|
@ Complement Check (80000BDh)
|
||||||
|
.byte 0xf0
|
||||||
|
|
||||||
|
@ Check Sum (80000BEh)
|
||||||
|
.byte 0x00,0x00
|
||||||
|
|
||||||
|
rom_header_end:
|
||||||
|
|
||||||
|
@--------------------------------------------------------------------
|
||||||
|
@- Reset -
|
||||||
|
@--------------------------------------------------------------------
|
||||||
|
.EXTERN PASCALMAIN
|
||||||
|
.GLOBAL start_vector
|
||||||
|
.CODE 32
|
||||||
|
.ALIGN
|
||||||
|
start_vector:
|
||||||
|
mov r0, #0x12 @ Switch to IRQ Mode
|
||||||
|
msr cpsr, r0
|
||||||
|
|
||||||
|
ldr sp, sp_irq @ Set SP_irq
|
||||||
|
|
||||||
|
mov r0, #0x1f @ Switch to System Mode
|
||||||
|
msr cpsr, r0
|
||||||
|
|
||||||
|
ldr sp, sp_usr @ Set SP_usr
|
||||||
|
str r0, [r1]
|
||||||
|
|
||||||
|
ldr r1, =PASCALMAIN @ Start & Switch to 16bit Code
|
||||||
|
mov lr, pc
|
||||||
|
bx r1
|
||||||
|
|
||||||
|
b start_vector @ Reset
|
||||||
|
|
||||||
|
.ALIGN
|
||||||
|
sp_usr: .word 0x3008000 - 0x100
|
||||||
|
sp_irq: .word 0x3008000 - 0x60
|
||||||
|
|
||||||
|
.ALIGN
|
||||||
|
.CODE 32
|
||||||
|
|
||||||
|
.END
|
1
rtl/gba/sysgba.pp
Normal file
1
rtl/gba/sysgba.pp
Normal file
@ -0,0 +1 @@
|
|||||||
|
{$i system.pp}
|
295
rtl/gba/system.pp
Normal file
295
rtl/gba/system.pp
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
{
|
||||||
|
$Id: system.pp,v 1.25 2005/04/24 21:19:22 peter Exp $
|
||||||
|
This file is part of the Free Pascal run time librar~y.
|
||||||
|
Copyright (c) 2000 by Marco van de Voort
|
||||||
|
member of the Free Pascal development team.
|
||||||
|
|
||||||
|
System unit for Linux.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
**********************************************************************}
|
||||||
|
|
||||||
|
{ These things are set in the makefile, }
|
||||||
|
{ But you can override them here.}
|
||||||
|
|
||||||
|
|
||||||
|
{ If you use an aout system, set the conditional AOUT}
|
||||||
|
{.$Define AOUT}
|
||||||
|
|
||||||
|
Unit {$ifdef VER1_0}Sysgba{$else}System{$endif};
|
||||||
|
|
||||||
|
Interface
|
||||||
|
|
||||||
|
{$define FPC_IS_SYSTEM}
|
||||||
|
|
||||||
|
{$i osdefs.inc}
|
||||||
|
|
||||||
|
{$I sysunixh.inc}
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
|
||||||
|
|
||||||
|
{$I system.inc}
|
||||||
|
|
||||||
|
|
||||||
|
{*****************************************************************************
|
||||||
|
Misc. System Dependent Functions
|
||||||
|
*****************************************************************************}
|
||||||
|
|
||||||
|
//procedure fpc_initializeunits;[public,alias:'FPC_INITIALIZEUNITS'];
|
||||||
|
//begin
|
||||||
|
// { dummy }
|
||||||
|
//end;
|
||||||
|
|
||||||
|
//procedure fpc_do_exit;[public,alias:'FPC_DO_EXIT'];
|
||||||
|
//begin
|
||||||
|
// { dummy }
|
||||||
|
//end;
|
||||||
|
|
||||||
|
//procedure halt; [public,alias:'FPC_HALT_ZERO'];
|
||||||
|
//begin
|
||||||
|
// fpc_do_exit;
|
||||||
|
//end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///-F-/// procedure haltproc(e:longint);cdecl;external name '_haltproc';
|
||||||
|
|
||||||
|
procedure System_exit;
|
||||||
|
begin
|
||||||
|
///-F-/// haltproc(ExitCode);
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
Function ParamCount: Longint;
|
||||||
|
Begin
|
||||||
|
///-F-/// Paramcount:=argc-1
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
function BackPos(c:char; const s: shortstring): integer;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
Begin
|
||||||
|
for i:=length(s) downto 0 do
|
||||||
|
if s[i] = c then break;
|
||||||
|
if i=0 then
|
||||||
|
BackPos := 0
|
||||||
|
else
|
||||||
|
BackPos := i;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ variable where full path and filename and executable is stored }
|
||||||
|
{ is setup by the startup of the system unit. }
|
||||||
|
var
|
||||||
|
execpathstr : shortstring;
|
||||||
|
|
||||||
|
function paramstr(l: longint) : string;
|
||||||
|
begin
|
||||||
|
{ stricly conforming POSIX applications }
|
||||||
|
{ have the executing filename as argv[0] }
|
||||||
|
///-F-/// if l=0 then
|
||||||
|
///-F-/// begin
|
||||||
|
///-F-/// paramstr := execpathstr;
|
||||||
|
///-F-/// end
|
||||||
|
///-F-/// else
|
||||||
|
///-F-/// paramstr:=strpas(argv[l]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure Randomize;
|
||||||
|
Begin
|
||||||
|
randseed:=longint(Fptime(nil));
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
{*****************************************************************************
|
||||||
|
SystemUnit Initialization
|
||||||
|
*****************************************************************************}
|
||||||
|
|
||||||
|
function reenable_signal(sig : longint) : boolean;
|
||||||
|
var
|
||||||
|
e : TSigSet;
|
||||||
|
i,j : byte;
|
||||||
|
begin
|
||||||
|
fillchar(e,sizeof(e),#0);
|
||||||
|
{ set is 1 based PM }
|
||||||
|
dec(sig);
|
||||||
|
i:=sig mod 32;
|
||||||
|
j:=sig div 32;
|
||||||
|
e[j]:=1 shl i;
|
||||||
|
fpsigprocmask(SIG_UNBLOCK,@e,nil);
|
||||||
|
reenable_signal:=geterrno=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
// signal handler is arch dependant due to processorexception to language
|
||||||
|
// exception translation
|
||||||
|
|
||||||
|
{$i sighnd.inc}
|
||||||
|
|
||||||
|
var
|
||||||
|
act: SigActionRec;
|
||||||
|
|
||||||
|
Procedure InstallSignals;
|
||||||
|
begin
|
||||||
|
{ Initialize the sigaction structure }
|
||||||
|
{ all flags and information set to zero }
|
||||||
|
FillChar(act, sizeof(SigActionRec),0);
|
||||||
|
{ initialize handler }
|
||||||
|
act.sa_handler := SigActionHandler(@SignalToRunError);
|
||||||
|
act.sa_flags:=SA_SIGINFO
|
||||||
|
{$ifdef cpux86_64}
|
||||||
|
or $4000000
|
||||||
|
{$endif cpux86_64}
|
||||||
|
;
|
||||||
|
FpSigAction(SIGFPE,@act,nil);
|
||||||
|
FpSigAction(SIGSEGV,@act,nil);
|
||||||
|
FpSigAction(SIGBUS,@act,nil);
|
||||||
|
FpSigAction(SIGILL,@act,nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SetupCmdLine;
|
||||||
|
var
|
||||||
|
bufsize,
|
||||||
|
len,j,
|
||||||
|
size,i : longint;
|
||||||
|
found : boolean;
|
||||||
|
buf : pchar;
|
||||||
|
|
||||||
|
procedure AddBuf;
|
||||||
|
begin
|
||||||
|
reallocmem(cmdline,size+bufsize);
|
||||||
|
move(buf^,cmdline[size],bufsize);
|
||||||
|
inc(size,bufsize);
|
||||||
|
bufsize:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
///-F-///
|
||||||
|
{
|
||||||
|
GetMem(buf,ARG_MAX);
|
||||||
|
size:=0;
|
||||||
|
bufsize:=0;
|
||||||
|
i:=0;
|
||||||
|
while (i<argc) do
|
||||||
|
begin
|
||||||
|
len:=strlen(argv[i]);
|
||||||
|
if len>ARG_MAX-2 then
|
||||||
|
len:=ARG_MAX-2;
|
||||||
|
found:=false;
|
||||||
|
for j:=1 to len do
|
||||||
|
if argv[i][j]=' ' then
|
||||||
|
begin
|
||||||
|
found:=true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if bufsize+len>=ARG_MAX-2 then
|
||||||
|
AddBuf;
|
||||||
|
if found then
|
||||||
|
begin
|
||||||
|
buf[bufsize]:='"';
|
||||||
|
inc(bufsize);
|
||||||
|
end;
|
||||||
|
move(argv[i]^,buf[bufsize],len);
|
||||||
|
inc(bufsize,len);
|
||||||
|
if found then
|
||||||
|
begin
|
||||||
|
buf[bufsize]:='"';
|
||||||
|
inc(bufsize);
|
||||||
|
end;
|
||||||
|
if i<argc then
|
||||||
|
buf[bufsize]:=' '
|
||||||
|
else
|
||||||
|
buf[bufsize]:=#0;
|
||||||
|
inc(bufsize);
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
AddBuf;
|
||||||
|
FreeMem(buf,ARG_MAX);
|
||||||
|
///-F-///
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure SysInitStdIO;
|
||||||
|
begin
|
||||||
|
OpenStdIO(Input,fmInput,StdInputHandle);
|
||||||
|
OpenStdIO(Output,fmOutput,StdOutputHandle);
|
||||||
|
OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
|
||||||
|
OpenStdIO(StdOut,fmOutput,StdOutputHandle);
|
||||||
|
OpenStdIO(StdErr,fmOutput,StdErrorHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure SysInitExecPath;
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
begin
|
||||||
|
execpathstr[0]:=#0;
|
||||||
|
i:=Fpreadlink('/proc/self/exe',@execpathstr[1],high(execpathstr));
|
||||||
|
{ it must also be an absolute filename, linux 2.0 points to a memory
|
||||||
|
location so this will skip that }
|
||||||
|
if (i>0) and (execpathstr[1]='/') then
|
||||||
|
execpathstr[0]:=char(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetProcessID: SizeUInt;
|
||||||
|
begin
|
||||||
|
GetProcessID := SizeUInt (fpGetPID);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Begin
|
||||||
|
///-F-/// IsConsole := TRUE;
|
||||||
|
///-F-/// IsLibrary := FALSE;
|
||||||
|
StackLength := InitialStkLen;
|
||||||
|
StackBottom := Sptr - StackLength;
|
||||||
|
{ Set up signals handlers }
|
||||||
|
InstallSignals;
|
||||||
|
{ Setup heap }
|
||||||
|
InitHeap;
|
||||||
|
SysInitExceptions;
|
||||||
|
{ Arguments }
|
||||||
|
///-F-/// SetupCmdLine;
|
||||||
|
SysInitExecPath;
|
||||||
|
{ Setup stdin, stdout and stderr }
|
||||||
|
SysInitStdIO;
|
||||||
|
{ Reset IO Error }
|
||||||
|
InOutRes:=0;
|
||||||
|
{ threading }
|
||||||
|
InitSystemThreads;
|
||||||
|
{$ifdef HASVARIANT}
|
||||||
|
///-F-/// initvariantmanager;
|
||||||
|
{$endif HASVARIANT}
|
||||||
|
{$ifdef HASWIDESTRING}
|
||||||
|
///-F-/// initwidestringmanager;
|
||||||
|
{$endif HASWIDESTRING}
|
||||||
|
End.
|
||||||
|
|
||||||
|
{
|
||||||
|
$Log: system.pp,v $
|
||||||
|
Revision 1.25 2005/04/24 21:19:22 peter
|
||||||
|
* unblock signal in signalhandler, remove the sigprocmask call
|
||||||
|
from setjmp
|
||||||
|
|
||||||
|
Revision 1.24 2005/02/14 17:13:30 peter
|
||||||
|
* truncate log
|
||||||
|
|
||||||
|
Revision 1.23 2005/02/13 21:47:56 peter
|
||||||
|
* include file cleanup part 2
|
||||||
|
|
||||||
|
Revision 1.22 2005/02/06 11:20:52 peter
|
||||||
|
* threading in system unit
|
||||||
|
* removed systhrds unit
|
||||||
|
|
||||||
|
Revision 1.21 2005/02/01 20:22:49 florian
|
||||||
|
* improved widestring infrastructure manager
|
||||||
|
|
||||||
|
}
|
1250
rtl/gba/unix.pp
Normal file
1250
rtl/gba/unix.pp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user