added devkitPSP and rearranged scripts in directories by toolchain

This commit is contained in:
Dave Murphy 2005-07-06 04:31:18 +00:00
parent 088eeca46f
commit dd066c3ac6
47 changed files with 7152 additions and 246 deletions

View File

@ -1,13 +1,13 @@
Devkit r13 build scripts
DevkitPro build scripts
--------------------------
This readme will guide you through building devkitARM or devkitPPC from source using a set of scripts.
This readme will guide you through building devkitARM, devkitPPC or devkitPSP from source using a set of scripts.
To use these scripts under minsys and MinGW you will need some additional packages over and above the base install.
The minsys developer toolkit
http://prdownloads.sf.net/mingw/msysDTK-1.0.1.exe?download
http://prdownloads.sourceforge.net/mingw/msysDTK-1.0.1.exe?download
Bison, Flex and Wget from the gnuwin32 project
@ -38,10 +38,14 @@ libogc, libgba and libnds can be found in the sourceforge project.
http://sourceforge.net/projects/devkitpro
The top level shell script has now been unified and offers the option of devkitARM or devkitPPC.
the pspsdk can be found at
Building devkitARM
------------------
http://ps2dev.org/files/pspsdk-1.0+beta.tar.gz
The top level shell script has now been unified and offers the option of devkitARM, devkitPPC or devkitPSP.
Building the devkits
--------------------
Simply run the "build-devkit.sh" script in the same directory as this text file as shown below, then follow the prompts;
@ -78,15 +82,6 @@ Getting started
The best thing to do next is test the compiler, so go to http://www.devkit.tk and download "libgba" from the downloads section and also "PCXview" from the sample code section.
Building devkitPPC
------------------
Simply run the "build-devkit.sh" script in the same directory as this text file as shown below, then follow the prompts;
./build-devkit.sh
Once the script finds the source packages they will be decompressed and the build process will begin. When its finished you have the option to delete all temporary files, sources and their source packages.
Using devkitPPC
---------------
@ -144,7 +139,7 @@ planned for release 14
* newest libogc
-------------------------------------------------------------------------------------
18th February 2005 - release 11 beta 2
18th February 2005 - devkitPPC release 11 beta 2
-------------------------------------------------------------------------------------
* patch for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9571
* updated to latest libogc
@ -171,7 +166,7 @@ planned for release 14
* updated specs file with -mogc switch for linking
-------------------------------------------------------------------------------------
12th June 2004 - release 6a
12th June 2004 - devkitARM release 6a
-------------------------------------------------------------------------------------
* long calls patch added
* -save-temps fixed (again)
@ -180,13 +175,13 @@ planned for release 14
* specs file and crt0 for gamepark gp32 libraries
-------------------------------------------------------------------------------------
8th May 2004 - release 6
8th May 2004 - devkitARM release 6
-------------------------------------------------------------------------------------
* updated to gcc 3.4.0
* reverted to binutils 2.14.0
-------------------------------------------------------------------------------------
12th April 2004 - release 5.
12th April 2004 - devkitARM release 5.
-------------------------------------------------------------------------------------
* built in crt0 and linkscript for gp32 added. Use -specs=gp32.specs when linking
* Mr Spiv's b2fxec included
@ -194,14 +189,14 @@ planned for release 14
* linux build available for download
-------------------------------------------------------------------------------------
15th March 2004 - Release 4
15th March 2004 - devkitARM Release 4
-------------------------------------------------------------------------------------
* updated to binutils 2.15.90
* more msdev error output conversion
* -save-temps fixed
-------------------------------------------------------------------------------------
26th February 2004 - Release 3a
26th February 2004 - devkitARM Release 3a
-------------------------------------------------------------------------------------
* updated to newlib 1.12.0
* crt0, linkscript and runtime library support added to DevkitARM
@ -212,14 +207,14 @@ planned for release 14
* updated to gcc 3.3.3
-------------------------------------------------------------------------------------
14th February 2004 - Release 2
14th February 2004 - devkitARM Release 2
-------------------------------------------------------------------------------------
* crt0, linkscript and runtime library support added to DevkitPPC
* adjusted error output for msdev
* Fixed minor problem with include paths
-------------------------------------------------------------------------------------
16th January 2004 - release 1
16th January 2004 - devkitARM release 1
-------------------------------------------------------------------------------------
* Initial build supporting arm target
* Required link script and crt0

View File

@ -1,6 +1,6 @@
#!/bin/sh
#---------------------------------------------------------------------------------
# Build scripts for devkitARM/devkitPPC release 12
# Build scripts for devkitARM/devkitPPC/devkitPSP
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
@ -12,6 +12,7 @@ NEWLIB_VER=1.13.0
LIBOGC_VER=20050521
LIBGBA_VER=20050615
LIBNDS_VER=20050615
PSPSDK_VER=1.0+beta
BINUTILS="binutils-$BINUTILS_VER.tar.bz2"
GCC_CORE="gcc-core-$GCC_VER.tar.bz2"
@ -20,6 +21,7 @@ NEWLIB="newlib-$NEWLIB_VER.tar.gz"
LIBOGC="libogc-src-$LIBOGC_VER.tar.bz2"
LIBGBA="libgba-src-$LIBGBA_VER.tar.bz2"
LIBNDS="libnds-src-$LIBNDS_VER.tar.bz2"
PSPSDK="pspsdk-$PSPSDK_VER.tar.gz"
BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/$BINUTILS"
GCC_CORE_URL="http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/$GCC_CORE"
@ -28,7 +30,7 @@ LIBOGC_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$LIBOGC"
LIBGBA_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$LIBGBA"
LIBNDS_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$LIBNDS"
NEWLIB_URL="ftp://sources.redhat.com/pub/newlib/$NEWLIB"
PSPSDK_URL="http://ps2dev.org/files/$PSPSDK"
#---------------------------------------------------------------------------------
# Ask whether to download the source packages or not
#---------------------------------------------------------------------------------
@ -42,9 +44,10 @@ do
echo
echo "1: build devkitARM (gba gp32 ds)"
echo "2: build devkitPPC (gamecube)"
echo "3: build devkitPSP (PSP)"
read VERSION
if [ "$VERSION" -ne 1 -a "$VERSION" -ne 2 ]
if [ "$VERSION" -ne 1 -a "$VERSION" -ne 2 -a "$VERSION" -ne 3 ]
then
VERSION=0
fi
@ -52,19 +55,32 @@ done
if [ $VERSION -eq 1 ]
then
scriptdir='./dka-scripts'
scriptdir='./dkarm/scripts'
package=devkitARM
builddir=arm-elf
target=arm-elf
toolchain=DEVKITARM
else
scriptdir='./dkp-scripts'
fi
if [ $VERSION -eq 2 ]
then
scriptdir='./dkppc/scripts'
package=devkitPPC
builddir=powerpc-gekko
target=powerpc-gekko
toolchain=DEVKITPPC
fi
if [ $VERSION -eq 3 ]
then
scriptdir='./dkpsp/scripts'
package=devkitPSP
builddir=psp
target=psp
toolchain=DEVKITPSP
fi
DOWNLOAD=0
while [ $DOWNLOAD -eq 0 ]
@ -167,6 +183,17 @@ then
fi
if [ $VERSION -eq 3 ]
then
if [ ! -f $SRCDIR/$PSPSDK ]
then
echo "Error: $PSPSDK not found in $SRCDIR"
exit
else
FOUND=1
fi
fi
done
else
@ -209,6 +236,16 @@ else
fi
fi
if [ $VERSION -eq 3 ]
then
wget -c $PSPSDK_URL
if [ ! -f $PSPSDK ]
then
echo "Error: Failed to download "$PSPSDK
exit
fi
fi
if [ $VERSION -eq 1 ]
then
wget -c $LIBNDS_URL
@ -233,6 +270,7 @@ NEWLIB_SRCDIR="newlib-$NEWLIB_VER"
LIBOGC_SRCDIR="libogc-$LIBOGC_VER"
LIBGBA_SRCDIR="libgba-$LIBGBA_VER"
LIBNDS_SRCDIR="libnds-$LIBNDS_VER"
PSPSDK_SRCDIR="pspsdk-$PSPSDK_VER"
#---------------------------------------------------------------------------------
# Add installed devkit to the path, adjusting path on minsys
@ -289,6 +327,12 @@ then
bzip2 -cd $SRCDIR/$LIBOGC | tar -xv -C $LIBOGC_SRCDIR
fi
if [ $VERSION -eq 3 ]
then
echo "Extracting $PSPSDK"
tar -xzvf $SRCDIR/$PSPSDK
fi
if [ $VERSION -eq 1 ]
then
echo "Extracting $LIBNDS"
@ -307,6 +351,12 @@ patch -p1 -d $BINUTILS_SRCDIR -i $(pwd)/patches/devkit-binutils-$BINUTILS_VER.pa
patch -p1 -d $GCC_SRCDIR -i $(pwd)/patches/devkit-gcc-$GCC_VER.patch
patch -p1 -d $NEWLIB_SRCDIR -i $(pwd)/patches/devkit-newlib-$NEWLIB_VER.patch
if [ $VERSION -eq 3 ]
then
echo
patch -p1 -d $PSPSDK_SRCDIR -i $(pwd)/patches/pspsdk-$PSPSDK_VER.patch
fi
#---------------------------------------------------------------------------------
# only necessary when Darwin gcc is 3.1 or earlier, to add a check for this here
@ -348,7 +398,7 @@ rm -fr $target
rm -fr $BINUTILS_SRCDIR
rm -fr $NEWLIB_SRCDIR
rm -fr $GCC_SRCDIR
rm -fr $LIBOGC_SRCDIR $LIBGBA_SRCDIR $LIBNDS_SRCDIR
rm -fr $LIBOGC_SRCDIR $LIBGBA_SRCDIR $LIBNDS_SRCDIR PSPSDK_SRCDIR
echo
echo "Would you like to delete the source packages? [y/N]"

11
dkarm/crtls/Makefile Normal file
View File

@ -0,0 +1,11 @@
PREFIX := arm-elf-
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
all:
$(CC) -x assembler-with-cpp -marm -c $(CRT)_crt0.s -o$(CRT)_crt0.o
$(CC) -x assembler-with-cpp -marm -mthumb-interwork -c $(CRT)_crt0.s -o interwork/$(CRT)_crt0.o
$(CC) -x assembler-with-cpp -mthumb -c $(CRT)_crt0.s -o thumb/$(CRT)_crt0.o
$(CC) -x assembler-with-cpp -mthumb -mthumb-interwork -c $(CRT)_crt0.s -o thumb/interwork/$(CRT)_crt0.o

172
dkarm/crtls/ds_arm7.ld Normal file
View File

@ -0,0 +1,172 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03800000, LENGTH = 64K
ewram : ORIGIN = 0x02040000, LENGTH = 4M
}
__iwram_start = 0x03800000;
__iwram_end = 0x03810000;
__sp_irq = __iwram_end - 0x60;
__sp_svc = __sp_irq - 0x100;
__sp_usr = __sp_svc - 0x100;
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.plt : { *(.plt) } >iwram = 0xff
.text : /* ALIGN (4): */
{
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.fini :
{
KEEP (*(.fini))
} >iwram =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.jcr : { KEEP (*(.jcr)) } >iwram = 0
.got : { *(.got.plt) *(.got) } >iwram = 0
.iwram ALIGN(4) :
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__iwram_end = . ;
.data ALIGN(4) : {
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
} >iwram = 0xff
__data_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram
__bss_end = . ;
__bss_end__ = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
%(old_link) -T ds_arm7.ld%s
*startfile:
ds_arm7_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,94 @@
@---------------------------------------------------------------------------------
.section ".init"
.global _start
@---------------------------------------------------------------------------------
.align 4
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
mov r0, #0x04000000 @ IME = 0;
add r0, r0, #0x208
strh r0, [r0]
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x13 @ Switch to SVC Mode
msr cpsr, r0
ldr sp, =__sp_svc @ Set SVC stack
mov r0, #0x1F @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
ldr r0, =__bss_start @ Clear BSS section to 0x00
ldr r1, =__bss_end
sub r1, r1, r0
bl ClearMem
ldr r3, =_init @ global constructors
bl _call_via_r3
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3 @ jump to user code
@ If the user ever returns, return to flash cartridge
mov r0, #0x08000000
bx r0
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
@---------------------------------------------------------------------------------
mov r2, #3 @ Round down to nearest word boundary
add r1, r1, r2 @ Shouldn't be needed
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
bxeq lr @ Quit if copy size is 0
mov r2, #0
ClrLoop:
stmia r0!, {r2}
subs r1, r1, #4
bne ClrLoop
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemCheck:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r3, r0 @ the length is not a multiple of 4,
bics r3, r3, r0 @ even though it should be.
bxeq lr @ Length is zero, so exit
CIDLoop:
ldmia r1!, {r0}
stmia r2!, {r0}
subs r3, r3, #4
bne CIDLoop
bx lr
@---------------------------------------------------------------------------------
.align
.pool
.end
@---------------------------------------------------------------------------------

228
dkarm/crtls/ds_arm9.ld Normal file
View File

@ -0,0 +1,228 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x037f8000, LENGTH = 32K
ewram : ORIGIN = 0x02000000, LENGTH = 4M - 4k
dtcm : ORIGIN = 0x00800000, LENGTH = 16K
itcm : ORIGIN = 0x00000000, LENGTH = 32K
}
__itcm_start = 0x00000000;
__iwram_start = 0x037f8000;
__iwram_end = 0x03800000;
__ewram_end = 0x02400000;
__eheap_end = 0x023ff000;
__dtcm_start = 0x00800000;
__dtcm_end = 0x00804000;
__sp_svc = __dtcm_end - 0x100;
__sp_irq = __sp_svc - 0x100;
__sp_usr = __sp_irq - 0x100;
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.plt : { *(.plt) } >ewram = 0xff
.text : /* ALIGN (4): */
{
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.fini :
{
KEEP (*(.fini))
} >ewram =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.jcr : { KEEP (*(.jcr)) } >ewram = 0
.got : { *(.got.plt) *(.got) } >ewram = 0
.ewram ALIGN(4) :
{
__ewram_start = ABSOLUTE(.) ;
*(.ewram)
*ewram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
__iwram_lma = . ;
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__iwram_end = . ;
__dtcm_lma = __iwram_lma + SIZEOF(.iwram);
.dtcm __dtcm_start : AT (__dtcm_lma)
{
__dtcm_start = ABSOLUTE(.);
*(.dtcm)
*(.dtcm.*)
. = ALIGN(4);
} >dtcm = 0xff
__dtcm_end = . ;
__data_lma = __dtcm_lma + SIZEOF(.dtcm) ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
} >dtcm = 0xff
__data_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >dtcm
__bss_end = . ;
__bss_end__ = . ;
__itcm_lma = __data_lma + SIZEOF(.data);
.itcm __itcm_start : AT (__itcm_lma)
{
__itcm_start = ABSOLUTE(.);
*(.itcm)
*(.itcm.*)
. = ALIGN(4);
} >itcm = 0xff
__itcm_end = . ;
__sbss_lma = __itcm_lma + SIZEOF(.itcm) ;
__appended_data = __itcm_lma + SIZEOF(.itcm) ;
.sbss __sbss_lma : AT (__sbss_lma)
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
} >ewram
__sbss_end = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
%(old_link) -T ds_arm9.ld%s
*startfile:
ds_arm9_crt0%O%s crti%O%s crtbegin%O%s

