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
This commit is contained in:
Michael Sevakis 2009-02-20 02:33:40 +00:00
parent 07ae1e4fb9
commit ec67912b63
11 changed files with 76 additions and 65 deletions

View file

@ -41,7 +41,6 @@ start:
.equ COP_CTRL, 0xcf004058 .equ COP_CTRL, 0xcf004058
.equ CPU_STATUS, 0xcf004050 .equ CPU_STATUS, 0xcf004050
.equ COP_STATUS, 0xcf004050 .equ COP_STATUS, 0xcf004050
.equ IIS_CONFIG, 0xc0002500
.equ SLEEP, 0x000000ca .equ SLEEP, 0x000000ca
.equ WAKE, 0x000000ce .equ WAKE, 0x000000ce
.equ CPUSLEEPING, 0x00008000 .equ CPUSLEEPING, 0x00008000
@ -63,7 +62,6 @@ start:
.equ COP_ICLR, 0x60004038 .equ COP_ICLR, 0x60004038
.equ COP_CTRL, 0x60007004 .equ COP_CTRL, 0x60007004
.equ COP_STATUS, 0x60007004 .equ COP_STATUS, 0x60007004
.equ IIS_CONFIG, 0x70002800
.equ SLEEP, 0x80000000 .equ SLEEP, 0x80000000
.equ WAKE, 0x00000000 .equ WAKE, 0x00000000
.equ CPUSLEEPING, 0x80000000 .equ CPUSLEEPING, 0x80000000
@ -186,6 +184,9 @@ cpu_init:
ldr r3, [r4] ldr r3, [r4]
tst r3, #COPSLEEPING tst r3, #COPSLEEPING
beq 1b beq 1b
/* Vectors and IRAM copy is done first since they are reclaimed for
* other uninitialized sections */
/* Copy exception handler code to address 0 */ /* Copy exception handler code to address 0 */
ldr r2, =_vectorsstart ldr r2, =_vectorsstart
@ -196,16 +197,7 @@ cpu_init:
ldrhi r5, [r4], #4 ldrhi r5, [r4], #4
strhi r5, [r2], #4 strhi r5, [r2], #4
bhi 1b bhi 1b
/* Zero out IBSS */
ldr r2, =_iedata
ldr r3, =_iend
mov r4, #0
1:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
/* Copy the IRAM */ /* Copy the IRAM */
ldr r2, =_iramcopy ldr r2, =_iramcopy
ldr r3, =_iramstart ldr r3, =_iramstart
@ -216,6 +208,15 @@ cpu_init:
strhi r5, [r3], #4 strhi r5, [r3], #4
bhi 1b bhi 1b
/* Zero out IBSS */
ldr r2, =_iedata
ldr r3, =_iend
mov r4, #0
1:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
/* Initialise bss section to zero */ /* Initialise bss section to zero */
ldr r2, =_edata ldr r2, =_edata
ldr r3, =_end ldr r3, =_end

View file

@ -103,6 +103,7 @@ SECTIONS
} AT> DRAM } AT> DRAM
_vectorscopy = LOADADDR(.vectors); _vectorscopy = LOADADDR(.vectors);
_noloaddram = LOADADDR(.vectors);
.ibss IRAMORIG (NOLOAD) : .ibss IRAMORIG (NOLOAD) :
{ {
@ -148,8 +149,7 @@ SECTIONS
/* .bss and .ncbss are treated as a single section to use one init loop to /* .bss and .ncbss are treated as a single section to use one init loop to
* zero it - note "_edata" and "_end" */ * zero it - note "_edata" and "_end" */
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ .bss _noloaddram (NOLOAD) :
SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)

View file

@ -103,6 +103,7 @@ SECTIONS
} AT> DRAM } AT> DRAM
_vectorscopy = LOADADDR(.vectors); _vectorscopy = LOADADDR(.vectors);
_noloaddram = LOADADDR(.vectors);
.ibss IRAMORIG (NOLOAD) : .ibss IRAMORIG (NOLOAD) :
{ {
@ -148,8 +149,7 @@ SECTIONS
/* .bss and .ncbss are treated as a single section to use one init loop to /* .bss and .ncbss are treated as a single section to use one init loop to
* zero it - note "_edata" and "_end" */ * zero it - note "_edata" and "_end" */
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ .bss _noloaddram (NOLOAD) :
SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)

View file

@ -103,6 +103,7 @@ SECTIONS
} AT> DRAM } AT> DRAM
_vectorscopy = LOADADDR(.vectors); _vectorscopy = LOADADDR(.vectors);
_noloaddram = LOADADDR(.vectors);
.ibss IRAMORIG (NOLOAD) : .ibss IRAMORIG (NOLOAD) :
{ {
@ -148,8 +149,7 @@ SECTIONS
/* .bss and .ncbss are treated as a single section to use one init loop to /* .bss and .ncbss are treated as a single section to use one init loop to
* zero it - note "_edata" and "_end" */ * zero it - note "_edata" and "_end" */
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ .bss _noloaddram (NOLOAD) :
SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)

View file

@ -103,6 +103,7 @@ SECTIONS
} AT> DRAM } AT> DRAM
_vectorscopy = LOADADDR(.vectors); _vectorscopy = LOADADDR(.vectors);
_noloaddram = LOADADDR(.vectors);
.ibss IRAMORIG (NOLOAD) : .ibss IRAMORIG (NOLOAD) :
{ {
@ -148,8 +149,7 @@ SECTIONS
/* .bss and .ncbss are treated as a single section to use one init loop to /* .bss and .ncbss are treated as a single section to use one init loop to
* zero it - note "_edata" and "_end" */ * zero it - note "_edata" and "_end" */
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ .bss _noloaddram (NOLOAD) :
SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)

View file

@ -103,6 +103,7 @@ SECTIONS
} AT> DRAM } AT> DRAM
_vectorscopy = LOADADDR(.vectors); _vectorscopy = LOADADDR(.vectors);
_noloaddram = LOADADDR(.vectors);
.ibss IRAMORIG (NOLOAD) : .ibss IRAMORIG (NOLOAD) :
{ {
@ -145,11 +146,10 @@ SECTIONS
. += 0x2000; . += 0x2000;
stackend = .; stackend = .;
} > IRAM } > IRAM
/* .bss and .ncbss are treated as a single section to use one init loop to /* .bss and .ncbss are treated as a single section to use one init loop to
* zero it - note "_edata" and "_end" */ * zero it - note "_edata" and "_end" */
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ .bss _noloaddram (NOLOAD) :
SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)

