rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | |
| 2 | .syntax unified |
| 3 | |
| 4 | miniloader_vectors: |
| 5 | .word 0x20003FF0 |
| 6 | .word miniloader_reset + 1 |
| 7 | .word miniloader_fault + 1 |
| 8 | .word miniloader_fault + 1 |
| 9 | .word miniloader_fault + 1 |
| 10 | .word miniloader_fault + 1 |
| 11 | .word miniloader_fault + 1 |
| 12 | .word miniloader_fault + 1 |
| 13 | .word miniloader_fault + 1 |
| 14 | .word miniloader_fault + 1 |
| 15 | .word miniloader_fault + 1 |
| 16 | .word miniloader_fault + 1 |
| 17 | .word miniloader_fault + 1 |
| 18 | .word miniloader_fault + 1 |
| 19 | .word miniloader_fault + 1 |
| 20 | .word miniloader_fault + 1 |
| 21 | |
| 22 | // miniloader_boot(unsigned src, unsigned count) |
| 23 | miniloader_boot: |
| 24 | mov r2, #0x10000000 |
| 25 | miniloader_boot_loop: |
| 26 | ldr r3, [r0], #4 |
| 27 | str r3, [r2], #4 |
| 28 | subs r1, #1 |
| 29 | bne miniloader_boot_loop |
| 30 | mov r0, #0x10000000 |
| 31 | ldr sp, [r0] |
| 32 | ldr r0, [r0, #4] |
| 33 | bx r0 |
| 34 | |
| 35 | miniloader_reset: |
| 36 | ldr r0, =0x20003FF8 |
| 37 | ldr r1, =0xAA113377 |
| 38 | ldr r2, =0xAA773311 |
| 39 | ldr r3, [r0] |
| 40 | ldr r4, [r0, #4] |
| 41 | mov r5, #0 |
| 42 | str r5, [r0] |
| 43 | str r5, [r0, #4] |
| 44 | cmp r1, r3 |
| 45 | bne start_bootloader |
| 46 | cmp r2, r4 |
| 47 | bne start_bootloader |
| 48 | start_app: |
| 49 | ldr r0, =0x8000 |
| 50 | ldr r1, =(131072/4) |
| 51 | b miniloader_boot |
| 52 | start_bootloader: |
| 53 | ldr r0, =0x00001000 |
| 54 | ldr r1, =(32768/4) |
| 55 | b miniloader_boot |
| 56 | |
| 57 | miniloader_fault: |
| 58 | b . |