From 15e52374698ba7395ff0ece0d3d70435a66406c4 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 5 Jul 2024 16:00:30 -0400 Subject: 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 --- .../arm/tms320dm320/creative-zvm/ata-creativezvm.c | 22 ++++++++++++---------- .../arm/tms320dm320/creative-zvm/ata-target.h | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'firmware/target/arm/tms320dm320/creative-zvm') diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c index a1985472a0..76929e603e 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c @@ -126,8 +126,10 @@ void GIO2(void) #define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */ -extern int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); -extern int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); +extern int ata_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf); +extern int ata_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf); + +// XXX 64-bit: Due to this it's not likely that this target will ever handle 64-bit storage. struct main_header { @@ -253,9 +255,9 @@ static void cfs_init(void) /* Read root inode */ _ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2); root_inode = (struct cfs_inode*)§or2; - + logf("Root inode = 0x%x", root_inode); - + logf("0x%x 0x%x", CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), root_inode->first_class_chain[0]); /* Read root inode's first sector */ @@ -277,9 +279,9 @@ static void cfs_init(void) vfat_inode_nr = root_direntry_items[i].inode_number; } } - + logf("VFAT inode = 0x%x", vfat_inode_nr); - + if(vfat_inode_nr != 0) { /* Read VFAT inode */ @@ -384,19 +386,19 @@ static void cfs_init(void) cfs_inited = true; } -static inline unsigned long map_sector(unsigned long sector) +static inline sector_t map_sector(sector_t sector) { /* * Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part * FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes. */ #ifndef BOOTLOADER - unsigned long *sectors = core_get_data(sectors_handle); + sector_t *sectors = core_get_data(sectors_handle); #endif return cfs_start+sectors[sector/64]*64+sector%64; } -int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf) +int ata_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf) { if(!cfs_inited) cfs_init(); @@ -423,7 +425,7 @@ 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_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf) { if(!cfs_inited) cfs_init(); diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h index d0aa12e040..41b8e73ad4 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h @@ -36,8 +36,8 @@ /* Nasty hack, but Creative is nasty... */ #define ata_read_sectors _ata_read_sectors #define ata_write_sectors _ata_write_sectors -extern int _ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); -extern int _ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); +extern int _ata_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf); +extern int _ata_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf); /* General purpose memory region #1 */ #define ATA_IOBASE 0x50FEE000 -- cgit v1.2.3