diff options
Diffstat (limited to 'bootloader/creativezvm.c')
-rw-r--r-- | bootloader/creativezvm.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/bootloader/creativezvm.c b/bootloader/creativezvm.c new file mode 100644 index 0000000000..f7a6d343d5 --- /dev/null +++ b/bootloader/creativezvm.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "system.h" | ||
21 | #include "lcd.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "ata.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 | |||
32 | |||
33 | static void load_fw(unsigned char* ptr, unsigned int len) | ||
34 | { | ||
35 | (void)ptr; | ||
36 | (void)len; | ||
37 | asm volatile("ldr pc, =0x1EE0000"); | ||
38 | } | ||
39 | |||
40 | void main(void) | ||
41 | { | ||
42 | unsigned char* loadbuffer; | ||
43 | int buffer_size; | ||
44 | int(*kernel_entry)(void); | ||
45 | int ret; | ||
46 | |||
47 | /* Make sure interrupts are disabled */ | ||
48 | set_irq_level(IRQ_DISABLED); | ||
49 | set_fiq_status(FIQ_DISABLED); | ||
50 | system_init(); | ||
51 | kernel_init(); | ||
52 | |||
53 | /* Now enable interrupts */ | ||
54 | set_irq_level(IRQ_ENABLED); | ||
55 | set_fiq_status(FIQ_ENABLED); | ||
56 | backlight_init(); | ||
57 | lcd_init(); | ||
58 | font_init(); | ||
59 | button_init(); | ||
60 | |||
61 | lcd_enable(true); | ||
62 | lcd_setfont(FONT_SYSFIXED); | ||
63 | reset_screen(); | ||
64 | printf("Rockbox boot loader"); | ||
65 | printf("Version %s", APPSVERSION); | ||
66 | |||
67 | ret = ata_init(); | ||
68 | if(ret) | ||
69 | printf("ATA error: %d", ret); | ||
70 | |||
71 | if(1) | ||
72 | { | ||
73 | printf("Loading Creative firmware..."); | ||
74 | |||
75 | loadbuffer = (unsigned char*)0x00A00000; | ||
76 | ret = load_minifs_file("creativeos.jrm", loadbuffer); | ||
77 | if(ret != -1) | ||
78 | { | ||
79 | set_irq_level(IRQ_DISABLED); | ||
80 | set_fiq_status(FIQ_DISABLED); | ||
81 | /* Doesn't return! */ | ||
82 | load_fw(loadbuffer, ret); | ||
83 | } | ||
84 | else | ||
85 | printf("FAILED!"); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | disk_init(); | ||
90 | |||
91 | ret = disk_mount_all(); | ||
92 | if (ret <= 0) | ||
93 | error(EDISK, ret); | ||
94 | |||
95 | printf("Loading Rockbox firmware..."); | ||
96 | |||
97 | loadbuffer = (unsigned char*)0x00900000; | ||
98 | buffer_size = (unsigned char*)0x01900000 - loadbuffer; | ||
99 | |||
100 | ret = load_firmware(loadbuffer, BOOTFILE, buffer_size); | ||
101 | if(ret < 0) | ||
102 | error(EBOOTFILE, ret); | ||
103 | |||
104 | else if(ret == EOK) | ||
105 | { | ||
106 | kernel_entry = (void*) loadbuffer; | ||
107 | ret = kernel_entry(); | ||
108 | printf("FAILED!"); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | while(1); | ||
113 | } | ||