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)
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 */
#if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \
(CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233) || \
- (CONFIG_CPU == RK27XX)) \
+ (CONFIG_CPU == RK27XX) || defined(CPU_COLDFIRE)) \
&& (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER)
/* Functions that have INIT_ATTR attached are NOT guaranteed to survive after
* 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)
/* End of the audio buffer, where the codec buffer starts */
#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
+#define CODECORIG ENDAUDIOADDR
+
+/* .init is copied to codec buffer */
+#define INITORIG CODECORIG
+#define INITSIZE CODECSIZE
/* Where the codec buffer ends, and the plugin buffer starts */
#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
@@ -28,6 +33,7 @@ MEMORY
{
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
+ INIT : ORIGIN = INITORIG, LENGTH = INITSIZE
}
SECTIONS
@@ -45,7 +51,7 @@ SECTIONS
.text :
{
. = ALIGN(0x200);
- *(.init.text)
+ KEEP(*(.startup*));
*(.text*)
. = ALIGN(0x4);
} > DRAM
@@ -90,6 +96,15 @@ SECTIONS
_iramcopy = LOADADDR(.iram);
_noloaddram = LOADADDR(.iram);
+ .init :
+ {
+ _initstart = .;
+ *(.init*)
+ *(.initdata*)
+ _initend = .;
+ } > INIT AT > DRAM
+ _initcopy = LOADADDR(.init);
+
.ibss (NOLOAD) :
{
_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 @@
#include "config.h"
#include "cpu.h"
- .section .init.text,"ax",@progbits
+ .section .startup,"ax",@progbits
.global start
start:
@@ -290,6 +290,17 @@ start:
/* .iram copy is done first since it is reclaimed for other
* uninitialized sections */
+ /* copy .init section */
+ lea _initcopy,%a2
+ lea _initstart,%a3
+ lea _initend,%a4
+ bra.b .initstart
+.initloop:
+ move.l (%a2)+,(%a3)+
+.initstart:
+ cmp.l %a3,%a4
+ bhi.b .initloop
+
/* copy the .iram section */
lea _iramcopy,%a2
lea _iramstart,%a3