fix checkwps
[maemo-rb.git] / bootloader / mini2440.c
blob23f135cb1a05a97c5ac125dd8d1e52c12210cb5d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2009 by Bob Cousins, Lyre Project
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 Standard files */
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include "inttypes.h"
26 #include "string.h"
27 #include "cpu.h"
28 #include "system.h"
29 #include "lcd.h"
30 #include "kernel.h"
31 #include "thread.h"
32 #include "storage.h"
33 #include "fat.h"
34 #include "disk.h"
35 #include "font.h"
36 #include "backlight.h"
37 #include "button.h"
38 #include "panic.h"
39 #include "power.h"
40 #include "file.h"
41 #include "common.h"
42 #include "sd.h"
43 #include "backlight-target.h"
44 #include "lcd-target.h"
45 #include "debug-target.h"
46 #include "dma-target.h"
47 #include "uart-s3c2440.h"
48 #include "led-mini2440.h"
49 #include "version.h"
52 int main(void)
54 unsigned char* loadbuffer;
55 int buffer_size;
56 int rc;
57 int(*kernel_entry)(void);
59 led_init();
60 clear_leds(LED_ALL);
61 /* NB: something in system_init() prevents H-JTAG from downloading */
62 /* system_init(); */
63 kernel_init();
64 /* enable_interrupt(IRQ_FIQ_STATUS); */
65 backlight_init();
66 lcd_init();
67 lcd_setfont(FONT_SYSFIXED);
68 button_init();
69 dma_init();
71 uart_init();
72 uart_init_device(DEBUG_UART_PORT);
74 /* mini2440_test(); */
76 /* Show debug messages if button is pressed */
77 int touch_data;
78 if(button_read_device(&touch_data) & BUTTON_MENU)
79 verbose = true;
81 printf("Rockbox boot loader");
82 printf("Version " RBVERSION);
84 rc = storage_init();
85 if(rc)
87 reset_screen();
88 error(EATA, rc, true);
91 disk_init(IF_MD(0));
92 rc = disk_mount_all();
93 if (rc<=0)
95 error(EDISK,rc, true);
98 printf("Loading firmware");
100 /* Flush out anything pending first */
101 cpucache_invalidate();
103 loadbuffer = (unsigned char*) 0x31000000;
104 buffer_size = (unsigned char*)0x31400000 - loadbuffer;
106 rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
107 if(rc < 0)
108 error(EBOOTFILE, rc, true);
110 printf("Loaded firmware %d\n", rc);
112 /* storage_close(); */
113 system_prepare_fw_start();
115 if (rc == EOK)
117 cpucache_invalidate();
118 kernel_entry = (void*) loadbuffer;
119 rc = kernel_entry();
122 /* end stop - should not get here */
123 led_flash(LED_ALL, LED_NONE);
124 while (1); /* avoid warning */