zenutils: remove unused empty file
[maemo-rb.git] / bootloader / mrobe500.c
blob5b9c520d023e2d9c0d3c63009a9fd460a827a473
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Karl Kurbjun
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "inttypes.h"
23 #include "string.h"
24 #include "cpu.h"
25 #include "system.h"
26 #include "lcd.h"
27 #include "kernel.h"
28 #include "thread.h"
29 #include "storage.h"
30 #include "fat.h"
31 #include "disk.h"
32 #include "font.h"
33 #include "adc.h"
34 #include "backlight.h"
35 #include "backlight-target.h"
36 #include "button.h"
37 #include "panic.h"
38 #include "power.h"
39 #include "file.h"
40 #include "common.h"
41 #include "rbunicode.h"
42 #include "usb.h"
43 #include "spi.h"
44 #include "uart-target.h"
45 #include "tsc2100.h"
46 #include "time.h"
47 #include "system-arm.h"
48 #include "version.h"
50 void main(void)
52 unsigned char* loadbuffer;
53 int buffer_size;
54 int rc;
55 int(*kernel_entry)(void);
57 /* Make sure interrupts are disabled */
58 set_irq_level(IRQ_DISABLED);
59 set_fiq_status(FIQ_DISABLED);
60 system_init();
61 kernel_init();
63 /* Now enable interrupts */
64 set_irq_level(IRQ_ENABLED);
65 set_fiq_status(FIQ_ENABLED);
67 lcd_init();
68 backlight_init();
69 font_init();
70 button_init();
71 usb_init();
74 power_init();
75 // enable_irq();
76 // enable_fiq();
78 adc_init();
80 lcd_setfont(FONT_SYSFIXED);
82 /* Show debug messages if button is pressed */
83 // if(button_read_device())
84 verbose = true;
86 printf("Rockbox boot loader");
87 printf("Version " RBVERSION);
89 /* Enter USB mode without USB thread */
90 if(usb_detect() == USB_INSERTED)
92 const char msg[] = "Bootloader USB mode";
93 reset_screen();
94 lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2,
95 (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
96 lcd_update();
98 ide_power_enable(true);
99 storage_enable(false);
100 sleep(HZ/20);
101 usb_enable(true);
103 while (usb_detect() == USB_INSERTED)
105 storage_spin(); /* Prevent the drive from spinning down */
106 sleep(HZ);
109 usb_enable(false);
111 reset_screen();
112 lcd_update();
115 sleep(50);
117 printf("ATA");
118 rc = storage_init();
119 if(rc)
121 reset_screen();
122 error(EATA, rc, true);
125 printf("disk");
126 disk_init();
128 printf("mount");
129 rc = disk_mount_all();
130 if (rc<=0)
132 error(EDISK,rc, true);
135 printf("Loading firmware");
137 loadbuffer = (unsigned char*) 0x00900000;
138 buffer_size = (unsigned char*)0x01900000 - loadbuffer;
140 rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
141 if(rc < 0)
142 error(EBOOTFILE, rc, true);
144 if (rc == EOK)
146 kernel_entry = (void*) loadbuffer;
147 rc = kernel_entry();