2007-02-23 09:30:09 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Greg White
|
|
|
|
*
|
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.
|
2007-02-23 09:30:09 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2006-08-12 08:27:48 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2007-04-21 04:48:20 +00:00
|
|
|
#include "inttypes.h"
|
|
|
|
#include "string.h"
|
2006-08-12 08:27:48 +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"
|
|
|
|
#include "backlight.h"
|
2007-04-21 04:48:20 +00:00
|
|
|
#include "backlight-target.h"
|
|
|
|
#include "button.h"
|
2006-08-12 08:27:48 +00:00
|
|
|
#include "panic.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "file.h"
|
2007-02-22 15:09:49 +00:00
|
|
|
#include "common.h"
|
2007-04-21 04:48:20 +00:00
|
|
|
#include "rbunicode.h"
|
|
|
|
#include "usb.h"
|
2007-10-23 03:29:15 +00:00
|
|
|
#include "mmu-arm.h"
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
#include <stdarg.h>
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2006-08-12 08:27:48 +00:00
|
|
|
char version[] = APPSVERSION;
|
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
void main(void)
|
2006-12-29 02:49:12 +00:00
|
|
|
{
|
|
|
|
unsigned char* loadbuffer;
|
|
|
|
int buffer_size;
|
|
|
|
int rc;
|
|
|
|
int(*kernel_entry)(void);
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
power_init();
|
|
|
|
system_init();
|
|
|
|
lcd_init();
|
|
|
|
backlight_init();
|
|
|
|
font_init();
|
2007-01-17 01:49:19 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
usb_init();
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
/* Enter USB mode without USB thread */
|
2007-09-04 08:03:07 +00:00
|
|
|
if(usb_detect() == USB_INSERTED)
|
2007-04-21 04:48:20 +00:00
|
|
|
{
|
|
|
|
const char msg[] = "Bootloader USB mode";
|
|
|
|
reset_screen();
|
|
|
|
lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2,
|
|
|
|
(LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
|
|
|
|
lcd_update();
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
ata_enable(false);
|
|
|
|
sleep(HZ/20);
|
|
|
|
usb_enable(true);
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-09-04 08:03:07 +00:00
|
|
|
while (usb_detect() == USB_INSERTED)
|
2007-04-21 04:48:20 +00:00
|
|
|
sleep(HZ);
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
usb_enable(false);
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
reset_screen();
|
|
|
|
lcd_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
kernel_init();
|
|
|
|
adc_init();
|
|
|
|
button_init();
|
|
|
|
|
|
|
|
/* Show debug messages if button is pressed */
|
|
|
|
if(button_read_device())
|
|
|
|
verbose = true;
|
|
|
|
|
|
|
|
printf("Rockbox boot loader");
|
|
|
|
printf("Version %s", version);
|
|
|
|
|
2008-04-22 04:34:25 +00:00
|
|
|
sleep(50); /* ATA seems to error without this pause */
|
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
rc = ata_init();
|
|
|
|
if(rc)
|
|
|
|
{
|
|
|
|
reset_screen();
|
|
|
|
error(EATA, rc);
|
2007-01-17 01:49:19 +00:00
|
|
|
}
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
disk_init();
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
rc = disk_mount_all();
|
|
|
|
if (rc<=0)
|
|
|
|
{
|
|
|
|
error(EDISK,rc);
|
2006-12-29 02:49:12 +00:00
|
|
|
}
|
2006-08-12 08:27:48 +00:00
|
|
|
|
2007-04-21 04:48:20 +00:00
|
|
|
printf("Loading firmware");
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2008-04-22 04:34:25 +00:00
|
|
|
loadbuffer = (unsigned char*) 0x31000000;
|
|
|
|
buffer_size = (unsigned char*)0x31400000 - loadbuffer;
|
2007-04-21 04:48:20 +00:00
|
|
|
|
|
|
|
rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
|
|
|
|
if(rc < 0)
|
|
|
|
error(EBOOTFILE, rc);
|
|
|
|
|
|
|
|
if (rc == EOK)
|
|
|
|
{
|
2007-01-13 02:24:15 +00:00
|
|
|
kernel_entry = (void*) loadbuffer;
|
2006-12-29 02:49:12 +00:00
|
|
|
rc = kernel_entry();
|
|
|
|
}
|
2006-08-12 08:27:48 +00:00
|
|
|
}
|
|
|
|
|