View file

@ -234,15 +234,8 @@ start:
movec.l %d0,%acr1 movec.l %d0,%acr1
#ifndef BOOTLOADER #ifndef BOOTLOADER
/* zero out .ibss */ /* .iram copy is done first since it is reclaimed for other
lea _iedata,%a2 * uninitialized sections */
lea _iend,%a4
bra.b .iedatastart
.iedataloop:
clr.l (%a2)+
.iedatastart:
cmp.l %a2,%a4
bhi.b .iedataloop
/* copy the .iram section */ /* copy the .iram section */
lea _iramcopy,%a2 lea _iramcopy,%a2
@ -254,6 +247,16 @@ start:
.iramstart: .iramstart:
cmp.l %a3,%a4 cmp.l %a3,%a4
bhi.b .iramloop bhi.b .iramloop
/* zero out .ibss */
lea _iedata,%a2
lea _iend,%a4
bra.b .iedatastart
.iedataloop:
clr.l (%a2)+
.iedatastart:
cmp.l %a2,%a4
bhi.b .iedataloop
#endif /* !BOOTLOADER */ #endif /* !BOOTLOADER */
#ifdef IRIVER_H300_SERIES #ifdef IRIVER_H300_SERIES

View file

@ -94,6 +94,7 @@ SECTIONS
} > IRAM AT> DRAM } > IRAM AT> DRAM
_iramcopy = LOADADDR(.iram); _iramcopy = LOADADDR(.iram);
_noloaddram = LOADADDR(.iram);
.ibss (NOLOAD) : .ibss (NOLOAD) :
{ {
@ -103,7 +104,7 @@ SECTIONS
_iend = .; _iend = .;
} > IRAM } > IRAM
.stack : .stack (NOLOAD) :
{ {
*(.stack) *(.stack)
stackbegin = .; stackbegin = .;
@ -111,7 +112,7 @@ SECTIONS
stackend = .; stackend = .;
} > IRAM } > IRAM
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram): .bss _noloaddram (NOLOAD):
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)
@ -120,25 +121,26 @@ SECTIONS
_end = .; _end = .;
} > DRAM } > DRAM
.audiobuf ALIGN(4) : .audiobuf (NOLOAD) :
{ {
. = ALIGN(4);
_audiobuffer = .; _audiobuffer = .;
audiobuffer = .; audiobuffer = .;
} > DRAM } > DRAM
.audiobufend ENDAUDIOADDR: .audiobufend ENDAUDIOADDR (NOLOAD) :
{ {
audiobufend = .; audiobufend = .;
_audiobufend = .; _audiobufend = .;
} > DRAM } > DRAM
.codec ENDAUDIOADDR: .codec ENDAUDIOADDR (NOLOAD) :
{ {
codecbuf = .; codecbuf = .;
_codecbuf = .; _codecbuf = .;
} }
.plugin ENDADDR: .plugin ENDADDR (NOLOAD) :
{ {
_pluginbuf = .; _pluginbuf = .;
pluginbuf = .; pluginbuf = .;

View file

@ -90,6 +90,7 @@ SECTIONS
} > IRAM AT> DRAM } > IRAM AT> DRAM
_iramcopy = LOADADDR(.iram); _iramcopy = LOADADDR(.iram);
_noloaddram = LOADADDR(.iram);
.ibss (NOLOAD) : .ibss (NOLOAD) :
{ {
@ -99,7 +100,7 @@ SECTIONS
_iend = .; _iend = .;
} > IRAM } > IRAM
.stack : .stack (NOLOAD) :
{ {
*(.stack) *(.stack)
stackbegin = .; stackbegin = .;
@ -107,7 +108,7 @@ SECTIONS
stackend = .; stackend = .;
} > IRAM } > IRAM
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram): .bss _noloaddram (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)
@ -116,25 +117,26 @@ SECTIONS
_end = .; _end = .;
} > DRAM } > DRAM
.audiobuf ALIGN(4) : .audiobuf (NOLOAD) :
{ {
. = ALIGN(4);
_audiobuffer = .; _audiobuffer = .;
audiobuffer = .; audiobuffer = .;
} > DRAM } > DRAM
.audiobufend ENDAUDIOADDR: .audiobufend ENDAUDIOADDR (NOLOAD) :
{ {
audiobufend = .; audiobufend = .;
_audiobufend = .; _audiobufend = .;
} > DRAM } > DRAM
.codec ENDAUDIOADDR: .codec ENDAUDIOADDR (NOLOAD) :
{ {
codecbuf = .; codecbuf = .;
_codecbuf = .; _codecbuf = .;
} }
.plugin ENDADDR: .plugin ENDADDR (NOLOAD) :
{ {
_pluginbuf = .; _pluginbuf = .;
pluginbuf = .; pluginbuf = .;

View file

@ -90,6 +90,7 @@ SECTIONS
} > IRAM AT> DRAM } > IRAM AT> DRAM
_iramcopy = LOADADDR(.iram); _iramcopy = LOADADDR(.iram);
_noloaddram = LOADADDR(.iram);
.ibss (NOLOAD) : .ibss (NOLOAD) :
{ {
@ -98,18 +99,16 @@ SECTIONS
. = ALIGN(0x4); . = ALIGN(0x4);
_iend = .; _iend = .;
} > IRAM } > IRAM
/* TRICK ALERT! We want 0x2000 bytes of stack, but we set the section .stack _noloaddram (NOLOAD) :
size smaller, and allow the stack to grow into the .iram copy */
.stack ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
{ {
*(.stack) *(.stack)
_stackbegin = . - SIZEOF(.iram); _stackbegin = .;
. += 0x2000 - SIZEOF(.iram); . += 0x2000;
_stackend = .; _stackend = .;
} > DRAM } > DRAM
.bss : .bss (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*) *(.bss*)
@ -118,25 +117,26 @@ SECTIONS
_end = .; _end = .;
} > DRAM } > DRAM
.audiobuf ALIGN(4) : .audiobuf (NOLOAD) :
{ {
. = ALIGN(4);
_audiobuffer = .; _audiobuffer = .;
audiobuffer = .; audiobuffer = .;
} > DRAM } > DRAM
.audiobufend ENDAUDIOADDR: .audiobufend ENDAUDIOADDR (NOLOAD) :
{ {
audiobufend = .; audiobufend = .;
_audiobufend = .; _audiobufend = .;
} > DRAM } > DRAM
.codec ENDAUDIOADDR: .codec ENDAUDIOADDR (NOLOAD) :
{ {
codecbuf = .; codecbuf = .;
_codecbuf = .; _codecbuf = .;
} }
.plugin ENDADDR: .plugin ENDADDR (NOLOAD) :
{ {
_pluginbuf = .; _pluginbuf = .;
pluginbuf = .; pluginbuf = .;

View file

@ -98,16 +98,8 @@ start:
mov #0,r0 mov #0,r0
ldc r0,gbr ldc r0,gbr
/* zero out .ibss */ /* .iram copy is done first since it is reclaimed for other
mov.l .iedata_k,r0 * uninitialized sections */
mov.l .iend_k,r1
bra .iedatastart
mov #0,r2
.iedataloop: /* backwards is faster and shorter */
mov.l r2,@-r1
.iedatastart:
cmp/hi r0,r1
bt .iedataloop
/* copy the .iram section */ /* copy the .iram section */
mov.l .iramcopy_k,r0 mov.l .iramcopy_k,r0
@ -127,6 +119,17 @@ start:
bt .iramloop bt .iramloop
.noiramcopy: .noiramcopy:
/* zero out .ibss */
mov.l .iedata_k,r0
mov.l .iend_k,r1
bra .iedatastart
mov #0,r2
.iedataloop: /* backwards is faster and shorter */
mov.l r2,@-r1
.iedatastart:
cmp/hi r0,r1
bt .iedataloop
/* zero out bss */ /* zero out bss */
mov.l .edata_k,r0 mov.l .edata_k,r0
mov.l .end_k,r1 mov.l .end_k,r1