1
0
Fork 0
forked from len0rd/rockbox

ipod6g: Reworking the bespoke ATA driver

ipod6g was configured with SECTOR_SIZE of 4096, but this ATA driver
unconditionally translated these to 512B operations on the actual
storage device.

Rockbox's storage layer already has robust support for "logical sectors
larger than physical storage sectors" through use of
MAX_LOG_SECTOR_SIZE.  So switch to that mechanism, allowing the ipod6g
ATA driver to be simplified.

If we want to support drives with physical sector sizes > 512B, then
we need to port the MAX_PHYS_SECTOR_SIZE logic from the primary ATA driver.

Additional changes:

 * Simplify MWDMA/UDMA selection logic
 * Report CE-ATA mode in debug menu
 * Use LBA48 commands only if drive is over 128GiB.
 * Drop default sleep/poweroff time from 20s to 7s (matching main ATA driver)

Finally, the bulk of the changes are the first phase of a badly needed
style cleanup that made reading this driver a lot harder than it should
be. I intend to split this into a separate patch.

Change-Id: I2feca9fd319c8d6cfb3c2610208970428d2fa947
This commit is contained in:
Solomon Peachy 2024-10-14 18:09:17 -04:00
parent 9efed5542e
commit 563da70139
5 changed files with 277 additions and 199 deletions

View file

@ -1430,11 +1430,13 @@ static int disk_callback(int btn, struct gui_synclist *lists)
simplelist_addline(
"Firmware: %s", buf);
uint64_t total_sectors = identify_info[60] | ((uint32_t)identify_info[61] << 16);
uint64_t total_sectors = (identify_info[61] << 16) | identify_info[60];
#ifdef HAVE_LBA48
if (identify_info[83] & 0x0400
&& total_sectors == 0x0FFFFFFF)
total_sectors = identify_info[100] | ((uint64_t)identify_info[101] << 16) | ((uint64_t)identify_info[102] << 32) | ((uint64_t)identify_info[103] << 48);
if (identify_info[83] & 0x0400 && total_sectors == 0x0FFFFFFF)
total_sectors = ((uint64_t)identify_info[103] << 48) |
((uint64_t)identify_info[102] << 32) |
((uint64_t)identify_info[101] << 16) |
identify_info[100];
#endif
uint32_t sector_size;
@ -1555,6 +1557,9 @@ static int disk_callback(int btn, struct gui_synclist *lists)
if (i == 0) {
simplelist_addline(
"DMA not enabled");
} else if (i == 0xff) {
simplelist_addline(
"CE-ATA mode");
} else {
simplelist_addline(
"DMA mode: %s %c",