summaryrefslogtreecommitdiffstats
path: root/firmware/target/coldfire/crt0.S
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/crt0.S')
-rw-r--r--firmware/target/coldfire/crt0.S53
1 files changed, 51 insertions, 2 deletions
diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S
index e6717710b1..881fcf908f 100644
--- a/firmware/target/coldfire/crt0.S
+++ b/firmware/target/coldfire/crt0.S
@@ -26,11 +26,51 @@
.global start
start:
+#if defined(BOOTLOADER) && defined(HAVE_DUALBOOT) \
+ && (defined(IAUDIO_X5) || defined(IAUDIO_M5))
+
+ /* 8 byte dualboot signature */
+ bra.b 1f /* 0x6006 */
+ .short 0x4442 /* DB */
+#if defined(IAUDIO_X5)
+ .long 0x69617835 /* iax5 */
+#elif defined(IAUDIO_M5)
+ .long 0x69616d35 /* iam5 */
+#else
+#error Dualboot signature not defined
+#endif
+1:
+ /* As the control registers are write-only, we're relying on MBAR2 being */
+ /* set up correctly by the preloader for button check */
+ /* Only use scratch regs until we're sure that we will boot rockbox */
+ lea MBAR2, %a1
+ move.l (%a1), %a0 /* store GPIO_READ result for button check in main() */
+
+ /* Wait ~3 seconds for ON-button release. We need roughly 300ns per
+ iteration, so we check 10000000 times to reach the desired delay */
+ move.l #10000000, %d0
+.on_button_test:
+ move.l (%a1), %d1 /* GPIO_READ */
+ and.l #0x06000000, %d1 /* Check main (bit 25=0) and remote (bit 26=0) */
+ cmp.l #0x06000000, %d1 /* ON buttons simultaneously */
+ beq.b .loadrockbox
+ subq.l #1, %d0
+ bne.b .on_button_test
+
+.loadoriginal:
+ jmp 0x10010
+
+.loadrockbox:
+ move.l %a0, %d7 /* keep initial GPIO_READ value in %d7 for now */
+
+#endif /* defined(BOOTLOADER && defined(HAVE_DUALBOOT)
+ && (defined(IAUDIO_X5) || defined(IAUDIO_M5)) */
+
move.w #0x2700,%sr
move.l #vectors,%d0
movec.l %d0,%vbr
-
+
move.l #MBAR+1,%d0
movec.l %d0,%mbar
@@ -39,7 +79,12 @@ start:
lea MBAR,%a0
lea MBAR2,%a1
-
+
+#if defined(BOOTLOADER) && !defined(HAVE_DUALBOOT) \
+ && (defined(IAUDIO_X5) || defined(IAUDIO_M5))
+ move.l (%a1), %d7 /* store GPIO_READ result for button check in main() */
+#endif
+
clr.l (0x180,%a1) /* PLLCR = 0 */
/* 64K DMA-capable SRAM at 0x10000000
@@ -318,6 +363,10 @@ start:
move.l %d0,(%a2)+
cmp.l %a2,%a4
bhi.b .mungeloop
+
+#if defined(BOOTLOADER) && (defined(IAUDIO_X5) || defined(IAUDIO_M5))
+ move.l %d7, initial_gpio_read
+#endif
jsr main
.hoo: