Cleanup MV/MD macros a little.
When using variadic macros there's no need for IF_MD2/IF_MV2 to deal with function parameters. IF_MD/IF_MV are enough. Throw in IF_MD_DRV/ID_MV_VOL that return the parameter if MD/MV, or 0 if not. Change-Id: I7605e6039f3be19cb47110c84dcb3c5516f2c3eb
This commit is contained in:
parent
c13f21a4d5
commit
a56f1ca1ed
44 changed files with 219 additions and 218 deletions
|
@ -1424,7 +1424,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
|
|||
simplelist_addline(
|
||||
"Size: %s", buf);
|
||||
unsigned long free;
|
||||
fat_size( IF_MV2(0,) NULL, &free );
|
||||
fat_size( IF_MV(0,) NULL, &free );
|
||||
simplelist_addline(
|
||||
"Free: %ld MB", free / 1024);
|
||||
simplelist_addline(
|
||||
|
@ -1543,7 +1543,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
|
|||
simplelist_addline(
|
||||
"Size: %ld MB", info.num_sectors*(info.sector_size/512)/2024);
|
||||
unsigned long free;
|
||||
fat_size( IF_MV2(0,) NULL, &free );
|
||||
fat_size( IF_MV(0,) NULL, &free );
|
||||
simplelist_addline(
|
||||
"Free: %ld MB", free / 1024);
|
||||
simplelist_addline(
|
||||
|
|
|
@ -160,7 +160,7 @@ static const char* info_getname(int selected_item, void *data,
|
|||
#endif
|
||||
if (info->new_data)
|
||||
{
|
||||
fat_size(IF_MV2(0,) &info->size, &info->free);
|
||||
fat_size(IF_MV(0,) &info->size, &info->free);
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
if (fat_ismounted(1))
|
||||
fat_size(1, &info->size2, &info->free2);
|
||||
|
|
|
@ -95,7 +95,7 @@ DIR_UNCACHED* opendir_uncached(const char* name)
|
|||
strlcpy(namecopy, name, sizeof(namecopy)); /* just copy */
|
||||
#endif
|
||||
|
||||
if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) {
|
||||
if ( fat_opendir(IF_MV(volume,) &pdir->fatdir, 0, NULL) < 0 ) {
|
||||
DEBUGF("Failed opening root dir\n");
|
||||
pdir->busy = false;
|
||||
return NULL;
|
||||
|
@ -122,7 +122,7 @@ DIR_UNCACHED* opendir_uncached(const char* name)
|
|||
* as the parent directory and the resulting one (this is safe,
|
||||
* in doubt, check fat_open(dir) code) which will allow this kind of
|
||||
* (ugly) things */
|
||||
if ( fat_opendir(IF_MV2(volume,)
|
||||
if ( fat_opendir(IF_MV(volume,)
|
||||
&pdir->fatdir,
|
||||
entry.firstcluster,
|
||||
&pdir->fatdir) < 0 ) {
|
||||
|
|
|
@ -303,7 +303,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
|
|||
sab.dir->entrycount = 0;
|
||||
sab.dir->file.firstcluster = 0;
|
||||
/* open directory */
|
||||
int rc = fat_opendir(IF_MV2(sab.volume,) sab.dir, startcluster, sab.dir);
|
||||
int rc = fat_opendir(IF_MV(sab.volume,) sab.dir, startcluster, sab.dir);
|
||||
if(rc < 0)
|
||||
{
|
||||
logf("fat_opendir failed: %d", rc);
|
||||
|
@ -381,7 +381,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
|
|||
/* used during the generation */
|
||||
static struct fat_dir sab_fat_dir;
|
||||
|
||||
static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce)
|
||||
static int dircache_scan_and_build(IF_MV(int volume,) struct dircache_entry *ce)
|
||||
{
|
||||
memset(ce, 0, sizeof(struct dircache_entry));
|
||||
|
||||
|
@ -493,7 +493,7 @@ static int sab_process_dir(struct dircache_entry *ce)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce)
|
||||
static int dircache_scan_and_build(IF_MV(int volume,) struct dircache_entry *ce)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
(void) volume;
|
||||
|
@ -786,9 +786,9 @@ static int dircache_do_rebuild(void)
|
|||
#endif
|
||||
cpu_boost(true);
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
if (dircache_scan_and_build(IF_MV2(i,) append_position) < 0)
|
||||
if (dircache_scan_and_build(IF_MV(i,) append_position) < 0)
|
||||
#else
|
||||
if (dircache_scan_and_build(IF_MV2(0,) root_entry) < 0)
|
||||
if (dircache_scan_and_build(IF_MV(0,) root_entry) < 0)
|
||||
#endif /* HAVE_MULTIVOLUME */
|
||||
{
|
||||
logf("dircache_scan_and_build failed");
|
||||
|
|
|
@ -90,7 +90,7 @@ struct partinfo* disk_init(IF_MD_NONVOID(int drive))
|
|||
#endif
|
||||
|
||||
unsigned char* sector = fat_get_sector_buffer();
|
||||
storage_read_sectors(IF_MD2(drive,) 0,1, sector);
|
||||
storage_read_sectors(IF_MD(drive,) 0,1, sector);
|
||||
/* check that the boot sector is initialized */
|
||||
if ( (sector[510] != 0x55) ||
|
||||
(sector[511] != 0xaa)) {
|
||||
|
@ -210,7 +210,7 @@ int disk_mount(int drive)
|
|||
|
||||
for (j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1)
|
||||
{
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start * j))
|
||||
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j))
|
||||
{
|
||||
pinfo[i].start *= j;
|
||||
pinfo[i].size *= j;
|
||||
|
@ -222,7 +222,7 @@ int disk_mount(int drive)
|
|||
}
|
||||
}
|
||||
#else
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start))
|
||||
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
|
||||
{
|
||||
mounted++;
|
||||
vol_drive[volume] = drive; /* remember the drive for this volume */
|
||||
|
@ -234,7 +234,7 @@ int disk_mount(int drive)
|
|||
if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */
|
||||
{ /* try "superfloppy" mode */
|
||||
DEBUGF("No partition found, trying to mount sector 0.\n");
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0))
|
||||
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0))
|
||||
{
|
||||
#ifdef MAX_LOG_SECTOR_SIZE
|
||||
disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE;
|
||||
|
|
|
@ -121,7 +121,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
|
|||
}
|
||||
|
||||
long startcluster = _dircache_get_entry_startcluster(ce);
|
||||
fat_open(IF_MV2(volume,)
|
||||
fat_open(IF_MV(volume,)
|
||||
startcluster,
|
||||
&(file->fatfile),
|
||||
NULL);
|
||||
|
@ -167,7 +167,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
|
|||
/* scan dir for name */
|
||||
while ((entry = readdir_uncached(dir))) {
|
||||
if ( !strcasecmp(name, entry->d_name) ) {
|
||||
fat_open(IF_MV2(dir->fatdir.file.volume,)
|
||||
fat_open(IF_MV(dir->fatdir.file.volume,)
|
||||
entry->startcluster,
|
||||
&(file->fatfile),
|
||||
&(dir->fatdir));
|
||||
|
|
|
@ -567,7 +567,7 @@ static int ata_transfer_sectors(unsigned long start,
|
|||
}
|
||||
|
||||
#ifndef MAX_PHYS_SECTOR_SIZE
|
||||
int ata_read_sectors(IF_MD2(int drive,)
|
||||
int ata_read_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -581,7 +581,7 @@ int ata_read_sectors(IF_MD2(int drive,)
|
|||
#endif
|
||||
|
||||
#ifndef MAX_PHYS_SECTOR_SIZE
|
||||
int ata_write_sectors(IF_MD2(int drive,)
|
||||
int ata_write_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -623,7 +623,7 @@ static inline int flush_current_sector(void)
|
|||
sector_cache.data, true);
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MD2(int drive,)
|
||||
int ata_read_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -689,7 +689,7 @@ int ata_read_sectors(IF_MD2(int drive,)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MD2(int drive,)
|
||||
int ata_write_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -1480,7 +1480,7 @@ int ata_spinup_time(void)
|
|||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ata_get_info(IF_MD2(int drive,)struct storage_info *info)
|
||||
void ata_get_info(IF_MD(int drive,)struct storage_info *info)
|
||||
{
|
||||
unsigned short *src,*dest;
|
||||
static char vendor[8];
|
||||
|
|
|
@ -384,7 +384,7 @@ int flash_disk_read_sectors(unsigned long start,
|
|||
return done;
|
||||
}
|
||||
|
||||
int nand_read_sectors(IF_MD2(int drive,)
|
||||
int nand_read_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -401,7 +401,7 @@ int nand_read_sectors(IF_MD2(int drive,)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MD2(int drive,)
|
||||
int nand_write_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
|
|
@ -189,13 +189,13 @@ static bool initialized = false;
|
|||
static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb));
|
||||
static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb));
|
||||
static int bpb_is_sane(IF_MV_NONVOID(struct bpb* fat_bpb));
|
||||
static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,)
|
||||
static void *cache_fat_sector(IF_MV(struct bpb* fat_bpb,)
|
||||
long secnum, bool dirty);
|
||||
static void create_dos_name(const unsigned char *name, unsigned char *newname);
|
||||
static void randomize_dos_name(unsigned char *name);
|
||||
static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,)
|
||||
static unsigned long find_free_cluster(IF_MV(struct bpb* fat_bpb,)
|
||||
unsigned long start);
|
||||
static int transfer(IF_MV2(struct bpb* fat_bpb,) unsigned long start,
|
||||
static int transfer(IF_MV(struct bpb* fat_bpb,) unsigned long start,
|
||||
long count, char* buf, bool write );
|
||||
|
||||
#define FAT_CACHE_SIZE 0x20
|
||||
|
@ -230,7 +230,7 @@ void fat_unlock(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster)
|
||||
static long cluster2sec(IF_MV(struct bpb* fat_bpb,) long cluster)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
struct bpb* fat_bpb = &fat_bpbs[0];
|
||||
|
@ -252,7 +252,7 @@ static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster)
|
|||
+ fat_bpb->firstdatasector;
|
||||
}
|
||||
|
||||
void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
|
||||
void fat_size(IF_MV(int volume,) unsigned long* size, unsigned long* free)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
const int volume = 0;
|
||||
|
@ -303,7 +303,7 @@ void fat_init(void)
|
|||
|
||||
/* fat_mount_internal is split out of fat_mount() to avoid having both the sector
|
||||
* buffer used here and the sector buffer used by update_fsinfo() on stack */
|
||||
static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long startsector)
|
||||
static int fat_mount_internal(IF_MV(int volume,) IF_MD(int drive,) long startsector)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
const int volume = 0;
|
||||
|
@ -318,7 +318,7 @@ static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long starts
|
|||
|
||||
unsigned char* buf = fat_get_sector_buffer();
|
||||
/* Read the sector */
|
||||
rc = storage_read_sectors(IF_MD2(drive,) startsector,1,buf);
|
||||
rc = storage_read_sectors(IF_MD(drive,) startsector,1,buf);
|
||||
if(rc)
|
||||
{
|
||||
fat_release_sector_buffer();
|
||||
|
@ -428,7 +428,7 @@ static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long starts
|
|||
{ /* FAT32 specific part of BPB */
|
||||
fat_bpb->bpb_rootclus = BYTES2INT32(buf,BPB_ROOTCLUS);
|
||||
fat_bpb->bpb_fsinfo = secmult * BYTES2INT16(buf,BPB_FSINFO);
|
||||
fat_bpb->rootdirsector = cluster2sec(IF_MV2(fat_bpb,)
|
||||
fat_bpb->rootdirsector = cluster2sec(IF_MV(fat_bpb,)
|
||||
fat_bpb->bpb_rootclus);
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long starts
|
|||
#endif /* #ifdef HAVE_FAT16SUPPORT */
|
||||
{
|
||||
/* Read the fsinfo sector */
|
||||
rc = storage_read_sectors(IF_MD2(drive,)
|
||||
rc = storage_read_sectors(IF_MD(drive,)
|
||||
startsector + fat_bpb->bpb_fsinfo, 1, buf);
|
||||
if (rc < 0)
|
||||
{
|
||||
|
@ -493,7 +493,7 @@ int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume))
|
|||
}
|
||||
#endif
|
||||
|
||||
int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector)
|
||||
int fat_mount(IF_MV(int volume,) IF_MD(int drive,) long startsector)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
const int volume = 0;
|
||||
|
@ -501,7 +501,7 @@ int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector)
|
|||
struct bpb* fat_bpb = &fat_bpbs[volume];
|
||||
int rc;
|
||||
|
||||
rc = fat_mount_internal(IF_MV2(volume,) IF_MD2(drive,) startsector);
|
||||
rc = fat_mount_internal(IF_MV(volume,) IF_MD(drive,) startsector);
|
||||
|
||||
if(rc!=0) return rc;
|
||||
|
||||
|
@ -576,7 +576,7 @@ void fat_recalc_free(IF_MV_NONVOID(int volume))
|
|||
{
|
||||
for (i = 0; i<fat_bpb->fatsize; i++) {
|
||||
unsigned int j;
|
||||
uint16_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) i, false);
|
||||
uint16_t* fat = cache_fat_sector(IF_MV(fat_bpb,) i, false);
|
||||
for (j = 0; j < CLUSTERS_PER_FAT16_SECTOR; j++) {
|
||||
unsigned int c = i * CLUSTERS_PER_FAT16_SECTOR + j;
|
||||
if ( c > fat_bpb->dataclusters+1 ) /* nr 0 is unused */
|
||||
|
@ -595,7 +595,7 @@ void fat_recalc_free(IF_MV_NONVOID(int volume))
|
|||
{
|
||||
for (i = 0; i<fat_bpb->fatsize; i++) {
|
||||
unsigned int j;
|
||||
uint32_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) i, false);
|
||||
uint32_t* fat = cache_fat_sector(IF_MV(fat_bpb,) i, false);
|
||||
for (j = 0; j < CLUSTERS_PER_FAT_SECTOR; j++) {
|
||||
unsigned long c = i * CLUSTERS_PER_FAT_SECTOR + j;
|
||||
if ( c > fat_bpb->dataclusters+1 ) /* nr 0 is unused */
|
||||
|
@ -677,7 +677,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce,
|
|||
#endif
|
||||
|
||||
/* Write to the first FAT */
|
||||
rc = storage_write_sectors(IF_MD2(fce->fat_vol->drive,)
|
||||
rc = storage_write_sectors(IF_MD(fce->fat_vol->drive,)
|
||||
secnum, 1,
|
||||
sectorbuf);
|
||||
if(rc < 0)
|
||||
|
@ -698,7 +698,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce,
|
|||
#else
|
||||
secnum += fat_bpbs[0].fatsize;
|
||||
#endif
|
||||
rc = storage_write_sectors(IF_MD2(fce->fat_vol->drive,)
|
||||
rc = storage_write_sectors(IF_MD(fce->fat_vol->drive,)
|
||||
secnum, 1, sectorbuf);
|
||||
if(rc < 0)
|
||||
{
|
||||
|
@ -712,7 +712,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce,
|
|||
|
||||
/* Note: The returned pointer is only safely valid until the next
|
||||
task switch! (Any subsequent ata read/write may yield.) */
|
||||
static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,)
|
||||
static void *cache_fat_sector(IF_MV(struct bpb* fat_bpb,)
|
||||
long fatsector, bool dirty)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
|
@ -744,7 +744,7 @@ static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,)
|
|||
/* Load the sector if it is not cached */
|
||||
if(!fce->inuse)
|
||||
{
|
||||
rc = storage_read_sectors(IF_MD2(fat_bpb->drive,)
|
||||
rc = storage_read_sectors(IF_MD(fat_bpb->drive,)
|
||||
secnum + fat_bpb->startsector,1,
|
||||
sectorbuf);
|
||||
if(rc < 0)
|
||||
|
@ -766,7 +766,7 @@ static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,)
|
|||
return sectorbuf;
|
||||
}
|
||||
|
||||
static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,)
|
||||
static unsigned long find_free_cluster(IF_MV(struct bpb* fat_bpb,)
|
||||
unsigned long startcluster)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
|
@ -785,7 +785,7 @@ static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,)
|
|||
for (i = 0; i<fat_bpb->fatsize; i++) {
|
||||
unsigned int j;
|
||||
unsigned int nr = (i + sector) % fat_bpb->fatsize;
|
||||
uint16_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) nr, false);
|
||||
uint16_t* fat = cache_fat_sector(IF_MV(fat_bpb,) nr, false);
|
||||
if ( !fat )
|
||||
break;
|
||||
for (j = 0; j < CLUSTERS_PER_FAT16_SECTOR; j++) {
|
||||
|
@ -813,7 +813,7 @@ static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,)
|
|||
for (i = 0; i<fat_bpb->fatsize; i++) {
|
||||
unsigned int j;
|
||||
unsigned long nr = (i + sector) % fat_bpb->fatsize;
|
||||
uint32_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) nr, false);
|
||||
uint32_t* fat = cache_fat_sector(IF_MV(fat_bpb,) nr, false);
|
||||
if ( !fat )
|
||||
break;
|
||||
for (j = 0; j < CLUSTERS_PER_FAT_SECTOR; j++) {
|
||||
|
@ -837,7 +837,7 @@ static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,)
|
|||
return 0; /* 0 is an illegal cluster number */
|
||||
}
|
||||
|
||||
static int update_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry,
|
||||
static int update_fat_entry(IF_MV(struct bpb* fat_bpb,) unsigned long entry,
|
||||
unsigned long val)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
|
@ -860,7 +860,7 @@ static int update_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry,
|
|||
if ( entry < 2 )
|
||||
panicf("Updating reserved FAT entry %ld.\n",entry);
|
||||
|
||||
sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, true);
|
||||
sec = cache_fat_sector(IF_MV(fat_bpb,) sector, true);
|
||||
if (!sec)
|
||||
{
|
||||
DEBUGF( "update_fat_entry() - Could not cache sector %d\n", sector);
|
||||
|
@ -896,7 +896,7 @@ static int update_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry,
|
|||
if ( entry < 2 )
|
||||
panicf("Updating reserved FAT entry %ld.\n",entry);
|
||||
|
||||
sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, true);
|
||||
sec = cache_fat_sector(IF_MV(fat_bpb,) sector, true);
|
||||
if (!sec)
|
||||
{
|
||||
DEBUGF("update_fat_entry() - Could not cache sector %ld\n", sector);
|
||||
|
@ -924,7 +924,7 @@ static int update_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static long read_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry)
|
||||
static long read_fat_entry(IF_MV(struct bpb* fat_bpb,) unsigned long entry)
|
||||
{
|
||||
#ifdef HAVE_FAT16SUPPORT
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
|
@ -936,7 +936,7 @@ static long read_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry)
|
|||
int offset = entry % CLUSTERS_PER_FAT16_SECTOR;
|
||||
unsigned short* sec;
|
||||
|
||||
sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, false);
|
||||
sec = cache_fat_sector(IF_MV(fat_bpb,) sector, false);
|
||||
if (!sec)
|
||||
{
|
||||
DEBUGF( "read_fat_entry() - Could not cache sector %d\n", sector);
|
||||
|
@ -952,7 +952,7 @@ static long read_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry)
|
|||
int offset = entry % CLUSTERS_PER_FAT_SECTOR;
|
||||
uint32_t* sec;
|
||||
|
||||
sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, false);
|
||||
sec = cache_fat_sector(IF_MV(fat_bpb,) sector, false);
|
||||
if (!sec)
|
||||
{
|
||||
DEBUGF( "read_fat_entry() - Could not cache sector %ld\n", sector);
|
||||
|
@ -963,7 +963,7 @@ static long read_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry)
|
|||
}
|
||||
}
|
||||
|
||||
static long get_next_cluster(IF_MV2(struct bpb* fat_bpb,) long cluster)
|
||||
static long get_next_cluster(IF_MV(struct bpb* fat_bpb,) long cluster)
|
||||
{
|
||||
long next_cluster;
|
||||
long eof_mark = FAT_EOF_MARK;
|
||||
|
@ -979,7 +979,7 @@ static long get_next_cluster(IF_MV2(struct bpb* fat_bpb,) long cluster)
|
|||
return cluster + 1; /* don't use the FAT */
|
||||
}
|
||||
#endif
|
||||
next_cluster = read_fat_entry(IF_MV2(fat_bpb,) cluster);
|
||||
next_cluster = read_fat_entry(IF_MV(fat_bpb,) cluster);
|
||||
|
||||
/* is this last cluster in chain? */
|
||||
if ( next_cluster >= eof_mark )
|
||||
|
@ -1003,7 +1003,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb))
|
|||
|
||||
unsigned char* fsinfo = fat_get_sector_buffer();
|
||||
/* update fsinfo */
|
||||
rc = storage_read_sectors(IF_MD2(fat_bpb->drive,)
|
||||
rc = storage_read_sectors(IF_MD(fat_bpb->drive,)
|
||||
fat_bpb->startsector + fat_bpb->bpb_fsinfo, 1,fsinfo);
|
||||
if (rc < 0)
|
||||
{
|
||||
|
@ -1017,7 +1017,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb))
|
|||
intptr = (uint32_t*)&(fsinfo[FSINFO_NEXTFREE]);
|
||||
*intptr = htole32(fat_bpb->fsinfo.nextfree);
|
||||
|
||||
rc = storage_write_sectors(IF_MD2(fat_bpb->drive,)
|
||||
rc = storage_write_sectors(IF_MD(fat_bpb->drive,)
|
||||
fat_bpb->startsector + fat_bpb->bpb_fsinfo,1,fsinfo);
|
||||
fat_release_sector_buffer();
|
||||
if (rc < 0)
|
||||
|
@ -1634,7 +1634,7 @@ static int update_short_entry( struct fat_file* file, long size, int attr )
|
|||
file->firstcluster, file->direntry, size);
|
||||
|
||||
/* create a temporary file handle for the dir holding this file */
|
||||
rc = fat_open(IF_MV2(file->volume,) file->dircluster, &dir, NULL);
|
||||
rc = fat_open(IF_MV(file->volume,) file->dircluster, &dir, NULL);
|
||||
if (rc < 0)
|
||||
return rc * 10 - 1;
|
||||
|
||||
|
@ -1739,7 +1739,7 @@ static int parse_direntry(struct fat_direntry *de, const unsigned char *buf)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int fat_open(IF_MV2(int volume,)
|
||||
int fat_open(IF_MV(int volume,)
|
||||
long startcluster,
|
||||
struct fat_file *file,
|
||||
const struct fat_dir* dir)
|
||||
|
@ -1803,7 +1803,7 @@ static __attribute__((noinline)) int fat_clear_cluster(int sector,
|
|||
int i,rc;
|
||||
memset(buf, 0, SECTOR_SIZE);
|
||||
for(i = 0;i < (int)fat_bpb->bpb_secperclus;i++) {
|
||||
rc = transfer(IF_MV2(fat_bpb,) sector + i, 1, buf, true );
|
||||
rc = transfer(IF_MV(fat_bpb,) sector + i, 1, buf, true );
|
||||
if (rc < 0)
|
||||
{
|
||||
fat_release_sector_buffer();
|
||||
|
@ -1838,15 +1838,15 @@ int fat_create_dir(const char* name,
|
|||
return rc * 10 - 1;
|
||||
|
||||
/* Allocate a new cluster for the directory */
|
||||
newdir->file.firstcluster = find_free_cluster(IF_MV2(fat_bpb,)
|
||||
newdir->file.firstcluster = find_free_cluster(IF_MV(fat_bpb,)
|
||||
fat_bpb->fsinfo.nextfree);
|
||||
if(newdir->file.firstcluster == 0)
|
||||
return -1;
|
||||
|
||||
update_fat_entry(IF_MV2(fat_bpb,) newdir->file.firstcluster, FAT_EOF_MARK);
|
||||
update_fat_entry(IF_MV(fat_bpb,) newdir->file.firstcluster, FAT_EOF_MARK);
|
||||
|
||||
/* Clear the entire cluster */
|
||||
sector = cluster2sec(IF_MV2(fat_bpb,) newdir->file.firstcluster);
|
||||
sector = cluster2sec(IF_MV(fat_bpb,) newdir->file.firstcluster);
|
||||
rc = fat_clear_cluster(sector,fat_bpb);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
@ -1892,12 +1892,12 @@ int fat_truncate(const struct fat_file *file)
|
|||
|
||||
LDEBUGF("fat_truncate(%lx, %lx)\n", file->firstcluster, last);
|
||||
|
||||
for ( last = get_next_cluster(IF_MV2(fat_bpb,) last); last; last = next ) {
|
||||
next = get_next_cluster(IF_MV2(fat_bpb,) last);
|
||||
update_fat_entry(IF_MV2(fat_bpb,) last,0);
|
||||
for ( last = get_next_cluster(IF_MV(fat_bpb,) last); last; last = next ) {
|
||||
next = get_next_cluster(IF_MV(fat_bpb,) last);
|
||||
update_fat_entry(IF_MV(fat_bpb,) last,0);
|
||||
}
|
||||
if (file->lastcluster)
|
||||
update_fat_entry(IF_MV2(fat_bpb,) file->lastcluster,FAT_EOF_MARK);
|
||||
update_fat_entry(IF_MV(fat_bpb,) file->lastcluster,FAT_EOF_MARK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1913,7 +1913,7 @@ int fat_closewrite(struct fat_file *file, long size, int attr)
|
|||
if (!size) {
|
||||
/* empty file */
|
||||
if ( file->firstcluster ) {
|
||||
update_fat_entry(IF_MV2(fat_bpb,) file->firstcluster, 0);
|
||||
update_fat_entry(IF_MV(fat_bpb,) file->firstcluster, 0);
|
||||
file->firstcluster = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1938,7 +1938,7 @@ int fat_closewrite(struct fat_file *file, long size, int attr)
|
|||
long len;
|
||||
long next;
|
||||
for ( next = file->firstcluster; next;
|
||||
next = get_next_cluster(IF_MV2(fat_bpb,) next) ) {
|
||||
next = get_next_cluster(IF_MV(fat_bpb,) next) ) {
|
||||
LDEBUGF("cluster %ld: %lx\n", count, next);
|
||||
count++;
|
||||
}
|
||||
|
@ -1965,7 +1965,7 @@ static int free_direntries(struct fat_file* file)
|
|||
int rc;
|
||||
|
||||
/* create a temporary file handle for the dir holding this file */
|
||||
rc = fat_open(IF_MV2(file->volume,) file->dircluster, &dir, NULL);
|
||||
rc = fat_open(IF_MV(file->volume,) file->dircluster, &dir, NULL);
|
||||
if (rc < 0)
|
||||
return rc * 10 - 1;
|
||||
|
||||
|
@ -2048,8 +2048,8 @@ int fat_remove(struct fat_file* file)
|
|||
LDEBUGF("fat_remove(%lx)\n",last);
|
||||
|
||||
while ( last ) {
|
||||
next = get_next_cluster(IF_MV2(fat_bpb,) last);
|
||||
update_fat_entry(IF_MV2(fat_bpb,) last,0);
|
||||
next = get_next_cluster(IF_MV(fat_bpb,) last);
|
||||
update_fat_entry(IF_MV(fat_bpb,) last,0);
|
||||
last = next;
|
||||
}
|
||||
|
||||
|
@ -2120,7 +2120,7 @@ int fat_rename(struct fat_file* file,
|
|||
it points to its parent directory (we don't check if it was a move) */
|
||||
if(FAT_ATTR_DIRECTORY == attr) {
|
||||
/* open the dir that was renamed, we re-use the olddir_file struct */
|
||||
rc = fat_open(IF_MV2(file->volume,) newfile.firstcluster, &olddir_file, NULL);
|
||||
rc = fat_open(IF_MV(file->volume,) newfile.firstcluster, &olddir_file, NULL);
|
||||
if (rc < 0)
|
||||
return rc * 10 - 6;
|
||||
|
||||
|
@ -2189,13 +2189,13 @@ static long next_write_cluster(struct fat_file* file,
|
|||
LDEBUGF("next_write_cluster(%lx,%lx)\n",file->firstcluster, oldcluster);
|
||||
|
||||
if (oldcluster)
|
||||
cluster = get_next_cluster(IF_MV2(fat_bpb,) oldcluster);
|
||||
cluster = get_next_cluster(IF_MV(fat_bpb,) oldcluster);
|
||||
|
||||
if (!cluster) {
|
||||
if (oldcluster > 0)
|
||||
cluster = find_free_cluster(IF_MV2(fat_bpb,) oldcluster+1);
|
||||
cluster = find_free_cluster(IF_MV(fat_bpb,) oldcluster+1);
|
||||
else if (oldcluster == 0)
|
||||
cluster = find_free_cluster(IF_MV2(fat_bpb,)
|
||||
cluster = find_free_cluster(IF_MV(fat_bpb,)
|
||||
fat_bpb->fsinfo.nextfree);
|
||||
#ifdef HAVE_FAT16SUPPORT
|
||||
else /* negative, pseudo-cluster of the root dir */
|
||||
|
@ -2204,10 +2204,10 @@ static long next_write_cluster(struct fat_file* file,
|
|||
|
||||
if (cluster) {
|
||||
if (oldcluster)
|
||||
update_fat_entry(IF_MV2(fat_bpb,) oldcluster, cluster);
|
||||
update_fat_entry(IF_MV(fat_bpb,) oldcluster, cluster);
|
||||
else
|
||||
file->firstcluster = cluster;
|
||||
update_fat_entry(IF_MV2(fat_bpb,) cluster, FAT_EOF_MARK);
|
||||
update_fat_entry(IF_MV(fat_bpb,) cluster, FAT_EOF_MARK);
|
||||
}
|
||||
else {
|
||||
#ifdef TEST_FAT
|
||||
|
@ -2219,7 +2219,7 @@ static long next_write_cluster(struct fat_file* file,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
sector = cluster2sec(IF_MV2(fat_bpb,) cluster);
|
||||
sector = cluster2sec(IF_MV(fat_bpb,) cluster);
|
||||
if (sector<0)
|
||||
return 0;
|
||||
|
||||
|
@ -2227,7 +2227,7 @@ static long next_write_cluster(struct fat_file* file,
|
|||
return cluster;
|
||||
}
|
||||
|
||||
static int transfer(IF_MV2(struct bpb* fat_bpb,)
|
||||
static int transfer(IF_MV(struct bpb* fat_bpb,)
|
||||
unsigned long start, long count, char* buf, bool write )
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
|
@ -2251,11 +2251,11 @@ static int transfer(IF_MV2(struct bpb* fat_bpb,)
|
|||
if (start + count > fat_bpb->totalsectors)
|
||||
panicf("Write %ld after data\n",
|
||||
start + count - fat_bpb->totalsectors);
|
||||
rc = storage_write_sectors(IF_MD2(fat_bpb->drive,)
|
||||
rc = storage_write_sectors(IF_MD(fat_bpb->drive,)
|
||||
start + fat_bpb->startsector, count, buf);
|
||||
}
|
||||
else
|
||||
rc = storage_read_sectors(IF_MD2(fat_bpb->drive,)
|
||||
rc = storage_read_sectors(IF_MD(fat_bpb->drive,)
|
||||
start + fat_bpb->startsector, count, buf);
|
||||
if (rc < 0) {
|
||||
DEBUGF( "transfer() - Couldn't %s sector %lx"
|
||||
|
@ -2302,8 +2302,8 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
|
|||
if (write)
|
||||
cluster = next_write_cluster(file, cluster, §or);
|
||||
else {
|
||||
cluster = get_next_cluster(IF_MV2(fat_bpb,) cluster);
|
||||
sector = cluster2sec(IF_MV2(fat_bpb,) cluster);
|
||||
cluster = get_next_cluster(IF_MV(fat_bpb,) cluster);
|
||||
sector = cluster2sec(IF_MV(fat_bpb,) cluster);
|
||||
}
|
||||
|
||||
clusternum++;
|
||||
|
@ -2330,7 +2330,7 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
|
|||
sector++;
|
||||
else {
|
||||
/* look up first sector of file */
|
||||
sector = cluster2sec(IF_MV2(fat_bpb,) file->firstcluster);
|
||||
sector = cluster2sec(IF_MV(fat_bpb,) file->firstcluster);
|
||||
numsec=1;
|
||||
#ifdef HAVE_FAT16SUPPORT
|
||||
if (file->firstcluster < 0)
|
||||
|
@ -2348,7 +2348,7 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
|
|||
if ( ((sector != first) && (sector != last+1)) || /* not sequential */
|
||||
(last-first+1 == 256) ) { /* max 256 sectors per ata request */
|
||||
long count = last - first + 1;
|
||||
rc = transfer(IF_MV2(fat_bpb,) first, count, buf, write );
|
||||
rc = transfer(IF_MV(fat_bpb,) first, count, buf, write );
|
||||
if (rc < 0)
|
||||
return rc * 10 - 1;
|
||||
|
||||
|
@ -2360,7 +2360,7 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
|
|||
(!eof))
|
||||
{
|
||||
long count = sector - first + 1;
|
||||
rc = transfer(IF_MV2(fat_bpb,) first, count, buf, write );
|
||||
rc = transfer(IF_MV(fat_bpb,) first, count, buf, write );
|
||||
if (rc < 0)
|
||||
return rc * 10 - 2;
|
||||
}
|
||||
|
@ -2413,7 +2413,7 @@ int fat_seek(struct fat_file *file, unsigned long seeksector )
|
|||
}
|
||||
|
||||
for (i=0; i<numclusters; i++) {
|
||||
cluster = get_next_cluster(IF_MV2(fat_bpb,) cluster);
|
||||
cluster = get_next_cluster(IF_MV(fat_bpb,) cluster);
|
||||
if (!cluster) {
|
||||
DEBUGF("Seeking beyond the end of the file! "
|
||||
"(sector %ld, cluster %ld)\n", seeksector, i);
|
||||
|
@ -2421,7 +2421,7 @@ int fat_seek(struct fat_file *file, unsigned long seeksector )
|
|||
}
|
||||
}
|
||||
|
||||
sector = cluster2sec(IF_MV2(fat_bpb,) cluster) + sectornum;
|
||||
sector = cluster2sec(IF_MV(fat_bpb,) cluster) + sectornum;
|
||||
}
|
||||
else {
|
||||
sectornum = -1;
|
||||
|
@ -2437,7 +2437,7 @@ int fat_seek(struct fat_file *file, unsigned long seeksector )
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fat_opendir(IF_MV2(int volume,)
|
||||
int fat_opendir(IF_MV(int volume,)
|
||||
struct fat_dir *dir, unsigned long startcluster,
|
||||
const struct fat_dir *parent_dir)
|
||||
{
|
||||
|
@ -2457,7 +2457,7 @@ int fat_opendir(IF_MV2(int volume,)
|
|||
if (startcluster == 0)
|
||||
startcluster = fat_bpb->bpb_rootclus;
|
||||
|
||||
rc = fat_open(IF_MV2(volume,) startcluster, &dir->file, parent_dir);
|
||||
rc = fat_open(IF_MV(volume,) startcluster, &dir->file, parent_dir);
|
||||
if(rc)
|
||||
{
|
||||
DEBUGF( "fat_opendir() - Couldn't open dir"
|
||||
|
|
|
@ -31,7 +31,7 @@ unsigned char ramdisk[SECTOR_SIZE * NUM_SECTORS];
|
|||
|
||||
long last_disk_activity = -1;
|
||||
|
||||
int ramdisk_read_sectors(IF_MD2(int drive,)
|
||||
int ramdisk_read_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
void* buf)
|
||||
|
@ -47,7 +47,7 @@ int ramdisk_read_sectors(IF_MD2(int drive,)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ramdisk_write_sectors(IF_MD2(int drive,)
|
||||
int ramdisk_write_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -110,7 +110,7 @@ void ramdisk_spindown(int seconds)
|
|||
(void)seconds;
|
||||
}
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void ramdisk_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
|
|
|
@ -80,7 +80,7 @@ void sd_spindown(int seconds)
|
|||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void sd_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void sd_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
|
|
|
@ -39,8 +39,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_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
void ata_spin(void);
|
||||
#if (CONFIG_LED == LED_REAL)
|
||||
void ata_set_led_enabled(bool enabled);
|
||||
|
@ -48,7 +48,7 @@ void ata_set_led_enabled(bool enabled);
|
|||
unsigned short* ata_get_identify(void);
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ata_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
void ata_get_info(IF_MD(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool ata_removable(IF_MD_NONVOID(int drive));
|
||||
|
|
|
@ -101,16 +101,16 @@ extern void fat_unlock(void);
|
|||
|
||||
extern void fat_init(void);
|
||||
extern int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume));
|
||||
extern int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector);
|
||||
extern int fat_mount(IF_MV(int volume,) IF_MD(int drive,) long startsector);
|
||||
extern int fat_unmount(int volume, bool flush);
|
||||
extern void fat_size(IF_MV2(int volume,) /* public for info */
|
||||
extern void fat_size(IF_MV(int volume,) /* public for info */
|
||||
unsigned long* size,
|
||||
unsigned long* free);
|
||||
extern void fat_recalc_free(IF_MV_NONVOID(int volume)); /* public for debug info screen */
|
||||
extern int fat_create_dir(const char* name,
|
||||
struct fat_dir* newdir,
|
||||
struct fat_dir* dir);
|
||||
extern int fat_open(IF_MV2(int volume,)
|
||||
extern int fat_open(IF_MV(int volume,)
|
||||
long cluster,
|
||||
struct fat_file* ent,
|
||||
const struct fat_dir* dir);
|
||||
|
@ -128,7 +128,7 @@ extern int fat_rename(struct fat_file* file,
|
|||
const unsigned char* newname,
|
||||
long size, int attr);
|
||||
|
||||
extern int fat_opendir(IF_MV2(int volume,)
|
||||
extern int fat_opendir(IF_MV(int volume,)
|
||||
struct fat_dir *ent, unsigned long startcluster,
|
||||
const struct fat_dir *parent_dir);
|
||||
extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);
|
||||
|
|
|
@ -36,13 +36,13 @@ 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_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
void mmc_spin(void);
|
||||
int mmc_spinup_time(void);
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void mmc_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
void mmc_get_info(IF_MD(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool mmc_removable(IF_MD_NONVOID(int drive));
|
||||
|
|
|
@ -27,27 +27,28 @@
|
|||
/* FixMe: These macros are a bit nasty and perhaps misplaced here.
|
||||
We'll get rid of them once decided on how to proceed with multivolume. */
|
||||
|
||||
/* Drives are things like a disk, a card, a flash chip. They can have volumes on them */
|
||||
/* Drives are things like a disk, a card, a flash chip. They can have volumes
|
||||
on them */
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
#define IF_MD(x) x /* optional drive parameter */
|
||||
#define IF_MD2(x,y) x,y /* same, for a list of arguments */
|
||||
#define IF_MD_NONVOID(x) x /* for prototype with sole volume parameter */
|
||||
#define IF_MD(x...) x /* valist contents or empty */
|
||||
#define IF_MD_NONVOID(x...) x /* valist contents or 'void' */
|
||||
#define IF_MD_DRV(d) d /* drive argument or '0' */
|
||||
#else /* empty definitions if no multi-drive */
|
||||
#define IF_MD(x)
|
||||
#define IF_MD2(x,y)
|
||||
#define IF_MD_NONVOID(x) void
|
||||
#define IF_MD(x...)
|
||||
#define IF_MD_NONVOID(x...) void
|
||||
#define IF_MD_DRV(d) 0
|
||||
#endif
|
||||
|
||||
/* Volumes mean things that have filesystems on them, like partitions */
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#define IF_MV(x) x /* optional volume parameter */
|
||||
#define IF_MV2(x,y) x,y /* same, for a list of arguments */
|
||||
#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */
|
||||
#define IF_MV(x...) x /* valist contents or empty */
|
||||
#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */
|
||||
#define IF_MV_VOL(v) v /* volume argument or '0' */
|
||||
#else /* empty definitions if no multi-volume */
|
||||
#define IF_MV(x)
|
||||
#define IF_MV2(x,y)
|
||||
#define IF_MV_NONVOID(x) void
|
||||
#define IF_MV(x...)
|
||||
#define IF_MV_NONVOID(x...) void
|
||||
#define IF_MV_VOL(v) 0
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif /* __MV_H__ */
|
||||
|
|
|
@ -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_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
#ifdef HAVE_STORAGE_FLUSH
|
||||
int nand_flush(void);
|
||||
#endif
|
||||
|
@ -45,7 +45,7 @@ void nand_spin(void);
|
|||
int nand_spinup_time(void); /* ticks */
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
void nand_get_info(IF_MD(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
|
||||
long nand_last_disk_activity(void);
|
||||
|
|
|
@ -35,14 +35,14 @@ 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_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
void ramdisk_spin(void);
|
||||
void ramdisk_sleepnow(void);
|
||||
int ramdisk_spinup_time(void);
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
void ramdisk_get_info(IF_MD(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
|
||||
long ramdisk_last_disk_activity(void);
|
||||
|
|
|
@ -42,13 +42,13 @@ 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_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
void sd_spin(void);
|
||||
int sd_spinup_time(void); /* ticks */
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void sd_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
void sd_get_info(IF_MD(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool sd_removable(IF_MV_NONVOID(int drive));
|
||||
|
|
|
@ -95,7 +95,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
|
|||
#define storage_get_identify() ata_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
|
||||
#define storage_get_info(drive, info) ata_get_info(IF_MD(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) ata_removable(IF_MD(drive))
|
||||
|
@ -121,7 +121,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
|
|||
#define storage_get_identify() sd_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
|
||||
#define storage_get_info(drive, info) sd_get_info(IF_MD(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) sd_removable(IF_MD(drive))
|
||||
|
@ -146,7 +146,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
|
|||
#define storage_get_identify() mmc_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
|
||||
#define storage_get_info(drive, info) mmc_get_info(IF_MD(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) mmc_removable(IF_MD(drive))
|
||||
|
@ -171,7 +171,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
|
|||
#define storage_get_identify() nand_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
|
||||
#define storage_get_info(drive, info) nand_get_info(IF_MD(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) nand_removable(IF_MD(drive))
|
||||
|
@ -196,7 +196,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
|
|||
#define storage_get_identify() ramdisk_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
|
||||
#define storage_get_info(drive, info) ramdisk_get_info(IF_MD(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) ramdisk_removable(IF_MD(drive))
|
||||
|
@ -231,6 +231,6 @@ bool storage_present(int drive);
|
|||
|
||||
#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
|
||||
|
||||
int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
#endif
|
||||
|
|
|
@ -83,7 +83,7 @@ static void storage_wait_turn(IF_MD_NONVOID(int drive))
|
|||
}
|
||||
#endif
|
||||
|
||||
int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
#ifdef HAVE_IO_PRIORITY
|
||||
|
@ -98,38 +98,38 @@ int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
|||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
return ata_read_sectors(IF_MD2(ldrive,) start,count,buf);
|
||||
return ata_read_sectors(IF_MD(ldrive,) start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
return mmc_read_sectors(IF_MD2(ldrive,) start,count,buf);
|
||||
return mmc_read_sectors(IF_MD(ldrive,) start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
return sd_read_sectors(IF_MD2(ldrive,) start,count,buf);
|
||||
return sd_read_sectors(IF_MD(ldrive,) start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
return nand_read_sectors(IF_MD2(ldrive,) start,count,buf);
|
||||
return nand_read_sectors(IF_MD(ldrive,) start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
return ramdisk_read_sectors(IF_MD2(ldrive,) start,count,buf);
|
||||
return ramdisk_read_sectors(IF_MD(ldrive,) start,count,buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
return -1;
|
||||
#else /* CONFIG_STORAGE_MULTI */
|
||||
return STORAGE_FUNCTION(read_sectors)(IF_MD2(drive,)start,count,buf);
|
||||
return STORAGE_FUNCTION(read_sectors)(IF_MD(drive,)start,count,buf);
|
||||
#endif /* CONFIG_STORAGE_MULTI */
|
||||
|
||||
}
|
||||
|
||||
int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
#ifdef HAVE_IO_PRIORITY
|
||||
|
@ -144,33 +144,33 @@ int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
|||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
return ata_write_sectors(IF_MD2(ldrive,)start,count,buf);
|
||||
return ata_write_sectors(IF_MD(ldrive,)start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
return mmc_write_sectors(IF_MD2(ldrive,)start,count,buf);
|
||||
return mmc_write_sectors(IF_MD(ldrive,)start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
return sd_write_sectors(IF_MD2(ldrive,)start,count,buf);
|
||||
return sd_write_sectors(IF_MD(ldrive,)start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
return nand_write_sectors(IF_MD2(ldrive,)start,count,buf);
|
||||
return nand_write_sectors(IF_MD(ldrive,)start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
return ramdisk_write_sectors(IF_MD2(ldrive,)start,count,buf);
|
||||
return ramdisk_write_sectors(IF_MD(ldrive,)start,count,buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
return -1;
|
||||
#else /* CONFIG_STORAGE_MULTI */
|
||||
return STORAGE_FUNCTION(write_sectors)(IF_MD2(drive,)start,count,buf);
|
||||
return STORAGE_FUNCTION(write_sectors)(IF_MD(drive,)start,count,buf);
|
||||
#endif /* CONFIG_STORAGE_MULTI */
|
||||
}
|
||||
|
||||
|
|
|
@ -693,7 +693,7 @@ static int sd_select_bank(signed char bank)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
|
||||
static int sd_transfer_sectors(IF_MD(int drive,) unsigned long start,
|
||||
int count, void* buf, const bool write)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
|
@ -887,19 +887,19 @@ sd_transfer_error_nodma:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
int ret;
|
||||
|
||||
mutex_lock(&sd_mtx);
|
||||
ret = sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false);
|
||||
ret = sd_transfer_sectors(IF_MD(drive,) start, count, buf, false);
|
||||
mutex_unlock(&sd_mtx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
#ifdef VERIFY_WRITE
|
||||
|
@ -911,7 +911,7 @@ int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
|||
|
||||
mutex_lock(&sd_mtx);
|
||||
|
||||
ret = sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true);
|
||||
ret = sd_transfer_sectors(IF_MD(drive,) start, count, (void*)buf, true);
|
||||
|
||||
#ifdef VERIFY_WRITE
|
||||
if (ret) {
|
||||
|
@ -928,10 +928,10 @@ int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
|||
if(transfer > UNALIGNED_NUM_SECTORS)
|
||||
transfer = UNALIGNED_NUM_SECTORS;
|
||||
|
||||
sd_transfer_sectors(IF_MD2(drive,) start, transfer, aligned_buffer, false);
|
||||
sd_transfer_sectors(IF_MD(drive,) start, transfer, aligned_buffer, false);
|
||||
if (memcmp(buf, aligned_buffer, transfer * 512) != 0) {
|
||||
/* try the write again in the hope to repair the damage */
|
||||
sd_transfer_sectors(IF_MD2(drive,) saved_start, saved_count, saved_buf, true);
|
||||
sd_transfer_sectors(IF_MD(drive,) saved_start, saved_count, saved_buf, true);
|
||||
panicf("sd: verify failed: sec=%ld n=%d!", start, transfer);
|
||||
}
|
||||
|
||||
|
|
|
@ -773,7 +773,7 @@ int sd_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
|
||||
static int sd_transfer_sectors(IF_MD(int drive,) unsigned long start,
|
||||
int count, void* buf, bool write)
|
||||
{
|
||||
unsigned long response;
|
||||
|
@ -969,16 +969,16 @@ sd_transfer_error_no_dma:
|
|||
}
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
return sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false);
|
||||
return sd_transfer_sectors(IF_MD(drive,) start, count, buf, false);
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
return sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true);
|
||||
return sd_transfer_sectors(IF_MD(drive,) start, count, (void*)buf, true);
|
||||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
|
|
@ -800,7 +800,7 @@ static void read_inplace_writes_cache(int bank, int phys_segment)
|
|||
}
|
||||
|
||||
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
|
@ -855,7 +855,7 @@ nand_read_error:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
|
@ -877,7 +877,7 @@ int nand_flush(void)
|
|||
#endif
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void nand_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
|
|
|
@ -36,13 +36,13 @@ int nand_init(void)
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int nand_read_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
return -1;
|
||||
|
@ -54,7 +54,7 @@ int nand_num_drives(int first_drive)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void nand_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
IF_MD((void)drive);
|
||||
info->sector_size = SECTOR_SIZE;
|
||||
|
|
|
@ -845,7 +845,7 @@ void sd_enable(bool on)
|
|||
(void) on;
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, void *buf)
|
||||
int sd_read_sectors(IF_MD(int sd_drive,) unsigned long start, int count, void *buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int sd_drive = 0;
|
||||
|
@ -853,7 +853,7 @@ int sd_read_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, void *
|
|||
return transfer_sectors(sd_map[sd_drive], start, count, buf, true);
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, const void* buf)
|
||||
int sd_write_sectors(IF_MD(int sd_drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int sd_drive = 0;
|
||||
|
@ -878,7 +878,7 @@ int mmc_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void mmc_get_info(IF_MD2(int mmc_drive,) struct storage_info *info)
|
||||
void mmc_get_info(IF_MD(int mmc_drive,) struct storage_info *info)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int mmc_drive = 0;
|
||||
|
@ -968,7 +968,7 @@ int mmc_spinup_time(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mmc_read_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, void *buf)
|
||||
int mmc_read_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, void *buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int mmc_drive = 0;
|
||||
|
@ -976,7 +976,7 @@ int mmc_read_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, void
|
|||
return transfer_sectors(mmc_map[mmc_drive], start, count, buf, true);
|
||||
}
|
||||
|
||||
int mmc_write_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, const void* buf)
|
||||
int mmc_write_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int mmc_drive = 0;
|
||||
|
|
|
@ -864,7 +864,7 @@ static void sd_select_device(int card_no)
|
|||
|
||||
/* API Functions */
|
||||
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
int sd_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
|
@ -981,7 +981,7 @@ sd_read_error:
|
|||
}
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
/* Write support is not finished yet */
|
||||
|
|
|
@ -35,14 +35,14 @@
|
|||
static bool initialized = false;
|
||||
|
||||
/* API Functions */
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
(void)drive;
|
||||
return ftl_read(start, incount, inbuf);
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
(void)drive;
|
||||
|
@ -74,7 +74,7 @@ void nand_enable(bool on)
|
|||
(void)on;
|
||||
}
|
||||
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void nand_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
(void)drive;
|
||||
uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
|
||||
|
|
|
@ -495,7 +495,7 @@ static inline void write_sd_data(unsigned char **src)
|
|||
*src += 512;
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
|
@ -618,7 +618,7 @@ int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
|||
}
|
||||
|
||||
/* Not tested */
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
|
|
|
@ -847,7 +847,7 @@ sd_transfer_error:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
|
||||
int sd_read_sectors(IF_MD(int card_no,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
int ret;
|
||||
|
@ -868,7 +868,7 @@ int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
#ifdef BOOTLOADER /* we don't need write support in bootloader */
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
static bool initialized = false;
|
||||
|
||||
/* API Functions */
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
return ftl_read(start, incount, inbuf);
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
return ftl_write(start, count, outbuf);
|
||||
|
@ -70,7 +70,7 @@ void nand_enable(bool on)
|
|||
(void)on;
|
||||
}
|
||||
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void nand_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
|
||||
(*info).sector_size = SECTOR_SIZE;
|
||||
|
|
|
@ -962,7 +962,7 @@ int ata_soft_reset(void)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
int ata_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
mutex_lock(&ata_mutex);
|
||||
|
@ -971,7 +971,7 @@ int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
mutex_lock(&ata_mutex);
|
||||
|
@ -1007,7 +1007,7 @@ void ata_spin(void)
|
|||
ata_set_active();
|
||||
}
|
||||
|
||||
void ata_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void ata_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
(*info).sector_size = SECTOR_SIZE;
|
||||
#ifdef ATA_HAVE_BBT
|
||||
|
|
|
@ -398,7 +398,7 @@ static void sd_select_device(int card_no)
|
|||
}
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
|
||||
int sd_read_sectors(IF_MD(int card_no,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
|
@ -512,7 +512,7 @@ sd_read_error:
|
|||
}
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int card_no,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int card_no,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
/* Write support is not finished yet */
|
||||
|
|
|
@ -126,8 +126,8 @@ void GIO2(void)
|
|||
|
||||
#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */
|
||||
|
||||
extern int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
|
||||
struct main_header
|
||||
{
|
||||
|
@ -396,14 +396,14 @@ static inline unsigned long map_sector(unsigned long sector)
|
|||
return cfs_start+sectors[sector/64]*64+sector%64;
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf)
|
||||
int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_read_sectors(IF_MD2(drive,) map_sector(start), count, buf);
|
||||
return _ata_read_sectors(IF_MD(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
@ -412,7 +412,7 @@ int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* bu
|
|||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
int ret = _ata_read_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
|
||||
int ret = _ata_read_sectors(IF_MD(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
|
@ -423,7 +423,7 @@ int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* bu
|
|||
}
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf)
|
||||
int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
@ -431,7 +431,7 @@ int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const v
|
|||
#if 0 /* Disabled for now */
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_write_sectors(IF_MD2(drive,) map_sector(start), count, buf);
|
||||
return _ata_write_sectors(IF_MD(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
|
@ -440,7 +440,7 @@ int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const v
|
|||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_write_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
|
||||
ret = _ata_write_sectors(IF_MD(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -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_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int _ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
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);
|
||||
|
||||
/* General purpose memory region #1 */
|
||||
#define ATA_IOBASE 0x50FEE000
|
||||
|
|
|
@ -849,7 +849,7 @@ sd_transfer_error:
|
|||
}
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
|
||||
int sd_read_sectors(IF_MD(int card_no,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
|
@ -858,7 +858,7 @@ int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
|
|||
return sd_transfer_sectors(card_no, start, incount, inbuf, false);
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int card_no,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD(int card_no,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
#ifndef BOOTLOADER
|
||||
|
|
|
@ -628,7 +628,7 @@ static inline int read_sector(unsigned long start, unsigned int count,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
|
||||
int nand_read_sectors(IF_MV(int drive,) unsigned long start, int count, void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive;
|
||||
|
@ -671,7 +671,7 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* b
|
|||
}
|
||||
|
||||
/* TODO */
|
||||
int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
|
||||
int nand_write_sectors(IF_MV(int drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
(void)start;
|
||||
(void)count;
|
||||
|
@ -728,7 +728,7 @@ void nand_sleepnow(void)
|
|||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
|
||||
void nand_get_info(IF_MV(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive;
|
||||
|
|
|
@ -1266,7 +1266,7 @@ static inline void sd_stop_transfer(void)
|
|||
mutex_unlock(&sd_mtx);
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
|
||||
int sd_read_sectors(IF_MV(int drive,) unsigned long start, int count, void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive;
|
||||
|
@ -1320,7 +1320,7 @@ err:
|
|||
return retval;
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
|
||||
int sd_write_sectors(IF_MV(int drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive;
|
||||
|
|
|
@ -603,7 +603,7 @@ static int send_block_send(unsigned char start_token, long timeout,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int mmc_read_sectors(IF_MD2(int drive,)
|
||||
int mmc_read_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -689,7 +689,7 @@ int mmc_read_sectors(IF_MD2(int drive,)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int mmc_write_sectors(IF_MD2(int drive,)
|
||||
int mmc_write_sectors(IF_MD(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -953,7 +953,7 @@ long mmc_last_disk_activity(void)
|
|||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void mmc_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
void mmc_get_info(IF_MD(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
|
|
|
@ -697,7 +697,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
) {
|
||||
DEBUGF("*** Mounting at block %ld\n",pinfo[i].start);
|
||||
rc = fat_mount(IF_MV2(0,) IF_MD2(0,) pinfo[i].start);
|
||||
rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
|
||||
if(rc) {
|
||||
DEBUGF("mount: %d",rc);
|
||||
return -1;
|
||||
|
@ -706,7 +706,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
if ( i==4 ) {
|
||||
if(fat_mount(IF_MV2(0,) IF_MD2(0,) 0)) {
|
||||
if(fat_mount(IF_MV(0,) IF_MD(0,) 0)) {
|
||||
DEBUGF("No FAT32 partition!");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -642,7 +642,7 @@ int main(void)
|
|||
|
||||
|
||||
|
||||
i = fat_mount(IF_MV2(0,) IF_MD2(0,) part[0].start);
|
||||
i = fat_mount(IF_MV(0,) IF_MD(0,) part[0].start);
|
||||
|
||||
debugf("fat_mount() returned %d\n", i);
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ static bool check_disk_present(IF_MD_NONVOID(int volume))
|
|||
return true;
|
||||
#else
|
||||
unsigned char* sector = fat_get_sector_buffer();
|
||||
bool success = storage_read_sectors(IF_MD2(volume,)0,1,sector) == 0;
|
||||
bool success = storage_read_sectors(IF_MD(volume,)0,1,sector) == 0;
|
||||
fat_release_sector_buffer();
|
||||
return success;
|
||||
#endif
|
||||
|
@ -526,7 +526,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
|||
int result = USBSTOR_WRITE_SECTORS_FILTER();
|
||||
|
||||
if (result == 0) {
|
||||
result = storage_write_sectors(IF_MD2(cur_cmd.lun,)
|
||||
result = storage_write_sectors(IF_MD(cur_cmd.lun,)
|
||||
cur_cmd.sector,
|
||||
MIN(WRITE_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
|
||||
cur_cmd.data[cur_cmd.data_select]);
|
||||
|
@ -728,7 +728,7 @@ static void send_and_read_next(void)
|
|||
ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
|
||||
MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE);
|
||||
#else
|
||||
result = storage_read_sectors(IF_MD2(cur_cmd.lun,)
|
||||
result = storage_read_sectors(IF_MD(cur_cmd.lun,)
|
||||
cur_cmd.sector,
|
||||
MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
|
||||
cur_cmd.data[cur_cmd.data_select]);
|
||||
|
@ -1087,7 +1087,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
|||
ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
|
||||
MIN(READ_BUFFER_SIZE/SECTOR_SIZE,cur_cmd.count)*SECTOR_SIZE);
|
||||
#else
|
||||
cur_cmd.last_result = storage_read_sectors(IF_MD2(cur_cmd.lun,)
|
||||
cur_cmd.last_result = storage_read_sectors(IF_MD(cur_cmd.lun,)
|
||||
cur_cmd.sector,
|
||||
MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
|
||||
cur_cmd.data[cur_cmd.data_select]);
|
||||
|
|
|
@ -170,7 +170,7 @@ static int mkrk27_init(const char *filename) {
|
|||
|| pinfo[i].type == PARTITION_TYPE_FAT16
|
||||
#endif
|
||||
) {
|
||||
rc = fat_mount(IF_MV2(0,) IF_MD2(0,) pinfo[i].start);
|
||||
rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
|
||||
if(rc) {
|
||||
mkrk27_set_error("mount: %d",rc);
|
||||
return -1;
|
||||
|
@ -179,7 +179,7 @@ static int mkrk27_init(const char *filename) {
|
|||
}
|
||||
}
|
||||
if ( i==4 ) {
|
||||
if(fat_mount(IF_MV2(0,) IF_MD2(0,) 0)) {
|
||||
if(fat_mount(IF_MV(0,) IF_MD(0,) 0)) {
|
||||
mkrk27_set_error("FAT32 partition!");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "thread.h"
|
||||
#include "kernel.h"
|
||||
#include "debug.h"
|
||||
#include "ata.h" /* for IF_MV2 et al. */
|
||||
#include "ata.h" /* for IF_MV et al. */
|
||||
#include "rbpaths.h"
|
||||
#include "load_code.h"
|
||||
|
||||
|
@ -534,7 +534,7 @@ long filesize(int fd)
|
|||
#endif
|
||||
}
|
||||
|
||||
void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
|
||||
void fat_size(IF_MV(int volume,) unsigned long* size, unsigned long* free)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
if (volume != 0) {
|
||||
|
|
|
@ -169,7 +169,7 @@ int storage_init(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int storage_write_sectors(IF_MV2(int drive,)
|
||||
int storage_write_sectors(IF_MV(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -197,7 +197,7 @@ int storage_write_sectors(IF_MV2(int drive,)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int storage_read_sectors(IF_MV2(int drive,)
|
||||
int storage_read_sectors(IF_MV(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
void* buf)
|
||||
|
|
Loading…
Reference in a new issue