Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2005 by Linus Nielsen Feltzing |
| 11 | * |
| 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. |
| 14 | * |
| 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 16 | * KIND, either express or implied. |
| 17 | * |
| 18 | ****************************************************************************/ |
| 19 | #include "config.h" |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <stdio.h> |
| 23 | #include "cpu.h" |
| 24 | #include "system.h" |
| 25 | #include "lcd.h" |
| 26 | #include "kernel.h" |
| 27 | #include "thread.h" |
| 28 | #include "ata.h" |
| 29 | #include "disk.h" |
| 30 | #include "font.h" |
| 31 | #include "adc.h" |
| 32 | #include "backlight.h" |
| 33 | #include "button.h" |
| 34 | #include "panic.h" |
| 35 | #include "power.h" |
| 36 | #include "file.h" |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 37 | #include "uda1380.h" |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 38 | |
Linus Nielsen Feltzing | 62c768c | 2005-07-09 07:46:42 +0000 | [diff] [blame] | 39 | #define DRAM_START 0x31000000 |
| 40 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 41 | int line = 0; |
| 42 | |
| 43 | int usb_screen(void) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | |
Linus Nielsen Feltzing | a2e8cf7 | 2005-07-15 07:42:25 +0000 | [diff] [blame] | 48 | char version[] = APPSVERSION; |
| 49 | |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 50 | static void usb_enable(bool on) |
| 51 | { |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 52 | and_l(~0x01000000, &GPIO_OUT); /* GPIO24 is the Cypress chip power */ |
| 53 | or_l(0x01000000, &GPIO_ENABLE); |
| 54 | or_l(0x01000000, &GPIO_FUNCTION); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 55 | |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 56 | or_l(0x00000080, &GPIO1_FUNCTION); /* GPIO39 is the USB detect input */ |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 57 | |
| 58 | if(on) |
| 59 | { |
| 60 | /* Power on the Cypress chip */ |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 61 | or_l(0x01000000, &GPIO_OUT); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 62 | sleep(2); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | /* Power off the Cypress chip */ |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 67 | and_l(~0x01000000, &GPIO_OUT); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
| 71 | bool usb_detect(void) |
| 72 | { |
| 73 | return (GPIO1_READ & 0x80)?true:false; |
| 74 | } |
| 75 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 76 | void start_iriver_fw(void) |
| 77 | { |
| 78 | asm(" move.w #0x2700,%sr"); |
Linus Nielsen Feltzing | f1530d8 | 2005-02-04 18:24:58 +0000 | [diff] [blame] | 79 | /* Reset the cookie for the crt0 crash check */ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 80 | asm(" move.l #0,%d0"); |
Linus Nielsen Feltzing | f1530d8 | 2005-02-04 18:24:58 +0000 | [diff] [blame] | 81 | asm(" move.l %d0,0x10017ffc"); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 82 | asm(" movec.l %d0,%vbr"); |
| 83 | asm(" move.l 0,%sp"); |
| 84 | asm(" lea.l 8,%a0"); |
| 85 | asm(" jmp (%a0)"); |
| 86 | } |
| 87 | |
| 88 | int load_firmware(void) |
| 89 | { |
| 90 | int fd; |
| 91 | int rc; |
| 92 | int len; |
| 93 | unsigned long chksum; |
Linus Nielsen Feltzing | a75f0e5 | 2005-07-09 09:04:37 +0000 | [diff] [blame] | 94 | char model[5]; |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 95 | unsigned long sum; |
| 96 | int i; |
Linus Nielsen Feltzing | e82df4e | 2005-07-08 15:09:44 +0000 | [diff] [blame] | 97 | unsigned char *buf = (unsigned char *)DRAM_START; |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 98 | char str[80]; |
| 99 | |
Linus Nielsen Feltzing | bbe919b | 2005-11-19 01:33:28 +0000 | [diff] [blame^] | 100 | fd = open("/.rockbox/" BOOTFILE, O_RDONLY); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 101 | if(fd < 0) |
Linus Nielsen Feltzing | bbe919b | 2005-11-19 01:33:28 +0000 | [diff] [blame^] | 102 | { |
| 103 | fd = open("/" BOOTFILE, O_RDONLY); |
| 104 | if(fd < 0) |
| 105 | return -1; |
| 106 | } |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 107 | |
Linus Nielsen Feltzing | b8a00d2 | 2005-02-10 21:55:48 +0000 | [diff] [blame] | 108 | len = filesize(fd) - 8; |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 109 | |
| 110 | snprintf(str, 80, "Length: %x", len); |
| 111 | lcd_puts(0, line++, str); |
| 112 | lcd_update(); |
| 113 | |
Linus Nielsen Feltzing | 2a77d3a | 2005-01-28 13:27:58 +0000 | [diff] [blame] | 114 | lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 115 | |
| 116 | rc = read(fd, &chksum, 4); |
| 117 | if(rc < 4) |
| 118 | return -2; |
| 119 | |
| 120 | snprintf(str, 80, "Checksum: %x", chksum); |
| 121 | lcd_puts(0, line++, str); |
| 122 | lcd_update(); |
| 123 | |
Linus Nielsen Feltzing | a75f0e5 | 2005-07-09 09:04:37 +0000 | [diff] [blame] | 124 | rc = read(fd, model, 4); |
| 125 | if(rc < 4) |
| 126 | return -3; |
| 127 | |
| 128 | model[4] = 0; |
| 129 | |
| 130 | snprintf(str, 80, "Model name: %s", model); |
| 131 | lcd_puts(0, line++, str); |
| 132 | lcd_update(); |
| 133 | |
Linus Nielsen Feltzing | 2a77d3a | 2005-01-28 13:27:58 +0000 | [diff] [blame] | 134 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 135 | |
| 136 | rc = read(fd, buf, len); |
| 137 | if(rc < len) |
| 138 | return -4; |
| 139 | |
| 140 | close(fd); |
| 141 | |
Linus Nielsen Feltzing | e82df4e | 2005-07-08 15:09:44 +0000 | [diff] [blame] | 142 | sum = MODEL_NUMBER; |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 143 | |
| 144 | for(i = 0;i < len;i++) { |
| 145 | sum += buf[i]; |
| 146 | } |
| 147 | |
| 148 | snprintf(str, 80, "Sum: %x", sum); |
| 149 | lcd_puts(0, line++, str); |
| 150 | lcd_update(); |
| 151 | |
| 152 | if(sum != chksum) |
| 153 | return -5; |
| 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
Linus Nielsen Feltzing | e82df4e | 2005-07-08 15:09:44 +0000 | [diff] [blame] | 158 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 159 | void start_firmware(void) |
| 160 | { |
| 161 | asm(" move.w #0x2700,%sr"); |
Linus Nielsen Feltzing | f1530d8 | 2005-02-04 18:24:58 +0000 | [diff] [blame] | 162 | /* Reset the cookie for the crt0 crash check */ |
| 163 | asm(" move.l #0,%d0"); |
| 164 | asm(" move.l %d0,0x10017ffc"); |
Linus Nielsen Feltzing | e82df4e | 2005-07-08 15:09:44 +0000 | [diff] [blame] | 165 | asm(" move.l %0,%%d0" :: "i"(DRAM_START)); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 166 | asm(" movec.l %d0,%vbr"); |
Linus Nielsen Feltzing | e82df4e | 2005-07-08 15:09:44 +0000 | [diff] [blame] | 167 | asm(" move.l %0,%%sp" :: "m"(*(int *)DRAM_START)); |
| 168 | asm(" move.l %0,%%a0" :: "m"(*(int *)(DRAM_START+4))); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 169 | asm(" jmp (%a0)"); |
| 170 | } |
| 171 | |
Linus Nielsen Feltzing | b8a00d2 | 2005-02-10 21:55:48 +0000 | [diff] [blame] | 172 | void main(void) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 173 | { |
| 174 | int i; |
| 175 | int rc; |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 176 | char buf[256]; |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 177 | bool rc_on_button = false; |
| 178 | bool on_button = false; |
| 179 | int data; |
Linus Nielsen Feltzing | dfa8ecb | 2005-07-11 14:01:45 +0000 | [diff] [blame] | 180 | int adc_battery, battery_voltage, batt_int, batt_frac; |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 181 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 182 | /* We want to read the buttons as early as possible, before the user |
| 183 | releases the ON button */ |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 184 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 185 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs |
| 186 | (The ON and Hold buttons on the main unit and the remote) */ |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 187 | or_l(0x00100062, &GPIO1_FUNCTION); |
| 188 | and_l(~0x00100062, &GPIO1_ENABLE); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 189 | |
| 190 | data = GPIO1_READ; |
| 191 | if ((data & 0x20) == 0) |
| 192 | on_button = true; |
| 193 | |
| 194 | if ((data & 0x40) == 0) |
| 195 | rc_on_button = true; |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 196 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 197 | /* Set the default state of the hard drive power to OFF */ |
| 198 | ide_power_enable(false); |
| 199 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 200 | power_init(); |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 201 | |
Linus Nielsen Feltzing | bbe919b | 2005-11-19 01:33:28 +0000 | [diff] [blame^] | 202 | /* Turn off if neither ON button is pressed */ |
| 203 | if(!(on_button || rc_on_button)) |
| 204 | power_off(); |
| 205 | |
| 206 | /* Backlight ON */ |
| 207 | or_l(0x00020000, &GPIO1_ENABLE); |
| 208 | or_l(0x00020000, &GPIO1_FUNCTION); |
| 209 | and_l(~0x00020000, &GPIO1_OUT); |
| 210 | |
| 211 | /* Remote backlight ON */ |
| 212 | #ifdef HAVE_REMOTE_LCD |
| 213 | #ifdef IRIVER_H300_SERIES |
| 214 | or_l(0x00000002, &GPIO1_ENABLE); |
| 215 | and_l(~0x00000002, &GPIO1_OUT); |
| 216 | #else |
| 217 | or_l(0x00000800, &GPIO_ENABLE); |
| 218 | or_l(0x00000800, &GPIO_FUNCTION); |
| 219 | and_l(~0x00000800, &GPIO_OUT); |
| 220 | #endif |
| 221 | #endif |
| 222 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 223 | /* Power on the hard drive early, to speed up the loading */ |
| 224 | if(!((on_button && button_hold()) || |
| 225 | (rc_on_button && remote_button_hold()))) { |
| 226 | ide_power_enable(true); |
| 227 | } |
| 228 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 229 | system_init(); |
| 230 | kernel_init(); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 231 | |
| 232 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
| 233 | /* Set up waitstates for the peripherals */ |
| 234 | set_cpu_frequency(0); /* PLL off */ |
| 235 | #endif |
Linus Nielsen Feltzing | d2ca7fc | 2005-07-12 05:25:42 +0000 | [diff] [blame] | 236 | |
| 237 | uda1380_reset(); |
Linus Nielsen Feltzing | dfa8ecb | 2005-07-11 14:01:45 +0000 | [diff] [blame] | 238 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 239 | backlight_init(); |
| 240 | set_irq_level(0); |
| 241 | lcd_init(); |
| 242 | font_init(); |
| 243 | adc_init(); |
| 244 | button_init(); |
| 245 | |
| 246 | lcd_setfont(FONT_SYSFIXED); |
| 247 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 248 | lcd_puts(0, line++, "Rockbox boot loader"); |
| 249 | snprintf(buf, sizeof(buf), "Version %s", version); |
Linus Nielsen Feltzing | a2e8cf7 | 2005-07-15 07:42:25 +0000 | [diff] [blame] | 250 | lcd_puts(0, line++, buf); |
Linus Nielsen Feltzing | d1af08f | 2005-07-09 19:48:22 +0000 | [diff] [blame] | 251 | lcd_update(); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 252 | |
Linus Nielsen Feltzing | b8a00d2 | 2005-02-10 21:55:48 +0000 | [diff] [blame] | 253 | sleep(HZ/50); /* Allow the button driver to check the buttons */ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 254 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 255 | /* Holding REC while starting runs the original firmware */ |
Linus Nielsen Feltzing | d1af08f | 2005-07-09 19:48:22 +0000 | [diff] [blame] | 256 | if(((button_status() & BUTTON_REC) == BUTTON_REC) || |
| 257 | ((button_status() & BUTTON_RC_REC) == BUTTON_RC_REC)) { |
Linus Nielsen Feltzing | 2a77d3a | 2005-01-28 13:27:58 +0000 | [diff] [blame] | 258 | lcd_puts(0, 8, "Starting original firmware..."); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 259 | lcd_update(); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 260 | start_iriver_fw(); |
| 261 | } |
| 262 | |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 263 | /* Don't start if the Hold button is active on the device you |
| 264 | are starting with */ |
| 265 | if((on_button && button_hold()) || |
| 266 | (rc_on_button && remote_button_hold())) { |
Linus Nielsen Feltzing | b8a00d2 | 2005-02-10 21:55:48 +0000 | [diff] [blame] | 267 | lcd_puts(0, 8, "HOLD switch on, power off..."); |
| 268 | lcd_update(); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 269 | sleep(HZ*2); |
Linus Nielsen Feltzing | bbe919b | 2005-11-19 01:33:28 +0000 | [diff] [blame^] | 270 | |
| 271 | /* Backlight OFF */ |
| 272 | #ifdef HAVE_REMOTE_LCD |
| 273 | #ifdef IRIVER_H300_SERIES |
| 274 | or_l(0x00000002, &GPIO1_OUT); |
| 275 | #else |
| 276 | or_l(0x00000800, &GPIO_OUT); |
| 277 | #endif |
| 278 | #endif |
Linus Nielsen Feltzing | d4ad14c | 2005-02-11 09:02:46 +0000 | [diff] [blame] | 279 | /* Reset the cookie for the crt0 crash check */ |
| 280 | asm(" move.l #0,%d0"); |
| 281 | asm(" move.l %d0,0x10017ffc"); |
Linus Nielsen Feltzing | b8a00d2 | 2005-02-10 21:55:48 +0000 | [diff] [blame] | 282 | power_off(); |
| 283 | } |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 284 | |
Linus Nielsen Feltzing | dfa8ecb | 2005-07-11 14:01:45 +0000 | [diff] [blame] | 285 | adc_battery = adc_read(ADC_BATTERY); |
| 286 | |
| 287 | battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; |
| 288 | batt_int = battery_voltage / 100; |
| 289 | batt_frac = battery_voltage % 100; |
| 290 | |
| 291 | snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); |
| 292 | lcd_puts(0, line++, buf); |
| 293 | lcd_update(); |
| 294 | |
| 295 | if(battery_voltage <= 300) { |
| 296 | line++; |
| 297 | lcd_puts(0, line++, "WARNING! BATTERY LOW!!"); |
| 298 | lcd_update(); |
| 299 | sleep(HZ*2); |
| 300 | } |
| 301 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 302 | rc = ata_init(); |
| 303 | if(rc) |
| 304 | { |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 305 | char str[32]; |
| 306 | lcd_clear_display(); |
| 307 | snprintf(str, 31, "ATA error: %d", rc); |
Linus Nielsen Feltzing | dfa8ecb | 2005-07-11 14:01:45 +0000 | [diff] [blame] | 308 | lcd_puts(0, line++, str); |
| 309 | lcd_puts(0, line++, "Insert USB cable and press"); |
| 310 | lcd_puts(0, line++, "a button"); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 311 | lcd_update(); |
| 312 | while(!(button_get(true) & BUTTON_REL)); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 313 | } |
| 314 | |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 315 | /* A hack to enter USB mode without using the USB thread */ |
| 316 | if(usb_detect()) |
| 317 | { |
| 318 | lcd_clear_display(); |
| 319 | lcd_puts(0, 7, " Bootloader USB mode"); |
| 320 | lcd_update(); |
| 321 | |
| 322 | ata_spin(); |
| 323 | ata_enable(false); |
| 324 | usb_enable(true); |
| 325 | while(usb_detect()) |
| 326 | { |
| 327 | ata_spin(); /* Prevent the drive from spinning down */ |
| 328 | sleep(HZ); |
Linus Nielsen Feltzing | e628b5c | 2005-07-19 08:08:33 +0000 | [diff] [blame] | 329 | |
| 330 | /* Backlight OFF */ |
| 331 | or_l(0x00020000, &GPIO1_OUT); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Linus Nielsen Feltzing | 1310390 | 2005-07-19 11:03:00 +0000 | [diff] [blame] | 334 | usb_enable(false); |
| 335 | ata_init(); /* Reinitialize ATA and continue booting */ |
| 336 | |
| 337 | lcd_clear_display(); |
| 338 | line = 0; |
| 339 | lcd_update(); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 340 | } |
| 341 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 342 | disk_init(); |
| 343 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 344 | rc = disk_mount_all(); |
| 345 | if (rc<=0) |
| 346 | { |
| 347 | lcd_clear_display(); |
Linus Nielsen Feltzing | 8e958b5 | 2005-05-20 18:16:45 +0000 | [diff] [blame] | 348 | lcd_puts(0, 0, "No partition found"); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 349 | while(button_get(true) != SYS_USB_CONNECTED) {}; |
| 350 | } |
| 351 | |
| 352 | lcd_puts(0, line++, "Loading firmware"); |
Linus Nielsen Feltzing | 2a3856f | 2005-02-07 01:47:47 +0000 | [diff] [blame] | 353 | lcd_update(); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 354 | i = load_firmware(); |
| 355 | snprintf(buf, 256, "Result: %d", i); |
| 356 | lcd_puts(0, line++, buf); |
| 357 | lcd_update(); |
| 358 | |
| 359 | if(i == 0) |
| 360 | start_firmware(); |
| 361 | |
Linus Nielsen Feltzing | b8a00d2 | 2005-02-10 21:55:48 +0000 | [diff] [blame] | 362 | start_iriver_fw(); |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | /* These functions are present in the firmware library, but we reimplement |
| 366 | them here because the originals do a lot more than we want */ |
| 367 | |
| 368 | void reset_poweroff_timer(void) |
| 369 | { |
| 370 | } |
| 371 | |
| 372 | void screen_dump(void) |
| 373 | { |
| 374 | } |
| 375 | |
| 376 | int dbg_ports(void) |
| 377 | { |
| 378 | return 0; |
| 379 | } |
| 380 | |
| 381 | void mpeg_stop(void) |
| 382 | { |
| 383 | } |
| 384 | |
| 385 | void usb_acknowledge(void) |
| 386 | { |
| 387 | } |
| 388 | |
| 389 | void usb_wait_for_disconnect(void) |
| 390 | { |
| 391 | } |
Linus Nielsen Feltzing | e244f7f | 2005-09-14 09:44:45 +0000 | [diff] [blame] | 392 | |
| 393 | void sys_poweroff(void) |
| 394 | { |
| 395 | } |