summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/gba/startup
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2005-07-06 18:46:04 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2005-07-06 18:46:04 +0000
commit3c7ed6b8cd505f696c9c2b6d90723094f334b348 (patch)
tree30da596d32865c2d042ece5735d16baeade7d17d /c/src/lib/libbsp/arm/gba/startup
parente9b4f29a409d9dc192a85dbbe693aeb1fa87e43b (diff)
downloadrtems-3c7ed6b8cd505f696c9c2b6d90723094f334b348.tar.bz2
2005-07-06 Markku Puro <markku.puro@kopteri.net>
* .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, configure.ac, clock/clockdrv.c, console/conio.c, console/console.c, console/defaultfont.c, include/arm_mode_bits.h, include/asm_macros.h, include/bsp.h, include/bspopts.h.in, include/conio.h, include/gba.h, include/gba_registers.h, include/tm27.h, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, start/logo.S, start/start.S, startup/bspstart.c, startup/cpu.c, startup/cpu_asm.S, startup/exit.c, startup/linkcmds, timer/timer.c: New files.
Diffstat (limited to 'c/src/lib/libbsp/arm/gba/startup')
-rw-r--r--c/src/lib/libbsp/arm/gba/startup/bspstart.c197
-rw-r--r--c/src/lib/libbsp/arm/gba/startup/cpu.c170
-rw-r--r--c/src/lib/libbsp/arm/gba/startup/cpu_asm.S86
-rw-r--r--c/src/lib/libbsp/arm/gba/startup/exit.c54
-rw-r--r--c/src/lib/libbsp/arm/gba/startup/linkcmds348
5 files changed, 855 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/gba/startup/bspstart.c b/c/src/lib/libbsp/arm/gba/startup/bspstart.c
new file mode 100644
index 0000000000..e21effe7d0
--- /dev/null
+++ b/c/src/lib/libbsp/arm/gba/startup/bspstart.c
@@ -0,0 +1,197 @@
+/**
+ * @file bspstart.c
+ *
+ * This file contains the GBA BSP startup package.
+ * It includes application, board, and monitor specific initialization and
+ * configuration. The generic CPU dependent initialization has been
+ * performed before this routine is invoked.
+ */
+/*
+ * RTEMS GBA BSP
+ *
+ * Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <bsp.h>
+#include <rtems/bspIo.h>
+#include <rtems/libio.h>
+#include <rtems/libcsupport.h>
+#include <gba.h>
+#include <conio.h>
+
+#define BSP_DEBUG 0
+
+/* Global Variables, Defined in 'linkcmds' */
+extern void _end;
+extern void _stack_size;
+extern void _irq_max_vector;
+extern void __heap_limit;
+extern void __ro_start;
+extern void __ro_end;
+extern void __data_start;
+extern void __data_end;
+extern void __load_start_data;
+extern void __load_stop_data;
+extern void __ewram_start;
+extern void __ewram_end;
+extern void __load_start_ewram;
+extern void __load_stop_ewram;
+extern void __iwram_start;
+extern void __iwram_end;
+extern void __load_start_iwram;
+extern void __load_stop_iwram;
+extern void __bss_start;
+extern void __bss_end;
+
+/** The original BSP configuration table from the application. */
+extern rtems_configuration_table Configuration;
+/** Our copy of BSP configuration table from the application. */
+rtems_configuration_table BSP_Configuration;
+
+/* External Prototypes */
+extern void bsp_cleanup( void );
+extern void rtems_irq_mngt_init(void);
+extern void bsp_libc_init( void *, rtems_unsigned32, int );
+extern void bsp_postdriver_hook(void);
+
+
+/** Chip registers */
+volatile unsigned int *Regs = (unsigned int *)GBA_IO_REGS_ADDR;
+
+/**
+ * Size of heap if it is 0 it will be dynamically defined by memory size,
+ * otherwise the value should be changed by binary patch
+ */
+rtems_unsigned32 _heap_size = 0;
+
+/** Address of start of free memory - should be updated after creating new partitions or regions.*/
+rtems_unsigned32 rtemsFreeMemStart;
+
+/** CPU configuration table. */
+rtems_cpu_table Cpu_table;
+/** Program name - from main(). */
+char *rtems_progname;
+
+
+/**
+ * @brief BSP pretasking hook.
+ *
+ * Called just before drivers are initialized.
+ * Used to setup libc and install any BSP extensions.
+ *
+ * NOTE: Must not use libc (to do io) from here, since drivers are not yet initialized.
+ *
+ * @param None
+ * @return None
+ */
+void bsp_pretasking_hook(void)
+{
+
+ if (_heap_size == 0) {
+ _heap_size = (rtems_unsigned32)&__heap_limit - rtemsFreeMemStart;
+ }
+
+ bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
+
+ rtemsFreeMemStart += _heap_size;
+
+
+#ifdef RTEMS_DEBUG
+ rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
+#endif /* RTEMS_DEBUG */
+
+#if BSP_DEBUG
+ /* The following information is very useful when debugging. */
+ printk("[bsp_pretasking_hook]\n");
+ printk("_heap_size = 0x%x\n", _heap_size);
+ printk("_stack_size = 0x%x\n", (rtems_unsigned32)&_stack_size);
+ printk("_irq_max_vector = 0x%x\n", (rtems_unsigned32)&_irq_max_vector);
+ printk("__ro_start = 0x%x : __ro_end = 0x%x\n", (rtems_unsigned32)&__ro_start, (rtems_unsigned32)&__ro_end);
+ printk("__ewram_start = 0x%x : __ewram_end = 0x%x\n", (rtems_unsigned32)&__ewram_start, (rtems_unsigned32)&__ewram_end);
+ printk("__data_start = 0x%x : __data_end = 0x%x\n", (rtems_unsigned32)&__data_start, (rtems_unsigned32)&__data_end);
+ printk("__bss_start = 0x%x : __bss_end = 0x%x\n", (rtems_unsigned32)&__bss_start,(rtems_unsigned32)&__bss_end);
+ printk("__iwram_start = 0x%x : __iwram_end = 0x%x\n", (rtems_unsigned32)&__iwram_start,(rtems_unsigned32)&__iwram_end);
+ printk("__load_start_iwram = 0x%x\n", (rtems_unsigned32)&__load_start_iwram);
+ printk("__load_stop_iwram = 0x%x\n", (rtems_unsigned32)&__load_stop_iwram);
+ printk("__load_start_ewram = 0x%x\n", (rtems_unsigned32)&__load_start_ewram);
+ printk("__load_stop_ewram = 0x%x\n", (rtems_unsigned32)&__load_stop_ewram);
+ printk("__load_start_data = 0x%x\n", (rtems_unsigned32)&__load_start_data);
+ printk("__load_stop_data = 0x%x\n", (rtems_unsigned32)&__load_stop_data);
+#endif
+}
+
+
+/**
+ * @brief BSP Start
+ *
+ * Called before main is invoked.
+ *
+ * @param None
+ * @return None
+ */
+void bsp_start_default( void )
+{
+ /* set the value of start of free memory. */
+ rtemsFreeMemStart = (rtems_unsigned32)&_end;
+
+ /* If we don't have command line arguments set default program name. */
+ Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
+ Cpu_table.predriver_hook = NULL; /* use system's */
+ Cpu_table.postdriver_hook = bsp_postdriver_hook;
+ Cpu_table.idle_task = NULL; /* don't override system IDLE task */
+ Cpu_table.do_zero_of_workspace = TRUE;
+ Cpu_table.interrupt_stack_size = 0;
+ Cpu_table.extra_mpci_receive_server_stack = 0;
+
+
+ /* Place RTEMS workspace at beginning of free memory. */
+ BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
+ rtemsFreeMemStart += BSP_Configuration.work_space_size;
+
+ /* Init conio */
+ gba_textmode(CO60);
+
+ /* Init rtems exceptions management */
+ /*!!!!!GBA - Can't use exception vectors in GBA because they are already in GBA ROM BIOS */
+ /* rtems_exception_init_mngt(); */
+
+ /* Init rtems interrupt management */
+ rtems_irq_mngt_init();
+
+#if BSP_DEBUG
+ /* The following information is very useful when debugging. */
+ printk("[bsp_start]\n");
+ printk("rtemsFreeMemStart= 0x%x\n", rtemsFreeMemStart);
+ printk("__heap_limit = 0x%x\n", (rtems_unsigned32)&__heap_limit);
+ printk("work_space_start = 0x%x size = 0x%x\n", BSP_Configuration.work_space_start,BSP_Configuration.work_space_size);
+ printk("maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions);
+ printk("microseconds_per_tick = 0x%x\n", BSP_Configuration.microseconds_per_tick);
+ printk("ticks_per_timeslice = 0x%x\n", BSP_Configuration.ticks_per_timeslice);
+ printk("maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices);
+ printk("number_of_device_drivers = 0x%x\n", BSP_Configuration.number_of_device_drivers);
+ printk("Device_driver_table = 0x%x\n", BSP_Configuration.Device_driver_table);
+#endif
+
+ /* Do we have enough memory */
+ if ((rtems_unsigned32)&__heap_limit < rtemsFreeMemStart) {
+ printk("\nFatal Error: Memory overflow[0x%x]!\n",rtemsFreeMemStart);
+ bsp_cleanup();
+ }
+
+}
+
+
+/**
+ * @brief weak alias for bsp_start_default
+ *
+ * By making this a weak alias for bsp_start_default, a brave soul
+ * can override the actual bsp_start routine used.
+ */
+void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
diff --git a/c/src/lib/libbsp/arm/gba/startup/cpu.c b/c/src/lib/libbsp/arm/gba/startup/cpu.c
new file mode 100644
index 0000000000..3ce8e5de42
--- /dev/null
+++ b/c/src/lib/libbsp/arm/gba/startup/cpu.c
@@ -0,0 +1,170 @@
+/**
+ * @file cpu.c
+ *
+ * ARM CPU Dependent Source.
+ */
+/*
+ * RTEMS GBA BSP
+ *
+ * COPYRIGHT (c) 2000 Canon Research Centre France SA.
+ * Emmanuel Raguet, mailto:raguet@crf.canon.fr
+ *
+ * Copyright (c) 2002 Advent Networks, Inc
+ * Jay Monkman <jmonkman@adventnetworks.com>
+ *
+ * Copyright (c) 2004
+ * Markku Puro <markku.puro@kopteri.net>
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+#include <stdint.h>
+#include <rtems/system.h>
+#include <rtems.h>
+#include <rtems/bspIo.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/wkspace.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/cpu.h>
+#include <arm_mode_bits.h>
+
+/**
+ * @brief _CPU_Initialize routine performs processor dependent initialization
+ *
+ * @param cpu_table CPU table to initialize
+ * @param thread_dispatch address of ISR disptaching routine (unused)
+ * @return None
+ */
+void _CPU_Initialize(
+ rtems_cpu_table *cpu_table,
+ void (*thread_dispatch) /* ignored on this CPU */
+)
+{
+ _CPU_Table = *cpu_table;
+}
+
+/**
+ * @brief _CPU_ISR_Get_level returns the current interrupt level
+ *
+ * @param None
+ * @return int level
+ */
+uint32_t _CPU_ISR_Get_level( void )
+{
+ uint32_t reg = 0; /* to avoid warning */
+
+ asm volatile ("mrs %0, cpsr \n" \
+ "and %0, %0, #0xc0 \n" \
+ : "=r" (reg) \
+ : "0" (reg) );
+ return reg;
+}
+
+
+/**
+ * @brief _CPU_ISR_install_vector kernel routine installs the RTEMS handler for the
+ * specified vector
+ *
+ * @param vector interrupt vector number
+ * @param new_handler replacement ISR for this vector number
+ * @param old_handler pointer to store former ISR for this vector number
+ * @return None
+ *
+ * @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!!
+ */
+extern __inline__ void _CPU_ISR_install_vector(uint32_t vector, proc_ptr new_handler, proc_ptr *old_handler);
+
+/**
+ * @brief _CPU_Context_Initialize kernel routine initialize the specified context
+ *
+ * @param the_context
+ * @param stack_base
+ * @param size
+ * @param new_level
+ * @param entry_point
+ * @param is_fp
+ * @return None
+ */
+void _CPU_Context_Initialize(
+ Context_Control *the_context,
+ uint32_t *stack_base,
+ uint32_t size,
+ uint32_t new_level,
+ void *entry_point,
+ boolean is_fp
+)
+{
+ the_context->register_sp = (uint32_t)stack_base + size ;
+ the_context->register_lr = (uint32_t)entry_point;
+ the_context->register_cpsr = new_level | ModePriv;
+}
+
+
+/**
+ * @brief _CPU_Install_interrupt_stack function is empty since the BSP must set up the interrupt stacks.
+ *
+ * @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!!
+ */
+extern __inline__ void _CPU_Install_interrupt_stack( void );
+
+/**
+ * @brief _defaultExcHandler function is empty
+ *
+ * @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!!
+ */
+extern void _defaultExcHandler (CPU_Exception_frame *ctx);
+
+/**
+ * @brief _currentExcHandler function is empty (_defaultExcHandler)
+ *
+ * @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!!
+ */
+cpuExcHandlerType _currentExcHandler = _defaultExcHandler;
+/*
+extern void _Exception_Handler_Undef_Swi();
+extern void _Exception_Handler_Abort();
+extern void _exc_data_abort();
+*/
+
+/**
+ * @brief rtems_exception_init_mngt function is empty since the BSP must set up the interrupt stacks.
+ *
+ * @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!!
+ */
+extern __inline__ void rtems_exception_init_mngt();
+
+
+/**
+ * @brief do_data_abort function is empty
+ *
+ * This function figure out what caused the data abort
+ *
+ * @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!!
+ * This function is supposed to figure out what caused the data abort, do that, then return.
+ * All unhandled instructions cause the system to hang.
+ */
+extern __inline__ void do_data_abort(uint32_t insn, uint32_t spsr, CPU_Exception_frame *ctx);
+
+
+/* @todo Can't use exception vectors in GBA because they are already in GBA ROM BIOS!! */
+/* @todo Remove dummy functions needed by linker
+ ****************************************************************************************/
+/* @cond INCLUDE_ASM */
+asm (" .text");
+asm (" .arm");
+asm (" .global _CPU_ISR_install_vector");
+asm ("_CPU_ISR_install_vector:");
+asm (" .global _CPU_Install_interrupt_stack");
+asm ("_CPU_Install_interrupt_stack:");
+asm (" .global _defaultExcHandler");
+asm ("_defaultExcHandler:");
+asm (" .global rtems_exception_init_mngt");
+asm ("rtems_exception_init_mngt:");
+asm (" .global do_data_abort");
+asm ("do_data_abort:");
+asm (" mov pc, lr");
+/* @endcond */
+
diff --git a/c/src/lib/libbsp/arm/gba/startup/cpu_asm.S b/c/src/lib/libbsp/arm/gba/startup/cpu_asm.S
new file mode 100644
index 0000000000..d4ea836960
--- /dev/null
+++ b/c/src/lib/libbsp/arm/gba/startup/cpu_asm.S
@@ -0,0 +1,86 @@
+/**
+ * @file cpu_asm.S
+ *
+ * This file contains the implementation of exception handlers.
+ */
+/*
+ * RTEMS GBA BSP
+ *
+ * Copyright (c) 2002 by Advent Networks, Inc.
+ * Jay Monkman <jmonkman@adventnetworks.com>
+ *
+ * COPYRIGHT (c) 2000 Canon Research Centre France SA.
+ * Emmanuel Raguet, mailto:raguet@crf.canon.fr
+ *
+ * Copyright (c) 2004
+ * Markku Puro <markku.puro@kopteri.net>
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#define __asm__
+#include <rtems/asm.h>
+#include <rtems/score/cpu_asm.h>
+#include <asm_macros.h>
+/* @cond INCLUDE_ASM */
+
+/**
+ * This routine performs a normal non-FP context.
+ * function void _CPU_Context_switch( run_context, heir_context )
+ * R0 = run_context R1 = heir_context
+ *
+ * This function copies the current registers to where r0 points, then
+ * restores the ones from where r1 points.
+ *
+ * Using the ldm/stm opcodes save 2-3 us on 100 MHz ARM9TDMI with
+ * a 16 bit data bus.
+ *
+ */
+ .align
+/* .section .iwram */
+PUBLIC_ARM_FUNCTION(_CPU_Context_switch)
+/* Start saving context */
+ mrs r2, cpsr
+ stmia r0, {r2, r4, r5, r6, r7, r8, r9, r10, r11, r13, r14}
+/* Start restoring context */
+_restore:
+ ldmia r1, {r2, r4, r5, r6, r7, r8, r9, r10, r11, r13, r14}
+ msr cpsr, r2
+ mov pc, lr
+LABEL_END(_CPU_Context_switch)
+
+/**
+ * This function copies the restores the registers from where r0 points.
+ * function void _CPU_Context_restore( new_context )
+ * It must match _CPU_Context_switch()
+ *
+ */
+PUBLIC_ARM_FUNCTION(_CPU_Context_restore)
+ mov r1, r0
+ b _restore
+LABEL_END(_CPU_Context_restore)
+
+/**
+ * function _Exception_Handler_Undef_Swi
+ * Can't use exception vectors in GBA
+ * @todo _Exception_Handler_Undef_Swi: Unused handler needed by ../score/cpu_asm.S
+ *
+ */
+ .global _Exception_Handler_Undef_Swi
+_Exception_Handler_Undef_Swi:
+ mov pc, lr
+
+/**
+ * function _Exception_Handler_Abort
+ * Can't use exception vectors in GBA
+ * @todo _Exception_Handler_Abort: Unused handler needed by ../score/cpu_asm.S
+ *
+ */
+ .global _Exception_Handler_Abort
+_Exception_Handler_Abort:
+ mov pc, lr
+/* @endcond */
diff --git a/c/src/lib/libbsp/arm/gba/startup/exit.c b/c/src/lib/libbsp/arm/gba/startup/exit.c
new file mode 100644
index 0000000000..d5fa3789ae
--- /dev/null
+++ b/c/src/lib/libbsp/arm/gba/startup/exit.c
@@ -0,0 +1,54 @@
+/**
+ * @file exit.c
+ *
+ * Routines to shutdown and reboot the BSP.
+ */
+/*
+ * RTEMS GBA BSP
+ *
+ * Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <bsp.h>
+#include <rtems/bspIo.h>
+#include <rtems/libio.h>
+#include <gba.h>
+
+
+/**
+ * @brief rtemsReboot BSP routine reboot rtems
+ *
+ * Input parameters: None
+ *
+ * Output parameters: None
+ */
+void rtemsReboot (void)
+{
+ asm volatile ("ldr r0, =_gba_reset");
+ asm volatile ("bx r0");
+}
+
+/**
+ * @brief bsp_cleanup BSP routine wait input from user for rebooting
+ *
+ * Normally at this point, the console driver is disconnected => we must
+ * use polled output/input. This is exactly what printk does.
+ *
+ * @param None
+ * @return None
+ */
+void bsp_cleanup(void)
+{
+ static const char line[]="\nEXECUTIVE SHUTDOWN! Press button to reboot...";
+ printk("\n");
+ printk("%s",line);
+ while ( !GBA_ANY_KEY(GBA_KEY_ALL) );
+ rtemsReboot();
+}
diff --git a/c/src/lib/libbsp/arm/gba/startup/linkcmds b/c/src/lib/libbsp/arm/gba/startup/linkcmds
new file mode 100644
index 0000000000..b985e9c6ab
--- /dev/null
+++ b/c/src/lib/libbsp/arm/gba/startup/linkcmds
@@ -0,0 +1,348 @@
+/**
+ * @file linkcmds
+ *
+ * GBA BSP linker script
+ */
+/*
+ * RTEMS GBA BSP
+ *
+ * Copyright (c) Jeff Frohwein
+ *
+ * Copyright (c) 2003 Jason Wilkins
+ *
+ * Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ *
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+/*****************************************************************************
+ * This Linker Script is based on work by Jeff Frohwein and Jason Wilkins
+ *****************************************************************************
+ * Linker Script v1.3 by Jeff Frohwein
+ * :
+ * This file is released into the public domain
+ * for commercial or non-commercial use with no
+ * restrictions placed upon it.
+ *****************************************************************************
+ * Copyright 2003, Jason Wilkins. This source code is free for any use except
+ * that this copyright notice and the following disclaimers remain intact when
+ * the source is distributed. There are absolutely no restrictions on use of
+ * object code generated from this source, but the disclaimers remain in force.
+ *
+ * THIS CODE WAS NOT MADE IN ASSOCIATION WITH NINTENDO AND DOES NOT MAKE USE OF
+ * ANY INTELLECTUAL PROPERTY CLAIMED BY NINTENDO.
+ *
+ * GAMEBOY ADVANCE IS A TRADEMARK OF NINTENDO.
+ *
+ * THIS CODE HAS BEEN PROVIDED "AS-IS" WITHOUT A WARRANTY OF ANY KIND, EITHER
+ * EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. THE ENTIRE RISK AS TO THE
+ * QUALITY OR PERFORMANCE OF THE CODE IS WITH YOU.
+ *
+ * IN NO EVENT, UNLESS AGREED TO IN WRITING, WILL ANY COPYRIGHT HOLDER, OR ANY
+ * OTHER PARTY, BE HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OR
+ * INABILITY TO USE THIS CODE.
+ *
+ *****************************************************************************/
+/* @cond INCLUDE_ASM */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+
+/*************************************************************************
+ The linker script MEMORY directive is not used here due to the fact
+ that __ro_start is not always a fixed value.
+ *************************************************************************
+MEMORY
+{
+ rom : ORIGIN = 0x08000000 , LENGTH = 96M
+ iwram : ORIGIN = 0x03000000 , LENGTH = 32K
+ ewram : ORIGIN = 0x02000000 , LENGTH = 256K
+ sram : ORIGIN = 0x0E000000 , LENGTH = 64K
+}
+ *************************************************************************/
+__gba_ewram_start = 0x02000000;
+__gba_ewram_end = 0x02040000;
+__gba_iwram_start = 0x03000000;
+__gba_iwram_end = 0x03008000;
+__gba_rom_start = 0x08000000;
+__gba_rom_end = 0x0E000000;
+__gba_sram_start = 0x0E000000;
+__gba_sram_end = 0x0E010000;
+
+__sp_irq_size = 0x2A0;
+_stack_size = 0xA00;
+__irq_vector = __gba_iwram_end - 0x0004; /* 0x03007FFC */
+__sp_svc = __gba_iwram_end - 0x0020; /* 0x03007FE0 */
+__sp_irq = __gba_iwram_end - 0x0060; /* 0x03007FA0 */
+__sp_usr = __sp_irq - __sp_irq_size; /* 0x03007D00 */
+__sp_limit = __sp_usr - _stack_size; /* 0x03007300 */
+__heap_limit = DEFINED(__gba_multiboot) ? __gba_ewram_end : ( DEFINED(__gba_iwram_bss) ? __sp_limit : __gba_ewram_end ) ;
+
+
+SECTIONS
+{
+/*** read-only sections ***/
+/*************************************************************************
+ if 'multiboot' allocate prog in __gba_ewram_start (0x02000000-0x0207FFFF)
+ else allocate prog in __gba_rom_start (0x08000000-0x0DFFFFFF)
+ *************************************************************************/
+ __ro_start = DEFINED(__gba_multiboot) ? __gba_ewram_start : __gba_rom_start ;
+ PROVIDE(__text_start__ = __ro_start );
+ .text __ro_start :
+ {
+ CREATE_OBJECT_SYMBOLS
+ */start.o(.text)
+ *(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .text)
+ *(.stub .text.* .gnu.linkonce.t*)
+
+ /*
+ * Special FreeBSD sysctl sections.
+ */
+ . = ALIGN (16);
+ __start_set_sysctl_set = .;
+ *(set_sysctl_*);
+ __stop_set_sysctl_set = ABSOLUTE(.);
+ *(set_domain_*);
+ *(set_pseudo_*);
+
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.glue_7)
+ *(.glue_7t)
+ . = ALIGN(4);
+ } =0xFF
+
+ .init :
+ {
+ *(.init)
+ . = ALIGN(4);
+ } =0xFF
+
+ .fini :
+ {
+ *(.fini)
+ . = ALIGN(4);
+ } =0xFF
+
+ __rodata_start = . ;
+ .rodata :
+ {
+ *(.rodata1)
+ *(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .rodata)
+ *(.rodata.* .gnu.linkonce.r*)
+ *(.roda) /* deprecated: for compatibility with objcopyroda */
+ SORT(CONSTRUCTORS)
+ . = ALIGN(4);
+ } =0xFF
+ __rodata_end = . ;
+
+ .eh_frame :
+ {
+ KEEP(*(.eh_frame))
+ . = ALIGN(4);
+ } =0xFF
+
+ .gcc_except_table :
+ {
+ *(.gcc_except_table)
+ . = ALIGN(4);
+ } =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))
+ /* We don't want to include the .ctor section 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))
+ . = ALIGN(4);
+ } =0xFF
+
+ .dtors :
+ {
+ KEEP(*crtbegin.o(.dtors))
+ KEEP(*(EXCLUDE_FILE (*crtend.o ) .dtors))
+ KEEP(*(SORT(.dtors.*)))
+ KEEP(*(.dtors))
+ . = ALIGN(4);
+ } =0xFF
+
+ .jcr :
+ {
+ *(.jcr)
+ . = ALIGN(4);
+ } =0xFF
+
+/*************************************************************************
+ calculate __ro_end
+ *************************************************************************/
+ __ro_end =
+ ADDR(.text) +
+ SIZEOF(.text) +
+ SIZEOF(.init) +
+ SIZEOF(.fini) +
+ SIZEOF(.rodata) +
+ SIZEOF(.eh_frame) +
+ SIZEOF(.gcc_except_table) +
+ SIZEOF(.ctors) +
+ SIZEOF(.dtors) +
+ SIZEOF(.jcr);
+ PROVIDE(__text_end__ = __ro_end );
+
+/*** IWRAM ***/
+/*************************************************************************
+ allocate iwram in __gba_iwram_start (0x03000000-0x03003FFF)
+ *************************************************************************/
+ __load_start_iwram = __ro_end;
+ . = __gba_iwram_start ;
+ __iwram_start = . ;
+ PROVIDE(__iwram_start__ = . );
+ .iwram : AT(__load_start_iwram)
+ {
+ /* put irq_vector_table in stat of iwram */
+ CREATE_OBJECT_SYMBOLS
+ _irq_vector_table = .;
+ PROVIDE(irq_vector_table = .);
+ . += 4;
+ . = ALIGN(16 * 4);
+ PROVIDE(irq_vector_table_end = .);
+ _irq_vector_table_end = .;
+ *(.iwram .iwram.*)
+ *.iwram.o (.text .rodata .data)
+ . = ALIGN(4);
+ } =0xFF
+ __iwram_end = . ;
+ PROVIDE(__iwram_end__ = . );
+ __load_stop_iwram = __load_start_iwram + SIZEOF(.iwram);
+
+ _irq_vector_table_size = _irq_vector_table_end - _irq_vector_table;
+ PROVIDE(_irq_max_vector = _irq_vector_table_size / 4 );
+
+
+/*** EWRAM ***/
+/*************************************************************************
+ if 'multiboot' allocate prog+ewram in __gba_ewram
+ else allocate only ewram in __gba_ewram_start
+ *************************************************************************/
+ . = DEFINED(__gba_multiboot) ? __load_stop_iwram : __gba_ewram_start ;
+ __load_start_ewram = __load_stop_iwram;
+ __ewram_start = . ;
+ PROVIDE(__ewram_start__ = . );
+ .ewram : AT(__load_start_ewram)
+ {
+ *(.ewram .ewram.*)
+ *.ewram.o (.text .rodata .data)
+ . = ALIGN(4);
+ } =0xFF
+ __ewram_end = . ;
+ PROVIDE(__ewram_end__ = . );
+ __load_stop_ewram = __load_start_ewram + SIZEOF(.ewram) ;
+
+/*************************************************************************
+ if 'multiboot' allocate prog+ewram+data+bss in __gba_ewram
+ else if 'iwram_data' allocate data in __gba_iwram
+ else allocate data in __gba_ewram
+ *************************************************************************/
+ . = DEFINED(__gba_multiboot) ? __load_stop_ewram : (DEFINED(__gba_iwram_data) ? __iwram_end : __ewram_end) ;
+ __load_start_data = __load_stop_ewram;
+ __data_start = . ;
+ PROVIDE(__data_start__ = . );
+ .data : AT(__load_start_data)
+ {
+ *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
+ *(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .data)
+ *(.data.* .gnu.linkonce.d.*)
+ *(.data1)
+ *(.tdata .tdata.* .gnu.linkonce.td.*)
+ *(.sdata .sdata.* .gnu.linkonce.s.*)
+ . = ALIGN(4);
+ } =0xFF
+ __data_end = . ;
+ PROVIDE(__data_end__ = . );
+ __load_stop_data = __load_start_data + SIZEOF(.data);
+
+/*** BSS ***/
+/*************************************************************************
+ if 'multiboot' allocate prog+ewram+data+bss in __gba_ewram
+ else if 'iwram_data' and 'iwram_bss' allocate iwram+data+bss in __gba_iwram
+ else if !'iwram_data' and 'iwram_bss' allocate iwram+bss in __gba_iwram
+ else allocate data+ewram+bss in __gba_ewram
+ *************************************************************************/
+ . = DEFINED(__gba_multiboot) ? __load_stop_data : ( DEFINED(__gba_iwram_data) ? (DEFINED(__gba_iwram_bss) ? __data_end : __ewram_end) : (DEFINED(__gba_iwram_bss) ? __iwram_end : __data_end) ) ;
+ __bss_start = . ;
+ PROVIDE(__bss_start__ = . );
+ .bss :
+ {
+ *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
+ *(.tbss .tbss.* .gnu.linkonce.tb.*)
+ *(.tcommon)
+ *(.sbss .sbss.* .gnu.linkonce.sb.*)
+ *(.scommon)
+ *(.bss .bss.* .gnu.linkonce.b*)
+ *(COMMON)
+ . = ALIGN(4);
+ }
+ __bss_end = . ;
+ PROVIDE(__bss_end__ = . );
+ PROVIDE(_bss_end__ = . );
+
+ PROVIDE(_end = . );
+ PROVIDE(__end__ = _end);
+ PROVIDE(end = _end);
+
+
+/*** debugging info ***/
+ /* 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) }
+ /* 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) }
+ .comment 0 : { *(.comment) }
+ /* 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) }
+}
+/* @endcond */