1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Jörg Hohensohn aka [IDC]Dragon
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.
16 * All files in this archive are subject to the GNU General Public License.
17 * See the file COPYING in the source tree root for full license agreement.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
43 #include "powermgmt.h"
48 lcd_puts(0, 0, "USB mode");
49 #ifdef HAVE_LCD_BITMAP
52 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
53 while(usb_wait_for_disconnect_w_tmo(&button_queue
, HZ
)) {
60 lcd_puts(0, 0, "Rockbox");
61 lcd_puts(0, 1, "Rescue boot");
62 #ifdef HAVE_LCD_BITMAP
68 #ifdef CONFIG_CHARGING
70 bool backlight_get_on_when_charging(void)
75 void charging_screen(void)
80 ide_power_enable(false); /* power down the disk, else would be spinning */
86 #if CONFIG_CHARGING == CHARGING_CONTROL
87 if (charge_state
== CHARGING
)
89 else if (charge_state
== TOPOFF
)
90 msg
= "topoff charge";
91 else if (charge_state
== TRICKLE
)
92 msg
= "trickle charge";
102 int battv
= battery_voltage();
103 snprintf(buf
, sizeof(buf
), "%d.%02dV %d%%",
104 battv
/ 100, battv
% 100, battery_level());
108 #ifdef HAVE_LCD_BITMAP
112 button
= button_get_w_tmo(HZ
/2);
114 if (button
== (BUTTON_ON
| BUTTON_REL
))
116 if (button
== (BUTTON_RIGHT
| BUTTON_REL
))
123 else if (!charger_inserted())
124 power_off(); /* charger removed: power down */
128 #endif /* CONFIG_CHARGING */
130 /* prompt user to plug USB and fix a problem */
131 void prompt_usb(const char* msg1
, const char* msg2
)
135 lcd_puts(0, 0, msg1
);
136 lcd_puts(0, 1, msg2
);
137 #ifdef HAVE_LCD_BITMAP
138 lcd_puts(0, 2, "Insert USB cable");
139 lcd_puts(0, 3, "and fix it.");
144 button
= button_get(true);
145 if (button
== SYS_POWEROFF
)
149 } while (button
!= SYS_USB_CONNECTED
);
170 #if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
171 if (charger_inserted()
172 #ifdef ATA_POWER_PLAYERSTYLE
173 && !ide_powered() /* relies on probing result from bootloader */
177 charging_screen(); /* display a "charging" screen */
178 show_logo(); /* again, to provide better visual feedback */
185 #ifdef HAVE_LCD_BITMAP
188 snprintf(str
, 31, "ATA error: %d", rc
);
191 while(!(button_get(true) & BUTTON_REL
));
193 panicf("ata: %d", rc
);
197 usb_start_monitoring();
199 { /* enter USB mode early, before trying to mount */
200 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
206 rc
= disk_mount_all();
209 prompt_usb("No partition", "found.");
212 { // rolo the firmware
213 static const char filename
[] = "/" BOOTFILE
;
214 rolo_load((char*)filename
); /* won't return if started */
216 prompt_usb("No firmware", filename
);
222 /* These functions are present in the firmware library, but we reimplement
223 them here because the originals do a lot more than we want */
225 void screen_dump(void)
234 void audio_stop(void)
238 int audio_status(void)
243 void mp3_shutdown(void)
251 void backlight_on(void)