From 3a6e3c254e5518c110ecaededebc26c5ae431552 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Thu, 15 Dec 2011 17:07:19 +0000 Subject: [PATCH] Add support for for per-drive logical sector size. This allows targets to have a different logical sector size for the internal storage and the sd card, like on the fuze+ for example. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31270 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/disk.c | 16 +++++++++++++--- firmware/export/disk.h | 2 +- firmware/usbstack/usb_storage.c | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 3c1f01cc61..a9fd346728 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -61,9 +61,18 @@ static int vol_drive[NUM_VOLUMES]; /* mounted to which drive (-1 if none) */ static struct mutex disk_mutex; #ifdef MAX_LOG_SECTOR_SIZE -int disk_sector_multiplier = 1; +static int disk_sector_multiplier[NUM_DRIVES] = {1}; #endif +int disk_get_sector_multiplier(IF_MD_NONVOID(int drive)) +{ + #ifdef HAVE_MULTIDRIVE + return disk_sector_multiplier[drive]; + #else + return disk_sector_multiplier[0]; + #endif +} + struct partinfo* disk_init(IF_MD_NONVOID(int drive)) { int i; @@ -174,6 +183,7 @@ int disk_mount(int drive) volume = get_free_volume(); pinfo = disk_init(IF_MD(drive)); + disk_sector_multiplier[drive] = 1; if (pinfo == NULL) { @@ -206,7 +216,7 @@ int disk_mount(int drive) vol_drive[volume] = drive; /* remember the drive for this volume */ volume = get_free_volume(); /* prepare next entry */ if (drive == 0) - disk_sector_multiplier = j; + disk_sector_multiplier[drive] = j; break; } } @@ -226,7 +236,7 @@ int disk_mount(int drive) if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0)) { #ifdef MAX_LOG_SECTOR_SIZE - disk_sector_multiplier = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE; + disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE; #endif mounted = 1; vol_drive[volume] = drive; /* remember the drive for this volume */ diff --git a/firmware/export/disk.h b/firmware/export/disk.h index 347d8b44db..ece0e2644f 100644 --- a/firmware/export/disk.h +++ b/firmware/export/disk.h @@ -46,7 +46,7 @@ int disk_unmount(int drive); /* The number of 512-byte sectors in a "logical" sector. Needed for ipod 5.5G */ #ifdef MAX_LOG_SECTOR_SIZE -extern int disk_sector_multiplier; +int disk_get_sector_multiplier(IF_MD_NONVOID(int drive)); #endif #endif diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index a178f06f87..64764f178d 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -787,7 +787,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) lun_present = false; #ifdef MAX_LOG_SECTOR_SIZE - block_size_mult = disk_sector_multiplier; + block_size_mult = disk_get_sector_multiplier(lun); #endif cur_cmd.tag = cbw->tag;