Document the Play Next option. (adjusted FS#6486)
[Rockbox.git] / bootloader / main-pp.c
blob5659073457f314cbf8acbc81c64d7c8de41f3478
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Barry Wardell
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
13 * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
15 * All files in this archive are subject to the GNU General Public License.
16 * See the file COPYING in the source tree root for full license agreement.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #include "common.h"
23 #include "cpu.h"
24 #include "file.h"
25 #include "system.h"
26 #include "kernel.h"
27 #include "lcd.h"
28 #include "font.h"
29 #include "ata.h"
30 #include "button.h"
31 #include "disk.h"
32 #include "power.h"
34 /* Maximum allowed firmware image size. 10MB is more than enough */
35 #define MAX_LOADSIZE (10*1024*1024)
37 /* A buffer to load the original firmware or Rockbox into */
38 unsigned char *loadbuffer = (unsigned char *)DRAM_START;
40 /* Bootloader version */
41 char version[] = APPSVERSION;
43 void* main(void)
45 char buf[256];
46 int i;
47 int rc;
48 unsigned short* identify_info;
49 struct partinfo* pinfo;
51 system_init();
52 kernel_init();
53 lcd_init();
54 font_init();
55 button_init();
57 lcd_setfont(FONT_SYSFIXED);
59 printf("Rockbox boot loader");
60 printf("Version: 20%s", version);
61 printf(MODEL_NAME);
63 i=ata_init();
64 if (i==0) {
65 identify_info=ata_get_identify();
66 /* Show model */
67 for (i=0; i < 20; i++) {
68 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
70 buf[40]=0;
71 for (i=39; i && buf[i]==' '; i--) {
72 buf[i]=0;
74 printf(buf);
75 } else {
76 printf("ATA error: %d", i);
77 udelay(5000000);
78 power_off();
81 disk_init();
82 rc = disk_mount_all();
83 if (rc<=0)
85 printf("No partition found");
86 udelay(5000000);
87 power_off();
90 pinfo = disk_partinfo(0);
91 printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048);
93 i=button_read_device();
94 if(i==BUTTON_LEFT)
96 /* Load original mi4 firmware. This expects a file called
97 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted
98 and header stripped using mi4code. It reads the file in to a memory
99 buffer called loadbuffer. The rest of the loading is done in crt0.S
101 printf("Loading original firmware...");
102 rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE);
103 if (rc < EOK) {
104 printf("Error!");
105 printf("Can't load /System/OF.bin:");
106 printf(strerror(rc));
107 udelay(5000000);
108 power_off();
110 } else {
111 printf("Loading Rockbox...");
112 rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE);
113 if (rc < EOK) {
114 printf("Error!");
115 printf("Can't load %s:", BOOTFILE);
116 printf(strerror(rc));
117 udelay(5000000);
118 power_off();
122 return (void*)loadbuffer;
125 /* These functions are present in the firmware library, but we reimplement
126 them here because the originals do a lot more than we want */
127 void usb_acknowledge(void)
131 void usb_wait_for_disconnect(void)