diff options
Diffstat (limited to 'bootloader/iriver_h1x0.c')
-rw-r--r-- | bootloader/iriver_h1x0.c | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/bootloader/iriver_h1x0.c b/bootloader/iriver_h1x0.c index 168bd29b67..d5a3b887a2 100644 --- a/bootloader/iriver_h1x0.c +++ b/bootloader/iriver_h1x0.c | |||
@@ -61,9 +61,7 @@ | |||
61 | extern int line; | 61 | extern int line; |
62 | extern int remote_line; | 62 | extern int remote_line; |
63 | 63 | ||
64 | #ifdef HAVE_EEPROM_SETTINGS | ||
65 | static bool recovery_mode = false; | 64 | static bool recovery_mode = false; |
66 | #endif | ||
67 | 65 | ||
68 | /* Reset the cookie for the crt0 crash check */ | 66 | /* Reset the cookie for the crt0 crash check */ |
69 | inline void __reset_cookie(void) | 67 | inline void __reset_cookie(void) |
@@ -96,12 +94,12 @@ void start_firmware(void) | |||
96 | void start_flashed_romimage(void) | 94 | void start_flashed_romimage(void) |
97 | { | 95 | { |
98 | uint8_t *src = (uint8_t *)FLASH_ROMIMAGE_ENTRY; | 96 | uint8_t *src = (uint8_t *)FLASH_ROMIMAGE_ENTRY; |
99 | int *reset_vector; | 97 | uint32_t *reset_vector; |
100 | 98 | ||
101 | if (!detect_flashed_romimage()) | 99 | if (!detect_flashed_romimage()) |
102 | return ; | 100 | return ; |
103 | 101 | ||
104 | reset_vector = (int *)(&src[sizeof(struct flash_header)+4]); | 102 | reset_vector = (uint32_t *)(&src[sizeof(struct flash_header)+sizeof(uint32_t)]); |
105 | 103 | ||
106 | asm(" move.w #0x2700,%sr"); | 104 | asm(" move.w #0x2700,%sr"); |
107 | __reset_cookie(); | 105 | __reset_cookie(); |
@@ -119,7 +117,7 @@ void start_flashed_romimage(void) | |||
119 | void start_flashed_ramimage(void) | 117 | void start_flashed_ramimage(void) |
120 | { | 118 | { |
121 | struct flash_header hdr; | 119 | struct flash_header hdr; |
122 | unsigned char *buf = (unsigned char *)DRAM_START; | 120 | uint8_t *buf = (uint8_t *)DRAM_START; |
123 | uint8_t *src = (uint8_t *)FLASH_RAMIMAGE_ENTRY; | 121 | uint8_t *src = (uint8_t *)FLASH_RAMIMAGE_ENTRY; |
124 | 122 | ||
125 | if (!detect_flashed_ramimage()) | 123 | if (!detect_flashed_ramimage()) |
@@ -141,11 +139,9 @@ void start_flashed_ramimage(void) | |||
141 | void shutdown(void) | 139 | void shutdown(void) |
142 | { | 140 | { |
143 | printf("Shutting down..."); | 141 | printf("Shutting down..."); |
144 | #ifdef HAVE_EEPROM_SETTINGS | ||
145 | /* Reset the rockbox crash check. */ | 142 | /* Reset the rockbox crash check. */ |
146 | firmware_settings.bl_version = 0; | 143 | firmware_settings.bl_version = 0; |
147 | eeprom_settings_store(); | 144 | eeprom_settings_store(); |
148 | #endif | ||
149 | 145 | ||
150 | /* We need to gracefully spin down the disk to prevent clicks. */ | 146 | /* We need to gracefully spin down the disk to prevent clicks. */ |
151 | if (ide_powered()) | 147 | if (ide_powered()) |
@@ -185,7 +181,6 @@ void check_battery(void) | |||
185 | } | 181 | } |
186 | } | 182 | } |
187 | 183 | ||
188 | #ifdef HAVE_EEPROM_SETTINGS | ||
189 | void initialize_eeprom(void) | 184 | void initialize_eeprom(void) |
190 | { | 185 | { |
191 | if (detect_original_firmware()) | 186 | if (detect_original_firmware()) |
@@ -235,17 +230,17 @@ void try_flashboot(void) | |||
235 | } | 230 | } |
236 | } | 231 | } |
237 | 232 | ||
238 | static const char *options[] = { | ||
239 | "Boot from disk", | ||
240 | "Boot RAM image", | ||
241 | "Boot ROM image", | ||
242 | "Shutdown" | ||
243 | }; | ||
244 | |||
245 | #define FAILSAFE_OPTIONS 4 | ||
246 | #define TIMEOUT (15*HZ) | ||
247 | void failsafe_menu(void) | 233 | void failsafe_menu(void) |
248 | { | 234 | { |
235 | static const char *options[] = | ||
236 | { | ||
237 | "Boot from disk", | ||
238 | "Boot RAM image", | ||
239 | "Boot ROM image", | ||
240 | "Shutdown" | ||
241 | }; | ||
242 | const int FAILSAFE_OPTIONS = sizeof(options) / sizeof(*options); | ||
243 | const long TIMEOUT = 15 * HZ; | ||
249 | long start_tick = current_tick; | 244 | long start_tick = current_tick; |
250 | int option = 3; | 245 | int option = 3; |
251 | int button; | 246 | int button; |
@@ -355,7 +350,6 @@ void failsafe_menu(void) | |||
355 | 350 | ||
356 | shutdown(); | 351 | shutdown(); |
357 | } | 352 | } |
358 | #endif | ||
359 | 353 | ||
360 | /* get rid of a nasty humming sound during boot | 354 | /* get rid of a nasty humming sound during boot |
361 | -> RESET signal */ | 355 | -> RESET signal */ |
@@ -427,9 +421,7 @@ void main(void) | |||
427 | coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); | 421 | coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); |
428 | enable_irq(); | 422 | enable_irq(); |
429 | 423 | ||
430 | #ifdef HAVE_EEPROM_SETTINGS | ||
431 | initialize_eeprom(); | 424 | initialize_eeprom(); |
432 | #endif | ||
433 | 425 | ||
434 | usb_init(); | 426 | usb_init(); |
435 | /* A small delay after usb_init is necessary to read the I/O port correctly | 427 | /* A small delay after usb_init is necessary to read the I/O port correctly |
@@ -458,19 +450,11 @@ void main(void) | |||
458 | } | 450 | } |
459 | 451 | ||
460 | /* Power on the hard drive early, to speed up the loading. */ | 452 | /* Power on the hard drive early, to speed up the loading. */ |
461 | if (!hold_status | 453 | if (!hold_status && !recovery_mode) |
462 | # ifdef HAVE_EEPROM_SETTINGS | ||
463 | && !recovery_mode | ||
464 | # endif | ||
465 | ) | ||
466 | { | ||
467 | ide_power_enable(true); | 454 | ide_power_enable(true); |
468 | } | ||
469 | 455 | ||
470 | # ifdef HAVE_EEPROM_SETTINGS | ||
471 | if (!hold_status && (usb_detect() != USB_INSERTED) && !recovery_mode) | 456 | if (!hold_status && (usb_detect() != USB_INSERTED) && !recovery_mode) |
472 | try_flashboot(); | 457 | try_flashboot(); |
473 | # endif | ||
474 | 458 | ||
475 | lcd_init(); | 459 | lcd_init(); |
476 | 460 | ||
@@ -500,11 +484,7 @@ void main(void) | |||
500 | 484 | ||
501 | /* Don't start if the Hold button is active on the device you | 485 | /* Don't start if the Hold button is active on the device you |
502 | are starting with */ | 486 | are starting with */ |
503 | if ((usb_detect() != USB_INSERTED) && (hold_status | 487 | if ((usb_detect() != USB_INSERTED) && (hold_status || recovery_mode)) |
504 | #ifdef HAVE_EEPROM_SETTINGS | ||
505 | || recovery_mode | ||
506 | #endif | ||
507 | )) | ||
508 | { | 488 | { |
509 | if (detect_original_firmware()) | 489 | if (detect_original_firmware()) |
510 | { | 490 | { |
@@ -512,9 +492,7 @@ void main(void) | |||
512 | shutdown(); | 492 | shutdown(); |
513 | } | 493 | } |
514 | 494 | ||
515 | #ifdef HAVE_EEPROM_SETTINGS | ||
516 | failsafe_menu(); | 495 | failsafe_menu(); |
517 | #endif | ||
518 | } | 496 | } |
519 | 497 | ||
520 | /* Holding REC while starting runs the original firmware */ | 498 | /* Holding REC while starting runs the original firmware */ |
@@ -537,13 +515,12 @@ void main(void) | |||
537 | lcd_remote_puts(0, 3, msg); | 515 | lcd_remote_puts(0, 3, msg); |
538 | lcd_remote_update(); | 516 | lcd_remote_update(); |
539 | 517 | ||
540 | #ifdef HAVE_EEPROM_SETTINGS | ||
541 | if (firmware_settings.initialized) | 518 | if (firmware_settings.initialized) |
542 | { | 519 | { |
543 | firmware_settings.disk_clean = false; | 520 | firmware_settings.disk_clean = false; |
544 | eeprom_settings_store(); | 521 | eeprom_settings_store(); |
545 | } | 522 | } |
546 | #endif | 523 | |
547 | ide_power_enable(true); | 524 | ide_power_enable(true); |
548 | storage_enable(false); | 525 | storage_enable(false); |
549 | sleep(HZ/20); | 526 | sleep(HZ/20); |
@@ -570,6 +547,11 @@ void main(void) | |||
570 | lcd_update(); | 547 | lcd_update(); |
571 | } | 548 | } |
572 | 549 | ||
550 | /* boot from flash if that is the default */ | ||
551 | try_flashboot(); | ||
552 | if (recovery_mode) | ||
553 | printf("Falling back to boot from disk"); | ||
554 | |||
573 | rc = storage_init(); | 555 | rc = storage_init(); |
574 | if(rc) | 556 | if(rc) |
575 | { | 557 | { |
@@ -580,7 +562,6 @@ void main(void) | |||
580 | while(!(button_get(true) & BUTTON_REL)); | 562 | while(!(button_get(true) & BUTTON_REL)); |
581 | } | 563 | } |
582 | 564 | ||
583 | |||
584 | filesystem_init(); | 565 | filesystem_init(); |
585 | 566 | ||
586 | rc = disk_mount_all(); | 567 | rc = disk_mount_all(); |