summaryrefslogtreecommitdiff
path: root/bootloader/mini2440.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/mini2440.c')
-rw-r--r--bootloader/mini2440.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/bootloader/mini2440.c b/bootloader/mini2440.c
new file mode 100644
index 0000000000..c17f386b5b
--- /dev/null
+++ b/bootloader/mini2440.c
@@ -0,0 +1,145 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 *
10 * Copyright (C) 2009 by Bob Cousins, Lyre Project
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
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#if 0
47#include "dma-target.h"
48#include "uart-s3c2440.h"
49#endif
50#include "led-mini2440.h"
51
52/* Show the Rockbox logo - in show_logo.c */
53extern int show_logo(void);
54
55
56int main(void)
57{
58#if 0
59 /* required later */
60 unsigned char* loadbuffer;
61 int buffer_size;
62 int rc;
63 int(*kernel_entry)(void);
64#endif
65 int start, elapsed;
66
67 led_init();
68 clear_leds(LED_ALL);
69 /* NB: something in system_init() prevents H-JTAG from downloading */
70/* system_init(); */
71 kernel_init();
72/* enable_interrupt(IRQ_FIQ_STATUS); */
73 backlight_init();
74 lcd_init();
75 lcd_setfont(FONT_SYSFIXED);
76 button_init();
77#if 0
78 dma_init();
79 uart_init_device(UART_DEBUG);
80#endif
81/* mini2440_test(); */
82
83#if 1
84 show_logo();
85 /* pause here for now */
86 led_flash(LED1|LED4, LED2|LED3);
87#endif
88
89
90#if 0
91 /* TODO */
92
93 /* Show debug messages if button is pressed */
94 if(button_read_device() & BUTTON_MENU)
95 verbose = true;
96
97 printf("Rockbox boot loader");
98 printf("Version %s", APPSVERSION);
99
100 rc = storage_init();
101 if(rc)
102 {
103 reset_screen();
104 error(EATA, rc);
105 }
106
107 disk_init(IF_MD(0));
108 rc = disk_mount_all();
109 if (rc<=0)
110 {
111 error(EDISK,rc);
112 }
113
114 printf("Loading firmware");
115
116 /* Flush out anything pending first */
117 cpucache_invalidate();
118
119 loadbuffer = (unsigned char*) 0x31000000;
120 buffer_size = (unsigned char*)0x31400000 - loadbuffer;
121
122 rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
123 if(rc < 0)
124 error(EBOOTFILE, rc);
125
126 printf("Loaded firmware %d\n", rc);
127
128/* storage_close(); */
129 system_prepare_fw_start();
130
131 if (rc == EOK)
132 {
133 uart_printf ("entering kernel\n");
134 cpucache_invalidate();
135 kernel_entry = (void*) loadbuffer;
136 rc = kernel_entry();
137 }
138
139 uart_printf ("stopping %d\n", rc);
140#endif
141
142 /* end stop - should not get here */
143 led_flash(LED_ALL, LED_NONE);
144 while (1); /* avoid warning */
145}