summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-04-25 13:43:58 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-04-25 14:04:38 +0000
commitd6220f618ba6daa043f70e42e421b8fad79e7731 (patch)
treecde37b392e8ad65281f9d1fdd43a2a27e3be607b /firmware
parentc37555d30d5063512a2146515c581a06389c5276 (diff)
downloadrockbox-d6220f618ba6daa043f70e42e421b8fad79e7731.tar.gz
rockbox-d6220f618ba6daa043f70e42e421b8fad79e7731.zip
MIPS: emulate -ffunction-sections with macros in mmu-mips
Using a macro to put each function in its own .icode-based section allows us to put the functions in IRAM _and_ have linker GC. This removes a troublesome #ifdef BOOTLOADER_SPL on the X1000 target. Change-Id: Ia7b59778f5c36b7970dee4280547e434a1f4fc5a
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/app.lds2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/boot.lds2
-rw-r--r--firmware/target/mips/ingenic_x1000/app.lds2
-rw-r--r--firmware/target/mips/ingenic_x1000/spl.lds1
-rw-r--r--firmware/target/mips/ingenic_x1000/system-target.h9
-rw-r--r--firmware/target/mips/mmu-mips.h17
6 files changed, 12 insertions, 21 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/app.lds b/firmware/target/mips/ingenic_jz47xx/app.lds
index bec8671ec9..8177db794f 100644
--- a/firmware/target/mips/ingenic_jz47xx/app.lds
+++ b/firmware/target/mips/ingenic_jz47xx/app.lds
@@ -66,7 +66,7 @@ SECTIONS
66 KEEP(*(.vectors.4)); 66 KEEP(*(.vectors.4));
67 KEEP(*(.vectors)); 67 KEEP(*(.vectors));
68 68
69 *(.icode); 69 *(.icode*);
70 *(.irodata); 70 *(.irodata);
71 *(.idata); 71 *(.idata);
72 KEEP(*(.vectors)) 72 KEEP(*(.vectors))
diff --git a/firmware/target/mips/ingenic_jz47xx/boot.lds b/firmware/target/mips/ingenic_jz47xx/boot.lds
index 9492050695..7b53272058 100644
--- a/firmware/target/mips/ingenic_jz47xx/boot.lds
+++ b/firmware/target/mips/ingenic_jz47xx/boot.lds
@@ -58,7 +58,7 @@ SECTIONS
58 KEEP(*(.vectors.4)); 58 KEEP(*(.vectors.4));
59 KEEP(*(.vectors)); 59 KEEP(*(.vectors));
60 60
61 *(.icode); 61 *(.icode*);
62 *(.irodata); 62 *(.irodata);
63 *(.idata); 63 *(.idata);
64 KEEP(*(.vectors*)) 64 KEEP(*(.vectors*))
diff --git a/firmware/target/mips/ingenic_x1000/app.lds b/firmware/target/mips/ingenic_x1000/app.lds
index 0f6352b8ee..bcfb3b28cf 100644
--- a/firmware/target/mips/ingenic_x1000/app.lds
+++ b/firmware/target/mips/ingenic_x1000/app.lds
@@ -63,7 +63,7 @@ SECTIONS
63 KEEP(*(.vectors.4)); 63 KEEP(*(.vectors.4));
64 KEEP(*(.vectors)); 64 KEEP(*(.vectors));
65 65
66 *(.icode); 66 *(.icode*);
67 *(.irodata); 67 *(.irodata);
68 *(.idata); 68 *(.idata);
69 _iramend = .; 69 _iramend = .;
diff --git a/firmware/target/mips/ingenic_x1000/spl.lds b/firmware/target/mips/ingenic_x1000/spl.lds
index ab4a2720f3..f11fd2cf3b 100644
--- a/firmware/target/mips/ingenic_x1000/spl.lds
+++ b/firmware/target/mips/ingenic_x1000/spl.lds
@@ -26,6 +26,7 @@ SECTIONS
26 { 26 {
27 *(.init.text); 27 *(.init.text);
28 *(.text*); 28 *(.text*);
29 *(.icode*);
29 } > TCSM 30 } > TCSM
30 31
31 . = ALIGN(4); 32 . = ALIGN(4);
diff --git a/firmware/target/mips/ingenic_x1000/system-target.h b/firmware/target/mips/ingenic_x1000/system-target.h
index e5e48e382b..13024584d3 100644
--- a/firmware/target/mips/ingenic_x1000/system-target.h
+++ b/firmware/target/mips/ingenic_x1000/system-target.h
@@ -28,15 +28,6 @@
28#define CACHEALIGN_BITS 5 28#define CACHEALIGN_BITS 5
29#define CACHE_SIZE (16*1024) 29#define CACHE_SIZE (16*1024)
30 30
31#ifdef BOOTLOADER_SPL
32/* This saves ~200 bytes in the SPL by allowing -ffunction-sections to split
33 * up the cache management functions, most of which aren't called by the SPL.
34 * If they are placed in .icode, then they all end up in one section and the
35 * linker can't discard the unused functions.
36 */
37# define MIPS_CACHEFUNC_ATTR
38#endif
39
40#ifdef DEBUG 31#ifdef DEBUG
41/* Define this to get CPU idle stats, visible in the debug menu. */ 32/* Define this to get CPU idle stats, visible in the debug menu. */
42# define X1000_CPUIDLE_STATS 33# define X1000_CPUIDLE_STATS
diff --git a/firmware/target/mips/mmu-mips.h b/firmware/target/mips/mmu-mips.h
index b54807f060..b8f5ff0143 100644
--- a/firmware/target/mips/mmu-mips.h
+++ b/firmware/target/mips/mmu-mips.h
@@ -28,33 +28,32 @@
28 * called safely eg. by the bootloader or RoLo, which need to flush the 28 * called safely eg. by the bootloader or RoLo, which need to flush the
29 * cache before jumping to the loaded binary. 29 * cache before jumping to the loaded binary.
30 */ 30 */
31#ifndef MIPS_CACHEFUNC_ATTR 31#define MIPS_CACHEFUNC_API(ret, name, args) \
32# define MIPS_CACHEFUNC_ATTR __attribute__((section(".icode"))) 32 ret name args __attribute__((section( ".icode." #name )))
33#endif
34 33
35void map_address(unsigned long virtual, unsigned long physical, 34void map_address(unsigned long virtual, unsigned long physical,
36 unsigned long length, unsigned int cache_flags); 35 unsigned long length, unsigned int cache_flags);
37void mmu_init(void); 36void mmu_init(void);
38 37
39/* Commits entire DCache */ 38/* Commits entire DCache */
40void commit_dcache(void) MIPS_CACHEFUNC_ATTR; 39MIPS_CACHEFUNC_API(void, commit_dcache, (void));
41/* Commit and discard entire DCache, will do writeback */ 40/* Commit and discard entire DCache, will do writeback */
42void commit_discard_dcache(void) MIPS_CACHEFUNC_ATTR; 41MIPS_CACHEFUNC_API(void, commit_discard_dcache, (void));
43 42
44/* Write DCache back to RAM for the given range and remove cache lines 43/* Write DCache back to RAM for the given range and remove cache lines
45 * from DCache afterwards */ 44 * from DCache afterwards */
46void commit_discard_dcache_range(const void *base, unsigned int size) MIPS_CACHEFUNC_ATTR; 45MIPS_CACHEFUNC_API(void, commit_discard_dcache_range, (const void *base, unsigned int size));
47 46
48/* Write DCache back to RAM for the given range */ 47/* Write DCache back to RAM for the given range */
49void commit_dcache_range(const void *base, unsigned int size) MIPS_CACHEFUNC_ATTR; 48MIPS_CACHEFUNC_API(void, commit_dcache_range, (const void *base, unsigned int size));
50 49
51/* 50/*
52 * Remove cache lines for the given range from DCache 51 * Remove cache lines for the given range from DCache
53 * will *NOT* do write back except for buffer edges not on a line boundary 52 * will *NOT* do write back except for buffer edges not on a line boundary
54 */ 53 */
55void discard_dcache_range(const void *base, unsigned int size) MIPS_CACHEFUNC_ATTR; 54MIPS_CACHEFUNC_API(void, discard_dcache_range, (const void *base, unsigned int size));
56 55
57/* Discards the entire ICache, and commit+discards the entire DCache */ 56/* Discards the entire ICache, and commit+discards the entire DCache */
58void commit_discard_idcache(void) MIPS_CACHEFUNC_ATTR; 57MIPS_CACHEFUNC_API(void, commit_discard_idcache, (void));
59 58
60#endif /* __MMU_MIPS_INCLUDE_H */ 59#endif /* __MMU_MIPS_INCLUDE_H */