summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-12-30 23:18:02 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-12-31 08:10:41 -0500
commita980d5f86951dca03baa447fd5a58005ba47a098 (patch)
treef315d780c0bee54aef6c2d925e7ab19ca0d9c4c3
parentea7b80dab0ee9f087c1db76975d9490db8b189d1 (diff)
downloadrockbox-a980d5f869.tar.gz
rockbox-a980d5f869.zip
x1000: Enable support for INIT_ATTR
Enable INIT_ATTR support in config.h. Load init code to the codec buffer, following the convention used by other targets that support INIT_ATTR. Change-Id: I8935fbaa100f0013bb328d71c4a49ec2ffafd003
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/target/mips/ingenic_x1000/app.lds22
-rw-r--r--firmware/target/mips/ingenic_x1000/crt0.S9
-rw-r--r--firmware/target/mips/ingenic_x1000/spl.lds1
4 files changed, 33 insertions, 1 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index e83194e0f4..d2ebbbf071 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -1070,7 +1070,7 @@ Lyre prototype 1 */
#if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \
(CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233) || \
- (CONFIG_CPU == RK27XX) || defined(CPU_COLDFIRE)) \
+ (CONFIG_CPU == RK27XX) || (CONFIG_CPU == X1000) || 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/mips/ingenic_x1000/app.lds b/firmware/target/mips/ingenic_x1000/app.lds
index 270055c18f..fe06e1cd8d 100644
--- a/firmware/target/mips/ingenic_x1000/app.lds
+++ b/firmware/target/mips/ingenic_x1000/app.lds
@@ -13,6 +13,10 @@ INPUT(target/mips/system-mips.o)
# undef CODEC_SIZE
# define PLUGIN_BUFFER_SIZE 0
# define CODEC_SIZE 0
+# if defined(HAVE_INIT_ATTR)
+/* This needs to be fixed for the bootloader */
+# error "bootloader does not support INIT_ATTR"
+# endif
#endif
/* End of the audio buffer, where the codec buffer starts */
@@ -21,11 +25,16 @@ INPUT(target/mips/system-mips.o)
/* Where the codec buffer ends, and the plugin buffer starts */
#define ENDCODECADDR (ENDAUDIOADDR + CODEC_SIZE)
+/* Place init code in the codec buffer */
+#define INIT_BASE ENDAUDIOADDR
+#define INIT_SIZE CODEC_SIZE
+
MEMORY
{
IRAM : ORIGIN = X1000_IRAM_BASE, LENGTH = X1000_IRAM_SIZE
DRAM : ORIGIN = X1000_DRAM_BASE, LENGTH = X1000_DRAM_SIZE
TCSM : ORIGIN = X1000_TCSM_BASE, LENGTH = X1000_TCSM_SIZE
+ INIT : ORIGIN = INIT_BASE, LENGTH = INIT_SIZE
}
SECTIONS
@@ -40,6 +49,9 @@ SECTIONS
.text :
{
*(.text*);
+#ifndef HAVE_INIT_ATTR
+ *(.init*);
+#endif
} > DRAM
. = ALIGN(4);
@@ -89,6 +101,16 @@ SECTIONS
} > TCSM AT> DRAM
_tcsmcopy = LOADADDR(.tcsm);
+#ifdef HAVE_INIT_ATTR
+ .init :
+ {
+ _initstart = .;
+ *(.init*);
+ _initend = .;
+ } > INIT AT> DRAM
+ _initcopy = LOADADDR(.init);
+#endif
+
/* Sections below have no data. */
. = ALIGN(4);
diff --git a/firmware/target/mips/ingenic_x1000/crt0.S b/firmware/target/mips/ingenic_x1000/crt0.S
index 494f3722aa..6c0942b0db 100644
--- a/firmware/target/mips/ingenic_x1000/crt0.S
+++ b/firmware/target/mips/ingenic_x1000/crt0.S
@@ -75,6 +75,15 @@ _realstart:
bal _copy
nop
+#ifdef HAVE_INIT_ATTR
+ /* Copy init code */
+ la a0, _initcopy
+ la a1, _initstart
+ la a2, _initend
+ bal _copy
+ nop
+#endif
+
/* Clear the BSS segment (needed to zero-initialize C static values) */
la a0, _bssbegin
la a1, _bssend
diff --git a/firmware/target/mips/ingenic_x1000/spl.lds b/firmware/target/mips/ingenic_x1000/spl.lds
index b6c982bd80..b3e508e9c3 100644
--- a/firmware/target/mips/ingenic_x1000/spl.lds
+++ b/firmware/target/mips/ingenic_x1000/spl.lds
@@ -18,6 +18,7 @@ SECTIONS
*(.startup.spl);
*(.text*);
*(.icode*);
+ *(.init*);
} > TCSM
. = ALIGN(4);