2005-11-08 00:52:39 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Dave Chapman
|
|
|
|
*
|
|
|
|
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
|
|
|
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-11-08 00:52:39 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2005-11-13 20:59:30 +00:00
|
|
|
#include <string.h>
|
2007-01-16 23:12:02 +00:00
|
|
|
#include <stdarg.h>
|
2005-11-08 00:52:39 +00:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "ata.h"
|
|
|
|
#include "fat.h"
|
|
|
|
#include "disk.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "adc.h"
|
2007-11-21 21:28:46 +00:00
|
|
|
#include "backlight.h"
|
2005-11-08 00:52:39 +00:00
|
|
|
#include "panic.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "file.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "common.h"
|
2012-03-04 14:34:29 +00:00
|
|
|
#include "rb-loader.h"
|
|
|
|
#include "loader_strerror.h"
|
2007-07-25 13:12:38 +00:00
|
|
|
#include "hwcompat.h"
|
2010-04-13 22:17:42 +00:00
|
|
|
#include "usb.h"
|
2010-05-27 09:41:46 +00:00
|
|
|
#include "version.h"
|
2005-11-08 00:52:39 +00:00
|
|
|
|
2006-02-21 21:13:03 +00:00
|
|
|
#define XSC(X) #X
|
|
|
|
#define SC(X) XSC(X)
|
|
|
|
|
2007-01-28 18:42:11 +00:00
|
|
|
/* Maximum allowed firmware image size. The largest known current
|
|
|
|
(December 2006) firmware is about 7.5MB (Apple's firmware for the ipod video)
|
|
|
|
so we set this to 8MB. */
|
|
|
|
#define MAX_LOADSIZE (8*1024*1024)
|
|
|
|
|
|
|
|
/* A buffer to load the Linux kernel or Rockbox into */
|
|
|
|
unsigned char *loadbuffer = (unsigned char *)DRAM_START;
|
|
|
|
|
2006-04-19 18:06:56 +00:00
|
|
|
#if CONFIG_KEYPAD == IPOD_4G_PAD && !defined(IPOD_MINI)
|
2005-11-08 00:52:39 +00:00
|
|
|
/* check if number of seconds has past */
|
|
|
|
int timer_check(int clock_start, unsigned int usecs)
|
|
|
|
{
|
2006-02-05 19:05:55 +00:00
|
|
|
if ((USEC_TIMER - clock_start) >= usecs) {
|
2005-11-08 00:52:39 +00:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-13 20:59:30 +00:00
|
|
|
static void ser_opto_keypad_cfg(int val)
|
|
|
|
{
|
|
|
|
int start_time;
|
|
|
|
|
2007-03-03 17:25:20 +00:00
|
|
|
GPIOB_ENABLE &=~ 0x80;
|
2005-11-13 20:59:30 +00:00
|
|
|
|
|
|
|
outl(inl(0x7000c104) | 0xc000000, 0x7000c104);
|
|
|
|
outl(val, 0x7000c120);
|
|
|
|
outl(inl(0x7000c100) | 0x80000000, 0x7000c100);
|
|
|
|
|
2007-03-03 17:25:20 +00:00
|
|
|
GPIOB_OUTPUT_VAL &=~ 0x10;
|
|
|
|
GPIOB_OUTPUT_EN |= 0x10;
|
2005-11-13 20:59:30 +00:00
|
|
|
|
2006-02-05 19:05:55 +00:00
|
|
|
start_time = USEC_TIMER;
|
2005-11-13 20:59:30 +00:00
|
|
|
do {
|
|
|
|
if ((inl(0x7000c104) & 0x80000000) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (timer_check(start_time, 1500) != 0);
|
|
|
|
|
|
|
|
outl(inl(0x7000c100) & ~0x80000000, 0x7000c100);
|
|
|
|
|
2007-03-03 17:25:20 +00:00
|
|
|
GPIOB_ENABLE |= 0x80;
|
|
|
|
GPIOB_OUTPUT_VAL |= 0x10;
|
|
|
|
GPIOB_OUTPUT_EN &=~0x10;
|
2005-11-13 20:59:30 +00:00
|
|
|
|
|
|
|
outl(inl(0x7000c104) | 0xc000000, 0x7000c104);
|
|
|
|
outl(inl(0x7000c100) | 0x60000000, 0x7000c100);
|
|
|
|
}
|
|
|
|
|
|
|
|
int opto_keypad_read(void)
|
|
|
|
{
|
|
|
|
int loop_cnt, had_io = 0;
|
|
|
|
|
|
|
|
for (loop_cnt = 5; loop_cnt != 0;)
|
|
|
|
{
|
|
|
|
int key_pressed = 0;
|
|
|
|
int start_time;
|
|
|
|
unsigned int key_pad_val;
|
|
|
|
|
|
|
|
ser_opto_keypad_cfg(0x8000023a);
|
|
|
|
|
2006-02-05 19:05:55 +00:00
|
|
|
start_time = USEC_TIMER;
|
2005-11-13 20:59:30 +00:00
|
|
|
do {
|
|
|
|
if (inl(0x7000c104) & 0x4000000) {
|
|
|
|
had_io = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (had_io != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (timer_check(start_time, 1500) != 0);
|
|
|
|
|
|
|
|
key_pad_val = inl(0x7000c140);
|
|
|
|
if ((key_pad_val & ~0x7fff0000) != 0x8000023a) {
|
|
|
|
loop_cnt--;
|
|
|
|
} else {
|
|
|
|
key_pad_val = (key_pad_val << 11) >> 27;
|
|
|
|
key_pressed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
outl(inl(0x7000c100) | 0x60000000, 0x7000c100);
|
|
|
|
outl(inl(0x7000c104) | 0xc000000, 0x7000c104);
|
|
|
|
|
|
|
|
if (key_pressed != 0) {
|
|
|
|
return key_pad_val ^ 0x1f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-05 19:05:55 +00:00
|
|
|
#endif
|
2005-11-13 20:59:30 +00:00
|
|
|
|
|
|
|
static int key_pressed(void)
|
|
|
|
{
|
|
|
|
unsigned char state;
|
|
|
|
|
2006-02-05 19:05:55 +00:00
|
|
|
#if CONFIG_KEYPAD == IPOD_4G_PAD
|
2006-04-02 00:20:11 +00:00
|
|
|
#ifdef IPOD_MINI /* mini 1G only */
|
2006-02-27 12:35:05 +00:00
|
|
|
state = GPIOA_INPUT_VAL & 0x3f;
|
2006-04-19 18:06:56 +00:00
|
|
|
if ((state & 0x10) == 0) return BUTTON_LEFT;
|
|
|
|
if ((state & 0x2) == 0) return BUTTON_MENU;
|
|
|
|
if ((state & 0x4) == 0) return BUTTON_PLAY;
|
|
|
|
if ((state & 0x8) == 0) return BUTTON_RIGHT;
|
2006-02-27 12:35:05 +00:00
|
|
|
#else
|
2005-11-13 20:59:30 +00:00
|
|
|
state = opto_keypad_read();
|
|
|
|
if ((state & 0x4) == 0) return BUTTON_LEFT;
|
|
|
|
if ((state & 0x10) == 0) return BUTTON_MENU;
|
|
|
|
if ((state & 0x8) == 0) return BUTTON_PLAY;
|
|
|
|
if ((state & 0x2) == 0) return BUTTON_RIGHT;
|
2006-04-19 18:06:56 +00:00
|
|
|
#endif
|
2007-07-27 07:32:55 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
|
|
|
state = GPIOA_INPUT_VAL;
|
2006-02-05 19:05:55 +00:00
|
|
|
if ((state & 0x08) == 0) return BUTTON_LEFT;
|
|
|
|
if ((state & 0x10) == 0) return BUTTON_MENU;
|
|
|
|
if ((state & 0x04) == 0) return BUTTON_PLAY;
|
|
|
|
if ((state & 0x01) == 0) return BUTTON_RIGHT;
|
|
|
|
#endif
|
2005-11-13 20:59:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-17 00:32:54 +00:00
|
|
|
bool button_hold(void)
|
|
|
|
{
|
2007-07-27 07:32:55 +00:00
|
|
|
#if CONFIG_KEYPAD == IPOD_1G2G_PAD
|
|
|
|
return (GPIOA_INPUT_VAL & 0x20);
|
|
|
|
#else
|
|
|
|
return !(GPIOA_INPUT_VAL & 0x20);
|
|
|
|
#endif
|
2006-12-17 00:32:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fatal_error(void)
|
|
|
|
{
|
2007-01-28 18:42:11 +00:00
|
|
|
extern int line;
|
2006-12-17 00:32:54 +00:00
|
|
|
bool holdstatus=false;
|
|
|
|
|
2006-12-17 10:23:51 +00:00
|
|
|
/* System font is 6 pixels wide */
|
2007-07-27 07:32:55 +00:00
|
|
|
#if defined(IPOD_1G2G) || defined(IPOD_3G)
|
2010-04-13 22:17:42 +00:00
|
|
|
printf("Insert Firewire cable, or");
|
|
|
|
printf("hold MENU+PLAY to reboot");
|
|
|
|
printf("then REW+FF for disk mode");
|
2007-07-27 07:32:55 +00:00
|
|
|
#elif LCD_WIDTH >= (30*6)
|
2010-04-13 22:17:42 +00:00
|
|
|
printf("Insert USB cable, or");
|
|
|
|
printf("hold MENU+SELECT to reboot");
|
2007-01-16 23:12:02 +00:00
|
|
|
printf("then SELECT+PLAY for disk mode");
|
2006-12-17 10:23:51 +00:00
|
|
|
#else
|
2010-04-13 22:17:42 +00:00
|
|
|
printf("Insert USB cable, or");
|
|
|
|
printf("hold MENU+SELECT to");
|
2007-01-16 23:12:02 +00:00
|
|
|
printf("reboot then SELECT+PLAY");
|
|
|
|
printf("for disk mode");
|
2006-12-17 10:23:51 +00:00
|
|
|
#endif
|
2007-05-22 19:05:14 +00:00
|
|
|
lcd_update();
|
2006-12-17 00:32:54 +00:00
|
|
|
|
2010-04-13 22:17:42 +00:00
|
|
|
usb_init();
|
2006-12-17 00:32:54 +00:00
|
|
|
while (1) {
|
|
|
|
if (button_hold() != holdstatus) {
|
|
|
|
if (button_hold()) {
|
|
|
|
holdstatus=true;
|
|
|
|
lcd_puts(0, line, "Hold switch on!");
|
|
|
|
} else {
|
|
|
|
holdstatus=false;
|
|
|
|
lcd_puts(0, line, " ");
|
|
|
|
}
|
|
|
|
lcd_update();
|
|
|
|
}
|
2010-04-13 22:17:42 +00:00
|
|
|
if (usb_detect() == USB_INSERTED) {
|
|
|
|
ata_sleepnow(); /* Immediately spindown the disk. */
|
|
|
|
sleep(HZ*2);
|
|
|
|
#if CONFIG_CPU == PP5020
|
|
|
|
memcpy((void *)0x40017f00, "diskmode\0\0hotstuff\0\0\1", 21);
|
|
|
|
#elif CONFIG_CPU == PP5022
|
|
|
|
memcpy((void *)0x4001ff00, "diskmode\0\0hotstuff\0\0\1", 21);
|
|
|
|
#elif CONFIG_CPU == PP5002
|
|
|
|
memcpy((void *)0x40017f00, "diskmodehotstuff\1", 17);
|
|
|
|
#endif /* CONFIG_CPU */
|
|
|
|
system_reboot(); /* Reboot */
|
|
|
|
}
|
2006-12-17 00:32:54 +00:00
|
|
|
udelay(100000); /* 100ms */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-05-12 20:41:44 +00:00
|
|
|
/* The bootloader is started from the OSOS image on the firmware
|
|
|
|
* partition. There are several ways it can be installed there:
|
|
|
|
* appended to the Apple firmware, on its own, or appended to
|
|
|
|
* Rockbox itself. The Apple ROM loader loads the entire OSOS
|
|
|
|
* image to DRAM_START, whatever it contains. If the bootloader
|
|
|
|
* is appended to another image then it will've modified the
|
|
|
|
* entry point in the OSOS header such that the ROM will call the
|
|
|
|
* bootloader rather than the main image.
|
|
|
|
*
|
|
|
|
* So, once the bootloader has control:
|
|
|
|
*
|
|
|
|
* 1) If the hold switch is on, or the menu button is being held,
|
|
|
|
* try to boot the Apple firmware.
|
|
|
|
* 1a) First, it looks for apple_os.ipod on the FAT32 partition,
|
|
|
|
* in .rockbox or the root directory. If found it loads that
|
|
|
|
* without further checking and runs it.
|
|
|
|
* 1b) Next, it checks to see if the OSOS image already loaded
|
|
|
|
* into RAM is in fact the Apple firmware with the bootloader
|
|
|
|
* appended. It looks at DRAM_START+0x20 for the string
|
|
|
|
* "portalplayer", and if it's there, just jumps back to
|
|
|
|
* DRAM_START where the entry point was before the bootloader
|
|
|
|
* was appended.
|
|
|
|
* 1c) If neither of those worked, it displays an error and dies.
|
|
|
|
*
|
|
|
|
* 2) If the play button is being held, try to boot Linux. It looks
|
|
|
|
* for linux.bin in the root directory, and if it's not there,
|
|
|
|
* it displays an error and dies.
|
|
|
|
*
|
|
|
|
* 3) Otherwise, try to boot Rockbox.
|
|
|
|
* 3a) First, it looks for rockbox.ipod on the FAT32 partition,
|
|
|
|
* in .rockbox or the root directory. If found it loads that
|
|
|
|
* without further checking and runs it.
|
|
|
|
* 3b) Next, it checks to see if the OSOS image already loaded
|
|
|
|
* into RAM is in fact Rockbox with the bootloader appended.
|
|
|
|
* It looks at DRAM_START+0x20 for the string "Rockbox\1"
|
|
|
|
* (which is inserted there in crt0-pp.S), and if it's there,
|
|
|
|
* just humps back to DRAM_START where the entry point was
|
|
|
|
* before the bootloader was appended.
|
|
|
|
* 3c) If neither of those worked, it displays an error and dies.
|
|
|
|
*
|
|
|
|
* The result is that any of the three install configurations work,
|
|
|
|
* and that images of apple_os.ipod or rockbox.ipod on the FAT32
|
|
|
|
* partition take priority over the contents of OSOS (this avoids
|
|
|
|
* upgrades failing to work if OSOS is not updated).
|
|
|
|
*
|
|
|
|
* Loading from OSOS is somewhat faster than loading from FAT32,
|
|
|
|
* because the Apple ROM doesn't have to deal with filesystems or
|
|
|
|
* fragmentation, and is already loading from OSOS anyway. Thus,
|
|
|
|
* the fastest boot configuration that still allows dual booting
|
|
|
|
* is to install Rockbox into OSOS with the bootloader appended
|
|
|
|
* (and delete/rename rockbox.ipod from the FAT32 partition).
|
|
|
|
*
|
|
|
|
* It is of course faster to just install Rockbox to OSOS alone,
|
|
|
|
* but then it's impossible to boot the Apple firmware.
|
|
|
|
*/
|
2006-12-17 00:32:54 +00:00
|
|
|
|
2005-11-08 00:52:39 +00:00
|
|
|
void* main(void)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
int i;
|
2007-03-05 23:56:28 +00:00
|
|
|
int btn;
|
2005-11-08 00:52:39 +00:00
|
|
|
int rc;
|
2009-05-12 20:41:44 +00:00
|
|
|
bool haveramos;
|
2006-12-17 00:32:54 +00:00
|
|
|
bool button_was_held;
|
2005-11-08 00:52:39 +00:00
|
|
|
struct partinfo* pinfo;
|
|
|
|
unsigned short* identify_info;
|
|
|
|
|
2006-12-17 00:32:54 +00:00
|
|
|
/* Check the button hold status as soon as possible - to
|
|
|
|
give the user maximum chance to turn it off in order to
|
|
|
|
reset the settings in rockbox. */
|
|
|
|
button_was_held = button_hold();
|
|
|
|
|
2007-11-21 21:28:46 +00:00
|
|
|
system_init();
|
|
|
|
kernel_init();
|
|
|
|
|
2007-09-12 22:21:03 +00:00
|
|
|
#ifndef HAVE_BACKLIGHT_INVERSION
|
2007-11-21 21:28:46 +00:00
|
|
|
backlight_init(); /* Turns on the backlight */
|
2007-09-12 22:21:03 +00:00
|
|
|
#endif
|
2005-11-08 00:52:39 +00:00
|
|
|
|
|
|
|
lcd_init();
|
|
|
|
font_init();
|
|
|
|
|
2006-12-17 00:32:54 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
lcd_set_foreground(LCD_WHITE);
|
|
|
|
lcd_set_background(LCD_BLACK);
|
|
|
|
lcd_clear_display();
|
|
|
|
#endif
|
|
|
|
|
2005-11-08 00:52:39 +00:00
|
|
|
#if 0
|
|
|
|
/* ADC and button drivers are not yet implemented */
|
|
|
|
adc_init();
|
|
|
|
button_init();
|
|
|
|
#endif
|
|
|
|
|
2007-03-05 23:56:28 +00:00
|
|
|
btn=key_pressed();
|
|
|
|
|
|
|
|
/* Enable bootloader messages */
|
|
|
|
if (btn==BUTTON_RIGHT)
|
|
|
|
verbose = true;
|
2005-11-08 00:52:39 +00:00
|
|
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
2007-01-16 23:12:02 +00:00
|
|
|
printf("Rockbox boot loader");
|
2010-05-27 09:41:46 +00:00
|
|
|
printf("Version: " RBVERSION);
|
2007-01-16 23:12:02 +00:00
|
|
|
printf("IPOD version: 0x%08x", IPOD_HW_REVISION);
|
2005-11-08 00:52:39 +00:00
|
|
|
|
|
|
|
i=ata_init();
|
|
|
|
if (i==0) {
|
|
|
|
identify_info=ata_get_identify();
|
|
|
|
/* Show model */
|
|
|
|
for (i=0; i < 20; i++) {
|
|
|
|
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
|
|
|
|
}
|
|
|
|
buf[40]=0;
|
|
|
|
for (i=39; i && buf[i]==' '; i--) {
|
|
|
|
buf[i]=0;
|
|
|
|
}
|
2007-01-16 23:12:02 +00:00
|
|
|
printf(buf);
|
2005-11-08 00:52:39 +00:00
|
|
|
} else {
|
2007-01-16 23:12:02 +00:00
|
|
|
printf("ATA: %d", i);
|
2005-11-08 00:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
disk_init();
|
|
|
|
rc = disk_mount_all();
|
|
|
|
if (rc<=0)
|
|
|
|
{
|
2007-01-16 23:12:02 +00:00
|
|
|
printf("No partition found");
|
2006-12-17 00:32:54 +00:00
|
|
|
fatal_error();
|
2005-11-08 00:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pinfo = disk_partinfo(1);
|
2008-11-21 15:20:25 +00:00
|
|
|
printf("Partition 1: 0x%02x %ld sectors",
|
|
|
|
pinfo->type, pinfo->size);
|
2005-11-08 00:52:39 +00:00
|
|
|
|
2007-03-05 23:56:28 +00:00
|
|
|
if (button_was_held || (btn==BUTTON_MENU)) {
|
2007-01-28 18:42:11 +00:00
|
|
|
/* If either the hold switch was on, or the Menu button was held, then
|
|
|
|
try the Apple firmware */
|
|
|
|
|
|
|
|
printf("Loading original firmware...");
|
|
|
|
|
|
|
|
/* First try an apple_os.ipod file on the FAT32 partition
|
|
|
|
(either in .rockbox or the root)
|
|
|
|
*/
|
|
|
|
|
|
|
|
rc=load_firmware(loadbuffer, "apple_os.ipod", MAX_LOADSIZE);
|
|
|
|
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc > 0) {
|
2007-03-06 14:05:43 +00:00
|
|
|
printf("apple_os.ipod loaded.");
|
|
|
|
return (void*)DRAM_START;
|
|
|
|
} else if (rc == EFILE_NOT_FOUND) {
|
2007-01-28 18:42:11 +00:00
|
|
|
/* If apple_os.ipod doesn't exist, then check if there is an Apple
|
|
|
|
firmware image in RAM */
|
2009-05-12 20:41:44 +00:00
|
|
|
haveramos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0);
|
|
|
|
if (haveramos) {
|
2007-01-28 18:42:11 +00:00
|
|
|
/* We have a copy of the retailos in RAM, lets just run it. */
|
2006-12-17 00:32:54 +00:00
|
|
|
return (void*)DRAM_START;
|
|
|
|
}
|
2012-03-04 14:34:29 +00:00
|
|
|
} else {
|
2007-01-28 18:42:11 +00:00
|
|
|
printf("Error!");
|
|
|
|
printf("Can't load apple_os.ipod:");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2007-01-28 18:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Everything failed - just loop forever */
|
|
|
|
printf("No RetailOS detected");
|
|
|
|
|
2007-03-05 23:56:28 +00:00
|
|
|
} else if (btn==BUTTON_PLAY) {
|
2007-01-28 18:42:11 +00:00
|
|
|
printf("Loading Linux...");
|
|
|
|
rc=load_raw_firmware(loadbuffer, "/linux.bin", MAX_LOADSIZE);
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc <= EFILE_EMPTY) {
|
2007-01-28 18:42:11 +00:00
|
|
|
printf("Error!");
|
|
|
|
printf("Can't load linux.bin:");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2007-01-28 18:42:11 +00:00
|
|
|
} else {
|
|
|
|
return (void*)DRAM_START;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("Loading Rockbox...");
|
|
|
|
rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE);
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc > 0) {
|
2007-01-28 18:42:11 +00:00
|
|
|
printf("Rockbox loaded.");
|
|
|
|
return (void*)DRAM_START;
|
2009-05-12 20:41:44 +00:00
|
|
|
} else if (rc == EFILE_NOT_FOUND) {
|
|
|
|
/* if rockbox.ipod doesn't exist, then check if there is a Rockbox
|
|
|
|
image in RAM */
|
|
|
|
haveramos = (memcmp((void*)(DRAM_START+0x20),"Rockbox\1",8)==0);
|
|
|
|
if (haveramos) {
|
|
|
|
/* We have a copy of Rockbox in RAM, lets just run it. */
|
|
|
|
return (void*)DRAM_START;
|
|
|
|
}
|
2005-11-13 20:59:30 +00:00
|
|
|
}
|
2009-05-12 20:41:44 +00:00
|
|
|
|
|
|
|
printf("Error!");
|
|
|
|
printf("Can't load " BOOTFILE ": ");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2005-11-13 20:59:30 +00:00
|
|
|
}
|
2007-01-28 18:42:11 +00:00
|
|
|
|
|
|
|
/* If we get to here, then we haven't been able to load any firmware */
|
2006-12-17 00:32:54 +00:00
|
|
|
fatal_error();
|
2007-01-28 18:42:11 +00:00
|
|
|
|
2006-12-17 00:32:54 +00:00
|
|
|
/* We never get here, but keep gcc happy */
|
|
|
|
return (void*)0;
|
2005-11-08 00:52:39 +00:00
|
|
|
}
|