mkrk27boot: Fix makefile.
[maemo-rb.git] / bootloader / sansaconnect.c
blob6b2a7e6124daef0a1fbf0a5f44df5513c43ac9f1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
10 * Copyright (C) 2011 by Tomasz Moń
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 "disk.h"
26 #include "font.h"
27 #include "backlight.h"
28 #include "button.h"
29 #include "common.h"
30 #include "version.h"
31 #include "uart-target.h"
32 #include "power.h"
34 extern void show_logo(void);
36 void main(void)
38 unsigned char* loadbuffer;
39 int buffer_size;
40 int(*kernel_entry)(void);
41 int ret;
42 int btn;
44 /* Make sure interrupts are disabled */
45 set_irq_level(IRQ_DISABLED);
46 set_fiq_status(FIQ_DISABLED);
47 system_init();
48 kernel_init();
50 /* Now enable interrupts */
51 set_irq_level(IRQ_ENABLED);
52 set_fiq_status(FIQ_ENABLED);
53 backlight_init();
54 lcd_init();
55 font_init();
56 button_init();
58 #ifdef HAVE_LCD_ENABLE
59 lcd_enable(true);
60 #endif
61 lcd_setfont(FONT_SYSFIXED);
62 reset_screen();
63 show_logo();
65 btn = button_read_device();
67 printf("Rockbox boot loader");
68 printf("Version " RBVERSION);
70 ret = storage_init();
71 if(ret)
72 printf("SD error: %d", ret);
74 disk_init(IF_MD(0));
76 ret = disk_mount_all();
77 if (ret <= 0)
78 error(EDISK, ret, true);
80 if (btn & BUTTON_PREV)
82 printf("Loading OF firmware...");
83 printf("Loading vmlinux.bin...");
84 loadbuffer = (unsigned char*)0x01008000;
85 buffer_size = 0x200000;
87 ret = load_raw_firmware(loadbuffer, "/vmlinux.bin", buffer_size);
89 if (ret < 0)
91 printf("Unable to load vmlinux.bin");
93 else
95 printf("Loading initrd.bin...");
96 loadbuffer = (unsigned char*)0x04400020;
97 buffer_size = 0x200000;
98 ret = load_raw_firmware(loadbuffer, "/initrd.bin", buffer_size);
101 if (ret > 0)
103 system_prepare_fw_start();
105 kernel_entry = (void*)0x01008000;
106 ret = kernel_entry();
107 printf("FAILED to boot OF");
111 printf("Loading Rockbox firmware...");
113 loadbuffer = (unsigned char*)CONFIG_SDRAM_START;
114 buffer_size = 0x1000000;
116 ret = load_firmware(loadbuffer, BOOTFILE, buffer_size);
118 if(ret < 0)
120 error(EBOOTFILE, ret, true);
122 else if(ret == EOK)
124 system_prepare_fw_start();
126 kernel_entry = (void*) loadbuffer;
127 ret = kernel_entry();
128 printf("FAILED!");
131 storage_sleepnow();
133 while(1);