summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-12-15 17:07:19 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-12-15 17:07:19 +0000
commit3a6e3c254e5518c110ecaededebc26c5ae431552 (patch)
tree0557d685bd97778bf7d7cda0f9b307af1e20a900
parent39148be8ac62d5e2d43f207dcccf2426eaa97310 (diff)
downloadrockbox-3a6e3c254e5518c110ecaededebc26c5ae431552.tar.gz
rockbox-3a6e3c254e5518c110ecaededebc26c5ae431552.zip
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
-rw-r--r--firmware/common/disk.c16
-rw-r--r--firmware/export/disk.h2
-rw-r--r--firmware/usbstack/usb_storage.c2
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) */
61static struct mutex disk_mutex; 61static struct mutex disk_mutex;
62 62
63#ifdef MAX_LOG_SECTOR_SIZE 63#ifdef MAX_LOG_SECTOR_SIZE
64int disk_sector_multiplier = 1; 64static int disk_sector_multiplier[NUM_DRIVES] = {1};
65#endif 65#endif
66 66
67int disk_get_sector_multiplier(IF_MD_NONVOID(int drive))
68{
69 #ifdef HAVE_MULTIDRIVE
70 return disk_sector_multiplier[drive];
71 #else
72 return disk_sector_multiplier[0];
73 #endif
74}
75
67struct partinfo* disk_init(IF_MD_NONVOID(int drive)) 76struct partinfo* disk_init(IF_MD_NONVOID(int drive))
68{ 77{
69 int i; 78 int i;
@@ -174,6 +183,7 @@ int disk_mount(int drive)
174 183
175 volume = get_free_volume(); 184 volume = get_free_volume();
176 pinfo = disk_init(IF_MD(drive)); 185 pinfo = disk_init(IF_MD(drive));
186 disk_sector_multiplier[drive] = 1;
177 187
178 if (pinfo == NULL) 188 if (pinfo == NULL)
179 { 189 {
@@ -206,7 +216,7 @@ int disk_mount(int drive)
206 vol_drive[volume] = drive; /* remember the drive for this volume */ 216 vol_drive[volume] = drive; /* remember the drive for this volume */
207 volume = get_free_volume(); /* prepare next entry */ 217 volume = get_free_volume(); /* prepare next entry */
208 if (drive == 0) 218 if (drive == 0)
209 disk_sector_multiplier = j; 219 disk_sector_multiplier[drive] = j;
210 break; 220 break;
211 } 221 }
212 } 222 }
@@ -226,7 +236,7 @@ int disk_mount(int drive)
226 if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0)) 236 if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0))
227 { 237 {
228#ifdef MAX_LOG_SECTOR_SIZE 238#ifdef MAX_LOG_SECTOR_SIZE
229 disk_sector_multiplier = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE; 239 disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE;
230#endif 240#endif
231 mounted = 1; 241 mounted = 1;
232 vol_drive[volume] = drive; /* remember the drive for this volume */ 242 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);
46 46
47/* The number of 512-byte sectors in a "logical" sector. Needed for ipod 5.5G */ 47/* The number of 512-byte sectors in a "logical" sector. Needed for ipod 5.5G */
48#ifdef MAX_LOG_SECTOR_SIZE 48#ifdef MAX_LOG_SECTOR_SIZE
49extern int disk_sector_multiplier; 49int disk_get_sector_multiplier(IF_MD_NONVOID(int drive));
50#endif 50#endif
51 51
52#endif 52#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)
787 lun_present = false; 787 lun_present = false;
788 788
789#ifdef MAX_LOG_SECTOR_SIZE 789#ifdef MAX_LOG_SECTOR_SIZE
790 block_size_mult = disk_sector_multiplier; 790 block_size_mult = disk_get_sector_multiplier(lun);
791#endif 791#endif
792 792
793 cur_cmd.tag = cbw->tag; 793 cur_cmd.tag = cbw->tag;