mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
storage: 64-bit sector offsets
* Create new 'sector_t' type alias:
* uint64_t for all targets with HAVE_LBA48 or HAVE_SDUC
* unsigned long for the everything else
* Alter all storage APIs to use sector_t instead of 'unsigned long'
* Alter Volume/Partition/storage info structures to use sector_t
* Disk cache converted to sector_t
* ATA Core:
* convert to using sector_t for sector addresses and drive sizes
* Always fill out upper 16 bits of LBA48 addresses
* IDENTIFY INFO is fixed at 512 bytes, not SECTOR_SIZE
* USB mass storage:
* convert to using sector_t for sector addesses and drive sizes
* Implement READ_16/WRITE_16 for LBA48 addresses
* Convert FAT code to use sector_t for all sector references
* output_dyn_value() now accepts int64_t instead of 'int'
* Corrected "rockbox info" to work for (MULTIVOLUME & !MULTIDRIVE)
* Better reporting of disk and (logical+physical) sector sizes in debug info
* Detect SDUC cards and report on storage debug_info screen
To-do: SDUC
* Refactor SD core to remove duplicate code in every driver
* Card probe and init state machine
* Implement core SDUC support
* SD2.0 needs to be 2.0+ (fixed for jz47xx and x1000)
* Host and Card ID (ACMD41)
* 32-bit addressing for all read/write/erase operations (CMD22)
* ADD SDUC to target device drivers, defining HAVE_SDUC as appropriate
Change-Id: Ib0138781a0081664d11511037685503df1b93608
This commit is contained in:
parent
9ff308a589
commit
15e5237469
49 changed files with 629 additions and 435 deletions
|
|
@ -140,8 +140,8 @@ bool ata_disk_is_active(void);
|
|||
int ata_soft_reset(void);
|
||||
int ata_init(void) STORAGE_INIT_ATTR;
|
||||
void ata_close(void);
|
||||
int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
||||
int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
||||
int ata_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
|
||||
int ata_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
|
||||
void ata_spin(void);
|
||||
#if (CONFIG_LED == LED_REAL)
|
||||
void ata_set_led_enabled(bool enabled);
|
||||
|
|
@ -233,4 +233,6 @@ int ata_read_smart(struct ata_smart_values*);
|
|||
#define STORAGE_CLOSE
|
||||
#endif
|
||||
|
||||
#define ATA_IDENTIFY_WORDS 256
|
||||
|
||||
#endif /* __ATA_H__ */
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
struct partinfo
|
||||
{
|
||||
unsigned long start; /* first sector (LBA) */
|
||||
unsigned long size; /* number of sectors */
|
||||
sector_t start; /* first sector (LBA) */
|
||||
sector_t size; /* number of sectors */
|
||||
unsigned char type;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ struct fat_filestr
|
|||
{
|
||||
struct fat_file *fatfilep; /* common file information */
|
||||
long lastcluster; /* cluster of last access */
|
||||
unsigned long lastsector; /* sector of last access */
|
||||
sector_t lastsector; /* sector of last access */
|
||||
long clusternum; /* cluster number of last access */
|
||||
unsigned long sectornum; /* sector number within current cluster */
|
||||
bool eof; /* end-of-file reached */
|
||||
|
|
@ -173,7 +173,7 @@ int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume));
|
|||
#endif /* MAX_LOG_SECTOR_SIZE */
|
||||
unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume));
|
||||
void fat_recalc_free(IF_MV_NONVOID(int volume));
|
||||
bool fat_size(IF_MV(int volume,) unsigned long *size, unsigned long *free);
|
||||
bool fat_size(IF_MV(int volume,) sector_t *size, sector_t *free);
|
||||
|
||||
/** Misc. **/
|
||||
void fat_empty_fat_direntry(struct fat_direntry *entry);
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ bool mmc_disk_is_active(void);
|
|||
int mmc_soft_reset(void);
|
||||
int mmc_init(void) STORAGE_INIT_ATTR;
|
||||
void mmc_close(void);
|
||||
int mmc_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
||||
int mmc_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
||||
int mmc_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
|
||||
int mmc_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
|
||||
void mmc_spin(void);
|
||||
int mmc_spinup_time(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#define __MV_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
/* FixMe: These macros are a bit nasty and perhaps misplaced here.
|
||||
|
|
@ -40,6 +41,19 @@
|
|||
#define IF_MD_DRV(d) 0
|
||||
#endif /* HAVE_MULTIDRIVE */
|
||||
|
||||
/* Storage size */
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA) && defined(HAVE_LBA48)
|
||||
typedef uint64_t sector_t;
|
||||
#define STORAGE_64BIT_SECTOR
|
||||
#elif (CONFIG_STORAGE & STORAGE_SD) && defined(HAVE_SDUC)
|
||||
typedef uint64_t sector_t;
|
||||
#define STORAGE_64BIT_SECTOR
|
||||
#else
|
||||
typedef unsigned long sector_t;
|
||||
#undef STORAGE_64BIT_SECTOR
|
||||
#endif
|
||||
|
||||
|
||||
/* Volumes mean things that have filesystems on them, like partitions */
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#define IF_MV(x...) x /* valist contents or empty */
|
||||
|
|
@ -113,7 +127,7 @@ struct volumeinfo
|
|||
/* Volume-centric functions (in disk.c) */
|
||||
void volume_recalc_free(IF_MV_NONVOID(int volume));
|
||||
unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume));
|
||||
void volume_size(IF_MV(int volume,) unsigned long *size, unsigned long *free);
|
||||
void volume_size(IF_MV(int volume,) sector_t *size, sector_t *free);
|
||||
#ifdef HAVE_DIRCACHE
|
||||
bool volume_ismounted(IF_MV_NONVOID(int volume));
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ bool nand_disk_is_active(void);
|
|||
int nand_soft_reset(void);
|
||||
int nand_init(void) STORAGE_INIT_ATTR;
|
||||
void nand_close(void);
|
||||
int nand_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
||||
int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
||||
int nand_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
|
||||
int nand_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
|
||||
#ifdef HAVE_STORAGE_FLUSH
|
||||
int nand_flush(void);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ bool ramdisk_disk_is_active(void);
|
|||
int ramdisk_soft_reset(void);
|
||||
int ramdisk_init(void) STORAGE_INIT_ATTR;
|
||||
void ramdisk_close(void);
|
||||
int ramdisk_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
||||
int ramdisk_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
||||
int ramdisk_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
|
||||
int ramdisk_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
|
||||
void ramdisk_spin(void);
|
||||
void ramdisk_sleepnow(void);
|
||||
int ramdisk_spinup_time(void);
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ bool sd_disk_is_active(void);
|
|||
int sd_soft_reset(void);
|
||||
int sd_init(void) STORAGE_INIT_ATTR;
|
||||
void sd_close(void);
|
||||
int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
||||
int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
||||
int sd_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
|
||||
int sd_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
|
||||
void sd_spin(void);
|
||||
int sd_spinup_time(void); /* ticks */
|
||||
|
||||
|
|
@ -93,6 +93,7 @@ int sd_num_drives(int first_drive);
|
|||
#define SD_READ_SINGLE_BLOCK 17
|
||||
#define SD_READ_MULTIPLE_BLOCK 18
|
||||
#define SD_SEND_NUM_WR_BLOCKS 22 /* acmd22 */
|
||||
#define SD_UC_ADDRESS_EXTENSION 22
|
||||
#define SD_SET_WR_BLK_ERASE_COUNT 23 /* acmd23 */
|
||||
#define SD_WRITE_BLOCK 24
|
||||
#define SD_WRITE_MULTIPLE_BLOCK 25
|
||||
|
|
|
|||
|
|
@ -22,9 +22,11 @@
|
|||
#define __SDMMC_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <mv.h> /* for sector_t */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
bool initialized;
|
||||
|
||||
unsigned long read_timeout; /* n * 8 clock cycles */
|
||||
|
|
@ -37,7 +39,7 @@ typedef struct
|
|||
unsigned int nsac; /* clock cycles */
|
||||
unsigned long taac; /* n * 0.1 ns */
|
||||
unsigned int r2w_factor;
|
||||
unsigned long numblocks; /* size in flash blocks */
|
||||
sector_t numblocks; /* size in flash blocks */
|
||||
unsigned int blocksize; /* block size in bytes */
|
||||
unsigned long rca; /* RCA register */
|
||||
|
||||
|
|
@ -48,6 +50,8 @@ typedef struct
|
|||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
unsigned int current_bank;
|
||||
#endif
|
||||
|
||||
unsigned int sd2plus; /* SD 2.0 or better */
|
||||
} tCardInfo;
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ int ramdisk_event(long id, intptr_t data);
|
|||
struct storage_info
|
||||
{
|
||||
unsigned int sector_size;
|
||||
unsigned int num_sectors;
|
||||
sector_t num_sectors;
|
||||
char *vendor;
|
||||
char *product;
|
||||
char *revision;
|
||||
|
|
@ -318,6 +318,6 @@ int storage_driver_type(int drive);
|
|||
|
||||
#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
|
||||
|
||||
int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
||||
int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
||||
int storage_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
|
||||
int storage_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue