summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire')
-rw-r--r--firmware/target/coldfire/crt0.S58
1 files changed, 51 insertions, 7 deletions
diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S
index 7fc389c23d..c177cd4e27 100644
--- a/firmware/target/coldfire/crt0.S
+++ b/firmware/target/coldfire/crt0.S
@@ -89,28 +89,40 @@ start:
89#endif 89#endif
90 90
91#ifdef BOOTLOADER 91#ifdef BOOTLOADER
92 /* Check if original firmware is still present */ 92 /* Check if we have a Rockbox ROM image */
93 lea 0x00100000,%a2
94 move.l (%a2),%d0
95 move.l #FLASH_MAGIC,%d1
96 cmp.l %d0,%d1
97 beq.b .imagefound
98
99 /* Check for RAM image */
93 lea 0x00001000,%a2 100 lea 0x00001000,%a2
94 move.l (%a2),%d0 101 move.l (%a2),%d0
95 move.l #0xfbfbfbf1,%d1 102 move.l #FLASH_MAGIC,%d1
96 cmp.l %d0,%d1 103 cmp.l %d0,%d1
97 beq.b .ignorecookie 104 beq.b .imagefound
98 105
99 /* The cookie is not reset. This must mean that the boot loader 106 /* Not either ROM or RAM image was found, so original firmware
100 has crashed. Let's start the original firmware immediately. */ 107 should be still present. */
108
109 /* Check if the cookie is present. */
101 lea 0x10017ffc,%a2 110 lea 0x10017ffc,%a2
102 move.l (%a2),%d0 111 move.l (%a2),%d0
103 move.l #0xc0015a17,%d1 112 move.l #0xc0015a17,%d1
104 cmp.l %d0,%d1 113 cmp.l %d0,%d1
105 bne.b .nocookie 114 bne.b .nocookie
106 /* Clear the cookie again */ 115
116 /* The cookie is not reset. This must mean that the boot loader
117 has crashed. Let's start the original firmware immediately. */
118 lea 0x10017ffc,%a2
107 clr.l (%a2) 119 clr.l (%a2)
108 jmp 8 120 jmp 8
109 121
110.nocookie: 122.nocookie:
111 /* Set the cookie */ 123 /* Set the cookie */
112 move.l %d1,(%a2) 124 move.l %d1,(%a2)
113.ignorecookie: 125.imagefound:
114 126
115 /* Set up the DRAM controller. The refresh is based on the 11.2896MHz 127 /* Set up the DRAM controller. The refresh is based on the 11.2896MHz
116 clock (5.6448MHz bus frequency). We haven't yet started the PLL */ 128 clock (5.6448MHz bus frequency). We haven't yet started the PLL */
@@ -168,6 +180,38 @@ start:
168 move.l %d0,0x31000800 /* A12=1 means CASL=1 (a0 is not connected) */ 180 move.l %d0,0x31000800 /* A12=1 means CASL=1 (a0 is not connected) */
169 181
170 /* DACR0[IMRS] gets deactivated by the SDRAM controller */ 182 /* DACR0[IMRS] gets deactivated by the SDRAM controller */
183
184 /* Check if we have a Rockbox ROM image. For RAM image only cookie is
185 not set at all. But we could support also RAM images loading. */
186 lea 0x00100000,%a2
187 move.l (%a2),%d0
188 move.l #FLASH_MAGIC,%d1
189 cmp.l %d0,%d1
190 bne.b .noromimage
191
192 /* Check again if the cookie is present. */
193 lea 0x10017ffc,%a2
194 move.l (%a2),%d0
195 move.l #0xc0015a17,%d1
196 cmp.l %d0,%d1
197 bne.b .nocookie2
198
199 /* We have found Rockbox in ROM!
200 Clear the cookie and load the ROM image */
201 lea 0x10017ffc,%a2
202 clr.l (%a2)
203 lea 0x00100028+4,%a2
204 move.l (%a2),%sp
205 lea 0x00100028+8,%a2
206 move.l (%a2),%d0
207 move.l %d0,%a2
208 jmp (%a2)
209
210.nocookie2:
211 /* Set the cookie */
212 move.l %d1,(%a2)
213.noromimage:
214
171#endif /* BOOTLOADER */ 215#endif /* BOOTLOADER */
172 216
173 /* Invalicate cache */ 217 /* Invalicate cache */