blob: 2bdd1a0f41138732437e853c7b3ab05ee7b182c9 [file] [log] [blame]
Dominik Wenger41c49702009-10-19 18:14:27 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Dominik Wenger5b4938a2009-10-22 17:45:02 +00008 * $Id$
Dominik Wenger41c49702009-10-19 18:14:27 +00009 *
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"
Michael Sevakis4ea4cdf2014-08-08 02:28:11 -040030#include "../kernel-internal.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000031#include "storage.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040032#include "file_internal.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000033#include "disk.h"
34#include "font.h"
35#include "backlight.h"
36#include "button.h"
37#include "panic.h"
38#include "power.h"
39#include "file.h"
40#include "common.h"
Marcin Bukat0b296912012-03-04 15:34:29 +010041#include "rb-loader.h"
42#include "loader_strerror.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000043#include "sd.h"
44#include "backlight-target.h"
45#include "lcd-target.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000046#include "dma-target.h"
47#include "uart-s3c2440.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000048#include "led-mini2440.h"
Rafaël Carré5d236b22010-05-27 09:41:46 +000049#include "version.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000050
Dominik Wenger41c49702009-10-19 18:14:27 +000051
52int main(void)
53{
Dominik Wenger41c49702009-10-19 18:14:27 +000054 unsigned char* loadbuffer;
55 int buffer_size;
56 int rc;
57 int(*kernel_entry)(void);
Dominik Wenger41c49702009-10-19 18:14:27 +000058
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();
Dominik Wenger41c49702009-10-19 18:14:27 +000069 dma_init();
Dominik Wenger90b576f2009-10-26 18:16:58 +000070
71 uart_init();
72 uart_init_device(DEBUG_UART_PORT);
Dominik Wenger41c49702009-10-19 18:14:27 +000073
Dominik Wenger5b4938a2009-10-22 17:45:02 +000074/* mini2440_test(); */
75
Dominik Wenger41c49702009-10-19 18:14:27 +000076 /* Show debug messages if button is pressed */
Dominik Wengerd25baec2009-10-31 16:48:08 +000077 int touch_data;
78 if(button_read_device(&touch_data) & BUTTON_MENU)
Dominik Wenger41c49702009-10-19 18:14:27 +000079 verbose = true;
80
81 printf("Rockbox boot loader");
Michael Sevakis95a4c3a2014-08-28 10:26:45 -040082 printf("Version %s", rbversion);
Dominik Wenger41c49702009-10-19 18:14:27 +000083
84 rc = storage_init();
85 if(rc)
86 {
87 reset_screen();
Rafaël Carré1ec82122010-06-23 05:08:36 +000088 error(EATA, rc, true);
Dominik Wenger41c49702009-10-19 18:14:27 +000089 }
90
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040091 filesystem_init();
Dominik Wenger41c49702009-10-19 18:14:27 +000092 rc = disk_mount_all();
93 if (rc<=0)
94 {
Rafaël Carré1ec82122010-06-23 05:08:36 +000095 error(EDISK,rc, true);
Dominik Wenger41c49702009-10-19 18:14:27 +000096 }
97
98 printf("Loading firmware");
99
100 /* Flush out anything pending first */
Marcin Bukat0b296912012-03-04 15:34:29 +0100101 commit_discard_idcache();
Dominik Wenger41c49702009-10-19 18:14:27 +0000102
103 loadbuffer = (unsigned char*) 0x31000000;
104 buffer_size = (unsigned char*)0x31400000 - loadbuffer;
105
106 rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
Marcin Bukat0b296912012-03-04 15:34:29 +0100107 if(rc <= 0)
Rafaël Carré1ec82122010-06-23 05:08:36 +0000108 error(EBOOTFILE, rc, true);
Marcin Bukat0b296912012-03-04 15:34:29 +0100109
Dominik Wenger41c49702009-10-19 18:14:27 +0000110 printf("Loaded firmware %d\n", rc);
111
112/* storage_close(); */
113 system_prepare_fw_start();
114
Marcin Bukat0b296912012-03-04 15:34:29 +0100115 commit_discard_idcache();
116 kernel_entry = (void*) loadbuffer;
117 rc = kernel_entry();
Dominik Wenger41c49702009-10-19 18:14:27 +0000118
Dominik Wenger41c49702009-10-19 18:14:27 +0000119 /* end stop - should not get here */
120 led_flash(LED_ALL, LED_NONE);
121 while (1); /* avoid warning */
122}