* startup/bspgetworkarea.c: Removed file.
	* Makefile.am, bsp_specs, start/start.S, startup/bspstart.c,
	libnds/include/nds/jtypes.h, libnds/source/arm9/gurumeditation.c,
	libnds/source/common/interruptDispatcher.S,
	libnds/source/common/interrupts.c, startup/linkcmds: Use linker
	command base file.
This commit is contained in:
Sebastian Huber
2010-12-03 10:49:50 +00:00
parent 90cc2ec8b2
commit f2d1c4db2f
11 changed files with 69 additions and 303 deletions

View File

@@ -1,3 +1,12 @@
2010-12-03 Sebastian Huber <sebastian.huber@embedded-brains.de>
* startup/bspgetworkarea.c: Removed file.
* Makefile.am, bsp_specs, start/start.S, startup/bspstart.c,
libnds/include/nds/jtypes.h, libnds/source/arm9/gurumeditation.c,
libnds/source/common/interruptDispatcher.S,
libnds/source/common/interrupts.c, startup/linkcmds: Use linker
command base file.
2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de> 2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
* make/dswifi/arm9/makefile: Workaround for GCC bug 38644. * make/dswifi/arm9/makefile: Workaround for GCC bug 38644.

View File

@@ -37,7 +37,7 @@ include_nds_HEADERS = touchscreen/touchscreen.h sound/sound.h
noinst_PROGRAMS += startup.rel noinst_PROGRAMS += startup.rel
startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \ startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
startup/bspstart.c ../../shared/bspclean.c startup/bspreset.c \ startup/bspstart.c ../../shared/bspclean.c startup/bspreset.c \
startup/bspgetworkarea.c ../../shared/bsppredriverhook.c \ ../../shared/bspgetworkarea.c ../../shared/bsppredriverhook.c \
../../shared/bsppretaskinghook.c ../../shared/bootcard.c ../../shared/bsppretaskinghook.c ../../shared/bootcard.c
startup_rel_CPPFLAGS = $(AM_CPPFLAGS) -DARM9 -I$(srcdir)/libnds/include startup_rel_CPPFLAGS = $(AM_CPPFLAGS) -DARM9 -I$(srcdir)/libnds/include
startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)

View File

