diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2024-11-09 16:38:28 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2024-11-09 17:48:00 -0500 |
commit | 1516c48a37bbd231c6c86272fd5ca88d0ffffe9b (patch) | |
tree | 3fb9d85c5bd552bf8b77c2bc8a8f6f09d5f25f77 | |
parent | c61ad40812a51abf8942e3e224a17f4b61000130 (diff) | |
download | rockbox-1516c48a37.tar.gz rockbox-1516c48a37.zip |
storage: Support a default virtual sector size
Normally, we figure out the virual sector size from the filesystem info.
However, if there's no filesystem, we fall back to the hardware's
logical sector size.
Some device firmware (eg ipod5g/6g) need their partition tables set up
with larger-than-logical sector sizes; this way we can present the
"correct" sector size to maintain interoperability with the stock
firmware and make it so that the drive can still be properly partitioned
from within rockbox.
This patch adds support for DEFAULT_VIRT_SECTOR_SIZE. Nothing uses it yet.
Change-Id: Iae746a50ffc37c51abb2c9b82d3c4596f1fa7559
-rw-r--r-- | apps/main.c | 8 | ||||
-rw-r--r-- | firmware/common/disk.c | 12 | ||||
-rw-r--r-- | firmware/export/disk.h | 4 |
3 files changed, 24 insertions, 0 deletions
diff --git a/apps/main.c b/apps/main.c index 53a2f9196b..0241c0e488 100644 --- a/apps/main.c +++ b/apps/main.c @@ -634,6 +634,13 @@ static void init(void) lcd_puts(0, 4, rbversion); lcd_update(); +#if defined(MAX_VIRT_SECTOR_SIZE) && defined(DEFAULT_VIRT_SECTOR_SIZE) +#ifdef HAVE_MULTIDRIVE + for (int i = 0 ; i < NUM_DRIVES ; i++) +#endif + disk_set_sector_multiplier(IF_MD(i,) DEFAULT_VIRT_SECTOR_SIZE); +#endif + #ifndef USB_NONE usb_start_monitoring(); while(button_get(true) != SYS_USB_CONNECTED) {}; @@ -650,6 +657,7 @@ static void init(void) lcd_putsf(0, 4, "Error mounting: %08x", rc); lcd_update(); sleep(HZ*5); + system_reboot(); } #endif } diff --git a/firmware/common/disk.c b/firmware/common/disk.c index ebcfe56852..e681fb64e3 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -124,6 +124,18 @@ int disk_get_sector_multiplier(IF_MD_NONVOID(int drive)) disk_reader_unlock(); return multiplier; } + +#ifdef DEFAULT_VIRT_SECTOR_SIZE +void disk_set_sector_multiplier(IF_MD(int drive,) uint16_t mult) +{ + if (!CHECK_DRV(drive)) + return; + + disk_writer_lock(); + disk_sector_multiplier[IF_MD_DRV(drive)] = mult; + disk_writer_unlock(); +} +#endif /* DEFAULT_VIRT_SECTOR_SIZE */ #endif /* MAX_VIRT_SECTOR_SIZE */ #ifdef MAX_VARIABLE_LOG_SECTOR diff --git a/firmware/export/disk.h b/firmware/export/disk.h index 408998f075..f1cec16b42 100644 --- a/firmware/export/disk.h +++ b/firmware/export/disk.h @@ -50,6 +50,10 @@ int disk_unmount(int drive); /* Used when the drive's logical sector size is smaller than the sector size used by the partition table and filesystem. Notably needed for ipod 5.5G/6G. */ #ifdef MAX_VIRT_SECTOR_SIZE int disk_get_sector_multiplier(IF_MD_NONVOID(int drive)); +/* The logical sector size to use when we have no valid paritions */ +#ifdef DEFAULT_VIRT_SECTOR_SIZE +void disk_set_sector_multiplier(IF_MD(int drive,) uint16_t mult); +#endif #endif #ifdef MAX_VARIABLE_LOG_SECTOR |