258
dkarm/crtls/ds_arm9_crt0.s Normal file
View File

@ -0,0 +1,258 @@
#define PAGE_4K (0b01011 << 1)
#define PAGE_8K (0b01100 << 1)
#define PAGE_16K (0b01101 << 1)
#define PAGE_32K (0b01110 << 1)
#define PAGE_64K (0b00111 << 1)
#define PAGE_128K (0b10000 << 1)
#define PAGE_256K (0b10001 << 1)
#define PAGE_512K (0b10010 << 1)
#define PAGE_1M (0b10011 << 1)
#define PAGE_2M (0b10100 << 1)
#define PAGE_4M (0b10101 << 1)
#define PAGE_8M (0b10110 << 1)
#define PAGE_16M (0b10111 << 1)
#define PAGE_32M (0b11000 << 1)
#define PAGE_64M (0b11001 << 1)
#define PAGE_128M (0b11010 << 1)
#define PAGE_256M (0b11011 << 1)
#define PAGE_512M (0b11100 << 1)
#define PAGE_1G (0b11101 << 1)
#define PAGE_2G (0b11110 << 1)
#define PAGE_4G (0b11111 << 1)
@---------------------------------------------------------------------------------
.section ".init"
.global _start
@---------------------------------------------------------------------------------
.align 4
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
mov r0, #0x04000000 @ IME = 0;
add r0, r0, #0x208
strh r0, [r0]
mov r1,#0 @ enable arm9 iwram
strb r1,[r0, #(0x247 - 0x208)]
ldr r1, =0x00002078 @ disable DTCM and protection unit
mcr p15, 0, r1, c1, c0
@---------------------------------------------------------------------------------
@ Protection Unit Setup added by Sasq
@---------------------------------------------------------------------------------
@ Disable cache
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 @ Instruction cache
mcr p15, 0, r0, c7, c6, 0 @ Data cache
@ Wait for write buffer to empty
mcr p15, 0, r0, c7, c10, 4
ldr r0, =0x0080000A
mcr p15, 0, r0, c9, c1 @ TCM base = 0x00800*4096, size = 16 KB
@---------------------------------------------------------------------------------
@ Setup memory regions similar to Release Version
@ this code currently breaks dualis
@---------------------------------------------------------------------------------
@-------------------------------------------------------------------------
@ Region 0 - IO registers
@-------------------------------------------------------------------------
ldr r0,=( PAGE_64M | 0x04000000 | 1)
mcr p15, 0, r0, c6, c0, 0
@-------------------------------------------------------------------------
@ Region 1 - Main Memory
@-------------------------------------------------------------------------
ldr r0,=( PAGE_4M | 0x02000000 | 1)
mcr p15, 0, r0, c6, c1, 0
@-------------------------------------------------------------------------
@ Region 2 - iwram
@-------------------------------------------------------------------------
ldr r0,=( PAGE_32K | 0x037F8000 | 1)
mcr p15, 0, r0, c6, c2, 0
@-------------------------------------------------------------------------
@ Region 3 - DS Accessory (GBA Cart)
@-------------------------------------------------------------------------
ldr r0,=( PAGE_128M | 0x08000000 | 1)
mcr p15, 0, r0, c6, c3, 0
@-------------------------------------------------------------------------
@ Region 4 - DTCM
@-------------------------------------------------------------------------
@ldr r0,=( PAGE_16K | 0x027C0000 | 1)
ldr r0,=( PAGE_16K | 0x00800000 | 1)
mcr p15, 0, r0, c6, c4, 0
@-------------------------------------------------------------------------
@ Region 5 - ITCM
@-------------------------------------------------------------------------
ldr r0,=( PAGE_32K | 0x00000000 | 1)
mcr p15, 0, r0, c6, c5, 0
@-------------------------------------------------------------------------
@ Region 6 - System ROM
@-------------------------------------------------------------------------
ldr r0,=( PAGE_32K | 0xFFFF0000 | 1)
mcr p15, 0, r0, c6, c6, 0
@-------------------------------------------------------------------------
@ Region 7 - IPC
@-------------------------------------------------------------------------
ldr r0,=( PAGE_4K | 0x027FF000 | 1)
mcr p15, 0, r0, c6, c7, 0
@-------------------------------------------------------------------------
@ Write buffer enable
@-------------------------------------------------------------------------
ldr r0,=0b00000110
mcr p15, 0, r0, c3, c0, 0
@-------------------------------------------------------------------------
@ DCache & ICache enable
@-------------------------------------------------------------------------
ldr r0,=0b01000110
ldr r0,=0x42
mcr p15, 0, r0, c2, c0, 0
mcr p15, 0, r0, c2, c0, 1
@-------------------------------------------------------------------------
@ IAccess
@-------------------------------------------------------------------------
ldr r0,=0x06606333
mcr p15, 0, r0, c5, c0, 3
@-------------------------------------------------------------------------
@ DAccess
@-------------------------------------------------------------------------
ldr r0,=0x36033333
mcr p15, 0, r0, c5, c0, 2
@-------------------------------------------------------------------------
@ Enable ICache, DCache, ITCM & DTCM
@-------------------------------------------------------------------------
mrc p15, 0, r0, c1, c0, 0
ldr r1,=0x55005
orr r0,r0,r1
mcr p15, 0, r0, c1, c0, 0
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x13 @ Switch to SVC Mode
msr cpsr, r0
ldr sp, =__sp_svc @ Set SVC stack
mov r0, #0x1F @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
ldr r1, =__data_lma @ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
ldr r2, =__data_start
ldr r4, =__data_end
bl CopyMemCheck
ldr r1, =__iwram_lma @ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
ldr r2, =__iwram_start
ldr r4, =__iwram_end
bl CopyMemCheck
ldr r1, =__itcm_lma @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
ldr r2, =__itcm_start
ldr r4, =__itcm_end
bl CopyMemCheck
ldr r1, =__dtcm_lma @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
ldr r2, =__dtcm_start
ldr r4, =__dtcm_end
bl CopyMemCheck
ldr r0, =__bss_start @ Clear BSS section
ldr r1, =__bss_end
sub r1, r1, r0
bl ClearMem
ldr r0, =__sbss_start @ Clear SBSS section
ldr r1, =__sbss_end
sub r1, r1, r0
bl ClearMem
ldr r1, =fake_heap_end @ set heap end
ldr r0, =__eheap_end
str r0, [r1]
ldr r3, =_init @ global constructors
bl _call_via_r3
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3 @ jump to user code
@ If the user ever returns, go to an infinte loop
ldr r0, =ILoop
ldr r0, [r0]
ldr r1, =0x027FFE78
str r0, [r1]
bx r1
ILoop:
b ILoop
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
@---------------------------------------------------------------------------------
mov r2, #3 @ Round down to nearest word boundary
add r1, r1, r2 @ Shouldn't be needed
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
bxeq lr @ Quit if copy size is 0
mov r2, #0
ClrLoop:
stmia r0!, {r2}
subs r1, r1, #4
bne ClrLoop
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemCheck:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r3, r0 @ the length is not a multiple of 4,
bics r3, r3, r0 @ even though it should be.
bxeq lr @ Length is zero, so exit
CIDLoop:
ldmia r1!, {r0}
stmia r2!, {r0}
subs r3, r3, #4
bne CIDLoop
bx lr
@---------------------------------------------------------------------------------
.align
.pool
.end
@---------------------------------------------------------------------------------

197
dkarm/crtls/ds_cart.ld Normal file
View File

@ -0,0 +1,197 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03800000, LENGTH = 64K
ewram : ORIGIN = 0x02000000, LENGTH = 4M
}
__iwram_start = 0x03800000;
__ewram_start = 0x02000000;
__eheap_end = 0x02040000;
__sp_irq = 0x03810000 - 0x60;
__sp_svc = __sp_irq - 0x100;
__sp_usr = __sp_svc - 0x100;
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.plt : { *(.plt) } >rom = 0xff
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*text.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.fini :
{
KEEP (*(.fini))
} >rom =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.jcr : { KEEP (*(.jcr)) } >rom = 0
.got : { *(.got.plt) *(.got) } >rom = 0
__ewram_lma = . ;
.ewram __ewram_start : AT (__ewram_lma)
{
__ewram_start = ABSOLUTE(.) ;
*(.ewram)
*ewram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.sbss ALIGN(4):
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
} >ewram
__sbss_end = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
__iwram_lma = __ewram_lma + SIZEOF(.ewram) + SIZEOF(.sbss);
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__iwram_end = . ;
__data_lma = __iwram_lma + SIZEOF(.iwram) ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
} >iwram = 0xff
__data_end = . ;
__appended_data = __data_lma + SIZEOF(.data) ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram
__bss_end = . ;
__bss_end__ = . ;
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
%(old_link) -T ds_cart.ld%s
*startfile:
ds_cart_crt0%O%s crti%O%s crtbegin%O%s

161
dkarm/crtls/ds_cart_crt0.s Normal file
View File

@ -0,0 +1,161 @@
@---------------------------------------------------------------------------------
.section ".init"
.global _start
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b rom_header_end
@---------------------------------------------------------------------------------
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
.fill 16,1,0 @ Game Title
.byte 0x30,0x31 @ Maker Code (80000B0h)
.byte 0x96 @ Fixed Value (80000B2h)
.byte 0x00 @ Main Unit Code (80000B3h)
.byte 0x00 @ Device Type (80000B4h)
.fill 7,1,0 @ unused
.byte 0x00 @ Software Version No (80000BCh)
.byte 0xf0 @ Complement Check (80000BDh)
.byte 0x00,0x00 @ Checksum (80000BEh)
rom_header_end:
b start_vector @ This branch must be here for proper
@ positioning of the following header.
.GLOBAL __boot_method, __slave_number
__boot_method:
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
__slave_number:
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
.byte 0 @ reserved
.byte 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
@---------------------------------------------------------------------------------
.align 4
.arm
@---------------------------------------------------------------------------------
start_vector:
@---------------------------------------------------------------------------------
mov r0, #0x04000000 @ IME = 0;
add r0, r0, #0x208
strh r0, [r0]
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x13 @ Switch to SVC Mode
msr cpsr, r0
ldr sp, =__sp_svc @ Set SVC stack
mov r0, #0x1F @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
mov r1, #0x42
strb r1, [r7], #1
mov r1, #0x35
strb r1, [r7], #1
mov r1, #0x2B
strb r1, [r7], #1
mov r1, #0x2B
strb r1, [r7], #1
ldr r1, =__data_lma @ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
ldr r2, =__data_start
ldr r4, =__data_end
bl CopyMemChk
ldr r1, =__iwram_lma @ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
ldr r2, =__iwram_start
ldr r4, =__iwram_end
bl CopyMemChk
ldr r0, =__bss_start @ Clear BSS section to 0x00
ldr r1, =__bss_end
sub r1, r1, r0
bl ClearMem
ldr r0, =__sbss_start @ Clear SBSS section to 0x00
ldr r1, =__sbss_end
sub r1, r1, r0
bl ClearMem
ldr r1, =fake_heap_end @ set heap end
ldr r0, =__eheap_end
str r0, [r1]
ldr r3, =_init @ global constructors
bl _call_via_r3
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3 @ jump to user code
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
mov r2, #3 @ Round down to nearest word boundary
add r1, r1, r2 @ Shouldn't be needed
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
bxeq lr @ Quit if copy size is 0
mov r2, #0
@---------------------------------------------------------------------------------
ClrLoop:
@---------------------------------------------------------------------------------
stmia r0!, {r2}
subs r1, r1, #4
bne ClrLoop
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemChk:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r3, r0 @ the length is not a multiple of 4,
bics r3, r3, r0 @ even though it should be.
bxeq lr @ Length is zero so exit
@---------------------------------------------------------------------------------
CIDLoop:
@---------------------------------------------------------------------------------
ldmia r1!, {r0}
stmia r2!, {r0}
subs r3, r3, #4
bne CIDLoop
bx lr
@---------------------------------------------------------------------------------
.align
.pool
@---------------------------------------------------------------------------------
.end
@---------------------------------------------------------------------------------

56
dkarm/crtls/er_crt0.s Normal file
View File

@ -0,0 +1,56 @@
@---------------------------------------------------------------------------------
@ nintendo e-reader startup code
@---------------------------------------------------------------------------------
@ author : tim schuerewegen
@ version : 1.0
@---------------------------------------------------------------------------------
.section ".init"
.global _start
.align
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b start_vector
.long 0
.long 0x02000000
start_vector:
@ enter thumb mode
adr r0, _start_thumb + 1
bx r0
.thumb
_start_thumb:
@ save return address (rom)
mov r3, lr
@ clear bss section
ldr r0, =__bss_start
ldr r1, =__bss_end
mov r2, #0
_loop_bss_clear:
strb r2, [r0]
add r0, #1
cmp r0, r1
blt _loop_bss_clear
@ set return address (rom)
mov lr, r3
@ jump to main
ldr r3, =main
bx r3
.align
.pool
.end
.align
.pool
.end

8
dkarm/crtls/gba.specs Normal file
View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
%(old_link) -T gba_cart.ld%s
*startfile:
gba_crt0%O%s crti%O%s crtbegin%O%s

298
dkarm/crtls/gba_cart.ld Normal file
View File

