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");
51 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
52 while(usb_wait_for_disconnect_w_tmo(&button_queue
, HZ
)) {
59 lcd_puts(0, 0, "Rockbox");
60 lcd_puts(0, 1, "Rescue boot");
68 bool backlight_get_on_when_charging(void)
73 void charging_screen(void)
78 ide_power_enable(false); /* power down the disk, else would be spinning */
84 #if CONFIG_CHARGING == CHARGING_CONTROL
85 if (charge_state
== CHARGING
)
87 else if (charge_state
== TOPOFF
)
88 msg
= "topoff charge";
89 else if (charge_state
== TRICKLE
)
90 msg
= "trickle charge";
100 int battv
= battery_voltage();
101 snprintf(buf
, sizeof(buf
), "%d.%02dV %d%%",
102 battv
/ 100, battv
% 100, battery_level());
107 button
= button_get_w_tmo(HZ
/2);
109 if (button
== (BUTTON_ON
| BUTTON_REL
))
111 if (button
== (BUTTON_RIGHT
| BUTTON_REL
))
118 else if (!charger_inserted())
119 power_off(); /* charger removed: power down */
123 #endif /* CONFIG_CHARGING */
125 /* prompt user to plug USB and fix a problem */
126 void prompt_usb(const char* msg1
, const char* msg2
)
130 lcd_puts(0, 0, msg1
);
131 lcd_puts(0, 1, msg2
);
132 #ifdef HAVE_LCD_BITMAP
133 lcd_puts(0, 2, "Insert USB cable");
134 lcd_puts(0, 3, "and fix it.");
139 button
= button_get(true);
140 if (button
== SYS_POWEROFF
)
144 } while (button
!= SYS_USB_CONNECTED
);
165 #if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
166 if (charger_inserted()
167 #ifdef ATA_POWER_PLAYERSTYLE
168 && !ide_powered() /* relies on probing result from bootloader */
172 charging_screen(); /* display a "charging" screen */
173 show_logo(); /* again, to provide better visual feedback */
180 #ifdef HAVE_LCD_BITMAP
183 snprintf(str
, 31, "ATA error: %d", rc
);
186 while(!(button_get(true) & BUTTON_REL
));
188 panicf("ata: %d", rc
);
192 usb_start_monitoring();
194 { /* enter USB mode early, before trying to mount */
195 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
201 rc
= disk_mount_all();
204 prompt_usb("No partition", "found.");
207 { // rolo the firmware
208 static const char filename
[] = "/" BOOTFILE
;
209 rolo_load((char*)filename
); /* won't return if started */
211 prompt_usb("No firmware", filename
);
217 /* These functions are present in the firmware library, but we reimplement
218 them here because the originals do a lot more than we want */
220 void screen_dump(void)
229 void audio_stop(void)
233 int audio_status(void)
238 void audio_stop_recording(void)
242 void mp3_shutdown(void)
250 void backlight_on(void)