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"
62 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
71 #ifdef HAVE_LCD_BITMAP
72 #include "scrollbar.h"
73 #include "peakmeter.h"
76 #if CONFIG_CODEC == SWCODEC
78 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
82 #ifdef IRIVER_H300_SERIES
83 #include "pcf50606.h" /* for pcf50606_read */
90 /*---------------------------------------------------*/
91 /* SPECIAL DEBUG STUFF */
92 /*---------------------------------------------------*/
93 extern struct thread_entry threads
[MAXTHREADS
];
95 static char thread_status_char(unsigned status
)
97 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
99 [0 ... THREAD_NUM_STATES
] = '?',
100 [STATE_RUNNING
] = 'R',
101 [STATE_BLOCKED
] = 'B',
102 [STATE_SLEEPING
] = 'S',
103 [STATE_BLOCKED_W_TMO
] = 'T',
104 [STATE_FROZEN
] = 'F',
105 [STATE_KILLED
] = 'K',
109 if (status
== STATE_BUSY
) /* Not a state index */
113 if (status
> THREAD_NUM_STATES
)
114 status
= THREAD_NUM_STATES
;
116 return thread_status_chars
[status
];
119 static char* threads_getname(int selected_item
, void * data
, char *buffer
)
123 struct thread_entry
*thread
= NULL
;
128 if (selected_item
< (int)NUM_CORES
)
130 usage
= idle_stack_usage(selected_item
);
131 snprintf(buffer
, MAX_PATH
, "Idle (%d): %2d%%", selected_item
, usage
);
135 selected_item
-= NUM_CORES
;
138 thread
= &threads
[selected_item
];
139 status
= thread_get_status(thread
);
141 if (status
== STATE_KILLED
)
143 snprintf(buffer
, MAX_PATH
, "%2d: ---", selected_item
);
147 thread_get_name(name
, 32, thread
);
148 usage
= thread_stack_usage(thread
);
150 snprintf(buffer
, MAX_PATH
,
151 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s",
153 IF_COP(thread
->core
,)
154 (status
== STATE_RUNNING
) ? '*' : ' ',
155 thread_status_char(status
),
156 IF_PRIO(thread
->priority
,)
161 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
164 #ifdef ROCKBOX_HAS_LOGF
165 if (action
== ACTION_STD_OK
)
167 int selpos
= gui_synclist_get_sel_pos(lists
);
169 if (selpos
>= NUM_CORES
)
170 remove_thread(&threads
[selpos
- NUM_CORES
]);
172 remove_thread(&threads
[selpos
]);
174 return ACTION_REDRAW
;
176 #endif /* ROCKBOX_HAS_LOGF */
180 static bool dbg_os(void)
182 struct simplelist_info info
;
183 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
187 MAXTHREADS
+NUM_CORES
,
190 #ifndef ROCKBOX_HAS_LOGF
191 info
.hide_selection
= true;
193 info
.action_callback
= dbg_threads_action_callback
;
194 info
.get_name
= threads_getname
;
195 return simplelist_show_list(&info
);
198 #ifdef HAVE_LCD_BITMAP
199 #if CONFIG_CODEC != SWCODEC
201 static bool dbg_audio_thread(void)
204 struct audio_debug d
;
206 lcd_setmargins(0, 0);
207 lcd_setfont(FONT_SYSFIXED
);
211 if (action_userabort(HZ
/5))
214 audio_get_debugdata(&d
);
218 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
220 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
222 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
224 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
226 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
228 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
231 /* Playable space left */
232 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
233 d
.playable_space
, HORIZONTAL
);
235 /* Show the watermark limit */
236 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
237 d
.low_watermark_level
, HORIZONTAL
);
239 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
240 d
.low_watermark_level
, d
.lowest_watermark_level
);
247 #endif /* !SIMULATOR */
248 #else /* CONFIG_CODEC == SWCODEC */
249 extern size_t filebuflen
;
250 /* This is a size_t, but call it a long so it puts a - when it's bad. */
252 static unsigned int ticks
, boost_ticks
;
254 static void dbg_audio_task(void)
257 if(FREQ
> CPUFREQ_NORMAL
)
264 static bool dbg_audio_thread(void)
271 size_t bufsize
= pcmbuf_get_bufsize();
272 int pcmbufdescs
= pcmbuf_descs();
274 ticks
= boost_ticks
= 0;
276 tick_add_task(dbg_audio_task
);
278 lcd_setmargins(0, 0);
279 lcd_setfont(FONT_SYSFIXED
);
282 button
= get_action(CONTEXT_STD
,HZ
/5);
285 case ACTION_STD_NEXT
:
288 case ACTION_STD_PREV
:
291 case ACTION_STD_CANCEL
:
298 bufused
= bufsize
- pcmbuf_free();
300 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
301 lcd_puts(0, line
++, buf
);
303 /* Playable space left */
304 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, bufsize
, 0, bufused
, HORIZONTAL
);
307 snprintf(buf
, sizeof(buf
), "codec: %8ld/%8ld", audio_filebufused(), (long) filebuflen
);
308 lcd_puts(0, line
++, buf
);
310 /* Playable space left */
311 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, filebuflen
, 0,
312 audio_filebufused(), HORIZONTAL
);
315 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
316 lcd_puts(0, line
++, buf
);
319 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
320 (int)((FREQ
+ 500000) / 1000000));
321 lcd_puts(0, line
++, buf
);
326 snprintf(buf
, sizeof(buf
), "boost ratio: %3d%%",
327 boost_ticks
* 100 / ticks
);
328 lcd_puts(0, line
++, buf
);
331 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
332 pcmbuf_used_descs(), pcmbufdescs
);
333 lcd_puts(0, line
++, buf
);
338 tick_remove_task(dbg_audio_task
);
342 #endif /* CONFIG_CODEC */
343 #endif /* HAVE_LCD_BITMAP */
346 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
347 /* Tool function to read the flash manufacturer and type, if available.
348 Only chips which could be reprogrammed in system will return values.
349 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
350 /* In IRAM to avoid problems when running directly from Flash */
351 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
352 unsigned addr1
, unsigned addr2
)
353 ICODE_ATTR
__attribute__((noinline
));
354 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
355 unsigned addr1
, unsigned addr2
)
358 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
359 unsigned manu
, id
; /* read values when in ID mode */
361 #if CONFIG_CPU == SH7034
362 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
363 #elif defined(CPU_COLDFIRE)
364 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
366 int old_level
; /* saved interrupt level */
368 not_manu
= flash
[0]; /* read the normal content */
369 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
371 /* disable interrupts, prevent any stray flash access */
372 old_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
374 flash
[addr1
] = 0xAA; /* enter command mode */
376 flash
[addr1
] = 0x90; /* ID command */
377 /* Atmel wants 20ms pause here */
378 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
380 manu
= flash
[0]; /* read the IDs */
383 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
384 /* Atmel wants 20ms pause here */
385 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
387 set_irq_level(old_level
); /* enable interrupts again */
389 /* I assume success if the obtained values are different from
390 the normal flash content. This is not perfectly bulletproof, they
391 could theoretically be the same by chance, causing us to fail. */
392 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
394 *p_manufacturer
= manu
; /* return the results */
396 return true; /* success */
398 return false; /* fail */
400 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
404 static int perfcheck(void)
410 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
413 "ldr r0, [%[timr]] \n"
414 "add r0, r0, %[tmo] \n"
416 "add %[res], %[res], #1 \n"
417 "ldr r1, [%[timr]] \n"
420 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
424 [timr
]"r"(&USEC_TIMER
),
426 #if CONFIG_CPU == PP5002
428 #else /* PP5020/5022/5024 */
439 #ifdef HAVE_LCD_BITMAP
440 static bool dbg_hw_info(void)
442 #if CONFIG_CPU == SH7034
444 int bitmask
= HW_MASK
;
445 int rom_version
= ROM_VERSION
;
446 unsigned manu
, id
; /* flash IDs */
447 bool got_id
; /* flag if we managed to get the flash IDs */
448 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
449 bool has_bootrom
; /* flag for boot ROM present */
450 int oldmode
; /* saved memory guard mode */
452 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
454 /* get flash ROM type */
455 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
457 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
459 /* check if the boot ROM area is a flash mirror */
460 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
461 if (has_bootrom
) /* if ROM and Flash different */
463 /* calculate CRC16 checksum of boot ROM */
464 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
467 system_memory_guard(oldmode
); /* re-enable memory guard */
469 lcd_setmargins(0, 0);
470 lcd_setfont(FONT_SYSFIXED
);
473 lcd_puts(0, 0, "[Hardware info]");
475 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
478 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
482 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
484 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
489 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
490 snprintf(buf
, 32, "Boot ROM: V1");
492 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
496 snprintf(buf
, 32, "Boot ROM: none");
502 while (!(action_userabort(TIMEOUT_BLOCK
)));
504 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
506 unsigned manu
, id
; /* flash IDs */
507 int got_id
; /* flag if we managed to get the flash IDs */
508 int oldmode
; /* saved memory guard mode */
511 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
513 /* get flash ROM type */
514 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
516 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
518 system_memory_guard(oldmode
); /* re-enable memory guard */
520 lcd_setmargins(0, 0);
521 lcd_setfont(FONT_SYSFIXED
);
524 lcd_puts(0, line
++, "[Hardware info]");
527 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
529 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
530 lcd_puts(0, line
++, buf
);
536 lcd_puts(0, ++line
, "Serial Number:");
538 got_id
= ds2411_read_id(&id
);
540 if (got_id
== DS2411_OK
)
542 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
543 lcd_puts(0, ++line
, buf
);
544 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
545 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
546 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
547 lcd_puts(0, ++line
, buf
);
548 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
552 snprintf(buf
, 32, "READ ERR=%d", got_id
);
555 lcd_puts(0, ++line
, buf
);
561 while (!(action_userabort(TIMEOUT_BLOCK
)));
563 #elif defined(CPU_PP502x)
566 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
567 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
568 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
569 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
571 lcd_setmargins(0, 0);
572 lcd_setfont(FONT_SYSFIXED
);
575 lcd_puts(0, line
++, "[Hardware info]");
578 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
579 lcd_puts(0, line
++, buf
);
583 extern int lcd_type
; /* Defined in lcd-colornano.c */
585 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
586 lcd_puts(0, line
++, buf
);
589 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
590 lcd_puts(0, line
++, buf
);
592 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
593 lcd_puts(0, line
++, buf
);
597 while (!(action_userabort(TIMEOUT_BLOCK
)));
599 #elif CONFIG_CPU == PP5002
603 lcd_setmargins(0, 0);
604 lcd_setfont(FONT_SYSFIXED
);
607 lcd_puts(0, line
++, "[Hardware info]");
610 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
611 lcd_puts(0, line
++, buf
);
614 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
615 lcd_puts(0, line
++, buf
);
619 while (!(action_userabort(TIMEOUT_BLOCK
)));
621 #endif /* CONFIG_CPU */
624 #else /* !HAVE_LCD_BITMAP */
625 static bool dbg_hw_info(void)
630 int rom_version
= ROM_VERSION
;
631 unsigned manu
, id
; /* flash IDs */
632 bool got_id
; /* flag if we managed to get the flash IDs */
633 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
634 bool has_bootrom
; /* flag for boot ROM present */
635 int oldmode
; /* saved memory guard mode */
637 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
639 /* get flash ROM type */
640 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
642 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
644 /* check if the boot ROM area is a flash mirror */
645 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
646 if (has_bootrom
) /* if ROM and Flash different */
648 /* calculate CRC16 checksum of boot ROM */
649 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
652 system_memory_guard(oldmode
); /* re-enable memory guard */
656 lcd_puts(0, 0, "[HW Info]");
662 snprintf(buf
, 32, "ROM: %d.%02d",
663 rom_version
/100, rom_version
%100);
667 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
669 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
674 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
675 snprintf(buf
, 32, "BootROM: V1");
676 else if (rom_crc
== 0x358099E8)
677 snprintf(buf
, 32, "BootROM: V2");
678 /* alternative boot ROM found in one single player so far */
680 snprintf(buf
, 32, "R: %08x", rom_crc
);
683 snprintf(buf
, 32, "BootROM: no");
689 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
693 case ACTION_STD_CANCEL
:
696 case ACTION_SETTINGS_DEC
:
702 case ACTION_SETTINGS_INC
:
711 #endif /* !HAVE_LCD_BITMAP */
712 #endif /* !SIMULATOR */
715 static char* dbg_partitions_getname(int selected_item
, void * data
, char *buffer
)
718 int partition
= selected_item
/2;
719 struct partinfo
* p
= disk_partinfo(partition
);
722 snprintf(buffer
, MAX_PATH
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
726 snprintf(buffer
, MAX_PATH
, "P%d: S:%lx", partition
, p
->start
);
731 bool dbg_partitions(void)
733 struct simplelist_info info
;
734 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
735 info
.selection_size
= 2;
736 info
.hide_selection
= true;
737 info
.get_name
= dbg_partitions_getname
;
738 return simplelist_show_list(&info
);
742 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
743 static bool dbg_spdif(void)
747 unsigned int control
;
752 unsigned int interruptstat
;
753 bool valnogood
, symbolerr
, parityerr
;
756 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
757 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
759 lcd_setmargins(0, 0);
761 lcd_setfont(FONT_SYSFIXED
);
763 #ifdef HAVE_SPDIF_POWER
764 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
771 control
= EBU1RCVCCHANNEL1
;
772 interruptstat
= INTERRUPTSTAT
;
773 INTERRUPTCLEAR
= 0x03c00000;
775 valnogood
= (interruptstat
& 0x01000000)?true:false;
776 symbolerr
= (interruptstat
& 0x00800000)?true:false;
777 parityerr
= (interruptstat
& 0x00400000)?true:false;
779 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
782 parityerr
?"--":"OK");
783 lcd_puts(0, line
++, buf
);
785 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
786 lcd_puts(0, line
++, buf
);
791 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
792 x
, x
?"Professional":"Consumer");
793 lcd_puts(0, line
++, buf
);
795 x
= (control
>> 30) & 1;
796 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
797 x
, x
?"Non-PCM":"PCM");
798 lcd_puts(0, line
++, buf
);
800 x
= (control
>> 29) & 1;
801 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
802 x
, x
?"Permitted":"Inhibited");
803 lcd_puts(0, line
++, buf
);
805 x
= (control
>> 27) & 7;
818 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
819 lcd_puts(0, line
++, buf
);
821 x
= (control
>> 24) & 3;
822 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
823 lcd_puts(0, line
++, buf
);
825 category
= (control
>> 17) & 127;
837 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
838 lcd_puts(0, line
++, buf
);
840 x
= (control
>> 16) & 1;
842 if(((category
& 0x70) == 0x10) ||
843 ((category
& 0x70) == 0x40) ||
844 ((category
& 0x78) == 0x38))
846 generation
= !generation
;
848 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
849 x
, generation
?"Original":"No ind.");
850 lcd_puts(0, line
++, buf
);
852 x
= (control
>> 12) & 15;
853 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
854 lcd_puts(0, line
++, buf
);
856 x
= (control
>> 8) & 15;
872 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
873 lcd_puts(0, line
++, buf
);
875 x
= (control
>> 4) & 15;
888 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
889 lcd_puts(0, line
++, buf
);
891 x
= (control
>> 2) & 3;
892 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
893 lcd_puts(0, line
++, buf
);
897 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
898 spdif_measure_frequency());
899 lcd_puts(0, line
++, buf
);
904 if (action_userabort(HZ
/10))
908 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
910 #ifdef HAVE_SPDIF_POWER
911 spdif_power_enable(global_settings
.spdif_enable
);
916 #endif /* CPU_COLDFIRE */
919 #ifdef HAVE_LCD_BITMAP
920 /* button definitions */
921 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
922 (CONFIG_KEYPAD == IRIVER_H300_PAD)
923 # define DEBUG_CANCEL BUTTON_OFF
925 #elif CONFIG_KEYPAD == RECORDER_PAD
926 # define DEBUG_CANCEL BUTTON_OFF
928 #elif CONFIG_KEYPAD == ONDIO_PAD
929 # define DEBUG_CANCEL BUTTON_MENU
931 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
932 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
933 (CONFIG_KEYPAD == IPOD_4G_PAD)
934 # define DEBUG_CANCEL BUTTON_MENU
936 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
937 # define DEBUG_CANCEL BUTTON_PLAY
939 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
940 # define DEBUG_CANCEL BUTTON_REC
942 #elif CONFIG_KEYPAD == GIGABEAT_PAD
943 # define DEBUG_CANCEL BUTTON_A
945 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
946 # define DEBUG_CANCEL BUTTON_REW
948 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
949 (CONFIG_KEYPAD == SANSA_C200_PAD)
950 # define DEBUG_CANCEL BUTTON_LEFT
951 #endif /* key definitios */
956 #if CONFIG_CPU == SH7034
957 unsigned short porta
;
958 unsigned short portb
;
961 int adc_battery_voltage
, adc_battery_level
;
963 lcd_setfont(FONT_SYSFIXED
);
964 lcd_setmargins(0, 0);
973 snprintf(buf
, 32, "PADR: %04x", porta
);
975 snprintf(buf
, 32, "PBDR: %04x", portb
);
978 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
980 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
982 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
984 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
987 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
988 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
989 adc_battery_voltage
% 1000, adc_battery_level
);
993 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
996 #elif defined(CPU_COLDFIRE)
997 unsigned int gpio_out
;
998 unsigned int gpio1_out
;
999 unsigned int gpio_read
;
1000 unsigned int gpio1_read
;
1001 unsigned int gpio_function
;
1002 unsigned int gpio1_function
;
1003 unsigned int gpio_enable
;
1004 unsigned int gpio1_enable
;
1005 int adc_buttons
, adc_remote
;
1006 int adc_battery_voltage
, adc_battery_level
;
1010 lcd_setmargins(0, 0);
1011 lcd_clear_display();
1012 lcd_setfont(FONT_SYSFIXED
);
1017 gpio_read
= GPIO_READ
;
1018 gpio1_read
= GPIO1_READ
;
1019 gpio_out
= GPIO_OUT
;
1020 gpio1_out
= GPIO1_OUT
;
1021 gpio_function
= GPIO_FUNCTION
;
1022 gpio1_function
= GPIO1_FUNCTION
;
1023 gpio_enable
= GPIO_ENABLE
;
1024 gpio1_enable
= GPIO1_ENABLE
;
1026 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1027 lcd_puts(0, line
++, buf
);
1028 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1029 lcd_puts(0, line
++, buf
);
1030 snprintf(buf
, sizeof(buf
), "GPIO_FUNCTION: %08x", gpio_function
);
1031 lcd_puts(0, line
++, buf
);
1032 snprintf(buf
, sizeof(buf
), "GPIO_ENABLE: %08x", gpio_enable
);
1033 lcd_puts(0, line
++, buf
);
1035 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1036 lcd_puts(0, line
++, buf
);
1037 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1038 lcd_puts(0, line
++, buf
);
1039 snprintf(buf
, sizeof(buf
), "GPIO1_FUNCTION: %08x", gpio1_function
);
1040 lcd_puts(0, line
++, buf
);
1041 snprintf(buf
, sizeof(buf
), "GPIO1_ENABLE: %08x", gpio1_enable
);
1042 lcd_puts(0, line
++, buf
);
1044 adc_buttons
= adc_read(ADC_BUTTONS
);
1045 adc_remote
= adc_read(ADC_REMOTE
);
1046 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1047 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1048 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1049 button_scan_enabled() ? '+' : '-', adc_buttons
);
1051 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1053 lcd_puts(0, line
++, buf
);
1054 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1055 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1056 remote_detect() ? '+' : '-', adc_remote
);
1058 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1060 lcd_puts(0, line
++, buf
);
1061 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1062 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1063 adc_read(ADC_REMOTEDETECT
));
1064 lcd_puts(0, line
++, buf
);
1067 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1068 adc_battery_voltage
% 1000, adc_battery_level
);
1069 lcd_puts(0, line
++, buf
);
1071 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1072 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1073 lcd_puts(0, line
++, buf
);
1077 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1081 #elif defined(CPU_PP502x)
1083 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1084 unsigned int gpio_e
, gpio_f
, gpio_g
, gpio_h
;
1085 unsigned int gpio_i
, gpio_j
, gpio_k
, gpio_l
;
1090 lcd_setmargins(0, 0);
1091 lcd_clear_display();
1092 lcd_setfont(FONT_SYSFIXED
);
1096 gpio_a
= GPIOA_INPUT_VAL
;
1097 gpio_b
= GPIOB_INPUT_VAL
;
1098 gpio_c
= GPIOC_INPUT_VAL
;
1100 gpio_g
= GPIOG_INPUT_VAL
;
1101 gpio_h
= GPIOH_INPUT_VAL
;
1102 gpio_i
= GPIOI_INPUT_VAL
;
1105 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_G: %02x", gpio_a
, gpio_g
);
1106 lcd_puts(0, line
++, buf
);
1107 snprintf(buf
, sizeof(buf
), "GPIO_B: %02x GPIO_H: %02x", gpio_b
, gpio_h
);
1108 lcd_puts(0, line
++, buf
);
1109 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_I: %02x", gpio_c
, gpio_i
);
1110 lcd_puts(0, line
++, buf
);
1112 gpio_d
= GPIOD_INPUT_VAL
;
1113 gpio_e
= GPIOE_INPUT_VAL
;
1114 gpio_f
= GPIOF_INPUT_VAL
;
1116 gpio_j
= GPIOJ_INPUT_VAL
;
1117 gpio_k
= GPIOK_INPUT_VAL
;
1118 gpio_l
= GPIOL_INPUT_VAL
;
1120 snprintf(buf
, sizeof(buf
), "GPIO_D: %02x GPIO_J: %02x", gpio_d
, gpio_j
);
1121 lcd_puts(0, line
++, buf
);
1122 snprintf(buf
, sizeof(buf
), "GPIO_E: %02x GPIO_K: %02x", gpio_e
, gpio_k
);
1123 lcd_puts(0, line
++, buf
);
1124 snprintf(buf
, sizeof(buf
), "GPIO_F: %02x GPIO_L: %02x", gpio_f
, gpio_l
);
1125 lcd_puts(0, line
++, buf
);
1128 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1129 lcd_puts(0, line
++, buf
);
1130 snprintf(buf
, sizeof(buf
), "CLOCK_SRC: %08lx", CLOCK_SOURCE
);
1131 lcd_puts(0, line
++, buf
);
1132 snprintf(buf
, sizeof(buf
), "CLCD_CLK_SRC: %08lx", CLCD_CLOCK_SRC
);
1133 lcd_puts(0, line
++, buf
);
1134 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1135 lcd_puts(0, line
++, buf
);
1136 snprintf(buf
, sizeof(buf
), "PLL_STATUS: %08lx", PLL_STATUS
);
1137 lcd_puts(0, line
++, buf
);
1138 snprintf(buf
, sizeof(buf
), "DEV_TIMING1: %08lx", DEV_TIMING1
);
1139 lcd_puts(0, line
++, buf
);
1141 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1143 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x", adc_read(ADC_BATTERY
),
1144 adc_read(ADC_UNKNOWN_1
));
1145 lcd_puts(0, line
++, buf
);
1146 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x", adc_read(ADC_REMOTE
),
1147 adc_read(ADC_SCROLLPAD
));
1148 lcd_puts(0, line
++, buf
);
1149 #elif defined(SANSA_E200)
1151 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %02x", adc_read(ADC_BVDD
));
1152 lcd_puts(0, line
++, buf
);
1153 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %02x", adc_read(ADC_RTCSUP
));
1154 lcd_puts(0, line
++, buf
);
1155 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %02x", adc_read(ADC_UVDD
));
1156 lcd_puts(0, line
++, buf
);
1157 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %02x", adc_read(ADC_CHG_IN
));
1158 lcd_puts(0, line
++, buf
);
1159 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %02x", adc_read(ADC_CVDD
));
1160 lcd_puts(0, line
++, buf
);
1161 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %02x", adc_read(ADC_BATTEMP
));
1162 lcd_puts(0, line
++, buf
);
1163 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %02x", adc_read(ADC_MICSUP1
));
1164 lcd_puts(0, line
++, buf
);
1165 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %02x", adc_read(ADC_MICSUP2
));
1166 lcd_puts(0, line
++, buf
);
1167 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %02x", adc_read(ADC_VBE1
));
1168 lcd_puts(0, line
++, buf
);
1169 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %02x", adc_read(ADC_VBE2
));
1170 lcd_puts(0, line
++, buf
);
1171 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1: %02x", adc_read(ADC_I_MICSUP1
));
1172 lcd_puts(0, line
++, buf
);
1173 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2: %02x", adc_read(ADC_I_MICSUP2
));
1174 lcd_puts(0, line
++, buf
);
1175 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %02x", adc_read(ADC_VBAT
));
1176 lcd_puts(0, line
++, buf
);
1179 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1183 #elif CONFIG_CPU == PP5002
1184 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1189 lcd_setmargins(0, 0);
1190 lcd_clear_display();
1191 lcd_setfont(FONT_SYSFIXED
);
1195 gpio_a
= GPIOA_INPUT_VAL
;
1196 gpio_b
= GPIOB_INPUT_VAL
;
1197 gpio_c
= GPIOC_INPUT_VAL
;
1198 gpio_d
= GPIOD_INPUT_VAL
;
1201 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x", gpio_a
, gpio_b
);
1202 lcd_puts(0, line
++, buf
);
1203 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x", gpio_c
, gpio_d
);
1204 lcd_puts(0, line
++, buf
);
1206 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1207 lcd_puts(0, line
++, buf
);
1208 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1209 lcd_puts(0, line
++, buf
);
1210 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1211 lcd_puts(0, line
++, buf
);
1212 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1213 lcd_puts(0, line
++, buf
);
1214 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1215 lcd_puts(0, line
++, buf
);
1216 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1217 lcd_puts(0, line
++, buf
);
1218 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1219 lcd_puts(0, line
++, buf
);
1220 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1221 lcd_puts(0, line
++, buf
);
1224 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1227 #elif CONFIG_CPU == S3C2440
1231 lcd_setmargins(0, 0);
1232 lcd_clear_display();
1233 lcd_setfont(FONT_SYSFIXED
);
1238 snprintf(buf
, sizeof(buf
), "[Ports and Registers]"); lcd_puts(0, line
++, buf
);
1240 snprintf(buf
, sizeof(buf
), "GPACON: %08x GPBCON: %08x", GPACON
, GPBCON
); lcd_puts(0, line
++, buf
);
1241 snprintf(buf
, sizeof(buf
), "GPADAT: %08x GPBDAT: %08x", GPADAT
, GPBDAT
); lcd_puts(0, line
++, buf
);
1242 snprintf(buf
, sizeof(buf
), "GPAUP: %08x GPBUP: %08x", 0, GPBUP
); lcd_puts(0, line
++, buf
);
1243 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1244 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1245 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1247 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1248 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1249 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1251 snprintf(buf
, sizeof(buf
), "GPECON: %08x GPFCON: %08x", GPECON
, GPFCON
); lcd_puts(0, line
++, buf
);
1252 snprintf(buf
, sizeof(buf
), "GPEDAT: %08x GPFDAT: %08x", GPEDAT
, GPFDAT
); lcd_puts(0, line
++, buf
);
1253 snprintf(buf
, sizeof(buf
), "GPEUP: %08x GPFUP: %08x", GPEUP
, GPFUP
); lcd_puts(0, line
++, buf
);
1255 snprintf(buf
, sizeof(buf
), "GPGCON: %08x GPHCON: %08x", GPGCON
, GPHCON
); lcd_puts(0, line
++, buf
);
1256 snprintf(buf
, sizeof(buf
), "GPGDAT: %08x GPHDAT: %08x", GPGDAT
, GPHDAT
); lcd_puts(0, line
++, buf
);
1257 snprintf(buf
, sizeof(buf
), "GPGUP: %08x GPHUP: %08x", GPGUP
, GPHUP
); lcd_puts(0, line
++, buf
);
1259 snprintf(buf
, sizeof(buf
), "GPJCON: %08x", GPJCON
); lcd_puts(0, line
++, buf
);
1260 snprintf(buf
, sizeof(buf
), "GPJDAT: %08x", GPJDAT
); lcd_puts(0, line
++, buf
);
1261 snprintf(buf
, sizeof(buf
), "GPJUP: %08x", GPJUP
); lcd_puts(0, line
++, buf
);
1265 snprintf(buf
, sizeof(buf
), "SRCPND: %08x INTMOD: %08x", SRCPND
, INTMOD
); lcd_puts(0, line
++, buf
);
1266 snprintf(buf
, sizeof(buf
), "INTMSK: %08x INTPND: %08x", INTMSK
, INTPND
); lcd_puts(0, line
++, buf
);
1267 snprintf(buf
, sizeof(buf
), "CLKCON: %08x CLKSLOW: %08x", CLKCON
, CLKSLOW
); lcd_puts(0, line
++, buf
);
1268 snprintf(buf
, sizeof(buf
), "MPLLCON: %08x UPLLCON: %08x", MPLLCON
, UPLLCON
); lcd_puts(0, line
++, buf
);
1269 snprintf(buf
, sizeof(buf
), "CLKDIVN: %08x", CLKDIVN
); lcd_puts(0, line
++, buf
);
1272 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1278 #else /* !HAVE_LCD_BITMAP */
1279 bool dbg_ports(void)
1281 unsigned short porta
;
1282 unsigned short portb
;
1283 unsigned char portc
;
1286 int adc_battery_voltage
;
1289 lcd_clear_display();
1300 snprintf(buf
, 32, "PADR: %04x", porta
);
1303 snprintf(buf
, 32, "PBDR: %04x", portb
);
1306 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1309 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1312 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1315 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1318 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1321 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1324 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1327 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1331 lcd_puts(0, 0, buf
);
1333 battery_read_info(&adc_battery_voltage
, NULL
);
1334 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1335 adc_battery_voltage
% 1000);
1336 lcd_puts(0, 1, buf
);
1339 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1343 case ACTION_STD_CANCEL
:
1346 case ACTION_SETTINGS_DEC
:
1352 case ACTION_SETTINGS_INC
:
1361 #endif /* !HAVE_LCD_BITMAP */
1362 #endif /* !SIMULATOR */
1364 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1365 static bool dbg_cpufreq(void)
1371 #ifdef HAVE_LCD_BITMAP
1372 lcd_setmargins(0, 0);
1373 lcd_setfont(FONT_SYSFIXED
);
1375 lcd_clear_display();
1381 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1382 lcd_puts(0, line
++, buf
);
1384 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1385 lcd_puts(0, line
++, buf
);
1388 button
= get_action(CONTEXT_STD
,HZ
/10);
1392 case ACTION_STD_PREV
:
1396 case ACTION_STD_NEXT
:
1401 while (get_cpu_boost_counter() > 0)
1403 set_cpu_frequency(CPUFREQ_DEFAULT
);
1406 case ACTION_STD_CANCEL
:
1413 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1416 #ifdef HAVE_LCD_BITMAP
1418 * view_battery() shows a automatically scaled graph of the battery voltage
1419 * over time. Usable for estimating battery life / charging rate.
1420 * The power_history array is updated in power_thread of powermgmt.c.
1423 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1424 #define BAT_YSPACE (LCD_HEIGHT - 20)
1426 static bool view_battery(void)
1430 unsigned short maxv
, minv
;
1433 lcd_setmargins(0, 0);
1434 lcd_setfont(FONT_SYSFIXED
);
1438 lcd_clear_display();
1440 case 0: /* voltage history graph */
1441 /* Find maximum and minimum voltage for scaling */
1442 minv
= power_history
[0];
1444 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1445 if (power_history
[i
] > maxv
)
1446 maxv
= power_history
[i
];
1447 if (power_history
[i
] < minv
)
1448 minv
= power_history
[i
];
1451 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1452 power_history
[0] % 1000);
1453 lcd_puts(0, 0, buf
);
1454 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1455 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1456 lcd_puts(0, 1, buf
);
1459 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1460 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1461 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1462 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1463 lcd_set_drawmode(DRMODE_SOLID
);
1464 lcd_vline(x
, LCD_HEIGHT
-1,
1465 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1471 case 1: /* status: */
1472 lcd_puts(0, 0, "Power status:");
1474 battery_read_info(&y
, NULL
);
1475 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1476 lcd_puts(0, 1, buf
);
1477 #ifdef ADC_EXT_POWER
1478 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1479 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1480 lcd_puts(0, 2, buf
);
1483 #if CONFIG_CHARGING == CHARGING_CONTROL
1484 snprintf(buf
, 30, "Chgr: %s %s",
1485 charger_inserted() ? "present" : "absent",
1486 charger_enabled
? "on" : "off");
1487 lcd_puts(0, 3, buf
);
1488 snprintf(buf
, 30, "short delta: %d", short_delta
);
1489 lcd_puts(0, 5, buf
);
1490 snprintf(buf
, 30, "long delta: %d", long_delta
);
1491 lcd_puts(0, 6, buf
);
1492 lcd_puts(0, 7, power_message
);
1493 snprintf(buf
, 30, "USB Inserted: %s",
1494 usb_inserted() ? "yes" : "no");
1495 lcd_puts(0, 8, buf
);
1496 #if defined IRIVER_H300_SERIES
1497 snprintf(buf
, 30, "USB Charging Enabled: %s",
1498 usb_charging_enabled() ? "yes" : "no");
1499 lcd_puts(0, 9, buf
);
1501 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1502 #if defined IPOD_NANO || defined IPOD_VIDEO
1503 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1504 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1505 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1506 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1507 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1509 snprintf(buf
, 30, "USB pwr: %s",
1510 usb_pwr
? "present" : "absent");
1511 lcd_puts(0, 3, buf
);
1512 snprintf(buf
, 30, "EXT pwr: %s",
1513 ext_pwr
? "present" : "absent");
1514 lcd_puts(0, 4, buf
);
1515 snprintf(buf
, 30, "Battery: %s",
1516 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1517 lcd_puts(0, 5, buf
);
1518 snprintf(buf
, 30, "Dock mode: %s",
1519 dock
? "enabled" : "disabled");
1520 lcd_puts(0, 6, buf
);
1521 snprintf(buf
, 30, "Headphone: %s",
1522 headphone
? "connected" : "disconnected");
1523 lcd_puts(0, 7, buf
);
1525 snprintf(buf
, 30, "Charger: %s",
1526 charger_inserted() ? "present" : "absent");
1527 lcd_puts(0, 3, buf
);
1529 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1530 #endif /* CONFIG_CHARGING */
1533 case 2: /* voltage deltas: */
1534 lcd_puts(0, 0, "Voltage deltas:");
1536 for (i
= 0; i
<= 6; i
++) {
1537 y
= power_history
[i
] - power_history
[i
+1];
1538 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1539 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1540 ((y
< 0) ? y
* -1 : y
) % 1000);
1541 lcd_puts(0, i
+1, buf
);
1545 case 3: /* remaining time estimation: */
1547 #if CONFIG_CHARGING == CHARGING_CONTROL
1548 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1549 lcd_puts(0, 0, buf
);
1551 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1552 lcd_puts(0, 1, buf
);
1554 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1555 lcd_puts(0, 2, buf
);
1557 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1558 lcd_puts(0, 3, buf
);
1560 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1561 lcd_puts(0, 4, buf
);
1562 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1564 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1565 power_history
[0] / 1000,
1566 power_history
[0] % 1000);
1567 lcd_puts(0, 5, buf
);
1569 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1570 lcd_puts(0, 6, buf
);
1572 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1573 lcd_puts(0, 7, buf
);
1579 switch(get_action(CONTEXT_SETTINGS
,HZ
/2))
1581 case ACTION_SETTINGS_DEC
:
1586 case ACTION_SETTINGS_INC
:
1591 case ACTION_STD_CANCEL
:
1598 #endif /* HAVE_LCD_BITMAP */
1602 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1603 #if defined(HAVE_MMC)
1604 #define CARDTYPE "MMC"
1606 #define CARDTYPE "microSD"
1608 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1611 int *cardnum
= (int*)lists
->gui_list
[SCREEN_MAIN
].data
;
1612 unsigned char card_name
[7];
1613 unsigned char pbuf
[32];
1614 char *title
= lists
->gui_list
[SCREEN_MAIN
].title
;
1615 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1616 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1617 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1618 static const unsigned char *nsec_units
[] = { "ns", "�s", "ms" };
1619 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1620 "3.1-3.31", "4.0" };
1621 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1623 if (btn
== ACTION_STD_OK
)
1625 *cardnum
^= 0x1; /* change cards */
1628 simplelist_set_line_count(0);
1630 card
= card_get_info(*cardnum
);
1632 if (card
->initialized
> 0)
1634 card_name
[6] = '\0';
1635 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1636 simplelist_addline(SIMPLELIST_ADD_LINE
,
1637 "%s Rev %d.%d", card_name
,
1638 (int) card_extract_bits(card
->cid
, 72, 4),
1639 (int) card_extract_bits(card
->cid
, 76, 4));
1640 simplelist_addline(SIMPLELIST_ADD_LINE
,
1642 (int) card_extract_bits(card
->cid
, 112, 4),
1643 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1644 simplelist_addline(SIMPLELIST_ADD_LINE
,
1646 card_extract_bits(card
->cid
, 80, 32));
1647 simplelist_addline(SIMPLELIST_ADD_LINE
,
1649 (int) card_extract_bits(card
->cid
, 0, 8),
1650 (int) card_extract_bits(card
->cid
, 8, 16));
1651 int temp
= card_extract_bits(card
->csd
, 2, 4);
1652 simplelist_addline(SIMPLELIST_ADD_LINE
,
1653 CARDTYPE
" v%s", temp
< 5 ?
1654 spec_vers
[temp
] : "?.?");
1655 simplelist_addline(SIMPLELIST_ADD_LINE
,
1656 "Blocks: 0x%06lx", card
->numblocks
);
1657 simplelist_addline(SIMPLELIST_ADD_LINE
,
1658 "Blksz.: %d P:%c%c", card
->blocksize
,
1659 card_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1660 card_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1661 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1663 simplelist_addline(SIMPLELIST_ADD_LINE
,
1665 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1667 simplelist_addline(SIMPLELIST_ADD_LINE
,
1669 simplelist_addline(SIMPLELIST_ADD_LINE
,
1670 "Nsac: %d clk", card
->nsac
);
1671 simplelist_addline(SIMPLELIST_ADD_LINE
,
1672 "R2W: *%d", card
->r2w_factor
);
1673 simplelist_addline(SIMPLELIST_ADD_LINE
,
1675 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1676 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1677 simplelist_addline(SIMPLELIST_ADD_LINE
,
1679 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1680 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1682 else if (card
->initialized
== 0)
1684 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1687 else /* card->initialized < 0 */
1689 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1692 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1693 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1694 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1695 gui_synclist_select_item(lists
, 0);
1696 btn
= ACTION_REDRAW
;
1700 #else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1701 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1706 unsigned short* identify_info
= ata_get_identify();
1707 bool timing_info_present
= false;
1710 simplelist_set_line_count(0);
1712 for (i
=0; i
< 20; i
++)
1713 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1715 /* kill trailing space */
1716 for (i
=39; i
&& buf
[i
]==' '; i
--)
1718 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1719 for (i
=0; i
< 4; i
++)
1720 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1722 simplelist_addline(SIMPLELIST_ADD_LINE
,
1723 "Firmware: %s", buf
);
1724 snprintf(buf
, sizeof buf
, "%ld MB",
1725 ((unsigned long)identify_info
[61] << 16 |
1726 (unsigned long)identify_info
[60]) / 2048 );
1727 simplelist_addline(SIMPLELIST_ADD_LINE
,
1730 fat_size( IF_MV2(0,) NULL
, &free
);
1731 simplelist_addline(SIMPLELIST_ADD_LINE
,
1732 "Free: %ld MB", free
/ 1024);
1733 simplelist_addline(SIMPLELIST_ADD_LINE
,
1734 "Spinup time: %d ms", ata_spinup_time
* (1000/HZ
));
1735 i
= identify_info
[83] & (1<<3);
1736 simplelist_addline(SIMPLELIST_ADD_LINE
,
1737 "Power mgmt: %s", i
? "enabled" : "unsupported");
1738 i
= identify_info
[83] & (1<<9);
1739 simplelist_addline(SIMPLELIST_ADD_LINE
,
1740 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1741 i
= identify_info
[82] & (1<<6);
1742 simplelist_addline(SIMPLELIST_ADD_LINE
,
1743 "Read-ahead: %s", i
? "enabled" : "unsupported");
1744 timing_info_present
= identify_info
[53] & (1<<1);
1745 if(timing_info_present
) {
1746 char pio3
[2], pio4
[2];pio3
[1] = 0;
1748 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1749 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1750 simplelist_addline(SIMPLELIST_ADD_LINE
,
1751 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1754 simplelist_addline(SIMPLELIST_ADD_LINE
,
1755 "No PIO mode info");
1757 timing_info_present
= identify_info
[53] & (1<<1);
1758 if(timing_info_present
) {
1759 simplelist_addline(SIMPLELIST_ADD_LINE
,
1760 "Cycle times %dns/%dns",
1762 identify_info
[68] );
1764 simplelist_addline(SIMPLELIST_ADD_LINE
,
1767 timing_info_present
= identify_info
[53] & (1<<1);
1768 if(timing_info_present
) {
1769 i
= identify_info
[49] & (1<<11);
1770 simplelist_addline(SIMPLELIST_ADD_LINE
,
1771 "IORDY support: %s", i
? "yes" : "no");
1772 i
= identify_info
[49] & (1<<10);
1773 simplelist_addline(SIMPLELIST_ADD_LINE
,
1774 "IORDY disable: %s", i
? "yes" : "no");
1776 simplelist_addline(SIMPLELIST_ADD_LINE
,
1779 simplelist_addline(SIMPLELIST_ADD_LINE
,
1780 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1783 #endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1784 static bool dbg_disk_info(void)
1786 struct simplelist_info info
;
1787 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1788 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1791 info
.callback_data
= (void*)&card
;
1794 info
.action_callback
= disk_callback
;
1795 info
.hide_selection
= true;
1796 return simplelist_show_list(&info
);
1798 #endif /* !SIMULATOR */
1800 #ifdef HAVE_DIRCACHE
1801 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1803 (void)btn
; (void)lists
;
1804 simplelist_set_line_count(0);
1805 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1806 dircache_is_enabled() ? "Yes" : "No");
1807 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1808 dircache_get_cache_size());
1809 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1810 global_status
.dircache_size
);
1811 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1813 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1814 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1815 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1816 dircache_get_build_ticks() / HZ
);
1817 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1818 dircache_get_entry_count());
1822 static bool dbg_dircache_info(void)
1824 struct simplelist_info info
;
1825 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1826 info
.action_callback
= dircache_callback
;
1827 info
.hide_selection
= true;
1828 return simplelist_show_list(&info
);
1831 #endif /* HAVE_DIRCACHE */
1833 #ifdef HAVE_TAGCACHE
1834 static int database_callback(int btn
, struct gui_synclist
*lists
)
1836 (void)btn
; (void)lists
;
1837 struct tagcache_stat
*stat
= tagcache_get_stat();
1838 simplelist_set_line_count(0);
1839 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1840 stat
->initialized
? "Yes" : "No");
1841 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1842 stat
->ready
? "Yes" : "No");
1843 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1844 stat
->ramcache
? "Yes" : "No");
1845 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1846 stat
->ramcache_used
, stat
->ramcache_allocated
);
1847 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1848 stat
->progress
, stat
->processed_entries
);
1849 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1851 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1852 stat
->commit_delayed
? "Yes" : "No");
1855 static bool dbg_tagcache_info(void)
1857 struct simplelist_info info
;
1858 simplelist_info_init(&info
, "Database Info", 7, NULL
);
1859 info
.action_callback
= database_callback
;
1860 info
.hide_selection
= true;
1861 return simplelist_show_list(&info
);
1865 #if CONFIG_CPU == SH7034
1866 static bool dbg_save_roms(void)
1869 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1871 fd
= creat("/internal_rom_0000-FFFF.bin");
1874 write(fd
, (void *)0, 0x10000);
1878 fd
= creat("/internal_rom_2000000-203FFFF.bin");
1881 write(fd
, (void *)0x2000000, 0x40000);
1885 system_memory_guard(oldmode
);
1888 #elif defined CPU_COLDFIRE
1889 static bool dbg_save_roms(void)
1892 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1894 #if defined(IRIVER_H100_SERIES)
1895 fd
= creat("/internal_rom_000000-1FFFFF.bin");
1896 #elif defined(IRIVER_H300_SERIES)
1897 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1898 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
1899 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1903 write(fd
, (void *)0, FLASH_SIZE
);
1906 system_memory_guard(oldmode
);
1909 fd
= creat("/internal_eeprom.bin");
1913 char buf
[EEPROM_SIZE
];
1916 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
1918 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1920 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
1923 write(fd
, buf
, sizeof buf
);
1926 set_irq_level(old_irq_level
);
1934 #elif defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200))
1935 static bool dbg_save_roms(void)
1939 fd
= creat("/internal_rom_000000-0FFFFF.bin");
1942 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1952 static int radio_callback(int btn
, struct gui_synclist
*lists
)
1955 if (btn
== ACTION_STD_CANCEL
)
1957 simplelist_set_line_count(1);
1959 #if (CONFIG_TUNER & LV24020LP)
1960 simplelist_addline(SIMPLELIST_ADD_LINE
,
1961 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
1962 simplelist_addline(SIMPLELIST_ADD_LINE
,
1963 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
1964 simplelist_addline(SIMPLELIST_ADD_LINE
,
1965 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
1966 simplelist_addline(SIMPLELIST_ADD_LINE
,
1967 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
1968 simplelist_addline(SIMPLELIST_ADD_LINE
,
1969 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
1970 simplelist_addline(SIMPLELIST_ADD_LINE
,
1971 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
1972 simplelist_addline(SIMPLELIST_ADD_LINE
,
1973 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
1975 #if (CONFIG_TUNER & S1A0903X01)
1976 simplelist_addline(SIMPLELIST_ADD_LINE
,
1977 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
1978 /* This one doesn't return dynamic data atm */
1980 #if (CONFIG_TUNER & TEA5767)
1981 struct tea5767_dbg_info nfo
;
1982 tea5767_dbg_info(&nfo
);
1983 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
1984 simplelist_addline(SIMPLELIST_ADD_LINE
,
1985 " Read: %02X %02X %02X %02X %02X",
1986 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
1987 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
1988 (unsigned)nfo
.read_regs
[4]);
1989 simplelist_addline(SIMPLELIST_ADD_LINE
,
1990 " Write: %02X %02X %02X %02X %02X",
1991 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
1992 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
1993 (unsigned)nfo
.write_regs
[4]);
1995 return ACTION_REDRAW
;
1997 static bool dbg_fm_radio(void)
1999 struct simplelist_info info
;
2000 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2001 simplelist_set_line_count(0);
2002 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2003 radio_hardware_present() ? "yes" : "no");
2005 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2006 info
.hide_selection
= true;
2007 return simplelist_show_list(&info
);
2009 #endif /* CONFIG_TUNER */
2010 #endif /* !SIMULATOR */
2012 #ifdef HAVE_LCD_BITMAP
2013 extern bool do_screendump_instead_of_usb
;
2015 static bool dbg_screendump(void)
2017 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2018 gui_syncsplash(HZ
, "Screendump %s",
2019 do_screendump_instead_of_usb
?"enabled":"disabled");
2022 #endif /* HAVE_LCD_BITMAP */
2024 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2025 static bool dbg_set_memory_guard(void)
2027 static const struct opt_items names
[MAXMEMGUARD
] = {
2029 { "Flash ROM writes", -1 },
2030 { "Zero area (all)", -1 }
2032 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2034 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2035 system_memory_guard(mode
);
2039 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2041 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2043 extern volatile bool lcd_poweroff
;
2045 static bool dbg_lcd_power_off(void)
2047 lcd_setmargins(0, 0);
2053 lcd_clear_display();
2054 lcd_puts(0, 0, "LCD Power Off");
2056 lcd_puts(1, 1, "Yes");
2058 lcd_puts(1, 1, "No");
2062 button
= get_action(CONTEXT_STD
,HZ
/5);
2065 case ACTION_STD_PREV
:
2066 case ACTION_STD_NEXT
:
2067 lcd_poweroff
= !lcd_poweroff
;
2070 case ACTION_STD_CANCEL
:
2081 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2082 static bool dbg_write_eeprom(void)
2087 char buf
[EEPROM_SIZE
];
2090 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2094 rc
= read(fd
, buf
, EEPROM_SIZE
);
2096 if(rc
== EEPROM_SIZE
)
2098 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2100 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2102 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2104 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2106 set_irq_level(old_irq_level
);
2110 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2116 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2121 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2122 #ifdef CPU_BOOST_LOGGING
2123 static bool cpu_boost_log(void)
2126 int count
= cpu_boost_log_getcount();
2127 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2130 lcd_setmargins(0, 0);
2131 lcd_setfont(FONT_SYSFIXED
);
2132 str
= cpu_boost_log_getlog_first();
2135 lcd_clear_display();
2136 for(j
=0; j
<lines
; j
++,i
++)
2139 str
= cpu_boost_log_getlog_next();
2150 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2153 case ACTION_STD_PREV
:
2154 case ACTION_STD_NEXT
:
2157 case ACTION_STD_CANCEL
:
2164 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2165 lcd_setfont(FONT_UI
);
2172 /****** The menu *********/
2173 struct the_menu_item
{
2174 unsigned char *desc
; /* string or ID */
2175 bool (*function
) (void); /* return true if USB was connected */
2177 static const struct the_menu_item menuitems
[] = {
2178 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2179 { "LCD Power Off", dbg_lcd_power_off
},
2181 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2182 (defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200)))
2183 { "Dump ROM contents", dbg_save_roms
},
2185 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440
2186 { "View I/O ports", dbg_ports
},
2188 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2189 { "CPU frequency", dbg_cpufreq
},
2191 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2192 { "S/PDIF analyzer", dbg_spdif
},
2194 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2195 { "Catch mem accesses", dbg_set_memory_guard
},
2197 { "View OS stacks", dbg_os
},
2198 #ifdef HAVE_LCD_BITMAP
2200 { "View battery", view_battery
},
2202 { "Screendump", dbg_screendump
},
2205 { "View HW info", dbg_hw_info
},
2208 { "View partitions", dbg_partitions
},
2211 { "View disk info", dbg_disk_info
},
2213 #ifdef HAVE_DIRCACHE
2214 { "View dircache info", dbg_dircache_info
},
2216 #ifdef HAVE_TAGCACHE
2217 { "View database info", dbg_tagcache_info
},
2219 #ifdef HAVE_LCD_BITMAP
2220 #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR)
2221 { "View audio thread", dbg_audio_thread
},
2224 { "pm histogram", peak_meter_histogram
},
2225 #endif /* PM_DEBUG */
2226 #endif /* HAVE_LCD_BITMAP */
2229 { "FM Radio", dbg_fm_radio
},
2232 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2233 { "Write back EEPROM", dbg_write_eeprom
},
2235 #ifdef ROCKBOX_HAS_LOGF
2236 {"logf", logfdisplay
},
2237 {"logfdump", logfdump
},
2239 #ifdef CPU_BOOST_LOGGING
2240 {"cpu_boost log",cpu_boost_log
},
2243 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2245 if (btn
== ACTION_STD_OK
)
2247 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2248 btn
= ACTION_REDRAW
;
2252 static char* dbg_menu_getname(int item
, void * data
, char *buffer
)
2254 (void)data
; (void)buffer
;
2255 return menuitems
[item
].desc
;
2257 bool debug_menu(void)
2259 struct simplelist_info info
;
2260 info
.title
= "Debug Menu";
2261 info
.selection_size
= 1;
2262 info
.count
= ARRAYLEN(menuitems
);
2263 info
.selection_size
= 1;
2264 info
.action_callback
= menu_action_callback
;
2265 info
.hide_selection
= false;
2266 info
.scroll_all
= false;
2267 info
.get_icon
= NULL
;
2268 info
.get_name
= dbg_menu_getname
;
2269 info
.callback_data
= NULL
;
2270 return simplelist_show_list(&info
);