summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/stub/pp/crt0.S
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 22:23:54 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 22:26:50 +0200
commitccfa51835e373c74cdda7eaad962a81ba1001fe2 (patch)
treed827d1027626cae478ab25742f78ffa11a90d2bf /utils/hwstub/stub/pp/crt0.S
parent399acc038750943c1a0ee7178a18714334871472 (diff)
downloadrockbox-ccfa51835e373c74cdda7eaad962a81ba1001fe2.tar.gz
rockbox-ccfa51835e373c74cdda7eaad962a81ba1001fe2.zip
Add hwstub support for portal player (manufacturer mode)
It is very similar to how e200tool from MrH works but uses the framework of hwstub which is makes it completely trivial since we already have the USB driver written. Change-Id: I61cdc245d3f828c2682bcd6ecfed5a1cc0094139
Diffstat (limited to 'utils/hwstub/stub/pp/crt0.S')
-rw-r--r--utils/hwstub/stub/pp/crt0.S42
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 @@
+.section .text,"ax",%progbits
+.code 32
+.align 0x04
+.global start
+start:
+ sub r7, pc, #8 /* Copy running address */
+ msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
+ /* The stub could be located at a virtual address so killing the MMU at
+ * this point would be mere suicide. We assume that the remap location
+ * is identically mapped and kill the MMU after the copy */
+
+ /* Relocate to right address */
+ mov r2, r7
+ ldr r3, =_copystart
+ ldr r4, =_copyend
+1:
+ cmp r4, r3
+ ldrhi r5, [r2], #4
+ strhi r5, [r3], #4
+ bhi 1b
+ mov r2, #0
+ mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache
+ /* Jump to real location */
+ ldr pc, =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 */
+ ldr r2, =bss_start
+ ldr r3, =bss_end
+ mov r4, #0
+1:
+ cmp r3, r2
+ strhi r4, [r2], #4
+ bhi 1b
+ /* jump to C code */
+ ldr sp, =oc_stackend
+ b main