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
This commit is contained in:
Amaury Pouly 2011-12-15 17:07:19 +00:00
parent 39148be8ac
commit 3a6e3c254e
3 changed files with 15 additions and 5 deletions

View file

@ -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 */

View file

@ -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

View file

@ -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;