@ -0,0 +1,298 @@
/* Linker Script Original v1.3 by Jeff Frohwein */
/* v1.0 - Original release */
/* v1.1 - Added proper .data section support */
/* v1.2 - Added support for c++ & iwram overlays */
/* - Major contributions by Jason Wilkins. */
/* v1.3 - .ewram section now can be used when */
/* compiling for MULTIBOOT mode. This fixes */
/* malloc() in DevKitAdvance which depends */
/* on __eheap_start instead of end to define*/
/* the starting location of heap space. */
/* External global variable __gba_iwram_heap*/
/* support added to allow labels end, _end, */
/* & __end__ to point to end of iwram or */
/* the end of ewram. */
/* Additions by WinterMute */
/* v1.4 - .sbss section added for unitialised */
/* data in ewram */
/* v1.5 - padding section added to stop EZF */
/* stripping important data */
/* This file is released into the public domain */
/* for commercial or non-commercial use with no */
/* restrictions placed upon it. */
/* NOTE!!!: This linker script defines the RAM & */
/* ROM start addresses. In order for it to work */
/* properly, remove -Ttext and -Tbss linker */
/* options from your makefile if they are */
/* present. */
/* You can use the following to view section */
/* addresses in your .elf file: */
/* objdump -h file.elf */
/* Please note that empty sections may incorrectly*/
/* list the lma address as the vma address for */
/* some versions of objdump. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
/* SEARCH_DIR(/bin/arm); */
/* The linker script function "var1 += var2;" sometimes */
/* reports incorrect values in the *.map file but the */
/* actual value it calculates is usually, if not always, */
/* correct. If you leave out the ". = ALIGN(4);" at the */
/* end of each section then the return value of SIZEOF() */
/* is sometimes incorrect and "var1 += var2;" appears to */
/* not work as well. "var1 += var2" style functions are */
/* avoided below as a result. */
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03000000, LENGTH = 32K
ewram : ORIGIN = 0x02000000, LENGTH = 256K
}
__text_start = 0x8000000;
__eheap_end = 0x2040000;
__iwram_start = 0x3000000;
__iwram_end = 0x3008000;
__sp_irq = __iwram_end - 0x100;
__sp_usr = __sp_irq - 0x100;
SECTIONS
{
. = __text_start;
.init :
{
KEEP (*(.init))
. = ALIGN(4);
} >rom =0xff
.plt :
{
*(.plt)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
__text_end = .;
.fini :
{
KEEP (*(.fini))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom =0
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
.jcr : { KEEP (*(.jcr)) } >rom
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
__iwram_lma = .;
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__data_lma = __iwram_lma + SIZEOF(.iwram) ;
__iwram_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram
__bss_end = . ;
__bss_end__ = . ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
} >iwram = 0xff
__iwram_overlay_lma = __data_lma + SIZEOF(.data);
__data_end = .;
__iwram_overlay_start = . ;
OVERLAY ALIGN(4) : NOCROSSREFS AT (__iwram_overlay_lma)
{
.iwram0 { *(.iwram0) . = ALIGN(4);}
.iwram1 { *(.iwram1) . = ALIGN(4);}
.iwram2 { *(.iwram2) . = ALIGN(4);}
.iwram3 { *(.iwram3) . = ALIGN(4);}
.iwram4 { *(.iwram4) . = ALIGN(4);}
.iwram5 { *(.iwram5) . = ALIGN(4);}
.iwram6 { *(.iwram6) . = ALIGN(4);}
.iwram7 { *(.iwram7) . = ALIGN(4);}
.iwram8 { *(.iwram8) . = ALIGN(4);}
.iwram9 { *(.iwram9) . = ALIGN(4);}
}>iwram = 0xff
__ewram_lma = LOADADDR(.iwram0) + SIZEOF(.iwram0)+SIZEOF(.iwram1)+SIZEOF(.iwram2)+SIZEOF(.iwram3)+SIZEOF(.iwram4)+SIZEOF(.iwram5)+SIZEOF(.iwram6)+SIZEOF(.iwram7)+SIZEOF(.iwram8)+SIZEOF(.iwram9);
__iwram_overlay_end = . ;
__iheap_start = . ;
__ewram_start = 0x2000000;
.ewram __ewram_start : AT (__ewram_lma)
{
*(.ewram)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
}>ewram = 0xff
__ewram_overlay_lma = __ewram_lma + SIZEOF(.ewram);
.sbss ALIGN(4):
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
} >ewram
__sbss_end = .;
__ewram_end = . ;
__ewram_overlay_start = . ;
OVERLAY ALIGN(4): NOCROSSREFS AT (__ewram_overlay_lma)
{
.ewram0 { *(.ewram0) . = ALIGN(4);}
.ewram1 { *(.ewram1) . = ALIGN(4);}
.ewram2 { *(.ewram2) . = ALIGN(4);}
.ewram3 { *(.ewram3) . = ALIGN(4);}
.ewram4 { *(.ewram4) . = ALIGN(4);}
.ewram5 { *(.ewram5) . = ALIGN(4);}
.ewram6 { *(.ewram6) . = ALIGN(4);}
.ewram7 { *(.ewram7) . = ALIGN(4);}
.ewram8 { *(.ewram8) . = ALIGN(4);}
.ewram9 { *(.ewram9) . = ALIGN(4);}
}>ewram = 0xff
__pad_lma = LOADADDR(.ewram0) + SIZEOF(.ewram0)+SIZEOF(.ewram1)+SIZEOF(.ewram2)+SIZEOF(.ewram3)+SIZEOF(.ewram4)+SIZEOF(.ewram5)+SIZEOF(.ewram6)+SIZEOF(.ewram7)+SIZEOF(.ewram8)+SIZEOF(.ewram9);
/* EZF Advance strips trailing 0xff bytes, add a pad section so nothing important is removed */
.pad ALIGN(4) : AT (__pad_lma)
{
LONG(0x52416b64)
LONG(0x4d)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} = 0xff
__ewram_overlay_end = . ;
__eheap_start = . ;
_end = .;
__end__ = _end ; /* v1.3 */
PROVIDE (end = _end); /* v1.3 */
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

248
dkarm/crtls/gba_crt0.s Normal file
View File

@ -0,0 +1,248 @@
.section ".init"
.global _start
.align
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b rom_header_end
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
.fill 16,1,0 @ Game Title
.byte 0x30,0x31 @ Maker Code (80000B0h)
.byte 0x96 @ Fixed Value (80000B2h)
.byte 0x00 @ Main Unit Code (80000B3h)
.byte 0x00 @ Device Type (80000B4h)
.fill 7,1,0 @ unused
.byte 0x00 @ Software Version No (80000BCh)
.byte 0xf0 @ Complement Check (80000BDh)
.byte 0x00,0x00 @ Checksum (80000BEh)
@---------------------------------------------------------------------------------
rom_header_end:
@---------------------------------------------------------------------------------
b start_vector @ This branch must be here for proper
@ positioning of the following header.
.GLOBAL __boot_method, __slave_number
@---------------------------------------------------------------------------------
__boot_method:
@---------------------------------------------------------------------------------
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
@---------------------------------------------------------------------------------
__slave_number:
@---------------------------------------------------------------------------------
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
.byte 0 @ reserved
.byte 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.global start_vector
.align
@---------------------------------------------------------------------------------
start_vector:
@---------------------------------------------------------------------------------
mov r0, #0x4000000 @ REG_BASE
add r0, r0, #0x208 @ REG_IME
strh r0, [r0]
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x1f @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
@---------------------------------------------------------------------------------
@ Enter Thumb mode
@---------------------------------------------------------------------------------
add r0, pc, #1
bx r0
.thumb
ldr r0, =__text_start
lsl r0, #5 @ Was code compiled at 0x08000000 or higher?
bcs DoEWRAMClear @ yes, you can not run it in external WRAM
mov r0, pc
lsl r0, #5 @ Are we running from ROM (0x8000000 or higher) ?
bcc SkipEWRAMClear @ No, so no need to do a copy.
@---------------------------------------------------------------------------------
@ We were started in ROM, silly emulators. :P
@ So we need to copy to ExWRAM.
@---------------------------------------------------------------------------------
mov r3, #0x40
lsl r3, #12 @ r3 = 0x40000
lsl r2, r3, #7 @ r2 = 0x2000000
mov r6, r2 @ r6 = 0x2000000
lsl r1, r2, #2 @ r1 = 0x8000000
bl CopyMem
bx r6 @ Jump to the code to execute
@---------------------------------------------------------------------------------
DoEWRAMClear: @ Clear External WRAM to 0x00
@---------------------------------------------------------------------------------
mov r1, #0x40
lsl r1, #12 @ r1 = 0x40000
lsl r0, r1, #7 @ r0 = 0x2000000
bl ClearMem
@---------------------------------------------------------------------------------
SkipEWRAMClear: @ Clear Internal WRAM to 0x00
@---------------------------------------------------------------------------------
mov r0, #3
lsl r0, #24 @ r0 = 0x3000000
ldr r1, =__iwram_end
sub r1,r0
bl ClearMem
@---------------------------------------------------------------------------------
@ Clear SBSS section to 0x00
@---------------------------------------------------------------------------------
ldr r0, =__sbss_start
ldr r1, =__sbss_end
sub r1, r0
bl ClearMem
@---------------------------------------------------------------------------------
@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r1, =__data_lma
ldr r2, =__data_start
ldr r4, =__data_end
bl CopyMemChk
@---------------------------------------------------------------------------------
@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r1,= __iwram_lma
ldr r2,= __iwram_start
ldr r4,= __iwram_end
bl CopyMemChk
@---------------------------------------------------------------------------------
@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r2,= __load_stop_iwram0
ldr r1,= __load_start_iwram0
sub r3, r2, r1 @ Is there any data to copy?
beq CIW0Skip @ no
ldr r2,= __iwram_overlay_start
bl CopyMem
@---------------------------------------------------------------------------------
CIW0Skip:
@---------------------------------------------------------------------------------
@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r1, =__ewram_lma
ldr r2, =__ewram_start
ldr r4, =__ewram_end
bl CopyMemChk
@---------------------------------------------------------------------------------
@ Copy external work ram overlay 0 (ewram0 section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r2, =__load_stop_ewram0
ldr r1, =__load_start_ewram0
sub r3, r2, r1 @ Is there any data to copy?
beq CEW0Skip @ no
ldr r2, =__ewram_overlay_start
bl CopyMem
@---------------------------------------------------------------------------------
CEW0Skip:
@---------------------------------------------------------------------------------
@ set heap end
@---------------------------------------------------------------------------------
ldr r1, =fake_heap_end
ldr r0, =__eheap_end
str r0, [r1]
@---------------------------------------------------------------------------------
@ global constructors
@---------------------------------------------------------------------------------
ldr r3, =_init
bl _call_via_r3
@---------------------------------------------------------------------------------
@ Jump to user code
@---------------------------------------------------------------------------------
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@---------------------------------------------------------------------------------
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
@---------------------------------------------------------------------------------
mov r2,#3 @ These commands are used in cases where
add r1,r2 @ the length is not a multiple of 4,
bic r1,r2 @ even though it should be.
beq ClearMX @ Length is zero so exit
mov r2,#0
@---------------------------------------------------------------------------------
ClrLoop:
@---------------------------------------------------------------------------------
stmia r0!, {r2}
sub r1,#4
bne ClrLoop
@---------------------------------------------------------------------------------
ClearMX:
@---------------------------------------------------------------------------------
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@---------------------------------------------------------------------------------
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemChk:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@---------------------------------------------------------------------------------
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r0 @ the length is not a multiple of 4,
bic r3, r0 @ even though it should be.
beq CIDExit @ Length is zero so exit
@---------------------------------------------------------------------------------
CIDLoop:
@---------------------------------------------------------------------------------
ldmia r1!, {r0}
stmia r2!, {r0}
sub r3, #4
bne CIDLoop
@---------------------------------------------------------------------------------
CIDExit:
@---------------------------------------------------------------------------------
bx lr
.align
.pool
.end

50
dkarm/crtls/gba_er.ld Normal file
View File

@ -0,0 +1,50 @@
/***********************************/
/* NINTENDO E-READER LINKER SCRIPT */
/***********************************/
/* Author : Tim Schuerewegen */
/* Version : 1.0 */
/***********************************/
OUTPUT_FORMAT( "elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH( arm)
ENTRY( _start)
SECTIONS
{
. = 0x02000000;
.init :
{
*(.init)
. = ALIGN(4);
} = 0xff
.text :
{
*(.text)
. = ALIGN(4);
} = 0xff
.rodata :
{
*(.rodata)
. = ALIGN(4);
} = 0xff
.data :
{
*(.data)
. = ALIGN(4);
} = 0xff
.bss :
{
__bss_start = .;
*(.bss)
. = ALIGN(4);
}
__bss_end = .;
__end = .;
}

8
dkarm/crtls/gba_er.specs Normal file
View File

@ -0,0 +1,8 @@
%rename link old_link
%rename endfile old_endfile
*link:
-T gba_er.ld%s %(old_link)
*startfile:
er_crt0%O%s

284
dkarm/crtls/gba_mb.ld Normal file
View File

@ -0,0 +1,284 @@
/* Linker Script Original v1.3 by Jeff Frohwein */
/* v1.0 - Original release */
/* v1.1 - Added proper .data section support */
/* v1.2 - Added support for c++ & iwram overlays */
/* - Major contributions by Jason Wilkins. */
/* v1.3 - .ewram section now can be used when */
/* compiling for MULTIBOOT mode. This fixes */
/* malloc() in DevKitAdvance which depends */
/* on __eheap_start instead of end to define*/
/* the starting location of heap space. */
/* External global variable __gba_iwram_heap*/
/* support added to allow labels end, _end, */
/* & __end__ to point to end of iwram or */
/* the end of ewram. */
/* Additions by WinterMute */
/* v1.4 - .sbss section added for unitialised */
/* data in ewram */
/* v1.5 - padding section added to stop EZF */
/* stripping important data */
/* v1.6 - added memory sections */
/* This file is released into the public domain */
/* for commercial or non-commercial use with no */
/* restrictions placed upon it. */
/* NOTE!!!: This linker script defines the RAM & */
/* ROM start addresses. In order for it to work */
/* properly, remove -Ttext and -Tbss linker */
/* options from your makefile if they are */
/* present. */
/* You can use the following to view section */
/* addresses in your .elf file: */
/* objdump -h file.elf */
/* Please note that empty sections may incorrectly*/
/* list the lma address as the vma address for */
/* some versions of objdump. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03000000, LENGTH = 32K
ewram : ORIGIN = 0x02000000, LENGTH = 256K
}
__text_start = 0x2000000 ;
__eheap_end = 0x2040000;
__iwram_start = 0x3000000;
__iwram_end = 0x3008000;
__sp_irq = __iwram_end - 0x100;
__sp_usr = __sp_irq - 0x100;
SECTIONS
{
. = __text_start;
.init :
{
KEEP (*(.init))
. = ALIGN(4);
} >ewram =0xff
.plt :
{
*(.plt)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram
.text ALIGN (4):
{
*(EXCLUDE_FILE (*.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
__text_end = .;
.fini :
{
KEEP (*(.fini))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram =0
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
.jcr : { KEEP (*(.jcr)) } >ewram
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
__iwram_lma = .;
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__data_lma = __iwram_lma + SIZEOF(.iwram) ;
__iwram_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
}
__bss_end = . ;
__bss_end__ = . ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__iwram_overlay_lma = __data_lma + SIZEOF(.data);
__data_end = .;
PROVIDE (edata = .);
__iwram_overlay_start = . ;
OVERLAY ALIGN(4) : NOCROSSREFS AT (__iwram_overlay_lma)
{
.iwram0 { *(.iwram0) . = ALIGN(4);}
.iwram1 { *(.iwram1) . = ALIGN(4);}
.iwram2 { *(.iwram2) . = ALIGN(4);}
.iwram3 { *(.iwram3) . = ALIGN(4);}
.iwram4 { *(.iwram4) . = ALIGN(4);}
.iwram5 { *(.iwram5) . = ALIGN(4);}
.iwram6 { *(.iwram6) . = ALIGN(4);}
.iwram7 { *(.iwram7) . = ALIGN(4);}
.iwram8 { *(.iwram8) . = ALIGN(4);}
.iwram9 { *(.iwram9) . = ALIGN(4);}
} >iwram = 0xff
__ewram_lma = LOADADDR(.iwram0) + SIZEOF(.iwram0)+SIZEOF(.iwram1)+SIZEOF(.iwram2)+SIZEOF(.iwram3)+SIZEOF(.iwram4)+SIZEOF(.iwram5)+SIZEOF(.iwram6)+SIZEOF(.iwram7)+SIZEOF(.iwram8)+SIZEOF(.iwram9);
__iwram_overlay_end = . ;
__iheap_start = . ;
/* v1.3 */
__ewram_start = __ewram_lma ;
.ewram __ewram_start : AT (__ewram_lma)
{
*(.ewram)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
__ewram_overlay_lma = __ewram_lma + SIZEOF(.ewram);
.sbss ALIGN(4):
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
}
__sbss_end = .;
__ewram_end = . ;
__ewram_overlay_start = . ;
OVERLAY ALIGN(4): NOCROSSREFS AT (__ewram_overlay_lma)
{
.ewram0 { *(.ewram0) . = ALIGN(4);}
.ewram1 { *(.ewram1) . = ALIGN(4);}
.ewram2 { *(.ewram2) . = ALIGN(4);}
.ewram3 { *(.ewram3) . = ALIGN(4);}
.ewram4 { *(.ewram4) . = ALIGN(4);}
.ewram5 { *(.ewram5) . = ALIGN(4);}
.ewram6 { *(.ewram6) . = ALIGN(4);}
.ewram7 { *(.ewram7) . = ALIGN(4);}
.ewram8 { *(.ewram8) . = ALIGN(4);}
.ewram9 { *(.ewram9) . = ALIGN(4);}
} >ewram = 0xff
__ewram_overlay_end = . ;
__eheap_start = . ;
_end = .;
__end__ = _end ; /* v1.3 */
PROVIDE (end = _end); /* v1.3 */
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

8
dkarm/crtls/gba_mb.specs Normal file
View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
-T gba_mb.ld%s %(old_link)
*startfile:
gba_crt0%O%s crti%O%s crtbegin%O%s

152
dkarm/crtls/gp32.ld Normal file
View File

@ -0,0 +1,152 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY
{
ram : ORIGIN = 0xc000000, LENGTH = 8M
}
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
.plt : { *(.plt) } >ram = 0xff
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*text.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
.fini :
{
KEEP (*(.fini))
} >ram =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.jcr : { KEEP (*(.jcr)) } >ram = 0
.got : { *(.got.plt) *(.got) } >ram = 0
__ro_end = . ;
.data ALIGN(4) :
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
__data_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
/* __bss_start__ = ABSOLUTE(.); */
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} > ram
__bss_end = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

8
dkarm/crtls/gp32.specs Normal file
View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
%(old_link) -T gp32.ld%s
*startfile:
gp32_crt0%O%s crti%O%s crtbegin%O%s

74
dkarm/crtls/gp32_crt0.s Normal file
View File

@ -0,0 +1,74 @@
.section ".init"
.code 32
.align
.global _start
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b _start2
@---------------------------------------------------------------------------------
@ AXF addresses
@---------------------------------------------------------------------------------
_text_start:
.word __text_start
_ro_end:
.word __ro_end
_data_start:
.word __data_start
.word __bss_end
_bss_start:
.word __bss_start
_bss_end:
.word __bss_end
@---------------------------------------------------------------------------------
@ GamePark magic sequence
@---------------------------------------------------------------------------------
.word 0x44450011
.word 0x44450011
.word 0x01234567
.word 0x12345678
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
@---------------------------------------------------------------------------------
_start2:
@---------------------------------------------------------------------------------
mrs r0, CPSR
orr r0, r0, #0xC0
msr CPSR_ctl, r0
mrs r0, CPSR
bic r0, r0, #0xC0
orr r0, r0, #0x40
msr CPSR_ctl,r0
@---------------------------------------------------------------------------------
@ global constructors
@---------------------------------------------------------------------------------
ldr r3,=_call_main
mov lr,r3
ldr r3,=_init
bx r3
@---------------------------------------------------------------------------------
@ Jump to user code
@---------------------------------------------------------------------------------
_call_main:
@---------------------------------------------------------------------------------
mov lr, #0
ldr r3, =main
bx r3
.pool
.end

197
dkarm/crtls/gp32_gpsdk.ld Normal file
View File

@ -0,0 +1,197 @@
/* GP32 Linker Script v1.2 by Jeff F */
/* v1.0 - Original release */
/* v1.1 - Cleaned up and added MEMORY command */
/* v1.2 - DJWillis - Added propper .init and */
/* .fini for GCC 3.3.2 and above */
/* */
/* This file is released into the public domain */
/* for commercial or non-commercial use with no */
/* restrictions placed upon it. */
/* */
/* NOTE!!!: This linker script defines the RAM */
/* start addresses. In order for it to work */
/* properly, remove -Ttext and -Tbss linker */
/* options from your makefile if they are */
/* present. */
/* */
/* You can use the following to view section */
/* addresses in your .elf file: */
/* objdump -h file.elf */
/* */
/* Please note that empty sections may incorrectly*/
/* list the lma address as the vma address for */
/* some versions of objdump. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
/* SEARCH_DIR(/bin/arm); */
/* Then use it like this: IWRAMHEAP */
/* The linker script function "var1 += var2;" sometimes */
/* reports incorrect values in the *.map file but the */
/* actual value it calculates is usually, if not always, */
/* correct. If you leave out the ". = ALIGN(4);" at the */
/* end of each section then the return value of SIZEOF() */
/* is sometimes incorrect and "var1 += var2;" appears to */
/* not work as well. "var1 += var2" style functions are */
/* avoided below as a result. */
/* The linker script MEMORY directive is not used here due */
/* to the fact that __text_start is not always a fixed value. */
MEMORY
{
ram : ORIGIN = 0xc000000, LENGTH = 8M
}
SECTIONS
{
.text : /* ALIGN (4): */
{
__text_start = . ;
*(EXCLUDE_FILE (*text.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
__text_end = . ;
.init :
{
*(.init)
} > ram = 0xff
.jcr :
{
*(.jcr)
} > ram = 0xff
.fini :
{
*(.fini)
} > ram = 0xff
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
.ctors :
{
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
__ro_end = . ;
.data ALIGN(4) :
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
__data_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
/* __bss_start__ = ABSOLUTE(.); */
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} > ram
__bss_end = . ;
__eheap_start = . ; /* Needed by DevKitAdvance. Start of malloc() heap for DKA. */
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
__eheap_end = . ;
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,8 @@
%rename link old_link
*link:
%(old_link) -T gp32_gpsdk.ld%s
*startfile:
gp32_gpsdk_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,246 @@
@****************************************************
@* gp32 crt0.S v1.0 by Jeff F *
@****************************************************
@ v1.0 - Original release
@
@ This file is released into the public domain for commercial
@ or non-commercial usage with no restrictions placed upon it.
.TEXT
@ Note: Normally it is the job of crt0.S to clear the BSS
@ (Zero Initialized) section to 0x00, but in the case of
@ the gp32 we do not have to do this because it is done
@ by the gp32 bios after it loads the app.
@ The official sdt dev kit uses 'Main ()' as the entry
@ point. If you would rather use 'main ()' instead then
@ comment out the next line.
@
@ You have to use 'main ()' at some point in your program
@ if you want to do c++ code. GCC will do a call to constructor
@ setup before executing 'main ()'. Using 'main ()' also increases
@ your program size by ~5500 bytes.
@ .equ __OfficialEntry, 1
@ The official sdt dev kit initializes various things in init.o
@ Crt0.S performs similar tasks for compatibility. If you don't
@ wish to use the official libs, or those that are compatible,
@ then you need to comment out the next line to prevent link errors.
.equ __OfficialInits, 1
.GLOBAL _start
_start:
.ALIGN
.CODE 32
@ Start Vector
b _GpInit
.word __text_start @ Start of text (Read Only) section
_roe: .word __ro_end @ End "
_rws: .word __data_start @ Start of data (Read/Write) section
.word __bss_end @ End of bss (this is the way sdt does it for some reason)
_zis: .word __bss_start @ Start of bss (Zero Initialized) section
_zie: .word __bss_end @ End "
.word 0x44450011
.word 0x44450011
.word 0x01234567
.word 0x12345678
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
_GpInit:
mrs r0,CPSR
orr r0,r0,#0xc0
msr CPSR_fsxc,r0
.ifdef __OfficialInits
@ Call function in user_init.s
@ bl asm_user_entry
@ Get pointer to GpSurfaceSet routine
mov r0,#0
swi 0xb
ldr r1,=GpSurfaceSet
ldr r2,=GpSurfaceFlip
str r0,[r1]
str r0,[r2]
@ Get time passed
mov r0,#6
swi 0xb
ldr r1,=_timepassed
str r0,[r1]
@ Get button stuff
mov r0,#0
swi 0x10
ldr r2,=_reg_io_key_a
ldr r3,=_reg_io_key_b
str r0,[r2]
str r1,[r3]
@ Set heap start location
ldr r0,_zie
ldr r1,=HEAPSTART
str r0,[r1]
@ Set heap end location
mov r0,#5
swi 0xb
ldr r1,=HEAPEND
sub r0,r0,#255
bic r0,r0,#3
str r0,[r1]
@ Set App Argument
swi 0x15
mov r10,r0
mov r11,r1 @ possibly not needed but left in anyway
mrs r0,CPSR
bic r0,r0,#192
orr r0,r0,#64
msr CPSR_fsxc,r0
mov r0,r10
mov r1,r11 @ possibly not needed but left in anyway
.endif
@ Jump to Main ()
.ifdef __OfficialEntry
ldr r3,=Main
.else
ldr r3,=main
.endif
bx r3 @ Init.o uses 'mov pc,r3' but
@ 'bx r3' is used here instead. This way
@ the main function can be ARM or Thumb.
.ifdef __OfficialInits
swi 0x12
orr r1,r1,r2
and r1,r1,r3
eor r1,r1,r4
mov r5,r1,lsr #4
add r1,r1,r7
sub r7,r7,r1
mov r8,#0
mov pc,r8
b .
b .
b .
b .
b .
b .
b .
b .
b .
b .
b .
b .
nop
nop
nop
nop
nop
nop
.GLOBAL _fw_init_for_dbg
_fw_init_for_dbg:
stmdb sp!,{r0-r12}
mov r10,lr
mov r11,sp
bic r0,r0,#31 @ 0x1f
orr r1,r0,#17 @ 0x11
orr r2,r0,#19 @ 0x13
msr cpsr_cxsf,r1
mov r12,#4
add r12,r12,pc
msr cpsr_cxsf,r2
swi 0x1ff
@ bl asm_user_entry_path
mov r0,r11
mov r1,r10
add r0,r0,#52
ldr r2,[r0]
mov lr,r1
stmdb sp!,{r2}
stmdb sp!,{r0-r12,lr}
@ Copy RW Base - ZI Base
ldr r0,=_roe @ |Image$$RO$$Limit|
ldr r3,=_zis @ |Image$$ZI$$Base|
ldr r2,=_rws @ |Image$$RW$$Base|
sub r3,r3,r2
CopyRWData:
cmp r3,#36
blt CopyRWData2
ldmia r0!,{r4-r12}
stmia r2!,{r4-r12}
sub r3,r3,#36
b CopyRWData
CopyRWData2:
cmp r3,#0
ble CopyRWData3
ldr r4,[r0],#4
str r4,[r2],#4
sub r3,r3,#4
b CopyRWData2
CopyRWData3:
@ Clear ZI section
ldr r1,=_zie @ |Image$$ZI$$Limit|
ldr r0,=_zis @ |Image$$ZI$$Base|
mov r2,#0
mov r3,r2
mov r4,r2
mov r5,r2
mov r6,r2
mov r7,r2
mov r8,r2
mov r9,r2
mov r10,r2
mov r11,r2
mov r12,r2
CopyZIData:
stmia r0!,{r2-r12}
cmp r0,r1
blt CopyZIData
ldmia sp!,{r0-r12,pc}
.endif
.ALIGN
.POOL
.END

58
dkarm/rules/base_rules Normal file
View File

@ -0,0 +1,58 @@
#---------------------------------------------------------------------------------
# path to tools - this can be deleted if you set the path in windows
#---------------------------------------------------------------------------------
export PATH := $(DEVKITARM)/bin:$(PATH)
#---------------------------------------------------------------------------------
# the prefix on the compiler executables
#---------------------------------------------------------------------------------
PREFIX := arm-elf-
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
@echo $(notdir $@)
@$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.o: %.cpp
@echo $(notdir $<)
@$(CXX) -MMD -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.c
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.s
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.S
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
padbin 4 $(<)
$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--rename-section .data=.rodata,readonly,data,contents,alloc \
--redefine-sym _binary_`(echo $(<) | sed -e 's/^\/\([a-zA-Z]\/\)/\1_/' | tr . _ | tr / _)`_start=`(echo $(<F) | tr . _)`\
--redefine-sym _binary_`(echo $(<) | sed -e 's/^\/\([a-zA-Z]\/\)/\1_/' | tr . _ | tr / _)`_end=`(echo $(<F) | tr . _)`_end\
--redefine-sym _binary_`(echo $(<) | sed -e 's/^\/\([a-zA-Z]\/\)/\1_/' | tr . _ | tr / _)`_size=`(echo $(<F) | tr . _)`_size\
$(<) $(@)
echo "extern const u32" `(echo $(<F) | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
echo "extern const u8" `(echo $(<F) | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
echo "extern const u32" `(echo $(<F) | tr . _)`_size[]";" >> `(echo $(<F) | tr . _)`.h
endef

23
dkarm/rules/ds_rules Normal file
View File

@ -0,0 +1,23 @@
-include $(DEVKITARM)/base_rules
LIBNDS := $(DEVKITPRO)/libnds
#---------------------------------------------------------------------------------
%.ds.gba: %.nds
@dsbuild $<
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.nds: %.bin
@ndstool -c $@ -9 $<
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.bin: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.elf:
@echo linking binary
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@

19
dkarm/rules/gba_rules Normal file
View File

@ -0,0 +1,19 @@
-include $(DEVKITARM)/base_rules
LIBGBA := $(DEVKITPRO)/libgba
#---------------------------------------------------------------------------------
%.gba: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
@gbafix $@
#---------------------------------------------------------------------------------
%_mb.elf:
@echo linking multiboot
@$(LD) -specs=gba_mb.specs $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
%.elf:
@echo linking cartridge
@$(LD) $(LDFLAGS) -specs=gba.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@

18
dkarm/rules/gp32_rules Normal file
View File

@ -0,0 +1,18 @@
-include $(DEVKITARM)/base_rules
LIBMIRKO := $(DEVKITPRO)/libmirko
#---------------------------------------------------------------------------------
%.fxe: %.bin
@b2fxec -a "$(AUTHOR)" -t "$(TITLE)" $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.bin: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.elf:
@echo linking binary
@$(LD) $(LDFLAGS) -specs=gp32.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@

View File

@ -0,0 +1,37 @@
#!/bin/sh
export DEVKITARM=$TOOLPATH/devkitARM
export DEVKITPRO=$TOOLPATH
#---------------------------------------------------------------------------------
# Install and build the gba crt
#---------------------------------------------------------------------------------
cp $(pwd)/dkarm/crtls/* $DEVKITARM/arm-elf/lib/
cd $DEVKITARM/arm-elf/lib/
$MAKE CRT=gba
$MAKE CRT=gp32
$MAKE CRT=er
$MAKE CRT=gp32_gpsdk
$MAKE CRT=ds_arm7
$MAKE CRT=ds_arm9
$MAKE CRT=ds_cart
cd $BUILDSCRIPTDIR
$MAKE -C tools/general
$MAKE -C tools/general install PREFIX=$DEVKITARM/bin
#---------------------------------------------------------------------------------
# copy base rulesets
#---------------------------------------------------------------------------------
cp dkarm/rules/* $DEVKITARM
cd $LIBNDS_SRCDIR
echo "building libnds ..."
$MAKE install INSTALLDIR=$TOOLPATH
echo "building libgba ..."
cd $BUILDSCRIPTDIR
cd $LIBGBA_SRCDIR
$MAKE install INSTALLDIR=$TOOLPATH

View File

@ -0,0 +1,95 @@
#!/bin/sh
#---------------------------------------------------------------------------------
# Check Parameters
#---------------------------------------------------------------------------------
prefix=$INSTALLDIR/devkitARM
#---------------------------------------------------------------------------------
# build and install binutils
#---------------------------------------------------------------------------------
mkdir -p $target/binutils
cd $target/binutils
../../$BINUTILS_SRCDIR/configure \
--prefix=$prefix --target=$target --disable-nls --disable-shared --disable-debug \
--disable-threads --with-gcc --with-gnu-as --with-gnu-ld --with-stabs \
2>&1 | tee $BUILDSCRIPTDIR/binutils_configure.log
$MAKE 2>&1 | tee binutils_make.log
$MAKE install 2>&1 | tee $BUILDSCRIPTDIR/binutils_install.log
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/binutils
rm -fr $BINUTILS_SRCDIR
#---------------------------------------------------------------------------------
# build and install just the c compiler
#---------------------------------------------------------------------------------
mkdir -p $target/gcc
cd $target/gcc
../../$GCC_SRCDIR/configure \
--enable-languages=c,c++ \
--with-cpu=arm7tdmi\
--enable-interwork --enable-multilib\
--with-gcc --with-gnu-ld --with-gnu-as --with-stabs \
--disable-shared --disable-threads --disable-win32-registry --disable-nls\
--target=$target \
--with-newlib \
--prefix=$prefix -v\
2>&1 | tee $BUILDSCRIPTDIR/gcc_configure.log
$MAKE all-gcc 2>&1| tee $BUILDSCRIPTDIR/gcc_make.log
$MAKE install-gcc 2>&1 | tee $BUILDSCRIPTDIR/gcc_install.log
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# build and install newlib
#---------------------------------------------------------------------------------
mkdir -p $target/newlib
cd $target/newlib
$BUILDSCRIPTDIR/$NEWLIB_SRCDIR/configure \
--enable-serial-configure \
--target=$target \
--prefix=$prefix \
--enable-newlib-mb \
| tee $BUILDSCRIPTDIR/newlib_configure.log
mkdir -p etc
$MAKE | tee $BUILDSCRIPTDIR/newlib_make.log
$MAKE install | tee $BUILDSCRIPTDIR/newlib_install.log
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/newlib
rm -fr $NEWLIB_SRCDIR
#---------------------------------------------------------------------------------
# build and install the final compiler
#---------------------------------------------------------------------------------
cd $BUILDSCRIPTDIR
cd $target/gcc
$MAKE | tee $BUILDSCRIPTDIR/gcc_final_make.log 2>&1
$MAKE install | tee $BUILDSCRIPTDIR/gcc_final_install.log 2>&1
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/gcc
rm -fr $GCC_SRCDIR

View File

@ -0,0 +1,16 @@
#!/bin/sh
export DEVKITARM=$TOOLPATH/devkitARM
export DEVKITPRO=$TOOLPATH
$MAKE -C tools/gba
$MAKE -C tools/gba install PREFIX=$DEVKITARM/bin
$MAKE -C tools/gp32
$MAKE -C tools/gp32 install PREFIX=$DEVKITARM/bin
$MAKE -C tools/nds/
$MAKE -C tools/nds/ install PREFIX=$DEVKITARM/bin
$MAKE -C tools clean

302
dkppc/crtls/gcn.ld Normal file
View File

@ -0,0 +1,302 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
"elf32-powerpc")
OUTPUT_ARCH(powerpc:common)
ENTRY(_start)
SEARCH_DIR("/powerpc/powerpc-eabi-elf/lib");
/* Do we need any of these for elf?
__DYNAMIC = 0; */
PROVIDE (__stack = 0x817F0000);
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x80003100;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rela.got1 : { *(.rela.got1) }
.rela.got2 : { *(.rela.got2) }
.rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
.rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
.rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
.rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/* DOL header (from TITANIK's GC docs)
*/
file_start = 0x80003000;
. = file_start;
.header :
{
/* 0000-001B Text[0..6] sections File Positions */
LONG(text_file_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 001C-0047 Data[0..10] sections File Positions */
LONG(data_file_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 0048-0063 Text[0..6] sections Mem Address */
LONG(text_mem_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 0064-008F Data[0..10] sections Mem Address */
LONG(data_mem_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 0090-00AB Text[0..6] sections Sizes */
LONG(text_mem_size);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 00AC-00D7 Data[0..10] sections Sizes */
LONG(data_mem_size);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 00D8 BSS Mem address
* 00DC BSS Size */
LONG(bss_mem_start);
LONG(bss_mem_size);
/* 00E0 Entry Point */
LONG(ABSOLUTE(_start));
}
. = 0x80003100;
text_mem_start = .;
.init :
{
KEEP (*(.init))
} =0
.text :
{
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} =0
.fini :
{
KEEP (*(.fini))
} =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
. = ALIGN(32);
text_mem_size = . - text_mem_start;
data_mem_start = .;
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
. = ALIGN(32);
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { *(.preinit_array) }
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { *(.init_array) }
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.fixup : { *(.fixup) }
.got1 : { *(.got1) }
.got2 : { *(.got2) }
.dynamic : { *(.dynamic) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.got : { *(.got.plt) *(.got) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
_edata = .;
PROVIDE (edata = .);
data_mem_size = . - data_mem_start;
bss_mem_start = .;
__bss_start = .;
.sbss :
{
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
}
.plt : { *(.plt) }
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
bss_mem_size = . - bss_mem_start;
text_file_start = text_mem_start - file_start;
data_file_start = data_mem_start - file_start;
_end = .;
__end = .;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}

483
dkppc/crtls/gcn_crt0.s Normal file
View File

@ -0,0 +1,483 @@
#---------------------------------------------------------------------------------
# crt0.s file for the GameCube V1.0 by Costis (costis@gbaemu.com)!
#
# some little modifications by Groepaz/Hitmen and WinterMute
#
# This is start-up code for initializing the GameCube system and hardware
# before executing the actual user program code. It clears the GPR's,
# initializes the FPR's, initializes the Data, Code, and L2 caches, clears
# and initializes SPR's, and disables exceptions (interrupts).
#
# Have fun!!! Please e-mail any suggestions or bugs to costis@gbaemu.com.
#---------------------------------------------------------------------------------
.section ".init"
.globl _start
.extern __bss_start, _end
.extern __init, __fini
.extern main
_start:
#---------------------------------------------------------------------------------
# Initialize the General Purpose Registers
#---------------------------------------------------------------------------------
bl InitGPRS
#---------------------------------------------------------------------------------
# Initialize the GameCube Hardware (Floating Point Registers, Caches, etc.)
#---------------------------------------------------------------------------------
bl InitHardware
#---------------------------------------------------------------------------------
# Initialize more cache aspects, clear a few SPR's, and disable interrupts.
#---------------------------------------------------------------------------------
bl SystemInit
#---------------------------------------------------------------------------------
# clear the bss section
#---------------------------------------------------------------------------------
lis 3, __bss_start@h
ori 3, 3, __bss_start@l
li 4, 0
lis 5, _end@h
ori 5, 5, _end@l
sub 5, 5, 3
#subi 3, 3, 4
mtctr 5
BSSCLoop:
#stwu 4, 4(3)
stbu 4,0(3)
bdnz BSSCLoop
#---------------------------------------------------------------------------------
# push args for main() and generate first stackframe
#---------------------------------------------------------------------------------
addi 1,1,-4
lis 0,0
stw 0,0(1)
stwu 1,-64(1)
#---------------------------------------------------------------------------------
# Initialise global constructors!
#---------------------------------------------------------------------------------
bl __init
#---------------------------------------------------------------------------------
# Branch to the user code!
#---------------------------------------------------------------------------------
bl main
#---------------------------------------------------------------------------------
# global destructors!
#---------------------------------------------------------------------------------
bl __fini
# call functions registered by atexit()
# .globl _exit
# bl exit
#_exit:
#---------------------------------------------------------------------------------
# if the main function returns, reset the gc
#
# notice that restarting the program may fail since the
# .data section may have been changed by previous run.
#---------------------------------------------------------------------------------
# disable irqs
#---------------------------------------------------------------------------------
mfmsr 3
rlwinm 4,3,0,17,15
mtmsr 4
extrwi 3,3,1,16
#---------------------------------------------------------------------------------
eloop:
#---------------------------------------------------------------------------------
# hot reset
#---------------------------------------------------------------------------------
lis 9,0xcc00
li 0,0x00
ori 9,9,0x3024
stw 0,0x00(9)
b eloop # try again if we really come here :=P
#---------------------------------------------------------------------------------
# General Purpose Register init
#---------------------------------------------------------------------------------
InitGPRS:
#---------------------------------------------------------------------------------
# Clear all of the GPR's to 0
#---------------------------------------------------------------------------------
li 0,0
li 3,0
li 4,0
li 5,0
li 6,0
li 7,0
li 8,0
li 9,0
li 10,0
li 11,0
li 12,0
li 14,0
li 15,0
li 16,0
li 17,0
li 18,0
li 19,0
li 20,0
li 21,0
li 22,0
li 23,0
li 24,0
li 25,0
li 26,0
li 27,0
li 28,0
li 29,0
li 30,0
li 31,0
#---------------------------------------------------------------------------------
# Set the Stack Pointer - set in linkscript
#---------------------------------------------------------------------------------
lis 1,__stack@h
ori 1,1,__stack@l
#---------------------------------------------------------------------------------
# Set the Small Data 2 (Read Only) base register.
#---------------------------------------------------------------------------------
lis 2,_SDA2_BASE_@h
ori 2,2,_SDA2_BASE_@l
#---------------------------------------------------------------------------------
# Set the Small Data (Read\Write) base register.
#---------------------------------------------------------------------------------
lis 13,_SDA_BASE_@h
ori 13,13,_SDA_BASE_@l
blr
#---------------------------------------------------------------------------------
# Hardware Init
#---------------------------------------------------------------------------------
InitHardware:
#---------------------------------------------------------------------------------
mflr 31 # Store the link register in r31
bl PSInit # Initialize Paired Singles
bl FPRInit # Initialize the FPR's
bl CacheInit # Initialize the system caches
mtlr 31 # Retreive the link register from r31
blr
#---------------------------------------------------------------------------------
PSInit:
#---------------------------------------------------------------------------------
mfspr 3, 920 # (HID2)
oris 3, 3, 0xA000
mtspr 920, 3 # (HID2)
#---------------------------------------------------------------------------------
# Set the Instruction Cache invalidation bit in HID0
#---------------------------------------------------------------------------------
mfspr 3,1008
ori 3,3,0x0800
mtspr 1008,3
sync
#---------------------------------------------------------------------------------
# Clear various Special Purpose Registers
#---------------------------------------------------------------------------------
li 3,0
mtspr 912,3
mtspr 913,3
mtspr 914,3
mtspr 915,3
mtspr 916,3
mtspr 917,3
mtspr 918,3
mtspr 919,3
#---------------------------------------------------------------------------------
# Return
#---------------------------------------------------------------------------------
blr
#---------------------------------------------------------------------------------
FPRInit:
#---------------------------------------------------------------------------------
# Enable the Floating Point Registers
#---------------------------------------------------------------------------------
mfmsr 3
ori 3,3,0x2000
mtmsr 3
#---------------------------------------------------------------------------------
# Clear all of the FPR's to 0
#---------------------------------------------------------------------------------
lis 3, zfloat@h
ori 3, 3, zfloat@l
lfd 0, 0(3)
fmr 1,0
fmr 2,0
fmr 3,0
fmr 4,0
fmr 5,0
fmr 6,0
fmr 7,0
fmr 8,0
fmr 9,0
fmr 10,0
fmr 11,0
fmr 12,0
fmr 13,0
fmr 14,0
fmr 15,0
fmr 16,0
fmr 17,0
fmr 18,0
fmr 19,0
fmr 20,0
fmr 21,0
fmr 22,0
fmr 23,0
fmr 24,0
fmr 25,0
fmr 26,0
fmr 27,0
fmr 28,0
fmr 29,0
fmr 30,0
fmr 31,0
mtfsf 255,0
blr
#---------------------------------------------------------------------------------
CacheInit:
#---------------------------------------------------------------------------------
mflr 0
stw 0, 4(1)
stwu 1, -16(1)
stw 31, 12(1)
stw 30, 8(1)
#---------------------------------------------------------------------------------
# Check if the Instruction Cache has been enabled.
#---------------------------------------------------------------------------------
mfspr 3,1008 # (HID0)
rlwinm 0, 3, 0, 16, 16
cmplwi 0, 0x0000
bne ICEnabled
isync
mfspr 3, 1008
ori 3, 3, 0x8000
mtspr 1008, 3
#---------------------------------------------------------------------------------
ICEnabled:
#---------------------------------------------------------------------------------
mfspr 3, 1008 # bl PPCMfhid0
rlwinm 0, 3, 0, 17, 17
cmplwi 0, 0x0000 # Check if the Data Cache has been enabled or not.
bne DCEnabled
# If not, then enable it.
sync
mfspr 3, 1008
ori 3, 3, 0x4000
mtspr 1008, 3
#---------------------------------------------------------------------------------
DCEnabled:
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR)
clrrwi 0, 3, 31 # Clear all of the bits except 31
cmplwi 0, 0x0000
bne L2GISkip # Skip the L2 Global Cache Invalidation process
# if it has already been done before.
#---------------------------------------------------------------------------------
# Store the current state of the MSR in r30
#---------------------------------------------------------------------------------
mfmsr 3
mr 30,3
sync
#---------------------------------------------------------------------------------
# Enable Instruction and Data Address Translation
#---------------------------------------------------------------------------------
li 3, 48
mtmsr 3
sync
sync
#---------------------------------------------------------------------------------
# Disable the L2 Global Cache.
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR
clrlwi 3, 3, 1
mtspr 1017, 3 # (L2CR)
sync
#---------------------------------------------------------------------------------
# Invalidate the L2 Global Cache.
#---------------------------------------------------------------------------------
bl L2GlobalInvalidate
#---------------------------------------------------------------------------------
# Restore the previous state of the MSR from r30
#---------------------------------------------------------------------------------
mr 3, 30
mtmsr 3
#---------------------------------------------------------------------------------
# Enable the L2 Global Cache
# disable the L2 Data Only bit and the L2 Global Invalidate Bit.
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR)
oris 0, 3, 0x8000
rlwinm 3, 0, 0, 11, 9
mtspr 1017, 3 # (L2CR)
#---------------------------------------------------------------------------------
L2GISkip:
#---------------------------------------------------------------------------------
# Restore the non-volatile registers to their previous values and return.
#---------------------------------------------------------------------------------
lwz 0, 20(1)
lwz 31, 12(1)
lwz 30, 8(1)
addi 1, 1, 16
mtlr 0
blr
#---------------------------------------------------------------------------------
L2GlobalInvalidate:
#---------------------------------------------------------------------------------
mflr 0
stw 0, 4(1)
stwu 1, -16(1)
stw 31, 12(1)
sync
#---------------------------------------------------------------------------------
# Disable the L2 Cache.
#---------------------------------------------------------------------------------
mfspr 3, 1017 # bl PPCMf1017
clrlwi 3, 3, 1
mtspr 1017, 3 # bl PPCMt1017
sync
#---------------------------------------------------------------------------------
# Initiate the L2 Cache Global Invalidation process.
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR)
oris 3, 3, 0x0020
mtspr 1017, 3 # (L2CR)
#---------------------------------------------------------------------------------
# Wait until the L2 Cache Global Invalidation has been completed.
#---------------------------------------------------------------------------------
L2GICheckComplete:
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR)
clrlwi 0, 3, 31
cmplwi 0, 0x0000
bne L2GICheckComplete
#---------------------------------------------------------------------------------
# Clear the L2 Data Only bit and the L2 Global Invalidate Bit.
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR)
rlwinm 3, 3, 0, 11, 9
mtspr 1017, 3 # (L2CR)
#---------------------------------------------------------------------------------
# Wait until the L2 Cache Global Invalidation status bit signifies that it is ready.
#---------------------------------------------------------------------------------
L2GDICheckComplete:
#---------------------------------------------------------------------------------
mfspr 3, 1017 # (L2CR)
clrlwi 0, 3, 31
cmplwi 0, 0x0000
bne L2GDICheckComplete
#---------------------------------------------------------------------------------
# Restore the non-volatile registers to their previous values and return.
#---------------------------------------------------------------------------------
lwz 0, 20(1)
lwz 31, 12(1)
addi 1, 1, 16
mtlr 0
blr
#---------------------------------------------------------------------------------
SystemInit:
#---------------------------------------------------------------------------------
mflr 0
stw 0, 4(1)
stwu 1, -0x18(1)
stw 31, 0x14(1)
stw 30, 0x10(1)
stw 29, 0xC(1)
#---------------------------------------------------------------------------------
# Disable interrupts!
#---------------------------------------------------------------------------------
mfmsr 3
rlwinm 4,3,0,17,15
mtmsr 4
#---------------------------------------------------------------------------------
# Clear various SPR's
#---------------------------------------------------------------------------------
li 3,0
mtspr 952, 3
mtspr 956, 3
mtspr 953, 3
mtspr 954, 3
mtspr 957, 3
mtspr 958, 3
#---------------------------------------------------------------------------------
# Disable Speculative Bus Accesses to non-guarded space from both caches.
#---------------------------------------------------------------------------------
mfspr 3, 1008 # (HID0)
ori 3, 3, 0x0200
mtspr 1008, 3
#---------------------------------------------------------------------------------
# Set the Non-IEEE mode in the FPSCR
#---------------------------------------------------------------------------------
mtfsb1 29
mfspr 3,920 # (HID2)
rlwinm 3, 3, 0, 2, 0
mtspr 920,3 # (HID2)
#---------------------------------------------------------------------------------
# Restore the non-volatile registers to their previous values and return.
#---------------------------------------------------------------------------------
lwz 0, 0x1C(1)
lwz 31, 0x14(1)
lwz 30, 0x10(1)
lwz 29, 0xC(1)
addi 1, 1, 0x18
mtlr 0
blr
#---------------------------------------------------------------------------------
zfloat:
#---------------------------------------------------------------------------------
.float 0
.align 4

348
dkppc/crtls/ogc.ld Normal file
View File

@ -0,0 +1,348 @@
/*
* Linkscript for GC, automatically sets up DOL structures,
* generate ELF file and use objdump, or generate binary
* directly.
*
* PSUL doesn't seem to handle separate text and data sections correctly,
* that is why the text and data sections are merged in the header.
*
* If you want to experiment, it should be quite obvious how to
* change the header to list the data separately.
*/
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc");
OUTPUT_ARCH(powerpc:common);
EXTERN(_start);
ENTRY(_start);
SECTIONS
{
/* DOL header (from TITANIK's GC docs)
*/
file_start = 0x80003000;
. = file_start;
.header :
{
/* 0000-001B Text[0..6] sections File Positions */
LONG(text_file_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 001C-0047 Data[0..10] sections File Positions */
LONG(data_file_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 0048-0063 Text[0..6] sections Mem Address */
LONG(text_mem_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 0064-008F Data[0..10] sections Mem Address */
LONG(data_mem_start);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 0090-00AB Text[0..6] sections Sizes */
LONG(text_mem_size);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 00AC-00D7 Data[0..10] sections Sizes */
LONG(data_mem_size);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
/* 00D8 BSS Mem address
* 00DC BSS Size */
LONG(bss_mem_start);
LONG(bss_mem_size);
/* 00E0 Entry Point */
LONG(ABSOLUTE(_start));
}
/* Program
*/
. = 0x80003100;
text_mem_start = .;
.init :
{
KEEP (*crt0.o(*.init))
KEEP (*(.init))
} = 0
.plt : { *(.plt) }
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rela.got1 : { *(.rela.got1) }
.rela.got2 : { *(.rela.got2) }
.rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
.rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rel.gnu.linkonce.sb.*) }
.rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
.rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.text :
{
*(.text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t.*)
} = 0
.fini :
{
KEEP (*(.fini))
} = 0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
text_mem_size = . - text_mem_start;
data_mem_start = .;
.rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) }
.sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { *(.preinit_array) }
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { *(.init_array) }
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
.data :
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.fixup : { *(.fixup) }
.got1 : { *(.got1) }
.got2 : { *(.got2) }
.dynamic : { *(.dynamic) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.got : { *(.got.plt) *(.got) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s.*)
}
_edata = .;
PROVIDE (edata = .);
data_mem_size = . - data_mem_start;
bss_mem_start = .;
.sbss :
{
__sbss_start = .;
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.sb.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
__sbss_end = .;
}
.bss :
{
__bss_start = .;
PROVIDE (__bss_start = .);
*(.dynbss)
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
PROVIDE (__bss_end = .);
__bss_end = .;
}
. = ALIGN(32 / 8);
bss_mem_size = . - bss_mem_start;
/* calculate file addresses */
text_file_start = text_mem_start - file_start;
data_file_start = data_mem_start - file_start;
_end = .;
PROVIDE(end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* These must appear regardless of . */
}
__stack_addr = (__bss_start + SIZEOF(.bss) + 0x2000 + 7) & (-8);
__stack_end = (__bss_start + SIZEOF(.bss));
__intrstack_addr = (__stack_addr + 0x2000);
__intrstack_end = (__stack_addr);
__ArenaLo = (__intrstack_addr + 31) & (-32);
__ArenaHi = (0x81700000);
__gxregs = (__ArenaHi + 31) & (-32);
/* for backward compatibility with old crt0 */
__stack = (0x81700000);
PROVIDE (text_mem_start = text_mem_start);
PROVIDE (data_mem_start = data_mem_start);
PROVIDE (bss_mem_start = bss_mem_start);
PROVIDE(__stack_addr = __stack_addr);
PROVIDE(__stack_end = __stack_end);
PROVIDE(__intrstack_addr = __intrstack_addr);
PROVIDE(__intrstack_end = __intrstack_end);
PROVIDE(__ArenaLo = __ArenaLo);
PROVIDE(__ArenaHi = __ArenaHi);
PROVIDE(__gxregs = __gxregs);

355
dkppc/crtls/specs Normal file
View File

@ -0,0 +1,355 @@
*asm:
--traditional-format %(asm_cpu) %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} %{memb|msdata|msdata=eabi: -memb} %{mlittle|mlittle-endian:-mlittle; mbig|mbig-endian :-mbig; mcall-aixdesc | mcall-freebsd | mcall-netbsd | mcall-openbsd | mcall-linux | mcall-gnu :-mbig; mcall-i960-old :-mlittle}
*asm_debug:
%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}
*asm_final:
*asm_options:
%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}
*invoke_as:
%{!S:-o %|.s |
as %(asm_options) %|.s %A }
*cpp:
%{posix: -D_POSIX_SOURCE} %{mads : %(cpp_os_ads) ; myellowknife : %(cpp_os_yellowknife) ; mmvme : %(cpp_os_mvme) ; msim : %(cpp_os_sim) ; mwindiss : %(cpp_os_windiss) ; mcall-freebsd: %(cpp_os_freebsd) ; mcall-linux : %(cpp_os_linux) ; mcall-gnu : %(cpp_os_gnu) ; mcall-netbsd : %(cpp_os_netbsd) ; mcall-openbsd: %(cpp_os_openbsd) ; : %(cpp_os_default) }
*cpp_options:
%(cpp_unique_options) %1 %{m*} %{std*} %{ansi} %{W*&pedantic*} %{w} %{f*} %{g*:%{!g0:%{!fno-working-directory:-fworking-directory}}} %{O*} %{undef}
*cpp_debug_options:
%{d*}
*cpp_unique_options:
%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}} %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*} %{P} %I %{MD:-MD %{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}} %{trigraphs} %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{E|M|MM:%W{o*}}
*trad_capable_cpp:
cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}
*cc1:
%{G*} %{mlittle|mlittle-endian: %(cc1_endian_little); mbig |mbig-endian : %(cc1_endian_big); mcall-aixdesc | mcall-freebsd | mcall-netbsd | mcall-openbsd | mcall-linux | mcall-gnu : -mbig %(cc1_endian_big); mcall-i960-old : -mlittle %(cc1_endian_little); : %(cc1_endian_default)} %{mno-sdata: -msdata=none } %{meabi: %{!mcall-*: -mcall-sysv }} %{!meabi: %{!mno-eabi: %{mrelocatable: -meabi } %{mcall-freebsd: -mno-eabi } %{mcall-i960-old: -meabi } %{mcall-linux: -mno-eabi } %{mcall-gnu: -mno-eabi } %{mcall-netbsd: -mno-eabi } %{mcall-openbsd: -mno-eabi }}} %{msdata: -msdata=default} %{mno-sdata: -msdata=none} %{profile: -p}
*cc1_options:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*} %{w} %{std*} %{ansi} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*}
*cc1plus:
*link_gcc_c_sequence:
%G %L %G
*endfile:
%{mgcn : crtsavres.o%s %(endfile_gcn); mogc : crtsavres.o%s %(endfile_gcn); myellowknife : crtsavres.o%s %(endfile_yellowknife) ; mmvme : crtsavres.o%s %(endfile_mvme) ; msim : crtsavres.o%s %(endfile_sim) ; mwindiss : %(endfile_windiss) ; mcall-freebsd: crtsavres.o%s %(endfile_freebsd) ; mcall-linux : crtsavres.o%s %(endfile_linux) ; mcall-gnu : crtsavres.o%s %(endfile_gnu) ; mcall-netbsd : crtsavres.o%s %(endfile_netbsd) ; mcall-openbsd: crtsavres.o%s %(endfile_openbsd) ; : %(crtsavres_default) %(endfile_default) }
*link:
%{h*} %{v:-V} %{!msdata=none:%{G*}} %{msdata=none:-G0} %{YP,*} %{R*} %{Qy:} %{!Qn:-Qy} %(link_shlib) %{!Wl,-T*: %{!T*: %(link_start) }} %(link_target) %(link_os)
*lib:
%{mgcn : %(lib_gcn); mogc : %(lib_ogc); myellowknife : %(lib_yellowknife) ; mmvme : %(lib_mvme) ; msim : %(lib_sim) ; mwindiss : %(lib_windiss) ; mcall-freebsd: %(lib_freebsd) ; mcall-linux : %(lib_linux) ; mcall-gnu : %(lib_gnu) ; mcall-netbsd : %(lib_netbsd) ; mcall-openbsd: %(lib_openbsd) ; : %(lib_default) }
*libgcc:
-lgcc
*startfile:
%{mgcn : %(startfile_gcn) ; mogc : %(startfile_ogc) ; myellowknife : %(startfile_yellowknife) ; mmvme : %(startfile_mvme) ; msim : %(startfile_sim) ; mwindiss : %(startfile_windiss) ; mcall-freebsd: %(startfile_freebsd) ; mcall-linux : %(startfile_linux) ; mcall-gnu : %(startfile_gnu) ; mcall-netbsd : %(startfile_netbsd) ; mcall-openbsd: %(startfile_openbsd) ; : %(startfile_default) }
*switches_need_spaces:
*cross_compile:
1
*version:
3.4.3
*multilib:
. ;
*multilib_defaults:
mbig mcall-sysv
*multilib_extra:
*multilib_matches:
*multilib_exclusions:
*multilib_options:
*linker:
collect2
*link_libgcc:
%D
*md_exec_prefix:
*md_startfile_prefix:
*md_startfile_prefix_1:
*startfile_prefix_spec:
*sysroot_suffix_spec:
*sysroot_hdrs_suffix_spec:
*cpp_default:
*asm_cpu:
%{!mcpu*: %{mpower: %{!mpower2: -mpwr}} %{mpower2: -mpwrx} %{mpowerpc*: -mppc} %{mno-power: %{!mpowerpc*: -mcom}} %{!mno-power: %{!mpower2: %(asm_default)}}} %{mcpu=common: -mcom} %{mcpu=power: -mpwr} %{mcpu=power2: -mpwrx} %{mcpu=power3: -m604} %{mcpu=power4: -mpower4} %{mcpu=powerpc: -mppc} %{mcpu=rios: -mpwr} %{mcpu=rios1: -mpwr} %{mcpu=rios2: -mpwrx} %{mcpu=rsc: -mpwr} %{mcpu=rsc1: -mpwr} %{mcpu=401: -mppc} %{mcpu=403: -m403} %{mcpu=405: -m405} %{mcpu=405fp: -m405} %{mcpu=440: -m440} %{mcpu=440fp: -m440} %{mcpu=505: -mppc} %{mcpu=601: -m601} %{mcpu=602: -mppc} %{mcpu=603: -mppc} %{mcpu=603e: -mppc} %{mcpu=ec603e: -mppc} %{mcpu=604: -mppc} %{mcpu=604e: -mppc} %{mcpu=620: -mppc} %{mcpu=630: -m604} %{mcpu=740: -mppc} %{mcpu=7400: -mppc} %{mcpu=7450: -mppc} %{mcpu=G4: -mppc} %{mcpu=750: -mppc} %{mcpu=G3: -mppc} %{mcpu=801: -mppc} %{mcpu=821: -mppc} %{mcpu=823: -mppc} %{mcpu=860: -mppc} %{mcpu=970: -mpower4} %{mcpu=G5: -mpower4} %{mcpu=8540: -me500} %{maltivec: -maltivec}
*asm_default:
-mppc
*crtsavres_default:
crtsavres.o%s
*lib_ogc:
--start-group -logcsys -lc --end-group -logc
*lib_gcn:
--start-group -lads -lc -lstubs --end-group
*lib_yellowknife:
--start-group -lyk -lc --end-group
*lib_mvme:
--start-group -lmvme -lc --end-group
*lib_sim:
--start-group -lsim -lc --end-group
*lib_freebsd:
%{!shared: %{!pg: %{!pthread:-lc} %{pthread:-lc_r}} %{pg: %{!pthread:-lc_p} %{pthread:-lc_r_p}} }
*lib_gnu:
%{mnewlib: --start-group -lgnu -lc --end-group } %{!mnewlib: %{shared:-lc} %{!shared: %{pthread:-lpthread } %{profile:-lc_p} %{!profile:-lc}}}
*lib_linux:
%{mnewlib: --start-group -llinux -lc --end-group } %{!mnewlib: %{pthread:-lpthread} %{shared:-lc} %{!shared: %{profile:-lc_p} %{!profile:-lc}}}
*lib_netbsd:
%{profile:-lgmon -lc_p} %{!profile:-lc}
*lib_openbsd:
%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}
*lib_windiss:
--start-group -li -lcfp -lwindiss -lram -limpl -limpfp --end-group
*lib_default:
*startfile_gcn:
gcn_crt0.o%s ecrti.o%s crtbegin.o%s
*startfile_ogc:
ecrti.o%s crtbegin.o%s
*startfile_yellowknife:
ecrti.o%s crt0.o%s crtbegin.o%s
*startfile_mvme:
ecrti.o%s crt0.o%s crtbegin.o%s
*startfile_sim:
ecrti.o%s sim-crt0.o%s crtbegin.o%s
*startfile_freebsd:
%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s}}}} crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
*startfile_gnu:
%{!shared: %{!static: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}} %{static: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
*startfile_linux:
%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} %{mnewlib:ecrti.o%s;:crti.o%s} %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
*startfile_netbsd:
ncrti.o%s crt0.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
*startfile_openbsd:
%{!shared: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
*startfile_windiss:
crt0.o%s crtbegin.o%s
*startfile_default:
*endfile_gcn:
crtend.o%s ecrtn.o%s
*endfile_yellowknife:
crtend.o%s ecrtn.o%s
*endfile_mvme:
crtend.o%s ecrtn.o%s
*endfile_sim:
crtend.o%s ecrtn.o%s
*endfile_freebsd:
%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
*endfile_gnu:
%{!shared:crtend.o%s} %{shared:crtendS.o%s} %{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}
*endfile_linux:
%{!shared:crtend.o%s} %{shared:crtendS.o%s} %{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}
*endfile_netbsd:
%{!shared:crtend.o%s} %{shared:crtendS.o%s} ncrtn.o%s
*endfile_openbsd:
%{!shared:crtend.o%s} %{shared:crtendS.o%s}
*endfile_windiss:
crtend.o%s
*endfile_default:
*link_path:
*link_shlib:
%{mshlib: %(link_path) } %{!mshlib: %{!shared: %{!symbolic: -dn -Bstatic}}} %{static: } %{shared:-G -dy -z text %(link_path) } %{symbolic:-Bsymbolic -G -dy -z text %(link_path) }
*link_target:
%{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: %{mcall-i960-old: --oformat elf32-powerpcle} }}}}
*link_start:
%{mgcn : %(link_start_gcn); mogc : %(link_start_gcn); myellowknife : %(link_start_yellowknife) ; mmvme : %(link_start_mvme) ; msim : %(link_start_sim) ; mwindiss : %(link_start_windiss) ; mcall-freebsd: %(link_start_freebsd) ; mcall-linux : %(link_start_linux) ; mcall-gnu : %(link_start_gnu) ; mcall-netbsd : %(link_start_netbsd) ; mcall-openbsd: %(link_start_openbsd) ; : %(link_start_default) }
*link_start_gcn:
-T ogc.ld%s
*link_start_yellowknife:
-T yellowknife.ld%s
*link_start_mvme:
-Ttext 0x40000
*link_start_sim:
*link_start_freebsd:
*link_start_gnu:
*link_start_linux:
*link_start_netbsd:
*link_start_openbsd:
-Ttext 0x400074
*link_start_windiss:
*link_start_default:
*link_os:
%{mads : %(link_os_ads) ; myellowknife : %(link_os_yellowknife) ; mmvme : %(link_os_mvme) ; msim : %(link_os_sim) ; mwindiss : %(link_os_windiss) ; mcall-freebsd: %(link_os_freebsd) ; mcall-linux : %(link_os_linux) ; mcall-gnu : %(link_os_gnu) ; mcall-netbsd : %(link_os_netbsd) ; mcall-openbsd: %(link_os_openbsd) ; : %(link_os_default) }
*link_os_ads:
*link_os_yellowknife:
*link_os_mvme:
*link_os_sim:
-m elf32ppcsim
*link_os_freebsd:
%{p:%e`-p' not supported; use `-pg' and gprof(1)} %{Wl,*:%*} %{v:-V} %{assert*} %{R*} %{rpath*} %{defsym*} %{shared:-Bshareable %{h*} %{soname*}} %{!shared: %{!static: %{rdynamic: -export-dynamic} %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} %{static:-Bstatic}} %{symbolic:-Bsymbolic}
*link_os_linux:
-m elf32ppclinux %{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}
*link_os_gnu:
-m elf32ppclinux %{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}
*link_os_netbsd:
%{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}
*link_os_openbsd:
*link_os_windiss:
*link_os_default:
*cc1_endian_big:
*cc1_endian_little:
%{!mstrict-align: %{!mno-strict-align: %{!mcall-i960-old: -mstrict-align } }}
*cc1_endian_default:
%(cc1_endian_big)
*cpp_os_ads:
*cpp_os_yellowknife:
*cpp_os_mvme:
*cpp_os_sim:
*cpp_os_freebsd:
-D__PPC__ -D__ppc__ -D__PowerPC__ -D__powerpc__ -Acpu=powerpc -Amachine=powerpc
*cpp_os_gnu:
-D__unix__ -D__gnu_hurd__ -D__GNU__ %{!undef: %{!ansi: -Dunix -D__unix}} -Asystem=gnu -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}
*cpp_os_linux:
-D__unix__ -D__gnu_linux__ -D__linux__ %{!undef: %{!ansi: %{!std=*:-Dunix -D__unix -Dlinux -D__linux} %{std=gnu*:-Dunix -D__unix -Dlinux -D__linux}}} -Asystem=linux -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}
*cpp_os_netbsd:
-D__powerpc__ -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__
*cpp_os_openbsd:
%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}
*cpp_os_windiss:
-D__rtasim -D__EABI__ -D__ppc %{!msoft-float: -D__hardfp}
*cpp_os_default:
*fbsd_dynamic_linker:
/usr/libexec/ld-elf.so.1
*link_command:
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %{pie:-pie} %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate:-lgcov} %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}

