Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Dominik Wenger | 5b4938a | 2009-10-22 17:45:02 +0000 | [diff] [blame] | 8 | * $Id$ |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 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" |
Michael Sevakis | 4ea4cdf | 2014-08-08 02:28:11 -0400 | [diff] [blame] | 30 | #include "../kernel-internal.h" |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 31 | #include "storage.h" |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 32 | #include "file_internal.h" |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 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" |
Marcin Bukat | 0b29691 | 2012-03-04 15:34:29 +0100 | [diff] [blame] | 42 | #include "rb-loader.h" |
| 43 | #include "loader_strerror.h" |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 44 | #include "sd.h" |
| 45 | #include "backlight-target.h" |
| 46 | #include "lcd-target.h" |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 47 | #include "dma-target.h" |
| 48 | #include "uart-s3c2440.h" |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 49 | #include "led-mini2440.h" |
Rafaël Carré | 5d236b2 | 2010-05-27 09:41:46 +0000 | [diff] [blame] | 50 | #include "version.h" |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 51 | |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 52 | |
| 53 | int main(void) |
| 54 | { |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 55 | unsigned char* loadbuffer; |
| 56 | int buffer_size; |
| 57 | int rc; |
| 58 | int(*kernel_entry)(void); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 59 | |
| 60 | led_init(); |
| 61 | clear_leds(LED_ALL); |
| 62 | /* NB: something in system_init() prevents H-JTAG from downloading */ |
| 63 | /* system_init(); */ |
| 64 | kernel_init(); |
| 65 | /* enable_interrupt(IRQ_FIQ_STATUS); */ |
| 66 | backlight_init(); |
| 67 | lcd_init(); |
| 68 | lcd_setfont(FONT_SYSFIXED); |
| 69 | button_init(); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 70 | dma_init(); |
Dominik Wenger | 90b576f | 2009-10-26 18:16:58 +0000 | [diff] [blame] | 71 | |
| 72 | uart_init(); |
| 73 | uart_init_device(DEBUG_UART_PORT); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 74 | |
Dominik Wenger | 5b4938a | 2009-10-22 17:45:02 +0000 | [diff] [blame] | 75 | /* mini2440_test(); */ |
| 76 | |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 77 | /* Show debug messages if button is pressed */ |
Dominik Wenger | d25baec | 2009-10-31 16:48:08 +0000 | [diff] [blame] | 78 | int touch_data; |
| 79 | if(button_read_device(&touch_data) & BUTTON_MENU) |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 80 | verbose = true; |
| 81 | |
| 82 | printf("Rockbox boot loader"); |
Michael Sevakis | 95a4c3a | 2014-08-28 10:26:45 -0400 | [diff] [blame] | 83 | printf("Version %s", rbversion); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 84 | |
| 85 | rc = storage_init(); |
| 86 | if(rc) |
| 87 | { |
| 88 | reset_screen(); |
Rafaël Carré | 1ec8212 | 2010-06-23 05:08:36 +0000 | [diff] [blame] | 89 | error(EATA, rc, true); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 92 | filesystem_init(); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 93 | rc = disk_mount_all(); |
| 94 | if (rc<=0) |
| 95 | { |
Rafaël Carré | 1ec8212 | 2010-06-23 05:08:36 +0000 | [diff] [blame] | 96 | error(EDISK,rc, true); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | printf("Loading firmware"); |
| 100 | |
| 101 | /* Flush out anything pending first */ |
Marcin Bukat | 0b29691 | 2012-03-04 15:34:29 +0100 | [diff] [blame] | 102 | commit_discard_idcache(); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 103 | |
| 104 | loadbuffer = (unsigned char*) 0x31000000; |
| 105 | buffer_size = (unsigned char*)0x31400000 - loadbuffer; |
| 106 | |
| 107 | rc = load_firmware(loadbuffer, BOOTFILE, buffer_size); |
Marcin Bukat | 0b29691 | 2012-03-04 15:34:29 +0100 | [diff] [blame] | 108 | if(rc <= 0) |
Rafaël Carré | 1ec8212 | 2010-06-23 05:08:36 +0000 | [diff] [blame] | 109 | error(EBOOTFILE, rc, true); |
Marcin Bukat | 0b29691 | 2012-03-04 15:34:29 +0100 | [diff] [blame] | 110 | |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 111 | printf("Loaded firmware %d\n", rc); |
| 112 | |
| 113 | /* storage_close(); */ |
| 114 | system_prepare_fw_start(); |
| 115 | |
Marcin Bukat | 0b29691 | 2012-03-04 15:34:29 +0100 | [diff] [blame] | 116 | commit_discard_idcache(); |
| 117 | kernel_entry = (void*) loadbuffer; |
| 118 | rc = kernel_entry(); |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 119 | |
Dominik Wenger | 41c4970 | 2009-10-19 18:14:27 +0000 | [diff] [blame] | 120 | /* end stop - should not get here */ |
| 121 | led_flash(LED_ALL, LED_NONE); |
| 122 | while (1); /* avoid warning */ |
| 123 | } |