summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Buren <braewoods+rb@braewoods.net>2020-11-14 14:29:18 +0000
committerJames Buren <braewoods+rb@braewoods.net>2020-11-14 14:29:18 +0000
commitaaa9a2cceedf45b04a85b206cd622a6fb1d9da77 (patch)
treee993961c0746ed1efd6d5c6a6ebbe976be1d2cd4
parent37eabbfe51e7ed7938c51934921f28cd54a1140d (diff)
downloadrockbox-aaa9a2cceedf45b04a85b206cd622a6fb1d9da77.tar.gz
rockbox-aaa9a2cceedf45b04a85b206cd622a6fb1d9da77.zip
h1x0/h300: clean up the bootloader source a bit
First this removes most of the conditionals for the CPP as they are always true for the targets that use the bootloader source. Second this moves some global variable references around to reduce some redundancy in the h1x0 bootloader source. All of this is done to make it easier to compare the two bootloaders as they are very heavily related to each other. Change-Id: I7eb4a3106fb9fce6059797310d9e053a3d3ecf63
-rw-r--r--bootloader/iriver_h1x0.c25
-rw-r--r--bootloader/iriver_h300.c11
2 files changed, 10 insertions, 26 deletions
diff --git a/bootloader/iriver_h1x0.c b/bootloader/iriver_h1x0.c
index e744b642b0..168bd29b67 100644
--- a/bootloader/iriver_h1x0.c
+++ b/bootloader/iriver_h1x0.c
@@ -57,6 +57,10 @@
57 57
58#define DRAM_START 0x31000000 58#define DRAM_START 0x31000000
59 59
60/* From common.c */
61extern int line;
62extern int remote_line;
63
60#ifdef HAVE_EEPROM_SETTINGS 64#ifdef HAVE_EEPROM_SETTINGS
61static bool recovery_mode = false; 65static bool recovery_mode = false;
62#endif 66#endif
@@ -89,7 +93,6 @@ void start_firmware(void)
89 asm(" jmp (%a0)"); 93 asm(" jmp (%a0)");
90} 94}
91 95
92#ifdef IRIVER_H100_SERIES
93void start_flashed_romimage(void) 96void start_flashed_romimage(void)
94{ 97{
95 uint8_t *src = (uint8_t *)FLASH_ROMIMAGE_ENTRY; 98 uint8_t *src = (uint8_t *)FLASH_ROMIMAGE_ENTRY;
@@ -134,7 +137,6 @@ void start_flashed_ramimage(void)
134 /* Failure */ 137 /* Failure */
135 power_off(); 138 power_off();
136} 139}
137#endif /* IRIVER_H100_SERIES */
138 140
139void shutdown(void) 141void shutdown(void)
140{ 142{
@@ -159,9 +161,7 @@ void shutdown(void)
159 161
160 /* Backlight OFF */ 162 /* Backlight OFF */
161 backlight_hw_off(); 163 backlight_hw_off();
162#ifdef HAVE_REMOTE_LCD
163 remote_backlight_hw_off(); 164 remote_backlight_hw_off();
164#endif
165 165
166 __reset_cookie(); 166 __reset_cookie();
167 power_off(); 167 power_off();
@@ -252,7 +252,6 @@ void failsafe_menu(void)
252 int defopt = -1; 252 int defopt = -1;
253 char buf[32]; 253 char buf[32];
254 int i; 254 int i;
255 extern int line;
256 255
257 reset_screen(); 256 reset_screen();
258 printf("Bootloader %s", rbversion); 257 printf("Bootloader %s", rbversion);
@@ -362,18 +361,14 @@ void failsafe_menu(void)
362 -> RESET signal */ 361 -> RESET signal */
363inline static void __uda1380_reset_hi(void) 362inline static void __uda1380_reset_hi(void)
364{ 363{
365#ifdef HAVE_UDA1380
366 or_l(1<<29, &GPIO_OUT); 364 or_l(1<<29, &GPIO_OUT);
367 or_l(1<<29, &GPIO_ENABLE); 365 or_l(1<<29, &GPIO_ENABLE);
368 or_l(1<<29, &GPIO_FUNCTION); 366 or_l(1<<29, &GPIO_FUNCTION);
369#endif
370} 367}
371 368
372inline static void __uda1380_reset_lo(void) 369inline static void __uda1380_reset_lo(void)
373{ 370{
374#ifdef HAVE_UDA1380
375 and_l(~(1<<29), &GPIO_OUT); 371 and_l(~(1<<29), &GPIO_OUT);
376#endif
377} 372}
378 373
379void main(void) 374void main(void)
@@ -385,8 +380,6 @@ void main(void)
385 bool rec_button = false; 380 bool rec_button = false;
386 bool hold_status = false; 381 bool hold_status = false;
387 int data; 382 int data;
388 extern int line; /* From common.c */
389 extern int remote_line; /* From common.c */
390 383
391 /* We want to read the buttons as early as possible, before the user 384 /* We want to read the buttons as early as possible, before the user
392 releases the ON button */ 385 releases the ON button */
@@ -422,22 +415,16 @@ void main(void)
422 backlight_hw_off(); 415 backlight_hw_off();
423 416
424 /* Remote backlight ON */ 417 /* Remote backlight ON */
425#ifdef HAVE_REMOTE_LCD
426 remote_backlight_hw_on(); 418 remote_backlight_hw_on();
427#endif
428 419
429 system_init(); 420 system_init();
430 kernel_init(); 421 kernel_init();
431 422
432 __uda1380_reset_lo(); 423 __uda1380_reset_lo();
433 424
434#ifdef HAVE_ADJUSTABLE_CPU_FREQ
435 /* Set up waitstates for the peripherals */ 425 /* Set up waitstates for the peripherals */
436 set_cpu_frequency(0); /* PLL off */ 426 set_cpu_frequency(0); /* PLL off */
437#ifdef CPU_COLDFIRE
438 coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); 427 coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS);
439#endif
440#endif
441 enable_irq(); 428 enable_irq();
442 429
443#ifdef HAVE_EEPROM_SETTINGS 430#ifdef HAVE_EEPROM_SETTINGS
@@ -547,10 +534,8 @@ void main(void)
547 lcd_putsxy((LCD_WIDTH-w)/2, (LCD_HEIGHT-h)/2, msg); 534 lcd_putsxy((LCD_WIDTH-w)/2, (LCD_HEIGHT-h)/2, msg);
548 lcd_update(); 535 lcd_update();
549 536
550#ifdef HAVE_REMOTE_LCD
551 lcd_remote_puts(0, 3, msg); 537 lcd_remote_puts(0, 3, msg);
552 lcd_remote_update(); 538 lcd_remote_update();
553#endif
554 539
555#ifdef HAVE_EEPROM_SETTINGS 540#ifdef HAVE_EEPROM_SETTINGS
556 if (firmware_settings.initialized) 541 if (firmware_settings.initialized)
@@ -608,7 +593,7 @@ void main(void)
608 593
609 printf("Loading firmware"); 594 printf("Loading firmware");
610 i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE); 595 i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE);
611 if(i < 0) 596 if(i <= EFILE_EMPTY)
612 printf("Error: %s", loader_strerror(i)); 597 printf("Error: %s", loader_strerror(i));
613 598
614 if (i > 0) 599 if (i > 0)
diff --git a/bootloader/iriver_h300.c b/bootloader/iriver_h300.c
index 4f4baf8cb5..ee344d4165 100644
--- a/bootloader/iriver_h300.c
+++ b/bootloader/iriver_h300.c
@@ -58,6 +58,10 @@
58 58
59#define DRAM_START 0x31000000 59#define DRAM_START 0x31000000
60 60
61/* From common.c */
62extern int line;
63extern int remote_line;
64
61/* Reset the cookie for the crt0 crash check */ 65/* Reset the cookie for the crt0 crash check */
62inline void __reset_cookie(void) 66inline void __reset_cookie(void)
63{ 67{
@@ -130,10 +134,6 @@ void check_battery(void)
130/* From the pcf50606 driver */ 134/* From the pcf50606 driver */
131extern unsigned char pcf50606_intregs[3]; 135extern unsigned char pcf50606_intregs[3];
132 136
133/* From common.c */
134extern int line;
135extern int remote_line;
136
137void main(void) 137void main(void)
138{ 138{
139 int i; 139 int i;
@@ -144,7 +144,6 @@ void main(void)
144 bool hold_status = false; 144 bool hold_status = false;
145 int data; 145 int data;
146 bool rtc_alarm; 146 bool rtc_alarm;
147 int button;
148 int mask; 147 int mask;
149 bool usb_charge = false; 148 bool usb_charge = false;
150 149
@@ -267,7 +266,7 @@ void main(void)
267 266
268 while(charger_inserted() && !request_start) 267 while(charger_inserted() && !request_start)
269 { 268 {
270 button = button_get_w_tmo(HZ); 269 long button = button_get_w_tmo(HZ);
271 270
272 switch(button) 271 switch(button)
273 { 272 {