55
dkppc/rules/base_rules Normal file
View File

@ -0,0 +1,55 @@
#---------------------------------------------------------------------------------
# the prefix on the compiler executables
#---------------------------------------------------------------------------------
PREFIX := powerpc-gekko-
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
@echo $(notdir $@)
@$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.o: %.cpp
@echo $(notdir $<)
@$(CXX) -MMD -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.c
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.s
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.S
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
cp $(<) $(*).tmp
alignbin $(*).tmp
$(OBJCOPY) -I binary -O elf32-powerpc -B powerpc \
--rename-section .data=.rodata,readonly,data,contents,alloc \
--redefine-sym _binary_`(echo $(*) | tr . _)`_tmp_start=`(echo $(*) | tr . _)`\
--redefine-sym _binary_`(echo $(*) | tr . _)`_tmp_end=`(echo $(*) | tr . _)`_end\
--redefine-sym _binary_`(echo $(*) | tr . _)`_tmp_size=`(echo $(*) | tr . _)`_size\
$(*).tmp $(@)
echo "extern const u32" `(echo $(*) | tr . _)`"_end[];" >> $(*).h
echo "extern const u8" `(echo $(*) | tr . _)`"[];" >> $(*).h
echo "extern const u32" `(echo $(*) | tr . _)`_size[]";" >> $(*).h
rm $(*).tmp
endef

