1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
26 #include "debug_menu.h"
32 #include "powermgmt.h"
36 #include "mp3_playback.h"
39 #include "statusbar.h"
49 #include "lcd-remote.h"
61 #include "eeprom_24cxx.h"
71 #ifdef HAVE_LCD_BITMAP
72 #include "scrollbar.h"
73 #include "peakmeter.h"
76 #if CONFIG_CODEC == SWCODEC
78 #include "pcm_playback.h"
79 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
83 #ifdef IRIVER_H300_SERIES
84 #include "pcf50606.h" /* for pcf50606_read */
91 static char* dbg_menu_getname(int item
, void * data
, char *buffer
);
92 static bool dbg_list(char *title
, int count
, int selection_size
,
93 int (*action_callback
)(int btn
, struct gui_synclist
*lists
),
94 char* (*dbg_getname
)(int item
, void * data
, char *buffer
))
96 struct gui_synclist lists
;
99 gui_synclist_init(&lists
, dbg_getname
, NULL
, false, selection_size
);
100 gui_synclist_set_title(&lists
, title
, NOICON
);
101 gui_synclist_set_icon_callback(&lists
, NULL
);
102 gui_synclist_set_nb_items(&lists
, count
*selection_size
);
103 if (dbg_getname
!= dbg_menu_getname
)
104 gui_synclist_hide_selection_marker(&lists
, true);
105 action_signalscreenchange();
106 gui_synclist_draw(&lists
);
109 gui_syncstatusbar_draw(&statusbars
, true);
110 action
= get_action(CONTEXT_STD
, HZ
/5);
111 if (gui_synclist_do_button(&lists
, action
, LIST_WRAP_UNLESS_HELD
))
112 gui_synclist_draw(&lists
);
114 action
= action_callback(action
, &lists
);
115 if (action
== ACTION_STD_CANCEL
)
117 else if(default_event_handler(action
) == SYS_USB_CONNECTED
)
120 action_signalscreenchange();
123 /*---------------------------------------------------*/
124 /* SPECIAL DEBUG STUFF */
125 /*---------------------------------------------------*/
126 extern struct thread_entry threads
[MAXTHREADS
];
130 static char thread_status_char(int status
)
134 case STATE_RUNNING
: return 'R';
135 case STATE_BLOCKED
: return 'B';
136 case STATE_SLEEPING
: return 'S';
137 case STATE_BLOCKED_W_TMO
: return 'T';
143 #define IF_COP2(...) __VA_ARGS__
147 static char* threads_getname(int selected_item
, void * data
, char *buffer
)
150 struct thread_entry
*thread
= NULL
;
152 thread
= &threads
[selected_item
];
154 if (thread
->name
== NULL
)
156 snprintf(buffer
, MAX_PATH
, "%2d: ---", selected_item
);
160 usage
= thread_stack_usage(thread
);
161 status
= thread_get_status(thread
);
162 #ifdef HAVE_PRIORITY_SCHEDULING
163 snprintf(buffer
, MAX_PATH
, "%2d: " IF_COP2("(%d) ") "%c%c %d %2d%% %s",
165 IF_COP2(thread
->core
,)
166 (status
== STATE_RUNNING
) ? '*' : ' ',
167 thread_status_char(status
),
169 usage
, thread
->name
);
171 snprintf(buffer
, MAX_PATH
, "%2d: " IF_COP2("(%d) ") "%c%c %2d%% %s",
173 IF_COP2(thread
->core
,)
174 (status
== STATE_RUNNING
) ? '*' : ' ',
175 thread_status_char(status
),
176 usage
, thread
->name
);
180 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
182 #ifdef ROCKBOX_HAS_LOGF
183 if (action
== ACTION_STD_OK
)
185 struct thread_entry
*thread
= &threads
[gui_synclist_get_sel_pos(lists
)];
186 if (thread
->name
!= NULL
)
187 remove_thread(thread
);
190 gui_synclist_draw(lists
);
194 static bool dbg_os(void)
196 return dbg_list(IF_COP2("Core and ") "Stack usage:", MAXTHREADS
, 1,
197 dbg_threads_action_callback
, threads_getname
);
199 #endif /* !SIMULATOR */
201 #ifdef HAVE_LCD_BITMAP
202 #if CONFIG_CODEC != SWCODEC
204 static bool dbg_audio_thread(void)
207 struct audio_debug d
;
209 lcd_setmargins(0, 0);
210 lcd_setfont(FONT_SYSFIXED
);
214 if (action_userabort(HZ
/5))
217 audio_get_debugdata(&d
);
221 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
223 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
225 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
227 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
229 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
231 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
234 /* Playable space left */
235 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
236 d
.playable_space
, HORIZONTAL
);
238 /* Show the watermark limit */
239 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
240 d
.low_watermark_level
, HORIZONTAL
);
242 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
243 d
.low_watermark_level
, d
.lowest_watermark_level
);
250 #endif /* !SIMULATOR */
251 #else /* CONFIG_CODEC == SWCODEC */
252 extern size_t filebuflen
;
253 /* This is a size_t, but call it a long so it puts a - when it's bad. */
255 static unsigned int ticks
, boost_ticks
;
257 static void dbg_audio_task(void)
260 if(FREQ
> CPUFREQ_NORMAL
)
267 static bool dbg_audio_thread(void)
274 size_t bufsize
= pcmbuf_get_bufsize();
275 int pcmbufdescs
= pcmbuf_descs();
277 ticks
= boost_ticks
= 0;
279 tick_add_task(dbg_audio_task
);
281 lcd_setmargins(0, 0);
282 lcd_setfont(FONT_SYSFIXED
);
285 button
= get_action(CONTEXT_STD
,HZ
/5);
288 case ACTION_STD_NEXT
:
291 case ACTION_STD_PREV
:
294 case ACTION_STD_CANCEL
:
298 action_signalscreenchange();
303 bufused
= bufsize
- pcmbuf_free();
305 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
306 lcd_puts(0, line
++, buf
);
308 /* Playable space left */
309 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, bufsize
, 0, bufused
, HORIZONTAL
);
312 snprintf(buf
, sizeof(buf
), "codec: %8ld/%8ld", audio_filebufused(), (long) filebuflen
);
313 lcd_puts(0, line
++, buf
);
315 /* Playable space left */
316 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, filebuflen
, 0,
317 audio_filebufused(), HORIZONTAL
);
320 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
321 lcd_puts(0, line
++, buf
);
324 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
325 (int)((FREQ
+ 500000) / 1000000));
326 lcd_puts(0, line
++, buf
);
331 snprintf(buf
, sizeof(buf
), "boost ratio: %3d%%",
332 boost_ticks
* 100 / ticks
);
333 lcd_puts(0, line
++, buf
);
336 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
337 pcmbuf_used_descs(), pcmbufdescs
);
338 lcd_puts(0, line
++, buf
);
343 tick_remove_task(dbg_audio_task
);
347 #endif /* CONFIG_CODEC */
348 #endif /* HAVE_LCD_BITMAP */
351 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
352 /* Tool function to read the flash manufacturer and type, if available.
353 Only chips which could be reprogrammed in system will return values.
354 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
355 /* In IRAM to avoid problems when running directly from Flash */
356 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
357 unsigned addr1
, unsigned addr2
)
358 ICODE_ATTR
__attribute__((noinline
));
359 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
360 unsigned addr1
, unsigned addr2
)
363 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
364 unsigned manu
, id
; /* read values when in ID mode */
366 #if CONFIG_CPU == SH7034
367 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
368 #elif defined(CPU_COLDFIRE)
369 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
371 int old_level
; /* saved interrupt level */
373 not_manu
= flash
[0]; /* read the normal content */
374 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
376 /* disable interrupts, prevent any stray flash access */
377 old_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
379 flash
[addr1
] = 0xAA; /* enter command mode */
381 flash
[addr1
] = 0x90; /* ID command */
382 /* Atmel wants 20ms pause here */
383 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
385 manu
= flash
[0]; /* read the IDs */
388 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
389 /* Atmel wants 20ms pause here */
390 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
392 set_irq_level(old_level
); /* enable interrupts again */
394 /* I assume success if the obtained values are different from
395 the normal flash content. This is not perfectly bulletproof, they
396 could theoretically be the same by chance, causing us to fail. */
397 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
399 *p_manufacturer
= manu
; /* return the results */
401 return true; /* success */
403 return false; /* fail */
405 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
408 #ifdef HAVE_LCD_BITMAP
409 static bool dbg_hw_info(void)
411 #if CONFIG_CPU == SH7034
413 int bitmask
= HW_MASK
;
414 int rom_version
= ROM_VERSION
;
415 unsigned manu
, id
; /* flash IDs */
416 bool got_id
; /* flag if we managed to get the flash IDs */
417 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
418 bool has_bootrom
; /* flag for boot ROM present */
419 int oldmode
; /* saved memory guard mode */
421 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
423 /* get flash ROM type */
424 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
426 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
428 /* check if the boot ROM area is a flash mirror */
429 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
430 if (has_bootrom
) /* if ROM and Flash different */
432 /* calculate CRC16 checksum of boot ROM */
433 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
436 system_memory_guard(oldmode
); /* re-enable memory guard */
438 lcd_setmargins(0, 0);
439 lcd_setfont(FONT_SYSFIXED
);
442 lcd_puts(0, 0, "[Hardware info]");
444 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
447 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
451 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
453 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
458 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
459 snprintf(buf
, 32, "Boot ROM: V1");
461 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
465 snprintf(buf
, 32, "Boot ROM: none");
473 if (action_userabort(TIMEOUT_BLOCK
))
476 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
478 unsigned manu
, id
; /* flash IDs */
479 int got_id
; /* flag if we managed to get the flash IDs */
480 int oldmode
; /* saved memory guard mode */
483 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
485 /* get flash ROM type */
486 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
488 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
490 system_memory_guard(oldmode
); /* re-enable memory guard */
492 lcd_setmargins(0, 0);
493 lcd_setfont(FONT_SYSFIXED
);
496 lcd_puts(0, line
++, "[Hardware info]");
499 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
501 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
502 lcd_puts(0, line
++, buf
);
508 lcd_puts(0, ++line
, "Serial Number:");
510 got_id
= ds2411_read_id(&id
);
512 if (got_id
== DS2411_OK
)
514 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
515 lcd_puts(0, ++line
, buf
);
516 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
517 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
518 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
519 lcd_puts(0, ++line
, buf
);
520 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
524 snprintf(buf
, 32, "READ ERR=%d", got_id
);
527 lcd_puts(0, ++line
, buf
);
535 if (action_userabort(TIMEOUT_BLOCK
))
538 #elif CONFIG_CPU == PP5020
540 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
541 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
542 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
543 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
545 lcd_setmargins(0, 0);
546 lcd_setfont(FONT_SYSFIXED
);
549 lcd_puts(0, 0, "[Hardware info]");
551 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08x", ipod_hw_rev
);
554 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
560 if (action_userabort(TIMEOUT_BLOCK
))
563 #endif /* CONFIG_CPU */
566 #else /* !HAVE_LCD_BITMAP */
567 static bool dbg_hw_info(void)
572 int rom_version
= ROM_VERSION
;
573 unsigned manu
, id
; /* flash IDs */
574 bool got_id
; /* flag if we managed to get the flash IDs */
575 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
576 bool has_bootrom
; /* flag for boot ROM present */
577 int oldmode
; /* saved memory guard mode */
579 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
581 /* get flash ROM type */
582 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
584 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
586 /* check if the boot ROM area is a flash mirror */
587 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
588 if (has_bootrom
) /* if ROM and Flash different */
590 /* calculate CRC16 checksum of boot ROM */
591 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
594 system_memory_guard(oldmode
); /* re-enable memory guard */
598 lcd_puts(0, 0, "[HW Info]");
604 snprintf(buf
, 32, "ROM: %d.%02d",
605 rom_version
/100, rom_version
%100);
609 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
611 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
616 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
617 snprintf(buf
, 32, "BootROM: V1");
618 else if (rom_crc
== 0x358099E8)
619 snprintf(buf
, 32, "BootROM: V2");
620 /* alternative boot ROM found in one single player so far */
622 snprintf(buf
, 32, "R: %08x", rom_crc
);
625 snprintf(buf
, 32, "BootROM: no");
631 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
635 case ACTION_STD_CANCEL
:
636 action_signalscreenchange();
639 case ACTION_SETTINGS_DEC
:
645 case ACTION_SETTINGS_INC
:
654 #endif /* !HAVE_LCD_BITMAP */
655 #endif /* !SIMULATOR */
658 static char* dbg_partitions_getname(int selected_item
, void * data
, char *buffer
)
661 int partition
= selected_item
/2;
662 struct partinfo
* p
= disk_partinfo(partition
);
665 snprintf(buffer
, MAX_PATH
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
669 snprintf(buffer
, MAX_PATH
, "P%d: S:%lx", partition
, p
->start
);
674 bool dbg_partitions(void)
676 return dbg_list("Partition Info", 4, 2,
677 NULL
, dbg_partitions_getname
);
681 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
682 static bool dbg_spdif(void)
686 unsigned int control
;
691 unsigned int interruptstat
;
692 bool valnogood
, symbolerr
, parityerr
;
695 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
696 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
698 lcd_setmargins(0, 0);
700 lcd_setfont(FONT_SYSFIXED
);
702 #ifdef HAVE_SPDIF_POWER
703 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
710 control
= EBU1RCVCCHANNEL1
;
711 interruptstat
= INTERRUPTSTAT
;
712 INTERRUPTCLEAR
= 0x03c00000;
714 valnogood
= (interruptstat
& 0x01000000)?true:false;
715 symbolerr
= (interruptstat
& 0x00800000)?true:false;
716 parityerr
= (interruptstat
& 0x00400000)?true:false;
718 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
721 parityerr
?"--":"OK");
722 lcd_puts(0, line
++, buf
);
724 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
725 lcd_puts(0, line
++, buf
);
730 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
731 x
, x
?"Professional":"Consumer");
732 lcd_puts(0, line
++, buf
);
734 x
= (control
>> 30) & 1;
735 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
736 x
, x
?"Non-PCM":"PCM");
737 lcd_puts(0, line
++, buf
);
739 x
= (control
>> 29) & 1;
740 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
741 x
, x
?"Permitted":"Inhibited");
742 lcd_puts(0, line
++, buf
);
744 x
= (control
>> 27) & 7;
757 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
758 lcd_puts(0, line
++, buf
);
760 x
= (control
>> 24) & 3;
761 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
762 lcd_puts(0, line
++, buf
);
764 category
= (control
>> 17) & 127;
776 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
777 lcd_puts(0, line
++, buf
);
779 x
= (control
>> 16) & 1;
781 if(((category
& 0x70) == 0x10) ||
782 ((category
& 0x70) == 0x40) ||
783 ((category
& 0x78) == 0x38))
785 generation
= !generation
;
787 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
788 x
, generation
?"Original":"No ind.");
789 lcd_puts(0, line
++, buf
);
791 x
= (control
>> 12) & 15;
792 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
793 lcd_puts(0, line
++, buf
);
795 x
= (control
>> 8) & 15;
811 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
812 lcd_puts(0, line
++, buf
);
814 x
= (control
>> 4) & 15;
827 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
828 lcd_puts(0, line
++, buf
);
830 x
= (control
>> 2) & 3;
831 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
832 lcd_puts(0, line
++, buf
);
836 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
837 spdif_measure_frequency());
838 lcd_puts(0, line
++, buf
);
843 if (action_userabort(HZ
/10))
847 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
849 #ifdef HAVE_SPDIF_POWER
850 spdif_power_enable(global_settings
.spdif_enable
);
855 #endif /* CPU_COLDFIRE */
858 #ifdef HAVE_LCD_BITMAP
859 /* button definitions */
860 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
861 (CONFIG_KEYPAD == IRIVER_H300_PAD)
862 # define DEBUG_CANCEL BUTTON_OFF
864 #elif CONFIG_KEYPAD == RECORDER_PAD
865 # define DEBUG_CANCEL BUTTON_OFF
867 #elif CONFIG_KEYPAD == ONDIO_PAD
868 # define DEBUG_CANCEL BUTTON_MENU
870 #elif (CONFIG_KEYPAD == IPOD_3G_PAD) || \
871 (CONFIG_KEYPAD == IPOD_4G_PAD)
872 # define DEBUG_CANCEL BUTTON_MENU
874 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
875 # define DEBUG_CANCEL BUTTON_PLAY
877 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
878 # define DEBUG_CANCEL BUTTON_REC
880 #elif CONFIG_KEYPAD == GIGABEAT_PAD
881 # define DEBUG_CANCEL BUTTON_A
883 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
884 # define DEBUG_CANCEL BUTTON_REW
886 #elif CONFIG_KEYPAD == SANSA_E200_PAD
887 # define DEBUG_CANCEL BUTTON_LEFT
888 #endif /* key definitios */
893 #if CONFIG_CPU == SH7034
894 unsigned short porta
;
895 unsigned short portb
;
898 int adc_battery_voltage
, adc_battery_level
;
900 lcd_setfont(FONT_SYSFIXED
);
901 lcd_setmargins(0, 0);
910 snprintf(buf
, 32, "PADR: %04x", porta
);
912 snprintf(buf
, 32, "PBDR: %04x", portb
);
915 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
917 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
919 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
921 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
924 battery_read_info(NULL
, &adc_battery_voltage
,
926 snprintf(buf
, 32, "Batt: %d.%02dV %d%% ", adc_battery_voltage
/ 100,
927 adc_battery_voltage
% 100, adc_battery_level
);
931 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
934 #elif defined(CPU_COLDFIRE)
935 unsigned int gpio_out
;
936 unsigned int gpio1_out
;
937 unsigned int gpio_read
;
938 unsigned int gpio1_read
;
939 unsigned int gpio_function
;
940 unsigned int gpio1_function
;
941 unsigned int gpio_enable
;
942 unsigned int gpio1_enable
;
943 int adc_buttons
, adc_remote
;
944 int adc_battery
, adc_battery_voltage
, adc_battery_level
;
948 lcd_setmargins(0, 0);
950 lcd_setfont(FONT_SYSFIXED
);
955 gpio_read
= GPIO_READ
;
956 gpio1_read
= GPIO1_READ
;
958 gpio1_out
= GPIO1_OUT
;
959 gpio_function
= GPIO_FUNCTION
;
960 gpio1_function
= GPIO1_FUNCTION
;
961 gpio_enable
= GPIO_ENABLE
;
962 gpio1_enable
= GPIO1_ENABLE
;
964 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
965 lcd_puts(0, line
++, buf
);
966 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
967 lcd_puts(0, line
++, buf
);
968 snprintf(buf
, sizeof(buf
), "GPIO_FUNCTION: %08x", gpio_function
);
969 lcd_puts(0, line
++, buf
);
970 snprintf(buf
, sizeof(buf
), "GPIO_ENABLE: %08x", gpio_enable
);
971 lcd_puts(0, line
++, buf
);
973 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
974 lcd_puts(0, line
++, buf
);
975 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
976 lcd_puts(0, line
++, buf
);
977 snprintf(buf
, sizeof(buf
), "GPIO1_FUNCTION: %08x", gpio1_function
);
978 lcd_puts(0, line
++, buf
);
979 snprintf(buf
, sizeof(buf
), "GPIO1_ENABLE: %08x", gpio1_enable
);
980 lcd_puts(0, line
++, buf
);
982 adc_buttons
= adc_read(ADC_BUTTONS
);
983 adc_remote
= adc_read(ADC_REMOTE
);
984 battery_read_info(&adc_battery
, &adc_battery_voltage
,
986 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
987 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
988 button_scan_enabled() ? '+' : '-', adc_buttons
);
990 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
992 lcd_puts(0, line
++, buf
);
993 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
994 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
995 remote_detect() ? '+' : '-', adc_remote
);
997 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1000 lcd_puts(0, line
++, buf
);
1001 snprintf(buf
, sizeof(buf
), "ADC_BATTERY: %02x", adc_battery
);
1002 lcd_puts(0, line
++, buf
);
1003 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1004 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1005 adc_read(ADC_REMOTEDETECT
));
1006 lcd_puts(0, line
++, buf
);
1009 snprintf(buf
, 32, "Batt: %d.%02dV %d%% ", adc_battery_voltage
/ 100,
1010 adc_battery_voltage
% 100, adc_battery_level
);
1011 lcd_puts(0, line
++, buf
);
1013 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1014 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1015 lcd_puts(0, line
++, buf
);
1019 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1023 #elif CONFIG_CPU == PP5020 || CONFIG_CPU == PP5024
1025 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1026 unsigned int gpio_e
, gpio_f
, gpio_g
, gpio_h
;
1027 unsigned int gpio_i
, gpio_j
, gpio_k
, gpio_l
;
1032 lcd_setmargins(0, 0);
1033 lcd_clear_display();
1034 lcd_setfont(FONT_SYSFIXED
);
1038 gpio_a
= GPIOA_INPUT_VAL
;
1039 gpio_b
= GPIOB_INPUT_VAL
;
1040 gpio_c
= GPIOC_INPUT_VAL
;
1042 gpio_g
= GPIOG_INPUT_VAL
;
1043 gpio_h
= GPIOH_INPUT_VAL
;
1044 gpio_i
= GPIOI_INPUT_VAL
;
1047 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_G: %02x", gpio_a
, gpio_g
);
1048 lcd_puts(0, line
++, buf
);
1049 snprintf(buf
, sizeof(buf
), "GPIO_B: %02x GPIO_H: %02x", gpio_b
, gpio_h
);
1050 lcd_puts(0, line
++, buf
);
1051 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_I: %02x", gpio_c
, gpio_i
);
1052 lcd_puts(0, line
++, buf
);
1055 gpio_d
= GPIOD_INPUT_VAL
;
1056 gpio_e
= GPIOE_INPUT_VAL
;
1057 gpio_f
= GPIOF_INPUT_VAL
;
1059 gpio_j
= GPIOJ_INPUT_VAL
;
1060 gpio_k
= GPIOK_INPUT_VAL
;
1061 gpio_l
= GPIOL_INPUT_VAL
;
1063 snprintf(buf
, sizeof(buf
), "GPIO_D: %02x GPIO_J: %02x", gpio_d
, gpio_j
);
1064 lcd_puts(0, line
++, buf
);
1065 snprintf(buf
, sizeof(buf
), "GPIO_E: %02x GPIO_K: %02x", gpio_e
, gpio_k
);
1066 lcd_puts(0, line
++, buf
);
1067 snprintf(buf
, sizeof(buf
), "GPIO_F: %02x GPIO_L: %02x", gpio_f
, gpio_l
);
1068 lcd_puts(0, line
++, buf
);
1069 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1071 snprintf(buf
, sizeof(buf
), "ADC_BATTERY: %02x", adc_read(ADC_BATTERY
));
1072 lcd_puts(0, line
++, buf
);
1073 snprintf(buf
, sizeof(buf
), "ADC_UNKNOWN_1: %02x", adc_read(ADC_UNKNOWN_1
));
1074 lcd_puts(0, line
++, buf
);
1075 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_read(ADC_REMOTE
));
1076 lcd_puts(0, line
++, buf
);
1077 snprintf(buf
, sizeof(buf
), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD
));
1078 lcd_puts(0, line
++, buf
);
1079 #elif defined(SANSA_E200)
1081 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %02x", adc_read(ADC_BVDD
));
1082 lcd_puts(0, line
++, buf
);
1083 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %02x", adc_read(ADC_RTCSUP
));
1084 lcd_puts(0, line
++, buf
);
1085 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %02x", adc_read(ADC_UVDD
));
1086 lcd_puts(0, line
++, buf
);
1087 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %02x", adc_read(ADC_CHG_IN
));
1088 lcd_puts(0, line
++, buf
);
1089 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %02x", adc_read(ADC_CVDD
));
1090 lcd_puts(0, line
++, buf
);
1091 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %02x", adc_read(ADC_BATTEMP
));
1092 lcd_puts(0, line
++, buf
);
1093 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %02x", adc_read(ADC_MICSUP1
));
1094 lcd_puts(0, line
++, buf
);
1095 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %02x", adc_read(ADC_MICSUP2
));
1096 lcd_puts(0, line
++, buf
);
1097 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %02x", adc_read(ADC_VBE1
));
1098 lcd_puts(0, line
++, buf
);
1099 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %02x", adc_read(ADC_VBE2
));
1100 lcd_puts(0, line
++, buf
);
1101 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1: %02x", adc_read(ADC_I_MICSUP1
));
1102 lcd_puts(0, line
++, buf
);
1103 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2: %02x", adc_read(ADC_I_MICSUP2
));
1104 lcd_puts(0, line
++, buf
);
1105 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %02x", adc_read(ADC_VBAT
));
1106 lcd_puts(0, line
++, buf
);
1109 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1113 #elif CONFIG_CPU == PP5002
1114 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1119 lcd_setmargins(0, 0);
1120 lcd_clear_display();
1121 lcd_setfont(FONT_SYSFIXED
);
1125 gpio_a
= GPIOA_INPUT_VAL
;
1126 gpio_b
= GPIOB_INPUT_VAL
;
1127 gpio_c
= GPIOC_INPUT_VAL
;
1128 gpio_d
= GPIOD_INPUT_VAL
;
1131 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x", gpio_a
, gpio_b
);
1132 lcd_puts(0, line
++, buf
);
1133 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x", gpio_c
, gpio_d
);
1134 lcd_puts(0, line
++, buf
);
1137 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1140 #elif CONFIG_CPU == S3C2440
1144 lcd_setmargins(0, 0);
1145 lcd_clear_display();
1146 lcd_setfont(FONT_SYSFIXED
);
1151 snprintf(buf
, sizeof(buf
), "[Ports and Registers]"); lcd_puts(0, line
++, buf
);
1153 snprintf(buf
, sizeof(buf
), "GPACON: %08x GPBCON: %08x", GPACON
, GPBCON
); lcd_puts(0, line
++, buf
);
1154 snprintf(buf
, sizeof(buf
), "GPADAT: %08x GPBDAT: %08x", GPADAT
, GPBDAT
); lcd_puts(0, line
++, buf
);
1155 snprintf(buf
, sizeof(buf
), "GPAUP: %08x GPBUP: %08x", 0, GPBUP
); lcd_puts(0, line
++, buf
);
1156 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1157 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1158 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1160 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1161 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1162 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1164 snprintf(buf
, sizeof(buf
), "GPECON: %08x GPFCON: %08x", GPECON
, GPFCON
); lcd_puts(0, line
++, buf
);
1165 snprintf(buf
, sizeof(buf
), "GPEDAT: %08x GPFDAT: %08x", GPEDAT
, GPFDAT
); lcd_puts(0, line
++, buf
);
1166 snprintf(buf
, sizeof(buf
), "GPEUP: %08x GPFUP: %08x", GPEUP
, GPFUP
); lcd_puts(0, line
++, buf
);
1168 snprintf(buf
, sizeof(buf
), "GPGCON: %08x GPHCON: %08x", GPGCON
, GPHCON
); lcd_puts(0, line
++, buf
);
1169 snprintf(buf
, sizeof(buf
), "GPGDAT: %08x GPHDAT: %08x", GPGDAT
, GPHDAT
); lcd_puts(0, line
++, buf
);
1170 snprintf(buf
, sizeof(buf
), "GPGUP: %08x GPHUP: %08x", GPGUP
, GPHUP
); lcd_puts(0, line
++, buf
);
1172 snprintf(buf
, sizeof(buf
), "GPJCON: %08x", GPJCON
); lcd_puts(0, line
++, buf
);
1173 snprintf(buf
, sizeof(buf
), "GPJDAT: %08x", GPJDAT
); lcd_puts(0, line
++, buf
);
1174 snprintf(buf
, sizeof(buf
), "GPJUP: %08x", GPJUP
); lcd_puts(0, line
++, buf
);
1178 snprintf(buf
, sizeof(buf
), "SRCPND: %08x INTMOD: %08x", SRCPND
, INTMOD
); lcd_puts(0, line
++, buf
);
1179 snprintf(buf
, sizeof(buf
), "INTMSK: %08x INTPND: %08x", INTMSK
, INTPND
); lcd_puts(0, line
++, buf
);
1180 snprintf(buf
, sizeof(buf
), "CLKCON: %08x CLKSLOW: %08x", CLKCON
, CLKSLOW
); lcd_puts(0, line
++, buf
);
1182 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1188 #else /* !HAVE_LCD_BITMAP */
1189 bool dbg_ports(void)
1191 unsigned short porta
;
1192 unsigned short portb
;
1193 unsigned char portc
;
1196 int adc_battery_voltage
;
1199 lcd_clear_display();
1210 snprintf(buf
, 32, "PADR: %04x", porta
);
1213 snprintf(buf
, 32, "PBDR: %04x", portb
);
1216 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1219 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1222 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1225 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1228 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1231 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1234 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1237 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1241 lcd_puts(0, 0, buf
);
1243 battery_read_info(NULL
, &adc_battery_voltage
, NULL
);
1244 snprintf(buf
, 32, "Batt: %d.%02dV", adc_battery_voltage
/ 100,
1245 adc_battery_voltage
% 100);
1246 lcd_puts(0, 1, buf
);
1249 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1253 case ACTION_STD_CANCEL
:
1254 action_signalscreenchange();
1257 case ACTION_SETTINGS_DEC
:
1263 case ACTION_SETTINGS_INC
:
1272 #endif /* !HAVE_LCD_BITMAP */
1273 #endif /* !SIMULATOR */
1275 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1276 static bool dbg_cpufreq(void)
1282 #ifdef HAVE_LCD_BITMAP
1283 lcd_setmargins(0, 0);
1284 lcd_setfont(FONT_SYSFIXED
);
1286 lcd_clear_display();
1292 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1293 lcd_puts(0, line
++, buf
);
1295 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1296 lcd_puts(0, line
++, buf
);
1299 button
= get_action(CONTEXT_STD
,HZ
/10);
1303 case ACTION_STD_PREV
:
1307 case ACTION_STD_NEXT
:
1312 while (get_cpu_boost_counter() > 0)
1314 set_cpu_frequency(CPUFREQ_DEFAULT
);
1317 case ACTION_STD_CANCEL
:
1318 action_signalscreenchange();
1325 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1328 #ifdef HAVE_LCD_BITMAP
1330 * view_battery() shows a automatically scaled graph of the battery voltage
1331 * over time. Usable for estimating battery life / charging rate.
1332 * The power_history array is updated in power_thread of powermgmt.c.
1335 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1336 #define BAT_YSPACE (LCD_HEIGHT - 20)
1338 static bool view_battery(void)
1342 unsigned short maxv
, minv
;
1345 lcd_setmargins(0, 0);
1346 lcd_setfont(FONT_SYSFIXED
);
1350 lcd_clear_display();
1352 case 0: /* voltage history graph */
1353 /* Find maximum and minimum voltage for scaling */
1356 for (i
= 0; i
< BAT_LAST_VAL
; i
++) {
1357 if (power_history
[i
] > maxv
)
1358 maxv
= power_history
[i
];
1359 if (power_history
[i
] && (power_history
[i
] < minv
))
1361 minv
= power_history
[i
];
1365 if ((minv
< 1) || (minv
>= 65535))
1370 maxv
< 65535 ? maxv
++ : minv
--;
1372 snprintf(buf
, 30, "Battery %d.%02d", power_history
[0] / 100,
1373 power_history
[0] % 100);
1374 lcd_puts(0, 0, buf
);
1375 snprintf(buf
, 30, "scale %d.%02d-%d.%02d V",
1376 minv
/ 100, minv
% 100, maxv
/ 100, maxv
% 100);
1377 lcd_puts(0, 1, buf
);
1380 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1381 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1382 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1383 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1384 lcd_set_drawmode(DRMODE_SOLID
);
1385 lcd_vline(x
, LCD_HEIGHT
-1,
1386 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1392 case 1: /* status: */
1393 lcd_puts(0, 0, "Power status:");
1395 battery_read_info(NULL
, &y
, NULL
);
1396 snprintf(buf
, 30, "Battery: %d.%02d V", y
/ 100, y
% 100);
1397 lcd_puts(0, 1, buf
);
1398 #ifdef ADC_EXT_POWER
1399 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 10000;
1400 snprintf(buf
, 30, "External: %d.%02d V", y
/ 100, y
% 100);
1401 lcd_puts(0, 2, buf
);
1404 #if CONFIG_CHARGING == CHARGING_CONTROL
1405 snprintf(buf
, 30, "Chgr: %s %s",
1406 charger_inserted() ? "present" : "absent",
1407 charger_enabled
? "on" : "off");
1408 lcd_puts(0, 3, buf
);
1409 snprintf(buf
, 30, "short delta: %d", short_delta
);
1410 lcd_puts(0, 5, buf
);
1411 snprintf(buf
, 30, "long delta: %d", long_delta
);
1412 lcd_puts(0, 6, buf
);
1413 lcd_puts(0, 7, power_message
);
1414 snprintf(buf
, 30, "USB Inserted: %s",
1415 usb_inserted() ? "yes" : "no");
1416 lcd_puts(0, 8, buf
);
1417 #if defined IRIVER_H300_SERIES
1418 snprintf(buf
, 30, "USB Charging Enabled: %s",
1419 usb_charging_enabled() ? "yes" : "no");
1420 lcd_puts(0, 9, buf
);
1422 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1423 #if defined IPOD_NANO || defined IPOD_VIDEO
1424 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1425 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1426 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1427 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1428 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1430 snprintf(buf
, 30, "USB pwr: %s",
1431 usb_pwr
? "present" : "absent");
1432 lcd_puts(0, 3, buf
);
1433 snprintf(buf
, 30, "EXT pwr: %s",
1434 ext_pwr
? "present" : "absent");
1435 lcd_puts(0, 4, buf
);
1436 snprintf(buf
, 30, "Battery: %s",
1437 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1438 lcd_puts(0, 5, buf
);
1439 snprintf(buf
, 30, "Dock mode: %s",
1440 dock
? "enabled" : "disabled");
1441 lcd_puts(0, 6, buf
);
1442 snprintf(buf
, 30, "Headphone: %s",
1443 headphone
? "connected" : "disconnected");
1444 lcd_puts(0, 7, buf
);
1446 snprintf(buf
, 30, "Charger: %s",
1447 charger_inserted() ? "present" : "absent");
1448 lcd_puts(0, 3, buf
);
1450 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1451 #endif /* CONFIG_CHARGING */
1454 case 2: /* voltage deltas: */
1455 lcd_puts(0, 0, "Voltage deltas:");
1457 for (i
= 0; i
<= 6; i
++) {
1458 y
= power_history
[i
] - power_history
[i
+i
];
1459 snprintf(buf
, 30, "-%d min: %s%d.%02d V", i
,
1460 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 100,
1461 ((y
< 0) ? y
* -1 : y
) % 100);
1462 lcd_puts(0, i
+1, buf
);
1466 case 3: /* remaining time estimation: */
1468 #if CONFIG_CHARGING == CHARGING_CONTROL
1469 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1470 lcd_puts(0, 0, buf
);
1472 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1473 lcd_puts(0, 1, buf
);
1475 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1476 lcd_puts(0, 2, buf
);
1478 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1479 lcd_puts(0, 3, buf
);
1481 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1482 lcd_puts(0, 4, buf
);
1483 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1485 snprintf(buf
, 30, "Last PwrHist: %d.%02d V",
1486 power_history
[0] / 100,
1487 power_history
[0] % 100);
1488 lcd_puts(0, 5, buf
);
1490 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1491 lcd_puts(0, 6, buf
);
1493 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1494 lcd_puts(0, 7, buf
);
1500 switch(get_action(CONTEXT_SETTINGS
,HZ
/2))
1502 case ACTION_SETTINGS_DEC
:
1507 case ACTION_SETTINGS_INC
:
1512 case ACTION_STD_CANCEL
:
1513 action_signalscreenchange();
1520 #endif /* HAVE_LCD_BITMAP */
1525 static bool dbg_mmc_info(void)
1531 unsigned char pbuf
[32], pbuf2
[32];
1532 unsigned char card_name
[7];
1534 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1535 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1536 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1537 static const unsigned char *nsec_units
[] = { "ns", "µs", "ms" };
1538 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1539 "3.1-3.31", "4.0" };
1541 card_name
[6] = '\0';
1543 lcd_setmargins(0, 0);
1544 lcd_setfont(FONT_SYSFIXED
);
1548 card
= mmc_card_info(currval
/ 2);
1551 lcd_clear_display();
1552 snprintf(pbuf
, sizeof(pbuf
), "[MMC%d p%d]", currval
/ 2,
1554 lcd_puts(0, line
++, pbuf
);
1556 if (card
->initialized
)
1558 if (!(currval
% 2)) /* General info */
1562 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1563 snprintf(pbuf
, sizeof(pbuf
), "%s Rev %d.%d", card_name
,
1564 (int) mmc_extract_bits(card
->cid
, 72, 4),
1565 (int) mmc_extract_bits(card
->cid
, 76, 4));
1566 lcd_puts(0, line
++, pbuf
);
1567 snprintf(pbuf
, sizeof(pbuf
), "Prod: %d/%d",
1568 (int) mmc_extract_bits(card
->cid
, 112, 4),
1569 (int) mmc_extract_bits(card
->cid
, 116, 4) + 1997);
1570 lcd_puts(0, line
++, pbuf
);
1571 snprintf(pbuf
, sizeof(pbuf
), "Ser#: 0x%08lx",
1572 mmc_extract_bits(card
->cid
, 80, 32));
1573 lcd_puts(0, line
++, pbuf
);
1574 snprintf(pbuf
, sizeof(pbuf
), "M=%02x, O=%04x",
1575 (int) mmc_extract_bits(card
->cid
, 0, 8),
1576 (int) mmc_extract_bits(card
->cid
, 8, 16));
1577 lcd_puts(0, line
++, pbuf
);
1578 temp
= mmc_extract_bits(card
->csd
, 2, 4);
1579 snprintf(pbuf
, sizeof(pbuf
), "MMC v%s", temp
< 5 ?
1580 spec_vers
[temp
] : "?.?");
1581 lcd_puts(0, line
++, pbuf
);
1582 snprintf(pbuf
, sizeof(pbuf
), "Blocks: 0x%06lx", card
->numblocks
);
1583 lcd_puts(0, line
++, pbuf
);
1584 snprintf(pbuf
, sizeof(pbuf
), "Blksz.: %d P:%c%c", card
->blocksize
,
1585 mmc_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1586 mmc_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1587 lcd_puts(0, line
++, pbuf
);
1589 else /* Technical details */
1591 output_dyn_value(pbuf2
, sizeof pbuf2
, card
->speed
/ 1000,
1593 snprintf(pbuf
, sizeof pbuf
, "Speed: %s", pbuf2
);
1594 lcd_puts(0, line
++, pbuf
);
1596 output_dyn_value(pbuf2
, sizeof pbuf2
, card
->tsac
,
1598 snprintf(pbuf
, sizeof pbuf
, "Tsac: %s", pbuf2
);
1599 lcd_puts(0, line
++, pbuf
);
1601 snprintf(pbuf
, sizeof(pbuf
), "Nsac: %d clk", card
->nsac
);
1602 lcd_puts(0, line
++, pbuf
);
1603 snprintf(pbuf
, sizeof(pbuf
), "R2W: *%d", card
->r2w_factor
);
1604 lcd_puts(0, line
++, pbuf
);
1605 snprintf(pbuf
, sizeof(pbuf
), "IRmax: %d..%d mA",
1606 i_vmin
[mmc_extract_bits(card
->csd
, 66, 3)],
1607 i_vmax
[mmc_extract_bits(card
->csd
, 69, 3)]);
1608 lcd_puts(0, line
++, pbuf
);
1609 snprintf(pbuf
, sizeof(pbuf
), "IWmax: %d..%d mA",
1610 i_vmin
[mmc_extract_bits(card
->csd
, 72, 3)],
1611 i_vmax
[mmc_extract_bits(card
->csd
, 75, 3)]);
1612 lcd_puts(0, line
++, pbuf
);
1616 lcd_puts(0, line
++, "Not found!");
1620 switch (get_action(CONTEXT_SETTINGS
,HZ
/2))
1622 case ACTION_STD_CANCEL
:
1626 case ACTION_SETTINGS_DEC
:
1632 case ACTION_SETTINGS_INC
:
1639 action_signalscreenchange();
1642 #else /* !HAVE_MMC */
1643 static bool dbg_disk_info(void)
1649 const int max_page
= 11;
1650 unsigned short* identify_info
= ata_get_identify();
1651 bool timing_info_present
= false;
1652 char pio3
[2], pio4
[2];
1654 lcd_setmargins(0, 0);
1660 lcd_clear_display();
1661 #ifdef HAVE_LCD_BITMAP
1662 lcd_puts(0, y
++, "Disk info:");
1668 for (i
=0; i
< 20; i
++)
1669 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1671 /* kill trailing space */
1672 for (i
=39; i
&& buf
[i
]==' '; i
--)
1674 lcd_puts(0, y
++, "Model");
1675 lcd_puts_scroll(0, y
++, buf
);
1679 for (i
=0; i
< 4; i
++)
1680 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1682 lcd_puts(0, y
++, "Firmware");
1683 lcd_puts(0, y
++, buf
);
1687 snprintf(buf
, sizeof buf
, "%ld MB",
1688 ((unsigned long)identify_info
[61] << 16 |
1689 (unsigned long)identify_info
[60]) / 2048 );
1690 lcd_puts(0, y
++, "Size");
1691 lcd_puts(0, y
++, buf
);
1696 fat_size( IF_MV2(0,) NULL
, &free
);
1697 snprintf(buf
, sizeof buf
, "%ld MB", free
/ 1024 );
1698 lcd_puts(0, y
++, "Free");
1699 lcd_puts(0, y
++, buf
);
1704 snprintf(buf
, sizeof buf
, "%d ms", ata_spinup_time
* (1000/HZ
));
1705 lcd_puts(0, y
++, "Spinup time");
1706 lcd_puts(0, y
++, buf
);
1710 i
= identify_info
[83] & (1<<3);
1711 lcd_puts(0, y
++, "Power mgmt:");
1712 lcd_puts(0, y
++, i
? "enabled" : "unsupported");
1716 i
= identify_info
[83] & (1<<9);
1717 lcd_puts(0, y
++, "Noise mgmt:");
1718 lcd_puts(0, y
++, i
? "enabled" : "unsupported");
1722 i
= identify_info
[82] & (1<<6);
1723 lcd_puts(0, y
++, "Read-ahead:");
1724 lcd_puts(0, y
++, i
? "enabled" : "unsupported");
1728 timing_info_present
= identify_info
[53] & (1<<1);
1729 if(timing_info_present
) {
1732 lcd_puts(0, y
++, "PIO modes:");
1733 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1734 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1735 snprintf(buf
, 128, "0 1 2 %s %s", pio3
, pio4
);
1736 lcd_puts(0, y
++, buf
);
1738 lcd_puts(0, y
++, "No PIO mode info");
1743 timing_info_present
= identify_info
[53] & (1<<1);
1744 if(timing_info_present
) {
1745 lcd_puts(0, y
++, "Cycle times");
1746 snprintf(buf
, 128, "%dns/%dns",
1749 lcd_puts(0, y
++, buf
);
1751 lcd_puts(0, y
++, "No timing info");
1756 timing_info_present
= identify_info
[53] & (1<<1);
1757 if(timing_info_present
) {
1758 i
= identify_info
[49] & (1<<11);
1759 snprintf(buf
, 128, "IORDY support: %s", i
? "yes" : "no");
1760 lcd_puts(0, y
++, buf
);
1761 i
= identify_info
[49] & (1<<10);
1762 snprintf(buf
, 128, "IORDY disable: %s", i
? "yes" : "no");
1763 lcd_puts(0, y
++, buf
);
1765 lcd_puts(0, y
++, "No timing info");
1770 lcd_puts(0, y
++, "Cluster size");
1771 snprintf(buf
, 128, "%d bytes", fat_get_cluster_size(IF_MV(0)));
1772 lcd_puts(0, y
++, buf
);
1777 /* Wait for a key to be pushed */
1778 key
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1780 case ACTION_STD_CANCEL
:
1784 case ACTION_SETTINGS_DEC
:
1789 case ACTION_SETTINGS_INC
:
1790 if (++page
> max_page
)
1796 action_signalscreenchange();
1799 #endif /* !HAVE_MMC */
1800 #endif /* !SIMULATOR */
1802 #ifdef HAVE_DIRCACHE
1803 static bool dbg_dircache_info(void)
1809 lcd_setmargins(0, 0);
1810 lcd_setfont(FONT_SYSFIXED
);
1816 lcd_clear_display();
1817 snprintf(buf
, sizeof(buf
), "Cache initialized: %s",
1818 dircache_is_enabled() ? "Yes" : "No");
1819 lcd_puts(0, line
++, buf
);
1821 snprintf(buf
, sizeof(buf
), "Cache size: %d B",
1822 dircache_get_cache_size());
1823 lcd_puts(0, line
++, buf
);
1825 snprintf(buf
, sizeof(buf
), "Last size: %d B",
1826 global_status
.dircache_size
);
1827 lcd_puts(0, line
++, buf
);
1829 snprintf(buf
, sizeof(buf
), "Limit: %d B", DIRCACHE_LIMIT
);
1830 lcd_puts(0, line
++, buf
);
1832 snprintf(buf
, sizeof(buf
), "Reserve: %d/%d B",
1833 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1834 lcd_puts(0, line
++, buf
);
1836 snprintf(buf
, sizeof(buf
), "Scanning took: %d s",
1837 dircache_get_build_ticks() / HZ
);
1838 lcd_puts(0, line
++, buf
);
1840 snprintf(buf
, sizeof(buf
), "Entry count: %d",
1841 dircache_get_entry_count());
1842 lcd_puts(0, line
++, buf
);
1846 if (action_userabort(HZ
/2))
1853 #endif /* HAVE_DIRCACHE */
1855 #ifdef HAVE_LCD_BITMAP
1856 #ifdef HAVE_TAGCACHE
1857 static bool dbg_tagcache_info(void)
1862 struct tagcache_stat
*stat
;
1864 lcd_setmargins(0, 0);
1865 lcd_setfont(FONT_SYSFIXED
);
1871 lcd_clear_display();
1872 stat
= tagcache_get_stat();
1873 snprintf(buf
, sizeof(buf
), "Initialized: %s", stat
->initialized
? "Yes" : "No");
1874 lcd_puts(0, line
++, buf
);
1875 snprintf(buf
, sizeof(buf
), "DB Ready: %s", stat
->ready
? "Yes" : "No");
1876 lcd_puts(0, line
++, buf
);
1877 snprintf(buf
, sizeof(buf
), "RAM Cache: %s", stat
->ramcache
? "Yes" : "No");
1878 lcd_puts(0, line
++, buf
);
1879 snprintf(buf
, sizeof(buf
), "RAM: %d/%d B",
1880 stat
->ramcache_used
, stat
->ramcache_allocated
);
1881 lcd_puts(0, line
++, buf
);
1882 snprintf(buf
, sizeof(buf
), "Progress: %d%% (%d entries)",
1883 stat
->progress
, stat
->processed_entries
);
1884 lcd_puts(0, line
++, buf
);
1885 snprintf(buf
, sizeof(buf
), "Commit step: %d", stat
->commit_step
);
1886 lcd_puts(0, line
++, buf
);
1887 snprintf(buf
, sizeof(buf
), "Commit delayed: %s",
1888 stat
->commit_delayed
? "Yes" : "No");
1889 lcd_puts(0, line
++, buf
);
1893 if (action_userabort(HZ
/2))
1902 #if CONFIG_CPU == SH7034
1903 static bool dbg_save_roms(void)
1906 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1908 fd
= creat("/internal_rom_0000-FFFF.bin");
1911 write(fd
, (void *)0, 0x10000);
1915 fd
= creat("/internal_rom_2000000-203FFFF.bin");
1918 write(fd
, (void *)0x2000000, 0x40000);
1922 system_memory_guard(oldmode
);
1925 #elif defined CPU_COLDFIRE
1926 static bool dbg_save_roms(void)
1929 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1931 #if defined(IRIVER_H100_SERIES)
1932 fd
= creat("/internal_rom_000000-1FFFFF.bin");
1933 #elif defined(IRIVER_H300_SERIES)
1934 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1935 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
1936 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1940 write(fd
, (void *)0, FLASH_SIZE
);
1943 system_memory_guard(oldmode
);
1946 fd
= creat("/internal_eeprom.bin");
1950 char buf
[EEPROM_SIZE
];
1953 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
1955 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1957 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
1960 write(fd
, buf
, sizeof buf
);
1963 set_irq_level(old_irq_level
);
1971 #elif defined(CPU_PP) && !defined(SANSA_E200)
1972 static bool dbg_save_roms(void)
1976 fd
= creat("/internal_rom_000000-0FFFFF.bin");
1979 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1989 static bool dbg_fm_radio(void)
1994 lcd_setmargins(0, 0);
1996 fm_detected
= radio_hardware_present();
2002 lcd_clear_display();
2004 snprintf(buf
, sizeof buf
, "HW detected: %s", fm_detected
?"yes":"no");
2005 lcd_puts(0, row
++, buf
);
2006 #if (CONFIG_TUNER & LV24020LP)
2009 snprintf(buf
, sizeof buf
, "CTRL_STAT: %02X",
2010 sanyo_get(RADIO_ALL
) );
2011 lcd_puts(0, row
++, buf
);
2013 snprintf(buf
, sizeof buf
, "RADIO_STAT: %02X",
2014 sanyo_get(RADIO_REG_STAT
));
2015 lcd_puts(0, row
++, buf
);
2017 snprintf(buf
, sizeof buf
, "MSS_FM: %d kHz",
2018 (sanyo_get(RADIO_MSS_FM
) ) );
2019 lcd_puts(0, row
++, buf
);
2021 snprintf(buf
, sizeof buf
, "MSS_IF: %d Hz",
2022 (sanyo_get(RADIO_MSS_IF
) ) );
2023 lcd_puts(0, row
++, buf
);
2025 snprintf(buf
, sizeof buf
, "MSS_SD: %d Hz",
2026 (sanyo_get(RADIO_MSS_SD
) ) );
2027 lcd_puts(0, row
++, buf
);
2029 snprintf(buf
, sizeof buf
, "if_set: %d Hz",
2030 (sanyo_get(RADIO_IF_SET
) ) );
2031 lcd_puts(0, row
++, buf
);
2033 snprintf(buf
, sizeof buf
, "sd_set: %d Hz",
2034 (sanyo_get(RADIO_SD_SET
) ) );
2035 lcd_puts(0, row
++, buf
);
2038 #if (CONFIG_TUNER & S1A0903X01)
2039 snprintf(buf
, sizeof buf
, "Samsung regs: %08X",
2040 samsung_get(RADIO_ALL
));
2041 lcd_puts(0, row
++, buf
);
2043 #if (CONFIG_TUNER & TEA5767)
2045 struct philips_dbg_info info
;
2046 philips_dbg_info(&info
);
2048 snprintf(buf
, sizeof buf
, "Philips regs:");
2049 lcd_puts(0, row
++, buf
);
2051 snprintf(buf
, sizeof buf
, " Read: %02X %02X %02X %02X %02X",
2052 (unsigned)info
.read_regs
[0], (unsigned)info
.read_regs
[1],
2053 (unsigned)info
.read_regs
[2], (unsigned)info
.read_regs
[3],
2054 (unsigned)info
.read_regs
[4]);
2055 lcd_puts(0, row
++, buf
);
2057 snprintf(buf
, sizeof buf
, " Write: %02X %02X %02X %02X %02X",
2058 (unsigned)info
.write_regs
[0], (unsigned)info
.write_regs
[1],
2059 (unsigned)info
.write_regs
[2], (unsigned)info
.write_regs
[3],
2060 (unsigned)info
.write_regs
[4]);
2061 lcd_puts(0, row
++, buf
);
2066 if (action_userabort(HZ
))
2071 #endif /* CONFIG_TUNER */
2072 #endif /* !SIMULATOR */
2074 #ifdef HAVE_LCD_BITMAP
2075 extern bool do_screendump_instead_of_usb
;
2077 static bool dbg_screendump(void)
2079 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2080 gui_syncsplash(HZ
, "Screendump %s",
2081 do_screendump_instead_of_usb
?"enabled":"disabled");
2084 #endif /* HAVE_LCD_BITMAP */
2086 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2087 static bool dbg_set_memory_guard(void)
2089 static const struct opt_items names
[MAXMEMGUARD
] = {
2091 { "Flash ROM writes", -1 },
2092 { "Zero area (all)", -1 }
2094 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2096 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2097 system_memory_guard(mode
);
2101 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2103 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2105 extern volatile bool lcd_poweroff
;
2107 static bool dbg_lcd_power_off(void)
2109 lcd_setmargins(0, 0);
2115 lcd_clear_display();
2116 lcd_puts(0, 0, "LCD Power Off");
2118 lcd_puts(1, 1, "Yes");
2120 lcd_puts(1, 1, "No");
2124 button
= get_action(CONTEXT_STD
,HZ
/5);
2127 case ACTION_STD_PREV
:
2128 case ACTION_STD_NEXT
:
2129 lcd_poweroff
= !lcd_poweroff
;
2132 case ACTION_STD_CANCEL
:
2133 action_signalscreenchange();
2144 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2145 static bool dbg_write_eeprom(void)
2150 char buf
[EEPROM_SIZE
];
2153 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2157 rc
= read(fd
, buf
, EEPROM_SIZE
);
2159 if(rc
== EEPROM_SIZE
)
2161 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2163 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2165 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2167 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2169 set_irq_level(old_irq_level
);
2173 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2179 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2184 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2185 #ifdef CPU_BOOST_LOGGING
2186 static bool cpu_boost_log(void)
2189 int count
= cpu_boost_log_getcount();
2190 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2193 lcd_setmargins(0, 0);
2194 lcd_setfont(FONT_SYSFIXED
);
2195 str
= cpu_boost_log_getlog_first();
2198 lcd_clear_display();
2199 for(j
=0; j
<lines
; j
++,i
++)
2202 str
= cpu_boost_log_getlog_next();
2211 action_signalscreenchange();
2214 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2217 case ACTION_STD_PREV
:
2218 case ACTION_STD_NEXT
:
2221 case ACTION_STD_CANCEL
:
2228 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2229 lcd_setfont(FONT_UI
);
2230 action_signalscreenchange();
2237 /****** The menu *********/
2238 struct the_menu_item
{
2239 unsigned char *desc
; /* string or ID */
2240 bool (*function
) (void); /* return true if USB was connected */
2242 static const struct the_menu_item menuitems
[] = {
2243 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2244 { "LCD Power Off", dbg_lcd_power_off
},
2246 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2247 (defined(CPU_PP) && !defined(SANSA_E200))
2248 { "Dump ROM contents", dbg_save_roms
},
2250 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440
2251 { "View I/O ports", dbg_ports
},
2253 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2254 { "CPU frequency", dbg_cpufreq
},
2256 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2257 { "S/PDIF analyzer", dbg_spdif
},
2259 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2260 { "Catch mem accesses", dbg_set_memory_guard
},
2263 { "View OS stacks", dbg_os
},
2265 #ifdef HAVE_LCD_BITMAP
2267 { "View battery", view_battery
},
2269 { "Screendump", dbg_screendump
},
2272 { "View HW info", dbg_hw_info
},
2275 { "View partitions", dbg_partitions
},
2279 { "View MMC info", dbg_mmc_info
},
2281 { "View disk info", dbg_disk_info
},
2284 #ifdef HAVE_DIRCACHE
2285 { "View dircache info", dbg_dircache_info
},
2287 #ifdef HAVE_LCD_BITMAP
2288 #ifdef HAVE_TAGCACHE
2289 { "View database info", dbg_tagcache_info
},
2291 #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR)
2292 { "View audio thread", dbg_audio_thread
},
2295 { "pm histogram", peak_meter_histogram
},
2296 #endif /* PM_DEBUG */
2297 #endif /* HAVE_LCD_BITMAP */
2300 { "FM Radio", dbg_fm_radio
},
2303 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2304 { "Write back EEPROM", dbg_write_eeprom
},
2306 #ifdef ROCKBOX_HAS_LOGF
2307 {"logf", logfdisplay
},
2308 {"logfdump", logfdump
},
2310 #ifdef CPU_BOOST_LOGGING
2311 {"cpu_boost log",cpu_boost_log
},
2314 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2316 if (btn
== ACTION_STD_OK
)
2318 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2319 gui_synclist_draw(lists
);
2323 static char* dbg_menu_getname(int item
, void * data
, char *buffer
)
2325 (void)data
; (void)buffer
;
2326 return menuitems
[item
].desc
;
2328 bool debug_menu(void)
2330 dbg_list("Debug Menu",ARRAYLEN(menuitems
) , 1,
2331 menu_action_callback
,