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