1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
28 #include "lcd-remote.h"
36 #include "backlight.h"
37 #include "backlight-target.h"
48 /* Maximum allowed firmware image size. 10MB is more than enough */
49 #define MAX_LOADSIZE (10*1024*1024)
51 #define DRAM_START 0x31000000
58 char version
[] = APPSVERSION
;
60 /* Reset the cookie for the crt0 crash check */
61 inline void __reset_cookie(void)
63 asm(" move.l #0,%d0");
64 asm(" move.l %d0,0x10017ffc");
67 void start_firmware(void)
69 asm(" move.w #0x2700,%sr");
71 asm(" move.l %0,%%d0" :: "i"(DRAM_START
));
72 asm(" movec.l %d0,%vbr");
73 asm(" move.l %0,%%sp" :: "m"(*(int *)DRAM_START
));
74 asm(" move.l %0,%%a0" :: "m"(*(int *)(DRAM_START
+4)));
80 printf("Shutting down...");
82 /* We need to gracefully spin down the disk to prevent clicks. */
85 /* Make sure ATA has been initialized. */
88 /* And put the disk into sleep immediately. */
96 #ifdef HAVE_REMOTE_LCD
97 __remote_backlight_off();
104 /* Print the battery voltage (and a warning message). */
105 void check_battery(void)
107 int adc_battery
, battery_voltage
, batt_int
, batt_frac
;
109 adc_battery
= adc_read(ADC_BATTERY
);
111 battery_voltage
= (adc_battery
* BATTERY_SCALE_FACTOR
) / 10000;
112 batt_int
= battery_voltage
/ 100;
113 batt_frac
= battery_voltage
% 100;
115 printf("Batt: %d.%02dV", batt_int
, batt_frac
);
117 if (battery_voltage
<= 350)
119 printf("WARNING! BATTERY LOW!!");
128 bool rc_on_button
= false;
129 bool on_button
= false;
130 bool rec_button
= false;
131 bool hold_status
= false;
144 set_cpu_frequency(CPUFREQ_NORMAL
);
145 coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS
);
149 #ifdef HAVE_REMOTE_LCD
157 printf("Rockbox boot loader");
158 printf("Version %s", version
);
165 printf("ATA error: %d", rc
);
172 rc
= disk_mount_all();
175 printf("No partition found");
180 printf("Loading firmware");
181 i
= load_firmware((unsigned char *)DRAM_START
, BOOTFILE
, MAX_LOADSIZE
);
182 printf("Result: %s", strerror(i
));
186 printf("Can't load rockbox.iaudio:");
187 printf(strerror(rc
));
195 /* These functions are present in the firmware library, but we reimplement
196 them here because the originals do a lot more than we want */
197 void screen_dump(void)