summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2012-02-28 15:51:09 +0100
committerMarcin Bukat <marcin.bukat@gmail.com>2012-03-04 00:33:27 +0100
commit1c565c9c3b5005ca1f1708040718e35a0cf69e88 (patch)
tree08bb4784b691e14086380f8c278be83367c2a64a
parent7569450d8ecf3551bc9caa4c3c85e5633c2ab370 (diff)
downloadrockbox-1c565c9c3b5005ca1f1708040718e35a0cf69e88.zip
rockbox-1c565c9c3b5005ca1f1708040718e35a0cf69e88.tar.gz
rockbox-1c565c9c3b5005ca1f1708040718e35a0cf69e88.tar.bz2
rockbox-1c565c9c3b5005ca1f1708040718e35a0cf69e88.tar.xz
rk27xx: rework linker scripts and crt0.S
Change-Id: Id1d509056026bc67e1a5051c60818336933d4aeb
-rw-r--r--firmware/target/arm/rk27xx/app.lds35
-rw-r--r--firmware/target/arm/rk27xx/boot.lds43
-rw-r--r--firmware/target/arm/rk27xx/crt0.S81
3 files changed, 77 insertions, 82 deletions
diff --git a/firmware/target/arm/rk27xx/app.lds b/firmware/target/arm/rk27xx/app.lds
index 080c74f..1675da4 100644
--- a/firmware/target/arm/rk27xx/app.lds
+++ b/firmware/target/arm/rk27xx/app.lds
@@ -37,42 +37,28 @@ SECTIONS
.intvect : {
_intvectstart = . ;
- *(.intvect)
- _intvectend = _newstart ;
+ KEEP(*(.intvect))
+ _intvectend = . ;
} > IRAM AT > DRAM
- _intvectcopy = LOADADDR(.intvect) ;
+ _intvectcopy = LOADADDR(.intvect);
.text : {
*(.init.text)
*(.text*)
+ *(.icode*)
*(.glue_7*)
} > DRAM
- .data : {
+ .rodata : {
*(.rodata*)
- *(.data*)
- *(.ncdata*);
+ *(.irodata*)
. = ALIGN(0x4);
} > DRAM
- .iram :
- {
- _iramstart = .;
- *(.icode)
- *(.irodata)
- *(.idata)
- . = ALIGN(0x4);
- _iramend = .;
- } > DRAM
- _iramcopy = LOADADDR(.iram) ;
-
- .ibss (NOLOAD) :
- {
- _iedata = .;
- *(.qharray)
- *(.ibss)
- . = ALIGN(0x4);
- _iend = .;
+ .data : {
+ *(.data*)
+ *(.idata*)
+ . = ALIGN(0x4);
} > DRAM
.stack (NOLOAD) :
@@ -95,7 +81,6 @@ SECTIONS
_edata = .;
*(.bss*);
*(.ibss);
- *(.ncbss*);
*(COMMON);
. = ALIGN(0x4);
_end = .;
diff --git a/firmware/target/arm/rk27xx/boot.lds b/firmware/target/arm/rk27xx/boot.lds
index b7bc9be..5e25d12 100644
--- a/firmware/target/arm/rk27xx/boot.lds
+++ b/firmware/target/arm/rk27xx/boot.lds
@@ -9,8 +9,8 @@ OUTPUT_FORMAT(elf32-bigarm)
OUTPUT_ARCH(arm)
STARTUP(target/arm/rk27xx/crt0.o)
-#define DRAMORIG 0x60000000
-#define DRAMSIZE (MEMORYSIZE * 0x100000)
+#define DRAMORIG 0x60700000
+#define DRAMSIZE (MEMORYSIZE * 0x100000 - 0x700000)
#define IRAMORIG 0x00000000
#define IRAMSIZE 4K
@@ -23,35 +23,39 @@ MEMORY
SECTIONS
{
- .intvect : {
- _intvectstart = . ;
- *(.intvect)
- _intvectend = _newstart ;
- } > IRAM AT > DRAM
- _intvectcopy = LOADADDR(.intvect) ;
+ .relocstart (NOLOAD) : {
+ _relocstart = .;
+ } > DRAM
.text : {
*(.init.text)
*(.text*)
+ *(.icode*)
*(.glue_7*)
+ } > DRAM
+
+ .intvect : {
+ _intvectstart = . ;
+ KEEP(*(.intvect))
+ _intvectend = . ;
+ } > IRAM AT > DRAM
+ _intvectcopy = LOADADDR(.intvect) ;
+
+ .rodata : {
+ *(.rodata*)
+ *(.irodata*)
+ . = ALIGN(0x4);
} > DRAM
.data : {
- *(.rodata*)
*(.data*)
- *(.ncdata*);
+ *(.idata*)
. = ALIGN(0x4);
} > DRAM
- .idata : {
- _datastart = . ;
- *(.irodata)
- *(.icode)
- *(.idata)
- . = ALIGN(0x4);
- _dataend = . ;
- } > DRAM
- _datacopy = LOADADDR(.idata) ;
+ .relocend (NOLOAD) : {
+ _relocend = .;
+ } > DRAM
.stack (NOLOAD) :
{
@@ -73,7 +77,6 @@ SECTIONS
_edata = .;
*(.bss*);
*(.ibss);
- *(.ncbss*);
*(COMMON);
. = ALIGN(0x4);
_end = .;
diff --git a/firmware/target/arm/rk27xx/crt0.S b/firmware/target/arm/rk27xx/crt0.S
index 23f3fcf..1bbd46a 100644
--- a/firmware/target/arm/rk27xx/crt0.S
+++ b/firmware/target/arm/rk27xx/crt0.S
@@ -5,7 +5,6 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id: crt0.S 18776 2008-10-11 18:32:17Z gevaerts $
*
* Copyright (C) 2008 by Marcoen Hirschberg
* Copyright (C) 2008 by Denes Balatoni
@@ -24,26 +23,50 @@
#include "config.h"
#include "cpu.h"
- .section .intvect,"ax",%progbits
- .global start
- .global _newstart
+ .global start
+ .global entry_point
+
/* Exception vectors */
-start:
- b _newstart
- ldr pc, =undef_instr_handler
- ldr pc, =software_int_handler
- ldr pc, =prefetch_abort_handler
- ldr pc, =data_abort_handler
- ldr pc, =reserved_handler
- ldr pc, =irq_handler
- ldr pc, =fiq_handler
+ .section .intvect,"ax",%progbits
+ ldr pc, =start
+ ldr pc, =undef_instr_handler
+ ldr pc, =software_int_handler
+ ldr pc, =prefetch_abort_handler
+ ldr pc, =data_abort_handler
+ ldr pc, =reserved_handler
+ ldr pc, =irq_handler
+ ldr pc, =fiq_handler
.ltorg
-_newstart:
- ldr pc, =newstart2
- .section .init.text,"ax",%progbits
-newstart2:
- msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
+ .text
+start:
+ msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
+
+#ifdef BOOTLOADER
+ sub r4, pc, #12 /* copy running address, accomodate
+ * for prefetch (-8) and msr instr (-4)
+ */
+
+ ldr r0, =0xefff0000 /* cache controler base address */
+ ldrh r1, [r0]
+ strh r1, [r0] /* global cache disable */
+
+ ldr r2, =_relocstart
+ ldr r3, =_relocend
+
+ cmp r2, r4
+ beq entry_point /* skip copying if we are in place already */
+1:
+ cmp r3, r2
+ ldrhi r1, [r4], #4
+ strhi r1, [r2], #4
+ bhi 1b
+
+entry_point_jmp:
+ ldr pc, =entry_point
+#endif
+
+entry_point:
mov r0, #0x18000000
add r0, r0, #0x1c000
@@ -135,26 +158,14 @@ newstart2:
strhi r4, [r2], #4
bhi 1b
-#ifndef BOOTLOADER
- /* Copy icode and data to ram */
- ldr r2, =_iramstart
- ldr r3, =_iramend
- ldr r4, =_iramcopy
-1:
- cmp r3, r2
- ldrhi r1, [r4], #4
- strhi r1, [r2], #4
- bhi 1b
-
- /* Initialise ibss section to zero */
- ldr r2, =_iedata
- ldr r3, =_iend
+ /* Initialise bss, ibss section to zero */
+ ldr r2, =_edata
+ ldr r3, =_end
mov r4, #0
1:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
-#endif
/* Set up stack for IRQ mode */
msr cpsr_c, #0xd2
@@ -184,12 +195,8 @@ newstart2:
strhi r3, [r2], #4
bhi 1b
-
bl main
- .text
-/* .global UIE*/
-
/* All illegal exceptions call into UIE with exception address as first
* parameter. This is calculated differently depending on which exception
* we're in. Second parameter is exception number, used for a string lookup