diff options
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 121 |
1 files changed, 98 insertions, 23 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 627d7f7bea..8e16ff1c21 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -124,6 +124,10 @@ | |||
124 | 124 | ||
125 | #include "talk.h" | 125 | #include "talk.h" |
126 | 126 | ||
127 | #if defined(HAVE_DEVICEDATA)// && !defined(SIMULATOR) | ||
128 | #include "devicedata.h" | ||
129 | #endif | ||
130 | |||
127 | #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) | 131 | #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) |
128 | #include "bootdata.h" | 132 | #include "bootdata.h" |
129 | #include "multiboot.h" | 133 | #include "multiboot.h" |
@@ -557,14 +561,16 @@ static const char* dbg_partitions_getname(int selected_item, void *data, | |||
557 | if (!disk_partinfo(partition, &p)) | 561 | if (!disk_partinfo(partition, &p)) |
558 | return buffer; | 562 | return buffer; |
559 | 563 | ||
564 | // XXX fix this up to use logical sector size | ||
565 | // XXX and if mounted, show free info... | ||
560 | if (selected_item%2) | 566 | if (selected_item%2) |
561 | { | 567 | { |
562 | snprintf(buffer, buffer_len, " T:%x %ld MB", p.type, | 568 | snprintf(buffer, buffer_len, " T:%x %llu MB", p.type, |
563 | p.size / ( 2048 / ( SECTOR_SIZE / 512 ))); | 569 | (uint64_t)(p.size / ( 2048 / ( SECTOR_SIZE / 512 )))); |
564 | } | 570 | } |
565 | else | 571 | else |
566 | { | 572 | { |
567 | snprintf(buffer, buffer_len, "P%d: S:%lx", partition, p.start); | 573 | snprintf(buffer, buffer_len, "P%d: S:%llx", partition, (uint64_t)p.start); |
568 | } | 574 | } |
569 | return buffer; | 575 | return buffer; |
570 | } | 576 | } |
@@ -572,7 +578,7 @@ static const char* dbg_partitions_getname(int selected_item, void *data, | |||
572 | static bool dbg_partitions(void) | 578 | static bool dbg_partitions(void) |
573 | { | 579 | { |
574 | struct simplelist_info info; | 580 | struct simplelist_info info; |
575 | simplelist_info_init(&info, "Partition Info", NUM_DRIVES * 4, NULL); | 581 | simplelist_info_init(&info, "Partition Info", NUM_DRIVES * MAX_PARTITIONS_PER_DRIVE, NULL); |
576 | info.selection_size = 2; | 582 | info.selection_size = 2; |
577 | info.scroll_all = true; | 583 | info.scroll_all = true; |
578 | info.get_name = dbg_partitions_getname; | 584 | info.get_name = dbg_partitions_getname; |
@@ -1343,6 +1349,22 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1343 | "R2W: *%d", card->r2w_factor); | 1349 | "R2W: *%d", card->r2w_factor); |
1344 | #if (CONFIG_STORAGE & STORAGE_SD) | 1350 | #if (CONFIG_STORAGE & STORAGE_SD) |
1345 | int csd_structure = card_extract_bits(card->csd, 127, 2); | 1351 | int csd_structure = card_extract_bits(card->csd, 127, 2); |
1352 | const char *ver; | ||
1353 | switch(csd_structure) { | ||
1354 | case 0: | ||
1355 | ver = "1 (SD)"; | ||
1356 | break; | ||
1357 | case 1: | ||
1358 | ver = "2 (SDHC/SDXC)"; | ||
1359 | break; | ||
1360 | case 2: | ||
1361 | ver = "3 (SDUC)"; | ||
1362 | break; | ||
1363 | default: | ||
1364 | ver = "Unknown"; | ||
1365 | break; | ||
1366 | } | ||
1367 | simplelist_addline("SDVer: %s\n", ver); | ||
1346 | if (csd_structure == 0) /* CSD version 1.0 */ | 1368 | if (csd_structure == 0) /* CSD version 1.0 */ |
1347 | #endif | 1369 | #endif |
1348 | { | 1370 | { |
@@ -1407,15 +1429,41 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1407 | buf[8]=0; | 1429 | buf[8]=0; |
1408 | simplelist_addline( | 1430 | simplelist_addline( |
1409 | "Firmware: %s", buf); | 1431 | "Firmware: %s", buf); |
1410 | snprintf(buf, sizeof buf, "%ld MB", | 1432 | |
1411 | ((unsigned long)identify_info[61] << 16 | | 1433 | uint64_t total_sectors = identify_info[60] | (identify_info[61] << 16); |
1412 | (unsigned long)identify_info[60]) / 2048 ); | 1434 | #ifdef HAVE_LBA48 |
1435 | if (identify_info[83] & 0x0400 | ||
1436 | && total_sectors == 0x0FFFFFFF) | ||
1437 | total_sectors = identify_info[100] | (identify_info[101] << 16) | ((uint64_t)identify_info[102] << 32) | ((uint64_t)identify_info[103] << 48); | ||
1438 | #endif | ||
1439 | |||
1440 | uint32_t sector_size; | ||
1441 | |||
1442 | /* Logical sector size > 512B ? */ | ||
1443 | if ((identify_info[106] & 0xd000) == 0x5000) | ||
1444 | sector_size = identify_info[117] | (identify_info[118] << 16); | ||
1445 | else | ||
1446 | sector_size = SECTOR_SIZE; | ||
1447 | |||
1448 | total_sectors *= sector_size; /* Convert to bytes */ | ||
1449 | total_sectors /= (1024 * 1024); /* Convert to MB */ | ||
1450 | |||
1451 | simplelist_addline("Size: %llu MB", total_sectors); | ||
1452 | simplelist_addline("Logical sector size: %u B", sector_size); | ||
1453 | |||
1454 | if((identify_info[106] & 0xe000) == 0x6000) | ||
1455 | sector_size *= BIT_N(identify_info[106] & 0x000f); | ||
1413 | simplelist_addline( | 1456 | simplelist_addline( |
1414 | "Size: %s", buf); | 1457 | "Physical sector size: %d B", sector_size); |
1415 | unsigned long free; | 1458 | |
1459 | #ifndef HAVE_MULTIVOLUME | ||
1460 | // XXX this needs to be fixed for multi-volume setups | ||
1461 | sector_t free; | ||
1416 | volume_size( IF_MV(0,) NULL, &free ); | 1462 | volume_size( IF_MV(0,) NULL, &free ); |
1417 | simplelist_addline( | 1463 | simplelist_addline( |
1418 | "Free: %ld MB", free / 1024); | 1464 | "Free: %llu MB", free / 1024); |
1465 | #endif | ||
1466 | |||
1419 | simplelist_addline("SSD detected: %s", ata_disk_isssd() ? "yes" : "no"); | 1467 | simplelist_addline("SSD detected: %s", ata_disk_isssd() ? "yes" : "no"); |
1420 | simplelist_addline( | 1468 | simplelist_addline( |
1421 | "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); | 1469 | "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); |
@@ -1452,11 +1500,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1452 | simplelist_addline( | 1500 | simplelist_addline( |
1453 | "No timing info"); | 1501 | "No timing info"); |
1454 | } | 1502 | } |
1455 | int sector_size = 512; | 1503 | |
1456 | if((identify_info[106] & 0xe000) == 0x6000) | ||
1457 | sector_size *= BIT_N(identify_info[106] & 0x000f); | ||
1458 | simplelist_addline( | ||
1459 | "Physical sector size: %d", sector_size); | ||
1460 | #ifdef HAVE_ATA_DMA | 1504 | #ifdef HAVE_ATA_DMA |
1461 | if (identify_info[63] & (1<<0)) { | 1505 | if (identify_info[63] & (1<<0)) { |
1462 | simplelist_addline( | 1506 | simplelist_addline( |
@@ -1751,8 +1795,8 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1751 | simplelist_addline("Model: %s", info.product); | 1795 | simplelist_addline("Model: %s", info.product); |
1752 | simplelist_addline("Firmware: %s", info.revision); | 1796 | simplelist_addline("Firmware: %s", info.revision); |
1753 | simplelist_addline( | 1797 | simplelist_addline( |
1754 | "Size: %ld MB", info.num_sectors*(info.sector_size/512)/2024); | 1798 | "Size: %lld MB", (uint64_t)(info.num_sectors*(info.sector_size/512)/2048)); |
1755 | unsigned long free; | 1799 | sector_t free; |
1756 | volume_size( IF_MV(0,) NULL, &free ); | 1800 | volume_size( IF_MV(0,) NULL, &free ); |
1757 | simplelist_addline( | 1801 | simplelist_addline( |
1758 | "Free: %ld MB", free / 1024); | 1802 | "Free: %ld MB", free / 1024); |
@@ -1771,13 +1815,13 @@ static bool dbg_identify_info(void) | |||
1771 | const unsigned short *identify_info = ata_get_identify(); | 1815 | const unsigned short *identify_info = ata_get_identify(); |
1772 | #ifdef ROCKBOX_LITTLE_ENDIAN | 1816 | #ifdef ROCKBOX_LITTLE_ENDIAN |
1773 | /* this is a pointer to a driver buffer so we can't modify it */ | 1817 | /* this is a pointer to a driver buffer so we can't modify it */ |
1774 | for (int i = 0; i < SECTOR_SIZE/2; ++i) | 1818 | for (int i = 0; i < ATA_IDENTIFY_WORDS; ++i) |
1775 | { | 1819 | { |
1776 | unsigned short word = swap16(identify_info[i]); | 1820 | unsigned short word = swap16(identify_info[i]); |
1777 | write(fd, &word, 2); | 1821 | write(fd, &word, 2); |
1778 | } | 1822 | } |
1779 | #else | 1823 | #else |
1780 | write(fd, identify_info, SECTOR_SIZE); | 1824 | write(fd, identify_info, ATA_IDENTIFY_WORDS*2); |
1781 | #endif | 1825 | #endif |
1782 | close(fd); | 1826 | close(fd); |
1783 | } | 1827 | } |
@@ -2585,8 +2629,35 @@ static bool dbg_boot_data(void) | |||
2585 | } | 2629 | } |
2586 | #endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */ | 2630 | #endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */ |
2587 | 2631 | ||
2632 | #if defined(HAVE_DEVICEDATA)// && !defined(SIMULATOR) | ||
2633 | static bool dbg_device_data(void) | ||
2634 | { | ||
2635 | struct simplelist_info info; | ||
2636 | info.scroll_all = true; | ||
2637 | simplelist_info_init(&info, "Device data", 1, NULL); | ||
2638 | simplelist_set_line_count(0); | ||
2639 | |||
2640 | simplelist_addline("Device data"); | ||
2641 | |||
2642 | #if defined(EROS_QN) | ||
2643 | simplelist_addline("Lcd Version: %d", (int)device_data.lcd_version); | ||
2644 | #endif | ||
2645 | |||
2646 | simplelist_addline("Device data RAW:"); | ||
2647 | for (size_t i = 0; i < device_data.length; i += 4) | ||
2648 | { | ||
2649 | simplelist_addline("%02x: %02x %02x %02x %02x", i, | ||
2650 | device_data.payload[i + 0], device_data.payload[i + 1], | ||
2651 | device_data.payload[i + 2], device_data.payload[i + 3]); | ||
2652 | } | ||
2653 | |||
2654 | return simplelist_show_list(&info); | ||
2655 | } | ||
2656 | #endif /* defined(HAVE_DEVICEDATA)*/ | ||
2657 | |||
2658 | |||
2588 | #if defined(IPOD_6G) && !defined(SIMULATOR) | 2659 | #if defined(IPOD_6G) && !defined(SIMULATOR) |
2589 | #define SYSCFG_MAX_ENTRIES 10 // 9 on iPod Classic/6G | 2660 | #define SYSCFG_MAX_ENTRIES 9 // 9 on iPod Classic/6G |
2590 | 2661 | ||
2591 | static bool dbg_syscfg(void) { | 2662 | static bool dbg_syscfg(void) { |
2592 | struct simplelist_info info; | 2663 | struct simplelist_info info; |
@@ -2607,8 +2678,7 @@ static bool dbg_syscfg(void) { | |||
2607 | return simplelist_show_list(&info); | 2678 | return simplelist_show_list(&info); |
2608 | } | 2679 | } |
2609 | 2680 | ||
2610 | simplelist_addline("Total size: %u bytes", syscfg_hdr.size); | 2681 | simplelist_addline("Total size: %u bytes, %u entries", syscfg_hdr.size, syscfg_hdr.num_entries); |
2611 | simplelist_addline("Entries: %u", syscfg_hdr.num_entries); | ||
2612 | 2682 | ||
2613 | size_t calculated_syscfg_size = syscfg_hdr_size + syscfg_entry_size * syscfg_hdr.num_entries; | 2683 | size_t calculated_syscfg_size = syscfg_hdr_size + syscfg_entry_size * syscfg_hdr.num_entries; |
2614 | 2684 | ||
@@ -2619,7 +2689,7 @@ static bool dbg_syscfg(void) { | |||
2619 | } | 2689 | } |
2620 | 2690 | ||
2621 | if (syscfg_hdr.num_entries > SYSCFG_MAX_ENTRIES) { | 2691 | if (syscfg_hdr.num_entries > SYSCFG_MAX_ENTRIES) { |
2622 | simplelist_addline("Too many entries, showing first %u", syscfg_hdr.num_entries); | 2692 | simplelist_addline("Too many entries, showing only first %u", SYSCFG_MAX_ENTRIES); |
2623 | } | 2693 | } |
2624 | 2694 | ||
2625 | size_t syscfg_num_entries = MIN(syscfg_hdr.num_entries, SYSCFG_MAX_ENTRIES); | 2695 | size_t syscfg_num_entries = MIN(syscfg_hdr.num_entries, SYSCFG_MAX_ENTRIES); |
@@ -2784,6 +2854,11 @@ static const struct { | |||
2784 | #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) | 2854 | #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) |
2785 | {"Boot data", dbg_boot_data }, | 2855 | {"Boot data", dbg_boot_data }, |
2786 | #endif | 2856 | #endif |
2857 | |||
2858 | #if defined(HAVE_DEVICEDATA)// && !defined(SIMULATOR) | ||
2859 | {"Device data", dbg_device_data }, | ||
2860 | #endif | ||
2861 | |||
2787 | #if defined(IPOD_6G) && !defined(SIMULATOR) | 2862 | #if defined(IPOD_6G) && !defined(SIMULATOR) |
2788 | {"View SysCfg", dbg_syscfg }, | 2863 | {"View SysCfg", dbg_syscfg }, |
2789 | #endif | 2864 | #endif |