Add the missing optional column separator for targets with HAVEREMOTEKEYMAP to the...
[kugel-rb.git] / bootloader / creativezvm.c
blob6469de7c29c09d862bce77f50b195b6cf9142339
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Maurus Cuelenaere
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "system.h"
21 #include "lcd.h"
22 #include "kernel.h"
23 #include "thread.h"
24 #include "storage.h"
25 #include "ata-target.h"
26 #include "disk.h"
27 #include "font.h"
28 #include "backlight.h"
29 #include "button.h"
30 #include "common.h"
31 #include "usb.h"
34 static void load_fw(unsigned char* ptr, unsigned int len)
36 (void)ptr;
37 (void)len;
38 asm volatile("ldr pc, =0x1EE0000");
41 void main(void)
43 unsigned char* loadbuffer;
44 int buffer_size;
45 int(*kernel_entry)(void);
46 int ret;
48 /* Make sure interrupts are disabled */
49 set_irq_level(IRQ_DISABLED);
50 set_fiq_status(FIQ_DISABLED);
51 system_init();
52 kernel_init();
54 /* Now enable interrupts */
55 set_irq_level(IRQ_ENABLED);
56 set_fiq_status(FIQ_ENABLED);
57 backlight_init();
58 lcd_init();
59 font_init();
60 button_init();
61 usb_init();
63 #ifdef HAVE_LCD_ENABLE
64 lcd_enable(true);
65 #endif
66 lcd_setfont(FONT_SYSFIXED);
67 reset_screen();
68 printf("Rockbox boot loader");
69 printf("Version %s", APPSVERSION);
71 ret = storage_init();
72 if(ret)
73 printf("ATA error: %d", ret);
75 /* If no button is held, start the OF */
76 if(button_read_device() == 0)
78 printf("Loading Creative firmware...");
80 loadbuffer = (unsigned char*)0x00A00000;
81 ret = load_minifs_file("creativeos.jrm", loadbuffer);
82 if(ret != -1)
84 set_irq_level(IRQ_DISABLED);
85 set_fiq_status(FIQ_DISABLED);
86 /* Doesn't return! */
87 load_fw(loadbuffer, ret);
89 else
90 printf("FAILED!");
92 else
94 disk_init();
96 ret = disk_mount_all();
97 if (ret <= 0)
98 error(EDISK, ret);
100 printf("Loading Rockbox firmware...");
102 loadbuffer = (unsigned char*)0x00900000;
103 buffer_size = (unsigned char*)0x01900000 - loadbuffer;
105 ret = load_firmware(loadbuffer, BOOTFILE, buffer_size);
106 if(ret < 0)
107 error(EBOOTFILE, ret);
109 else if(ret == EOK)
111 kernel_entry = (void*) loadbuffer;
112 ret = kernel_entry();
113 printf("FAILED!");
117 storage_sleepnow();
119 while(1);