1
0
Fork 0
forked from len0rd/rockbox

utils/hwstub: make stmp stub able to load in a MMU'ed environement

In might be useful to load hwstub in an environment with the MMU active,
in which case care must be taken on the order in which things are done.
Mostly, one should not disable the MMU before moving stuff around. The code
assumes the linking address (0 currently) is identity mapped.

Change-Id: I8d54ce9e8cadcde2e08990353ca7a46803731ca7
This commit is contained in:
Amaury Pouly 2014-02-04 00:16:46 +01:00
parent c17d30f204
commit 81dfed27cf

View file

@ -5,12 +5,10 @@
start: start:
sub r7, pc, #8 /* Copy running address */ sub r7, pc, #8 /* Copy running address */
msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
/* Disable MMU, disable caching and buffering; /* The stub could be located at a virtual address so killing the MMU at
* use low exception range address */ * this point would be mere suicide. We assume that the remap location
mrc p15, 0, r0, c1, c0, 0 * is identically mapped and kill the MMU after the copy */
ldr r1, =0x3005
bic r0, r1
mcr p15, 0, r0, c1, c0, 0
/* Relocate to right address */ /* Relocate to right address */
mov r2, r7 mov r2, r7
ldr r3, =_copystart ldr r3, =_copystart
@ -25,6 +23,12 @@ start:
/* Jump to real location */ /* Jump to real location */
ldr pc, =remap ldr pc, =remap
remap: remap:
/* Disable MMU, disable caching and buffering;
* use low exception range address */
mrc p15, 0, r0, c1, c0, 0
ldr r1, =0x3005
bic r0, r1
mcr p15, 0, r0, c1, c0, 0
/* clear bss */ /* clear bss */
ldr r2, =bss_start ldr r2, =bss_start
ldr r3, =bss_end ldr r3, =bss_end