summaryrefslogtreecommitdiffstats
path: root/bootloader/telechips.c
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2008-03-29 17:26:16 +0000
committerRob Purchase <shotofadds@rockbox.org>2008-03-29 17:26:16 +0000
commit3b46671a40f4338b7ace8cdb64cf716f73626f31 (patch)
tree59381645ee4dd78815623567180bdc5dc07f8da7 /bootloader/telechips.c
parentedf6d90ca4a488bf49e377475e6982cb03f1f2bb (diff)
downloadrockbox-3b46671a40f4338b7ace8cdb64cf716f73626f31.tar.gz
rockbox-3b46671a40f4338b7ace8cdb64cf716f73626f31.tar.bz2
rockbox-3b46671a40f4338b7ace8cdb64cf716f73626f31.zip
Make the Telechips bootloader slightly less messy, kill some warnings and allow entry to the bootloader debug screen via the D2's hold switch.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16879 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader/telechips.c')
-rw-r--r--bootloader/telechips.c125
1 files changed, 68 insertions, 57 deletions
diff --git a/bootloader/telechips.c b/bootloader/telechips.c
index 305bdf3081..4c8b6ef5fd 100644
--- a/bootloader/telechips.c
+++ b/bootloader/telechips.c
@@ -35,6 +35,7 @@
#include "button.h"
#include "adc.h"
#include "adc-target.h"
+#include "backlight.h"
#include "backlight-target.h"
#include "panic.h"
#include "power.h"
@@ -52,66 +53,12 @@ extern int line;
#define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */
-void* main(void)
+void show_debug_screen(void)
{
int button;
int power_count = 0;
int count = 0;
bool do_power_off = false;
-
-#if defined(COWON_D2) && defined(TCCBOOT)
- int rc;
- unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS;
-#endif
-
- power_init();
- system_init();
- lcd_init();
-
- adc_init();
- button_init();
- backlight_init();
-
- font_init();
- lcd_setfont(FONT_SYSFIXED);
-
- _backlight_on();
-
-/* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
- available for loading the firmware. Otherwise display the debug screen. */
-#if defined(COWON_D2) && defined(TCCBOOT)
- printf("Rockbox boot loader");
- printf("Version %s", version);
-
- printf("ATA");
- rc = ata_init();
- if(rc)
- {
- reset_screen();
- error(EATA, rc);
- }
-
- printf("mount");
- rc = disk_mount_all();
- if (rc<=0)
- {
- error(EDISK,rc);
- }
-
- rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE);
-
- if (rc < 0)
- {
- error(EBOOTFILE,rc);
- }
- else if (rc == EOK)
- {
- int(*kernel_entry)(void);
-
- kernel_entry = (void*) loadbuffer;
- rc = kernel_entry();
- }
-#else
while(!do_power_off) {
line = 0;
@@ -140,7 +87,7 @@ void* main(void)
printf("GPIOC: 0x%08x",GPIOC);
printf("GPIOD: 0x%08x",GPIOD);
printf("GPIOE: 0x%08x",GPIOE);
-
+
for (i = 0; i<4; i++)
{
printf("ADC%d: 0x%04x",i,adc_read(i));
@@ -163,7 +110,7 @@ void* main(void)
y = (y*LCD_HEIGHT) / 1024;
lcd_hline(x-5, x+5, y);
lcd_vline(x, y-5, y+5);
-
+
buf[0] = 0x2f;
buf[1] = (0xF<<1) | 1; /* ADC start for P1+P2 */
i2c_write(0x10, buf, 2);
@@ -186,7 +133,71 @@ void* main(void)
power_off();
printf("(NOT) POWERED OFF");
+ while (true);
+}
+
+
+void* main(void)
+{
+#if defined(COWON_D2) && defined(TCCBOOT)
+ int rc;
+ unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS;
+#endif
+
+ power_init();
+ system_init();
+ lcd_init();
+
+ adc_init();
+ button_init();
+ backlight_init();
+
+ font_init();
+ lcd_setfont(FONT_SYSFIXED);
+
+ _backlight_on();
+
+/* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
+ available for loading the firmware. Otherwise display the debug screen. */
+#if defined(COWON_D2) && defined(TCCBOOT)
+ printf("Rockbox boot loader");
+ printf("Version %s", version);
+
+ printf("ATA");
+ rc = ata_init();
+ if(rc)
+ {
+ reset_screen();
+ error(EATA, rc);
+ }
+
+ printf("mount");
+ rc = disk_mount_all();
+ if (rc<=0)
+ {
+ error(EDISK,rc);
+ }
+
+ rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE);
+
+ if (rc < 0)
+ {
+ error(EBOOTFILE,rc);
+ }
+ else if (rc == EOK)
+ {
+ int(*kernel_entry)(void);
+
+ /* wait for button release to allow debug statememts to be read */
+ while (button_read_device()) {};
+
+ kernel_entry = (void*) loadbuffer;
+
+ /* allow entry to the debug screen if hold is on */
+ if (!button_hold()) rc = kernel_entry();
+ }
#endif
+ show_debug_screen();
return 0;
}