diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2024-07-05 16:00:30 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2024-08-12 14:23:44 -0400 |
commit | 15e52374698ba7395ff0ece0d3d70435a66406c4 (patch) | |
tree | 778f81817b2381decc920b49242e91f994f2d8ee /apps/debug_menu.c | |
parent | 9ff308a589f3655453fe047d9b08ca5e2a01f06d (diff) | |
download | rockbox-15e52374698ba7395ff0ece0d3d70435a66406c4.tar.gz rockbox-15e52374698ba7395ff0ece0d3d70435a66406c4.zip |
storage: 64-bit sector offsets
* Create new 'sector_t' type alias:
* uint64_t for all targets with HAVE_LBA48 or HAVE_SDUC
* unsigned long for the everything else
* Alter all storage APIs to use sector_t instead of 'unsigned long'
* Alter Volume/Partition/storage info structures to use sector_t
* Disk cache converted to sector_t
* ATA Core:
* convert to using sector_t for sector addresses and drive sizes
* Always fill out upper 16 bits of LBA48 addresses
* IDENTIFY INFO is fixed at 512 bytes, not SECTOR_SIZE
* USB mass storage:
* convert to using sector_t for sector addesses and drive sizes
* Implement READ_16/WRITE_16 for LBA48 addresses
* Convert FAT code to use sector_t for all sector references
* output_dyn_value() now accepts int64_t instead of 'int'
* Corrected "rockbox info" to work for (MULTIVOLUME & !MULTIDRIVE)
* Better reporting of disk and (logical+physical) sector sizes in debug info
* Detect SDUC cards and report on storage debug_info screen
To-do: SDUC
* Refactor SD core to remove duplicate code in every driver
* Card probe and init state machine
* Implement core SDUC support
* SD2.0 needs to be 2.0+ (fixed for jz47xx and x1000)
* Host and Card ID (ACMD41)
* 32-bit addressing for all read/write/erase operations (CMD22)
* ADD SDUC to target device drivers, defining HAVE_SDUC as appropriate
Change-Id: Ib0138781a0081664d11511037685503df1b93608
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 4a863e7484..2328784c96 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -557,14 +557,16 @@ static const char* dbg_partitions_getname(int selected_item, void *data, | |||
557 | if (!disk_partinfo(partition, &p)) | 557 | if (!disk_partinfo(partition, &p)) |
558 | return buffer; | 558 | return buffer; |
559 | 559 | ||
560 | // XXX fix this up to use logical sector size | ||
561 | // XXX and if mounted, show free info... | ||
560 | if (selected_item%2) | 562 | if (selected_item%2) |
561 | { | 563 | { |
562 | snprintf(buffer, buffer_len, " T:%x %ld MB", p.type, | 564 | snprintf(buffer, buffer_len, " T:%x %llu MB", p.type, |
563 | p.size / ( 2048 / ( SECTOR_SIZE / 512 ))); | 565 | (uint64_t)(p.size / ( 2048 / ( SECTOR_SIZE / 512 )))); |
564 | } | 566 | } |
565 | else | 567 | else |
566 | { | 568 | { |
567 | snprintf(buffer, buffer_len, "P%d: S:%lx", partition, p.start); | 569 | snprintf(buffer, buffer_len, "P%d: S:%llx", partition, (uint64_t)p.start); |
568 | } | 570 | } |
569 | return buffer; | 571 | return buffer; |
570 | } | 572 | } |
@@ -572,7 +574,7 @@ static const char* dbg_partitions_getname(int selected_item, void *data, | |||
572 | static bool dbg_partitions(void) | 574 | static bool dbg_partitions(void) |
573 | { | 575 | { |
574 | struct simplelist_info info; | 576 | struct simplelist_info info; |
575 | simplelist_info_init(&info, "Partition Info", NUM_DRIVES * 4, NULL); | 577 | simplelist_info_init(&info, "Partition Info", NUM_DRIVES * MAX_PARTITIONS_PER_DRIVE, NULL); |
576 | info.selection_size = 2; | 578 | info.selection_size = 2; |
577 | info.scroll_all = true; | 579 | info.scroll_all = true; |
578 | info.get_name = dbg_partitions_getname; | 580 | info.get_name = dbg_partitions_getname; |
@@ -1343,6 +1345,22 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1343 | "R2W: *%d", card->r2w_factor); | 1345 | "R2W: *%d", card->r2w_factor); |
1344 | #if (CONFIG_STORAGE & STORAGE_SD) | 1346 | #if (CONFIG_STORAGE & STORAGE_SD) |
1345 | int csd_structure = card_extract_bits(card->csd, 127, 2); | 1347 | int csd_structure = card_extract_bits(card->csd, 127, 2); |
1348 | const char *ver; | ||
1349 | switch(csd_structure) { | ||
1350 | case 0: | ||
1351 | ver = "1 (SD)"; | ||
1352 | break; | ||
1353 | case 1: | ||
1354 | ver = "2 (SDHC/SDXC)"; | ||
1355 | break; | ||
1356 | case 2: | ||
1357 | ver = "3 (SDUC)"; | ||
1358 | break; | ||
1359 | default: | ||
1360 | ver = "Unknown"; | ||
1361 | break; | ||
1362 | } | ||
1363 | simplelist_addline("SDVer: %s\n", ver); | ||
1346 | if (csd_structure == 0) /* CSD version 1.0 */ | 1364 | if (csd_structure == 0) /* CSD version 1.0 */ |
1347 | #endif | 1365 | #endif |
1348 | { | 1366 | { |
@@ -1407,15 +1425,41 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1407 | buf[8]=0; | 1425 | buf[8]=0; |
1408 | simplelist_addline( | 1426 | simplelist_addline( |
1409 | "Firmware: %s", buf); | 1427 | "Firmware: %s", buf); |
1410 | snprintf(buf, sizeof buf, "%ld MB", | 1428 | |
1411 | ((unsigned long)identify_info[61] << 16 | | 1429 | uint64_t total_sectors = identify_info[60] | (identify_info[61] << 16); |
1412 | (unsigned long)identify_info[60]) / 2048 ); | 1430 | #ifdef HAVE_LBA48 |
1431 | if (identify_info[83] & 0x0400 | ||
1432 | && total_sectors == 0x0FFFFFFF) | ||
1433 | total_sectors = identify_info[100] | (identify_info[101] << 16) | ((uint64_t)identify_info[102] << 32) | ((uint64_t)identify_info[103] << 48); | ||
1434 | #endif | ||
1435 | |||
1436 | uint32_t sector_size; | ||
1437 | |||
1438 | /* Logical sector size > 512B ? */ | ||
1439 | if ((identify_info[106] & 0xd000) == 0x5000) | ||
1440 | sector_size = identify_info[117] | (identify_info[118] << 16); | ||
1441 | else | ||
1442 | sector_size = SECTOR_SIZE; | ||
1443 | |||
1444 | total_sectors *= sector_size; /* Convert to bytes */ | ||
1445 | total_sectors /= (1024 * 1024); /* Convert to MB */ | ||
1446 | |||
1447 | simplelist_addline("Size: %llu MB", total_sectors); | ||
1448 | simplelist_addline("Logical sector size: %u B", sector_size); | ||
1449 | |||
1450 | if((identify_info[106] & 0xe000) == 0x6000) | ||
1451 | sector_size *= BIT_N(identify_info[106] & 0x000f); | ||
1413 | simplelist_addline( | 1452 | simplelist_addline( |
1414 | "Size: %s", buf); | 1453 | "Physical sector size: %d B", sector_size); |
1415 | unsigned long free; | 1454 | |
1455 | #ifndef HAVE_MULTIVOLUME | ||
1456 | // XXX this needs to be fixed for multi-volume setups | ||
1457 | sector_t free; | ||
1416 | volume_size( IF_MV(0,) NULL, &free ); | 1458 | volume_size( IF_MV(0,) NULL, &free ); |
1417 | simplelist_addline( | 1459 | simplelist_addline( |
1418 | "Free: %ld MB", free / 1024); | 1460 | "Free: %llu MB", free / 1024); |
1461 | #endif | ||
1462 | |||
1419 | simplelist_addline("SSD detected: %s", ata_disk_isssd() ? "yes" : "no"); | 1463 | simplelist_addline("SSD detected: %s", ata_disk_isssd() ? "yes" : "no"); |
1420 | simplelist_addline( | 1464 | simplelist_addline( |
1421 | "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); | 1465 | "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); |
@@ -1452,11 +1496,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1452 | simplelist_addline( | 1496 | simplelist_addline( |
1453 | "No timing info"); | 1497 | "No timing info"); |
1454 | } | 1498 | } |
1455 | int sector_size = 512; | 1499 | |
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 | 1500 | #ifdef HAVE_ATA_DMA |
1461 | if (identify_info[63] & (1<<0)) { | 1501 | if (identify_info[63] & (1<<0)) { |
1462 | simplelist_addline( | 1502 | simplelist_addline( |
@@ -1751,8 +1791,8 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1751 | simplelist_addline("Model: %s", info.product); | 1791 | simplelist_addline("Model: %s", info.product); |
1752 | simplelist_addline("Firmware: %s", info.revision); | 1792 | simplelist_addline("Firmware: %s", info.revision); |
1753 | simplelist_addline( | 1793 | simplelist_addline( |
1754 | "Size: %ld MB", info.num_sectors*(info.sector_size/512)/2024); | 1794 | "Size: %lld MB", (uint64_t)(info.num_sectors*(info.sector_size/512)/2048)); |
1755 | unsigned long free; | 1795 | storage_t free; |
1756 | volume_size( IF_MV(0,) NULL, &free ); | 1796 | volume_size( IF_MV(0,) NULL, &free ); |
1757 | simplelist_addline( | 1797 | simplelist_addline( |
1758 | "Free: %ld MB", free / 1024); | 1798 | "Free: %ld MB", free / 1024); |
@@ -1771,13 +1811,13 @@ static bool dbg_identify_info(void) | |||
1771 | const unsigned short *identify_info = ata_get_identify(); | 1811 | const unsigned short *identify_info = ata_get_identify(); |
1772 | #ifdef ROCKBOX_LITTLE_ENDIAN | 1812 | #ifdef ROCKBOX_LITTLE_ENDIAN |
1773 | /* this is a pointer to a driver buffer so we can't modify it */ | 1813 | /* this is a pointer to a driver buffer so we can't modify it */ |
1774 | for (int i = 0; i < SECTOR_SIZE/2; ++i) | 1814 | for (int i = 0; i < ATA_IDENTIFY_WORDS; ++i) |
1775 | { | 1815 | { |
1776 | unsigned short word = swap16(identify_info[i]); | 1816 | unsigned short word = swap16(identify_info[i]); |
1777 | write(fd, &word, 2); | 1817 | write(fd, &word, 2); |
1778 | } | 1818 | } |
1779 | #else | 1819 | #else |
1780 | write(fd, identify_info, SECTOR_SIZE); | 1820 | write(fd, identify_info, ATA_IDENTIFY_WORDS*2); |
1781 | #endif | 1821 | #endif |
1782 | close(fd); | 1822 | close(fd); |
1783 | } | 1823 | } |