View File

@ -0,0 +1,10 @@
-include $(DEVKITPPC)/base_rules
%.dol: %.elf
@echo output ... $(notdir $@)
@$(OBJCOPY) -O binary $< $@
#---------------------------------------------------------------------------------
%.elf:
@echo linking ... $(notdir $@)
@$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@

View File

@ -0,0 +1,26 @@
#!/bin/sh
DEVKITPPC=$INSTALLDIR/devkitPPC
#---------------------------------------------------------------------------------
# Install and build the gamecube crt and libogc
#---------------------------------------------------------------------------------
echo "installing specs ..."
cp `pwd`/dkppc/crtls/gcn* $DEVKITPPC/$target/lib/
cp `pwd`/dkpppc/crtls/ogc.ld $DEVKITPPC/$target/lib/
cp `pwd`/dkppc/crtls/specs $DEVKITPPC/lib/gcc/$target/$GCC_VER/specs
echo "building libogc ..."
cd $LIBOGC_SRCDIR
$MAKE
echo "installing libogc ..."
$MAKE install
#---------------------------------------------------------------------------------
# copy base rulesets
#---------------------------------------------------------------------------------
cd $BUILDSCRIPTDIR
cp dkp-rules/* $DEVKITPPC

View File

@ -0,0 +1,93 @@
#!/bin/sh
#---------------------------------------------------------------------------------
# Check Parameters
#---------------------------------------------------------------------------------
prefix=$INSTALLDIR/devkitPPC
#---------------------------------------------------------------------------------
# build and install binutils
#---------------------------------------------------------------------------------
mkdir -p $target/binutils
cd $target/binutils
../../$BINUTILS_SRCDIR/configure \
--prefix=$prefix --target=$target --disable-nls --disable-shared --disable-debug \
--with-gcc --with-gnu-as --with-gnu-ld --with-stabs \
2>&1 | tee binutils_configure.log
$MAKE | tee binutils_make.log 2>&1
$MAKE install | tee binutils_install.log 2>&1
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/binutils
rm -fr $BINUTILS_SRCDIR
#---------------------------------------------------------------------------------
# build and install just the c compiler
#---------------------------------------------------------------------------------
mkdir -p $target/gcc
cd $target/gcc
../../$GCC_SRCDIR/configure \
--enable-languages=c,c++ \
--with-cpu=750\
--with-gcc --with-gnu-ld --with-gnu-as --with-stabs \
--with-included-gettext --without-headers\
--disable-nls --disable-shared --enable-threads --disable-multilib\
--disable-win32-registry\
--target=$target \
--with-newlib \
--prefix=$prefix -v\
2>&1 | tee gcc_configure.log
$MAKE all-gcc | tee gcc_make.log 2>&1
$MAKE install-gcc | tee gcc_install.log 2>&1
#---------------------------------------------------------------------------------
# build and install newlib
#---------------------------------------------------------------------------------
cd $BUILDSCRIPTDIR
mkdir -p $target/newlib
cd $target/newlib
mkdir -p etc
$BUILDSCRIPTDIR/$NEWLIB_SRCDIR/configure --target=$target \
--prefix=$prefix \
--enable-serial-configure \
| tee newlib_configure.log 2>&1
$MAKE all | tee newlib_make.log
$MAKE install | tee newlib_install.log
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/newlib
rm -fr $NEWLIB_SRCDIR
#---------------------------------------------------------------------------------
# build and install the final compiler
#---------------------------------------------------------------------------------
cd $target/gcc
$MAKE | tee gcc_final_make.log 2>&1
$MAKE install | tee gcc_final_install.log 2>&1
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/gcc
rm -fr $GCC_SRCDIR

View File

@ -0,0 +1,15 @@
#!/bin/sh
#---------------------------------------------------------------------------------
# Install and build the pspsdk
#---------------------------------------------------------------------------------
echo "building pspsdk ..."
cd $PSPSDK_SRCDIR
$MAKE
echo "installing pspsdk ..."
$MAKE install
cd $BUILDSCRIPTDIR

View File

@ -0,0 +1,94 @@
#!/bin/sh
#---------------------------------------------------------------------------------
# Check Parameters
#---------------------------------------------------------------------------------
prefix=$INSTALLDIR/devkitPSP
#---------------------------------------------------------------------------------
# build and install binutils
#---------------------------------------------------------------------------------
#mkdir -p $target/binutils
#cd $target/binutils
../../$BINUTILS_SRCDIR/configure \
--prefix=$prefix --target=$target --disable-nls --disable-shared --disable-debug \
--disable-threads --with-gcc --with-gnu-as --with-gnu-ld --with-stabs \
2>&1 | tee $BUILDSCRIPTDIR/binutils_configure.log
$MAKE 2>&1 | tee binutils_make.log
$MAKE install 2>&1 | tee $BUILDSCRIPTDIR/binutils_install.log
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/binutils
rm -fr $BINUTILS_SRCDIR
#---------------------------------------------------------------------------------
# build and install just the c compiler
#---------------------------------------------------------------------------------
mkdir -p $target/gcc
cd $target/gcc
../../$GCC_SRCDIR/configure \
--enable-languages=c,c++ \
--disable-multilib\
--with-gcc --with-gnu-ld --with-gnu-as --with-stabs \
--disable-shared --disable-threads --disable-win32-registry --disable-nls\
--enable-cxx-flags="-G0" \
--target=$target \
--with-newlib \
--prefix=$prefix \
2>&1 | tee $BUILDSCRIPTDIR/gcc_configure.log
$MAKE all-gcc 2>&1| tee $BUILDSCRIPTDIR/gcc_make.log
$MAKE install-gcc 2>&1 | tee $BUILDSCRIPTDIR/gcc_install.log
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# build and install newlib
#---------------------------------------------------------------------------------
mkdir -p $target/newlib
cd $target/newlib
$BUILDSCRIPTDIR/$NEWLIB_SRCDIR/configure \
--enable-serial-configure \
--target=$target \
--prefix=$prefix \
| tee $BUILDSCRIPTDIR/newlib_configure.log
mkdir -p etc
$MAKE
$MAKE install
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/newlib
rm -fr $NEWLIB_SRCDIR
#---------------------------------------------------------------------------------
# build and install the final compiler
#---------------------------------------------------------------------------------
cd $BUILDSCRIPTDIR
cd $target/gcc
$MAKE | tee $BUILDSCRIPTDIR/gcc_final_make.log 2>&1
$MAKE install | tee $BUILDSCRIPTDIR/gcc_final_install.log 2>&1
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/gcc
rm -fr $GCC_SRCDIR

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
diff -NBaur newlib-1.13.0/config.sub newlib-1.13.0-new/config.sub
diff -Nbaur newlib-1.13.0/config.sub newlib-1.13.0-new/config.sub
--- newlib-1.13.0/config.sub Tue Nov 16 01:18:39 2004
+++ newlib-1.13.0-new/config.sub Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/config.sub Mon Jul 4 23:31:59 2005
@@ -219,6 +219,9 @@
basic_machine=m68k-atari
os=-mint
@ -11,9 +11,62 @@ diff -NBaur newlib-1.13.0/config.sub newlib-1.13.0-new/config.sub
esac
# Decode aliases for certain CPU-COMPANY combinations.
diff -NBaur newlib-1.13.0/newlib/configure.host newlib-1.13.0-new/newlib/configure.host
@@ -253,6 +256,7 @@
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
+ | mipsallegrex | mipsallegrexel \
| mn10200 | mn10300 \
| msp430 \
| ns16k | ns32k \
@@ -326,6 +330,7 @@
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
+ | mipsallegrex-* | mipsallegrexel-* \
| mmix-* \
| msp430-* \
| none-* | np1-* | ns16k-* | ns32k-* \
@@ -664,6 +669,10 @@
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
+ ;;
+ psp)
+ basic_machine=mipsallegrexel-psp
+ os=-elf
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
diff -Nbaur newlib-1.13.0/configure newlib-1.13.0-new/configure
--- newlib-1.13.0/configure Thu Dec 16 19:51:28 2004
+++ newlib-1.13.0-new/configure Mon Jul 4 23:31:59 2005
@@ -1507,6 +1507,9 @@
mips*-*-linux*)
noconfigdirs="$noconfigdirs target-newlib target-libgloss"
;;
+ mipsallegrex*-*-*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
mips*-*-*)
noconfigdirs="$noconfigdirs gprof ${libgcj}"
;;
diff -Nbaur newlib-1.13.0/configure.in newlib-1.13.0-new/configure.in
--- newlib-1.13.0/configure.in Thu Dec 16 19:51:28 2004
+++ newlib-1.13.0-new/configure.in Mon Jul 4 23:31:59 2005
@@ -716,6 +716,9 @@
mips*-*-linux*)
noconfigdirs="$noconfigdirs target-newlib target-libgloss"
;;
+ mipsallegrex*-*-*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
mips*-*-*)
noconfigdirs="$noconfigdirs gprof ${libgcj}"
;;
diff -Nbaur newlib-1.13.0/newlib/configure.host newlib-1.13.0-new/newlib/configure.host
--- newlib-1.13.0/newlib/configure.host Tue Oct 5 20:44:24 2004
+++ newlib-1.13.0-new/newlib/configure.host Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/configure.host Mon Jul 4 23:31:59 2005
@@ -389,6 +389,9 @@
powerpcle-*-pe)
posix_dir=posix
@ -24,9 +77,20 @@ diff -NBaur newlib-1.13.0/newlib/configure.host newlib-1.13.0-new/newlib/configu
sh*-*)
sys_dir=sh
;;
diff -NBaur newlib-1.13.0/newlib/libc/sys/arm/Makefile.in newlib-1.13.0-new/newlib/libc/sys/arm/Makefile.in
@@ -569,6 +572,10 @@
newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
;;
mips*-*-elf*)
+ case "${host}" in
+ mipsallegrex*)
+ newlib_cflags="${newlib_cflags} -G0 -DPREFER_SIZE_OVER_SPEED -DCOMPACT_CTYPE" ;;
+ esac
default_newlib_io_long_long="yes"
newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
;;
diff -Nbaur newlib-1.13.0/newlib/libc/sys/arm/Makefile.in newlib-1.13.0-new/newlib/libc/sys/arm/Makefile.in
--- newlib-1.13.0/newlib/libc/sys/arm/Makefile.in Wed Jun 9 20:05:09 2004
+++ newlib-1.13.0-new/newlib/libc/sys/arm/Makefile.in Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/arm/Makefile.in Mon Jul 4 23:30:01 2005
@@ -88,7 +88,7 @@
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
@ -36,15 +100,15 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/arm/Makefile.in newlib-1.13.0-new/newl
@MAY_SUPPLY_SYSCALLS_FALSE@extra_objs =
lib_a_SOURCES = libcfunc.c trap.S
diff -NBaur newlib-1.13.0/newlib/libc/sys/arm/malloc_vars.c newlib-1.13.0-new/newlib/libc/sys/arm/malloc_vars.c
diff -Nbaur newlib-1.13.0/newlib/libc/sys/arm/malloc_vars.c newlib-1.13.0-new/newlib/libc/sys/arm/malloc_vars.c
--- newlib-1.13.0/newlib/libc/sys/arm/malloc_vars.c Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/arm/malloc_vars.c Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/arm/malloc_vars.c Mon Jul 4 23:30:01 2005
@@ -0,0 +1,2 @@
+char *fake_heap_end = (char*)0;
+char *fake_heap_start = (char*)0;
diff -NBaur newlib-1.13.0/newlib/libc/sys/arm/syscalls.c newlib-1.13.0-new/newlib/libc/sys/arm/syscalls.c
diff -Nbaur newlib-1.13.0/newlib/libc/sys/arm/syscalls.c newlib-1.13.0-new/newlib/libc/sys/arm/syscalls.c
--- newlib-1.13.0/newlib/libc/sys/arm/syscalls.c Tue Jan 6 19:27:21 2004
+++ newlib-1.13.0-new/newlib/libc/sys/arm/syscalls.c Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/arm/syscalls.c Mon Jul 4 23:30:01 2005
@@ -474,19 +474,41 @@
n = n;
}
@ -88,9 +152,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/arm/syscalls.c newlib-1.13.0-new/newli
{
/* Some of the libstdc++-v3 tests rely upon detecting
out of memory errors, so do not abort here. */
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.am newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.am
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.am newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.am
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.am Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.am Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.am Mon Jul 4 23:30:01 2005
@@ -0,0 +1,19 @@
+## Process this file with automake to generate Makefile.in
+
@ -111,9 +175,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.am newlib-1.13.0-new
+
+ACLOCAL_AMFLAGS = -I ../../..
+CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.in newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.in
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.in newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.in
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.in Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.in Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/Makefile.in Mon Jul 4 23:30:01 2005
@@ -0,0 +1,341 @@
+# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+
@ -456,9 +520,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/Makefile.in newlib-1.13.0-new
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/aclocal.m4 newlib-1.13.0-new/newlib/libc/sys/ppcgekko/aclocal.m4
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/aclocal.m4 newlib-1.13.0-new/newlib/libc/sys/ppcgekko/aclocal.m4
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/aclocal.m4 Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/aclocal.m4 Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/aclocal.m4 Mon Jul 4 23:30:01 2005
@@ -0,0 +1,382 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4-p6
+
@ -842,9 +906,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/aclocal.m4 newlib-1.13.0-new/
+]
+)
+
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/configure newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/configure newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/configure Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure Mon Jul 4 23:30:01 2005
@@ -0,0 +1,1906 @@
+#! /bin/sh
+
@ -2752,9 +2816,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/configure newlib-1.13.0-new/n
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/configure.in newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure.in
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/configure.in newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure.in
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/configure.in Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure.in Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/configure.in Mon Jul 4 23:30:01 2005
@@ -0,0 +1,12 @@
+dnl This is the newlib/libc/sys/ppcgekko configure.in file.
+dnl Process this file with autoconf to produce a configure script.
@ -2768,23 +2832,23 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/configure.in newlib-1.13.0-ne
+NEWLIB_CONFIGURE(../../..)
+
+AC_OUTPUT(Makefile)
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/crt0.c newlib-1.13.0-new/newlib/libc/sys/ppcgekko/crt0.c
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/crt0.c newlib-1.13.0-new/newlib/libc/sys/ppcgekko/crt0.c
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/crt0.c Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/crt0.c Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/crt0.c Mon Jul 4 23:30:01 2005
@@ -0,0 +1,4 @@
+/* I have a copy of something that would serve as a NetWare crt0.o,
+ but it is copyright by Novell. */
+
+int _dummy_crt0 = 1;
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/include/newlib.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/include/newlib.h
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/include/newlib.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/include/newlib.h
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/include/newlib.h Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/include/newlib.h Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/include/newlib.h Mon Jul 4 23:30:01 2005
@@ -0,0 +1,2 @@
+/* dummy file for external tools to use. Real file is created by
+ newlib configuration. */
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/malloc.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/malloc.h
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/malloc.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/malloc.h
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/malloc.h Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/malloc.h Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/malloc.h Mon Jul 4 23:30:01 2005
@@ -0,0 +1,8 @@
+#ifndef _MACHMALLOC_H_
+#define _MACHMALLOC_H_
@ -2794,9 +2858,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/malloc.h newlib-1.13.
+#endif /* _MACHMALLOC_H_ */
+
+
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/stdlib.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/stdlib.h
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/stdlib.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/stdlib.h
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/stdlib.h Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/stdlib.h Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/machine/stdlib.h Mon Jul 4 23:30:01 2005
@@ -0,0 +1,8 @@
+#ifndef _MACHSTDLIB_H_
+#define _MACHSTDLIB_H_
@ -2806,9 +2870,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/machine/stdlib.h newlib-1.13.
+#endif /* _MACHSTDLIB_H_ */
+
+
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/lock.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/lock.h
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/lock.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/lock.h
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/lock.h Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/lock.h Thu Apr 14 09:04:31 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/lock.h Mon Jul 4 23:30:01 2005
@@ -0,0 +1,53 @@
+#ifndef __SYS_LOCK_H__
+#define __SYS_LOCK_H__
@ -2863,9 +2927,9 @@ diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/lock.h newlib-1.13.0-new/
+extern int __libc_lock_release(int*);
+
+#endif /* __SYS_LOCK_H__ */
diff -NBaur newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/stdio.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/stdio.h
diff -Nbaur newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/stdio.h newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/stdio.h
--- newlib-1.13.0/newlib/libc/sys/ppcgekko/sys/stdio.h Thu Jan 1 00:00:00 1970
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/stdio.h Sun Feb 27 12:17:44 2005
+++ newlib-1.13.0-new/newlib/libc/sys/ppcgekko/sys/stdio.h Mon Jul 4 23:30:02 2005
@@ -0,0 +1,25 @@
+#ifndef _NEWLIB_STDIO_H
+#define _NEWLIB_STDIO_H

