Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2005 by Dave Chapman |
| 11 | * |
| 12 | * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing |
| 13 | * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach |
| 14 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License |
| 17 | * as published by the Free Software Foundation; either version 2 |
| 18 | * of the License, or (at your option) any later version. |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | ****************************************************************************/ |
| 24 | #include "config.h" |
| 25 | |
| 26 | #include <stdlib.h> |
| 27 | #include <stdio.h> |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 28 | #include <string.h> |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 29 | #include <stdarg.h> |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 30 | #include "cpu.h" |
| 31 | #include "system.h" |
| 32 | #include "lcd.h" |
| 33 | #include "kernel.h" |
| 34 | #include "thread.h" |
| 35 | #include "ata.h" |
| 36 | #include "fat.h" |
| 37 | #include "disk.h" |
| 38 | #include "font.h" |
| 39 | #include "adc.h" |
Jens Arnold | afd5174 | 2007-11-21 21:28:46 +0000 | [diff] [blame] | 40 | #include "backlight.h" |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 41 | #include "panic.h" |
| 42 | #include "power.h" |
| 43 | #include "file.h" |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 44 | #include "common.h" |
Dave Chapman | ebc076b | 2007-07-25 13:12:38 +0000 | [diff] [blame] | 45 | #include "hwcompat.h" |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 46 | |
Dave Chapman | 8adc81d | 2006-02-21 21:13:03 +0000 | [diff] [blame] | 47 | #define XSC(X) #X |
| 48 | #define SC(X) XSC(X) |
| 49 | |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 50 | /* Maximum allowed firmware image size. The largest known current |
| 51 | (December 2006) firmware is about 7.5MB (Apple's firmware for the ipod video) |
| 52 | so we set this to 8MB. */ |
| 53 | #define MAX_LOADSIZE (8*1024*1024) |
| 54 | |
| 55 | /* A buffer to load the Linux kernel or Rockbox into */ |
| 56 | unsigned char *loadbuffer = (unsigned char *)DRAM_START; |
| 57 | |
| 58 | /* Bootloader version */ |
| 59 | char version[] = APPSVERSION; |
| 60 | |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 61 | #define BUTTON_LEFT 1 |
| 62 | #define BUTTON_MENU 2 |
| 63 | #define BUTTON_RIGHT 3 |
| 64 | #define BUTTON_PLAY 4 |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 65 | #define BUTTON_HOLD 5 |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 66 | |
Frank Dischner | 5d9eccd | 2006-04-19 18:06:56 +0000 | [diff] [blame] | 67 | #if CONFIG_KEYPAD == IPOD_4G_PAD && !defined(IPOD_MINI) |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 68 | /* check if number of seconds has past */ |
| 69 | int timer_check(int clock_start, unsigned int usecs) |
| 70 | { |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 71 | if ((USEC_TIMER - clock_start) >= usecs) { |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 72 | return 1; |
| 73 | } else { |
| 74 | return 0; |
| 75 | } |
| 76 | } |
| 77 | |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 78 | static void ser_opto_keypad_cfg(int val) |
| 79 | { |
| 80 | int start_time; |
| 81 | |
Barry Wardell | 8b06125 | 2007-03-03 17:25:20 +0000 | [diff] [blame] | 82 | GPIOB_ENABLE &=~ 0x80; |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 83 | |
| 84 | outl(inl(0x7000c104) | 0xc000000, 0x7000c104); |
| 85 | outl(val, 0x7000c120); |
| 86 | outl(inl(0x7000c100) | 0x80000000, 0x7000c100); |
| 87 | |
Barry Wardell | 8b06125 | 2007-03-03 17:25:20 +0000 | [diff] [blame] | 88 | GPIOB_OUTPUT_VAL &=~ 0x10; |
| 89 | GPIOB_OUTPUT_EN |= 0x10; |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 90 | |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 91 | start_time = USEC_TIMER; |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 92 | do { |
| 93 | if ((inl(0x7000c104) & 0x80000000) == 0) { |
| 94 | break; |
| 95 | } |
| 96 | } while (timer_check(start_time, 1500) != 0); |
| 97 | |
| 98 | outl(inl(0x7000c100) & ~0x80000000, 0x7000c100); |
| 99 | |
Barry Wardell | 8b06125 | 2007-03-03 17:25:20 +0000 | [diff] [blame] | 100 | GPIOB_ENABLE |= 0x80; |
| 101 | GPIOB_OUTPUT_VAL |= 0x10; |
| 102 | GPIOB_OUTPUT_EN &=~0x10; |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 103 | |
| 104 | outl(inl(0x7000c104) | 0xc000000, 0x7000c104); |
| 105 | outl(inl(0x7000c100) | 0x60000000, 0x7000c100); |
| 106 | } |
| 107 | |
| 108 | int opto_keypad_read(void) |
| 109 | { |
| 110 | int loop_cnt, had_io = 0; |
| 111 | |
| 112 | for (loop_cnt = 5; loop_cnt != 0;) |
| 113 | { |
| 114 | int key_pressed = 0; |
| 115 | int start_time; |
| 116 | unsigned int key_pad_val; |
| 117 | |
| 118 | ser_opto_keypad_cfg(0x8000023a); |
| 119 | |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 120 | start_time = USEC_TIMER; |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 121 | do { |
| 122 | if (inl(0x7000c104) & 0x4000000) { |
| 123 | had_io = 1; |
| 124 | break; |
| 125 | } |
| 126 | |
| 127 | if (had_io != 0) { |
| 128 | break; |
| 129 | } |
| 130 | } while (timer_check(start_time, 1500) != 0); |
| 131 | |
| 132 | key_pad_val = inl(0x7000c140); |
| 133 | if ((key_pad_val & ~0x7fff0000) != 0x8000023a) { |
| 134 | loop_cnt--; |
| 135 | } else { |
| 136 | key_pad_val = (key_pad_val << 11) >> 27; |
| 137 | key_pressed = 1; |
| 138 | } |
| 139 | |
| 140 | outl(inl(0x7000c100) | 0x60000000, 0x7000c100); |
| 141 | outl(inl(0x7000c104) | 0xc000000, 0x7000c104); |
| 142 | |
| 143 | if (key_pressed != 0) { |
| 144 | return key_pad_val ^ 0x1f; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 150 | #endif |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 151 | |
| 152 | static int key_pressed(void) |
| 153 | { |
| 154 | unsigned char state; |
| 155 | |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 156 | #if CONFIG_KEYPAD == IPOD_4G_PAD |
Jens Arnold | 7f88088 | 2006-04-02 00:20:11 +0000 | [diff] [blame] | 157 | #ifdef IPOD_MINI /* mini 1G only */ |
Dave Chapman | 2850791 | 2006-02-27 12:35:05 +0000 | [diff] [blame] | 158 | state = GPIOA_INPUT_VAL & 0x3f; |
Frank Dischner | 5d9eccd | 2006-04-19 18:06:56 +0000 | [diff] [blame] | 159 | if ((state & 0x10) == 0) return BUTTON_LEFT; |
| 160 | if ((state & 0x2) == 0) return BUTTON_MENU; |
| 161 | if ((state & 0x4) == 0) return BUTTON_PLAY; |
| 162 | if ((state & 0x8) == 0) return BUTTON_RIGHT; |
Dave Chapman | 2850791 | 2006-02-27 12:35:05 +0000 | [diff] [blame] | 163 | #else |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 164 | state = opto_keypad_read(); |
| 165 | if ((state & 0x4) == 0) return BUTTON_LEFT; |
| 166 | if ((state & 0x10) == 0) return BUTTON_MENU; |
| 167 | if ((state & 0x8) == 0) return BUTTON_PLAY; |
| 168 | if ((state & 0x2) == 0) return BUTTON_RIGHT; |
Frank Dischner | 5d9eccd | 2006-04-19 18:06:56 +0000 | [diff] [blame] | 169 | #endif |
Jens Arnold | 90eacb2 | 2007-07-27 07:32:55 +0000 | [diff] [blame] | 170 | #elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
| 171 | state = GPIOA_INPUT_VAL; |
Dave Chapman | fa74356 | 2006-02-05 19:05:55 +0000 | [diff] [blame] | 172 | if ((state & 0x08) == 0) return BUTTON_LEFT; |
| 173 | if ((state & 0x10) == 0) return BUTTON_MENU; |
| 174 | if ((state & 0x04) == 0) return BUTTON_PLAY; |
| 175 | if ((state & 0x01) == 0) return BUTTON_RIGHT; |
| 176 | #endif |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 177 | return 0; |
| 178 | } |
| 179 | |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 180 | bool button_hold(void) |
| 181 | { |
Jens Arnold | 90eacb2 | 2007-07-27 07:32:55 +0000 | [diff] [blame] | 182 | #if CONFIG_KEYPAD == IPOD_1G2G_PAD |
| 183 | return (GPIOA_INPUT_VAL & 0x20); |
| 184 | #else |
| 185 | return !(GPIOA_INPUT_VAL & 0x20); |
| 186 | #endif |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 189 | void fatal_error(void) |
| 190 | { |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 191 | extern int line; |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 192 | bool holdstatus=false; |
| 193 | |
Dave Chapman | 0025a97 | 2006-12-17 10:23:51 +0000 | [diff] [blame] | 194 | /* System font is 6 pixels wide */ |
Jens Arnold | 90eacb2 | 2007-07-27 07:32:55 +0000 | [diff] [blame] | 195 | #if defined(IPOD_1G2G) || defined(IPOD_3G) |
| 196 | printf("Hold MENU+PLAY to"); |
| 197 | printf("reboot then REW+FF"); |
| 198 | printf("for disk mode"); |
| 199 | #elif LCD_WIDTH >= (30*6) |
Dave Chapman | c5302d5 | 2007-05-23 07:18:40 +0000 | [diff] [blame] | 200 | printf("Hold MENU+SELECT to reboot"); |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 201 | printf("then SELECT+PLAY for disk mode"); |
Dave Chapman | 0025a97 | 2006-12-17 10:23:51 +0000 | [diff] [blame] | 202 | #else |
Dave Chapman | c5302d5 | 2007-05-23 07:18:40 +0000 | [diff] [blame] | 203 | printf("Hold MENU+SELECT to"); |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 204 | printf("reboot then SELECT+PLAY"); |
| 205 | printf("for disk mode"); |
Dave Chapman | 0025a97 | 2006-12-17 10:23:51 +0000 | [diff] [blame] | 206 | #endif |
Dave Chapman | 7d79db2 | 2007-05-22 19:05:14 +0000 | [diff] [blame] | 207 | lcd_update(); |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 208 | |
| 209 | while (1) { |
| 210 | if (button_hold() != holdstatus) { |
| 211 | if (button_hold()) { |
| 212 | holdstatus=true; |
| 213 | lcd_puts(0, line, "Hold switch on!"); |
| 214 | } else { |
| 215 | holdstatus=false; |
| 216 | lcd_puts(0, line, " "); |
| 217 | } |
| 218 | lcd_update(); |
| 219 | } |
| 220 | udelay(100000); /* 100ms */ |
| 221 | } |
| 222 | |
| 223 | } |
| 224 | |
| 225 | |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 226 | void* main(void) |
| 227 | { |
| 228 | char buf[256]; |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 229 | int i; |
Dave Chapman | 4d25bff | 2007-03-05 23:56:28 +0000 | [diff] [blame] | 230 | int btn; |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 231 | int rc; |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 232 | bool haveretailos; |
| 233 | bool button_was_held; |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 234 | struct partinfo* pinfo; |
| 235 | unsigned short* identify_info; |
| 236 | |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 237 | /* Check the button hold status as soon as possible - to |
| 238 | give the user maximum chance to turn it off in order to |
| 239 | reset the settings in rockbox. */ |
| 240 | button_was_held = button_hold(); |
| 241 | |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 242 | system_init(); |
| 243 | kernel_init(); |
Jens Arnold | afd5174 | 2007-11-21 21:28:46 +0000 | [diff] [blame] | 244 | |
| 245 | #ifndef HAVE_BACKLIGHT_INVERSION |
| 246 | backlight_init(); /* Turns on the backlight */ |
| 247 | #endif |
| 248 | |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 249 | lcd_init(); |
| 250 | font_init(); |
| 251 | |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 252 | #ifdef HAVE_LCD_COLOR |
| 253 | lcd_set_foreground(LCD_WHITE); |
| 254 | lcd_set_background(LCD_BLACK); |
| 255 | lcd_clear_display(); |
| 256 | #endif |
| 257 | |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 258 | #if 0 |
| 259 | /* ADC and button drivers are not yet implemented */ |
| 260 | adc_init(); |
| 261 | button_init(); |
| 262 | #endif |
| 263 | |
Dave Chapman | 4d25bff | 2007-03-05 23:56:28 +0000 | [diff] [blame] | 264 | btn=key_pressed(); |
| 265 | |
| 266 | /* Enable bootloader messages */ |
| 267 | if (btn==BUTTON_RIGHT) |
| 268 | verbose = true; |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 269 | |
| 270 | lcd_setfont(FONT_SYSFIXED); |
| 271 | |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 272 | printf("Rockbox boot loader"); |
Dave Chapman | dc1fc3c | 2007-03-06 09:49:09 +0000 | [diff] [blame] | 273 | printf("Version: %s", version); |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 274 | printf("IPOD version: 0x%08x", IPOD_HW_REVISION); |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 275 | |
| 276 | i=ata_init(); |
| 277 | if (i==0) { |
| 278 | identify_info=ata_get_identify(); |
| 279 | /* Show model */ |
| 280 | for (i=0; i < 20; i++) { |
| 281 | ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); |
| 282 | } |
| 283 | buf[40]=0; |
| 284 | for (i=39; i && buf[i]==' '; i--) { |
| 285 | buf[i]=0; |
| 286 | } |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 287 | printf(buf); |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 288 | } else { |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 289 | printf("ATA: %d", i); |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | disk_init(); |
| 293 | rc = disk_mount_all(); |
| 294 | if (rc<=0) |
| 295 | { |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 296 | printf("No partition found"); |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 297 | fatal_error(); |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | pinfo = disk_partinfo(1); |
Linus Nielsen Feltzing | f3f0d1c | 2007-01-16 23:12:02 +0000 | [diff] [blame] | 301 | printf("Partition 1: 0x%02x %ld MB", |
| 302 | pinfo->type, pinfo->size / 2048); |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 303 | |
Dave Chapman | 4d25bff | 2007-03-05 23:56:28 +0000 | [diff] [blame] | 304 | if (button_was_held || (btn==BUTTON_MENU)) { |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 305 | /* If either the hold switch was on, or the Menu button was held, then |
| 306 | try the Apple firmware */ |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 307 | |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 308 | printf("Loading original firmware..."); |
| 309 | |
| 310 | /* First try an apple_os.ipod file on the FAT32 partition |
| 311 | (either in .rockbox or the root) |
| 312 | */ |
| 313 | |
| 314 | rc=load_firmware(loadbuffer, "apple_os.ipod", MAX_LOADSIZE); |
| 315 | |
Dave Chapman | a02c426 | 2007-03-06 14:05:43 +0000 | [diff] [blame] | 316 | if (rc == EOK) { |
| 317 | printf("apple_os.ipod loaded."); |
| 318 | return (void*)DRAM_START; |
| 319 | } else if (rc == EFILE_NOT_FOUND) { |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 320 | /* If apple_os.ipod doesn't exist, then check if there is an Apple |
| 321 | firmware image in RAM */ |
| 322 | haveretailos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0); |
| 323 | if (haveretailos) { |
| 324 | /* We have a copy of the retailos in RAM, lets just run it. */ |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 325 | return (void*)DRAM_START; |
| 326 | } |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 327 | } else if (rc < EFILE_NOT_FOUND) { |
| 328 | printf("Error!"); |
| 329 | printf("Can't load apple_os.ipod:"); |
| 330 | printf(strerror(rc)); |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 331 | } |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 332 | |
| 333 | /* Everything failed - just loop forever */ |
| 334 | printf("No RetailOS detected"); |
| 335 | |
Dave Chapman | 4d25bff | 2007-03-05 23:56:28 +0000 | [diff] [blame] | 336 | } else if (btn==BUTTON_PLAY) { |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 337 | printf("Loading Linux..."); |
| 338 | rc=load_raw_firmware(loadbuffer, "/linux.bin", MAX_LOADSIZE); |
| 339 | if (rc < EOK) { |
| 340 | printf("Error!"); |
| 341 | printf("Can't load linux.bin:"); |
| 342 | printf(strerror(rc)); |
| 343 | } else { |
| 344 | return (void*)DRAM_START; |
| 345 | } |
| 346 | } else { |
| 347 | printf("Loading Rockbox..."); |
| 348 | rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE); |
| 349 | if (rc < EOK) { |
| 350 | printf("Error!"); |
| 351 | printf("Can't load rockbox.ipod:"); |
| 352 | printf(strerror(rc)); |
| 353 | } else { |
| 354 | printf("Rockbox loaded."); |
| 355 | return (void*)DRAM_START; |
Dave Chapman | 061f380 | 2005-11-13 20:59:30 +0000 | [diff] [blame] | 356 | } |
| 357 | } |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 358 | |
| 359 | /* If we get to here, then we haven't been able to load any firmware */ |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 360 | fatal_error(); |
Barry Wardell | 84b509d | 2007-01-28 18:42:11 +0000 | [diff] [blame] | 361 | |
Dave Chapman | 02aeacb | 2006-12-17 00:32:54 +0000 | [diff] [blame] | 362 | /* We never get here, but keep gcc happy */ |
| 363 | return (void*)0; |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /* These functions are present in the firmware library, but we reimplement |
| 367 | them here because the originals do a lot more than we want */ |
Dave Chapman | 38e8fb6 | 2005-11-08 00:52:39 +0000 | [diff] [blame] | 368 | void usb_acknowledge(void) |
| 369 | { |
| 370 | } |
| 371 | |
| 372 | void usb_wait_for_disconnect(void) |
| 373 | { |
| 374 | } |