summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2009-02-20 02:33:40 +0000
committerMichael Sevakis <jethead71@rockbox.org>2009-02-20 02:33:40 +0000
commitec67912b638e0fae3cae7b4182d23db6d36c5135 (patch)
tree8101f45d02947a828d20174a45d1a6d19fafa3b2
parent07ae1e4fb9a1fd9d6ce9c48c5300b53e87303937 (diff)
downloadrockbox-ec67912b638e0fae3cae7b4182d23db6d36c5135.tar.gz
rockbox-ec67912b638e0fae3cae7b4182d23db6d36c5135.zip
Reclaim .iram areas in DRAM by overlapping their load addresses with the uninitialized data sections. I did what I could test out-- not any flash image linker scripts or other target processors. Move any .iram copies in crt0.S's to be the first operation even if not _strictly_ necessary to be emphatic (aka. 'beware').
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20061 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/crt0-pp.S25
-rw-r--r--firmware/target/arm/ipod/app.lds4
-rw-r--r--firmware/target/arm/iriver/app.lds4
-rw-r--r--firmware/target/arm/olympus/app.lds4
-rw-r--r--firmware/target/arm/philips/app.lds4
-rw-r--r--firmware/target/arm/sandisk/app.lds6
-rw-r--r--firmware/target/coldfire/crt0.S21
-rw-r--r--firmware/target/coldfire/iaudio/app.lds14
-rw-r--r--firmware/target/coldfire/iriver/app.lds14
-rw-r--r--firmware/target/sh/archos/app.lds22
-rw-r--r--firmware/target/sh/crt0.S23
11 files changed, 76 insertions, 65 deletions
diff --git a/firmware/target/arm/crt0-pp.S b/firmware/target/arm/crt0-pp.S
index f698783017..210b560560 100644
--- a/firmware/target/arm/crt0-pp.S
+++ b/firmware/target/arm/crt0-pp.S
@@ -41,7 +41,6 @@ start:
41 .equ COP_CTRL, 0xcf004058 41 .equ COP_CTRL, 0xcf004058
42 .equ CPU_STATUS, 0xcf004050 42 .equ CPU_STATUS, 0xcf004050
43 .equ COP_STATUS, 0xcf004050 43 .equ COP_STATUS, 0xcf004050
44 .equ IIS_CONFIG, 0xc0002500
45 .equ SLEEP, 0x000000ca 44 .equ SLEEP, 0x000000ca
46 .equ WAKE, 0x000000ce 45 .equ WAKE, 0x000000ce
47 .equ CPUSLEEPING, 0x00008000 46 .equ CPUSLEEPING, 0x00008000
@@ -63,7 +62,6 @@ start:
63 .equ COP_ICLR, 0x60004038 62 .equ COP_ICLR, 0x60004038
64 .equ COP_CTRL, 0x60007004 63 .equ COP_CTRL, 0x60007004
65 .equ COP_STATUS, 0x60007004 64 .equ COP_STATUS, 0x60007004
66 .equ IIS_CONFIG, 0x70002800
67 .equ SLEEP, 0x80000000 65 .equ SLEEP, 0x80000000
68 .equ WAKE, 0x00000000 66 .equ WAKE, 0x00000000
69 .equ CPUSLEEPING, 0x80000000 67 .equ CPUSLEEPING, 0x80000000
@@ -186,6 +184,9 @@ cpu_init:
186 ldr r3, [r4] 184 ldr r3, [r4]
187 tst r3, #COPSLEEPING 185 tst r3, #COPSLEEPING
188 beq 1b 186 beq 1b
187
188 /* Vectors and IRAM copy is done first since they are reclaimed for
189 * other uninitialized sections */
189 190
190 /* Copy exception handler code to address 0 */ 191 /* Copy exception handler code to address 0 */
191 ldr r2, =_vectorsstart 192 ldr r2, =_vectorsstart
@@ -196,16 +197,7 @@ cpu_init:
196 ldrhi r5, [r4], #4 197 ldrhi r5, [r4], #4
197 strhi r5, [r2], #4 198 strhi r5, [r2], #4
198 bhi 1b 199 bhi 1b
199 200
200 /* Zero out IBSS */
201 ldr r2, =_iedata
202 ldr r3, =_iend
203 mov r4, #0
2041:
205 cmp r3, r2
206 strhi r4, [r2], #4
207 bhi 1b
208
209 /* Copy the IRAM */ 201 /* Copy the IRAM */
210 ldr r2, =_iramcopy 202 ldr r2, =_iramcopy
211 ldr r3, =_iramstart 203 ldr r3, =_iramstart
@@ -216,6 +208,15 @@ cpu_init:
216 strhi r5, [r3], #4 208 strhi r5, [r3], #4
217 bhi 1b 209 bhi 1b
218 210
211 /* Zero out IBSS */
212 ldr r2, =_iedata
213 ldr r3, =_iend
214 mov r4, #0
2151:
216 cmp r3, r2
217 strhi r4, [r2], #4
218 bhi 1b
219
219 /* Initialise bss section to zero */ 220 /* Initialise bss section to zero */
220 ldr r2, =_edata 221 ldr r2, =_edata
221 ldr r3, =_end 222 ldr r3, =_end
diff --git a/firmware/target/arm/ipod/app.lds b/firmware/target/arm/ipod/app.lds
index d7159e8e1e..22468192eb 100644
--- a/firmware/target/arm/ipod/app.lds
+++ b/firmware/target/arm/ipod/app.lds
@@ -103,6 +103,7 @@ SECTIONS
103 } AT> DRAM 103 } AT> DRAM
104 104
105 _vectorscopy = LOADADDR(.vectors); 105 _vectorscopy = LOADADDR(.vectors);
106 _noloaddram = LOADADDR(.vectors);
106 107
107 .ibss IRAMORIG (NOLOAD) : 108 .ibss IRAMORIG (NOLOAD) :
108 { 109 {
@@ -148,8 +149,7 @@ SECTIONS
148 149
149 /* .bss and .ncbss are treated as a single section to use one init loop to 150 /* .bss and .ncbss are treated as a single section to use one init loop to
150 * zero it - note "_edata" and "_end" */ 151 * zero it - note "_edata" and "_end" */
151 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ 152 .bss _noloaddram (NOLOAD) :
152 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
153 { 153 {
154 _edata = .; 154 _edata = .;
155 *(.bss*) 155 *(.bss*)
diff --git a/firmware/target/arm/iriver/app.lds b/firmware/target/arm/iriver/app.lds
index d7159e8e1e..22468192eb 100644
--- a/firmware/target/arm/iriver/app.lds
+++ b/firmware/target/arm/iriver/app.lds
@@ -103,6 +103,7 @@ SECTIONS
103 } AT> DRAM 103 } AT> DRAM
104 104
105 _vectorscopy = LOADADDR(.vectors); 105 _vectorscopy = LOADADDR(.vectors);
106 _noloaddram = LOADADDR(.vectors);
106 107
107 .ibss IRAMORIG (NOLOAD) : 108 .ibss IRAMORIG (NOLOAD) :
108 { 109 {
@@ -148,8 +149,7 @@ SECTIONS
148 149
149 /* .bss and .ncbss are treated as a single section to use one init loop to 150 /* .bss and .ncbss are treated as a single section to use one init loop to
150 * zero it - note "_edata" and "_end" */ 151 * zero it - note "_edata" and "_end" */
151 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ 152 .bss _noloaddram (NOLOAD) :
152 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
153 { 153 {
154 _edata = .; 154 _edata = .;
155 *(.bss*) 155 *(.bss*)
diff --git a/firmware/target/arm/olympus/app.lds b/firmware/target/arm/olympus/app.lds
index d7159e8e1e..22468192eb 100644
--- a/firmware/target/arm/olympus/app.lds
+++ b/firmware/target/arm/olympus/app.lds
@@ -103,6 +103,7 @@ SECTIONS
103 } AT> DRAM 103 } AT> DRAM
104 104
105 _vectorscopy = LOADADDR(.vectors); 105 _vectorscopy = LOADADDR(.vectors);
106 _noloaddram = LOADADDR(.vectors);
106 107
107 .ibss IRAMORIG (NOLOAD) : 108 .ibss IRAMORIG (NOLOAD) :
108 { 109 {
@@ -148,8 +149,7 @@ SECTIONS
148 149
149 /* .bss and .ncbss are treated as a single section to use one init loop to 150 /* .bss and .ncbss are treated as a single section to use one init loop to
150 * zero it - note "_edata" and "_end" */ 151 * zero it - note "_edata" and "_end" */
151 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ 152 .bss _noloaddram (NOLOAD) :
152 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
153 { 153 {
154 _edata = .; 154 _edata = .;
155 *(.bss*) 155 *(.bss*)
diff --git a/firmware/target/arm/philips/app.lds b/firmware/target/arm/philips/app.lds
index d7159e8e1e..22468192eb 100644
--- a/firmware/target/arm/philips/app.lds
+++ b/firmware/target/arm/philips/app.lds
@@ -103,6 +103,7 @@ SECTIONS
103 } AT> DRAM 103 } AT> DRAM
104 104
105 _vectorscopy = LOADADDR(.vectors); 105 _vectorscopy = LOADADDR(.vectors);
106 _noloaddram = LOADADDR(.vectors);
106 107
107 .ibss IRAMORIG (NOLOAD) : 108 .ibss IRAMORIG (NOLOAD) :
108 { 109 {
@@ -148,8 +149,7 @@ SECTIONS
148 149
149 /* .bss and .ncbss are treated as a single section to use one init loop to 150 /* .bss and .ncbss are treated as a single section to use one init loop to
150 * zero it - note "_edata" and "_end" */ 151 * zero it - note "_edata" and "_end" */
151 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ 152 .bss _noloaddram (NOLOAD) :
152 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
153 { 153 {
154 _edata = .; 154 _edata = .;
155 *(.bss*) 155 *(.bss*)
diff --git a/firmware/target/arm/sandisk/app.lds b/firmware/target/arm/sandisk/app.lds
index d7159e8e1e..3010644b72 100644
--- a/firmware/target/arm/sandisk/app.lds
+++ b/firmware/target/arm/sandisk/app.lds
@@ -103,6 +103,7 @@ SECTIONS
103 } AT> DRAM 103 } AT> DRAM
104 104
105 _vectorscopy = LOADADDR(.vectors); 105 _vectorscopy = LOADADDR(.vectors);
106 _noloaddram = LOADADDR(.vectors);
106 107
107 .ibss IRAMORIG (NOLOAD) : 108 .ibss IRAMORIG (NOLOAD) :
108 { 109 {
@@ -145,11 +146,10 @@ SECTIONS
145 . += 0x2000; 146 . += 0x2000;
146 stackend = .; 147 stackend = .;
147 } > IRAM 148 } > IRAM
148 149
149 /* .bss and .ncbss are treated as a single section to use one init loop to 150 /* .bss and .ncbss are treated as a single section to use one init loop to
150 * zero it - note "_edata" and "_end" */ 151 * zero it - note "_edata" and "_end" */
151 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ 152 .bss _noloaddram (NOLOAD) :
152 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
153 { 153 {
154 _edata = .; 154 _edata = .;
155 *(.bss*) 155 *(.bss*)
diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S
index dbf01a347c..bc8a370823 100644
--- a/firmware/target/coldfire/crt0.S
+++ b/firmware/target/coldfire/crt0.S
@@ -234,15 +234,8 @@ start:
234 movec.l %d0,%acr1 234 movec.l %d0,%acr1
235 235
236#ifndef BOOTLOADER 236#ifndef BOOTLOADER
237 /* zero out .ibss */ 237 /* .iram copy is done first since it is reclaimed for other
238 lea _iedata,%a2 238 * uninitialized sections */
239 lea _iend,%a4
240 bra.b .iedatastart
241.iedataloop:
242 clr.l (%a2)+
243.iedatastart:
244 cmp.l %a2,%a4
245 bhi.b .iedataloop
246 239
247 /* copy the .iram section */ 240 /* copy the .iram section */
248 lea _iramcopy,%a2 241 lea _iramcopy,%a2
@@ -254,6 +247,16 @@ start:
254.iramstart: 247.iramstart:
255 cmp.l %a3,%a4 248 cmp.l %a3,%a4
256 bhi.b .iramloop 249 bhi.b .iramloop
250
251 /* zero out .ibss */
252 lea _iedata,%a2
253 lea _iend,%a4
254 bra.b .iedatastart
255.iedataloop:
256 clr.l (%a2)+
257.iedatastart:
258 cmp.l %a2,%a4
259 bhi.b .iedataloop
257#endif /* !BOOTLOADER */ 260#endif /* !BOOTLOADER */
258 261
259#ifdef IRIVER_H300_SERIES 262#ifdef IRIVER_H300_SERIES
diff --git a/firmware/target/coldfire/iaudio/app.lds b/firmware/target/coldfire/iaudio/app.lds
index d3ccce24f0..5cb2f6cb3f 100644
--- a/firmware/target/coldfire/iaudio/app.lds
+++ b/firmware/target/coldfire/iaudio/app.lds
@@ -94,6 +94,7 @@ SECTIONS
94 } > IRAM AT> DRAM 94 } > IRAM AT> DRAM
95 95
96 _iramcopy = LOADADDR(.iram); 96 _iramcopy = LOADADDR(.iram);
97 _noloaddram = LOADADDR(.iram);
97 98
98 .ibss (NOLOAD) : 99 .ibss (NOLOAD) :
99 { 100 {
@@ -103,7 +104,7 @@ SECTIONS
103 _iend = .; 104 _iend = .;
104 } > IRAM 105 } > IRAM
105 106
106 .stack : 107 .stack (NOLOAD) :
107 { 108 {
108 *(.stack) 109 *(.stack)
109 stackbegin = .; 110 stackbegin = .;
@@ -111,7 +112,7 @@ SECTIONS
111 stackend = .; 112 stackend = .;
112 } > IRAM 113 } > IRAM
113 114
114 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram): 115 .bss _noloaddram (NOLOAD):
115 { 116 {
116 _edata = .; 117 _edata = .;
117 *(.bss*) 118 *(.bss*)
@@ -120,25 +121,26 @@ SECTIONS
120 _end = .; 121 _end = .;
121 } > DRAM 122 } > DRAM
122 123
123 .audiobuf ALIGN(4) : 124 .audiobuf (NOLOAD) :
124 { 125 {
126 . = ALIGN(4);
125 _audiobuffer = .; 127 _audiobuffer = .;
126 audiobuffer = .; 128 audiobuffer = .;
127 } > DRAM 129 } > DRAM
128 130
129 .audiobufend ENDAUDIOADDR: 131 .audiobufend ENDAUDIOADDR (NOLOAD) :
130 { 132 {
131 audiobufend = .; 133 audiobufend = .;
132 _audiobufend = .; 134 _audiobufend = .;
133 } > DRAM 135 } > DRAM
134 136
135 .codec ENDAUDIOADDR: 137 .codec ENDAUDIOADDR (NOLOAD) :
136 { 138 {
137 codecbuf = .; 139 codecbuf = .;
138 _codecbuf = .; 140 _codecbuf = .;
139 } 141 }
140 142
141 .plugin ENDADDR: 143 .plugin ENDADDR (NOLOAD) :
142 { 144 {
143 _pluginbuf = .; 145 _pluginbuf = .;
144 pluginbuf = .; 146 pluginbuf = .;
diff --git a/firmware/target/coldfire/iriver/app.lds b/firmware/target/coldfire/iriver/app.lds
index ae21ecd9de..d087f997c8 100644
--- a/firmware/target/coldfire/iriver/app.lds
+++ b/firmware/target/coldfire/iriver/app.lds
@@ -90,6 +90,7 @@ SECTIONS
90 } > IRAM AT> DRAM 90 } > IRAM AT> DRAM
91 91
92 _iramcopy = LOADADDR(.iram); 92 _iramcopy = LOADADDR(.iram);
93 _noloaddram = LOADADDR(.iram);
93 94
94 .ibss (NOLOAD) : 95 .ibss (NOLOAD) :
95 { 96 {
@@ -99,7 +100,7 @@ SECTIONS
99 _iend = .; 100 _iend = .;
100 } > IRAM 101 } > IRAM
101 102
102 .stack : 103 .stack (NOLOAD) :
103 { 104 {
104 *(.stack) 105 *(.stack)
105 stackbegin = .; 106 stackbegin = .;
@@ -107,7 +108,7 @@ SECTIONS
107 stackend = .; 108 stackend = .;
108 } > IRAM 109 } > IRAM
109 110
110 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram): 111 .bss _noloaddram (NOLOAD) :
111 { 112 {
112 _edata = .; 113 _edata = .;
113 *(.bss*) 114 *(.bss*)
@@ -116,25 +117,26 @@ SECTIONS
116 _end = .; 117 _end = .;
117 } > DRAM 118 } > DRAM
118 119
119 .audiobuf ALIGN(4) : 120 .audiobuf (NOLOAD) :
120 { 121 {
122 . = ALIGN(4);
121 _audiobuffer = .; 123 _audiobuffer = .;
122 audiobuffer = .; 124 audiobuffer = .;
123 } > DRAM 125 } > DRAM
124 126
125 .audiobufend ENDAUDIOADDR: 127 .audiobufend ENDAUDIOADDR (NOLOAD) :
126 { 128 {
127 audiobufend = .; 129 audiobufend = .;
128 _audiobufend = .; 130 _audiobufend = .;
129 } > DRAM 131 } > DRAM
130 132
131 .codec ENDAUDIOADDR: 133 .codec ENDAUDIOADDR (NOLOAD) :
132 { 134 {
133 codecbuf = .; 135 codecbuf = .;
134 _codecbuf = .; 136 _codecbuf = .;
135 } 137 }
136 138
137 .plugin ENDADDR: 139 .plugin ENDADDR (NOLOAD) :
138 { 140 {
139 _pluginbuf = .; 141 _pluginbuf = .;
140 pluginbuf = .; 142 pluginbuf = .;
diff --git a/firmware/target/sh/archos/app.lds b/firmware/target/sh/archos/app.lds
index 02ed6bef77..225f11f705 100644
--- a/firmware/target/sh/archos/app.lds
+++ b/firmware/target/sh/archos/app.lds
@@ -90,6 +90,7 @@ SECTIONS
90 } > IRAM AT> DRAM 90 } > IRAM AT> DRAM
91 91
92 _iramcopy = LOADADDR(.iram); 92 _iramcopy = LOADADDR(.iram);
93 _noloaddram = LOADADDR(.iram);
93 94
94 .ibss (NOLOAD) : 95 .ibss (NOLOAD) :
95 { 96 {
@@ -98,18 +99,16 @@ SECTIONS
98 . = ALIGN(0x4); 99 . = ALIGN(0x4);
99 _iend = .; 100 _iend = .;
100 } > IRAM 101 } > IRAM
101 102
102 /* TRICK ALERT! We want 0x2000 bytes of stack, but we set the section 103 .stack _noloaddram (NOLOAD) :
103 size smaller, and allow the stack to grow into the .iram copy */
104 .stack ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
105 { 104 {
106 *(.stack) 105 *(.stack)
107 _stackbegin = . - SIZEOF(.iram); 106 _stackbegin = .;
108 . += 0x2000 - SIZEOF(.iram); 107 . += 0x2000;
109 _stackend = .; 108 _stackend = .;
110 } > DRAM 109 } > DRAM
111 110
112 .bss : 111 .bss (NOLOAD) :
113 { 112 {
114 _edata = .; 113 _edata = .;
115 *(.bss*) 114 *(.bss*)
@@ -118,25 +117,26 @@ SECTIONS
118 _end = .; 117 _end = .;
119 } > DRAM 118 } > DRAM
120 119
121 .audiobuf ALIGN(4) : 120 .audiobuf (NOLOAD) :
122 { 121 {
122 . = ALIGN(4);
123 _audiobuffer = .; 123 _audiobuffer = .;
124 audiobuffer = .; 124 audiobuffer = .;
125 } > DRAM 125 } > DRAM
126 126
127 .audiobufend ENDAUDIOADDR: 127 .audiobufend ENDAUDIOADDR (NOLOAD) :
128 { 128 {
129 audiobufend = .; 129 audiobufend = .;
130 _audiobufend = .; 130 _audiobufend = .;
131 } > DRAM 131 } > DRAM
132 132
133 .codec ENDAUDIOADDR: 133 .codec ENDAUDIOADDR (NOLOAD) :
134 { 134 {
135 codecbuf = .; 135 codecbuf = .;
136 _codecbuf = .; 136 _codecbuf = .;
137 } 137 }
138 138
139 .plugin ENDADDR: 139 .plugin ENDADDR (NOLOAD) :
140 { 140 {
141 _pluginbuf = .; 141 _pluginbuf = .;
142 pluginbuf = .; 142 pluginbuf = .;
diff --git a/firmware/target/sh/crt0.S b/firmware/target/sh/crt0.S
index a87bee899f..0e8bbfdd68 100644
--- a/firmware/target/sh/crt0.S
+++ b/firmware/target/sh/crt0.S
@@ -98,16 +98,8 @@ start:
98 mov #0,r0 98 mov #0,r0
99 ldc r0,gbr 99 ldc r0,gbr
100 100
101 /* zero out .ibss */ 101 /* .iram copy is done first since it is reclaimed for other
102 mov.l .iedata_k,r0 102 * uninitialized sections */
103 mov.l .iend_k,r1
104 bra .iedatastart
105 mov #0,r2
106.iedataloop: /* backwards is faster and shorter */
107 mov.l r2,@-r1
108.iedatastart:
109 cmp/hi r0,r1
110 bt .iedataloop
111 103
112 /* copy the .iram section */ 104 /* copy the .iram section */
113 mov.l .iramcopy_k,r0 105 mov.l .iramcopy_k,r0
@@ -127,6 +119,17 @@ start:
127 bt .iramloop 119 bt .iramloop
128.noiramcopy: 120.noiramcopy:
129 121
122 /* zero out .ibss */
123 mov.l .iedata_k,r0
124 mov.l .iend_k,r1
125 bra .iedatastart
126 mov #0,r2
127.iedataloop: /* backwards is faster and shorter */
128 mov.l r2,@-r1
129.iedatastart:
130 cmp/hi r0,r1
131 bt .iedataloop
132
130 /* zero out bss */ 133 /* zero out bss */
131 mov.l .edata_k,r0 134 mov.l .edata_k,r0
132 mov.l .end_k,r1 135 mov.l .end_k,r1