diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 355 |
1 files changed, 0 insertions, 355 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a43dd0a768..b557f46dc3 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -416,361 +416,6 @@ static bool dbg_buffering_thread(void) | |||
416 | #endif /* CONFIG_CODEC */ | 416 | #endif /* CONFIG_CODEC */ |
417 | #endif /* HAVE_LCD_BITMAP */ | 417 | #endif /* HAVE_LCD_BITMAP */ |
418 | 418 | ||
419 | |||
420 | #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)) | ||
421 | /* Tool function to read the flash manufacturer and type, if available. | ||
422 | Only chips which could be reprogrammed in system will return values. | ||
423 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
424 | /* In IRAM to avoid problems when running directly from Flash */ | ||
425 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
426 | unsigned addr1, unsigned addr2) | ||
427 | ICODE_ATTR __attribute__((noinline)); | ||
428 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
429 | unsigned addr1, unsigned addr2) | ||
430 | |||
431 | { | ||
432 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
433 | unsigned manu, id; /* read values when in ID mode */ | ||
434 | |||
435 | #if CONFIG_CPU == SH7034 | ||
436 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ | ||
437 | #elif defined(CPU_COLDFIRE) | ||
438 | volatile unsigned short* flash = (unsigned short*)0; /* flash mapping */ | ||
439 | #endif | ||
440 | int old_level; /* saved interrupt level */ | ||
441 | |||
442 | not_manu = flash[0]; /* read the normal content */ | ||
443 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
444 | |||
445 | /* disable interrupts, prevent any stray flash access */ | ||
446 | old_level = disable_irq_save(); | ||
447 | |||
448 | flash[addr1] = 0xAA; /* enter command mode */ | ||
449 | flash[addr2] = 0x55; | ||
450 | flash[addr1] = 0x90; /* ID command */ | ||
451 | /* Atmel wants 20ms pause here */ | ||
452 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
453 | |||
454 | manu = flash[0]; /* read the IDs */ | ||
455 | id = flash[1]; | ||
456 | |||
457 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
458 | /* Atmel wants 20ms pause here */ | ||
459 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
460 | |||
461 | restore_irq(old_level); /* enable interrupts again */ | ||
462 | |||
463 | /* I assume success if the obtained values are different from | ||
464 | the normal flash content. This is not perfectly bulletproof, they | ||
465 | could theoretically be the same by chance, causing us to fail. */ | ||
466 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
467 | { | ||
468 | *p_manufacturer = manu; /* return the results */ | ||
469 | *p_device = id; | ||
470 | return true; /* success */ | ||
471 | } | ||
472 | return false; /* fail */ | ||
473 | } | ||
474 | #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */ | ||
475 | |||
476 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | ||
477 | #ifdef CPU_PP | ||
478 | static int perfcheck(void) | ||
479 | { | ||
480 | int result; | ||
481 | |||
482 | asm ( | ||
483 | "mrs r2, CPSR \n" | ||
484 | "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */ | ||
485 | "msr CPSR_c, r0 \n" | ||
486 | "mov %[res], #0 \n" | ||
487 | "ldr r0, [%[timr]] \n" | ||
488 | "add r0, r0, %[tmo] \n" | ||
489 | "1: \n" | ||
490 | "add %[res], %[res], #1 \n" | ||
491 | "ldr r1, [%[timr]] \n" | ||
492 | "cmp r1, r0 \n" | ||
493 | "bmi 1b \n" | ||
494 | "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */ | ||
495 | : | ||
496 | [res]"=&r"(result) | ||
497 | : | ||
498 | [timr]"r"(&USEC_TIMER), | ||
499 | [tmo]"r"( | ||
500 | #if CONFIG_CPU == PP5002 | ||
501 | 16000 | ||
502 | #else /* PP5020/5022/5024 */ | ||
503 | 10226 | ||
504 | #endif | ||
505 | ) | ||
506 | : | ||
507 | "r0", "r1", "r2" | ||
508 | ); | ||
509 | return result; | ||
510 | } | ||
511 | #endif | ||
512 | |||
513 | #ifdef HAVE_LCD_BITMAP | ||
514 | static bool dbg_hw_info(void) | ||
515 | { | ||
516 | #if CONFIG_CPU == SH7034 | ||
517 | int bitmask = HW_MASK; | ||
518 | int rom_version = ROM_VERSION; | ||
519 | unsigned manu, id; /* flash IDs */ | ||
520 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
521 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ | ||
522 | bool has_bootrom; /* flag for boot ROM present */ | ||
523 | int oldmode; /* saved memory guard mode */ | ||
524 | |||
525 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
526 | |||
527 | /* get flash ROM type */ | ||
528 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
529 | if (!got_id) | ||
530 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
531 | |||
532 | /* check if the boot ROM area is a flash mirror */ | ||
533 | has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); | ||
534 | if (has_bootrom) /* if ROM and Flash different */ | ||
535 | { | ||
536 | /* calculate CRC16 checksum of boot ROM */ | ||
537 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); | ||
538 | } | ||
539 | |||
540 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
541 | |||
542 | lcd_setfont(FONT_SYSFIXED); | ||
543 | lcd_clear_display(); | ||
544 | |||
545 | lcd_puts(0, 0, "[Hardware info]"); | ||
546 | |||
547 | lcd_putsf(0, 1, "ROM: %d.%02d", rom_version/100, rom_version%100); | ||
548 | |||
549 | lcd_putsf(0, 2, "Mask: 0x%04x", bitmask); | ||
550 | |||
551 | if (got_id) | ||
552 | lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu, id); | ||
553 | else | ||
554 | lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */ | ||
555 | |||
556 | if (has_bootrom) | ||
557 | { | ||
558 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
559 | lcd_puts(0, 4, "Boot ROM: V1"); | ||
560 | else | ||
561 | lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc); | ||
562 | } | ||
563 | else | ||
564 | { | ||
565 | lcd_puts(0, 4, "Boot ROM: none"); | ||
566 | } | ||
567 | |||
568 | lcd_update(); | ||
569 | |||
570 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
571 | |||
572 | #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250 | ||
573 | unsigned manu, id; /* flash IDs */ | ||
574 | int got_id; /* flag if we managed to get the flash IDs */ | ||
575 | int oldmode; /* saved memory guard mode */ | ||
576 | int line = 0; | ||
577 | |||
578 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
579 | |||
580 | /* get flash ROM type */ | ||
581 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
582 | if (!got_id) | ||
583 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
584 | |||
585 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
586 | |||
587 | lcd_setfont(FONT_SYSFIXED); | ||
588 | lcd_clear_display(); | ||
589 | |||
590 | lcd_puts(0, line++, "[Hardware info]"); | ||
591 | |||
592 | if (got_id) | ||
593 | lcd_putsf(0, line++, "Flash: M=%04x D=%04x", manu, id); | ||
594 | else | ||
595 | lcd_puts(0, line++, "Flash: M=???? D=????"); /* unknown, sorry */ | ||
596 | |||
597 | #ifdef IAUDIO_X5 | ||
598 | { | ||
599 | struct ds2411_id id; | ||
600 | |||
601 | lcd_puts(0, ++line, "Serial Number:"); | ||
602 | |||
603 | got_id = ds2411_read_id(&id); | ||
604 | |||
605 | if (got_id == DS2411_OK) | ||
606 | { | ||
607 | lcd_putsf(0, ++line, " FC=%02x", (unsigned)id.family_code); | ||
608 | lcd_putsf(0, ++line, " ID=%02X %02X %02X %02X %02X %02X", | ||
609 | (unsigned)id.uid[0], (unsigned)id.uid[1], (unsigned)id.uid[2], | ||
610 | (unsigned)id.uid[3], (unsigned)id.uid[4], (unsigned)id.uid[5]); | ||
611 | lcd_putsf(0, ++line, " CRC=%02X", (unsigned)id.crc); | ||
612 | } | ||
613 | else | ||
614 | { | ||
615 | lcd_putsf(0, ++line, "READ ERR=%d", got_id); | ||
616 | } | ||
617 | } | ||
618 | #endif | ||
619 | |||
620 | lcd_update(); | ||
621 | |||
622 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
623 | |||
624 | #elif defined(CPU_PP502x) | ||
625 | int line = 0; | ||
626 | char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff, | ||
627 | (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff, | ||
628 | (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff, | ||
629 | (PP_VER1 >> 8) & 0xff, (PP_VER1) & 0xff, '\0' }; | ||
630 | |||
631 | lcd_setfont(FONT_SYSFIXED); | ||
632 | lcd_clear_display(); | ||
633 | |||
634 | lcd_puts(0, line++, "[Hardware info]"); | ||
635 | |||
636 | #ifdef IPOD_ARCH | ||
637 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
638 | #endif | ||
639 | |||
640 | #ifdef IPOD_COLOR | ||
641 | extern int lcd_type; /* Defined in lcd-colornano.c */ | ||
642 | |||
643 | lcd_putsf(0, line++, "LCD type: %d", lcd_type); | ||
644 | #endif | ||
645 | |||
646 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
647 | |||
648 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
649 | |||
650 | lcd_update(); | ||
651 | |||
652 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
653 | |||
654 | #elif CONFIG_CPU == PP5002 | ||
655 | int line = 0; | ||
656 | char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff, | ||
657 | (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff, | ||
658 | (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff, | ||
659 | (PP_VER1 >> 8) & 0xff, PP_VER1 & 0xff, '\0' }; | ||
660 | |||
661 | |||
662 | lcd_setfont(FONT_SYSFIXED); | ||
663 | lcd_clear_display(); | ||
664 | |||
665 | lcd_puts(0, line++, "[Hardware info]"); | ||
666 | |||
667 | #ifdef IPOD_ARCH | ||
668 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
669 | #endif | ||
670 | |||
671 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
672 | |||
673 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
674 | |||
675 | lcd_update(); | ||
676 | |||
677 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
678 | |||
679 | #else | ||
680 | /* Define this function in your target tree */ | ||
681 | return __dbg_hw_info(); | ||
682 | #endif /* CONFIG_CPU */ | ||
683 | lcd_setfont(FONT_UI); | ||
684 | return false; | ||
685 | } | ||
686 | #else /* !HAVE_LCD_BITMAP */ | ||
687 | static bool dbg_hw_info(void) | ||
688 | { | ||
689 | int button; | ||
690 | int currval = 0; | ||
691 | int rom_version = ROM_VERSION; | ||
692 | unsigned manu, id; /* flash IDs */ | ||
693 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
694 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ | ||
695 | bool has_bootrom; /* flag for boot ROM present */ | ||
696 | int oldmode; /* saved memory guard mode */ | ||
697 | |||
698 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
699 | |||
700 | /* get flash ROM type */ | ||
701 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
702 | if (!got_id) | ||
703 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
704 | |||
705 | /* check if the boot ROM area is a flash mirror */ | ||
706 | has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); | ||
707 | if (has_bootrom) /* if ROM and Flash different */ | ||
708 | { | ||
709 | /* calculate CRC16 checksum of boot ROM */ | ||
710 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); | ||
711 | } | ||
712 | |||
713 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
714 | |||
715 | lcd_clear_display(); | ||
716 | |||
717 | lcd_puts(0, 0, "[HW Info]"); | ||
718 | while(1) | ||
719 | { | ||
720 | switch(currval) | ||
721 | { | ||
722 | case 0: | ||
723 | lcd_putsf(0, 1, "ROM: %d.%02d", | ||
724 | rom_version/100, rom_version%100); | ||
725 | break; | ||
726 | case 1: | ||
727 | if (got_id) | ||
728 | lcd_putsf(0, 1, "Flash:%02x,%02x", manu, id); | ||
729 | else | ||
730 | lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */ | ||
731 | break; | ||
732 | case 2: | ||
733 | if (has_bootrom) | ||
734 | { | ||
735 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
736 | lcd_puts(0, 1, "BootROM: V1"); | ||
737 | else if (rom_crc == 0x358099E8) | ||
738 | lcd_puts(0, 1, "BootROM: V2"); | ||
739 | /* alternative boot ROM found in one single player so far */ | ||
740 | else | ||
741 | lcd_putsf(0, 1, "R: %08x", rom_crc); | ||
742 | } | ||
743 | else | ||
744 | lcd_puts(0, 1, "BootROM: no"); | ||
745 | } | ||
746 | |||
747 | lcd_update(); | ||
748 | |||
749 | button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK); | ||
750 | |||
751 | switch(button) | ||
752 | { | ||
753 | case ACTION_STD_CANCEL: | ||
754 | return false; | ||
755 | |||
756 | case ACTION_SETTINGS_DEC: | ||
757 | currval--; | ||
758 | if(currval < 0) | ||
759 | currval = 2; | ||
760 | break; | ||
761 | |||
762 | case ACTION_SETTINGS_INC: | ||
763 | currval++; | ||
764 | if(currval > 2) | ||
765 | currval = 0; | ||
766 | break; | ||
767 | } | ||
768 | } | ||
769 | return false; | ||
770 | } | ||
771 | #endif /* !HAVE_LCD_BITMAP */ | ||
772 | #endif /* PLATFORM_NATIVE */ | ||
773 | |||
774 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 419 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
775 | static const char* dbg_partitions_getname(int selected_item, void *data, | 420 | static const char* dbg_partitions_getname(int selected_item, void *data, |
776 | char *buffer, size_t buffer_len) | 421 | char *buffer, size_t buffer_len) |