summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader')
-rw-r--r--[-rwxr-xr-x]bootloader/ondavx747.c113
1 files changed, 93 insertions, 20 deletions
diff --git a/bootloader/ondavx747.c b/bootloader/ondavx747.c
index 0d3e592c6d..d60c311bb7 100755..100644
--- a/bootloader/ondavx747.c
+++ b/bootloader/ondavx747.c
@@ -34,6 +34,7 @@
34#include "adc.h" 34#include "adc.h"
35 35
36extern int show_logo(void); 36extern int show_logo(void);
37extern void power_off(void);
37 38
38static void show_splash(int timeout, const char *msg) 39static void show_splash(int timeout, const char *msg)
39{ 40{
@@ -130,7 +131,89 @@ static int boot_of(void)
130 kernel_entry = (void*) 0x80004008; 131 kernel_entry = (void*) 0x80004008;
131 kernel_entry(0, "Jan 10 2008", "15:34:42"); /* Reversed from the SPL */ 132 kernel_entry(0, "Jan 10 2008", "15:34:42"); /* Reversed from the SPL */
132 133
133 return 0; 134 return 0; /* Shouldn't happen */
135}
136
137static int boot_rockbox(void)
138{
139 int rc;
140 void (*kernel_entry)(void);
141
142 printf("Loading firmware");
143 rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000);
144 if(rc < 0)
145 return rc;
146 else
147 {
148 printf("Starting Rockbox...");
149 adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */
150
151 disable_interrupt();
152 kernel_entry = (void*) CONFIG_SDRAM_START;
153 kernel_entry();
154
155 return 0; /* Shouldn't happen */
156 }
157}
158
159#define RECT_X (LCD_WIDTH/8)
160#define RECT_Y(i) (LCD_HEIGHT/20 + LCD_HEIGHT/10*i + RECT_HEIGHT*i)
161#define RECT_WIDTH (LCD_WIDTH*3/4)
162#define RECT_HEIGHT (LCD_HEIGHT/ARRAYLEN(strings) - LCD_HEIGHT/10)
163#define TEXT_X(i) (RECT_X + RECT_WIDTH/2 - strlen(strings[i])*SYSFONT_WIDTH/2)
164#define TEXT_Y(i) (RECT_Y(i) + RECT_HEIGHT/2 - SYSFONT_HEIGHT/2)
165static int boot_menu(void)
166{
167 const char* strings[] = {"Boot Rockbox", "Boot OF", "USB mode"};
168 int button, touch;
169 unsigned int i;
170
171 adc_init();
172
173redraw:
174 lcd_clear_display();
175 for(i=0; i<ARRAYLEN(strings); i++)
176 {
177 lcd_drawrect(RECT_X, RECT_Y(i), RECT_WIDTH, RECT_HEIGHT);
178 lcd_putsxy(TEXT_X(i), TEXT_Y(i), strings[i]);
179 }
180 lcd_update();
181
182 while(1)
183 {
184 button = button_get_w_tmo(HZ/4);
185 if(button & (BUTTON_TOUCHSCREEN|BUTTON_REPEAT))
186 {
187 touch = button_get_data();
188 unsigned int x = touch & 0xFFFF, y = touch >> 16;
189 int found = -1;
190 for(i=0; i<ARRAYLEN(strings); i++)
191 {
192 if(x > RECT_X && x < RECT_X+RECT_WIDTH &&
193 y > RECT_Y(i) && y < RECT_Y(i)+RECT_HEIGHT)
194 {
195 found = i;
196 break;
197 }
198 }
199
200 switch(found)
201 {
202 case 0:
203 return boot_rockbox();
204 case 1:
205 return boot_of();
206 case 2:
207 usb_mode();
208 break;
209 }
210
211 if(found != -1)
212 goto redraw;
213 }
214 else if(button & (BUTTON_POWER|BUTTON_REPEAT))
215 power_off();
216 }
134} 217}
135 218
136int main(void) 219int main(void)
@@ -139,7 +222,6 @@ int main(void)
139#ifdef HAVE_TOUCHSCREEN 222#ifdef HAVE_TOUCHSCREEN
140 int dummy; 223 int dummy;
141#endif 224#endif
142 void (*kernel_entry)(void);
143 225
144 kernel_init(); 226 kernel_init();
145 lcd_init(); 227 lcd_init();
@@ -163,8 +245,11 @@ int main(void)
163 if(rc) 245 if(rc)
164 verbose = true; 246 verbose = true;
165 247
166 if(rc & BUTTON_VOL_UP) 248#ifdef BUTTON_VOL_UP
167 usb_mode(); 249 if(rc & BUTTON_VOL_UP ||
250#endif
251 0)
252 rc = boot_menu();
168 253
169 if(verbose) 254 if(verbose)
170 reset_screen(); 255 reset_screen();
@@ -175,28 +260,16 @@ int main(void)
175 if (rc <= 0) 260 if (rc <= 0)
176 error(EDISK,rc); 261 error(EDISK,rc);
177 262
263#ifdef HAS_BUTTON_HOLD
178 if(button_hold()) 264 if(button_hold())
179 {
180 rc = boot_of(); 265 rc = boot_of();
181 if(rc < 0) 266 else
182 printf("Error: %s", strerror(rc)); 267#endif
183 } 268 rc = boot_rockbox();
184 269
185 printf("Loading firmware");
186 rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000);
187 if(rc < 0) 270 if(rc < 0)
188 printf("Error: %s", strerror(rc)); 271 printf("Error: %s", strerror(rc));
189 272
190 if (rc == EOK)
191 {
192 printf("Starting Rockbox...");
193 adc_close(); /* Disable SADC */
194
195 disable_interrupt();
196 kernel_entry = (void*) CONFIG_SDRAM_START;
197 kernel_entry();
198 }
199
200 /* Halt */ 273 /* Halt */
201 while (1) 274 while (1)
202 core_idle(); 275 core_idle();