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 * 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.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 ****************************************************************************/
45 #include "powermgmt.h"
50 lcd_puts(0, 0, "USB mode");
53 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
54 while(usb_wait_for_disconnect_w_tmo(&button_queue
, HZ
)) {
61 lcd_puts(0, 0, "Rockbox");
62 lcd_puts(0, 1, "Rescue boot");
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
/ 1000, (battv
% 1000) / 10, battery_level());
109 button
= button_get_w_tmo(HZ
/2);
111 if (button
== (BUTTON_ON
| BUTTON_REL
))
113 if (button
== (BUTTON_RIGHT
| BUTTON_REL
))
118 if (usb_detect() == USB_INSERTED
)
120 else if (!charger_inserted())
121 power_off(); /* charger removed: power down */
125 #endif /* CONFIG_CHARGING */
127 /* prompt user to plug USB and fix a problem */
128 void prompt_usb(const char* msg1
, const char* msg2
)
132 lcd_puts(0, 0, msg1
);
133 lcd_puts(0, 1, msg2
);
134 #ifdef HAVE_LCD_BITMAP
135 lcd_puts(0, 2, "Insert USB cable");
136 lcd_puts(0, 3, "and fix it.");
141 button
= button_get(true);
142 if (button
== SYS_POWEROFF
)
146 } while (button
!= SYS_USB_CONNECTED
);
167 #if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
168 if (charger_inserted()
169 #ifdef ATA_POWER_PLAYERSTYLE
170 && !ide_powered() /* relies on probing result from bootloader */
174 charging_screen(); /* display a "charging" screen */
175 show_logo(); /* again, to provide better visual feedback */
182 #ifdef HAVE_LCD_BITMAP
185 snprintf(str
, 31, "ATA error: %d", rc
);
188 while(!(button_get(true) & BUTTON_REL
));
190 panicf("ata: %d", rc
);
194 usb_start_monitoring();
195 while (usb_detect() == USB_INSERTED
)
196 { /* enter USB mode early, before trying to mount */
197 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
203 rc
= disk_mount_all();
206 prompt_usb("No partition", "found.");
209 { // rolo the firmware
210 static const char filename
[] = "/" BOOTFILE
;
211 rolo_load((char*)filename
); /* won't return if started */
213 prompt_usb("No firmware", filename
);
219 /* These functions are present in the firmware library, but we reimplement
220 them here because the originals do a lot more than we want */
222 void screen_dump(void)
231 void audio_stop(void)
235 int audio_status(void)
240 void audio_stop_recording(void)
244 void mp3_shutdown(void)
252 void backlight_on(void)