summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-02-04 18:24:58 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-02-04 18:24:58 +0000
commitf1530d8a8267f6ff6686623f12da3c3cf33b9888 (patch)
treed3c32fa680354a2fc0bc87ca6a10e41ab8ab7142
parentb143652572219241950a2e9f953e3bc7be31e42c (diff)
downloadrockbox-f1530d8a8267f6ff6686623f12da3c3cf33b9888.tar.gz
rockbox-f1530d8a8267f6ff6686623f12da3c3cf33b9888.zip
Boot loader safety measures
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5791 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/main.c5
-rw-r--r--firmware/crt0.S15
2 files changed, 20 insertions, 0 deletions
diff --git a/bootloader/main.c b/bootloader/main.c
index 0a18bed9ec..11e0f71801 100644
--- a/bootloader/main.c
+++ b/bootloader/main.c
@@ -45,7 +45,9 @@ int usb_screen(void)
45void start_iriver_fw(void) 45void start_iriver_fw(void)
46{ 46{
47 asm(" move.w #0x2700,%sr"); 47 asm(" move.w #0x2700,%sr");
48 /* Reset the cookie for the crt0 crash check */
48 asm(" move.l #0,%d0"); 49 asm(" move.l #0,%d0");
50 asm(" move.l %d0,0x10017ffc");
49 asm(" movec.l %d0,%vbr"); 51 asm(" movec.l %d0,%vbr");
50 asm(" move.l 0,%sp"); 52 asm(" move.l 0,%sp");
51 asm(" lea.l 8,%a0"); 53 asm(" lea.l 8,%a0");
@@ -110,6 +112,9 @@ int load_firmware(void)
110void start_firmware(void) 112void start_firmware(void)
111{ 113{
112 asm(" move.w #0x2700,%sr"); 114 asm(" move.w #0x2700,%sr");
115 /* Reset the cookie for the crt0 crash check */
116 asm(" move.l #0,%d0");
117 asm(" move.l %d0,0x10017ffc");
113 asm(" move.l #0x30000000,%d0"); 118 asm(" move.l #0x30000000,%d0");
114 asm(" movec.l %d0,%vbr"); 119 asm(" movec.l %d0,%vbr");
115 asm(" move.l 0x30000000,%sp"); 120 asm(" move.l 0x30000000,%sp");
diff --git a/firmware/crt0.S b/firmware/crt0.S
index 1f385d4ce5..339366582f 100644
--- a/firmware/crt0.S
+++ b/firmware/crt0.S
@@ -173,6 +173,21 @@ irq_handler:
173 173
174 174
175#ifdef BOOTLOADER 175#ifdef BOOTLOADER
176 /* The cookie is not reset. This must mean that the boot loader
177 has crashed. Let's start the original firmware immediately. */
178 lea 0x10017ffc,%a2
179 move.l (%a2),%d0
180 move.l #0xc0015a17,%d1
181 cmp.l %d0,%d1
182 bne .nocookie
183 /* Clear the cookie again */
184 move.l #0,(%a2)
185 jmp 8
186
187.nocookie:
188 /* Set the cookie */
189 move.l %d1,(%a2)
190
176 /* Set up the DRAM controller. The refresh is based on the 11.2896MHz 191 /* Set up the DRAM controller. The refresh is based on the 11.2896MHz
177 clock (5.6448MHz bus frequency). We haven't yet started the PLL */ 192 clock (5.6448MHz bus frequency). We haven't yet started the PLL */
178 move.l #0x80050000,%d0 193 move.l #0x80050000,%d0