View File

@ -0,0 +1,42 @@
diff -NBaur pspsdk-1.0+beta/tools/psp-config.c pspsdk-1.0+beta-new/tools/psp-config.c
--- pspsdk-1.0+beta/tools/psp-config.c Mon Jun 27 06:31:22 2005
+++ pspsdk-1.0+beta-new/tools/psp-config.c Tue Jul 5 04:54:45 2005
@@ -17,8 +19,17 @@
#define PATH_SEP ":"
#define DIR_SEP '/'
#define DIR_SEP_STR "/"
+
+#ifdef __MINGW32__
+
+/* The suffix to the path to strip off, if this is not there then we have an error */
+#define PSPDEV_PATH_SUFFIX "/bin/psp-config.exe"
+#else
+
/* The suffix to the path to strip off, if this is not there then we have an error */
#define PSPDEV_PATH_SUFFIX "/bin/psp-config"
+
+#endif
/************************/
/* Speficies that the current usage is to the print the pspsdk path */
@@ -70,6 +81,20 @@
int found = 0;
/* Check if name is an absolute path, if so out job is done */
+#ifdef __MINGW32__
+
+ char *ptr = name;
+
+ char temp = name[0];
+ *(ptr++) = '/';
+ *(ptr++) = temp;
+ while (*(ptr)) {
+ temp = *(ptr);
+ if (temp == '\\') *(ptr) = '/';
+ ptr++;
+ }
+
+#endif
if(name[0] == DIR_SEP)
{
/* Absolute path */