summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-03-03 23:20:32 +0000
committerThomas Martitz <kugel@rockbox.org>2010-03-03 23:20:32 +0000
commitf8edc325896c9c24d7f32f4861a0b0d2a8b9f4cd (patch)
treeb2682307d01fffb54dd68e54b8f2e2986fe6bcc6 /firmware/target/arm
parente479853f1542616dab56817c8f5326364b663c7c (diff)
FS#10756 - Free unused init code
Introduce a new .init section for initialisation code, so that it can be copied to an area which is later overwritten before calling. The stack/bss can then overwrite that code, effectively freeing the code size that the initialisation routines need. Gives a few kB ram usage back. Only implemented for PP and as3525 so far. More targets could be added, as well as more functions. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25013 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/as3525/app.lds14
-rw-r--r--firmware/target/arm/crt0-pp.S13
-rw-r--r--firmware/target/arm/crt0.S21
-rw-r--r--firmware/target/arm/sandisk/app.lds16
4 files changed, 58 insertions, 6 deletions
diff --git a/firmware/target/arm/as3525/app.lds b/firmware/target/arm/as3525/app.lds
index eb5b28f852..6e610d6e15 100644
--- a/firmware/target/arm/as3525/app.lds
+++ b/firmware/target/arm/as3525/app.lds
@@ -99,6 +99,8 @@ SECTIONS
_iramend = .;
} > IRAM AT> DRAM
+ _iramcopy = LOADADDR(.iram);
+
.ibss (NOLOAD) :
{
_iedata = .;
@@ -108,9 +110,17 @@ SECTIONS
_iend = .;
} > IRAM
- _iramcopy = LOADADDR(.iram);
+ .init ENDAUDIOADDR :
+ {
+ . = ALIGN(4);
+ _initstart = .;
+ *(.init)
+ _initend = .;
+ } AT> DRAM
+
+ _initcopy = LOADADDR(.init);
- .stack (NOLOAD) :
+ .stack _iramcopy (NOLOAD) :
{
*(.stack)
stackbegin = .;
diff --git a/firmware/target/arm/crt0-pp.S b/firmware/target/arm/crt0-pp.S
index 9c996960cc..4e16df0f7a 100644
--- a/firmware/target/arm/crt0-pp.S
+++ b/firmware/target/arm/crt0-pp.S
@@ -213,6 +213,19 @@ cpu_init:
strhi r5, [r3], #4
bhi 1b
+#ifdef INIT_ATTR
+ /* copy init code to codec buffer */
+ ldr r2, =_initstart
+ ldr r3, =_initend
+ ldr r4, =_initcopy
+
+1:
+ cmp r3, r2
+ ldrhi r5, [r4], #4
+ strhi r5, [r2], #4
+ bhi 1b
+#endif
+
/* Zero out IBSS */
ldr r2, =_iedata
ldr r3, =_iend
diff --git a/firmware/target/arm/crt0.S b/firmware/target/arm/crt0.S
index 238cfdd65a..6284bcb16c 100644
--- a/firmware/target/arm/crt0.S
+++ b/firmware/target/arm/crt0.S
@@ -71,6 +71,7 @@ newstart:
bhi 1b
/* Copy the IRAM */
+ /* must be done before bss is zeroed */
ldr r2, =_iramcopy
ldr r3, =_iramstart
ldr r4, =_iramend
@@ -79,6 +80,23 @@ newstart:
ldrhi r5, [r2], #4
strhi r5, [r3], #4
bhi 1b
+
+#endif
+
+#ifdef INIT_ATTR
+ /* copy init data to codec buffer */
+ /* must be done before bss is zeroed */
+ ldr r2, =_initcopy
+ ldr r3, =_initstart
+ ldr r4, =_initend
+1:
+ cmp r4, r3
+ ldrhi r5, [r2], #4
+ strhi r5, [r3], #4
+ bhi 1b
+
+ mov r2, #0
+ mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache
#endif
/* Initialise bss section to zero */
@@ -89,7 +107,7 @@ newstart:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
-
+
/* Set up some stack and munge it with 0xdeadbeef */
ldr sp, =stackend
ldr r2, =stackbegin
@@ -115,7 +133,6 @@ newstart:
/* Switch back to supervisor mode */
msr cpsr_c, #0xd3
-
bl main
diff --git a/firmware/target/arm/sandisk/app.lds b/firmware/target/arm/sandisk/app.lds
index 3010644b72..ec26fdbe38 100644
--- a/firmware/target/arm/sandisk/app.lds
+++ b/firmware/target/arm/sandisk/app.lds
@@ -37,8 +37,8 @@ STARTUP(target/arm/crt0-pp.o)
MEMORY
{
- DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
- IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
+ DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
+ IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
}
SECTIONS
@@ -126,6 +126,17 @@ SECTIONS
_iramcopy = LOADADDR(.iram);
+
+ .init ENDAUDIOADDR :
+ {
+ . = ALIGN(4);
+ _initstart = .;
+ *(.init)
+ _initend = .;
+ } AT> DRAM
+
+ _initcopy = LOADADDR(.init);
+
.idle_stacks (NOLOAD) :
{
*(.idle_stacks)
@@ -175,6 +186,7 @@ SECTIONS
.audiobuf (NOLOAD) :
{
_audiobuffer = .;
+ . = ALIGN(0x4);
audiobuffer = .;
} > DRAM