summaryrefslogtreecommitdiff
path: root/apps/debug_menu.c
diff options
context:
space:
mode:
authorDaniel Ankers <dan@weirdo.org.uk>2006-08-21 17:35:35 +0000
committerDaniel Ankers <dan@weirdo.org.uk>2006-08-21 17:35:35 +0000
commit0aec12f3fd801c5acc03a75818e06741957d51b9 (patch)
treed78b6d52c5962a00a5fefde97e977653a15c0428 /apps/debug_menu.c
parente09dc8d51323bf0940b19ff8e12de7891fda2c52 (diff)
downloadrockbox-0aec12f3fd801c5acc03a75818e06741957d51b9.tar.gz
rockbox-0aec12f3fd801c5acc03a75818e06741957d51b9.zip
Threading changes in preparation for multiple core support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10681 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r--apps/debug_menu.c205
1 files changed, 106 insertions, 99 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index c3a0d93dc6..69149767cc 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -78,8 +78,8 @@
78/*---------------------------------------------------*/ 78/*---------------------------------------------------*/
79extern char ata_device; 79extern char ata_device;
80extern int ata_io_address; 80extern int ata_io_address;
81extern int num_threads; 81extern int num_threads[];
82extern const char *thread_name[]; 82extern const char *thread_name[][MAXTHREADS];
83 83
84#ifdef HAVE_LCD_BITMAP 84#ifdef HAVE_LCD_BITMAP
85/* Test code!!! */ 85/* Test code!!! */
@@ -88,6 +88,8 @@ bool dbg_os(void)
88 char buf[32]; 88 char buf[32];
89 int i; 89 int i;
90 int usage; 90 int usage;
91 unsigned int core;
92 int line;
91 93
92 lcd_setmargins(0, 0); 94 lcd_setmargins(0, 0);
93 lcd_setfont(FONT_SYSFIXED); 95 lcd_setfont(FONT_SYSFIXED);
@@ -95,12 +97,16 @@ bool dbg_os(void)
95 97
96 while(1) 98 while(1)
97 { 99 {
98 lcd_puts(0, 0, "Stack usage:"); 100 lcd_puts(0, 0, "Core and stack usage:");
99 for(i = 0; i < num_threads;i++) 101 line = 0;
102 for(core = 0; core < NUM_CORES; core++)
100 { 103 {
101 usage = thread_stack_usage(i); 104 for(i = 0; i < num_threads[core]; i++)
102 snprintf(buf, 32, "%s: %d%%", thread_name[i], usage); 105 {
103 lcd_puts(0, 1+i, buf); 106 usage = thread_stack_usage_on_core(core, i);
107 snprintf(buf, 32, "(%d) %s: %d%%", core, thread_name[core][i], usage);
108 lcd_puts(0, ++line, buf);
109 }
104 } 110 }
105 111
106 lcd_update(); 112 lcd_update();
@@ -124,10 +130,11 @@ bool dbg_os(void)
124 { 130 {
125 lcd_puts(0, 0, "Stack usage"); 131 lcd_puts(0, 0, "Stack usage");
126 132
133 /* Only Archos Player uses this - so assume a single core */
127 usage = thread_stack_usage(currval); 134 usage = thread_stack_usage(currval);
128 snprintf(buf, 32, "%d: %d%% ", currval, usage); 135 snprintf(buf, 32, "%d: %d%% ", currval, usage);
129 lcd_puts(0, 1, buf); 136 lcd_puts(0, 1, buf);
130 137
131 button = get_action(CONTEXT_SETTINGS,HZ/10); 138 button = get_action(CONTEXT_SETTINGS,HZ/10);
132 139
133 switch(button) 140 switch(button)
@@ -162,14 +169,14 @@ bool dbg_audio_thread(void)
162 169
163 lcd_setmargins(0, 0); 170 lcd_setmargins(0, 0);
164 lcd_setfont(FONT_SYSFIXED); 171 lcd_setfont(FONT_SYSFIXED);
165 172
166 while(1) 173 while(1)
167 { 174 {
168 if (action_userabort(HZ/5)) 175 if (action_userabort(HZ/5))
169 return false; 176 return false;
170 177
171 audio_get_debugdata(&d); 178 audio_get_debugdata(&d);
172 179
173 lcd_clear_display(); 180 lcd_clear_display();
174 181
175 snprintf(buf, sizeof(buf), "read: %x", d.audiobuf_read); 182 snprintf(buf, sizeof(buf), "read: %x", d.audiobuf_read);
@@ -186,17 +193,17 @@ bool dbg_audio_thread(void)
186 lcd_puts(0, 5, buf); 193 lcd_puts(0, 5, buf);
187 194
188 /* Playable space left */ 195 /* Playable space left */
189 scrollbar(0, 6*8, 112, 4, d.audiobuflen, 0, 196 scrollbar(0, 6*8, 112, 4, d.audiobuflen, 0,
190 d.playable_space, HORIZONTAL); 197 d.playable_space, HORIZONTAL);
191 198
192 /* Show the watermark limit */ 199 /* Show the watermark limit */
193 scrollbar(0, 6*8+4, 112, 4, d.audiobuflen, 0, 200 scrollbar(0, 6*8+4, 112, 4, d.audiobuflen, 0,
194 d.low_watermark_level, HORIZONTAL); 201 d.low_watermark_level, HORIZONTAL);
195 202
196 snprintf(buf, sizeof(buf), "wm: %x - %x", 203 snprintf(buf, sizeof(buf), "wm: %x - %x",
197 d.low_watermark_level, d.lowest_watermark_level); 204 d.low_watermark_level, d.lowest_watermark_level);
198 lcd_puts(0, 7, buf); 205 lcd_puts(0, 7, buf);
199 206
200 lcd_update(); 207 lcd_update();
201 } 208 }
202 return false; 209 return false;
@@ -229,7 +236,7 @@ bool dbg_audio_thread(void)
229 ticks = boost_ticks = 0; 236 ticks = boost_ticks = 0;
230 237
231 tick_add_task(dbg_audio_task); 238 tick_add_task(dbg_audio_task);
232 239
233 lcd_setmargins(0, 0); 240 lcd_setmargins(0, 0);
234 lcd_setfont(FONT_SYSFIXED); 241 lcd_setfont(FONT_SYSFIXED);
235 while(!done) 242 while(!done)
@@ -249,7 +256,7 @@ bool dbg_audio_thread(void)
249 } 256 }
250 action_signalscreenchange(); 257 action_signalscreenchange();
251 line = 0; 258 line = 0;
252 259
253 lcd_clear_display(); 260 lcd_clear_display();
254 261
255 bufused = bufsize - pcmbuf_free(); 262 bufused = bufsize - pcmbuf_free();
@@ -283,12 +290,12 @@ bool dbg_audio_thread(void)
283 snprintf(buf, sizeof(buf), "pcmbufdesc: %2d/%2d", 290 snprintf(buf, sizeof(buf), "pcmbufdesc: %2d/%2d",
284 pcmbuf_used_descs(), pcmbufdescs); 291 pcmbuf_used_descs(), pcmbufdescs);
285 lcd_puts(0, line++, buf); 292 lcd_puts(0, line++, buf);
286 293
287 lcd_update(); 294 lcd_update();
288 } 295 }
289 296
290 tick_remove_task(dbg_audio_task); 297 tick_remove_task(dbg_audio_task);
291 298
292 return false; 299 return false;
293} 300}
294#endif /* CONFIG_CODEC */ 301#endif /* CONFIG_CODEC */
@@ -303,7 +310,7 @@ static void flash_write_word(unsigned addr, unsigned value) {
303 flash_word_temp = value; 310 flash_word_temp = value;
304 311
305 long extAddr = (long)addr << 1; 312 long extAddr = (long)addr << 1;
306 ddma_transfer(1, 1, &flash_word_temp, extAddr, 2); 313 ddma_transfer(1, 1, &flash_word_temp, extAddr, 2);
307} 314}
308 315
309static unsigned flash_read_word(unsigned addr) __attribute__ ((section(".icode"))); 316static unsigned flash_read_word(unsigned addr) __attribute__ ((section(".icode")));
@@ -324,7 +331,7 @@ bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
324 __attribute__ ((section (".icode"))); 331 __attribute__ ((section (".icode")));
325bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, 332bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
326 unsigned addr1, unsigned addr2) 333 unsigned addr1, unsigned addr2)
327 334
328{ 335{
329#if (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020) 336#if (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
330 /* TODO: Implement for iPod */ 337 /* TODO: Implement for iPod */
@@ -382,9 +389,9 @@ bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
382 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ 389 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
383 390
384 set_irq_level(old_level); /* enable interrupts again */ 391 set_irq_level(old_level); /* enable interrupts again */
385 392
386 /* I assume success if the obtained values are different from 393 /* I assume success if the obtained values are different from
387 the normal flash content. This is not perfectly bulletproof, they 394 the normal flash content. This is not perfectly bulletproof, they
388 could theoretically be the same by chance, causing us to fail. */ 395 could theoretically be the same by chance, causing us to fail. */
389 if (not_manu != manu || not_id != id) /* a value has changed */ 396 if (not_manu != manu || not_id != id) /* a value has changed */
390 { 397 {
@@ -431,7 +438,7 @@ bool dbg_hw_info(void)
431 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ 438 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
432 if (!got_id) 439 if (!got_id)
433 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ 440 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
434 441
435 /* check if the boot ROM area is a flash mirror */ 442 /* check if the boot ROM area is a flash mirror */
436 has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); 443 has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
437 if (has_bootrom) /* if ROM and Flash different */ 444 if (has_bootrom) /* if ROM and Flash different */
@@ -450,16 +457,16 @@ bool dbg_hw_info(void)
450 457
451 snprintf(buf, 32, "ROM: %d.%02d", rom_version/100, rom_version%100); 458 snprintf(buf, 32, "ROM: %d.%02d", rom_version/100, rom_version%100);
452 lcd_puts(0, 1, buf); 459 lcd_puts(0, 1, buf);
453 460
454 snprintf(buf, 32, "Mask: 0x%04x", bitmask); 461 snprintf(buf, 32, "Mask: 0x%04x", bitmask);
455 lcd_puts(0, 2, buf); 462 lcd_puts(0, 2, buf);
456 463
457 snprintf(buf, 32, "USB: %s", usb_polarity?"positive":"negative"); 464 snprintf(buf, 32, "USB: %s", usb_polarity?"positive":"negative");
458 lcd_puts(0, 3, buf); 465 lcd_puts(0, 3, buf);
459 466
460 snprintf(buf, 32, "PR: %s", pr_polarity?"positive":"negative"); 467 snprintf(buf, 32, "PR: %s", pr_polarity?"positive":"negative");
461 lcd_puts(0, 4, buf); 468 lcd_puts(0, 4, buf);
462 469
463 if (got_id) 470 if (got_id)
464 snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id); 471 snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id);
465 else 472 else
@@ -483,7 +490,7 @@ bool dbg_hw_info(void)
483 snprintf(buf, 32, "ATA: 0x%x,%s", ata_io_address, 490 snprintf(buf, 32, "ATA: 0x%x,%s", ata_io_address,
484 ata_device ? "slave":"master"); 491 ata_device ? "slave":"master");
485 lcd_puts(0, 7, buf); 492 lcd_puts(0, 7, buf);
486#endif 493#endif
487 lcd_update(); 494 lcd_update();
488 495
489 while(1) 496 while(1)
@@ -503,7 +510,7 @@ bool dbg_hw_info(void)
503 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ 510 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
504 if (!got_id) 511 if (!got_id)
505 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ 512 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
506 513
507 system_memory_guard(oldmode); /* re-enable memory guard */ 514 system_memory_guard(oldmode); /* re-enable memory guard */
508 515
509 lcd_setmargins(0, 0); 516 lcd_setmargins(0, 0);
@@ -533,7 +540,7 @@ bool dbg_hw_info(void)
533 lcd_clear_display(); 540 lcd_clear_display();
534 541
535 lcd_puts(0, 0, "[Hardware info]"); 542 lcd_puts(0, 0, "[Hardware info]");
536 543
537 snprintf(buf, sizeof(buf), "HW rev: 0x%08x", ipod_hw_rev); 544 snprintf(buf, sizeof(buf), "HW rev: 0x%08x", ipod_hw_rev);
538 lcd_puts(0, 1, buf); 545 lcd_puts(0, 1, buf);
539 546
@@ -581,7 +588,7 @@ bool dbg_hw_info(void)
581 /* calculate CRC16 checksum of boot ROM */ 588 /* calculate CRC16 checksum of boot ROM */
582 rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); 589 rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
583 } 590 }
584 591
585 system_memory_guard(oldmode); /* re-enable memory guard */ 592 system_memory_guard(oldmode); /* re-enable memory guard */
586 593
587 lcd_clear_display(); 594 lcd_clear_display();
@@ -617,7 +624,7 @@ bool dbg_hw_info(void)
617 { 624 {
618 if (rom_crc == 0x56DBA4EE) /* known Version 1 */ 625 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
619 snprintf(buf, 32, "BootROM: V1"); 626 snprintf(buf, 32, "BootROM: V1");
620 else if (rom_crc == 0x358099E8) 627 else if (rom_crc == 0x358099E8)
621 snprintf(buf, 32, "BootROM: V2"); 628 snprintf(buf, 32, "BootROM: V2");
622 /* alternative boot ROM found in one single player so far */ 629 /* alternative boot ROM found in one single player so far */
623 else 630 else
@@ -626,10 +633,10 @@ bool dbg_hw_info(void)
626 else 633 else
627 snprintf(buf, 32, "BootROM: no"); 634 snprintf(buf, 32, "BootROM: no");
628 } 635 }
629 636
630 lcd_puts(0, 1, buf); 637 lcd_puts(0, 1, buf);
631 lcd_update(); 638 lcd_update();
632 639
633 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK); 640 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK);
634 641
635 switch(button) 642 switch(button)
@@ -643,7 +650,7 @@ bool dbg_hw_info(void)
643 if(currval < 0) 650 if(currval < 0)
644 currval = 5; 651 currval = 5;
645 break; 652 break;
646 653
647 case ACTION_SETTINGS_INC: 654 case ACTION_SETTINGS_INC:
648 currval++; 655 currval++;
649 if(currval > 5) 656 if(currval > 5)
@@ -677,7 +684,7 @@ bool dbg_partitions(void)
677 snprintf(buf, sizeof buf, "T:%x %ld MB", p->type, p->size / 2048); 684 snprintf(buf, sizeof buf, "T:%x %ld MB", p->type, p->size / 2048);
678 lcd_puts(0, 1, buf); 685 lcd_puts(0, 1, buf);
679 lcd_update(); 686 lcd_update();
680 687
681 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK); 688 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK);
682 689
683 switch(button) 690 switch(button)
@@ -691,7 +698,7 @@ bool dbg_partitions(void)
691 if (partition < 0) 698 if (partition < 0)
692 partition = 3; 699 partition = 3;
693 break; 700 break;
694 701
695 case ACTION_SETTINGS_INC: 702 case ACTION_SETTINGS_INC:
696 partition++; 703 partition++;
697 if (partition > 3) 704 if (partition > 3)
@@ -751,22 +758,22 @@ bool dbg_spdif(void)
751 lcd_puts(0, line++, buf); 758 lcd_puts(0, line++, buf);
752 759
753 line++; 760 line++;
754 761
755 x = control >> 31; 762 x = control >> 31;
756 snprintf(buf, sizeof(buf), "PRO: %d (%s)", 763 snprintf(buf, sizeof(buf), "PRO: %d (%s)",
757 x, x?"Professional":"Consumer"); 764 x, x?"Professional":"Consumer");
758 lcd_puts(0, line++, buf); 765 lcd_puts(0, line++, buf);
759 766
760 x = (control >> 30) & 1; 767 x = (control >> 30) & 1;
761 snprintf(buf, sizeof(buf), "Audio: %d (%s)", 768 snprintf(buf, sizeof(buf), "Audio: %d (%s)",
762 x, x?"Non-PCM":"PCM"); 769 x, x?"Non-PCM":"PCM");
763 lcd_puts(0, line++, buf); 770 lcd_puts(0, line++, buf);
764 771
765 x = (control >> 29) & 1; 772 x = (control >> 29) & 1;
766 snprintf(buf, sizeof(buf), "Copy: %d (%s)", 773 snprintf(buf, sizeof(buf), "Copy: %d (%s)",
767 x, x?"Permitted":"Inhibited"); 774 x, x?"Permitted":"Inhibited");
768 lcd_puts(0, line++, buf); 775 lcd_puts(0, line++, buf);
769 776
770 x = (control >> 27) & 7; 777 x = (control >> 27) & 7;
771 switch(x) 778 switch(x)
772 { 779 {
@@ -786,7 +793,7 @@ bool dbg_spdif(void)
786 x = (control >> 24) & 3; 793 x = (control >> 24) & 3;
787 snprintf(buf, sizeof(buf), "Mode: %d", x); 794 snprintf(buf, sizeof(buf), "Mode: %d", x);
788 lcd_puts(0, line++, buf); 795 lcd_puts(0, line++, buf);
789 796
790 category = (control >> 17) & 127; 797 category = (control >> 17) & 127;
791 switch(category) 798 switch(category)
792 { 799 {
@@ -801,7 +808,7 @@ bool dbg_spdif(void)
801 } 808 }
802 snprintf(buf, sizeof(buf), "Category: 0x%02x (%s)", category, s); 809 snprintf(buf, sizeof(buf), "Category: 0x%02x (%s)", category, s);
803 lcd_puts(0, line++, buf); 810 lcd_puts(0, line++, buf);
804 811
805 x = (control >> 16) & 1; 812 x = (control >> 16) & 1;
806 generation = x; 813 generation = x;
807 if(((category & 0x70) == 0x10) || 814 if(((category & 0x70) == 0x10) ||
@@ -813,11 +820,11 @@ bool dbg_spdif(void)
813 snprintf(buf, sizeof(buf), "Generation: %d (%s)", 820 snprintf(buf, sizeof(buf), "Generation: %d (%s)",
814 x, generation?"Original":"No ind."); 821 x, generation?"Original":"No ind.");
815 lcd_puts(0, line++, buf); 822 lcd_puts(0, line++, buf);
816 823
817 x = (control >> 12) & 15; 824 x = (control >> 12) & 15;
818 snprintf(buf, sizeof(buf), "Source: %d", x); 825 snprintf(buf, sizeof(buf), "Source: %d", x);
819 lcd_puts(0, line++, buf); 826 lcd_puts(0, line++, buf);
820 827
821 x = (control >> 8) & 15; 828 x = (control >> 8) & 15;
822 switch(x) 829 switch(x)
823 { 830 {
@@ -836,7 +843,7 @@ bool dbg_spdif(void)
836 } 843 }
837 snprintf(buf, sizeof(buf), "Channel: %d (%s)", x, s); 844 snprintf(buf, sizeof(buf), "Channel: %d (%s)", x, s);
838 lcd_puts(0, line++, buf); 845 lcd_puts(0, line++, buf);
839 846
840 x = (control >> 4) & 15; 847 x = (control >> 4) & 15;
841 switch(x) 848 switch(x)
842 { 849 {
@@ -857,7 +864,7 @@ bool dbg_spdif(void)
857 snprintf(buf, sizeof(buf), "Clock accuracy: %d", x); 864 snprintf(buf, sizeof(buf), "Clock accuracy: %d", x);
858 lcd_puts(0, line++, buf); 865 lcd_puts(0, line++, buf);
859 line++; 866 line++;
860 867
861 snprintf(buf, sizeof(buf), "Measured freq: %ldHz", 868 snprintf(buf, sizeof(buf), "Measured freq: %ldHz",
862 (long)((long long)FREQMEAS*CPU_FREQ/((1 << 15)*3*(1 << 13))/128)); 869 (long)((long long)FREQMEAS*CPU_FREQ/((1 << 15)*3*(1 << 13))/128));
863 lcd_puts(0, line++, buf); 870 lcd_puts(0, line++, buf);
@@ -914,7 +921,7 @@ bool dbg_ports(void)
914 battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000; 921 battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
915 batt_int = battery_voltage / 100; 922 batt_int = battery_voltage / 100;
916 batt_frac = battery_voltage % 100; 923 batt_frac = battery_voltage % 100;
917 924
918 snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac, 925 snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
919 battery_level()); 926 battery_level());
920 lcd_puts(0, 6, buf); 927 lcd_puts(0, 6, buf);
@@ -960,7 +967,7 @@ bool dbg_ports(void)
960 gpio1_function = GPIO1_FUNCTION; 967 gpio1_function = GPIO1_FUNCTION;
961 gpio_enable = GPIO_ENABLE; 968 gpio_enable = GPIO_ENABLE;
962 gpio1_enable = GPIO1_ENABLE; 969 gpio1_enable = GPIO1_ENABLE;
963 970
964 snprintf(buf, sizeof(buf), "GPIO_READ: %08x", gpio_read); 971 snprintf(buf, sizeof(buf), "GPIO_READ: %08x", gpio_read);
965 lcd_puts(0, line++, buf); 972 lcd_puts(0, line++, buf);
966 snprintf(buf, sizeof(buf), "GPIO_OUT: %08x", gpio_out); 973 snprintf(buf, sizeof(buf), "GPIO_OUT: %08x", gpio_out);
@@ -985,7 +992,7 @@ bool dbg_ports(void)
985#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 992#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
986 adc_remotedetect = adc_read(ADC_REMOTEDETECT); 993 adc_remotedetect = adc_read(ADC_REMOTEDETECT);
987#endif 994#endif
988 995
989 snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons); 996 snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons);
990 lcd_puts(0, line++, buf); 997 lcd_puts(0, line++, buf);
991 snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_remote); 998 snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_remote);
@@ -1000,16 +1007,16 @@ bool dbg_ports(void)
1000 battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; 1007 battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000;
1001 batt_int = battery_voltage / 100; 1008 batt_int = battery_voltage / 100;
1002 batt_frac = battery_voltage % 100; 1009 batt_frac = battery_voltage % 100;
1003 1010
1004 snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac, 1011 snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
1005 battery_level()); 1012 battery_level());
1006 lcd_puts(0, line++, buf); 1013 lcd_puts(0, line++, buf);
1007 1014
1008#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 1015#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1009 snprintf(buf, sizeof(buf), "remotetype:: %d", remote_type()); 1016 snprintf(buf, sizeof(buf), "remotetype:: %d", remote_type());
1010 lcd_puts(0, line++, buf); 1017 lcd_puts(0, line++, buf);
1011#endif 1018#endif
1012 1019
1013 lcd_update(); 1020 lcd_update();
1014 if (action_userabort(HZ/10)) 1021 if (action_userabort(HZ/10))
1015 return false; 1022 return false;
@@ -1128,15 +1135,15 @@ bool dbg_ports(void)
1128 break; 1135 break;
1129 } 1136 }
1130 lcd_puts(0, 0, buf); 1137 lcd_puts(0, 0, buf);
1131 1138
1132 battery_voltage = (adc_read(ADC_UNREG_POWER) * 1139 battery_voltage = (adc_read(ADC_UNREG_POWER) *
1133 BATTERY_SCALE_FACTOR) / 10000; 1140 BATTERY_SCALE_FACTOR) / 10000;
1134 batt_int = battery_voltage / 100; 1141 batt_int = battery_voltage / 100;
1135 batt_frac = battery_voltage % 100; 1142 batt_frac = battery_voltage % 100;
1136 1143
1137 snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); 1144 snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac);
1138 lcd_puts(0, 1, buf); 1145 lcd_puts(0, 1, buf);
1139 1146
1140 button = get_action(CONTEXT_SETTINGS,HZ/5); 1147 button = get_action(CONTEXT_SETTINGS,HZ/5);
1141 1148
1142 switch(button) 1149 switch(button)
@@ -1179,7 +1186,7 @@ bool dbg_cpufreq(void)
1179 while(1) 1186 while(1)
1180 { 1187 {
1181 line = 0; 1188 line = 0;
1182 1189
1183 snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ); 1190 snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ);
1184 lcd_puts(0, line++, buf); 1191 lcd_puts(0, line++, buf);
1185 1192
@@ -1212,7 +1219,7 @@ bool dbg_cpufreq(void)
1212 return false; 1219 return false;
1213} 1220}
1214#endif /* HAVE_ADJUSTABLE_CPU_FREQ */ 1221#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1215 1222
1216#ifdef HAVE_LCD_BITMAP 1223#ifdef HAVE_LCD_BITMAP
1217/* 1224/*
1218 * view_battery() shows a automatically scaled graph of the battery voltage 1225 * view_battery() shows a automatically scaled graph of the battery voltage
@@ -1229,7 +1236,7 @@ bool view_battery(void)
1229 int i, x, y; 1236 int i, x, y;
1230 unsigned short maxv, minv; 1237 unsigned short maxv, minv;
1231 char buf[32]; 1238 char buf[32];
1232 1239
1233 lcd_setmargins(0, 0); 1240 lcd_setmargins(0, 0);
1234 lcd_setfont(FONT_SYSFIXED); 1241 lcd_setfont(FONT_SYSFIXED);
1235 1242
@@ -1248,20 +1255,20 @@ bool view_battery(void)
1248 minv = power_history[i]; 1255 minv = power_history[i];
1249 } 1256 }
1250 } 1257 }
1251 1258
1252 if ((minv < 1) || (minv >= 65535)) 1259 if ((minv < 1) || (minv >= 65535))
1253 minv = 1; 1260 minv = 1;
1254 if (maxv < 2) 1261 if (maxv < 2)
1255 maxv = 2; 1262 maxv = 2;
1256 1263
1257 lcd_clear_display(); 1264 lcd_clear_display();
1258 snprintf(buf, 30, "Battery %d.%02d", power_history[0] / 100, 1265 snprintf(buf, 30, "Battery %d.%02d", power_history[0] / 100,
1259 power_history[0] % 100); 1266 power_history[0] % 100);
1260 lcd_puts(0, 0, buf); 1267 lcd_puts(0, 0, buf);
1261 snprintf(buf, 30, "scale %d.%02d-%d.%02d V", 1268 snprintf(buf, 30, "scale %d.%02d-%d.%02d V",
1262 minv / 100, minv % 100, maxv / 100, maxv % 100); 1269 minv / 100, minv % 100, maxv / 100, maxv % 100);
1263 lcd_puts(0, 1, buf); 1270 lcd_puts(0, 1, buf);
1264 1271
1265 x = 0; 1272 x = 0;
1266 for (i = BAT_LAST_VAL - 1; i >= 0; i--) { 1273 for (i = BAT_LAST_VAL - 1; i >= 0; i--) {
1267 y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv); 1274 y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv);
@@ -1274,7 +1281,7 @@ bool view_battery(void)
1274 } 1281 }
1275 1282
1276 break; 1283 break;
1277 1284
1278 case 1: /* status: */ 1285 case 1: /* status: */
1279 lcd_clear_display(); 1286 lcd_clear_display();
1280 lcd_puts(0, 0, "Power status:"); 1287 lcd_puts(0, 0, "Power status:");
@@ -1289,7 +1296,7 @@ bool view_battery(void)
1289#endif 1296#endif
1290#ifdef CONFIG_CHARGING 1297#ifdef CONFIG_CHARGING
1291#if CONFIG_CHARGING == CHARGING_CONTROL 1298#if CONFIG_CHARGING == CHARGING_CONTROL
1292 snprintf(buf, 30, "Chgr: %s %s", 1299 snprintf(buf, 30, "Chgr: %s %s",
1293 charger_inserted() ? "present" : "absent", 1300 charger_inserted() ? "present" : "absent",
1294 charger_enabled ? "on" : "off"); 1301 charger_enabled ? "on" : "off");
1295 lcd_puts(0, 3, buf); 1302 lcd_puts(0, 3, buf);
@@ -1329,15 +1336,15 @@ bool view_battery(void)
1329#endif /* CONFIG_CHARGING != CHARGING_CONTROL */ 1336#endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1330#endif /* CONFIG_CHARGING */ 1337#endif /* CONFIG_CHARGING */
1331 break; 1338 break;
1332 1339
1333 case 2: /* voltage deltas: */ 1340 case 2: /* voltage deltas: */
1334 lcd_clear_display(); 1341 lcd_clear_display();
1335 lcd_puts(0, 0, "Voltage deltas:"); 1342 lcd_puts(0, 0, "Voltage deltas:");
1336 1343
1337 for (i = 0; i <= 6; i++) { 1344 for (i = 0; i <= 6; i++) {
1338 y = power_history[i] - power_history[i+i]; 1345 y = power_history[i] - power_history[i+i];
1339 snprintf(buf, 30, "-%d min: %s%d.%02d V", i, 1346 snprintf(buf, 30, "-%d min: %s%d.%02d V", i,
1340 (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 100, 1347 (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 100,
1341 ((y < 0) ? y * -1 : y ) % 100); 1348 ((y < 0) ? y * -1 : y ) % 100);
1342 lcd_puts(0, i+1, buf); 1349 lcd_puts(0, i+1, buf);
1343 } 1350 }
@@ -1375,21 +1382,21 @@ bool view_battery(void)
1375 lcd_puts(0, 7, buf); 1382 lcd_puts(0, 7, buf);
1376 break; 1383 break;
1377 } 1384 }
1378 1385
1379 lcd_update(); 1386 lcd_update();
1380 1387
1381 switch(get_action(CONTEXT_SETTINGS,HZ/2)) 1388 switch(get_action(CONTEXT_SETTINGS,HZ/2))
1382 { 1389 {
1383 case ACTION_SETTINGS_DEC: 1390 case ACTION_SETTINGS_DEC:
1384 if (view) 1391 if (view)
1385 view--; 1392 view--;
1386 break; 1393 break;
1387 1394
1388 case ACTION_SETTINGS_INC: 1395 case ACTION_SETTINGS_INC:
1389 if (view < 3) 1396 if (view < 3)
1390 view++; 1397 view++;
1391 break; 1398 break;
1392 1399
1393 case ACTION_STD_CANCEL: 1400 case ACTION_STD_CANCEL:
1394 action_signalscreenchange(); 1401 action_signalscreenchange();
1395 return false; 1402 return false;
@@ -1399,7 +1406,7 @@ bool view_battery(void)
1399} 1406}
1400 1407
1401#endif /* HAVE_LCD_BITMAP */ 1408#endif /* HAVE_LCD_BITMAP */
1402 1409
1403static bool view_runtime(void) 1410static bool view_runtime(void)
1404{ 1411{
1405 char s[32]; 1412 char s[32];
@@ -1441,7 +1448,7 @@ static bool view_runtime(void)
1441 t = global_settings.topruntime; 1448 t = global_settings.topruntime;
1442 lcd_puts(0, y++, "Top time"); 1449 lcd_puts(0, y++, "Top time");
1443 } 1450 }
1444 1451
1445 snprintf(s, sizeof(s), "%dh %dm %ds", 1452 snprintf(s, sizeof(s), "%dh %dm %ds",
1446 t / 3600, (t % 3600) / 60, t % 60); 1453 t / 3600, (t % 3600) / 60, t % 60);
1447 lcd_puts(0, y++, s); 1454 lcd_puts(0, y++, s);
@@ -1498,7 +1505,7 @@ bool dbg_mmc_info(void)
1498 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; 1505 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1499 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; 1506 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
1500 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" }; 1507 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
1501 1508
1502 card_name[6] = '\0'; 1509 card_name[6] = '\0';
1503 1510
1504 lcd_setmargins(0, 0); 1511 lcd_setmargins(0, 0);
@@ -1574,7 +1581,7 @@ bool dbg_mmc_info(void)
1574 case ACTION_STD_CANCEL: 1581 case ACTION_STD_CANCEL:
1575 done = true; 1582 done = true;
1576 break; 1583 break;
1577 1584
1578 case ACTION_SETTINGS_DEC: 1585 case ACTION_SETTINGS_DEC:
1579 currval--; 1586 currval--;
1580 if (currval < 0) 1587 if (currval < 0)
@@ -1606,7 +1613,7 @@ static bool dbg_disk_info(void)
1606#ifdef HAVE_LCD_BITMAP 1613#ifdef HAVE_LCD_BITMAP
1607 lcd_setmargins(0, 0); 1614 lcd_setmargins(0, 0);
1608#endif 1615#endif
1609 1616
1610 while(!done) 1617 while(!done)
1611 { 1618 {
1612 int y=0; 1619 int y=0;
@@ -1639,7 +1646,7 @@ static bool dbg_disk_info(void)
1639 1646
1640 case 2: 1647 case 2:
1641 snprintf(buf, sizeof buf, "%ld MB", 1648 snprintf(buf, sizeof buf, "%ld MB",
1642 ((unsigned long)identify_info[61] << 16 | 1649 ((unsigned long)identify_info[61] << 16 |
1643 (unsigned long)identify_info[60]) / 2048 ); 1650 (unsigned long)identify_info[60]) / 2048 );
1644 lcd_puts(0, y++, "Size"); 1651 lcd_puts(0, y++, "Size");
1645 lcd_puts(0, y++, buf); 1652 lcd_puts(0, y++, buf);
@@ -1739,7 +1746,7 @@ static bool dbg_disk_info(void)
1739 if (--page < 0) 1746 if (--page < 0)
1740 page = max_page; 1747 page = max_page;
1741 break; 1748 break;
1742 1749
1743 case ACTION_SETTINGS_INC: 1750 case ACTION_SETTINGS_INC:
1744 if (++page > max_page) 1751 if (++page > max_page)
1745 page = 0; 1752 page = 0;
@@ -1765,9 +1772,9 @@ static bool dbg_dircache_info(void)
1765 while (!done) 1772 while (!done)
1766 { 1773 {
1767 line = 0; 1774 line = 0;
1768 1775
1769 lcd_clear_display(); 1776 lcd_clear_display();
1770 snprintf(buf, sizeof(buf), "Cache initialized: %s", 1777 snprintf(buf, sizeof(buf), "Cache initialized: %s",
1771 dircache_is_enabled() ? "Yes" : "No"); 1778 dircache_is_enabled() ? "Yes" : "No");
1772 lcd_puts(0, line++, buf); 1779 lcd_puts(0, line++, buf);
1773 1780
@@ -1819,25 +1826,25 @@ static bool dbg_tagcache_info(void)
1819 while (!done) 1826 while (!done)
1820 { 1827 {
1821 line = 0; 1828 line = 0;
1822 1829
1823 lcd_clear_display(); 1830 lcd_clear_display();
1824 stat = tagcache_get_stat(); 1831 stat = tagcache_get_stat();
1825 snprintf(buf, sizeof(buf), "Initialized: %s", stat->initialized ? "Yes" : "No"); 1832 snprintf(buf, sizeof(buf), "Initialized: %s", stat->initialized ? "Yes" : "No");
1826 lcd_puts(0, line++, buf); 1833 lcd_puts(0, line++, buf);
1827 snprintf(buf, sizeof(buf), "DB Ready: %s", stat->ready ? "Yes" : "No"); 1834 snprintf(buf, sizeof(buf), "DB Ready: %s", stat->ready ? "Yes" : "No");
1828 lcd_puts(0, line++, buf); 1835 lcd_puts(0, line++, buf);
1829 snprintf(buf, sizeof(buf), "RAM Cache: %s", stat->ramcache ? "Yes" : "No"); 1836 snprintf(buf, sizeof(buf), "RAM Cache: %s", stat->ramcache ? "Yes" : "No");
1830 lcd_puts(0, line++, buf); 1837 lcd_puts(0, line++, buf);
1831 snprintf(buf, sizeof(buf), "RAM: %d/%d B", 1838 snprintf(buf, sizeof(buf), "RAM: %d/%d B",
1832 stat->ramcache_used, stat->ramcache_allocated); 1839 stat->ramcache_used, stat->ramcache_allocated);
1833 lcd_puts(0, line++, buf); 1840 lcd_puts(0, line++, buf);
1834 snprintf(buf, sizeof(buf), "Progress: %d%% (%d entries)", 1841 snprintf(buf, sizeof(buf), "Progress: %d%% (%d entries)",
1835 stat->progress, stat->processed_entries); 1842 stat->progress, stat->processed_entries);
1836 lcd_puts(0, line++, buf); 1843 lcd_puts(0, line++, buf);
1837 snprintf(buf, sizeof(buf), "Commit step: %d", stat->commit_step); 1844 snprintf(buf, sizeof(buf), "Commit step: %d", stat->commit_step);
1838 lcd_puts(0, line++, buf); 1845 lcd_puts(0, line++, buf);
1839 snprintf(buf, sizeof(buf), "Commit delayed: %s", 1846 snprintf(buf, sizeof(buf), "Commit delayed: %s",
1840 stat->commit_delayed ? "Yes" : "No"); 1847 stat->commit_delayed ? "Yes" : "No");
1841 lcd_puts(0, line++, buf); 1848 lcd_puts(0, line++, buf);
1842 1849
1843 lcd_update(); 1850 lcd_update();
@@ -1892,7 +1899,7 @@ bool dbg_save_roms(void)
1892 close(fd); 1899 close(fd);
1893 } 1900 }
1894 system_memory_guard(oldmode); 1901 system_memory_guard(oldmode);
1895 1902
1896#ifdef HAVE_EEPROM 1903#ifdef HAVE_EEPROM
1897 fd = creat("/internal_eeprom.bin", O_WRONLY); 1904 fd = creat("/internal_eeprom.bin", O_WRONLY);
1898 if (fd >= 0) 1905 if (fd >= 0)
@@ -1916,7 +1923,7 @@ bool dbg_save_roms(void)
1916 close(fd); 1923 close(fd);
1917 } 1924 }
1918#endif 1925#endif
1919 1926
1920 return false; 1927 return false;
1921} 1928}
1922#endif /* CPU */ 1929#endif /* CPU */
@@ -1938,10 +1945,10 @@ bool dbg_fm_radio(void)
1938 1945
1939 lcd_clear_display(); 1946 lcd_clear_display();
1940 fm_detected = radio_hardware_present(); 1947 fm_detected = radio_hardware_present();
1941 1948
1942 snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no"); 1949 snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no");
1943 lcd_puts(0, row++, buf); 1950 lcd_puts(0, row++, buf);
1944 1951
1945#if (CONFIG_TUNER & S1A0903X01) 1952#if (CONFIG_TUNER & S1A0903X01)
1946 regs = samsung_get(RADIO_ALL); 1953 regs = samsung_get(RADIO_ALL);
1947 snprintf(buf, sizeof buf, "Samsung regs: %08lx", regs); 1954 snprintf(buf, sizeof buf, "Samsung regs: %08lx", regs);
@@ -1954,7 +1961,7 @@ bool dbg_fm_radio(void)
1954#endif 1961#endif
1955 1962
1956 lcd_update(); 1963 lcd_update();
1957 1964
1958 if (action_userabort(HZ)) 1965 if (action_userabort(HZ))
1959 return false; 1966 return false;
1960 } 1967 }
@@ -1983,7 +1990,7 @@ bool dbg_set_memory_guard(void)
1983 { "Zero area (all)", -1 } 1990 { "Zero area (all)", -1 }
1984 }; 1991 };
1985 int mode = system_memory_guard(MEMGUARD_KEEP); 1992 int mode = system_memory_guard(MEMGUARD_KEEP);
1986 1993
1987 set_option( "Catch mem accesses", &mode, INT, names, MAXMEMGUARD, NULL); 1994 set_option( "Catch mem accesses", &mode, INT, names, MAXMEMGUARD, NULL);
1988 system_memory_guard(mode); 1995 system_memory_guard(mode);
1989 1996
@@ -1999,7 +2006,7 @@ bool dbg_write_eeprom(void)
1999 int old_irq_level; 2006 int old_irq_level;
2000 char buf[EEPROM_SIZE]; 2007 char buf[EEPROM_SIZE];
2001 int err; 2008 int err;
2002 2009
2003 fd = open("/internal_eeprom.bin", O_RDONLY); 2010 fd = open("/internal_eeprom.bin", O_RDONLY);
2004 2011
2005 if (fd >= 0) 2012 if (fd >= 0)
@@ -2093,7 +2100,7 @@ bool debug_menu(void)
2093 NULL, NULL, NULL); 2100 NULL, NULL, NULL);
2094 result = menu_run(m); 2101 result = menu_run(m);
2095 menu_exit(m); 2102 menu_exit(m);
2096 2103
2097 return result; 2104 return result;
2098} 2105}
2099 2106