mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
S5L8702: Reallocate the bootloader without dependency on _dfuloadaddr
Also adds support for S5L8720 initialization. This currently changes only the bootloader code for ipod6g. Tested on target. This is a part of the large iPod Nano 3G and iPod Nano 4G support patch. Credit: Cástor Muñoz <cmvidal@gmail.com> Change-Id: Ib4b5f12b701058940c1c5bd686d8ac346ae14e12
This commit is contained in:
parent
e9b0aa495b
commit
0fef17206e
1 changed files with 54 additions and 10 deletions
|
@ -38,31 +38,56 @@ start:
|
||||||
ldr pc, =fiq_handler
|
ldr pc, =fiq_handler
|
||||||
.ltorg
|
.ltorg
|
||||||
_newstart:
|
_newstart:
|
||||||
#if !defined(BOOTLOADER)
|
#ifndef BOOTLOADER
|
||||||
ldr pc, =newstart2 // we do not want to execute from 0x0 as iram will be mapped there
|
/* we do not want to execute from 0x0 as iram will be mapped there */
|
||||||
|
ldr pc, =newstart2
|
||||||
.section .init.text,"ax",%progbits
|
.section .init.text,"ax",%progbits
|
||||||
newstart2:
|
newstart2:
|
||||||
#endif
|
#endif
|
||||||
msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
|
msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
#ifdef BOOTLOADER
|
||||||
/* Relocate ourself to IRAM1 - we have been loaded to IRAM0 */
|
/* Actually we are reallocating from load address IRAM0:0000 or
|
||||||
ldr r0, =_dfuloadaddr
|
* IRAM1:0000 to exec address IRAM1:0800.
|
||||||
ldr r1, =_movestart
|
* Note that vector section is also reallocated to IRAM0:0000.
|
||||||
ldr r2, =_moveend
|
*/
|
||||||
|
/* Reallocate from IRAM0:0000 or IRAM1:0000 to IRAM1:0800 */
|
||||||
|
/* _movestart and _moveend must be already aligned to 32-byte */
|
||||||
|
|
||||||
|
_rtpc:
|
||||||
|
sub r11, pc, #8 /* subtract 8 for pipeline */
|
||||||
|
sub r11, #_rtpc-start /* _src_start = runtime start: address */
|
||||||
|
|
||||||
|
/* [start .. start+_movelen] -> [_movestart .. _moveend] */
|
||||||
|
ldr r1, =_moveend
|
||||||
|
ldr r2, =_movestart
|
||||||
|
sub r3, r1, r2 /* _movelen = _moveend - _movestart */
|
||||||
|
add r0, r11, r3 /* _src_end = _src_start + _movelen */
|
||||||
1:
|
1:
|
||||||
|
ldmdb r0!, {r3-r10}
|
||||||
|
stmdb r1!, {r3-r10}
|
||||||
|
cmp r2, r1
|
||||||
|
blt 1b
|
||||||
|
|
||||||
|
/* copy vector section to start of IRAM0 (it will be mapped to 0x0) */
|
||||||
|
/* [start .. _newstart] -> [IRAM0_START .. IRAM0_START+vect_len] */
|
||||||
|
mov r0, r11 // src start
|
||||||
|
ldr r1, =IRAM0_ORIG // dst start
|
||||||
|
add r2, r1, #_newstart-start // dst end
|
||||||
|
2:
|
||||||
ldmia r0!, {r3-r10}
|
ldmia r0!, {r3-r10}
|
||||||
stmia r1!, {r3-r10}
|
stmia r1!, {r3-r10}
|
||||||
cmp r1, r2
|
cmp r1, r2
|
||||||
blt 1b
|
blt 2b
|
||||||
|
|
||||||
ldr pc, =start_loc /* jump to the relocated start_loc: */
|
ldr pc, =start_loc /* jump to the relocated start_loc: */
|
||||||
|
|
||||||
.section .init.text,"ax",%progbits
|
.section .init.text,"ax",%progbits
|
||||||
.global start_loc
|
.global start_loc
|
||||||
start_loc:
|
start_loc:
|
||||||
#endif
|
#endif /* BOOTLOADER */
|
||||||
|
|
||||||
|
#if defined(IPOD_6G) || defined(IPOD_NANO3G)
|
||||||
mrc p15, 0, r0, c1, c0, 0
|
mrc p15, 0, r0, c1, c0, 0
|
||||||
bic r0, r0, #0x1000
|
bic r0, r0, #0x1000
|
||||||
bic r0, r0, #0x5
|
bic r0, r0, #0x5
|
||||||
|
@ -75,7 +100,26 @@ start_loc:
|
||||||
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
|
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
|
||||||
mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
|
mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
|
||||||
|
|
||||||
/* reset VIC controller */
|
#elif defined(IPOD_NANO4G)
|
||||||
|
mrc p15, 0, r0, c1, c0, 0
|
||||||
|
bic r0, r0, #0x1000
|
||||||
|
bic r0, r0, #0x5
|
||||||
|
mcr p15, 0, r0, c1, c0, 0 /* disable caches and protection unit */
|
||||||
|
|
||||||
|
mov r0, #0
|
||||||
|
mcr p15, 0, r0, c7, c14, 0 /* clean & invalidate dcache */
|
||||||
|
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
|
||||||
|
mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
|
||||||
|
mcr p15, 0, r0, c7, c5, 4 /* flush prefetch buffer */
|
||||||
|
|
||||||
|
mcr p15, 0, r0, c8, c7, 0 /* invalidate all unlocked entries in TLB */
|
||||||
|
mcr p15, 0, r0, c13, c0, 0 /* disable context id register */
|
||||||
|
/* XXX: arm1176jaf page 249/972 */
|
||||||
|
// TODO: put it in mmu-armv6.S
|
||||||
|
// mcr p15, 0, r0, c2, c0, 2 /* write translation table control register (set backwards compatiblity) */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* reset VIC controller */ // TODO: this could go to system_init()
|
||||||
ldr r1, =0x38e00000
|
ldr r1, =0x38e00000
|
||||||
add r2, r1, #0x00001000
|
add r2, r1, #0x00001000
|
||||||
add r3, r1, #0x00002000
|
add r3, r1, #0x00002000
|
||||||
|
@ -86,7 +130,7 @@ start_loc:
|
||||||
str r4, [r2,#0xf00]
|
str r4, [r2,#0xf00]
|
||||||
str r4, [r3,#0x08]
|
str r4, [r3,#0x08]
|
||||||
str r4, [r3,#0x0c]
|
str r4, [r3,#0x0c]
|
||||||
str r0, [r1,#0x14]
|
str r0, [r1,#0x14] // TODO: This is not done by s5l8720, and I don't think it's necessary for s5l8702
|
||||||
str r0, [r2,#0x14]
|
str r0, [r2,#0x14]
|
||||||
|
|
||||||
#if defined(BOOTLOADER)
|
#if defined(BOOTLOADER)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue