Add changelog (merge from 3.1 branch)
[kugel-rb.git] / bootloader / ondavx747.c
blob09acbc81668ce541f7fdbfc5f3ea47e0ad530241
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Maurus Cuelenaere
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdio.h>
23 #include <stdarg.h>
24 #include <string.h>
25 #include "config.h"
26 #include "jz4740.h"
27 #include "backlight.h"
28 #include "font.h"
29 #include "lcd.h"
30 #include "ata.h"
31 #include "usb.h"
32 #include "system.h"
33 #include "button.h"
34 #include "timefuncs.h"
35 #include "rtc.h"
36 #include "common.h"
37 #include "mipsregs.h"
38 #include "storage.h"
40 #ifdef ONDA_VX747P
41 #define ONDA_VX747
42 #endif
44 int main(void)
46 kernel_init();
47 lcd_init();
48 font_init();
49 lcd_setfont(FONT_SYSFIXED);
50 button_init();
51 rtc_init();
52 usb_init();
54 backlight_init();
56 #if 0 /* Enable this when multi storage works */
57 storage_init();
58 #else
59 ata_init();
60 #endif
62 int touch, btn;
63 char datetime[30];
64 reset_screen();
65 printf("Rockbox bootloader v0.0001");
66 printf("REG_EMC_SACR0: 0x%x", REG_EMC_SACR0);
67 printf("REG_EMC_SACR1: 0x%x", REG_EMC_SACR1);
68 printf("REG_EMC_SACR2: 0x%x", REG_EMC_SACR2);
69 printf("REG_EMC_SACR3: 0x%x", REG_EMC_SACR3);
70 printf("REG_EMC_SACR4: 0x%x", REG_EMC_SACR4);
71 printf("REG_EMC_DMAR0: 0x%x", REG_EMC_DMAR0);
72 unsigned int cpu_id = read_c0_prid();
73 printf("CPU_ID: 0x%x", cpu_id);
74 printf(" * Company ID: 0x%x", (cpu_id >> 16) & 7);
75 printf(" * Processor ID: 0x%x", (cpu_id >> 8) & 7);
76 printf(" * Revision ID: 0x%x", cpu_id & 7);
77 unsigned int config_data = read_c0_config();
78 printf("C0_CONFIG: 0x%x", config_data);
79 printf(" * Architecture type: 0x%x", (config_data >> 13) & 3);
80 printf(" * Architecture revision: 0x%x", (config_data >> 10) & 7);
81 printf(" * MMU type: 0x%x", (config_data >> 7) & 7);
82 printf("C0_CONFIG1: 0x%x", read_c0_config1());
83 if(read_c0_config1() & (1 << 0)) printf(" * FP available");
84 if(read_c0_config1() & (1 << 1)) printf(" * EJTAG available");
85 if(read_c0_config1() & (1 << 2)) printf(" * MIPS-16 available");
86 if(read_c0_config1() & (1 << 4)) printf(" * Performace counters available");
87 if(read_c0_config1() & (1 << 5)) printf(" * MDMX available");
88 if(read_c0_config1() & (1 << 6)) printf(" * CP2 available");
89 printf("C0_STATUS: 0x%x", read_c0_status());
91 lcd_puts_scroll(0, 25, "This is a very very long scrolling line.... VERY LONG VERY LONG VERY LONG VERY LONG VERY LONG VERY LONG!!!!!");
93 while(1)
95 #ifdef ONDA_VX747
96 #if 1
97 btn = button_get(false);
98 touch = button_get_data();
99 #else /* button_get() has performance issues */
100 btn = button_read_device(&touch);
101 #endif
102 #else
103 btn = button_read_device();
104 #endif /* ONDA_VX747 */
105 #define KNOP(x,y) lcd_set_foreground(LCD_BLACK); \
106 if(btn & x) \
107 lcd_set_foreground(LCD_WHITE); \
108 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(#x), SYSFONT_HEIGHT*y, #x);
109 KNOP(BUTTON_VOL_UP, 0);
110 KNOP(BUTTON_VOL_DOWN, 1);
111 KNOP(BUTTON_MENU, 2);
112 KNOP(BUTTON_POWER, 3);
113 lcd_set_foreground(LCD_WHITE);
114 if(button_hold())
115 printf("BUTTON_HOLD");
116 if(btn & BUTTON_POWER)
117 power_off();
118 #ifdef ONDA_VX747
119 if(btn & BUTTON_TOUCH)
121 lcd_set_foreground(LCD_RGBPACK(touch & 0xFF, (touch >> 8)&0xFF, (touch >> 16)&0xFF));
122 lcd_fillrect((touch>>16)-5, (touch&0xFFFF)-5, 5, 5);
123 lcd_update();
124 lcd_set_foreground(LCD_WHITE);
126 #endif
127 snprintf(datetime, 30, "%02d/%02d/%04d %02d:%02d:%02d", get_time()->tm_mday, get_time()->tm_mon, get_time()->tm_year,
128 get_time()->tm_hour, get_time()->tm_min, get_time()->tm_sec);
129 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT, datetime);
130 snprintf(datetime, 30, "%d", current_tick);
131 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*2, datetime);
132 snprintf(datetime, 30, "X: %03d Y: %03d", touch>>16, touch & 0xFFFF);
133 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*3, datetime);
134 snprintf(datetime, 30, "PIN3: 0x%08x", REG_GPIO_PXPIN(3));
135 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*4, datetime);
136 snprintf(datetime, 30, "PIN2: 0x%08x", REG_GPIO_PXPIN(2));
137 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*5, datetime);
138 snprintf(datetime, 30, "PIN1: 0x%08x", REG_GPIO_PXPIN(1));
139 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*6, datetime);
140 snprintf(datetime, 30, "PIN0: 0x%08x", REG_GPIO_PXPIN(0));
141 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*7, datetime);
142 snprintf(datetime, 30, "BadVAddr: 0x%08x", read_c0_badvaddr());
143 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*8, datetime);
144 snprintf(datetime, 30, "ICSR: 0x%08x", REG_INTC_ISR);
145 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*9, datetime);
146 lcd_update();
147 yield();
150 return 0;