summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-01-10 08:56:40 +0100
committerMarcin Bukat <marcin.bukat@gmail.com>2014-01-10 09:01:08 +0100
commit9cd3444e272bbffc5ca6dcf172577b0e7885a3d2 (patch)
treee606ccba81fa96bbe21abc5e78ba688566fd762d
parent837cad0d382e5600e68bb4ed6d499e6053fa50e5 (diff)
downloadrockbox-9cd3444e272bbffc5ca6dcf172577b0e7885a3d2.tar.gz
rockbox-9cd3444e272bbffc5ca6dcf172577b0e7885a3d2.zip
rk27xx: Implement HAVE_INIT_ATTR magic
This reclaims over 7kB of ram. Change-Id: I4a89c9a673ada7959311f320900060f6db303c07
-rw-r--r--firmware/export/config.h3
-rw-r--r--firmware/target/arm/rk27xx/app.lds35
-rw-r--r--firmware/target/arm/rk27xx/crt0.S14
3 files changed, 42 insertions, 10 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 702a58811c..50b5ee4e43 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -981,7 +981,8 @@ Lyre prototype 1 */
981#endif 981#endif
982 982
983#if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \ 983#if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \
984 (CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233)) \ 984 (CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233) || \
985 (CONFIG_CPU == RK27XX)) \
985 && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) 986 && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER)
986/* Functions that have INIT_ATTR attached are NOT guaranteed to survive after 987/* Functions that have INIT_ATTR attached are NOT guaranteed to survive after
987 * root_menu() has been called. Their code may be overwritten by other data or 988 * root_menu() has been called. Their code may be overwritten by other data or
diff --git a/firmware/target/arm/rk27xx/app.lds b/firmware/target/arm/rk27xx/app.lds
index 1675da491c..fb2cc54db6 100644
--- a/firmware/target/arm/rk27xx/app.lds
+++ b/firmware/target/arm/rk27xx/app.lds
@@ -22,6 +22,10 @@ STARTUP(target/arm/rk27xx/crt0.o)
22#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 22#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
23#define CODECORIG (ENDAUDIOADDR) 23#define CODECORIG (ENDAUDIOADDR)
24 24
25/* .init is copied to codec buffer */
26#define INITORIG CODECORIG
27#define INITSIZE CODECSIZE
28
25/* Where the codec buffer ends, and the plugin buffer starts */ 29/* Where the codec buffer ends, and the plugin buffer starts */
26#define ENDADDR (ENDAUDIOADDR + CODECSIZE) 30#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
27 31
@@ -29,21 +33,14 @@ MEMORY
29{ 33{
30 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE 34 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
31 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE 35 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
36 INIT : ORIGIN = INITORIG, LENGTH = INITSIZE
32} 37}
33 38
34SECTIONS 39SECTIONS
35{ 40{
36 loadaddress = DRAMORIG; 41 loadaddress = DRAMORIG;
37 42
38 .intvect : {
39 _intvectstart = . ;
40 KEEP(*(.intvect))
41 _intvectend = . ;
42 } > IRAM AT > DRAM
43 _intvectcopy = LOADADDR(.intvect);
44
45 .text : { 43 .text : {
46 *(.init.text)
47 *(.text*) 44 *(.text*)
48 *(.icode*) 45 *(.icode*)
49 *(.glue_7*) 46 *(.glue_7*)
@@ -61,7 +58,27 @@ SECTIONS
61 . = ALIGN(0x4); 58 . = ALIGN(0x4);
62 } > DRAM 59 } > DRAM
63 60
64 .stack (NOLOAD) : 61 /* NOLOAD sections at end start here. Any part of the binary image past
62 * this point is discarded or copied elsewhere. */
63 _noloaddram = .;
64
65 .intvect : {
66 _intvectstart = . ;
67 KEEP(*(.intvect))
68 _intvectend = . ;
69 } > IRAM AT > DRAM
70 _intvectcopy = LOADADDR(.intvect);
71
72 .init : {
73 . = ALIGN(4);
74 _initstart = .;
75 *(.init*)
76 *(.initdata*)
77 _initend = .;
78 } > INIT AT > DRAM
79 _initcopy = LOADADDR(.init);
80
81 .stack _noloaddram (NOLOAD) :
65 { 82 {
66 *(.stack) 83 *(.stack)
67 _stackbegin = .; 84 _stackbegin = .;
diff --git a/firmware/target/arm/rk27xx/crt0.S b/firmware/target/arm/rk27xx/crt0.S
index 2a6b2cc329..fb5f02dbdc 100644
--- a/firmware/target/arm/rk27xx/crt0.S
+++ b/firmware/target/arm/rk27xx/crt0.S
@@ -149,6 +149,20 @@ entry_point:
149 strhi r1, [r2], #4 149 strhi r1, [r2], #4
150 bhi 1b 150 bhi 1b
151 151
152#ifdef HAVE_INIT_ATTR
153 /* Copy init section to the codec buffer
154 * before .bss zeroing
155 */
156 ldr r2, =_initstart
157 ldr r3, =_initend
158 ldr r4, =_initcopy
1591:
160 cmp r3, r2
161 ldrhi r1, [r4], #4
162 strhi r1, [r2], #4
163 bhi 1b
164#endif
165
152 /* Initialise bss, ibss section to zero */ 166 /* Initialise bss, ibss section to zero */
153 ldr r2, =_edata 167 ldr r2, =_edata
154 ldr r3, =_end 168 ldr r3, =_end