Oops
[Rockbox.git] / apps / debug_menu.c
blob70fc3ac46e897086da0604b9598ee8aaa2bbca84
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Heikki Hannikainen
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include <stdio.h>
22 #include <stdbool.h>
23 #include <string.h>
24 #include "lcd.h"
25 #include "menu.h"
26 #include "debug_menu.h"
27 #include "kernel.h"
28 #include "sprintf.h"
29 #include "action.h"
30 #include "debug.h"
31 #include "thread.h"
32 #include "powermgmt.h"
33 #include "system.h"
34 #include "font.h"
35 #include "audio.h"
36 #include "mp3_playback.h"
37 #include "settings.h"
38 #include "dir.h"
39 #include "panic.h"
40 #include "screens.h"
41 #include "misc.h"
42 #include "splash.h"
43 #include "dircache.h"
44 #include "tagcache.h"
45 #include "lcd-remote.h"
46 #include "crc32.h"
47 #include "logf.h"
48 #ifndef SIMULATOR
49 #include "disk.h"
50 #include "adc.h"
51 #include "power.h"
52 #include "usb.h"
53 #include "rtc.h"
54 #include "ata.h"
55 #include "fat.h"
56 #include "mas.h"
57 #include "eeprom_24cxx.h"
58 #ifdef HAVE_MMC
59 #include "ata_mmc.h"
60 #endif
61 #ifdef CONFIG_TUNER
62 #include "tuner.h"
63 #include "radio.h"
64 #endif
65 #endif
67 #ifdef HAVE_LCD_BITMAP
68 #include "widgets.h"
69 #include "peakmeter.h"
70 #endif
71 #include "logfdisp.h"
72 #if CONFIG_CODEC == SWCODEC
73 #include "pcmbuf.h"
74 #include "pcm_playback.h"
75 #endif
77 /*---------------------------------------------------*/
78 /* SPECIAL DEBUG STUFF */
79 /*---------------------------------------------------*/
80 extern char ata_device;
81 extern int ata_io_address;
82 extern struct core_entry cores[NUM_CORES];
84 char thread_status_char(int status)
86 switch (status)
88 case STATE_RUNNING : return 'R';
89 case STATE_BLOCKED : return 'B';
90 case STATE_SLEEPING : return 'S';
91 case STATE_BLOCKED_W_TMO: return 'T';
94 return '?';
96 #ifndef SIMULATOR
97 #ifdef HAVE_LCD_BITMAP
98 /* Test code!!! */
99 bool dbg_os(void)
101 struct thread_entry *thread;
102 char buf[32];
103 int i;
104 int usage;
105 int status;
106 #if NUM_CORES > 1
107 unsigned int core;
108 int line;
109 #endif
111 lcd_setmargins(0, 0);
112 lcd_setfont(FONT_SYSFIXED);
113 lcd_clear_display();
115 while(1)
117 #if 0 /* Enable to simulate UI lag. */
118 int _x;
119 for (_x = 0; _x < 1000000L; _x++) ;
120 #endif
121 #if NUM_CORES > 1
122 lcd_puts(0, 0, "Core and stack usage:");
123 line = 0;
124 for(core = 0; core < NUM_CORES; core++)
126 for(i = 0; i < MAXTHREADS; i++)
128 thread = &cores[core].threads[i];
129 if (thread->name == NULL)
130 continue;
132 usage = thread_stack_usage(thread);
133 status = thread_get_status(thread);
135 snprintf(buf, 32, "(%d) %c%c %d %s: %d%%", core,
136 (status == STATE_RUNNING) ? '*' : ' ',
137 thread_status_char(status),
138 cores[CURRENT_CORE].threads[i].priority,
139 cores[core].threads[i].name, usage);
140 lcd_puts(0, ++line, buf);
143 #else
144 lcd_puts(0, 0, "Stack usage:");
145 for(i = 0; i < MAXTHREADS; i++)
147 thread = &cores[CURRENT_CORE].threads[i];
148 if (thread->name == NULL)
149 continue;
151 usage = thread_stack_usage(thread);
152 status = thread_get_status(thread);
153 # ifdef HAVE_PRIORITY_SCHEDULING
154 snprintf(buf, 32, "%c%c %d %s: %d%%",
155 (status == STATE_RUNNING) ? '*' : ' ',
156 thread_status_char(status),
157 cores[CURRENT_CORE].threads[i].priority,
158 cores[CURRENT_CORE].threads[i].name, usage);
159 # else
160 snprintf(buf, 32, "%c%c %s: %d%%",
161 (status == STATE_RUNNING) ? '*' : ' ',
162 (status == STATE_BLOCKED) ? 'B' : ' ',
163 cores[CURRENT_CORE].threads[i].name, usage);
164 # endif
165 lcd_puts(0, 1+i, buf);
167 #endif
169 lcd_update();
171 if (action_userabort(HZ/10))
172 return false;
174 return false;
176 #else /* !HAVE_LCD_BITMAP */
177 bool dbg_os(void)
179 char buf[32];
180 int button;
181 int usage;
182 int currval = 0;
184 lcd_clear_display();
186 while(1)
188 lcd_puts(0, 0, "Stack usage");
190 /* Only Archos Player uses this - so assume a single core */
191 usage = thread_stack_usage(&cores[CPU].threads[currval]);
192 snprintf(buf, 32, "%d: %d%% ", currval, usage);
193 lcd_puts(0, 1, buf);
195 button = get_action(CONTEXT_SETTINGS,HZ/10);
197 switch(button)
199 case ACTION_STD_CANCEL:
200 action_signalscreenchange();
201 return false;
203 case ACTION_SETTINGS_DEC:
204 currval--;
205 if(currval < 0)
206 currval = MAXTHREADS-1;
207 break;
209 case ACTION_SETTINGS_INC:
210 currval++;
211 if(currval > MAXTHREADS-1)
212 currval = 0;
213 break;
216 return false;
218 #endif /* !HAVE_LCD_BITMAP */
219 #endif /* !SIMULATOR */
220 #ifdef HAVE_LCD_BITMAP
221 #if CONFIG_CODEC != SWCODEC
222 #ifndef SIMULATOR
223 bool dbg_audio_thread(void)
225 char buf[32];
226 struct audio_debug d;
228 lcd_setmargins(0, 0);
229 lcd_setfont(FONT_SYSFIXED);
231 while(1)
233 if (action_userabort(HZ/5))
234 return false;
236 audio_get_debugdata(&d);
238 lcd_clear_display();
240 snprintf(buf, sizeof(buf), "read: %x", d.audiobuf_read);
241 lcd_puts(0, 0, buf);
242 snprintf(buf, sizeof(buf), "write: %x", d.audiobuf_write);
243 lcd_puts(0, 1, buf);
244 snprintf(buf, sizeof(buf), "swap: %x", d.audiobuf_swapwrite);
245 lcd_puts(0, 2, buf);
246 snprintf(buf, sizeof(buf), "playing: %d", d.playing);
247 lcd_puts(0, 3, buf);
248 snprintf(buf, sizeof(buf), "playable: %x", d.playable_space);
249 lcd_puts(0, 4, buf);
250 snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space);
251 lcd_puts(0, 5, buf);
253 /* Playable space left */
254 scrollbar(0, 6*8, 112, 4, d.audiobuflen, 0,
255 d.playable_space, HORIZONTAL);
257 /* Show the watermark limit */
258 scrollbar(0, 6*8+4, 112, 4, d.audiobuflen, 0,
259 d.low_watermark_level, HORIZONTAL);
261 snprintf(buf, sizeof(buf), "wm: %x - %x",
262 d.low_watermark_level, d.lowest_watermark_level);
263 lcd_puts(0, 7, buf);
265 lcd_update();
267 return false;
269 #endif /* !SIMULATOR */
270 #else /* CONFIG_CODEC == SWCODEC */
271 extern size_t filebuflen;
272 /* This is a size_t, but call it a long so it puts a - when it's bad. */
273 extern long filebufused;
275 static unsigned int ticks, boost_ticks;
277 void dbg_audio_task(void)
279 #ifndef SIMULATOR
280 if(FREQ > CPUFREQ_NORMAL)
281 boost_ticks++;
282 #endif
284 ticks++;
287 bool dbg_audio_thread(void)
289 char buf[32];
290 int button;
291 int line;
292 bool done = false;
293 size_t bufused;
294 size_t bufsize = pcmbuf_get_bufsize();
295 int pcmbufdescs = pcmbuf_descs();
297 ticks = boost_ticks = 0;
299 tick_add_task(dbg_audio_task);
301 lcd_setmargins(0, 0);
302 lcd_setfont(FONT_SYSFIXED);
303 while(!done)
305 button = get_action(CONTEXT_STD,HZ/5);
306 switch(button)
308 case ACTION_STD_NEXT:
309 audio_next();
310 break;
311 case ACTION_STD_PREV:
312 audio_prev();
313 break;
314 case ACTION_STD_CANCEL:
315 done = true;
316 break;
318 action_signalscreenchange();
319 line = 0;
321 lcd_clear_display();
323 bufused = bufsize - pcmbuf_free();
325 snprintf(buf, sizeof(buf), "pcm: %7ld/%7ld", (long) bufused, (long) bufsize);
326 lcd_puts(0, line++, buf);
328 /* Playable space left */
329 scrollbar(0, line*8, LCD_WIDTH, 6, bufsize, 0, bufused, HORIZONTAL);
330 line++;
332 snprintf(buf, sizeof(buf), "codec: %8ld/%8ld", filebufused, (long) filebuflen);
333 lcd_puts(0, line++, buf);
335 /* Playable space left */
336 scrollbar(0, line*8, LCD_WIDTH, 6, filebuflen, 0,
337 filebufused, HORIZONTAL);
338 line++;
340 snprintf(buf, sizeof(buf), "track count: %2d", audio_track_count());
341 lcd_puts(0, line++, buf);
343 #ifndef SIMULATOR
344 snprintf(buf, sizeof(buf), "cpu freq: %3dMHz",
345 (int)((FREQ + 500000) / 1000000));
346 lcd_puts(0, line++, buf);
347 #endif
349 snprintf(buf, sizeof(buf), "boost ratio: %3d%%",
350 boost_ticks * 100 / ticks);
351 lcd_puts(0, line++, buf);
353 snprintf(buf, sizeof(buf), "pcmbufdesc: %2d/%2d",
354 pcmbuf_used_descs(), pcmbufdescs);
355 lcd_puts(0, line++, buf);
357 lcd_update();
360 tick_remove_task(dbg_audio_task);
362 return false;
364 #endif /* CONFIG_CODEC */
365 #endif /* HAVE_LCD_BITMAP */
368 #if CONFIG_CPU == TCC730
369 static unsigned flash_word_temp __attribute__ ((section (".idata")));
371 static void flash_write_word(unsigned addr, unsigned value) __attribute__ ((section(".icode")));
372 static void flash_write_word(unsigned addr, unsigned value) {
373 flash_word_temp = value;
375 long extAddr = (long)addr << 1;
376 ddma_transfer(1, 1, &flash_word_temp, extAddr, 2);
379 static unsigned flash_read_word(unsigned addr) __attribute__ ((section(".icode")));
380 static unsigned flash_read_word(unsigned addr) {
381 long extAddr = (long)addr << 1;
382 ddma_transfer(1, 1, &flash_word_temp, extAddr, 2);
383 return flash_word_temp;
386 #endif
388 /* Tool function to read the flash manufacturer and type, if available.
389 Only chips which could be reprogrammed in system will return values.
390 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
391 /* In IRAM to avoid problems when running directly from Flash */
392 bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
393 unsigned addr1, unsigned addr2)
394 __attribute__ ((section (".icode")));
395 bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
396 unsigned addr1, unsigned addr2)
399 #ifndef SIMULATOR
400 #if (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
401 /* TODO: Implement for iPod */
402 (void)p_manufacturer;
403 (void)p_device;
404 (void)addr1;
405 (void)addr2;
406 #elif CONFIG_CPU == PNX0101
407 /* TODO: Implement for iFP7xx */
408 (void)p_manufacturer;
409 (void)p_device;
410 (void)addr1;
411 (void)addr2;
412 #elif CONFIG_CPU == S3C2440
413 /* TODO: Implement for Gigabeat */
414 (void)p_manufacturer;
415 (void)p_device;
416 (void)addr1;
417 (void)addr2;
418 #else
419 unsigned not_manu, not_id; /* read values before switching to ID mode */
420 unsigned manu, id; /* read values when in ID mode */
421 #if CONFIG_CPU == TCC730
422 #define FLASH(addr) (flash_read_word(addr))
423 #define SET_FLASH(addr, val) (flash_write_word((addr), (val)))
425 #else /* memory mapped */
426 #if CONFIG_CPU == SH7034
427 volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */
428 #elif defined(CPU_COLDFIRE)
429 volatile unsigned short* flash = (unsigned short*)0; /* flash mapping */
430 #endif
431 #define FLASH(addr) (flash[addr])
432 #define SET_FLASH(addr, val) (flash[addr] = val)
433 #endif
434 int old_level; /* saved interrupt level */
436 not_manu = FLASH(0); /* read the normal content */
437 not_id = FLASH(1); /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
439 /* disable interrupts, prevent any stray flash access */
440 old_level = set_irq_level(HIGHEST_IRQ_LEVEL);
442 SET_FLASH(addr1, 0xAA); /* enter command mode */
443 SET_FLASH(addr2, 0x55);
444 SET_FLASH(addr1, 0x90); /* ID command */
445 /* Atmel wants 20ms pause here */
446 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
448 manu = FLASH(0); /* read the IDs */
449 id = FLASH(1);
451 SET_FLASH(0, 0xF0); /* reset flash (back to normal read mode) */
452 /* Atmel wants 20ms pause here */
453 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
455 set_irq_level(old_level); /* enable interrupts again */
457 /* I assume success if the obtained values are different from
458 the normal flash content. This is not perfectly bulletproof, they
459 could theoretically be the same by chance, causing us to fail. */
460 if (not_manu != manu || not_id != id) /* a value has changed */
462 *p_manufacturer = manu; /* return the results */
463 *p_device = id;
464 return true; /* success */
466 #endif
467 #else
468 (void) p_manufacturer;
469 (void) p_device;
470 (void) addr1;
471 (void) addr2;
472 #endif
473 return false; /* fail */
476 #ifndef SIMULATOR
477 #ifdef HAVE_LCD_BITMAP
478 bool dbg_hw_info(void)
480 #if CONFIG_CPU == SH7034
481 char buf[32];
482 int usb_polarity;
483 int pr_polarity;
484 int bitmask = *(unsigned short*)0x20000fc;
485 int rom_version = *(unsigned short*)0x20000fe;
486 unsigned manu, id; /* flash IDs */
487 bool got_id; /* flag if we managed to get the flash IDs */
488 unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */
489 bool has_bootrom; /* flag for boot ROM present */
490 int oldmode; /* saved memory guard mode */
492 #ifdef USB_ENABLE_ONDIOSTYLE
493 if(PADRL & 0x20)
494 #else
495 if(PADRH & 0x04)
496 #endif
497 usb_polarity = 0; /* Negative */
498 else
499 usb_polarity = 1; /* Positive */
501 if(PADRH & 0x08)
502 pr_polarity = 0; /* Negative */
503 else
504 pr_polarity = 1; /* Positive */
506 oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
508 /* get flash ROM type */
509 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
510 if (!got_id)
511 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
513 /* check if the boot ROM area is a flash mirror */
514 has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
515 if (has_bootrom) /* if ROM and Flash different */
517 /* calculate CRC16 checksum of boot ROM */
518 rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
521 system_memory_guard(oldmode); /* re-enable memory guard */
523 lcd_setmargins(0, 0);
524 lcd_setfont(FONT_SYSFIXED);
525 lcd_clear_display();
527 lcd_puts(0, 0, "[Hardware info]");
529 snprintf(buf, 32, "ROM: %d.%02d", rom_version/100, rom_version%100);
530 lcd_puts(0, 1, buf);
532 snprintf(buf, 32, "Mask: 0x%04x", bitmask);
533 lcd_puts(0, 2, buf);
535 snprintf(buf, 32, "USB: %s", usb_polarity?"positive":"negative");
536 lcd_puts(0, 3, buf);
538 snprintf(buf, 32, "PR: %s", pr_polarity?"positive":"negative");
539 lcd_puts(0, 4, buf);
541 if (got_id)
542 snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id);
543 else
544 snprintf(buf, 32, "Flash: M=?? D=??"); /* unknown, sorry */
545 lcd_puts(0, 5, buf);
547 if (has_bootrom)
549 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
550 snprintf(buf, 32, "Boot ROM: V1");
551 else
552 snprintf(buf, 32, "ROMcrc: 0x%08x", rom_crc);
554 else
556 snprintf(buf, 32, "Boot ROM: none");
558 lcd_puts(0, 6, buf);
560 #ifndef HAVE_MMC /* have ATA */
561 snprintf(buf, 32, "ATA: 0x%x,%s", ata_io_address,
562 ata_device ? "slave":"master");
563 lcd_puts(0, 7, buf);
564 #endif
565 lcd_update();
567 while(1)
569 if (action_userabort(TIMEOUT_BLOCK))
570 return false;
572 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
573 char buf[32];
574 unsigned manu, id; /* flash IDs */
575 bool got_id; /* flag if we managed to get the flash IDs */
576 int oldmode; /* saved memory guard mode */
578 oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
580 /* get flash ROM type */
581 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
582 if (!got_id)
583 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
585 system_memory_guard(oldmode); /* re-enable memory guard */
587 lcd_setmargins(0, 0);
588 lcd_setfont(FONT_SYSFIXED);
589 lcd_clear_display();
591 lcd_puts(0, 0, "[Hardware info]");
593 if (got_id)
594 snprintf(buf, 32, "Flash: M=%04x D=%04x", manu, id);
595 else
596 snprintf(buf, 32, "Flash: M=???? D=????"); /* unknown, sorry */
597 lcd_puts(0, 1, buf);
599 lcd_update();
601 while(1)
603 if (action_userabort(TIMEOUT_BLOCK))
604 return false;
606 #elif CONFIG_CPU == PP5020
607 char buf[32];
609 lcd_setmargins(0, 0);
610 lcd_setfont(FONT_SYSFIXED);
611 lcd_clear_display();
613 lcd_puts(0, 0, "[Hardware info]");
615 snprintf(buf, sizeof(buf), "HW rev: 0x%08x", ipod_hw_rev);
616 lcd_puts(0, 1, buf);
618 lcd_update();
620 while(1)
622 if (action_userabort(TIMEOUT_BLOCK))
623 return false;
625 #endif /* CONFIG_CPU */
626 return false;
628 #else /* !HAVE_LCD_BITMAP */
629 bool dbg_hw_info(void)
631 char buf[32];
632 int button;
633 int currval = 0;
634 int usb_polarity;
635 int bitmask = *(unsigned short*)0x20000fc;
636 int rom_version = *(unsigned short*)0x20000fe;
637 unsigned manu, id; /* flash IDs */
638 bool got_id; /* flag if we managed to get the flash IDs */
639 unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */
640 bool has_bootrom; /* flag for boot ROM present */
641 int oldmode; /* saved memory guard mode */
643 if(PADRH & 0x04)
644 usb_polarity = 0; /* Negative */
645 else
646 usb_polarity = 1; /* Positive */
648 oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
650 /* get flash ROM type */
651 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
652 if (!got_id)
653 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
655 /* check if the boot ROM area is a flash mirror */
656 has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
657 if (has_bootrom) /* if ROM and Flash different */
659 /* calculate CRC16 checksum of boot ROM */
660 rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
663 system_memory_guard(oldmode); /* re-enable memory guard */
665 lcd_clear_display();
667 lcd_puts(0, 0, "[HW Info]");
668 while(1)
670 switch(currval)
672 case 0:
673 snprintf(buf, 32, "ROM: %d.%02d",
674 rom_version/100, rom_version%100);
675 break;
676 case 1:
677 snprintf(buf, 32, "USB: %s",
678 usb_polarity?"pos":"neg");
679 break;
680 case 2:
681 snprintf(buf, 32, "ATA: 0x%x%s",
682 ata_io_address, ata_device ? "s":"m");
683 break;
684 case 3:
685 snprintf(buf, 32, "Mask: %04x", bitmask);
686 break;
687 case 4:
688 if (got_id)
689 snprintf(buf, 32, "Flash:%02x,%02x", manu, id);
690 else
691 snprintf(buf, 32, "Flash:??,??"); /* unknown, sorry */
692 break;
693 case 5:
694 if (has_bootrom)
696 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
697 snprintf(buf, 32, "BootROM: V1");
698 else if (rom_crc == 0x358099E8)
699 snprintf(buf, 32, "BootROM: V2");
700 /* alternative boot ROM found in one single player so far */
701 else
702 snprintf(buf, 32, "R: %08x", rom_crc);
704 else
705 snprintf(buf, 32, "BootROM: no");
708 lcd_puts(0, 1, buf);
709 lcd_update();
711 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK);
713 switch(button)
715 case ACTION_STD_CANCEL:
716 action_signalscreenchange();
717 return false;
719 case ACTION_SETTINGS_DEC:
720 currval--;
721 if(currval < 0)
722 currval = 5;
723 break;
725 case ACTION_SETTINGS_INC:
726 currval++;
727 if(currval > 5)
728 currval = 0;
729 break;
732 return false;
734 #endif /* !HAVE_LCD_BITMAP */
735 #endif /* !SIMULATOR */
737 #ifndef SIMULATOR
738 bool dbg_partitions(void)
740 int partition=0;
742 lcd_clear_display();
743 lcd_puts(0, 0, "Partition");
744 lcd_puts(0, 1, "list");
745 lcd_update();
746 sleep(HZ/2);
748 while(1)
750 char buf[32];
751 int button;
752 struct partinfo* p = disk_partinfo(partition);
754 lcd_clear_display();
755 snprintf(buf, sizeof buf, "P%d: S:%lx", partition, p->start);
756 lcd_puts(0, 0, buf);
757 snprintf(buf, sizeof buf, "T:%x %ld MB", p->type, p->size / 2048);
758 lcd_puts(0, 1, buf);
759 lcd_update();
761 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK);
763 switch(button)
765 case ACTION_STD_CANCEL:
766 action_signalscreenchange();
767 return false;
769 case ACTION_SETTINGS_DEC:
770 partition--;
771 if (partition < 0)
772 partition = 3;
773 break;
775 case ACTION_SETTINGS_INC:
776 partition++;
777 if (partition > 3)
778 partition = 0;
779 break;
781 default:
782 if(default_event_handler(button) == SYS_USB_CONNECTED)
783 return true;
784 break;
787 return false;
789 #endif
791 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
792 bool dbg_spdif(void)
794 char buf[128];
795 int line;
796 unsigned int control;
797 int x;
798 char *s;
799 int category;
800 int generation;
801 unsigned int interruptstat;
802 bool valnogood, symbolerr, parityerr;
803 bool done = false;
805 lcd_setmargins(0, 0);
806 lcd_clear_display();
807 lcd_setfont(FONT_SYSFIXED);
808 #ifdef HAVE_SPDIF_POWER
809 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
810 #endif
811 PHASECONFIG = 0x34; /* Gain = 3*2^13, source = EBUIN */
813 while (!done)
815 line = 0;
817 control = EBU1RCVCCHANNEL1;
818 interruptstat = INTERRUPTSTAT;
819 INTERRUPTCLEAR = 0x03c00000;
821 valnogood = (interruptstat & 0x01000000)?true:false;
822 symbolerr = (interruptstat & 0x00800000)?true:false;
823 parityerr = (interruptstat & 0x00400000)?true:false;
825 snprintf(buf, sizeof(buf), "Val: %s Sym: %s Par: %s",
826 valnogood?"--":"OK",
827 symbolerr?"--":"OK",
828 parityerr?"--":"OK");
829 lcd_puts(0, line++, buf);
831 snprintf(buf, sizeof(buf), "Status word: %08x", (int)control);
832 lcd_puts(0, line++, buf);
834 line++;
836 x = control >> 31;
837 snprintf(buf, sizeof(buf), "PRO: %d (%s)",
838 x, x?"Professional":"Consumer");
839 lcd_puts(0, line++, buf);
841 x = (control >> 30) & 1;
842 snprintf(buf, sizeof(buf), "Audio: %d (%s)",
843 x, x?"Non-PCM":"PCM");
844 lcd_puts(0, line++, buf);
846 x = (control >> 29) & 1;
847 snprintf(buf, sizeof(buf), "Copy: %d (%s)",
848 x, x?"Permitted":"Inhibited");
849 lcd_puts(0, line++, buf);
851 x = (control >> 27) & 7;
852 switch(x)
854 case 0:
855 s = "None";
856 break;
857 case 1:
858 s = "50/15us";
859 break;
860 default:
861 s = "Reserved";
862 break;
864 snprintf(buf, sizeof(buf), "Preemphasis: %d (%s)", x, s);
865 lcd_puts(0, line++, buf);
867 x = (control >> 24) & 3;
868 snprintf(buf, sizeof(buf), "Mode: %d", x);
869 lcd_puts(0, line++, buf);
871 category = (control >> 17) & 127;
872 switch(category)
874 case 0x00:
875 s = "General";
876 break;
877 case 0x40:
878 s = "Audio CD";
879 break;
880 default:
881 s = "Unknown";
883 snprintf(buf, sizeof(buf), "Category: 0x%02x (%s)", category, s);
884 lcd_puts(0, line++, buf);
886 x = (control >> 16) & 1;
887 generation = x;
888 if(((category & 0x70) == 0x10) ||
889 ((category & 0x70) == 0x40) ||
890 ((category & 0x78) == 0x38))
892 generation = !generation;
894 snprintf(buf, sizeof(buf), "Generation: %d (%s)",
895 x, generation?"Original":"No ind.");
896 lcd_puts(0, line++, buf);
898 x = (control >> 12) & 15;
899 snprintf(buf, sizeof(buf), "Source: %d", x);
900 lcd_puts(0, line++, buf);
902 x = (control >> 8) & 15;
903 switch(x)
905 case 0:
906 s = "Unspecified";
907 break;
908 case 8:
909 s = "A (Left)";
910 break;
911 case 4:
912 s = "B (Right)";
913 break;
914 default:
915 s = "";
916 break;
918 snprintf(buf, sizeof(buf), "Channel: %d (%s)", x, s);
919 lcd_puts(0, line++, buf);
921 x = (control >> 4) & 15;
922 switch(x)
924 case 0:
925 s = "44.1kHz";
926 break;
927 case 0x4:
928 s = "48kHz";
929 break;
930 case 0xc:
931 s = "32kHz";
932 break;
934 snprintf(buf, sizeof(buf), "Frequency: %d (%s)", x, s);
935 lcd_puts(0, line++, buf);
937 x = (control >> 2) & 3;
938 snprintf(buf, sizeof(buf), "Clock accuracy: %d", x);
939 lcd_puts(0, line++, buf);
940 line++;
942 #ifndef SIMULATOR
943 snprintf(buf, sizeof(buf), "Measured freq: %ldHz",
944 (long)((long long)FREQMEAS*CPU_FREQ/((1 << 15)*3*(1 << 13))/128));
945 lcd_puts(0, line++, buf);
946 #endif
948 lcd_update();
950 if (action_userabort(HZ/10))
951 return false;
953 #ifdef HAVE_SPDIF_POWER
954 spdif_power_enable(global_settings.spdif_enable);
955 #endif
957 return false;
959 #endif /* CPU_COLDFIRE */
961 #ifndef SIMULATOR
962 #ifdef HAVE_LCD_BITMAP
963 /* Test code!!! */
964 bool dbg_ports(void)
966 #if CONFIG_CPU == SH7034
967 unsigned short porta;
968 unsigned short portb;
969 unsigned char portc;
970 char buf[32];
971 int battery_voltage;
972 int batt_int, batt_frac;
974 lcd_setfont(FONT_SYSFIXED);
975 lcd_setmargins(0, 0);
976 lcd_clear_display();
978 while(1)
980 porta = PADR;
981 portb = PBDR;
982 portc = PCDR;
984 snprintf(buf, 32, "PADR: %04x", porta);
985 lcd_puts(0, 0, buf);
986 snprintf(buf, 32, "PBDR: %04x", portb);
987 lcd_puts(0, 1, buf);
989 snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
990 lcd_puts(0, 2, buf);
991 snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
992 lcd_puts(0, 3, buf);
993 snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
994 lcd_puts(0, 4, buf);
995 snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
996 lcd_puts(0, 5, buf);
998 battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
999 batt_int = battery_voltage / 100;
1000 batt_frac = battery_voltage % 100;
1002 snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
1003 battery_level());
1004 lcd_puts(0, 6, buf);
1005 #ifndef HAVE_MMC /* have ATA */
1006 snprintf(buf, 32, "ATA: %s, 0x%x",
1007 ata_device?"slave":"master", ata_io_address);
1008 lcd_puts(0, 7, buf);
1009 #endif
1010 lcd_update();
1011 if (action_userabort(HZ/10))
1012 return false;
1014 #elif defined(CPU_COLDFIRE)
1015 unsigned int gpio_out;
1016 unsigned int gpio1_out;
1017 unsigned int gpio_read;
1018 unsigned int gpio1_read;
1019 unsigned int gpio_function;
1020 unsigned int gpio1_function;
1021 unsigned int gpio_enable;
1022 unsigned int gpio1_enable;
1023 int adc_buttons, adc_remote, adc_battery;
1024 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1025 int adc_remotedetect;
1026 #endif
1027 char buf[128];
1028 int line;
1029 int battery_voltage;
1030 int batt_int, batt_frac;
1032 lcd_setmargins(0, 0);
1033 lcd_clear_display();
1034 lcd_setfont(FONT_SYSFIXED);
1036 while(1)
1038 line = 0;
1039 gpio_read = GPIO_READ;
1040 gpio1_read = GPIO1_READ;
1041 gpio_out = GPIO_OUT;
1042 gpio1_out = GPIO1_OUT;
1043 gpio_function = GPIO_FUNCTION;
1044 gpio1_function = GPIO1_FUNCTION;
1045 gpio_enable = GPIO_ENABLE;
1046 gpio1_enable = GPIO1_ENABLE;
1048 snprintf(buf, sizeof(buf), "GPIO_READ: %08x", gpio_read);
1049 lcd_puts(0, line++, buf);
1050 snprintf(buf, sizeof(buf), "GPIO_OUT: %08x", gpio_out);
1051 lcd_puts(0, line++, buf);
1052 snprintf(buf, sizeof(buf), "GPIO_FUNCTION: %08x", gpio_function);
1053 lcd_puts(0, line++, buf);
1054 snprintf(buf, sizeof(buf), "GPIO_ENABLE: %08x", gpio_enable);
1055 lcd_puts(0, line++, buf);
1057 snprintf(buf, sizeof(buf), "GPIO1_READ: %08x", gpio1_read);
1058 lcd_puts(0, line++, buf);
1059 snprintf(buf, sizeof(buf), "GPIO1_OUT: %08x", gpio1_out);
1060 lcd_puts(0, line++, buf);
1061 snprintf(buf, sizeof(buf), "GPIO1_FUNCTION: %08x", gpio1_function);
1062 lcd_puts(0, line++, buf);
1063 snprintf(buf, sizeof(buf), "GPIO1_ENABLE: %08x", gpio1_enable);
1064 lcd_puts(0, line++, buf);
1066 adc_buttons = adc_read(ADC_BUTTONS);
1067 adc_remote = adc_read(ADC_REMOTE);
1068 adc_battery = adc_read(ADC_BATTERY);
1069 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1070 adc_remotedetect = adc_read(ADC_REMOTEDETECT);
1071 #endif
1073 snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons);
1074 lcd_puts(0, line++, buf);
1075 snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_remote);
1076 lcd_puts(0, line++, buf);
1077 snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery);
1078 lcd_puts(0, line++, buf);
1079 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1080 snprintf(buf, sizeof(buf), "ADC_REMOTEDETECT: %02x", adc_remotedetect);
1081 lcd_puts(0, line++, buf);
1082 #endif
1084 battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000;
1085 batt_int = battery_voltage / 100;
1086 batt_frac = battery_voltage % 100;
1088 snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
1089 battery_level());
1090 lcd_puts(0, line++, buf);
1092 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1093 snprintf(buf, sizeof(buf), "remotetype:: %d", remote_type());
1094 lcd_puts(0, line++, buf);
1095 #endif
1097 lcd_update();
1098 if (action_userabort(HZ/10))
1099 return false;
1102 #elif CONFIG_CPU == PP5020
1104 unsigned int gpio_a, gpio_b, gpio_c, gpio_d;
1105 unsigned int gpio_e, gpio_f, gpio_g, gpio_h;
1106 unsigned int gpio_i, gpio_j, gpio_k, gpio_l;
1108 char buf[128];
1109 int line;
1111 lcd_setmargins(0, 0);
1112 lcd_clear_display();
1113 lcd_setfont(FONT_SYSFIXED);
1115 while(1)
1117 gpio_a = GPIOA_INPUT_VAL;
1118 gpio_b = GPIOB_INPUT_VAL;
1119 gpio_c = GPIOC_INPUT_VAL;
1121 gpio_g = GPIOG_INPUT_VAL;
1122 gpio_h = GPIOH_INPUT_VAL;
1123 gpio_i = GPIOI_INPUT_VAL;
1125 line = 0;
1126 snprintf(buf, sizeof(buf), "GPIO_A: %02x GPIO_G: %02x", gpio_a, gpio_g);
1127 lcd_puts(0, line++, buf);
1128 snprintf(buf, sizeof(buf), "GPIO_B: %02x GPIO_H: %02x", gpio_b, gpio_h);
1129 lcd_puts(0, line++, buf);
1130 snprintf(buf, sizeof(buf), "GPIO_C: %02x GPIO_I: %02x", gpio_c, gpio_i);
1131 lcd_puts(0, line++, buf);
1132 line++;
1134 gpio_d = GPIOD_INPUT_VAL;
1135 gpio_e = GPIOE_INPUT_VAL;
1136 gpio_f = GPIOF_INPUT_VAL;
1138 gpio_j = GPIOJ_INPUT_VAL;
1139 gpio_k = GPIOK_INPUT_VAL;
1140 gpio_l = GPIOL_INPUT_VAL;
1142 snprintf(buf, sizeof(buf), "GPIO_D: %02x GPIO_J: %02x", gpio_d, gpio_j);
1143 lcd_puts(0, line++, buf);
1144 snprintf(buf, sizeof(buf), "GPIO_E: %02x GPIO_K: %02x", gpio_e, gpio_k);
1145 lcd_puts(0, line++, buf);
1146 snprintf(buf, sizeof(buf), "GPIO_F: %02x GPIO_L: %02x", gpio_f, gpio_l);
1147 lcd_puts(0, line++, buf);
1148 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1149 line++;
1150 snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_read(ADC_BATTERY));
1151 lcd_puts(0, line++, buf);
1152 snprintf(buf, sizeof(buf), "ADC_UNKNOWN_1: %02x", adc_read(ADC_UNKNOWN_1));
1153 lcd_puts(0, line++, buf);
1154 snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_read(ADC_REMOTE));
1155 lcd_puts(0, line++, buf);
1156 snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD));
1157 lcd_puts(0, line++, buf);
1158 #endif
1159 lcd_update();
1160 if (action_userabort(HZ/10))
1161 return false;
1164 #endif /* CPU */
1165 return false;
1167 #else /* !HAVE_LCD_BITMAP */
1168 bool dbg_ports(void)
1170 unsigned short porta;
1171 unsigned short portb;
1172 unsigned char portc;
1173 char buf[32];
1174 int button;
1175 int battery_voltage;
1176 int batt_int, batt_frac;
1177 int currval = 0;
1179 lcd_clear_display();
1181 while(1)
1183 porta = PADR;
1184 portb = PBDR;
1185 portc = PCDR;
1187 switch(currval)
1189 case 0:
1190 snprintf(buf, 32, "PADR: %04x ", porta);
1191 break;
1192 case 1:
1193 snprintf(buf, 32, "PBDR: %04x ", portb);
1194 break;
1195 case 2:
1196 snprintf(buf, 32, "AN0: %03x ", adc_read(0));
1197 break;
1198 case 3:
1199 snprintf(buf, 32, "AN1: %03x ", adc_read(1));
1200 break;
1201 case 4:
1202 snprintf(buf, 32, "AN2: %03x ", adc_read(2));
1203 break;
1204 case 5:
1205 snprintf(buf, 32, "AN3: %03x ", adc_read(3));
1206 break;
1207 case 6:
1208 snprintf(buf, 32, "AN4: %03x ", adc_read(4));
1209 break;
1210 case 7:
1211 snprintf(buf, 32, "AN5: %03x ", adc_read(5));
1212 break;
1213 case 8:
1214 snprintf(buf, 32, "AN6: %03x ", adc_read(6));
1215 break;
1216 case 9:
1217 snprintf(buf, 32, "AN7: %03x ", adc_read(7));
1218 break;
1219 case 10:
1220 snprintf(buf, 32, "%s, 0x%x ",
1221 ata_device?"slv":"mst", ata_io_address);
1222 break;
1224 lcd_puts(0, 0, buf);
1226 battery_voltage = (adc_read(ADC_UNREG_POWER) *
1227 BATTERY_SCALE_FACTOR) / 10000;
1228 batt_int = battery_voltage / 100;
1229 batt_frac = battery_voltage % 100;
1231 snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac);
1232 lcd_puts(0, 1, buf);
1234 button = get_action(CONTEXT_SETTINGS,HZ/5);
1236 switch(button)
1238 case ACTION_STD_CANCEL:
1239 action_signalscreenchange();
1240 return false;
1242 case ACTION_SETTINGS_DEC:
1243 currval--;
1244 if(currval < 0)
1245 currval = 10;
1246 break;
1248 case ACTION_SETTINGS_INC:
1249 currval++;
1250 if(currval > 10)
1251 currval = 0;
1252 break;
1255 return false;
1257 #endif /* !HAVE_LCD_BITMAP */
1258 #endif /* !SIMULATOR */
1260 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1261 extern int boost_counter;
1262 bool dbg_cpufreq(void)
1264 char buf[128];
1265 int line;
1266 int button;
1268 #ifdef HAVE_LCD_BITMAP
1269 lcd_setmargins(0, 0);
1270 lcd_setfont(FONT_SYSFIXED);
1271 #endif
1272 lcd_clear_display();
1274 while(1)
1276 line = 0;
1278 snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ);
1279 lcd_puts(0, line++, buf);
1281 snprintf(buf, sizeof(buf), "boost_counter: %d", boost_counter);
1282 lcd_puts(0, line++, buf);
1284 lcd_update();
1285 button = get_action(CONTEXT_STD,HZ/10);
1287 switch(button)
1289 case ACTION_STD_PREV:
1290 cpu_boost(true);
1291 break;
1292 case ACTION_STD_NEXT:
1293 cpu_boost(false);
1294 break;
1296 case ACTION_STD_OK:
1297 set_cpu_frequency(CPUFREQ_DEFAULT);
1298 boost_counter = 0;
1299 break;
1301 case ACTION_STD_CANCEL:
1302 action_signalscreenchange();
1303 return false;
1307 return false;
1309 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1311 #ifndef SIMULATOR
1312 #ifdef HAVE_LCD_BITMAP
1314 * view_battery() shows a automatically scaled graph of the battery voltage
1315 * over time. Usable for estimating battery life / charging rate.
1316 * The power_history array is updated in power_thread of powermgmt.c.
1319 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1320 #define BAT_YSPACE (LCD_HEIGHT - 20)
1322 bool view_battery(void)
1324 int view = 0;
1325 int i, x, y;
1326 unsigned short maxv, minv;
1327 char buf[32];
1329 lcd_setmargins(0, 0);
1330 lcd_setfont(FONT_SYSFIXED);
1332 while(1)
1334 switch (view) {
1335 case 0: /* voltage history graph */
1336 /* Find maximum and minimum voltage for scaling */
1337 maxv = 0;
1338 minv = 65535;
1339 for (i = 0; i < BAT_LAST_VAL; i++) {
1340 if (power_history[i] > maxv)
1341 maxv = power_history[i];
1342 if (power_history[i] && (power_history[i] < minv))
1344 minv = power_history[i];
1348 if ((minv < 1) || (minv >= 65535))
1349 minv = 1;
1350 if (maxv < 2)
1351 maxv = 2;
1352 if (minv == maxv)
1353 maxv < 65535 ? maxv++ : minv--;
1355 lcd_clear_display();
1356 snprintf(buf, 30, "Battery %d.%02d", power_history[0] / 100,
1357 power_history[0] % 100);
1358 lcd_puts(0, 0, buf);
1359 snprintf(buf, 30, "scale %d.%02d-%d.%02d V",
1360 minv / 100, minv % 100, maxv / 100, maxv % 100);
1361 lcd_puts(0, 1, buf);
1363 x = 0;
1364 for (i = BAT_LAST_VAL - 1; i >= 0; i--) {
1365 y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv);
1366 lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
1367 lcd_vline(x, LCD_HEIGHT-1, 20);
1368 lcd_set_drawmode(DRMODE_SOLID);
1369 lcd_vline(x, LCD_HEIGHT-1,
1370 MIN(MAX(LCD_HEIGHT-1 - y, 20), LCD_HEIGHT-1));
1371 x++;
1374 break;
1376 case 1: /* status: */
1377 lcd_clear_display();
1378 lcd_puts(0, 0, "Power status:");
1380 y = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
1381 snprintf(buf, 30, "Battery: %d.%02d V", y / 100, y % 100);
1382 lcd_puts(0, 1, buf);
1383 #ifdef ADC_EXT_POWER
1384 y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 10000;
1385 snprintf(buf, 30, "External: %d.%02d V", y / 100, y % 100);
1386 lcd_puts(0, 2, buf);
1387 #endif
1388 #ifdef CONFIG_CHARGING
1389 #if CONFIG_CHARGING == CHARGING_CONTROL
1390 snprintf(buf, 30, "Chgr: %s %s",
1391 charger_inserted() ? "present" : "absent",
1392 charger_enabled ? "on" : "off");
1393 lcd_puts(0, 3, buf);
1394 snprintf(buf, 30, "short delta: %d", short_delta);
1395 lcd_puts(0, 5, buf);
1396 snprintf(buf, 30, "long delta: %d", long_delta);
1397 lcd_puts(0, 6, buf);
1398 lcd_puts(0, 7, power_message);
1399 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1400 #if defined IPOD_NANO || defined IPOD_VIDEO
1401 int usb_pwr = (GPIOL_INPUT_VAL & 0x10)?true:false;
1402 int ext_pwr = (GPIOL_INPUT_VAL & 0x08)?false:true;
1403 int dock = (GPIOA_INPUT_VAL & 0x10)?true:false;
1404 int charging = (GPIOB_INPUT_VAL & 0x01)?false:true;
1405 int headphone= (GPIOA_INPUT_VAL & 0x80)?true:false;
1407 snprintf(buf, 30, "USB pwr: %s",
1408 usb_pwr ? "present" : "absent");
1409 lcd_puts(0, 3, buf);
1410 snprintf(buf, 30, "EXT pwr: %s",
1411 ext_pwr ? "present" : "absent");
1412 lcd_puts(0, 4, buf);
1413 snprintf(buf, 30, "Battery: %s",
1414 charging ? "charging" : (usb_pwr||ext_pwr) ? "charged" : "discharging");
1415 lcd_puts(0, 5, buf);
1416 snprintf(buf, 30, "Dock mode: %s",
1417 dock ? "enabled" : "disabled");
1418 lcd_puts(0, 6, buf);
1419 snprintf(buf, 30, "Headphone: %s",
1420 headphone ? "connected" : "disconnected");
1421 lcd_puts(0, 7, buf);
1422 #else
1423 snprintf(buf, 30, "Charger: %s",
1424 charger_inserted() ? "present" : "absent");
1425 lcd_puts(0, 3, buf);
1426 #endif
1427 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1428 #endif /* CONFIG_CHARGING */
1429 break;
1431 case 2: /* voltage deltas: */
1432 lcd_clear_display();
1433 lcd_puts(0, 0, "Voltage deltas:");
1435 for (i = 0; i <= 6; i++) {
1436 y = power_history[i] - power_history[i+i];
1437 snprintf(buf, 30, "-%d min: %s%d.%02d V", i,
1438 (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 100,
1439 ((y < 0) ? y * -1 : y ) % 100);
1440 lcd_puts(0, i+1, buf);
1442 break;
1444 case 3: /* remaining time estimation: */
1445 lcd_clear_display();
1447 #if CONFIG_CHARGING == CHARGING_CONTROL
1448 snprintf(buf, 30, "charge_state: %d", charge_state);
1449 lcd_puts(0, 0, buf);
1451 snprintf(buf, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min);
1452 lcd_puts(0, 1, buf);
1454 snprintf(buf, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level);
1455 lcd_puts(0, 2, buf);
1457 snprintf(buf, 30, "P=%2d I=%2d", pid_p, pid_i);
1458 lcd_puts(0, 3, buf);
1460 snprintf(buf, 30, "Trickle sec: %d/60", trickle_sec);
1461 lcd_puts(0, 4, buf);
1462 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1464 snprintf(buf, 30, "Last PwrHist: %d.%02d V",
1465 power_history[0] / 100,
1466 power_history[0] % 100);
1467 lcd_puts(0, 5, buf);
1469 snprintf(buf, 30, "battery level: %d%%", battery_level());
1470 lcd_puts(0, 6, buf);
1472 snprintf(buf, 30, "Est. remain: %d m", battery_time());
1473 lcd_puts(0, 7, buf);
1474 break;
1477 lcd_update();
1479 switch(get_action(CONTEXT_SETTINGS,HZ/2))
1481 case ACTION_SETTINGS_DEC:
1482 if (view)
1483 view--;
1484 break;
1486 case ACTION_SETTINGS_INC:
1487 if (view < 3)
1488 view++;
1489 break;
1491 case ACTION_STD_CANCEL:
1492 action_signalscreenchange();
1493 return false;
1496 return false;
1499 #endif /* HAVE_LCD_BITMAP */
1500 #endif
1502 static bool view_runtime(void)
1504 char s[32];
1505 bool done = false;
1506 int state = 1;
1508 while(!done)
1510 int y=0;
1511 int t;
1512 int key;
1513 lcd_clear_display();
1514 #ifdef HAVE_LCD_BITMAP
1515 lcd_puts(0, y++, "Running time:");
1516 y++;
1517 #endif
1519 if (state & 1) {
1520 #ifdef CONFIG_CHARGING
1521 if (charger_inserted()
1522 #ifdef HAVE_USB_POWER
1523 || usb_powered()
1524 #endif
1527 global_settings.runtime = 0;
1529 else
1530 #endif
1532 global_settings.runtime += ((current_tick - lasttime) / HZ);
1534 lasttime = current_tick;
1536 t = global_settings.runtime;
1537 lcd_puts(0, y++, "Current time");
1539 else {
1540 t = global_settings.topruntime;
1541 lcd_puts(0, y++, "Top time");
1544 snprintf(s, sizeof(s), "%dh %dm %ds",
1545 t / 3600, (t % 3600) / 60, t % 60);
1546 lcd_puts(0, y++, s);
1547 lcd_update();
1549 /* Wait for a key to be pushed */
1550 key = get_action(CONTEXT_SETTINGS,HZ);
1551 switch(key) {
1552 case ACTION_STD_CANCEL:
1553 done = true;
1554 break;
1556 case ACTION_SETTINGS_INC:
1557 case ACTION_SETTINGS_DEC:
1558 if (state == 1)
1559 state = 2;
1560 else
1561 state = 1;
1562 break;
1564 case ACTION_STD_OK:
1565 lcd_clear_display();
1566 /*NOTE: this needs to be changed to sync splash! */
1567 lcd_puts(0,0,"Clear time?");
1568 lcd_puts(0,1,"PLAY = Yes");
1569 lcd_update();
1570 while (1) {
1571 key = get_action(CONTEXT_STD,TIMEOUT_BLOCK);
1572 if ( key == ACTION_STD_OK ) {
1573 if ( state == 1 )
1574 global_settings.runtime = 0;
1575 else
1576 global_settings.topruntime = 0;
1577 break;
1580 break;
1583 action_signalscreenchange();
1584 return false;
1587 #ifndef SIMULATOR
1588 #ifdef HAVE_MMC
1589 bool dbg_mmc_info(void)
1591 bool done = false;
1592 int currval = 0;
1593 tCardInfo *card;
1594 unsigned char pbuf[32], pbuf2[32];
1595 unsigned char card_name[7];
1597 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1598 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1599 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
1600 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
1602 card_name[6] = '\0';
1604 lcd_setmargins(0, 0);
1605 lcd_setfont(FONT_SYSFIXED);
1607 while (!done)
1609 card = mmc_card_info(currval / 2);
1611 lcd_clear_display();
1612 snprintf(pbuf, sizeof(pbuf), "[MMC%d p%d]", currval / 2,
1613 (currval % 2) + 1);
1614 lcd_puts(0, 0, pbuf);
1616 if (card->initialized)
1618 if (!(currval % 2)) /* General info */
1620 strncpy(card_name, ((unsigned char*)card->cid) + 3, 6);
1621 snprintf(pbuf, sizeof(pbuf), "%s Rev %d.%d", card_name,
1622 (int) mmc_extract_bits(card->cid, 72, 4),
1623 (int) mmc_extract_bits(card->cid, 76, 4));
1624 lcd_puts(0, 1, pbuf);
1625 snprintf(pbuf, sizeof(pbuf), "Prod: %d/%d",
1626 (int) mmc_extract_bits(card->cid, 112, 4),
1627 (int) mmc_extract_bits(card->cid, 116, 4) + 1997);
1628 lcd_puts(0, 2, pbuf);
1629 snprintf(pbuf, sizeof(pbuf), "Ser#: 0x%08lx",
1630 mmc_extract_bits(card->cid, 80, 32));
1631 lcd_puts(0, 3, pbuf);
1632 snprintf(pbuf, sizeof(pbuf), "M=%02x, O=%04x",
1633 (int) mmc_extract_bits(card->cid, 0, 8),
1634 (int) mmc_extract_bits(card->cid, 8, 16));
1635 lcd_puts(0, 4, pbuf);
1636 snprintf(pbuf, sizeof(pbuf), "Blocks: 0x%06lx", card->numblocks);
1637 lcd_puts(0, 5, pbuf);
1638 snprintf(pbuf, sizeof(pbuf), "Blksz.: %d", card->blocksize);
1639 lcd_puts(0, 6, pbuf);
1641 else /* Technical details */
1643 output_dyn_value(pbuf2, sizeof pbuf2, card->speed / 1000,
1644 kbit_units, false);
1645 snprintf(pbuf, sizeof pbuf, "Speed: %s", pbuf2);
1646 lcd_puts(0, 1, pbuf);
1648 output_dyn_value(pbuf2, sizeof pbuf2, card->tsac,
1649 nsec_units, false);
1650 snprintf(pbuf, sizeof pbuf, "Tsac: %s", pbuf2);
1651 lcd_puts(0, 2, pbuf);
1653 snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac);
1654 lcd_puts(0, 3, pbuf);
1655 snprintf(pbuf, sizeof(pbuf), "R2W: *%d", card->r2w_factor);
1656 lcd_puts(0, 4, pbuf);
1657 snprintf(pbuf, sizeof(pbuf), "IRmax: %d..%d mA",
1658 i_vmin[mmc_extract_bits(card->csd, 66, 3)],
1659 i_vmax[mmc_extract_bits(card->csd, 69, 3)]);
1660 lcd_puts(0, 5, pbuf);
1661 snprintf(pbuf, sizeof(pbuf), "IWmax: %d..%d mA",
1662 i_vmin[mmc_extract_bits(card->csd, 72, 3)],
1663 i_vmax[mmc_extract_bits(card->csd, 75, 3)]);
1664 lcd_puts(0, 6, pbuf);
1667 else
1668 lcd_puts(0, 1, "Not found!");
1670 lcd_update();
1672 switch (get_action(CONTEXT_SETTINGS,HZ/2))
1674 case ACTION_STD_CANCEL:
1675 done = true;
1676 break;
1678 case ACTION_SETTINGS_DEC:
1679 currval--;
1680 if (currval < 0)
1681 currval = 3;
1682 break;
1684 case ACTION_SETTINGS_INC:
1685 currval++;
1686 if (currval > 3)
1687 currval = 0;
1688 break;
1691 action_signalscreenchange();
1692 return false;
1694 #else /* !HAVE_MMC */
1695 static bool dbg_disk_info(void)
1697 char buf[128];
1698 bool done = false;
1699 int i;
1700 int page = 0;
1701 const int max_page = 11;
1702 unsigned short* identify_info = ata_get_identify();
1703 bool timing_info_present = false;
1704 char pio3[2], pio4[2];
1706 #ifdef HAVE_LCD_BITMAP
1707 lcd_setmargins(0, 0);
1708 #endif
1710 while(!done)
1712 int y=0;
1713 int key;
1714 lcd_clear_display();
1715 #ifdef HAVE_LCD_BITMAP
1716 lcd_puts(0, y++, "Disk info:");
1717 y++;
1718 #endif
1720 switch (page) {
1721 case 0:
1722 for (i=0; i < 20; i++)
1723 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
1724 buf[40]=0;
1725 /* kill trailing space */
1726 for (i=39; i && buf[i]==' '; i--)
1727 buf[i] = 0;
1728 lcd_puts(0, y++, "Model");
1729 lcd_puts_scroll(0, y++, buf);
1730 break;
1732 case 1:
1733 for (i=0; i < 4; i++)
1734 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
1735 buf[8]=0;
1736 lcd_puts(0, y++, "Firmware");
1737 lcd_puts(0, y++, buf);
1738 break;
1740 case 2:
1741 snprintf(buf, sizeof buf, "%ld MB",
1742 ((unsigned long)identify_info[61] << 16 |
1743 (unsigned long)identify_info[60]) / 2048 );
1744 lcd_puts(0, y++, "Size");
1745 lcd_puts(0, y++, buf);
1746 break;
1748 case 3: {
1749 unsigned long free;
1750 fat_size( IF_MV2(0,) NULL, &free );
1751 snprintf(buf, sizeof buf, "%ld MB", free / 1024 );
1752 lcd_puts(0, y++, "Free");
1753 lcd_puts(0, y++, buf);
1754 break;
1757 case 4:
1758 snprintf(buf, sizeof buf, "%d ms", ata_spinup_time * (1000/HZ));
1759 lcd_puts(0, y++, "Spinup time");
1760 lcd_puts(0, y++, buf);
1761 break;
1763 case 5:
1764 i = identify_info[83] & (1<<3);
1765 lcd_puts(0, y++, "Power mgmt:");
1766 lcd_puts(0, y++, i ? "enabled" : "unsupported");
1767 break;
1769 case 6:
1770 i = identify_info[83] & (1<<9);
1771 lcd_puts(0, y++, "Noise mgmt:");
1772 lcd_puts(0, y++, i ? "enabled" : "unsupported");
1773 break;
1775 case 7:
1776 i = identify_info[82] & (1<<6);
1777 lcd_puts(0, y++, "Read-ahead:");
1778 lcd_puts(0, y++, i ? "enabled" : "unsupported");
1779 break;
1781 case 8:
1782 timing_info_present = identify_info[53] & (1<<1);
1783 if(timing_info_present) {
1784 pio3[1] = 0;
1785 pio4[1] = 0;
1786 lcd_puts(0, y++, "PIO modes:");
1787 pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
1788 pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
1789 snprintf(buf, 128, "0 1 2 %s %s", pio3, pio4);
1790 lcd_puts(0, y++, buf);
1791 } else {
1792 lcd_puts(0, y++, "No PIO mode info");
1794 break;
1796 case 9:
1797 timing_info_present = identify_info[53] & (1<<1);
1798 if(timing_info_present) {
1799 lcd_puts(0, y++, "Cycle times");
1800 snprintf(buf, 128, "%dns/%dns",
1801 identify_info[67],
1802 identify_info[68]);
1803 lcd_puts(0, y++, buf);
1804 } else {
1805 lcd_puts(0, y++, "No timing info");
1807 break;
1809 case 10:
1810 timing_info_present = identify_info[53] & (1<<1);
1811 if(timing_info_present) {
1812 i = identify_info[49] & (1<<11);
1813 snprintf(buf, 128, "IORDY support: %s", i ? "yes" : "no");
1814 lcd_puts(0, y++, buf);
1815 i = identify_info[49] & (1<<10);
1816 snprintf(buf, 128, "IORDY disable: %s", i ? "yes" : "no");
1817 lcd_puts(0, y++, buf);
1818 } else {
1819 lcd_puts(0, y++, "No timing info");
1821 break;
1823 case 11:
1824 lcd_puts(0, y++, "Cluster size");
1825 snprintf(buf, 128, "%d bytes", fat_get_cluster_size(IF_MV(0)));
1826 lcd_puts(0, y++, buf);
1827 break;
1829 lcd_update();
1831 /* Wait for a key to be pushed */
1832 key = get_action(CONTEXT_SETTINGS,HZ/5);
1833 switch(key) {
1834 case ACTION_STD_CANCEL:
1835 done = true;
1836 break;
1838 case ACTION_SETTINGS_DEC:
1839 if (--page < 0)
1840 page = max_page;
1841 break;
1843 case ACTION_SETTINGS_INC:
1844 if (++page > max_page)
1845 page = 0;
1846 break;
1848 lcd_stop_scroll();
1850 action_signalscreenchange();
1851 return false;
1853 #endif /* !HAVE_MMC */
1854 #endif /* !SIMULATOR */
1856 #ifdef HAVE_DIRCACHE
1857 static bool dbg_dircache_info(void)
1859 bool done = false;
1860 int line;
1861 char buf[32];
1863 lcd_setmargins(0, 0);
1864 lcd_setfont(FONT_SYSFIXED);
1866 while (!done)
1868 line = 0;
1870 lcd_clear_display();
1871 snprintf(buf, sizeof(buf), "Cache initialized: %s",
1872 dircache_is_enabled() ? "Yes" : "No");
1873 lcd_puts(0, line++, buf);
1875 snprintf(buf, sizeof(buf), "Cache size: %d B",
1876 dircache_get_cache_size());
1877 lcd_puts(0, line++, buf);
1879 snprintf(buf, sizeof(buf), "Last size: %d B",
1880 global_settings.dircache_size);
1881 lcd_puts(0, line++, buf);
1883 snprintf(buf, sizeof(buf), "Limit: %d B", DIRCACHE_LIMIT);
1884 lcd_puts(0, line++, buf);
1886 snprintf(buf, sizeof(buf), "Reserve: %d/%d B",
1887 dircache_get_reserve_used(), DIRCACHE_RESERVE);
1888 lcd_puts(0, line++, buf);
1890 snprintf(buf, sizeof(buf), "Scanning took: %d s",
1891 dircache_get_build_ticks() / HZ);
1892 lcd_puts(0, line++, buf);
1894 snprintf(buf, sizeof(buf), "Entry count: %d",
1895 dircache_get_entry_count());
1896 lcd_puts(0, line++, buf);
1898 lcd_update();
1900 if (action_userabort(HZ/2))
1901 return false;
1904 return false;
1907 #endif /* HAVE_DIRCACHE */
1909 #ifdef HAVE_LCD_BITMAP
1910 static bool dbg_tagcache_info(void)
1912 bool done = false;
1913 int line;
1914 char buf[32];
1915 struct tagcache_stat *stat;
1917 lcd_setmargins(0, 0);
1918 lcd_setfont(FONT_SYSFIXED);
1920 while (!done)
1922 line = 0;
1924 lcd_clear_display();
1925 stat = tagcache_get_stat();
1926 snprintf(buf, sizeof(buf), "Initialized: %s", stat->initialized ? "Yes" : "No");
1927 lcd_puts(0, line++, buf);
1928 snprintf(buf, sizeof(buf), "DB Ready: %s", stat->ready ? "Yes" : "No");
1929 lcd_puts(0, line++, buf);
1930 snprintf(buf, sizeof(buf), "RAM Cache: %s", stat->ramcache ? "Yes" : "No");
1931 lcd_puts(0, line++, buf);
1932 snprintf(buf, sizeof(buf), "RAM: %d/%d B",
1933 stat->ramcache_used, stat->ramcache_allocated);
1934 lcd_puts(0, line++, buf);
1935 snprintf(buf, sizeof(buf), "Progress: %d%% (%d entries)",
1936 stat->progress, stat->processed_entries);
1937 lcd_puts(0, line++, buf);
1938 snprintf(buf, sizeof(buf), "Commit step: %d", stat->commit_step);
1939 lcd_puts(0, line++, buf);
1940 snprintf(buf, sizeof(buf), "Commit delayed: %s",
1941 stat->commit_delayed ? "Yes" : "No");
1942 lcd_puts(0, line++, buf);
1944 lcd_update();
1946 if (action_userabort(HZ/2))
1947 return false;
1950 return false;
1952 #endif
1954 #if CONFIG_CPU == SH7034
1955 bool dbg_save_roms(void)
1957 int fd;
1958 int oldmode = system_memory_guard(MEMGUARD_NONE);
1960 fd = creat("/internal_rom_0000-FFFF.bin", O_WRONLY);
1961 if(fd >= 0)
1963 write(fd, (void *)0, 0x10000);
1964 close(fd);
1967 fd = creat("/internal_rom_2000000-203FFFF.bin", O_WRONLY);
1968 if(fd >= 0)
1970 write(fd, (void *)0x2000000, 0x40000);
1971 close(fd);
1974 system_memory_guard(oldmode);
1975 return false;
1977 #elif defined CPU_COLDFIRE
1978 bool dbg_save_roms(void)
1980 int fd;
1981 int oldmode = system_memory_guard(MEMGUARD_NONE);
1983 #if defined(IRIVER_H100_SERIES)
1984 fd = creat("/internal_rom_000000-1FFFFF.bin", O_WRONLY);
1985 #elif defined(IRIVER_H300_SERIES)
1986 fd = creat("/internal_rom_000000-3FFFFF.bin", O_WRONLY);
1987 #elif defined(IAUDIO_X5)
1988 fd = creat("/internal_rom_000000-3FFFFF.bin", O_WRONLY);
1989 #endif
1990 if(fd >= 0)
1992 write(fd, (void *)0, FLASH_SIZE);
1993 close(fd);
1995 system_memory_guard(oldmode);
1997 #ifdef HAVE_EEPROM
1998 fd = creat("/internal_eeprom.bin", O_WRONLY);
1999 if (fd >= 0)
2001 int old_irq_level;
2002 char buf[EEPROM_SIZE];
2003 int err;
2005 old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL);
2007 err = eeprom_24cxx_read(0, buf, sizeof buf);
2008 if (err)
2009 gui_syncsplash(HZ*3, true, "Eeprom read failure (%d)",err);
2010 else
2012 write(fd, buf, sizeof buf);
2015 set_irq_level(old_irq_level);
2017 close(fd);
2019 #endif
2021 return false;
2023 #endif /* CPU */
2025 #ifndef SIMULATOR
2026 #ifdef CONFIG_TUNER
2027 bool dbg_fm_radio(void)
2029 char buf[32];
2030 bool fm_detected;
2032 #ifdef HAVE_LCD_BITMAP
2033 lcd_setmargins(0, 0);
2034 #endif
2036 while(1)
2038 int row = 0;
2039 unsigned long regs;
2041 lcd_clear_display();
2042 fm_detected = radio_hardware_present();
2044 snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no");
2045 lcd_puts(0, row++, buf);
2047 #if (CONFIG_TUNER & S1A0903X01)
2048 regs = samsung_get(RADIO_ALL);
2049 snprintf(buf, sizeof buf, "Samsung regs: %08lx", regs);
2050 lcd_puts(0, row++, buf);
2051 #endif
2052 #if (CONFIG_TUNER & TEA5767)
2053 regs = philips_get(RADIO_ALL);
2054 snprintf(buf, sizeof buf, "Philips regs: %08lx", regs);
2055 lcd_puts(0, row++, buf);
2056 #endif
2058 lcd_update();
2060 if (action_userabort(HZ))
2061 return false;
2063 return false;
2065 #endif /* CONFIG_TUNER */
2066 #endif /* !SIMULATOR */
2068 #ifdef HAVE_LCD_BITMAP
2069 extern bool do_screendump_instead_of_usb;
2071 bool dbg_screendump(void)
2073 do_screendump_instead_of_usb = !do_screendump_instead_of_usb;
2074 gui_syncsplash(HZ, true, "Screendump %s",
2075 do_screendump_instead_of_usb?"enabled":"disabled");
2076 return false;
2078 #endif /* HAVE_LCD_BITMAP */
2080 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2081 bool dbg_set_memory_guard(void)
2083 static const struct opt_items names[MAXMEMGUARD] = {
2084 { "None", -1 },
2085 { "Flash ROM writes", -1 },
2086 { "Zero area (all)", -1 }
2088 int mode = system_memory_guard(MEMGUARD_KEEP);
2090 set_option( "Catch mem accesses", &mode, INT, names, MAXMEMGUARD, NULL);
2091 system_memory_guard(mode);
2093 return false;
2095 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2097 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2098 bool dbg_write_eeprom(void)
2100 int fd;
2101 int rc;
2102 int old_irq_level;
2103 char buf[EEPROM_SIZE];
2104 int err;
2106 fd = open("/internal_eeprom.bin", O_RDONLY);
2108 if (fd >= 0)
2110 rc = read(fd, buf, EEPROM_SIZE);
2112 if(rc == EEPROM_SIZE)
2114 old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL);
2116 err = eeprom_24cxx_write(0, buf, sizeof buf);
2117 if (err)
2118 gui_syncsplash(HZ*3, true, "Eeprom write failure (%d)",err);
2119 else
2120 gui_syncsplash(HZ*3, true, "Eeprom written successfully");
2122 set_irq_level(old_irq_level);
2124 else
2126 gui_syncsplash(HZ*3, true, "File read error (%d)",rc);
2128 close(fd);
2130 else
2132 gui_syncsplash(HZ*3, true, "Failed to open 'internal_eeprom.bin'");
2135 return false;
2137 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2139 bool debug_menu(void)
2141 int m;
2142 bool result;
2144 static const struct menu_item items[] = {
2145 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2146 { "Dump ROM contents", dbg_save_roms },
2147 #endif
2148 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || (CONFIG_CPU == PP5020)
2149 { "View I/O ports", dbg_ports },
2150 #endif
2151 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2152 { "CPU frequency", dbg_cpufreq },
2153 #endif
2154 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2155 { "S/PDIF analyzer", dbg_spdif },
2156 #endif
2157 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2158 { "Catch mem accesses", dbg_set_memory_guard },
2159 #endif
2160 #ifndef SIMULATOR
2161 { "View OS stacks", dbg_os },
2162 #endif
2163 #ifdef HAVE_LCD_BITMAP
2164 #ifndef SIMULATOR
2165 { "View battery", view_battery },
2166 #endif
2167 { "Screendump", dbg_screendump },
2168 #endif
2169 #ifndef SIMULATOR
2170 { "View HW info", dbg_hw_info },
2171 #endif
2172 #ifndef SIMULATOR
2173 { "View partitions", dbg_partitions },
2174 #endif
2175 #ifndef SIMULATOR
2176 #ifdef HAVE_MMC
2177 { "View MMC info", dbg_mmc_info },
2178 #else
2179 { "View disk info", dbg_disk_info },
2180 #endif
2181 #endif
2182 #ifdef HAVE_DIRCACHE
2183 { "View dircache info", dbg_dircache_info },
2184 #endif
2185 #ifdef HAVE_LCD_BITMAP
2186 { "View tagcache info", dbg_tagcache_info },
2187 #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR)
2188 { "View audio thread", dbg_audio_thread },
2189 #endif
2190 #ifdef PM_DEBUG
2191 { "pm histogram", peak_meter_histogram},
2192 #endif /* PM_DEBUG */
2193 #endif /* HAVE_LCD_BITMAP */
2194 { "View runtime", view_runtime },
2195 #ifndef SIMULATOR
2196 #ifdef CONFIG_TUNER
2197 { "FM Radio", dbg_fm_radio },
2198 #endif
2199 #endif
2200 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2201 { "Write back EEPROM", dbg_write_eeprom },
2202 #endif
2203 #ifdef ROCKBOX_HAS_LOGF
2204 {"logf", logfdisplay },
2205 {"logfdump", logfdump },
2206 #endif
2209 m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
2210 NULL, NULL, NULL);
2211 result = menu_run(m);
2212 menu_exit(m);
2214 return result;