1
0
Fork 0
forked from len0rd/rockbox

storage: rename MAX_LOG_SECTOR_SIZE to MAX_VIRT_SECTOR_SIZE

Change-Id: I34f00748c1b0935d65af5f0fc6bdd13356ff31e1
This commit is contained in:
Solomon Peachy 2024-11-07 17:15:28 -05:00
parent 7ecab006c0
commit bc6c189dcb
15 changed files with 38 additions and 38 deletions

View file

@ -1452,7 +1452,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
simplelist_addline("Size: %llu MB", (uint64_t)total_sectors); simplelist_addline("Size: %llu MB", (uint64_t)total_sectors);
simplelist_addline("Logical sector size: %lu B", sector_size); simplelist_addline("Logical sector size: %lu B", sector_size);
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
simplelist_addline("Sector multiplier: %u", disk_get_sector_multiplier()); simplelist_addline("Sector multiplier: %u", disk_get_sector_multiplier());
#endif #endif

View file

@ -110,7 +110,7 @@ static void init_volume(struct volumeinfo *vi, int drive, int part)
vi->partition = part; vi->partition = part;
} }
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
static uint16_t disk_sector_multiplier[NUM_DRIVES] = static uint16_t disk_sector_multiplier[NUM_DRIVES] =
{ [0 ... NUM_DRIVES-1] = 1 }; { [0 ... NUM_DRIVES-1] = 1 };
@ -124,7 +124,7 @@ int disk_get_sector_multiplier(IF_MD_NONVOID(int drive))
disk_reader_unlock(); disk_reader_unlock();
return multiplier; return multiplier;
} }
#endif /* MAX_LOG_SECTOR_SIZE */ #endif /* MAX_VIRT_SECTOR_SIZE */
#if (CONFIG_STORAGE & STORAGE_ATA) // XXX make this more generic? #if (CONFIG_STORAGE & STORAGE_ATA) // XXX make this more generic?
static uint16_t disk_log_sector_size[NUM_DRIVES] = static uint16_t disk_log_sector_size[NUM_DRIVES] =
@ -163,13 +163,13 @@ bool disk_init(IF_MD_NONVOID(int drive))
struct storage_info *info = (struct storage_info*) sector; struct storage_info *info = (struct storage_info*) sector;
storage_get_info(IF_MD_DRV(drive), info); storage_get_info(IF_MD_DRV(drive), info);
disk_writer_lock(); disk_writer_lock();
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
disk_log_sector_size[IF_MD_DRV(drive)] = info->sector_size; disk_log_sector_size[IF_MD_DRV(drive)] = info->sector_size;
#endif #endif
disk_writer_unlock(); disk_writer_unlock();
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
if (info->sector_size > MAX_LOG_SECTOR_SIZE || info->sector_size > DC_CACHE_BUFSIZE) { if (info->sector_size > MAX_VIRT_SECTOR_SIZE || info->sector_size > DC_CACHE_BUFSIZE) {
panicf("Unsupported logical sector size: %d", panicf("Unsupported logical sector size: %d",
info->sector_size); info->sector_size);
} }
@ -374,7 +374,7 @@ int disk_mount(int drive)
} }
struct partinfo *pinfo = &part[IF_MD_DRV(drive)*4]; struct partinfo *pinfo = &part[IF_MD_DRV(drive)*4];
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
disk_sector_multiplier[IF_MD_DRV(drive)] = 1; disk_sector_multiplier[IF_MD_DRV(drive)] = 1;
#endif #endif
@ -383,7 +383,7 @@ int disk_mount(int drive)
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0)) if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0))
{ {
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume)) / LOG_SECTOR_SIZE(drive); disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume)) / LOG_SECTOR_SIZE(drive);
#endif #endif
mounted = 1; mounted = 1;
@ -402,8 +402,8 @@ int disk_mount(int drive)
DEBUGF("Trying to mount partition %d.\n", i); DEBUGF("Trying to mount partition %d.\n", i);
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/LOG_SECTOR_SIZE(drive)); j <<= 1) for (int j = 1; j <= (MAX_VIRT_SECTOR_SIZE/LOG_SECTOR_SIZE(drive)); j <<= 1)
{ {
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j))
{ {
@ -417,7 +417,7 @@ int disk_mount(int drive)
break; break;
} }
} }
#else /* ndef MAX_LOG_SECTOR_SIZE */ #else /* ndef MAX_VIRT_SECTOR_SIZE */
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
{ {
mounted++; mounted++;
@ -425,7 +425,7 @@ int disk_mount(int drive)
volume_onmount_internal(IF_MV(volume)); volume_onmount_internal(IF_MV(volume));
volume = get_free_volume(); /* prepare next entry */ volume = get_free_volume(); /* prepare next entry */
} }
#endif /* MAX_LOG_SECTOR_SIZE */ #endif /* MAX_VIRT_SECTOR_SIZE */
} }
} }

