Dave Chapman | 657dcb5 | 2006-08-31 19:19:35 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2006 by Dave Chapman |
| 11 | * |
| 12 | * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing |
| 13 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * as published by the Free Software Foundation; either version 2 |
| 17 | * of the License, or (at your option) any later version. |
Dave Chapman | 657dcb5 | 2006-08-31 19:19:35 +0000 | [diff] [blame] | 18 | * |
| 19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 20 | * KIND, either express or implied. |
| 21 | * |
| 22 | ****************************************************************************/ |
| 23 | #include "config.h" |
| 24 | |
| 25 | #include <stdlib.h> |
| 26 | #include <stdio.h> |
| 27 | #include <string.h> |
| 28 | #include "cpu.h" |
| 29 | #include "system.h" |
| 30 | #include "lcd.h" |
| 31 | #include "kernel.h" |
| 32 | #include "thread.h" |
| 33 | #include "ata.h" |
| 34 | #include "fat.h" |
| 35 | #include "disk.h" |
| 36 | #include "font.h" |
| 37 | #include "adc.h" |
| 38 | #include "backlight.h" |
| 39 | #include "panic.h" |
| 40 | #include "power.h" |
| 41 | #include "file.h" |
Linus Nielsen Feltzing | 46597c9 | 2007-02-22 15:09:49 +0000 | [diff] [blame] | 42 | #include "common.h" |
Dave Chapman | 657dcb5 | 2006-08-31 19:19:35 +0000 | [diff] [blame] | 43 | |
| 44 | char version[] = APPSVERSION; |
| 45 | |
Dave Chapman | 657dcb5 | 2006-08-31 19:19:35 +0000 | [diff] [blame] | 46 | void* main(void) |
| 47 | { |
| 48 | int i; |
| 49 | int rc; |
| 50 | int fd; |
| 51 | char buffer[80]; |
| 52 | unsigned char* framebuffer = (unsigned char*)0x11e00000; |
| 53 | |
| 54 | #if 0 |
| 55 | lcd_init(); |
| 56 | font_init(); |
| 57 | |
Linus Nielsen Feltzing | 46597c9 | 2007-02-22 15:09:49 +0000 | [diff] [blame] | 58 | printf("Hello World!"); |
Dave Chapman | 657dcb5 | 2006-08-31 19:19:35 +0000 | [diff] [blame] | 59 | #endif |
| 60 | |
| 61 | i=ata_init(); |
| 62 | |
| 63 | disk_init(); |
| 64 | rc = disk_mount_all(); |
| 65 | |
| 66 | #if 0 |
| 67 | /* Dump the flash */ |
| 68 | fd=open("/flash.bin",O_CREAT|O_RDWR); |
| 69 | write(fd,(char*)0,1024*1024); |
| 70 | close(fd); |
| 71 | #endif |
| 72 | |
| 73 | #if 1 |
| 74 | /* Dump what may be the framebuffer */ |
| 75 | fd=open("/framebuffer.bin",O_CREAT|O_RDWR|O_TRUNC); |
| 76 | write(fd,framebuffer,220*176*4); |
| 77 | close(fd); |
| 78 | #endif |
| 79 | |
| 80 | |
| 81 | fd=open("/gpio.txt",O_CREAT|O_RDWR|O_TRUNC); |
| 82 | unsigned int gpio_a = GPIOA_INPUT_VAL; |
| 83 | unsigned int gpio_b = GPIOB_INPUT_VAL; |
| 84 | unsigned int gpio_c = GPIOC_INPUT_VAL; |
| 85 | unsigned int gpio_d = GPIOD_INPUT_VAL; |
| 86 | unsigned int gpio_e = GPIOE_INPUT_VAL; |
| 87 | unsigned int gpio_f = GPIOF_INPUT_VAL; |
| 88 | unsigned int gpio_g = GPIOG_INPUT_VAL; |
| 89 | unsigned int gpio_h = GPIOH_INPUT_VAL; |
| 90 | unsigned int gpio_i = GPIOI_INPUT_VAL; |
| 91 | unsigned int gpio_j = GPIOJ_INPUT_VAL; |
| 92 | unsigned int gpio_k = GPIOK_INPUT_VAL; |
| 93 | unsigned int gpio_l = GPIOL_INPUT_VAL; |
| 94 | |
| 95 | snprintf(buffer, sizeof(buffer), "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",gpio_a,gpio_b,gpio_c,gpio_d,gpio_e,gpio_f,gpio_g,gpio_h,gpio_i,gpio_j,gpio_k,gpio_l); |
| 96 | write(fd,buffer,strlen(buffer)+1); |
| 97 | close(fd); |
| 98 | |
| 99 | /* Wait for FFWD button to be pressed */ |
| 100 | while((GPIOA_INPUT_VAL & 0x04) != 0); |
| 101 | |
| 102 | |
| 103 | /* Now reboot */ |
| 104 | DEV_RS |= 0x4; |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | /* These functions are present in the firmware library, but we reimplement |
| 110 | them here because the originals do a lot more than we want */ |
Dave Chapman | 657dcb5 | 2006-08-31 19:19:35 +0000 | [diff] [blame] | 111 | void usb_acknowledge(void) |
| 112 | { |
| 113 | } |
| 114 | |
| 115 | void usb_wait_for_disconnect(void) |
| 116 | { |
| 117 | } |