diff options
Diffstat (limited to 'utils/hwstub/stub/pp/crt0.S')
-rw-r--r-- | utils/hwstub/stub/pp/crt0.S | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/hwstub/stub/pp/crt0.S b/utils/hwstub/stub/pp/crt0.S new file mode 100644 index 0000000000..38b6f18ac5 --- /dev/null +++ b/utils/hwstub/stub/pp/crt0.S | |||
@@ -0,0 +1,42 @@ | |||
1 | .section .text,"ax",%progbits | ||
2 | .code 32 | ||
3 | .align 0x04 | ||
4 | .global start | ||
5 | start: | ||
6 | sub r7, pc, #8 /* Copy running address */ | ||
7 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ | ||
8 | /* The stub could be located at a virtual address so killing the MMU at | ||
9 | * this point would be mere suicide. We assume that the remap location | ||
10 | * is identically mapped and kill the MMU after the copy */ | ||
11 | |||
12 | /* Relocate to right address */ | ||
13 | mov r2, r7 | ||
14 | ldr r3, =_copystart | ||
15 | ldr r4, =_copyend | ||
16 | 1: | ||
17 | cmp r4, r3 | ||
18 | ldrhi r5, [r2], #4 | ||
19 | strhi r5, [r3], #4 | ||
20 | bhi 1b | ||
21 | mov r2, #0 | ||
22 | mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache | ||
23 | /* Jump to real location */ | ||
24 | ldr pc, =remap | ||
25 | remap: | ||
26 | /* Disable MMU, disable caching and buffering; | ||
27 | * use low exception range address */ | ||
28 | mrc p15, 0, r0, c1, c0, 0 | ||
29 | ldr r1, =0x3005 | ||
30 | bic r0, r1 | ||
31 | mcr p15, 0, r0, c1, c0, 0 | ||
32 | /* clear bss */ | ||
33 | ldr r2, =bss_start | ||
34 | ldr r3, =bss_end | ||
35 | mov r4, #0 | ||
36 | 1: | ||
37 | cmp r3, r2 | ||
38 | strhi r4, [r2], #4 | ||
39 | bhi 1b | ||
40 | /* jump to C code */ | ||
41 | ldr sp, =oc_stackend | ||
42 | b main | ||