@@ -7,8 +7,7 @@
%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}} %{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}
*link: *link:
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -Bstatic -N} %{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile: *endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s } %{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -38,9 +38,9 @@
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// libgba compatible section macros // libgba compatible section macros
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
#define ITCM_CODE __attribute__((section(".itcm"), long_call)) #define ITCM_CODE __attribute__((section(".bsp_fast_text"), long_call))
#define DTCM_DATA __attribute__((section(".dtcm"))) #define DTCM_DATA __attribute__((section(".bsp_fast_data")))
#define DTCM_BSS __attribute__((section(".sbss"))) #define DTCM_BSS __attribute__((section(".sbss")))
#define ALIGN(m) __attribute__((aligned (m))) #define ALIGN(m) __attribute__((aligned (m)))

View File

@@ -34,6 +34,8 @@
#include <stdio.h> #include <stdio.h>
#include <inttypes.h> #include <inttypes.h>
#include <bsp/linker-symbols.h>
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
unsigned long ARMShift(unsigned long value,unsigned char shift) { unsigned long ARMShift(unsigned long value,unsigned char shift) {
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
@@ -205,7 +207,6 @@ static const char *registerNames[] =
{ "r0","r1","r2","r3","r4","r5","r6","r7", { "r0","r1","r2","r3","r4","r5","r6","r7",
"r8 ","r9 ","r10","r11","r12","sp ","lr ","pc " }; "r8 ","r9 ","r10","r11","r12","sp ","lr ","pc " };
extern const char __itcm_start[];
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
static void defaultHandler(void) { static void defaultHandler(void) {
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
@@ -232,7 +233,7 @@ static void defaultHandler(void) {
iprintf ("\x1b[10Cdata abort!\n\n"); iprintf ("\x1b[10Cdata abort!\n\n");
codeAddress = exceptionRegisters[15] - offset; codeAddress = exceptionRegisters[15] - offset;
if ( (codeAddress > 0x02000000 && codeAddress < 0x02400000) || if ( (codeAddress > 0x02000000 && codeAddress < 0x02400000) ||
(codeAddress > (u32)__itcm_start && codeAddress < (u32)(__itcm_start + 32768)) ) (codeAddress > (u32)bsp_section_fast_text_begin && codeAddress < (u32)(bsp_section_fast_text_begin + 32768)) )
exceptionAddress = getExceptionAddress( codeAddress, thumbState); exceptionAddress = getExceptionAddress( codeAddress, thumbState);
else else
exceptionAddress = codeAddress; exceptionAddress = codeAddress;

View File

@@ -28,7 +28,7 @@
#endif #endif
#ifdef ARM9 #ifdef ARM9
.section .itcm,"ax",%progbits .section .bsp_fast_text,"ax",%progbits
#endif #endif
.extern irqTable .extern irqTable

View File

@@ -34,7 +34,7 @@ void irqDummy(void) {}
#ifdef ARM9 #ifdef ARM9
#define INT_TABLE_SECTION __attribute__((section(".itcm"))) #define INT_TABLE_SECTION __attribute__((section(".bsp_fast_text")))
#else #else
#define INT_TABLE_SECTION #define INT_TABLE_SECTION
#endif #endif

View File

@@ -1,3 +1,5 @@
#include <bsp/linker-symbols.h>
@--------------------------------------------------------------------------------- @---------------------------------------------------------------------------------
@ DS processor selection @ DS processor selection
@--------------------------------------------------------------------------------- @---------------------------------------------------------------------------------
@@ -73,9 +75,9 @@ _start:
@ Wait for write buffer to empty @ Wait for write buffer to empty
mcr p15, 0, r0, c7, c10, 4 mcr p15, 0, r0, c7, c10, 4
ldr r0, =__dtcm_start ldr r0, =bsp_section_fast_data_begin
orr r0,r0,#0x0a orr r0,r0,#0x0a
mcr p15, 0, r0, c9, c1,0 @ DTCM base = __dtcm_start, size = 16 KB mcr p15, 0, r0, c9, c1,0 @ DTCM base = bsp_section_fast_data_begin, size = 16 KB
mov r0,#0x20 mov r0,#0x20
mcr p15, 0, r0, c9, c1,1 @ ITCM base = 0 , size = 32 MB mcr p15, 0, r0, c9, c1,1 @ ITCM base = 0 , size = 32 MB
@@ -111,14 +113,14 @@ _start:
@------------------------------------------------------------------------- @-------------------------------------------------------------------------
@ Region 4 - DTCM @ Region 4 - DTCM
@------------------------------------------------------------------------- @-------------------------------------------------------------------------
ldr r0,=__dtcm_start ldr r0,=bsp_section_fast_data_begin
orr r0,r0,#(PAGE_16K | 1) orr r0,r0,#(PAGE_16K | 1)
mcr p15, 0, r0, c6, c4, 0 mcr p15, 0, r0, c6, c4, 0
@------------------------------------------------------------------------- @-------------------------------------------------------------------------
@ Region 5 - ITCM @ Region 5 - ITCM
@------------------------------------------------------------------------- @-------------------------------------------------------------------------
ldr r0,=__itcm_start ldr r0,=bsp_section_fast_text_begin
orr r0,r0,#(PAGE_32K | 1) orr r0,r0,#(PAGE_32K | 1)
mcr p15, 0, r0, c6, c5, 0 mcr p15, 0, r0, c6, c5, 0
@@ -169,24 +171,24 @@ _start:
mov r0, #0x12 @ Switch to IRQ Mode mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0 msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack ldr sp, =bsp_stack_irq_end @ Set IRQ stack
mov r0, #0x1f @ Switch to SVC Mode mov r0, #0x1f @ Switch to SVC Mode
msr cpsr, r0 msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack ldr sp, =bsp_stack_svc_end @ Set user stack
ldr r1, =__itcm_lma @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM) ldr r1, =bsp_section_fast_text_load_begin @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
ldr r2, =__itcm_start ldr r2, =bsp_section_fast_text_begin
ldr r4, =__itcm_end ldr r4, =bsp_section_fast_text_end
bl CopyMemCheck bl CopyMemCheck
ldr r1, =__dtcm_lma @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM) ldr r1, =bsp_section_fast_data_load_begin @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
ldr r2, =__dtcm_start ldr r2, =bsp_section_fast_data_begin
ldr r4, =__dtcm_end ldr r4, =bsp_section_fast_data_end
bl CopyMemCheck bl CopyMemCheck
ldr r0, =__bss_start @ Clear BSS section ldr r0, =bsp_section_bss_begin @ Clear BSS section
ldr r1, =__bss_end ldr r1, =bsp_section_bss_end
sub r1, r1, r0 sub r1, r1, r0
bl ClearMem bl ClearMem

View File

@@ -1,36 +0,0 @@
/*
* 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$
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <stdint.h>
/*
* These are from the linker script.
*/
extern void * _end;
extern void *__ewram_end;
/*
* This method returns the base address and size of the area which
* is to be allocated between the RTEMS Workspace and the C Program
* Heap.
*/
void bsp_get_work_area(
void **work_area_start,
uintptr_t *work_area_size,
void **heap_start,
uintptr_t *heap_size
)
{
*work_area_start = &_end;
*work_area_size = (void *)&__ewram_end - (void *)&_end;
*heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
*heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
}

View File

@@ -13,6 +13,7 @@
#include <bsp.h> #include <bsp.h>
#include <bsp/bootcard.h> #include <bsp/bootcard.h>
#include <bsp/linker-symbols.h>
#include <nds.h> #include <nds.h>
extern void BSP_rtems_irq_mngt_init (void); extern void BSP_rtems_irq_mngt_init (void);
@@ -50,14 +51,11 @@ void bsp_start (void)
* reset bss area. * reset bss area.
*/ */
extern uint8_t __bss_start;
extern uint8_t __bss_end;
void void
bss_reset (void) bss_reset (void)
{ {
memset (&__bss_start, 0, (uint32_t) & __bss_end - (uint32_t) & __bss_start); memset (bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
} }
/* /*

View File

@@ -1,246 +1,39 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY { MEMORY {
ROM : ORIGIN = 0x08000000, LENGTH = 32M
rom : ORIGIN = 0x08000000, LENGTH = 32M EWRAM : ORIGIN = 0x02000000, LENGTH = 4M - 4k
ewram : ORIGIN = 0x02000000, LENGTH = 4M - 4k DTCM : ORIGIN = 0x0b000000, LENGTH = 16k
dtcm : ORIGIN = 0x0b000000, LENGTH = 16K ITCM : ORIGIN = 0x01000000, LENGTH = 16k
itcm : ORIGIN = 0x01000000, LENGTH = 32K NIRVANA : ORIGIN = 0, LENGTH = 0
} }
__itcm_start = ORIGIN(itcm); REGION_ALIAS ("REGION_START", EWRAM);
__ewram_end = ORIGIN(ewram) + LENGTH(ewram); REGION_ALIAS ("REGION_VECTOR", DTCM);
__eheap_end = ORIGIN(ewram) + LENGTH(ewram); REGION_ALIAS ("REGION_TEXT", EWRAM);
__dtcm_start = ORIGIN(dtcm); REGION_ALIAS ("REGION_TEXT_LOAD", EWRAM);
__dtcm_top = ORIGIN(dtcm) + LENGTH(dtcm); REGION_ALIAS ("REGION_RODATA", EWRAM);
REGION_ALIAS ("REGION_RODATA_LOAD", EWRAM);
REGION_ALIAS ("REGION_DATA", EWRAM);
REGION_ALIAS ("REGION_DATA_LOAD", EWRAM);
REGION_ALIAS ("REGION_FAST_TEXT", ITCM);
REGION_ALIAS ("REGION_FAST_TEXT_LOAD", EWRAM);
REGION_ALIAS ("REGION_FAST_DATA", DTCM);
REGION_ALIAS ("REGION_FAST_DATA_LOAD", EWRAM);
REGION_ALIAS ("REGION_BSS", EWRAM);
REGION_ALIAS ("REGION_WORK", EWRAM);
REGION_ALIAS ("REGION_STACK", EWRAM);
__dtcm_top = ORIGIN (DTCM) + LENGTH (DTCM);
__irq_flags = __dtcm_top - 0x08; __irq_flags = __dtcm_top - 0x08;
__irq_vector = __dtcm_top - 0x04; __irq_vector = __dtcm_top - 0x04;
__sp_svc = __dtcm_top - 0x100; SECTIONS {
__sp_irq = __sp_svc - 0x100; .sbss : {
__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): */
{
*(EXCLUDE_FILE (*.itcm*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
/*
* Special FreeBSD sysctl sections.
*/
. = ALIGN (16);
__start_set_sysctl_set = .;
*(set_sysctl_*);
__stop_set_sysctl_set = ABSOLUTE(.);
*(set_domain_*);
*(set_pseudo_*);
. = 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
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ewram
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ewram
__exidx_end = .;
/* 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 : { KEEP (*(.preinit_array)) } >ewram = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >ewram = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >ewram = 0xff
PROVIDE (__fini_array_end = .);
.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) *(.rel.got) } >ewram = 0
.ewram ALIGN(4) :
{
__ewram_start = ABSOLUTE(.) ;
*(.ewram)
*ewram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.data ALIGN(4) :
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
__data_end = ABSOLUTE(.) ;
} >ewram = 0xff
__dtcm_lma = . ;
.dtcm __dtcm_start : AT (__dtcm_lma)
{
*(.dtcm)
*(.dtcm.*)
. = ALIGN(4);
__dtcm_end = ABSOLUTE(.);
} >dtcm = 0xff
__itcm_lma = __dtcm_lma + SIZEOF(.dtcm);
.itcm __itcm_start : AT (__itcm_lma)
{
*(.itcm)
*itcm.*(.text)
. = ALIGN(4);
__itcm_end = ABSOLUTE(.);
} >itcm = 0xff
.sbss __dtcm_end :
{
__sbss_start = ABSOLUTE(.); __sbss_start = ABSOLUTE(.);
__sbss_start__ = ABSOLUTE(.); __sbss_start__ = ABSOLUTE(.);
*(.sbss) *(.sbss)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */ . = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__sbss_end = ABSOLUTE(.); __sbss_end = ABSOLUTE(.);
} >dtcm } > DTCM
__bss_lma = __itcm_lma + SIZEOF(.itcm) ;
__appended_data = __itcm_lma + SIZEOF(.itcm) ;
.bss __bss_lma : AT (__bss_lma)
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__bss_end = ABSOLUTE(.) ;
__bss_end__ = __bss_end ;
} >ewram
_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 . */
} }
INCLUDE linkcmds.armv4