summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-01-10 21:46:43 +0100
committerMarcin Bukat <marcin.bukat@gmail.com>2014-01-17 19:03:06 +0100
commitb31c856b842096e5128a86a8316083190527d467 (patch)
tree648a14c99b81f279d2cc6767f262d27ed5abc1e0
parentd55e5698e587dda405ec53cceb6f3642768bd198 (diff)
downloadrockbox-b31c856b842096e5128a86a8316083190527d467.tar.gz
rockbox-b31c856b842096e5128a86a8316083190527d467.zip
coldfire: Implement HAVE_INIT_ATTR magic
This reclaims ~6kB of ram. Change-Id: Iafdc661b1cf4445669c08c79205043792b8d14c3 Reviewed-on: http://gerrit.rockbox.org/718 Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/target/coldfire/app.lds17
-rw-r--r--firmware/target/coldfire/crt0.S13
3 files changed, 29 insertions, 3 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 50b5ee4e43..89e0036947 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -982,7 +982,7 @@ Lyre prototype 1 */
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_CPU == RK27XX) || defined(CPU_COLDFIRE)) \
986 && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) 986 && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER)
987/* 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
988 * 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/coldfire/app.lds b/firmware/target/coldfire/app.lds
index 5364157fdd..457c71c97c 100644
--- a/firmware/target/coldfire/app.lds
+++ b/firmware/target/coldfire/app.lds
@@ -20,6 +20,11 @@ STARTUP(target/coldfire/crt0.o)
20 20
21/* End of the audio buffer, where the codec buffer starts */ 21/* End of the audio buffer, where the codec buffer starts */
22#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 22#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
23#define CODECORIG ENDAUDIOADDR
24
25/* .init is copied to codec buffer */
26#define INITORIG CODECORIG
27#define INITSIZE CODECSIZE
23 28
24/* Where the codec buffer ends, and the plugin buffer starts */ 29/* Where the codec buffer ends, and the plugin buffer starts */
25#define ENDADDR (ENDAUDIOADDR + CODECSIZE) 30#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
@@ -28,6 +33,7 @@ MEMORY
28{ 33{
29 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE 34 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
30 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE 35 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
36 INIT : ORIGIN = INITORIG, LENGTH = INITSIZE
31} 37}
32 38
33SECTIONS 39SECTIONS
@@ -45,7 +51,7 @@ SECTIONS
45 .text : 51 .text :
46 { 52 {
47 . = ALIGN(0x200); 53 . = ALIGN(0x200);
48 *(.init.text) 54 KEEP(*(.startup*));
49 *(.text*) 55 *(.text*)
50 . = ALIGN(0x4); 56 . = ALIGN(0x4);
51 } > DRAM 57 } > DRAM
@@ -90,6 +96,15 @@ SECTIONS
90 _iramcopy = LOADADDR(.iram); 96 _iramcopy = LOADADDR(.iram);
91 _noloaddram = LOADADDR(.iram); 97 _noloaddram = LOADADDR(.iram);
92 98
99 .init :
100 {
101 _initstart = .;
102 *(.init*)
103 *(.initdata*)
104 _initend = .;
105 } > INIT AT > DRAM
106 _initcopy = LOADADDR(.init);
107
93 .ibss (NOLOAD) : 108 .ibss (NOLOAD) :
94 { 109 {
95 _iedata = .; 110 _iedata = .;
diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S
index 881fcf908f..5e73131894 100644
--- a/firmware/target/coldfire/crt0.S
+++ b/firmware/target/coldfire/crt0.S
@@ -21,7 +21,7 @@
21#include "config.h" 21#include "config.h"
22#include "cpu.h" 22#include "cpu.h"
23 23
24 .section .init.text,"ax",@progbits 24 .section .startup,"ax",@progbits
25 25
26 .global start 26 .global start
27start: 27start:
@@ -290,6 +290,17 @@ start:
290 /* .iram copy is done first since it is reclaimed for other 290 /* .iram copy is done first since it is reclaimed for other
291 * uninitialized sections */ 291 * uninitialized sections */
292 292
293 /* copy .init section */
294 lea _initcopy,%a2
295 lea _initstart,%a3
296 lea _initend,%a4
297 bra.b .initstart
298.initloop:
299 move.l (%a2)+,(%a3)+
300.initstart:
301 cmp.l %a3,%a4
302 bhi.b .initloop
303
293 /* copy the .iram section */ 304 /* copy the .iram section */
294 lea _iramcopy,%a2 305 lea _iramcopy,%a2
295 lea _iramstart,%a3 306 lea _iramstart,%a3