summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c26
-rw-r--r--apps/main.c32
2 files changed, 58 insertions, 0 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 6df8f2f534..91746d2e58 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -193,6 +193,7 @@ bool dbg_mpeg_thread(void)
193/* Tool function to calculate a CRC16 across some buffer */ 193/* Tool function to calculate a CRC16 across some buffer */
194unsigned short crc_16(unsigned char* buf, unsigned len) 194unsigned short crc_16(unsigned char* buf, unsigned len)
195{ 195{
196 /* CCITT standard polynomial 0x1021 */
196 static const unsigned short crc16_lookup[16] = 197 static const unsigned short crc16_lookup[16] =
197 { /* lookup table for 4 bits at a time is affordable */ 198 { /* lookup table for 4 bits at a time is affordable */
198 0x0000, 0x1021, 0x2042, 0x3063, 199 0x0000, 0x1021, 0x2042, 0x3063,
@@ -1324,6 +1325,30 @@ bool dbg_save_roms(void)
1324 return false; 1325 return false;
1325} 1326}
1326 1327
1328
1329/* test code, to be removed later */
1330extern union /* defined in main.c */
1331{
1332 unsigned char port8 [512];
1333 unsigned short port16[256];
1334 unsigned port32[128];
1335} startup_io;
1336
1337bool dbg_save_io(void) /* dump the initial I/O space to disk */
1338{
1339 int fd;
1340
1341 fd = creat("/startup_io.bin", O_WRONLY);
1342 if(fd >= 0)
1343 {
1344 write(fd, (void *)&startup_io, sizeof(startup_io));
1345 close(fd);
1346 }
1347
1348 return false;
1349}
1350/* end of test code */
1351
1327bool debug_menu(void) 1352bool debug_menu(void)
1328{ 1353{
1329 int m; 1354 int m;
@@ -1331,6 +1356,7 @@ bool debug_menu(void)
1331 1356
1332 struct menu_items items[] = { 1357 struct menu_items items[] = {
1333 { "Dump ROM contents", dbg_save_roms }, 1358 { "Dump ROM contents", dbg_save_roms },
1359 { "Dump startup I/O", dbg_save_io },
1334 { "View I/O ports", dbg_ports }, 1360 { "View I/O ports", dbg_ports },
1335#ifdef HAVE_LCD_BITMAP 1361#ifdef HAVE_LCD_BITMAP
1336#ifdef HAVE_RTC 1362#ifdef HAVE_RTC
diff --git a/apps/main.c b/apps/main.c
index e10f9ed5f1..4d329bb658 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -54,6 +54,16 @@
54#include "screens.h" 54#include "screens.h"
55#include "power.h" 55#include "power.h"
56 56
57/* diagnostic, to be removed later: */
58/* snapshot of the I/O space on startup, to compare initialisations */
59union
60{
61 unsigned char port8 [512];
62 unsigned short port16[256];
63 unsigned port32[128];
64} startup_io;
65
66
57char appsversion[]=APPSVERSION; 67char appsversion[]=APPSVERSION;
58 68
59void init(void); 69void init(void);
@@ -225,6 +235,28 @@ void init(void)
225 235
226int main(void) 236int main(void)
227{ 237{
238 /* diagnostic, to be removed later: dump I/O space */
239 int i;
240 for (i = 0; i < 512; i++)
241 { // most can be read with 8 bit access
242 startup_io.port8[i] = *((volatile unsigned char*)0x5FFFE00 + i);
243 }
244 // some don't allow that, read with 32 bit if aligned
245 startup_io.port32[0x140/4] = *((volatile unsigned char*)0x5FFFF40);
246 startup_io.port32[0x144/4] = *((volatile unsigned char*)0x5FFFF44);
247 startup_io.port32[0x150/4] = *((volatile unsigned char*)0x5FFFF50);
248 startup_io.port32[0x154/4] = *((volatile unsigned char*)0x5FFFF54);
249 startup_io.port32[0x160/4] = *((volatile unsigned char*)0x5FFFF60);
250 startup_io.port32[0x170/4] = *((volatile unsigned char*)0x5FFFF70);
251 startup_io.port32[0x174/4] = *((volatile unsigned char*)0x5FFFF74);
252
253 // read the rest with 16 bit
254 startup_io.port16[0x14A/2] = *((volatile unsigned short*)0x5FFFF4A);
255 startup_io.port16[0x15A/2] = *((volatile unsigned short*)0x5FFFF5A);
256 startup_io.port16[0x16A/2] = *((volatile unsigned short*)0x5FFFF6A);
257 startup_io.port16[0x17A/2] = *((volatile unsigned short*)0x5FFFF7A);
258 /* end of diagnostic */
259
228 app_main(); 260 app_main();
229 261
230 while(1) { 262 while(1) {