View file

@ -22,10 +22,10 @@
#ifdef MAX_PHYS_SECTOR_SIZE #ifdef MAX_PHYS_SECTOR_SIZE
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
#define __MAX_LOG_SECTOR_SIZE MAX_LOG_SECTOR_SIZE #define __MAX_VIRT_SECTOR_SIZE MAX_VIRT_SECTOR_SIZE
#else #else
#define __MAX_LOG_SECTOR_SIZE SECTOR_SIZE #define __MAX_VIRT_SECTOR_SIZE SECTOR_SIZE
#endif #endif
struct sector_cache_entry { struct sector_cache_entry {
@ -226,7 +226,7 @@ static int ata_get_phys_sector_mult(void)
sector 1 then assume the drive supports "512e" and will handle sector 1 then assume the drive supports "512e" and will handle
it better than us, so ignore the large physical sectors. it better than us, so ignore the large physical sectors.
*/ */
char throwaway[__MAX_LOG_SECTOR_SIZE]; char throwaway[__MAX_VIRT_SECTOR_SIZE];
rc = ata_transfer_sectors(1, 1, &throwaway, false); rc = ata_transfer_sectors(1, 1, &throwaway, false);
if (rc == 0) if (rc == 0)
phys_sector_mult = 1; phys_sector_mult = 1;

View file

@ -163,7 +163,7 @@ union raw_dirent
#define FAT_NTRES_LC_NAME 0x08 #define FAT_NTRES_LC_NAME 0x08
#define FAT_NTRES_LC_EXT 0x10 #define FAT_NTRES_LC_EXT 0x10
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
#define LOG_SECTOR_SIZE(bpb) fat_bpb->sector_size #define LOG_SECTOR_SIZE(bpb) fat_bpb->sector_size
#else #else
#define LOG_SECTOR_SIZE(bpb) SECTOR_SIZE #define LOG_SECTOR_SIZE(bpb) SECTOR_SIZE
@ -272,14 +272,14 @@ static struct bpb
int BPB_FN_DECL(update_fat_entry, unsigned long, unsigned long); int BPB_FN_DECL(update_fat_entry, unsigned long, unsigned long);
void BPB_FN_DECL(fat_recalc_free_internal); void BPB_FN_DECL(fat_recalc_free_internal);
#endif /* HAVE_FAT16SUPPORT */ #endif /* HAVE_FAT16SUPPORT */
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
uint16_t sector_size; uint16_t sector_size;
#endif #endif
} fat_bpbs[NUM_VOLUMES]; /* mounted partition info */ } fat_bpbs[NUM_VOLUMES]; /* mounted partition info */
#ifdef STORAGE_NEEDS_BOUNCE_BUFFER #ifdef STORAGE_NEEDS_BOUNCE_BUFFER
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
#define BOUNCE_SECTOR_SIZE MAX_LOG_SECTOR_SIZE #define BOUNCE_SECTOR_SIZE MAX_VIRT_SECTOR_SIZE
#else #else
#define BOUNCE_SECTOR_SIZE SECTOR_SIZE #define BOUNCE_SECTOR_SIZE SECTOR_SIZE
#endif #endif
@ -1999,7 +1999,7 @@ static int free_cluster_chain(struct bpb *fat_bpb, long startcluster)
int fat_file_sector_size(const struct fat_file *file) int fat_file_sector_size(const struct fat_file *file)
{ {
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
const struct bpb *fat_bpb = FAT_BPB(file->volume); const struct bpb *fat_bpb = FAT_BPB(file->volume);
#endif #endif
@ -2769,7 +2769,7 @@ int fat_readdir(struct fat_filestr *dirstr, struct fat_dirscan_info *scan,
scan->entries = 0; scan->entries = 0;
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
struct fat_file *file = dirstr->fatfilep; struct fat_file *file = dirstr->fatfilep;
const struct bpb *fat_bpb = FAT_BPB(file->volume); const struct bpb *fat_bpb = FAT_BPB(file->volume);
#endif #endif
@ -2917,7 +2917,7 @@ int fat_mount(IF_MV(int volume,) IF_MD(int drive,) unsigned long startsector)
fat_bpb->drive = drive; fat_bpb->drive = drive;
#endif #endif
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
fat_bpb->sector_size = disk_get_log_sector_size(IF_MD(drive)); fat_bpb->sector_size = disk_get_log_sector_size(IF_MD(drive));
#endif #endif
@ -2959,7 +2959,7 @@ int fat_unmount(IF_MV_NONVOID(int volume))
/** Debug screen stuff **/ /** Debug screen stuff **/
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
/* This isn't necessarily the same as storage's logical sector size; /* This isn't necessarily the same as storage's logical sector size;
we can have situations where the filesystem (and partition table) we can have situations where the filesystem (and partition table)
uses a larger "virtual sector" than the underlying storage device */ uses a larger "virtual sector" than the underlying storage device */
@ -2973,7 +2973,7 @@ int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume))
return bytes; return bytes;
} }
#endif /* MAX_LOG_SECTOR_SIZE */ #endif /* MAX_VIRT_SECTOR_SIZE */
unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume)) unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume))
{ {

View file

@ -197,7 +197,7 @@
/* The fuze+ actually interesting partition table does not use 512-byte sector /* The fuze+ actually interesting partition table does not use 512-byte sector
* (usually 2048 logical sector size) */ * (usually 2048 logical sector size) */
#define MAX_LOG_SECTOR_SIZE 2048 #define MAX_VIRT_SECTOR_SIZE 2048
/* Define this if you have adjustable CPU frequency */ /* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ #define HAVE_ADJUSTABLE_CPU_FREQ

View file

@ -187,7 +187,7 @@
/* The ZEN X-Fi Style actually interesting partition table does not use 512-byte sector /* The ZEN X-Fi Style actually interesting partition table does not use 512-byte sector
* (usually 2048 logical sector size) */ * (usually 2048 logical sector size) */
#define MAX_LOG_SECTOR_SIZE 2048 #define MAX_VIRT_SECTOR_SIZE 2048
/* Define this if you have adjustable CPU frequency */ /* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ #define HAVE_ADJUSTABLE_CPU_FREQ

View file

@ -192,7 +192,7 @@
#define HAVE_ATA_SMART #define HAVE_ATA_SMART
/* define this if the device has larger sectors when accessed via USB */ /* define this if the device has larger sectors when accessed via USB */
#define MAX_LOG_SECTOR_SIZE 4096 #define MAX_VIRT_SECTOR_SIZE 4096
/* This is the minimum access size for the device, even if it's larger than the logical sector size */ /* This is the minimum access size for the device, even if it's larger than the logical sector size */
#define MAX_PHYS_SECTOR_SIZE 4096 #define MAX_PHYS_SECTOR_SIZE 4096

View file

@ -215,7 +215,7 @@
/* define this if the device has larger sectors when accessed via USB */ /* define this if the device has larger sectors when accessed via USB */
/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */ /* (only relevant in disk.c, fat.c now always supports large virtual sectors) */
#define MAX_LOG_SECTOR_SIZE 2048 #define MAX_VIRT_SECTOR_SIZE 2048
/* define this if the hard drive uses large physical sectors (ATA-7 feature) */ /* define this if the hard drive uses large physical sectors (ATA-7 feature) */
/* and doesn't handle them in the drive firmware */ /* and doesn't handle them in the drive firmware */

View file

@ -198,7 +198,7 @@
/* The fuze+ actually interesting partition table does not use 512-byte sector /* The fuze+ actually interesting partition table does not use 512-byte sector
* (usually 2048 logical sector size) */ * (usually 2048 logical sector size) */
#define MAX_LOG_SECTOR_SIZE 2048 #define MAX_VIRT_SECTOR_SIZE 2048
/* Define this if you have adjustable CPU frequency */ /* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ #define HAVE_ADJUSTABLE_CPU_FREQ

View file

@ -168,7 +168,7 @@
/* The fuze+ actually interesting partition table does not use 512-byte sector /* The fuze+ actually interesting partition table does not use 512-byte sector
* (usually 2048 logical sector size) */ * (usually 2048 logical sector size) */
#define MAX_LOG_SECTOR_SIZE 2048 #define MAX_VIRT_SECTOR_SIZE 2048
/* Define this if you have adjustable CPU frequency */ /* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ #define HAVE_ADJUSTABLE_CPU_FREQ

View file

@ -168,7 +168,7 @@
/* The fuze+ actually interesting partition table does not use 512-byte sector /* The fuze+ actually interesting partition table does not use 512-byte sector
* (usually 2048 logical sector size) */ * (usually 2048 logical sector size) */
#define MAX_LOG_SECTOR_SIZE 2048 #define MAX_VIRT_SECTOR_SIZE 2048
/* Define this if you have adjustable CPU frequency */ /* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ #define HAVE_ADJUSTABLE_CPU_FREQ

View file

@ -48,7 +48,7 @@ int disk_unmount_all(void);
int disk_unmount(int drive); 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. */ /* 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_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
int disk_get_sector_multiplier(IF_MD_NONVOID(int drive)); int disk_get_sector_multiplier(IF_MD_NONVOID(int drive));
#endif #endif
/* The size of the drive's smallest addressible unit */ /* The size of the drive's smallest addressible unit */

View file

@ -170,9 +170,9 @@ int fat_mount(IF_MV(int volume,) IF_MD(int drive,) unsigned long startsector);
int fat_unmount(IF_MV_NONVOID(int volume)); int fat_unmount(IF_MV_NONVOID(int volume));
/** Debug screen stuff **/ /** Debug screen stuff **/
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume)); int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume));
#endif /* MAX_LOG_SECTOR_SIZE */ #endif /* MAX_VIRT_SECTOR_SIZE */
unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume)); unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume));
void fat_recalc_free(IF_MV_NONVOID(int volume)); void fat_recalc_free(IF_MV_NONVOID(int volume));
bool fat_size(IF_MV(int volume,) sector_t *size, sector_t *free); bool fat_size(IF_MV(int volume,) sector_t *size, sector_t *free);

View file

@ -108,8 +108,8 @@
#endif #endif
/* this _could_ be larger than a sector if that would ever be useful */ /* this _could_ be larger than a sector if that would ever be useful */
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
#define DC_CACHE_BUFSIZE MAX_LOG_SECTOR_SIZE #define DC_CACHE_BUFSIZE MAX_VIRT_SECTOR_SIZE
#else #else
#define DC_CACHE_BUFSIZE SECTOR_SIZE #define DC_CACHE_BUFSIZE SECTOR_SIZE
#endif #endif

View file

@ -793,7 +793,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
lun_present = false; lun_present = false;
unsigned int block_size_mult = 1; /* Number of LOGICAL storage device blocks in each USB block */ unsigned int block_size_mult = 1; /* Number of LOGICAL storage device blocks in each USB block */
#ifdef MAX_LOG_SECTOR_SIZE #ifdef MAX_VIRT_SECTOR_SIZE
block_size_mult = disk_get_sector_multiplier(IF_MD(lun)); block_size_mult = disk_get_sector_multiplier(IF_MD(lun));
#endif #endif