diff options
Diffstat (limited to 'flash/bootbox/main.c')
-rw-r--r-- | flash/bootbox/main.c | 224 |
1 files changed, 0 insertions, 224 deletions
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c deleted file mode 100644 index ac90d60336..0000000000 --- a/flash/bootbox/main.c +++ /dev/null | |||
@@ -1,224 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Jörg Hohensohn aka [IDC]Dragon | ||
11 | * | ||
12 | * This is "Bootbox", a minimalistic loader, rescue firmware for just | ||
13 | * booting into a full features one. Aside from that it does charging | ||
14 | * and USB mode, to enable copying the desired firmware. | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License | ||
18 | * as published by the Free Software Foundation; either version 2 | ||
19 | * of the License, or (at your option) any later version. | ||
20 | * | ||
21 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
22 | * KIND, either express or implied. | ||
23 | * | ||
24 | ****************************************************************************/ | ||
25 | #include "config.h" | ||
26 | |||
27 | #include <stdlib.h> | ||
28 | #include <stdio.h> | ||
29 | #include "cpu.h" | ||
30 | #include "system.h" | ||
31 | #include "lcd.h" | ||
32 | #include "../kernel-internal.h" | ||
33 | #include "storage.h" | ||
34 | #include "disk.h" | ||
35 | #include "font.h" | ||
36 | #include "adc.h" | ||
37 | #include "button.h" | ||
38 | #include "panic.h" | ||
39 | #include "power.h" | ||
40 | #include "file.h" | ||
41 | #include "rolo.h" | ||
42 | #include "usb.h" | ||
43 | #include "powermgmt.h" | ||
44 | |||
45 | static void usb_screen(void) | ||
46 | { | ||
47 | lcd_clear_display(); | ||
48 | lcd_puts(0, 0, "USB mode"); | ||
49 | lcd_update(); | ||
50 | |||
51 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
52 | while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { | ||
53 | } | ||
54 | } | ||
55 | |||
56 | static void show_logo(void) | ||
57 | { | ||
58 | lcd_clear_display(); | ||
59 | lcd_puts(0, 0, "Rockbox"); | ||
60 | lcd_puts(0, 1, "Rescue boot"); | ||
61 | lcd_update(); | ||
62 | } | ||
63 | |||
64 | #if CONFIG_CHARGING | ||
65 | static void charging_screen(void) | ||
66 | { | ||
67 | unsigned int button; | ||
68 | const char* msg; | ||
69 | |||
70 | ide_power_enable(false); /* power down the disk, else would be spinning */ | ||
71 | |||
72 | lcd_clear_display(); | ||
73 | |||
74 | do | ||
75 | { | ||
76 | #ifdef ARCHOS_RECORDER | ||
77 | if (charge_state == CHARGING) | ||
78 | msg = "charging"; | ||
79 | else if (charge_state == TOPOFF) | ||
80 | msg = "topoff charge"; | ||
81 | else if (charge_state == TRICKLE) | ||
82 | msg = "trickle charge"; | ||
83 | else | ||
84 | msg = "not charging"; | ||
85 | #else | ||
86 | msg = "charging"; | ||
87 | #endif | ||
88 | lcd_puts(0, 0, msg); | ||
89 | { | ||
90 | char buf[32]; | ||
91 | int battv = battery_voltage(); | ||
92 | snprintf(buf, sizeof(buf), "%d.%02dV %d%%", | ||
93 | battv / 1000, (battv % 1000) / 10, battery_level()); | ||
94 | lcd_puts(0, 1, buf); | ||
95 | } | ||
96 | lcd_update(); | ||
97 | |||
98 | button = button_get_w_tmo(HZ/2); | ||
99 | #ifdef BUTTON_ON | ||
100 | if (button == (BUTTON_ON | BUTTON_REL)) | ||
101 | #else | ||
102 | if (button == (BUTTON_RIGHT | BUTTON_REL)) | ||
103 | #endif | ||
104 | break; /* start */ | ||
105 | else | ||
106 | { | ||
107 | if (usb_detect() == USB_INSERTED) | ||
108 | break; | ||
109 | else if (!charger_inserted()) | ||
110 | power_off(); /* charger removed: power down */ | ||
111 | } | ||
112 | } while (1); | ||
113 | } | ||
114 | #endif /* CONFIG_CHARGING */ | ||
115 | |||
116 | /* prompt user to plug USB and fix a problem */ | ||
117 | static void prompt_usb(const char* msg1, const char* msg2) | ||
118 | { | ||
119 | int button; | ||
120 | lcd_clear_display(); | ||
121 | lcd_puts(0, 0, msg1); | ||
122 | lcd_puts(0, 1, msg2); | ||
123 | #ifdef HAVE_LCD_BITMAP | ||
124 | lcd_puts(0, 2, "Insert USB cable"); | ||
125 | lcd_puts(0, 3, "and fix it."); | ||
126 | #endif | ||
127 | lcd_update(); | ||
128 | do | ||
129 | { | ||
130 | button = button_get(true); | ||
131 | if (button == SYS_POWEROFF) | ||
132 | { | ||
133 | power_off(); | ||
134 | } | ||
135 | } while (button != SYS_USB_CONNECTED); | ||
136 | usb_screen(); | ||
137 | system_reboot(); | ||
138 | } | ||
139 | |||
140 | void main(void) | ||
141 | { | ||
142 | int rc; | ||
143 | |||
144 | power_init(); | ||
145 | system_init(); | ||
146 | kernel_init(); | ||
147 | lcd_init(); | ||
148 | show_logo(); | ||
149 | enable_irq(); | ||
150 | adc_init(); | ||
151 | usb_init(); | ||
152 | button_init(); | ||
153 | powermgmt_init(); | ||
154 | |||
155 | #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) | ||
156 | if (charger_inserted() | ||
157 | #ifdef ATA_POWER_PLAYERSTYLE | ||
158 | && !ide_powered() /* relies on probing result from bootloader */ | ||
159 | #endif | ||
160 | ) | ||
161 | { | ||
162 | charging_screen(); /* display a "charging" screen */ | ||
163 | show_logo(); /* again, to provide better visual feedback */ | ||
164 | } | ||
165 | #endif | ||
166 | |||
167 | rc = storage_init(); | ||
168 | if(rc) | ||
169 | { | ||
170 | #ifdef HAVE_LCD_BITMAP | ||
171 | char str[32]; | ||
172 | lcd_clear_display(); | ||
173 | snprintf(str, 31, "ATA error: %d", rc); | ||
174 | lcd_puts(0, 1, str); | ||
175 | lcd_update(); | ||
176 | while(!(button_get(true) & BUTTON_REL)); | ||
177 | #endif | ||
178 | panicf("storage: %d", rc); | ||
179 | } | ||
180 | |||
181 | usb_start_monitoring(); | ||
182 | while (usb_detect() == USB_INSERTED) | ||
183 | { /* enter USB mode early, before trying to mount */ | ||
184 | if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) | ||
185 | { | ||
186 | usb_screen(); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | rc = disk_mount_all(); | ||
191 | if (rc<=0) | ||
192 | { | ||
193 | prompt_usb("No partition", "found."); | ||
194 | } | ||
195 | |||
196 | { // rolo the firmware | ||
197 | static const char filename[] = "/" BOOTFILE; | ||
198 | rolo_load((char*)filename); /* won't return if started */ | ||
199 | |||
200 | prompt_usb("No firmware", filename); | ||
201 | } | ||
202 | |||
203 | |||
204 | } | ||
205 | |||
206 | /* These functions are present in the firmware library, but we reimplement | ||
207 | them here because the originals do a lot more than we want */ | ||
208 | |||
209 | void audio_stop(void) | ||
210 | { | ||
211 | } | ||
212 | |||
213 | int audio_status(void) | ||
214 | { | ||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | void audio_stop_recording(void) | ||
219 | { | ||
220 | } | ||
221 | |||
222 | void mp3_shutdown(void) | ||
223 | { | ||
224 | } | ||