summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-08-17 12:18:22 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-08-17 12:18:22 -0400
commita56f1ca1ed63b93eb61fd5319f47347b3eb1e364 (patch)
tree62a253ba44b23c1867cef59fee40b40092719ee1 /firmware
parentc13f21a4d5c27c638c9f0dedf6d7b1f9bbb4d682 (diff)
downloadrockbox-a56f1ca1ed63b93eb61fd5319f47347b3eb1e364.tar.gz
rockbox-a56f1ca1ed63b93eb61fd5319f47347b3eb1e364.zip
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dir_uncached.c4
-rw-r--r--firmware/common/dircache.c10
-rw-r--r--firmware/common/disk.c8
-rw-r--r--firmware/common/file.c4
-rw-r--r--firmware/drivers/ata.c10
-rw-r--r--firmware/drivers/ata_flash.c4
-rw-r--r--firmware/drivers/fat.c128
-rw-r--r--firmware/drivers/ramdisk.c6
-rw-r--r--firmware/drivers/sd.c2
-rw-r--r--firmware/export/ata.h6
-rw-r--r--firmware/export/fat.h8
-rw-r--r--firmware/export/mmc.h6
-rw-r--r--firmware/export/mv.h29
-rw-r--r--firmware/export/nand.h6
-rw-r--r--firmware/export/ramdisk.h6
-rw-r--r--firmware/export/sd.h6
-rw-r--r--firmware/export/storage.h14
-rw-r--r--firmware/storage.c28
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c14
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c10
-rw-r--r--firmware/target/arm/ata-nand-telechips.c6
-rw-r--r--firmware/target/arm/imx233/nand-imx233.c6
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c10
-rw-r--r--firmware/target/arm/pp/ata-sd-pp.c4
-rw-r--r--firmware/target/arm/rk27xx/ata-nand-rk27xx.c6
-rw-r--r--firmware/target/arm/rk27xx/sd-rk27xx.c4
-rw-r--r--firmware/target/arm/s3c2440/sd-s3c2440.c4
-rw-r--r--firmware/target/arm/s5l8700/ata-nand-s5l8700.c6
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c6
-rw-r--r--firmware/target/arm/tcc780x/sd-tcc780x.c4
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c16
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-target.h4
-rw-r--r--firmware/target/arm/tms320dm320/sdmmc-dm320.c4
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c6
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c4
-rw-r--r--firmware/target/sh/archos/ondio/ata_mmc.c6
-rw-r--r--firmware/test/fat/main.c4
-rw-r--r--firmware/test/i2c/main.c2
-rw-r--r--firmware/usbstack/usb_storage.c8
39 files changed, 210 insertions, 209 deletions
diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c
index 14c8522822..b850a514e7 100644
--- a/firmware/common/dir_uncached.c
+++ b/firmware/common/dir_uncached.c
@@ -95,7 +95,7 @@ DIR_UNCACHED* opendir_uncached(const char* name)
95 strlcpy(namecopy, name, sizeof(namecopy)); /* just copy */ 95 strlcpy(namecopy, name, sizeof(namecopy)); /* just copy */
96#endif 96#endif
97 97
98 if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) { 98 if ( fat_opendir(IF_MV(volume,) &pdir->fatdir, 0, NULL) < 0 ) {
99 DEBUGF("Failed opening root dir\n"); 99 DEBUGF("Failed opening root dir\n");
100 pdir->busy = false; 100 pdir->busy = false;
101 return NULL; 101 return NULL;
@@ -122,7 +122,7 @@ DIR_UNCACHED* opendir_uncached(const char* name)
122 * as the parent directory and the resulting one (this is safe, 122 * as the parent directory and the resulting one (this is safe,
123 * in doubt, check fat_open(dir) code) which will allow this kind of 123 * in doubt, check fat_open(dir) code) which will allow this kind of
124 * (ugly) things */ 124 * (ugly) things */
125 if ( fat_opendir(IF_MV2(volume,) 125 if ( fat_opendir(IF_MV(volume,)
126 &pdir->fatdir, 126 &pdir->fatdir,
127 entry.firstcluster, 127 entry.firstcluster,
128 &pdir->fatdir) < 0 ) { 128 &pdir->fatdir) < 0 ) {
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 21ae71fd5d..b53fc4d7a6 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -303,7 +303,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
303 sab.dir->entrycount = 0; 303 sab.dir->entrycount = 0;
304 sab.dir->file.firstcluster = 0; 304 sab.dir->file.firstcluster = 0;
305 /* open directory */ 305 /* open directory */
306 int rc = fat_opendir(IF_MV2(sab.volume,) sab.dir, startcluster, sab.dir); 306 int rc = fat_opendir(IF_MV(sab.volume,) sab.dir, startcluster, sab.dir);
307 if(rc < 0) 307 if(rc < 0)
308 { 308 {
309 logf("fat_opendir failed: %d", rc); 309 logf("fat_opendir failed: %d", rc);
@@ -381,7 +381,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
381/* used during the generation */ 381/* used during the generation */
382static struct fat_dir sab_fat_dir; 382static struct fat_dir sab_fat_dir;
383 383
384static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce) 384static int dircache_scan_and_build(IF_MV(int volume,) struct dircache_entry *ce)
385{ 385{
386 memset(ce, 0, sizeof(struct dircache_entry)); 386 memset(ce, 0, sizeof(struct dircache_entry));
387 387
@@ -493,7 +493,7 @@ static int sab_process_dir(struct dircache_entry *ce)
493 return 0; 493 return 0;
494} 494}
495 495
496static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce) 496static int dircache_scan_and_build(IF_MV(int volume,) struct dircache_entry *ce)
497{ 497{
498 #ifdef HAVE_MULTIVOLUME 498 #ifdef HAVE_MULTIVOLUME
499 (void) volume; 499 (void) volume;
@@ -786,9 +786,9 @@ static int dircache_do_rebuild(void)
786#endif 786#endif
787 cpu_boost(true); 787 cpu_boost(true);
788#ifdef HAVE_MULTIVOLUME 788#ifdef HAVE_MULTIVOLUME
789 if (dircache_scan_and_build(IF_MV2(i,) append_position) < 0) 789 if (dircache_scan_and_build(IF_MV(i,) append_position) < 0)
790#else 790#else
791 if (dircache_scan_and_build(IF_MV2(0,) root_entry) < 0) 791 if (dircache_scan_and_build(IF_MV(0,) root_entry) < 0)
792#endif /* HAVE_MULTIVOLUME */ 792#endif /* HAVE_MULTIVOLUME */
793 { 793 {
794 logf("dircache_scan_and_build failed"); 794 logf("dircache_scan_and_build failed");
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 1a7ddd9eb4..fb6daee174 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -90,7 +90,7 @@ struct partinfo* disk_init(IF_MD_NONVOID(int drive))
90#endif 90#endif
91 91
92 unsigned char* sector = fat_get_sector_buffer(); 92 unsigned char* sector = fat_get_sector_buffer();
93 storage_read_sectors(IF_MD2(drive,) 0,1, sector); 93 storage_read_sectors(IF_MD(drive,) 0,1, sector);
94 /* check that the boot sector is initialized */ 94 /* check that the boot sector is initialized */
95 if ( (sector[510] != 0x55) || 95 if ( (sector[510] != 0x55) ||
96 (sector[511] != 0xaa)) { 96 (sector[511] != 0xaa)) {
@@ -210,7 +210,7 @@ int disk_mount(int drive)
210 210
211 for (j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) 211 for (j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1)
212 { 212 {
213 if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start * j)) 213 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j))
214 { 214 {
215 pinfo[i].start *= j; 215 pinfo[i].start *= j;
216 pinfo[i].size *= j; 216 pinfo[i].size *= j;
@@ -222,7 +222,7 @@ int disk_mount(int drive)
222 } 222 }
223 } 223 }
224#else 224#else
225 if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start)) 225 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
226 { 226 {
227 mounted++; 227 mounted++;
228 vol_drive[volume] = drive; /* remember the drive for this volume */ 228 vol_drive[volume] = drive; /* remember the drive for this volume */
@@ -234,7 +234,7 @@ int disk_mount(int drive)
234 if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */ 234 if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */
235 { /* try "superfloppy" mode */ 235 { /* try "superfloppy" mode */
236 DEBUGF("No partition found, trying to mount sector 0.\n"); 236 DEBUGF("No partition found, trying to mount sector 0.\n");
237 if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0)) 237 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0))
238 { 238 {
239#ifdef MAX_LOG_SECTOR_SIZE 239#ifdef MAX_LOG_SECTOR_SIZE
240 disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE; 240 disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE;
diff --git a/firmware/common/file.c b/firmware/common/file.c
index cfebd0622f..920eada84e 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -121,7 +121,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
121 } 121 }
122 122
123 long startcluster = _dircache_get_entry_startcluster(ce); 123 long startcluster = _dircache_get_entry_startcluster(ce);
124 fat_open(IF_MV2(volume,) 124 fat_open(IF_MV(volume,)
125 startcluster, 125 startcluster,
126 &(file->fatfile), 126 &(file->fatfile),
127 NULL); 127 NULL);
@@ -167,7 +167,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
167 /* scan dir for name */ 167 /* scan dir for name */
168 while ((entry = readdir_uncached(dir))) { 168 while ((entry = readdir_uncached(dir))) {
169 if ( !strcasecmp(name, entry->d_name) ) { 169 if ( !strcasecmp(name, entry->d_name) ) {
170 fat_open(IF_MV2(dir->fatdir.file.volume,) 170 fat_open(IF_MV(dir->fatdir.file.volume,)
171 entry->startcluster, 171 entry->startcluster,
172 &(file->fatfile), 172 &(file->fatfile),
173 &(dir->fatdir)); 173 &(dir->fatdir));
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index ec04ac1426..4b365a50ab 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -567,7 +567,7 @@ static int ata_transfer_sectors(unsigned long start,
567} 567}
568 568
569#ifndef MAX_PHYS_SECTOR_SIZE 569#ifndef MAX_PHYS_SECTOR_SIZE
570int ata_read_sectors(IF_MD2(int drive,) 570int ata_read_sectors(IF_MD(int drive,)
571 unsigned long start, 571 unsigned long start,
572 int incount, 572 int incount,
573 void* inbuf) 573 void* inbuf)
@@ -581,7 +581,7 @@ int ata_read_sectors(IF_MD2(int drive,)
581#endif 581#endif
582 582
583#ifndef MAX_PHYS_SECTOR_SIZE 583#ifndef MAX_PHYS_SECTOR_SIZE
584int ata_write_sectors(IF_MD2(int drive,) 584int ata_write_sectors(IF_MD(int drive,)
585 unsigned long start, 585 unsigned long start,
586 int count, 586 int count,
587 const void* buf) 587 const void* buf)
@@ -623,7 +623,7 @@ static inline int flush_current_sector(void)
623 sector_cache.data, true); 623 sector_cache.data, true);
624} 624}
625 625
626int ata_read_sectors(IF_MD2(int drive,) 626int ata_read_sectors(IF_MD(int drive,)
627 unsigned long start, 627 unsigned long start,
628 int incount, 628 int incount,
629 void* inbuf) 629 void* inbuf)
@@ -689,7 +689,7 @@ int ata_read_sectors(IF_MD2(int drive,)
689 return rc; 689 return rc;
690} 690}
691 691
692int ata_write_sectors(IF_MD2(int drive,) 692int ata_write_sectors(IF_MD(int drive,)
693 unsigned long start, 693 unsigned long start,
694 int count, 694 int count,
695 const void* buf) 695 const void* buf)
@@ -1480,7 +1480,7 @@ int ata_spinup_time(void)
1480} 1480}
1481 1481
1482#ifdef STORAGE_GET_INFO 1482#ifdef STORAGE_GET_INFO
1483void ata_get_info(IF_MD2(int drive,)struct storage_info *info) 1483void ata_get_info(IF_MD(int drive,)struct storage_info *info)
1484{ 1484{
1485 unsigned short *src,*dest; 1485 unsigned short *src,*dest;
1486 static char vendor[8]; 1486 static char vendor[8];
diff --git a/firmware/drivers/ata_flash.c b/firmware/drivers/ata_flash.c
index 2d31b413ac..de2988b9be 100644
--- a/firmware/drivers/ata_flash.c
+++ b/firmware/drivers/ata_flash.c
@@ -384,7 +384,7 @@ int flash_disk_read_sectors(unsigned long start,
384 return done; 384 return done;
385} 385}
386 386
387int nand_read_sectors(IF_MD2(int drive,) 387int nand_read_sectors(IF_MD(int drive,)
388 unsigned long start, 388 unsigned long start,
389 int incount, 389 int incount,
390 void* inbuf) 390 void* inbuf)
@@ -401,7 +401,7 @@ int nand_read_sectors(IF_MD2(int drive,)
401 return 0; 401 return 0;
402} 402}
403 403
404int nand_write_sectors(IF_MD2(int drive,) 404int nand_write_sectors(IF_MD(int drive,)
405 unsigned long start, 405 unsigned long start,
406 int count, 406 int count,
407 const void* buf) 407 const void* buf)
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index e22f9507b0..0b8451a5c6 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -189,13 +189,13 @@ static bool initialized = false;
189static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)); 189static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb));
190static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb)); 190static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb));
191static int bpb_is_sane(IF_MV_NONVOID(struct bpb* fat_bpb)); 191static int bpb_is_sane(IF_MV_NONVOID(struct bpb* fat_bpb));
192static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,) 192static void *cache_fat_sector(IF_MV(struct bpb* fat_bpb,)
193 long secnum, bool dirty); 193 long secnum, bool dirty);
194static void create_dos_name(const unsigned char *name, unsigned char *newname); 194static void create_dos_name(const unsigned char *name, unsigned char *newname);
195static void randomize_dos_name(unsigned char *name); 195static void randomize_dos_name(unsigned char *name);
196static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,) 196static unsigned long find_free_cluster(IF_MV(struct bpb* fat_bpb,)
197 unsigned long start); 197 unsigned long start);
198static int transfer(IF_MV2(struct bpb* fat_bpb,) unsigned long start, 198static int transfer(IF_MV(struct bpb* fat_bpb,) unsigned long start,
199 long count, char* buf, bool write ); 199 long count, char* buf, bool write );
200 200
201#define FAT_CACHE_SIZE 0x20 201#define FAT_CACHE_SIZE 0x20
@@ -230,7 +230,7 @@ void fat_unlock(void)
230} 230}
231#endif 231#endif
232 232
233static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster) 233static long cluster2sec(IF_MV(struct bpb* fat_bpb,) long cluster)
234{ 234{
235#ifndef HAVE_MULTIVOLUME 235#ifndef HAVE_MULTIVOLUME
236 struct bpb* fat_bpb = &fat_bpbs[0]; 236 struct bpb* fat_bpb = &fat_bpbs[0];
@@ -252,7 +252,7 @@ static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster)
252 + fat_bpb->firstdatasector; 252 + fat_bpb->firstdatasector;
253} 253}
254 254
255void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free) 255void fat_size(IF_MV(int volume,) unsigned long* size, unsigned long* free)
256{ 256{
257#ifndef HAVE_MULTIVOLUME 257#ifndef HAVE_MULTIVOLUME
258 const int volume = 0; 258 const int volume = 0;
@@ -303,7 +303,7 @@ void fat_init(void)
303 303
304/* fat_mount_internal is split out of fat_mount() to avoid having both the sector 304/* fat_mount_internal is split out of fat_mount() to avoid having both the sector
305 * buffer used here and the sector buffer used by update_fsinfo() on stack */ 305 * buffer used here and the sector buffer used by update_fsinfo() on stack */
306static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long startsector) 306static int fat_mount_internal(IF_MV(int volume,) IF_MD(int drive,) long startsector)
307{ 307{
308#ifndef HAVE_MULTIVOLUME 308#ifndef HAVE_MULTIVOLUME
309 const int volume = 0; 309 const int volume = 0;
@@ -318,7 +318,7 @@ static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long starts
318 318
319 unsigned char* buf = fat_get_sector_buffer(); 319 unsigned char* buf = fat_get_sector_buffer();
320 /* Read the sector */ 320 /* Read the sector */
321 rc = storage_read_sectors(IF_MD2(drive,) startsector,1,buf); 321 rc = storage_read_sectors(IF_MD(drive,) startsector,1,buf);
322 if(rc) 322 if(rc)
323 { 323 {
324 fat_release_sector_buffer(); 324 fat_release_sector_buffer();
@@ -428,7 +428,7 @@ static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long starts
428 { /* FAT32 specific part of BPB */ 428 { /* FAT32 specific part of BPB */
429 fat_bpb->bpb_rootclus = BYTES2INT32(buf,BPB_ROOTCLUS); 429 fat_bpb->bpb_rootclus = BYTES2INT32(buf,BPB_ROOTCLUS);
430 fat_bpb->bpb_fsinfo = secmult * BYTES2INT16(buf,BPB_FSINFO); 430 fat_bpb->bpb_fsinfo = secmult * BYTES2INT16(buf,BPB_FSINFO);
431 fat_bpb->rootdirsector = cluster2sec(IF_MV2(fat_bpb,) 431 fat_bpb->rootdirsector = cluster2sec(IF_MV(fat_bpb,)
432 fat_bpb->bpb_rootclus); 432 fat_bpb->bpb_rootclus);
433 } 433 }
434 434
@@ -450,7 +450,7 @@ static int fat_mount_internal(IF_MV2(int volume,) IF_MD2(int drive,) long starts
450#endif /* #ifdef HAVE_FAT16SUPPORT */ 450#endif /* #ifdef HAVE_FAT16SUPPORT */
451 { 451 {
452 /* Read the fsinfo sector */ 452 /* Read the fsinfo sector */
453 rc = storage_read_sectors(IF_MD2(drive,) 453 rc = storage_read_sectors(IF_MD(drive,)
454 startsector + fat_bpb->bpb_fsinfo, 1, buf); 454 startsector + fat_bpb->bpb_fsinfo, 1, buf);
455 if (rc < 0) 455 if (rc < 0)
456 { 456 {
@@ -493,7 +493,7 @@ int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume))
493} 493}
494#endif 494#endif
495 495
496int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector) 496int fat_mount(IF_MV(int volume,) IF_MD(int drive,) long startsector)
497{ 497{
498#ifndef HAVE_MULTIVOLUME 498#ifndef HAVE_MULTIVOLUME
499 const int volume = 0; 499 const int volume = 0;
@@ -501,7 +501,7 @@ int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector)
501 struct bpb* fat_bpb = &fat_bpbs[volume]; 501 struct bpb* fat_bpb = &fat_bpbs[volume];
502 int rc; 502 int rc;
503 503
504 rc = fat_mount_internal(IF_MV2(volume,) IF_MD2(drive,) startsector); 504 rc = fat_mount_internal(IF_MV(volume,) IF_MD(drive,) startsector);
505 505
506 if(rc!=0) return rc; 506 if(rc!=0) return rc;
507 507
@@ -576,7 +576,7 @@ void fat_recalc_free(IF_MV_NONVOID(int volume))
576 { 576 {
577 for (i = 0; i<fat_bpb->fatsize; i++) { 577 for (i = 0; i<fat_bpb->fatsize; i++) {
578 unsigned int j; 578 unsigned int j;
579 uint16_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) i, false); 579 uint16_t* fat = cache_fat_sector(IF_MV(fat_bpb,) i, false);
580 for (j = 0; j < CLUSTERS_PER_FAT16_SECTOR; j++) { 580 for (j = 0; j < CLUSTERS_PER_FAT16_SECTOR; j++) {
581 unsigned int c = i * CLUSTERS_PER_FAT16_SECTOR + j; 581 unsigned int c = i * CLUSTERS_PER_FAT16_SECTOR + j;
582 if ( c > fat_bpb->dataclusters+1 ) /* nr 0 is unused */ 582 if ( c > fat_bpb->dataclusters+1 ) /* nr 0 is unused */
@@ -595,7 +595,7 @@ void fat_recalc_free(IF_MV_NONVOID(int volume))
595 { 595 {
596 for (i = 0; i<fat_bpb->fatsize; i++) { 596 for (i = 0; i<fat_bpb->fatsize; i++) {
597 unsigned int j; 597 unsigned int j;
598 uint32_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) i, false); 598 uint32_t* fat = cache_fat_sector(IF_MV(fat_bpb,) i, false);
599 for (j = 0; j < CLUSTERS_PER_FAT_SECTOR; j++) { 599 for (j = 0; j < CLUSTERS_PER_FAT_SECTOR; j++) {
600 unsigned long c = i * CLUSTERS_PER_FAT_SECTOR + j; 600 unsigned long c = i * CLUSTERS_PER_FAT_SECTOR + j;
601 if ( c > fat_bpb->dataclusters+1 ) /* nr 0 is unused */ 601 if ( c > fat_bpb->dataclusters+1 ) /* nr 0 is unused */
@@ -677,7 +677,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce,
677#endif 677#endif
678 678
679 /* Write to the first FAT */ 679 /* Write to the first FAT */
680 rc = storage_write_sectors(IF_MD2(fce->fat_vol->drive,) 680 rc = storage_write_sectors(IF_MD(fce->fat_vol->drive,)
681 secnum, 1, 681 secnum, 1,
682 sectorbuf); 682 sectorbuf);
683 if(rc < 0) 683 if(rc < 0)
@@ -698,7 +698,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce,
698#else 698#else
699 secnum += fat_bpbs[0].fatsize; 699 secnum += fat_bpbs[0].fatsize;
700#endif 700#endif
701 rc = storage_write_sectors(IF_MD2(fce->fat_vol->drive,) 701 rc = storage_write_sectors(IF_MD(fce->fat_vol->drive,)
702 secnum, 1, sectorbuf); 702 secnum, 1, sectorbuf);
703 if(rc < 0) 703 if(rc < 0)
704 { 704 {
@@ -712,7 +712,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce,
712 712
713/* Note: The returned pointer is only safely valid until the next 713/* Note: The returned pointer is only safely valid until the next
714 task switch! (Any subsequent ata read/write may yield.) */ 714 task switch! (Any subsequent ata read/write may yield.) */
715static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,) 715static void *cache_fat_sector(IF_MV(struct bpb* fat_bpb,)
716 long fatsector, bool dirty) 716 long fatsector, bool dirty)
717{ 717{
718#ifndef HAVE_MULTIVOLUME 718#ifndef HAVE_MULTIVOLUME
@@ -744,7 +744,7 @@ static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,)
744 /* Load the sector if it is not cached */ 744 /* Load the sector if it is not cached */
745 if(!fce->inuse) 745 if(!fce->inuse)
746 { 746 {
747 rc = storage_read_sectors(IF_MD2(fat_bpb->drive,) 747 rc = storage_read_sectors(IF_MD(fat_bpb->drive,)
748 secnum + fat_bpb->startsector,1, 748 secnum + fat_bpb->startsector,1,
749 sectorbuf); 749 sectorbuf);
750 if(rc < 0) 750 if(rc < 0)
@@ -766,7 +766,7 @@ static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,)
766 return sectorbuf; 766 return sectorbuf;
767} 767}
768 768
769static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,) 769static unsigned long find_free_cluster(IF_MV(struct bpb* fat_bpb,)
770 unsigned long startcluster) 770 unsigned long startcluster)
771{ 771{
772#ifndef HAVE_MULTIVOLUME 772#ifndef HAVE_MULTIVOLUME
@@ -785,7 +785,7 @@ static unsigned long find_free_cluster(IF_MV2(struct bpb* fat_bpb,)
785 for (i = 0; i<fat_bpb->fatsize; i++) { 785 for (i = 0; i<fat_bpb->fatsize; i++) {
786 unsigned int j; 786 unsigned int j;
787 unsigned int nr = (i + sector) % fat_bpb->fatsize; 787 unsigned int nr = (i + sector) % fat_bpb->fatsize;
788 uint16_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) nr, false); 788 uint16_t* fat = cache_fat_sector(IF_MV(fat_bpb,) nr, false);
789 if ( !fat ) 789 if ( !fat )
790 break; 790 break;
791 for (j = 0; j < CLUSTERS_PER_FAT16_SECTOR; j++) { 791 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,)
813 for (i = 0; i<fat_bpb->fatsize; i++) { 813 for (i = 0; i<fat_bpb->fatsize; i++) {
814 unsigned int j; 814 unsigned int j;
815 unsigned long nr = (i + sector) % fat_bpb->fatsize; 815 unsigned long nr = (i + sector) % fat_bpb->fatsize;
816 uint32_t* fat = cache_fat_sector(IF_MV2(fat_bpb,) nr, false); 816 uint32_t* fat = cache_fat_sector(IF_MV(fat_bpb,) nr, false);
817 if ( !fat ) 817 if ( !fat )
818 break; 818 break;
819 for (j = 0; j < CLUSTERS_PER_FAT_SECTOR; j++) { 819 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,)
837 return 0; /* 0 is an illegal cluster number */ 837 return 0; /* 0 is an illegal cluster number */
838} 838}
839 839
840static int update_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry, 840static int update_fat_entry(IF_MV(struct bpb* fat_bpb,) unsigned long entry,
841 unsigned long val) 841 unsigned long val)
842{ 842{
843#ifndef HAVE_MULTIVOLUME 843#ifndef HAVE_MULTIVOLUME
@@ -860,7 +860,7 @@ static int update_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry,
860 if ( entry < 2 ) 860 if ( entry < 2 )
861 panicf("Updating reserved FAT entry %ld.\n",entry); 861 panicf("Updating reserved FAT entry %ld.\n",entry);
862 862
863 sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, true); 863 sec = cache_fat_sector(IF_MV(fat_bpb,) sector, true);
864 if (!sec) 864 if (!sec)
865 { 865 {
866 DEBUGF( "update_fat_entry() - Could not cache sector %d\n", sector); 866 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,
896 if ( entry < 2 ) 896 if ( entry < 2 )
897 panicf("Updating reserved FAT entry %ld.\n",entry); 897 panicf("Updating reserved FAT entry %ld.\n",entry);
898 898
899 sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, true); 899 sec = cache_fat_sector(IF_MV(fat_bpb,) sector, true);
900 if (!sec) 900 if (!sec)
901 { 901 {
902 DEBUGF("update_fat_entry() - Could not cache sector %ld\n", sector); 902 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,
924 return 0; 924 return 0;
925} 925}
926 926
927static long read_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry) 927static long read_fat_entry(IF_MV(struct bpb* fat_bpb,) unsigned long entry)
928{ 928{
929#ifdef HAVE_FAT16SUPPORT 929#ifdef HAVE_FAT16SUPPORT
930#ifndef HAVE_MULTIVOLUME 930#ifndef HAVE_MULTIVOLUME
@@ -936,7 +936,7 @@ static long read_fat_entry(IF_MV2(struct bpb* fat_bpb,) unsigned long entry)
936 int offset = entry % CLUSTERS_PER_FAT16_SECTOR; 936 int offset = entry % CLUSTERS_PER_FAT16_SECTOR;
937 unsigned short* sec; 937 unsigned short* sec;
938 938
939 sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, false); 939 sec = cache_fat_sector(IF_MV(fat_bpb,) sector, false);
940 if (!sec) 940 if (!sec)
941 { 941 {
942 DEBUGF( "read_fat_entry() - Could not cache sector %d\n", sector); 942 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)
952 int offset = entry % CLUSTERS_PER_FAT_SECTOR; 952 int offset = entry % CLUSTERS_PER_FAT_SECTOR;
953 uint32_t* sec; 953 uint32_t* sec;
954 954
955 sec = cache_fat_sector(IF_MV2(fat_bpb,) sector, false); 955 sec = cache_fat_sector(IF_MV(fat_bpb,) sector, false);
956 if (!sec) 956 if (!sec)
957 { 957 {
958 DEBUGF( "read_fat_entry() - Could not cache sector %ld\n", sector); 958 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)
963 } 963 }
964} 964}
965 965
966static long get_next_cluster(IF_MV2(struct bpb* fat_bpb,) long cluster) 966static long get_next_cluster(IF_MV(struct bpb* fat_bpb,) long cluster)
967{ 967{
968 long next_cluster; 968 long next_cluster;
969 long eof_mark = FAT_EOF_MARK; 969 long eof_mark = FAT_EOF_MARK;
@@ -979,7 +979,7 @@ static long get_next_cluster(IF_MV2(struct bpb* fat_bpb,) long cluster)
979 return cluster + 1; /* don't use the FAT */ 979 return cluster + 1; /* don't use the FAT */
980 } 980 }
981#endif 981#endif
982 next_cluster = read_fat_entry(IF_MV2(fat_bpb,) cluster); 982 next_cluster = read_fat_entry(IF_MV(fat_bpb,) cluster);
983 983
984 /* is this last cluster in chain? */ 984 /* is this last cluster in chain? */
985 if ( next_cluster >= eof_mark ) 985 if ( next_cluster >= eof_mark )
@@ -1003,7 +1003,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb))
1003 1003
1004 unsigned char* fsinfo = fat_get_sector_buffer(); 1004 unsigned char* fsinfo = fat_get_sector_buffer();
1005 /* update fsinfo */ 1005 /* update fsinfo */
1006 rc = storage_read_sectors(IF_MD2(fat_bpb->drive,) 1006 rc = storage_read_sectors(IF_MD(fat_bpb->drive,)
1007 fat_bpb->startsector + fat_bpb->bpb_fsinfo, 1,fsinfo); 1007 fat_bpb->startsector + fat_bpb->bpb_fsinfo, 1,fsinfo);
1008 if (rc < 0) 1008 if (rc < 0)
1009 { 1009 {
@@ -1017,7 +1017,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb))
1017 intptr = (uint32_t*)&(fsinfo[FSINFO_NEXTFREE]); 1017 intptr = (uint32_t*)&(fsinfo[FSINFO_NEXTFREE]);
1018 *intptr = htole32(fat_bpb->fsinfo.nextfree); 1018 *intptr = htole32(fat_bpb->fsinfo.nextfree);
1019 1019
1020 rc = storage_write_sectors(IF_MD2(fat_bpb->drive,) 1020 rc = storage_write_sectors(IF_MD(fat_bpb->drive,)
1021 fat_bpb->startsector + fat_bpb->bpb_fsinfo,1,fsinfo); 1021 fat_bpb->startsector + fat_bpb->bpb_fsinfo,1,fsinfo);
1022 fat_release_sector_buffer(); 1022 fat_release_sector_buffer();
1023 if (rc < 0) 1023 if (rc < 0)
@@ -1634,7 +1634,7 @@ static int update_short_entry( struct fat_file* file, long size, int attr )
1634 file->firstcluster, file->direntry, size); 1634 file->firstcluster, file->direntry, size);
1635 1635
1636 /* create a temporary file handle for the dir holding this file */ 1636 /* create a temporary file handle for the dir holding this file */
1637 rc = fat_open(IF_MV2(file->volume,) file->dircluster, &dir, NULL); 1637 rc = fat_open(IF_MV(file->volume,) file->dircluster, &dir, NULL);
1638 if (rc < 0) 1638 if (rc < 0)
1639 return rc * 10 - 1; 1639 return rc * 10 - 1;
1640 1640
@@ -1739,7 +1739,7 @@ static int parse_direntry(struct fat_direntry *de, const unsigned char *buf)
1739 return 1; 1739 return 1;
1740} 1740}
1741 1741
1742int fat_open(IF_MV2(int volume,) 1742int fat_open(IF_MV(int volume,)
1743 long startcluster, 1743 long startcluster,
1744 struct fat_file *file, 1744 struct fat_file *file,
1745 const struct fat_dir* dir) 1745 const struct fat_dir* dir)
@@ -1803,7 +1803,7 @@ static __attribute__((noinline)) int fat_clear_cluster(int sector,
1803 int i,rc; 1803 int i,rc;
1804 memset(buf, 0, SECTOR_SIZE); 1804 memset(buf, 0, SECTOR_SIZE);
1805 for(i = 0;i < (int)fat_bpb->bpb_secperclus;i++) { 1805 for(i = 0;i < (int)fat_bpb->bpb_secperclus;i++) {
1806 rc = transfer(IF_MV2(fat_bpb,) sector + i, 1, buf, true ); 1806 rc = transfer(IF_MV(fat_bpb,) sector + i, 1, buf, true );
1807 if (rc < 0) 1807 if (rc < 0)
1808 { 1808 {
1809 fat_release_sector_buffer(); 1809 fat_release_sector_buffer();
@@ -1838,15 +1838,15 @@ int fat_create_dir(const char* name,
1838 return rc * 10 - 1; 1838 return rc * 10 - 1;
1839 1839
1840 /* Allocate a new cluster for the directory */ 1840 /* Allocate a new cluster for the directory */
1841 newdir->file.firstcluster = find_free_cluster(IF_MV2(fat_bpb,) 1841 newdir->file.firstcluster = find_free_cluster(IF_MV(fat_bpb,)
1842 fat_bpb->fsinfo.nextfree); 1842 fat_bpb->fsinfo.nextfree);
1843 if(newdir->file.firstcluster == 0) 1843 if(newdir->file.firstcluster == 0)
1844 return -1; 1844 return -1;
1845 1845
1846 update_fat_entry(IF_MV2(fat_bpb,) newdir->file.firstcluster, FAT_EOF_MARK); 1846 update_fat_entry(IF_MV(fat_bpb,) newdir->file.firstcluster, FAT_EOF_MARK);
1847 1847
1848 /* Clear the entire cluster */ 1848 /* Clear the entire cluster */
1849 sector = cluster2sec(IF_MV2(fat_bpb,) newdir->file.firstcluster); 1849 sector = cluster2sec(IF_MV(fat_bpb,) newdir->file.firstcluster);
1850 rc = fat_clear_cluster(sector,fat_bpb); 1850 rc = fat_clear_cluster(sector,fat_bpb);
1851 if (rc < 0) 1851 if (rc < 0)
1852 return rc; 1852 return rc;
@@ -1892,12 +1892,12 @@ int fat_truncate(const struct fat_file *file)
1892 1892
1893 LDEBUGF("fat_truncate(%lx, %lx)\n", file->firstcluster, last); 1893 LDEBUGF("fat_truncate(%lx, %lx)\n", file->firstcluster, last);
1894 1894
1895 for ( last = get_next_cluster(IF_MV2(fat_bpb,) last); last; last = next ) { 1895 for ( last = get_next_cluster(IF_MV(fat_bpb,) last); last; last = next ) {
1896 next = get_next_cluster(IF_MV2(fat_bpb,) last); 1896 next = get_next_cluster(IF_MV(fat_bpb,) last);
1897 update_fat_entry(IF_MV2(fat_bpb,) last,0); 1897 update_fat_entry(IF_MV(fat_bpb,) last,0);
1898 } 1898 }
1899 if (file->lastcluster) 1899 if (file->lastcluster)
1900 update_fat_entry(IF_MV2(fat_bpb,) file->lastcluster,FAT_EOF_MARK); 1900 update_fat_entry(IF_MV(fat_bpb,) file->lastcluster,FAT_EOF_MARK);
1901 1901
1902 return 0; 1902 return 0;
1903} 1903}
@@ -1913,7 +1913,7 @@ int fat_closewrite(struct fat_file *file, long size, int attr)
1913 if (!size) { 1913 if (!size) {
1914 /* empty file */ 1914 /* empty file */
1915 if ( file->firstcluster ) { 1915 if ( file->firstcluster ) {
1916 update_fat_entry(IF_MV2(fat_bpb,) file->firstcluster, 0); 1916 update_fat_entry(IF_MV(fat_bpb,) file->firstcluster, 0);
1917 file->firstcluster = 0; 1917 file->firstcluster = 0;
1918 } 1918 }
1919 } 1919 }
@@ -1938,7 +1938,7 @@ int fat_closewrite(struct fat_file *file, long size, int attr)
1938 long len; 1938 long len;
1939 long next; 1939 long next;
1940 for ( next = file->firstcluster; next; 1940 for ( next = file->firstcluster; next;
1941 next = get_next_cluster(IF_MV2(fat_bpb,) next) ) { 1941 next = get_next_cluster(IF_MV(fat_bpb,) next) ) {
1942 LDEBUGF("cluster %ld: %lx\n", count, next); 1942 LDEBUGF("cluster %ld: %lx\n", count, next);
1943 count++; 1943 count++;
1944 } 1944 }
@@ -1965,7 +1965,7 @@ static int free_direntries(struct fat_file* file)
1965 int rc; 1965 int rc;
1966 1966
1967 /* create a temporary file handle for the dir holding this file */ 1967 /* create a temporary file handle for the dir holding this file */
1968 rc = fat_open(IF_MV2(file->volume,) file->dircluster, &dir, NULL); 1968 rc = fat_open(IF_MV(file->volume,) file->dircluster, &dir, NULL);
1969 if (rc < 0) 1969 if (rc < 0)
1970 return rc * 10 - 1; 1970 return rc * 10 - 1;
1971 1971
@@ -2048,8 +2048,8 @@ int fat_remove(struct fat_file* file)
2048 LDEBUGF("fat_remove(%lx)\n",last); 2048 LDEBUGF("fat_remove(%lx)\n",last);
2049 2049
2050 while ( last ) { 2050 while ( last ) {
2051 next = get_next_cluster(IF_MV2(fat_bpb,) last); 2051 next = get_next_cluster(IF_MV(fat_bpb,) last);
2052 update_fat_entry(IF_MV2(fat_bpb,) last,0); 2052 update_fat_entry(IF_MV(fat_bpb,) last,0);
2053 last = next; 2053 last = next;
2054 } 2054 }
2055 2055
@@ -2120,7 +2120,7 @@ int fat_rename(struct fat_file* file,
2120 it points to its parent directory (we don't check if it was a move) */ 2120 it points to its parent directory (we don't check if it was a move) */
2121 if(FAT_ATTR_DIRECTORY == attr) { 2121 if(FAT_ATTR_DIRECTORY == attr) {
2122 /* open the dir that was renamed, we re-use the olddir_file struct */ 2122 /* open the dir that was renamed, we re-use the olddir_file struct */
2123 rc = fat_open(IF_MV2(file->volume,) newfile.firstcluster, &olddir_file, NULL); 2123 rc = fat_open(IF_MV(file->volume,) newfile.firstcluster, &olddir_file, NULL);
2124 if (rc < 0) 2124 if (rc < 0)
2125 return rc * 10 - 6; 2125 return rc * 10 - 6;
2126 2126
@@ -2189,13 +2189,13 @@ static long next_write_cluster(struct fat_file* file,
2189 LDEBUGF("next_write_cluster(%lx,%lx)\n",file->firstcluster, oldcluster); 2189 LDEBUGF("next_write_cluster(%lx,%lx)\n",file->firstcluster, oldcluster);
2190 2190
2191 if (oldcluster) 2191 if (oldcluster)
2192 cluster = get_next_cluster(IF_MV2(fat_bpb,) oldcluster); 2192 cluster = get_next_cluster(IF_MV(fat_bpb,) oldcluster);
2193 2193
2194 if (!cluster) { 2194 if (!cluster) {
2195 if (oldcluster > 0) 2195 if (oldcluster > 0)
2196 cluster = find_free_cluster(IF_MV2(fat_bpb,) oldcluster+1); 2196 cluster = find_free_cluster(IF_MV(fat_bpb,) oldcluster+1);
2197 else if (oldcluster == 0) 2197 else if (oldcluster == 0)
2198 cluster = find_free_cluster(IF_MV2(fat_bpb,) 2198 cluster = find_free_cluster(IF_MV(fat_bpb,)
2199 fat_bpb->fsinfo.nextfree); 2199 fat_bpb->fsinfo.nextfree);
2200#ifdef HAVE_FAT16SUPPORT 2200#ifdef HAVE_FAT16SUPPORT
2201 else /* negative, pseudo-cluster of the root dir */ 2201 else /* negative, pseudo-cluster of the root dir */
@@ -2204,10 +2204,10 @@ static long next_write_cluster(struct fat_file* file,
2204 2204
2205 if (cluster) { 2205 if (cluster) {
2206 if (oldcluster) 2206 if (oldcluster)
2207 update_fat_entry(IF_MV2(fat_bpb,) oldcluster, cluster); 2207 update_fat_entry(IF_MV(fat_bpb,) oldcluster, cluster);
2208 else 2208 else
2209 file->firstcluster = cluster; 2209 file->firstcluster = cluster;
2210 update_fat_entry(IF_MV2(fat_bpb,) cluster, FAT_EOF_MARK); 2210 update_fat_entry(IF_MV(fat_bpb,) cluster, FAT_EOF_MARK);
2211 } 2211 }
2212 else { 2212 else {
2213#ifdef TEST_FAT 2213#ifdef TEST_FAT
@@ -2219,7 +2219,7 @@ static long next_write_cluster(struct fat_file* file,
2219 return 0; 2219 return 0;
2220 } 2220 }
2221 } 2221 }
2222 sector = cluster2sec(IF_MV2(fat_bpb,) cluster); 2222 sector = cluster2sec(IF_MV(fat_bpb,) cluster);
2223 if (sector<0) 2223 if (sector<0)
2224 return 0; 2224 return 0;
2225 2225
@@ -2227,7 +2227,7 @@ static long next_write_cluster(struct fat_file* file,
2227 return cluster; 2227 return cluster;
2228} 2228}
2229 2229
2230static int transfer(IF_MV2(struct bpb* fat_bpb,) 2230static int transfer(IF_MV(struct bpb* fat_bpb,)
2231 unsigned long start, long count, char* buf, bool write ) 2231 unsigned long start, long count, char* buf, bool write )
2232{ 2232{
2233#ifndef HAVE_MULTIVOLUME 2233#ifndef HAVE_MULTIVOLUME
@@ -2251,11 +2251,11 @@ static int transfer(IF_MV2(struct bpb* fat_bpb,)
2251 if (start + count > fat_bpb->totalsectors) 2251 if (start + count > fat_bpb->totalsectors)
2252 panicf("Write %ld after data\n", 2252 panicf("Write %ld after data\n",
2253 start + count - fat_bpb->totalsectors); 2253 start + count - fat_bpb->totalsectors);
2254 rc = storage_write_sectors(IF_MD2(fat_bpb->drive,) 2254 rc = storage_write_sectors(IF_MD(fat_bpb->drive,)
2255 start + fat_bpb->startsector, count, buf); 2255 start + fat_bpb->startsector, count, buf);
2256 } 2256 }
2257 else 2257 else
2258 rc = storage_read_sectors(IF_MD2(fat_bpb->drive,) 2258 rc = storage_read_sectors(IF_MD(fat_bpb->drive,)
2259 start + fat_bpb->startsector, count, buf); 2259 start + fat_bpb->startsector, count, buf);
2260 if (rc < 0) { 2260 if (rc < 0) {
2261 DEBUGF( "transfer() - Couldn't %s sector %lx" 2261 DEBUGF( "transfer() - Couldn't %s sector %lx"
@@ -2302,8 +2302,8 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
2302 if (write) 2302 if (write)
2303 cluster = next_write_cluster(file, cluster, &sector); 2303 cluster = next_write_cluster(file, cluster, &sector);
2304 else { 2304 else {
2305 cluster = get_next_cluster(IF_MV2(fat_bpb,) cluster); 2305 cluster = get_next_cluster(IF_MV(fat_bpb,) cluster);
2306 sector = cluster2sec(IF_MV2(fat_bpb,) cluster); 2306 sector = cluster2sec(IF_MV(fat_bpb,) cluster);
2307 } 2307 }
2308 2308
2309 clusternum++; 2309 clusternum++;
@@ -2330,7 +2330,7 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
2330 sector++; 2330 sector++;
2331 else { 2331 else {
2332 /* look up first sector of file */ 2332 /* look up first sector of file */
2333 sector = cluster2sec(IF_MV2(fat_bpb,) file->firstcluster); 2333 sector = cluster2sec(IF_MV(fat_bpb,) file->firstcluster);
2334 numsec=1; 2334 numsec=1;
2335#ifdef HAVE_FAT16SUPPORT 2335#ifdef HAVE_FAT16SUPPORT
2336 if (file->firstcluster < 0) 2336 if (file->firstcluster < 0)
@@ -2348,7 +2348,7 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
2348 if ( ((sector != first) && (sector != last+1)) || /* not sequential */ 2348 if ( ((sector != first) && (sector != last+1)) || /* not sequential */
2349 (last-first+1 == 256) ) { /* max 256 sectors per ata request */ 2349 (last-first+1 == 256) ) { /* max 256 sectors per ata request */
2350 long count = last - first + 1; 2350 long count = last - first + 1;
2351 rc = transfer(IF_MV2(fat_bpb,) first, count, buf, write ); 2351 rc = transfer(IF_MV(fat_bpb,) first, count, buf, write );
2352 if (rc < 0) 2352 if (rc < 0)
2353 return rc * 10 - 1; 2353 return rc * 10 - 1;
2354 2354
@@ -2360,7 +2360,7 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
2360 (!eof)) 2360 (!eof))
2361 { 2361 {
2362 long count = sector - first + 1; 2362 long count = sector - first + 1;
2363 rc = transfer(IF_MV2(fat_bpb,) first, count, buf, write ); 2363 rc = transfer(IF_MV(fat_bpb,) first, count, buf, write );
2364 if (rc < 0) 2364 if (rc < 0)
2365 return rc * 10 - 2; 2365 return rc * 10 - 2;
2366 } 2366 }
@@ -2413,7 +2413,7 @@ int fat_seek(struct fat_file *file, unsigned long seeksector )
2413 } 2413 }
2414 2414
2415 for (i=0; i<numclusters; i++) { 2415 for (i=0; i<numclusters; i++) {
2416 cluster = get_next_cluster(IF_MV2(fat_bpb,) cluster); 2416 cluster = get_next_cluster(IF_MV(fat_bpb,) cluster);
2417 if (!cluster) { 2417 if (!cluster) {
2418 DEBUGF("Seeking beyond the end of the file! " 2418 DEBUGF("Seeking beyond the end of the file! "
2419 "(sector %ld, cluster %ld)\n", seeksector, i); 2419 "(sector %ld, cluster %ld)\n", seeksector, i);
@@ -2421,7 +2421,7 @@ int fat_seek(struct fat_file *file, unsigned long seeksector )
2421 } 2421 }
2422 } 2422 }
2423 2423
2424 sector = cluster2sec(IF_MV2(fat_bpb,) cluster) + sectornum; 2424 sector = cluster2sec(IF_MV(fat_bpb,) cluster) + sectornum;
2425 } 2425 }
2426 else { 2426 else {
2427 sectornum = -1; 2427 sectornum = -1;
@@ -2437,7 +2437,7 @@ int fat_seek(struct fat_file *file, unsigned long seeksector )
2437 return 0; 2437 return 0;
2438} 2438}
2439 2439
2440int fat_opendir(IF_MV2(int volume,) 2440int fat_opendir(IF_MV(int volume,)
2441 struct fat_dir *dir, unsigned long startcluster, 2441 struct fat_dir *dir, unsigned long startcluster,
2442 const struct fat_dir *parent_dir) 2442 const struct fat_dir *parent_dir)
2443{ 2443{
@@ -2457,7 +2457,7 @@ int fat_opendir(IF_MV2(int volume,)
2457 if (startcluster == 0) 2457 if (startcluster == 0)
2458 startcluster = fat_bpb->bpb_rootclus; 2458 startcluster = fat_bpb->bpb_rootclus;
2459 2459
2460 rc = fat_open(IF_MV2(volume,) startcluster, &dir->file, parent_dir); 2460 rc = fat_open(IF_MV(volume,) startcluster, &dir->file, parent_dir);
2461 if(rc) 2461 if(rc)
2462 { 2462 {
2463 DEBUGF( "fat_opendir() - Couldn't open dir" 2463 DEBUGF( "fat_opendir() - Couldn't open dir"
diff --git a/firmware/drivers/ramdisk.c b/firmware/drivers/ramdisk.c
index 7324af9f0a..c1f8824c93 100644
--- a/firmware/drivers/ramdisk.c
+++ b/firmware/drivers/ramdisk.c
@@ -31,7 +31,7 @@ unsigned char ramdisk[SECTOR_SIZE * NUM_SECTORS];
31 31
32long last_disk_activity = -1; 32long last_disk_activity = -1;
33 33
34int ramdisk_read_sectors(IF_MD2(int drive,) 34int ramdisk_read_sectors(IF_MD(int drive,)
35 unsigned long start, 35 unsigned long start,
36 int count, 36 int count,
37 void* buf) 37 void* buf)
@@ -47,7 +47,7 @@ int ramdisk_read_sectors(IF_MD2(int drive,)
47 return 0; 47 return 0;
48} 48}
49 49
50int ramdisk_write_sectors(IF_MD2(int drive,) 50int ramdisk_write_sectors(IF_MD(int drive,)
51 unsigned long start, 51 unsigned long start,
52 int count, 52 int count,
53 const void* buf) 53 const void* buf)
@@ -110,7 +110,7 @@ void ramdisk_spindown(int seconds)
110 (void)seconds; 110 (void)seconds;
111} 111}
112#ifdef STORAGE_GET_INFO 112#ifdef STORAGE_GET_INFO
113void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info) 113void ramdisk_get_info(IF_MD(int drive,) struct storage_info *info)
114{ 114{
115#ifdef HAVE_MULTIDRIVE 115#ifdef HAVE_MULTIDRIVE
116 (void)drive; /* unused for now */ 116 (void)drive; /* unused for now */
diff --git a/firmware/drivers/sd.c b/firmware/drivers/sd.c
index 3c4543fbc9..6185d5382d 100644
--- a/firmware/drivers/sd.c
+++ b/firmware/drivers/sd.c
@@ -80,7 +80,7 @@ void sd_spindown(int seconds)
80} 80}
81 81
82#ifdef STORAGE_GET_INFO 82#ifdef STORAGE_GET_INFO
83void sd_get_info(IF_MD2(int drive,) struct storage_info *info) 83void sd_get_info(IF_MD(int drive,) struct storage_info *info)
84{ 84{
85#ifndef HAVE_MULTIDRIVE 85#ifndef HAVE_MULTIDRIVE
86 const int drive=0; 86 const int drive=0;
diff --git a/firmware/export/ata.h b/firmware/export/ata.h
index 41a2fd5c9f..0bcb144e63 100644
--- a/firmware/export/ata.h
+++ b/firmware/export/ata.h
@@ -39,8 +39,8 @@ bool ata_disk_is_active(void);
39int ata_soft_reset(void); 39int ata_soft_reset(void);
40int ata_init(void) STORAGE_INIT_ATTR; 40int ata_init(void) STORAGE_INIT_ATTR;
41void ata_close(void); 41void ata_close(void);
42int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 42int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
43int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 43int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
44void ata_spin(void); 44void ata_spin(void);
45#if (CONFIG_LED == LED_REAL) 45#if (CONFIG_LED == LED_REAL)
46void ata_set_led_enabled(bool enabled); 46void ata_set_led_enabled(bool enabled);
@@ -48,7 +48,7 @@ void ata_set_led_enabled(bool enabled);
48unsigned short* ata_get_identify(void); 48unsigned short* ata_get_identify(void);
49 49
50#ifdef STORAGE_GET_INFO 50#ifdef STORAGE_GET_INFO
51void ata_get_info(IF_MD2(int drive,) struct storage_info *info); 51void ata_get_info(IF_MD(int drive,) struct storage_info *info);
52#endif 52#endif
53#ifdef HAVE_HOTSWAP 53#ifdef HAVE_HOTSWAP
54bool ata_removable(IF_MD_NONVOID(int drive)); 54bool ata_removable(IF_MD_NONVOID(int drive));
diff --git a/firmware/export/fat.h b/firmware/export/fat.h
index 15511076e2..a0d52acc35 100644
--- a/firmware/export/fat.h
+++ b/firmware/export/fat.h
@@ -101,16 +101,16 @@ extern void fat_unlock(void);
101 101
102extern void fat_init(void); 102extern void fat_init(void);
103extern int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume)); 103extern int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume));
104extern int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector); 104extern int fat_mount(IF_MV(int volume,) IF_MD(int drive,) long startsector);
105extern int fat_unmount(int volume, bool flush); 105extern int fat_unmount(int volume, bool flush);
106extern void fat_size(IF_MV2(int volume,) /* public for info */ 106extern void fat_size(IF_MV(int volume,) /* public for info */
107 unsigned long* size, 107 unsigned long* size,
108 unsigned long* free); 108 unsigned long* free);
109extern void fat_recalc_free(IF_MV_NONVOID(int volume)); /* public for debug info screen */ 109extern void fat_recalc_free(IF_MV_NONVOID(int volume)); /* public for debug info screen */
110extern int fat_create_dir(const char* name, 110extern int fat_create_dir(const char* name,
111 struct fat_dir* newdir, 111 struct fat_dir* newdir,
112 struct fat_dir* dir); 112 struct fat_dir* dir);
113extern int fat_open(IF_MV2(int volume,) 113extern int fat_open(IF_MV(int volume,)
114 long cluster, 114 long cluster,
115 struct fat_file* ent, 115 struct fat_file* ent,
116 const struct fat_dir* dir); 116 const struct fat_dir* dir);
@@ -128,7 +128,7 @@ extern int fat_rename(struct fat_file* file,
128 const unsigned char* newname, 128 const unsigned char* newname,
129 long size, int attr); 129 long size, int attr);
130 130
131extern int fat_opendir(IF_MV2(int volume,) 131extern int fat_opendir(IF_MV(int volume,)
132 struct fat_dir *ent, unsigned long startcluster, 132 struct fat_dir *ent, unsigned long startcluster,
133 const struct fat_dir *parent_dir); 133 const struct fat_dir *parent_dir);
134extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry); 134extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);
diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h
index 8d20f81236..0d27e20a64 100644
--- a/firmware/export/mmc.h
+++ b/firmware/export/mmc.h
@@ -36,13 +36,13 @@ bool mmc_disk_is_active(void);
36int mmc_soft_reset(void); 36int mmc_soft_reset(void);
37int mmc_init(void) STORAGE_INIT_ATTR; 37int mmc_init(void) STORAGE_INIT_ATTR;
38void mmc_close(void); 38void mmc_close(void);
39int mmc_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 39int mmc_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
40int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 40int mmc_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
41void mmc_spin(void); 41void mmc_spin(void);
42int mmc_spinup_time(void); 42int mmc_spinup_time(void);
43 43
44#ifdef STORAGE_GET_INFO 44#ifdef STORAGE_GET_INFO
45void mmc_get_info(IF_MD2(int drive,) struct storage_info *info); 45void mmc_get_info(IF_MD(int drive,) struct storage_info *info);
46#endif 46#endif
47#ifdef HAVE_HOTSWAP 47#ifdef HAVE_HOTSWAP
48bool mmc_removable(IF_MD_NONVOID(int drive)); 48bool mmc_removable(IF_MD_NONVOID(int drive));
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
index b1d16a7267..b1c8a83008 100644
--- a/firmware/export/mv.h
+++ b/firmware/export/mv.h
@@ -27,27 +27,28 @@
27/* FixMe: These macros are a bit nasty and perhaps misplaced here. 27/* FixMe: These macros are a bit nasty and perhaps misplaced here.
28 We'll get rid of them once decided on how to proceed with multivolume. */ 28 We'll get rid of them once decided on how to proceed with multivolume. */
29 29
30/* Drives are things like a disk, a card, a flash chip. They can have volumes on them */ 30/* Drives are things like a disk, a card, a flash chip. They can have volumes
31 on them */
31#ifdef HAVE_MULTIDRIVE 32#ifdef HAVE_MULTIDRIVE
32#define IF_MD(x) x /* optional drive parameter */ 33#define IF_MD(x...) x /* valist contents or empty */
33#define IF_MD2(x,y) x,y /* same, for a list of arguments */ 34#define IF_MD_NONVOID(x...) x /* valist contents or 'void' */
34#define IF_MD_NONVOID(x) x /* for prototype with sole volume parameter */ 35#define IF_MD_DRV(d) d /* drive argument or '0' */
35#else /* empty definitions if no multi-drive */ 36#else /* empty definitions if no multi-drive */
36#define IF_MD(x) 37#define IF_MD(x...)
37#define IF_MD2(x,y) 38#define IF_MD_NONVOID(x...) void
38#define IF_MD_NONVOID(x) void 39#define IF_MD_DRV(d) 0
39#endif 40#endif
40 41
41/* Volumes mean things that have filesystems on them, like partitions */ 42/* Volumes mean things that have filesystems on them, like partitions */
42#ifdef HAVE_MULTIVOLUME 43#ifdef HAVE_MULTIVOLUME
43#define IF_MV(x) x /* optional volume parameter */ 44#define IF_MV(x...) x /* valist contents or empty */
44#define IF_MV2(x,y) x,y /* same, for a list of arguments */ 45#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */
45#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ 46#define IF_MV_VOL(v) v /* volume argument or '0' */
46#else /* empty definitions if no multi-volume */ 47#else /* empty definitions if no multi-volume */
47#define IF_MV(x) 48#define IF_MV(x...)
48#define IF_MV2(x,y) 49#define IF_MV_NONVOID(x...) void
49#define IF_MV_NONVOID(x) void 50#define IF_MV_VOL(v) 0
50#endif 51#endif
51 52
52 53
53#endif 54#endif /* __MV_H__ */
diff --git a/firmware/export/nand.h b/firmware/export/nand.h
index 58751ab298..fe25c9b407 100644
--- a/firmware/export/nand.h
+++ b/firmware/export/nand.h
@@ -36,8 +36,8 @@ bool nand_disk_is_active(void);
36int nand_soft_reset(void); 36int nand_soft_reset(void);
37int nand_init(void) STORAGE_INIT_ATTR; 37int nand_init(void) STORAGE_INIT_ATTR;
38void nand_close(void); 38void nand_close(void);
39int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 39int nand_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
40int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 40int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
41#ifdef HAVE_STORAGE_FLUSH 41#ifdef HAVE_STORAGE_FLUSH
42int nand_flush(void); 42int nand_flush(void);
43#endif 43#endif
@@ -45,7 +45,7 @@ void nand_spin(void);
45int nand_spinup_time(void); /* ticks */ 45int nand_spinup_time(void); /* ticks */
46 46
47#ifdef STORAGE_GET_INFO 47#ifdef STORAGE_GET_INFO
48void nand_get_info(IF_MD2(int drive,) struct storage_info *info); 48void nand_get_info(IF_MD(int drive,) struct storage_info *info);
49#endif 49#endif
50 50
51long nand_last_disk_activity(void); 51long nand_last_disk_activity(void);
diff --git a/firmware/export/ramdisk.h b/firmware/export/ramdisk.h
index c478c78882..d79ac50836 100644
--- a/firmware/export/ramdisk.h
+++ b/firmware/export/ramdisk.h
@@ -35,14 +35,14 @@ bool ramdisk_disk_is_active(void);
35int ramdisk_soft_reset(void); 35int ramdisk_soft_reset(void);
36int ramdisk_init(void) STORAGE_INIT_ATTR; 36int ramdisk_init(void) STORAGE_INIT_ATTR;
37void ramdisk_close(void); 37void ramdisk_close(void);
38int ramdisk_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 38int ramdisk_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
39int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 39int ramdisk_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
40void ramdisk_spin(void); 40void ramdisk_spin(void);
41void ramdisk_sleepnow(void); 41void ramdisk_sleepnow(void);
42int ramdisk_spinup_time(void); 42int ramdisk_spinup_time(void);
43 43
44#ifdef STORAGE_GET_INFO 44#ifdef STORAGE_GET_INFO
45void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info); 45void ramdisk_get_info(IF_MD(int drive,) struct storage_info *info);
46#endif 46#endif
47 47
48long ramdisk_last_disk_activity(void); 48long ramdisk_last_disk_activity(void);
diff --git a/firmware/export/sd.h b/firmware/export/sd.h
index 1c3c429508..a5942dde1e 100644
--- a/firmware/export/sd.h
+++ b/firmware/export/sd.h
@@ -42,13 +42,13 @@ bool sd_disk_is_active(void);
42int sd_soft_reset(void); 42int sd_soft_reset(void);
43int sd_init(void) STORAGE_INIT_ATTR; 43int sd_init(void) STORAGE_INIT_ATTR;
44void sd_close(void); 44void sd_close(void);
45int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 45int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
46int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 46int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
47void sd_spin(void); 47void sd_spin(void);
48int sd_spinup_time(void); /* ticks */ 48int sd_spinup_time(void); /* ticks */
49 49
50#ifdef STORAGE_GET_INFO 50#ifdef STORAGE_GET_INFO
51void sd_get_info(IF_MD2(int drive,) struct storage_info *info); 51void sd_get_info(IF_MD(int drive,) struct storage_info *info);
52#endif 52#endif
53#ifdef HAVE_HOTSWAP 53#ifdef HAVE_HOTSWAP
54bool sd_removable(IF_MV_NONVOID(int drive)); 54bool sd_removable(IF_MV_NONVOID(int drive));
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
index 6c875bc847..1793e385df 100644
--- a/firmware/export/storage.h
+++ b/firmware/export/storage.h
@@ -95,7 +95,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
95 #define storage_get_identify() ata_get_identify() 95 #define storage_get_identify() ata_get_identify()
96 96
97 #ifdef STORAGE_GET_INFO 97 #ifdef STORAGE_GET_INFO
98 #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info) 98 #define storage_get_info(drive, info) ata_get_info(IF_MD(drive,) info)
99 #endif 99 #endif
100 #ifdef HAVE_HOTSWAP 100 #ifdef HAVE_HOTSWAP
101 #define storage_removable(drive) ata_removable(IF_MD(drive)) 101 #define storage_removable(drive) ata_removable(IF_MD(drive))
@@ -121,7 +121,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
121 #define storage_get_identify() sd_get_identify() 121 #define storage_get_identify() sd_get_identify()
122 122
123 #ifdef STORAGE_GET_INFO 123 #ifdef STORAGE_GET_INFO
124 #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info) 124 #define storage_get_info(drive, info) sd_get_info(IF_MD(drive,) info)
125 #endif 125 #endif
126 #ifdef HAVE_HOTSWAP 126 #ifdef HAVE_HOTSWAP
127 #define storage_removable(drive) sd_removable(IF_MD(drive)) 127 #define storage_removable(drive) sd_removable(IF_MD(drive))
@@ -146,7 +146,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
146 #define storage_get_identify() mmc_get_identify() 146 #define storage_get_identify() mmc_get_identify()
147 147
148 #ifdef STORAGE_GET_INFO 148 #ifdef STORAGE_GET_INFO
149 #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info) 149 #define storage_get_info(drive, info) mmc_get_info(IF_MD(drive,) info)
150 #endif 150 #endif
151 #ifdef HAVE_HOTSWAP 151 #ifdef HAVE_HOTSWAP
152 #define storage_removable(drive) mmc_removable(IF_MD(drive)) 152 #define storage_removable(drive) mmc_removable(IF_MD(drive))
@@ -171,7 +171,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
171 #define storage_get_identify() nand_get_identify() 171 #define storage_get_identify() nand_get_identify()
172 172
173 #ifdef STORAGE_GET_INFO 173 #ifdef STORAGE_GET_INFO
174 #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info) 174 #define storage_get_info(drive, info) nand_get_info(IF_MD(drive,) info)
175 #endif 175 #endif
176 #ifdef HAVE_HOTSWAP 176 #ifdef HAVE_HOTSWAP
177 #define storage_removable(drive) nand_removable(IF_MD(drive)) 177 #define storage_removable(drive) nand_removable(IF_MD(drive))
@@ -196,7 +196,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
196 #define storage_get_identify() ramdisk_get_identify() 196 #define storage_get_identify() ramdisk_get_identify()
197 197
198 #ifdef STORAGE_GET_INFO 198 #ifdef STORAGE_GET_INFO
199 #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info) 199 #define storage_get_info(drive, info) ramdisk_get_info(IF_MD(drive,) info)
200 #endif 200 #endif
201 #ifdef HAVE_HOTSWAP 201 #ifdef HAVE_HOTSWAP
202 #define storage_removable(drive) ramdisk_removable(IF_MD(drive)) 202 #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
@@ -231,6 +231,6 @@ bool storage_present(int drive);
231 231
232#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/ 232#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
233 233
234int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 234int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
235int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 235int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
236#endif 236#endif
diff --git a/firmware/storage.c b/firmware/storage.c
index 0f78712784..8740e4ebd2 100644
--- a/firmware/storage.c
+++ b/firmware/storage.c
@@ -83,7 +83,7 @@ static void storage_wait_turn(IF_MD_NONVOID(int drive))
83} 83}
84#endif 84#endif
85 85
86int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, 86int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count,
87 void* buf) 87 void* buf)
88{ 88{
89#ifdef HAVE_IO_PRIORITY 89#ifdef HAVE_IO_PRIORITY
@@ -98,38 +98,38 @@ int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
98 { 98 {
99#if (CONFIG_STORAGE & STORAGE_ATA) 99#if (CONFIG_STORAGE & STORAGE_ATA)
100 case STORAGE_ATA: 100 case STORAGE_ATA:
101 return ata_read_sectors(IF_MD2(ldrive,) start,count,buf); 101 return ata_read_sectors(IF_MD(ldrive,) start,count,buf);
102#endif 102#endif
103 103
104#if (CONFIG_STORAGE & STORAGE_MMC) 104#if (CONFIG_STORAGE & STORAGE_MMC)
105 case STORAGE_MMC: 105 case STORAGE_MMC:
106 return mmc_read_sectors(IF_MD2(ldrive,) start,count,buf); 106 return mmc_read_sectors(IF_MD(ldrive,) start,count,buf);
107#endif 107#endif
108 108
109#if (CONFIG_STORAGE & STORAGE_SD) 109#if (CONFIG_STORAGE & STORAGE_SD)
110 case STORAGE_SD: 110 case STORAGE_SD:
111 return sd_read_sectors(IF_MD2(ldrive,) start,count,buf); 111 return sd_read_sectors(IF_MD(ldrive,) start,count,buf);
112#endif 112#endif
113 113
114#if (CONFIG_STORAGE & STORAGE_NAND) 114#if (CONFIG_STORAGE & STORAGE_NAND)
115 case STORAGE_NAND: 115 case STORAGE_NAND:
116 return nand_read_sectors(IF_MD2(ldrive,) start,count,buf); 116 return nand_read_sectors(IF_MD(ldrive,) start,count,buf);
117#endif 117#endif
118 118
119#if (CONFIG_STORAGE & STORAGE_RAMDISK) 119#if (CONFIG_STORAGE & STORAGE_RAMDISK)
120 case STORAGE_RAMDISK: 120 case STORAGE_RAMDISK:
121 return ramdisk_read_sectors(IF_MD2(ldrive,) start,count,buf); 121 return ramdisk_read_sectors(IF_MD(ldrive,) start,count,buf);
122#endif 122#endif
123 } 123 }
124 124
125 return -1; 125 return -1;
126#else /* CONFIG_STORAGE_MULTI */ 126#else /* CONFIG_STORAGE_MULTI */
127 return STORAGE_FUNCTION(read_sectors)(IF_MD2(drive,)start,count,buf); 127 return STORAGE_FUNCTION(read_sectors)(IF_MD(drive,)start,count,buf);
128#endif /* CONFIG_STORAGE_MULTI */ 128#endif /* CONFIG_STORAGE_MULTI */
129 129
130} 130}
131 131
132int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 132int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count,
133 const void* buf) 133 const void* buf)
134{ 134{
135#ifdef HAVE_IO_PRIORITY 135#ifdef HAVE_IO_PRIORITY
@@ -144,33 +144,33 @@ int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
144 { 144 {
145#if (CONFIG_STORAGE & STORAGE_ATA) 145#if (CONFIG_STORAGE & STORAGE_ATA)
146 case STORAGE_ATA: 146 case STORAGE_ATA:
147 return ata_write_sectors(IF_MD2(ldrive,)start,count,buf); 147 return ata_write_sectors(IF_MD(ldrive,)start,count,buf);
148#endif 148#endif
149 149
150#if (CONFIG_STORAGE & STORAGE_MMC) 150#if (CONFIG_STORAGE & STORAGE_MMC)
151 case STORAGE_MMC: 151 case STORAGE_MMC:
152 return mmc_write_sectors(IF_MD2(ldrive,)start,count,buf); 152 return mmc_write_sectors(IF_MD(ldrive,)start,count,buf);
153#endif 153#endif
154 154
155#if (CONFIG_STORAGE & STORAGE_SD) 155#if (CONFIG_STORAGE & STORAGE_SD)
156 case STORAGE_SD: 156 case STORAGE_SD:
157 return sd_write_sectors(IF_MD2(ldrive,)start,count,buf); 157 return sd_write_sectors(IF_MD(ldrive,)start,count,buf);
158#endif 158#endif
159 159
160#if (CONFIG_STORAGE & STORAGE_NAND) 160#if (CONFIG_STORAGE & STORAGE_NAND)
161 case STORAGE_NAND: 161 case STORAGE_NAND:
162 return nand_write_sectors(IF_MD2(ldrive,)start,count,buf); 162 return nand_write_sectors(IF_MD(ldrive,)start,count,buf);
163#endif 163#endif
164 164
165#if (CONFIG_STORAGE & STORAGE_RAMDISK) 165#if (CONFIG_STORAGE & STORAGE_RAMDISK)
166 case STORAGE_RAMDISK: 166 case STORAGE_RAMDISK:
167 return ramdisk_write_sectors(IF_MD2(ldrive,)start,count,buf); 167 return ramdisk_write_sectors(IF_MD(ldrive,)start,count,buf);
168#endif 168#endif
169 } 169 }
170 170
171 return -1; 171 return -1;
172#else /* CONFIG_STORAGE_MULTI */ 172#else /* CONFIG_STORAGE_MULTI */
173 return STORAGE_FUNCTION(write_sectors)(IF_MD2(drive,)start,count,buf); 173 return STORAGE_FUNCTION(write_sectors)(IF_MD(drive,)start,count,buf);
174#endif /* CONFIG_STORAGE_MULTI */ 174#endif /* CONFIG_STORAGE_MULTI */
175} 175}
176 176
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 5bed36e51e..c80c7f7491 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -693,7 +693,7 @@ static int sd_select_bank(signed char bank)
693 return 0; 693 return 0;
694} 694}
695 695
696static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, 696static int sd_transfer_sectors(IF_MD(int drive,) unsigned long start,
697 int count, void* buf, const bool write) 697 int count, void* buf, const bool write)
698{ 698{
699#ifndef HAVE_MULTIDRIVE 699#ifndef HAVE_MULTIDRIVE
@@ -887,19 +887,19 @@ sd_transfer_error_nodma:
887 return ret; 887 return ret;
888} 888}
889 889
890int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, 890int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count,
891 void* buf) 891 void* buf)
892{ 892{
893 int ret; 893 int ret;
894 894
895 mutex_lock(&sd_mtx); 895 mutex_lock(&sd_mtx);
896 ret = sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false); 896 ret = sd_transfer_sectors(IF_MD(drive,) start, count, buf, false);
897 mutex_unlock(&sd_mtx); 897 mutex_unlock(&sd_mtx);
898 898
899 return ret; 899 return ret;
900} 900}
901 901
902int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 902int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
903 const void* buf) 903 const void* buf)
904{ 904{
905#ifdef VERIFY_WRITE 905#ifdef VERIFY_WRITE
@@ -911,7 +911,7 @@ int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
911 911
912 mutex_lock(&sd_mtx); 912 mutex_lock(&sd_mtx);
913 913
914 ret = sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true); 914 ret = sd_transfer_sectors(IF_MD(drive,) start, count, (void*)buf, true);
915 915
916#ifdef VERIFY_WRITE 916#ifdef VERIFY_WRITE
917 if (ret) { 917 if (ret) {
@@ -928,10 +928,10 @@ int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
928 if(transfer > UNALIGNED_NUM_SECTORS) 928 if(transfer > UNALIGNED_NUM_SECTORS)
929 transfer = UNALIGNED_NUM_SECTORS; 929 transfer = UNALIGNED_NUM_SECTORS;
930 930
931 sd_transfer_sectors(IF_MD2(drive,) start, transfer, aligned_buffer, false); 931 sd_transfer_sectors(IF_MD(drive,) start, transfer, aligned_buffer, false);
932 if (memcmp(buf, aligned_buffer, transfer * 512) != 0) { 932 if (memcmp(buf, aligned_buffer, transfer * 512) != 0) {
933 /* try the write again in the hope to repair the damage */ 933 /* try the write again in the hope to repair the damage */
934 sd_transfer_sectors(IF_MD2(drive,) saved_start, saved_count, saved_buf, true); 934 sd_transfer_sectors(IF_MD(drive,) saved_start, saved_count, saved_buf, true);
935 panicf("sd: verify failed: sec=%ld n=%d!", start, transfer); 935 panicf("sd: verify failed: sec=%ld n=%d!", start, transfer);
936 } 936 }
937 937
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 9edc598edf..ae3dde4495 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -773,7 +773,7 @@ int sd_init(void)
773 return 0; 773 return 0;
774} 774}
775 775
776static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, 776static int sd_transfer_sectors(IF_MD(int drive,) unsigned long start,
777 int count, void* buf, bool write) 777 int count, void* buf, bool write)
778{ 778{
779 unsigned long response; 779 unsigned long response;
@@ -969,16 +969,16 @@ sd_transfer_error_no_dma:
969 } 969 }
970} 970}
971 971
972int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, 972int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count,
973 void* buf) 973 void* buf)
974{ 974{
975 return sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false); 975 return sd_transfer_sectors(IF_MD(drive,) start, count, buf, false);
976} 976}
977 977
978int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 978int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
979 const void* buf) 979 const void* buf)
980{ 980{
981 return sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true); 981 return sd_transfer_sectors(IF_MD(drive,) start, count, (void*)buf, true);
982} 982}
983 983
984#ifndef BOOTLOADER 984#ifndef BOOTLOADER
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index 2ae425f4c6..fe1314d35a 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -800,7 +800,7 @@ static void read_inplace_writes_cache(int bank, int phys_segment)
800} 800}
801 801
802 802
803int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount, 803int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
804 void* inbuf) 804 void* inbuf)
805{ 805{
806#ifdef HAVE_MULTIDRIVE 806#ifdef HAVE_MULTIDRIVE
@@ -855,7 +855,7 @@ nand_read_error:
855 return ret; 855 return ret;
856} 856}
857 857
858int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 858int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
859 const void* outbuf) 859 const void* outbuf)
860{ 860{
861#ifdef HAVE_MULTIDRIVE 861#ifdef HAVE_MULTIDRIVE
@@ -877,7 +877,7 @@ int nand_flush(void)
877#endif 877#endif
878 878
879#ifdef STORAGE_GET_INFO 879#ifdef STORAGE_GET_INFO
880void nand_get_info(IF_MD2(int drive,) struct storage_info *info) 880void nand_get_info(IF_MD(int drive,) struct storage_info *info)
881{ 881{
882#ifdef HAVE_MULTIDRIVE 882#ifdef HAVE_MULTIDRIVE
883 (void)drive; /* unused for now */ 883 (void)drive; /* unused for now */
diff --git a/firmware/target/arm/imx233/nand-imx233.c b/firmware/target/arm/imx233/nand-imx233.c
index ec584b5869..22c4fc2748 100644
--- a/firmware/target/arm/imx233/nand-imx233.c
+++ b/firmware/target/arm/imx233/nand-imx233.c
@@ -36,13 +36,13 @@ int nand_init(void)
36{ 36{
37 return -1; 37 return -1;
38} 38}
39int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, 39int nand_read_sectors(IF_MD(int drive,) unsigned long start, int count,
40 void* buf) 40 void* buf)
41{ 41{
42 return -1; 42 return -1;
43} 43}
44 44
45int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 45int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
46 const void* buf) 46 const void* buf)
47{ 47{
48 return -1; 48 return -1;
@@ -54,7 +54,7 @@ int nand_num_drives(int first_drive)
54 return 1; 54 return 1;
55} 55}
56 56
57void nand_get_info(IF_MD2(int drive,) struct storage_info *info) 57void nand_get_info(IF_MD(int drive,) struct storage_info *info)
58{ 58{
59 IF_MD((void)drive); 59 IF_MD((void)drive);
60 info->sector_size = SECTOR_SIZE; 60 info->sector_size = SECTOR_SIZE;
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index c389a1d2c8..e520fcc6e6 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -845,7 +845,7 @@ void sd_enable(bool on)
845 (void) on; 845 (void) on;
846} 846}
847 847
848int sd_read_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, void *buf) 848int sd_read_sectors(IF_MD(int sd_drive,) unsigned long start, int count, void *buf)
849{ 849{
850#ifndef HAVE_MULTIDRIVE 850#ifndef HAVE_MULTIDRIVE
851 int sd_drive = 0; 851 int sd_drive = 0;
@@ -853,7 +853,7 @@ int sd_read_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, void *
853 return transfer_sectors(sd_map[sd_drive], start, count, buf, true); 853 return transfer_sectors(sd_map[sd_drive], start, count, buf, true);
854} 854}
855 855
856int sd_write_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, const void* buf) 856int sd_write_sectors(IF_MD(int sd_drive,) unsigned long start, int count, const void* buf)
857{ 857{
858#ifndef HAVE_MULTIDRIVE 858#ifndef HAVE_MULTIDRIVE
859 int sd_drive = 0; 859 int sd_drive = 0;
@@ -878,7 +878,7 @@ int mmc_init(void)
878 return 0; 878 return 0;
879} 879}
880 880
881void mmc_get_info(IF_MD2(int mmc_drive,) struct storage_info *info) 881void mmc_get_info(IF_MD(int mmc_drive,) struct storage_info *info)
882{ 882{
883#ifndef HAVE_MULTIDRIVE 883#ifndef HAVE_MULTIDRIVE
884 int mmc_drive = 0; 884 int mmc_drive = 0;
@@ -968,7 +968,7 @@ int mmc_spinup_time(void)
968 return 0; 968 return 0;
969} 969}
970 970
971int mmc_read_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, void *buf) 971int mmc_read_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, void *buf)
972{ 972{
973#ifndef HAVE_MULTIDRIVE 973#ifndef HAVE_MULTIDRIVE
974 int mmc_drive = 0; 974 int mmc_drive = 0;
@@ -976,7 +976,7 @@ int mmc_read_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, void
976 return transfer_sectors(mmc_map[mmc_drive], start, count, buf, true); 976 return transfer_sectors(mmc_map[mmc_drive], start, count, buf, true);
977} 977}
978 978
979int mmc_write_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, const void* buf) 979int mmc_write_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, const void* buf)
980{ 980{
981#ifndef HAVE_MULTIDRIVE 981#ifndef HAVE_MULTIDRIVE
982 int mmc_drive = 0; 982 int mmc_drive = 0;
diff --git a/firmware/target/arm/pp/ata-sd-pp.c b/firmware/target/arm/pp/ata-sd-pp.c
index f83bb60566..bcf8a660c2 100644
--- a/firmware/target/arm/pp/ata-sd-pp.c
+++ b/firmware/target/arm/pp/ata-sd-pp.c
@@ -864,7 +864,7 @@ static void sd_select_device(int card_no)
864 864
865/* API Functions */ 865/* API Functions */
866 866
867int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int incount, 867int sd_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
868 void* inbuf) 868 void* inbuf)
869{ 869{
870#ifndef HAVE_MULTIDRIVE 870#ifndef HAVE_MULTIDRIVE
@@ -981,7 +981,7 @@ sd_read_error:
981 } 981 }
982} 982}
983 983
984int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 984int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
985 const void* outbuf) 985 const void* outbuf)
986{ 986{
987/* Write support is not finished yet */ 987/* Write support is not finished yet */
diff --git a/firmware/target/arm/rk27xx/ata-nand-rk27xx.c b/firmware/target/arm/rk27xx/ata-nand-rk27xx.c
index fc150ecf52..a32963b44d 100644
--- a/firmware/target/arm/rk27xx/ata-nand-rk27xx.c
+++ b/firmware/target/arm/rk27xx/ata-nand-rk27xx.c
@@ -35,14 +35,14 @@
35static bool initialized = false; 35static bool initialized = false;
36 36
37/* API Functions */ 37/* API Functions */
38int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount, 38int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
39 void* inbuf) 39 void* inbuf)
40{ 40{
41 (void)drive; 41 (void)drive;
42 return ftl_read(start, incount, inbuf); 42 return ftl_read(start, incount, inbuf);
43} 43}
44 44
45int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 45int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
46 const void* outbuf) 46 const void* outbuf)
47{ 47{
48 (void)drive; 48 (void)drive;
@@ -74,7 +74,7 @@ void nand_enable(bool on)
74 (void)on; 74 (void)on;
75} 75}
76 76
77void nand_get_info(IF_MD2(int drive,) struct storage_info *info) 77void nand_get_info(IF_MD(int drive,) struct storage_info *info)
78{ 78{
79 (void)drive; 79 (void)drive;
80 uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock; 80 uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c
index cb870c9e38..ef9845d696 100644
--- a/firmware/target/arm/rk27xx/sd-rk27xx.c
+++ b/firmware/target/arm/rk27xx/sd-rk27xx.c
@@ -495,7 +495,7 @@ static inline void write_sd_data(unsigned char **src)
495 *src += 512; 495 *src += 512;
496} 496}
497 497
498int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, 498int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count,
499 void* buf) 499 void* buf)
500{ 500{
501#ifdef HAVE_MULTIDRIVE 501#ifdef HAVE_MULTIDRIVE
@@ -618,7 +618,7 @@ int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
618} 618}
619 619
620/* Not tested */ 620/* Not tested */
621int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 621int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
622 const void* buf) 622 const void* buf)
623{ 623{
624#ifdef HAVE_MULTIDRIVE 624#ifdef HAVE_MULTIDRIVE
diff --git a/firmware/target/arm/s3c2440/sd-s3c2440.c b/firmware/target/arm/s3c2440/sd-s3c2440.c
index 8695b65fa5..6658fa1515 100644
--- a/firmware/target/arm/s3c2440/sd-s3c2440.c
+++ b/firmware/target/arm/s3c2440/sd-s3c2440.c
@@ -847,7 +847,7 @@ sd_transfer_error:
847 return ret; 847 return ret;
848} 848}
849 849
850int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount, 850int sd_read_sectors(IF_MD(int card_no,) unsigned long start, int incount,
851 void* inbuf) 851 void* inbuf)
852{ 852{
853 int ret; 853 int ret;
@@ -868,7 +868,7 @@ int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
868} 868}
869 869
870/*****************************************************************************/ 870/*****************************************************************************/
871int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 871int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
872 const void* outbuf) 872 const void* outbuf)
873{ 873{
874#ifdef BOOTLOADER /* we don't need write support in bootloader */ 874#ifdef BOOTLOADER /* we don't need write support in bootloader */
diff --git a/firmware/target/arm/s5l8700/ata-nand-s5l8700.c b/firmware/target/arm/s5l8700/ata-nand-s5l8700.c
index a5dcb4b874..227f6b703b 100644
--- a/firmware/target/arm/s5l8700/ata-nand-s5l8700.c
+++ b/firmware/target/arm/s5l8700/ata-nand-s5l8700.c
@@ -33,13 +33,13 @@
33static bool initialized = false; 33static bool initialized = false;
34 34
35/* API Functions */ 35/* API Functions */
36int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount, 36int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
37 void* inbuf) 37 void* inbuf)
38{ 38{
39 return ftl_read(start, incount, inbuf); 39 return ftl_read(start, incount, inbuf);
40} 40}
41 41
42int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 42int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
43 const void* outbuf) 43 const void* outbuf)
44{ 44{
45 return ftl_write(start, count, outbuf); 45 return ftl_write(start, count, outbuf);
@@ -70,7 +70,7 @@ void nand_enable(bool on)
70 (void)on; 70 (void)on;
71} 71}
72 72
73void nand_get_info(IF_MD2(int drive,) struct storage_info *info) 73void nand_get_info(IF_MD(int drive,) struct storage_info *info)
74{ 74{
75 uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock; 75 uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
76 (*info).sector_size = SECTOR_SIZE; 76 (*info).sector_size = SECTOR_SIZE;
diff --git a/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c
index dbf0ce9dd4..395c0f49e6 100644
--- a/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c
+++ b/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c
@@ -962,7 +962,7 @@ int ata_soft_reset(void)
962 return rc; 962 return rc;
963} 963}
964 964
965int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int incount, 965int ata_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
966 void* inbuf) 966 void* inbuf)
967{ 967{
968 mutex_lock(&ata_mutex); 968 mutex_lock(&ata_mutex);
@@ -971,7 +971,7 @@ int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
971 return rc; 971 return rc;
972} 972}
973 973
974int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, 974int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count,
975 const void* outbuf) 975 const void* outbuf)
976{ 976{
977 mutex_lock(&ata_mutex); 977 mutex_lock(&ata_mutex);
@@ -1007,7 +1007,7 @@ void ata_spin(void)
1007 ata_set_active(); 1007 ata_set_active();
1008} 1008}
1009 1009
1010void ata_get_info(IF_MD2(int drive,) struct storage_info *info) 1010void ata_get_info(IF_MD(int drive,) struct storage_info *info)
1011{ 1011{
1012 (*info).sector_size = SECTOR_SIZE; 1012 (*info).sector_size = SECTOR_SIZE;
1013#ifdef ATA_HAVE_BBT 1013#ifdef ATA_HAVE_BBT
diff --git a/firmware/target/arm/tcc780x/sd-tcc780x.c b/firmware/target/arm/tcc780x/sd-tcc780x.c
index 3b67d21958..55ae4e7c70 100644
--- a/firmware/target/arm/tcc780x/sd-tcc780x.c
+++ b/firmware/target/arm/tcc780x/sd-tcc780x.c
@@ -398,7 +398,7 @@ static void sd_select_device(int card_no)
398 } 398 }
399} 399}
400 400
401int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount, 401int sd_read_sectors(IF_MD(int card_no,) unsigned long start, int incount,
402 void* inbuf) 402 void* inbuf)
403{ 403{
404#ifndef HAVE_MULTIDRIVE 404#ifndef HAVE_MULTIDRIVE
@@ -512,7 +512,7 @@ sd_read_error:
512 } 512 }
513} 513}
514 514
515int sd_write_sectors(IF_MD2(int card_no,) unsigned long start, int count, 515int sd_write_sectors(IF_MD(int card_no,) unsigned long start, int count,
516 const void* outbuf) 516 const void* outbuf)
517{ 517{
518/* Write support is not finished yet */ 518/* Write support is not finished yet */
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
index 4ff39e2a9e..f13904628d 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
@@ -126,8 +126,8 @@ void GIO2(void)
126 126
127#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */ 127#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */
128 128
129extern int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 129extern int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
130extern int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 130extern int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
131 131
132struct main_header 132struct main_header
133{ 133{
@@ -396,14 +396,14 @@ static inline unsigned long map_sector(unsigned long sector)
396 return cfs_start+sectors[sector/64]*64+sector%64; 396 return cfs_start+sectors[sector/64]*64+sector%64;
397} 397}
398 398
399int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf) 399int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf)
400{ 400{
401 if(!cfs_inited) 401 if(!cfs_inited)
402 cfs_init(); 402 cfs_init();
403 403
404 /* Check if count is lesser than or equal to 1 native CFS sector */ 404 /* Check if count is lesser than or equal to 1 native CFS sector */
405 if(count <= 64) 405 if(count <= 64)
406 return _ata_read_sectors(IF_MD2(drive,) map_sector(start), count, buf); 406 return _ata_read_sectors(IF_MD(drive,) map_sector(start), count, buf);
407 else 407 else
408 { 408 {
409 int i; 409 int i;
@@ -412,7 +412,7 @@ int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* bu
412 /* Read sectors in parts of 0x8000 */ 412 /* Read sectors in parts of 0x8000 */
413 for(i=0; i<count; i+=64) 413 for(i=0; i<count; i+=64)
414 { 414 {
415 int ret = _ata_read_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest); 415 int ret = _ata_read_sectors(IF_MD(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
416 if(ret != 0) 416 if(ret != 0)
417 return ret; 417 return ret;
418 418
@@ -423,7 +423,7 @@ int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* bu
423 } 423 }
424} 424}
425 425
426int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf) 426int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf)
427{ 427{
428 if(!cfs_inited) 428 if(!cfs_inited)
429 cfs_init(); 429 cfs_init();
@@ -431,7 +431,7 @@ int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const v
431#if 0 /* Disabled for now */ 431#if 0 /* Disabled for now */
432 /* Check if count is lesser than or equal to 1 native CFS sector */ 432 /* Check if count is lesser than or equal to 1 native CFS sector */
433 if(count <= 64) 433 if(count <= 64)
434 return _ata_write_sectors(IF_MD2(drive,) map_sector(start), count, buf); 434 return _ata_write_sectors(IF_MD(drive,) map_sector(start), count, buf);
435 else 435 else
436 { 436 {
437 int i, ret; 437 int i, ret;
@@ -440,7 +440,7 @@ int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const v
440 /* Read sectors in parts of 0x8000 */ 440 /* Read sectors in parts of 0x8000 */
441 for(i=0; i<count; i+=64) 441 for(i=0; i<count; i+=64)
442 { 442 {
443 ret = _ata_write_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest); 443 ret = _ata_write_sectors(IF_MD(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
444 if(ret != 0) 444 if(ret != 0)
445 return ret; 445 return ret;
446 446
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
index 5b66d192a5..d0aa12e040 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 @@
36/* Nasty hack, but Creative is nasty... */ 36/* Nasty hack, but Creative is nasty... */
37#define ata_read_sectors _ata_read_sectors 37#define ata_read_sectors _ata_read_sectors
38#define ata_write_sectors _ata_write_sectors 38#define ata_write_sectors _ata_write_sectors
39extern int _ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); 39extern int _ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
40extern int _ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); 40extern int _ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
41 41
42/* General purpose memory region #1 */ 42/* General purpose memory region #1 */
43#define ATA_IOBASE 0x50FEE000 43#define ATA_IOBASE 0x50FEE000
diff --git a/firmware/target/arm/tms320dm320/sdmmc-dm320.c b/firmware/target/arm/tms320dm320/sdmmc-dm320.c
index 2a7e1739eb..284061e1ad 100644
--- a/firmware/target/arm/tms320dm320/sdmmc-dm320.c
+++ b/firmware/target/arm/tms320dm320/sdmmc-dm320.c
@@ -849,7 +849,7 @@ sd_transfer_error:
849 } 849 }
850} 850}
851 851
852int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount, 852int sd_read_sectors(IF_MD(int card_no,) unsigned long start, int incount,
853 void* inbuf) 853 void* inbuf)
854{ 854{
855#ifndef HAVE_MULTIDRIVE 855#ifndef HAVE_MULTIDRIVE
@@ -858,7 +858,7 @@ int sd_read_sectors(IF_MD2(int card_no,) unsigned long start, int incount,
858 return sd_transfer_sectors(card_no, start, incount, inbuf, false); 858 return sd_transfer_sectors(card_no, start, incount, inbuf, false);
859} 859}
860 860
861int sd_write_sectors(IF_MD2(int card_no,) unsigned long start, int count, 861int sd_write_sectors(IF_MD(int card_no,) unsigned long start, int count,
862 const void* outbuf) 862 const void* outbuf)
863{ 863{
864#ifndef BOOTLOADER 864#ifndef BOOTLOADER
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
index f201983404..ac4092f043 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
@@ -628,7 +628,7 @@ static inline int read_sector(unsigned long start, unsigned int count,
628 return ret; 628 return ret;
629} 629}
630 630
631int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) 631int nand_read_sectors(IF_MV(int drive,) unsigned long start, int count, void* buf)
632{ 632{
633#ifdef HAVE_MULTIVOLUME 633#ifdef HAVE_MULTIVOLUME
634 (void)drive; 634 (void)drive;
@@ -671,7 +671,7 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* b
671} 671}
672 672
673/* TODO */ 673/* TODO */
674int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) 674int nand_write_sectors(IF_MV(int drive,) unsigned long start, int count, const void* buf)
675{ 675{
676 (void)start; 676 (void)start;
677 (void)count; 677 (void)count;
@@ -728,7 +728,7 @@ void nand_sleepnow(void)
728} 728}
729 729
730#ifdef STORAGE_GET_INFO 730#ifdef STORAGE_GET_INFO
731void nand_get_info(IF_MV2(int drive,) struct storage_info *info) 731void nand_get_info(IF_MV(int drive,) struct storage_info *info)
732{ 732{
733#ifdef HAVE_MULTIVOLUME 733#ifdef HAVE_MULTIVOLUME
734 (void)drive; 734 (void)drive;
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 846b9095f1..9c0d1982ad 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -1266,7 +1266,7 @@ static inline void sd_stop_transfer(void)
1266 mutex_unlock(&sd_mtx); 1266 mutex_unlock(&sd_mtx);
1267} 1267}
1268 1268
1269int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) 1269int sd_read_sectors(IF_MV(int drive,) unsigned long start, int count, void* buf)
1270{ 1270{
1271#ifdef HAVE_MULTIVOLUME 1271#ifdef HAVE_MULTIVOLUME
1272 (void)drive; 1272 (void)drive;
@@ -1320,7 +1320,7 @@ err:
1320 return retval; 1320 return retval;
1321} 1321}
1322 1322
1323int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) 1323int sd_write_sectors(IF_MV(int drive,) unsigned long start, int count, const void* buf)
1324{ 1324{
1325#ifdef HAVE_MULTIVOLUME 1325#ifdef HAVE_MULTIVOLUME
1326 (void)drive; 1326 (void)drive;
diff --git a/firmware/target/sh/archos/ondio/ata_mmc.c b/firmware/target/sh/archos/ondio/ata_mmc.c
index fc2efcd3e4..5d95a0e789 100644
--- a/firmware/target/sh/archos/ondio/ata_mmc.c
+++ b/firmware/target/sh/archos/ondio/ata_mmc.c
@@ -603,7 +603,7 @@ static int send_block_send(unsigned char start_token, long timeout,
603 return rc; 603 return rc;
604} 604}
605 605
606int mmc_read_sectors(IF_MD2(int drive,) 606int mmc_read_sectors(IF_MD(int drive,)
607 unsigned long start, 607 unsigned long start,
608 int incount, 608 int incount,
609 void* inbuf) 609 void* inbuf)
@@ -689,7 +689,7 @@ int mmc_read_sectors(IF_MD2(int drive,)
689 return rc; 689 return rc;
690} 690}
691 691
692int mmc_write_sectors(IF_MD2(int drive,) 692int mmc_write_sectors(IF_MD(int drive,)
693 unsigned long start, 693 unsigned long start,
694 int count, 694 int count,
695 const void* buf) 695 const void* buf)
@@ -953,7 +953,7 @@ long mmc_last_disk_activity(void)
953} 953}
954 954
955#ifdef STORAGE_GET_INFO 955#ifdef STORAGE_GET_INFO
956void mmc_get_info(IF_MD2(int drive,) struct storage_info *info) 956void mmc_get_info(IF_MD(int drive,) struct storage_info *info)
957{ 957{
958#ifndef HAVE_MULTIDRIVE 958#ifndef HAVE_MULTIDRIVE
959 const int drive=0; 959 const int drive=0;
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c
index 756f326bb3..96a95a8b2a 100644
--- a/firmware/test/fat/main.c
+++ b/firmware/test/fat/main.c
@@ -697,7 +697,7 @@ int main(int argc, char *argv[])
697#endif 697#endif
698 ) { 698 ) {
699 DEBUGF("*** Mounting at block %ld\n",pinfo[i].start); 699 DEBUGF("*** Mounting at block %ld\n",pinfo[i].start);
700 rc = fat_mount(IF_MV2(0,) IF_MD2(0,) pinfo[i].start); 700 rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
701 if(rc) { 701 if(rc) {
702 DEBUGF("mount: %d",rc); 702 DEBUGF("mount: %d",rc);
703 return -1; 703 return -1;
@@ -706,7 +706,7 @@ int main(int argc, char *argv[])
706 } 706 }
707 } 707 }
708 if ( i==4 ) { 708 if ( i==4 ) {
709 if(fat_mount(IF_MV2(0,) IF_MD2(0,) 0)) { 709 if(fat_mount(IF_MV(0,) IF_MD(0,) 0)) {
710 DEBUGF("No FAT32 partition!"); 710 DEBUGF("No FAT32 partition!");
711 return -1; 711 return -1;
712 } 712 }
diff --git a/firmware/test/i2c/main.c b/firmware/test/i2c/main.c
index ad684829fb..990369eae8 100644
--- a/firmware/test/i2c/main.c
+++ b/firmware/test/i2c/main.c
@@ -642,7 +642,7 @@ int main(void)
642 642
643 643
644 644
645 i = fat_mount(IF_MV2(0,) IF_MD2(0,) part[0].start); 645 i = fat_mount(IF_MV(0,) IF_MD(0,) part[0].start);
646 646
647 debugf("fat_mount() returned %d\n", i); 647 debugf("fat_mount() returned %d\n", i);
648 648
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index b898978776..d1279d0ee1 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -353,7 +353,7 @@ static bool check_disk_present(IF_MD_NONVOID(int volume))
353 return true; 353 return true;
354#else 354#else
355 unsigned char* sector = fat_get_sector_buffer(); 355 unsigned char* sector = fat_get_sector_buffer();
356 bool success = storage_read_sectors(IF_MD2(volume,)0,1,sector) == 0; 356 bool success = storage_read_sectors(IF_MD(volume,)0,1,sector) == 0;
357 fat_release_sector_buffer(); 357 fat_release_sector_buffer();
358 return success; 358 return success;
359#endif 359#endif
@@ -526,7 +526,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
526 int result = USBSTOR_WRITE_SECTORS_FILTER(); 526 int result = USBSTOR_WRITE_SECTORS_FILTER();
527 527
528 if (result == 0) { 528 if (result == 0) {
529 result = storage_write_sectors(IF_MD2(cur_cmd.lun,) 529 result = storage_write_sectors(IF_MD(cur_cmd.lun,)
530 cur_cmd.sector, 530 cur_cmd.sector,
531 MIN(WRITE_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), 531 MIN(WRITE_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
532 cur_cmd.data[cur_cmd.data_select]); 532 cur_cmd.data[cur_cmd.data_select]);
@@ -728,7 +728,7 @@ static void send_and_read_next(void)
728 ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE, 728 ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
729 MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); 729 MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE);
730#else 730#else
731 result = storage_read_sectors(IF_MD2(cur_cmd.lun,) 731 result = storage_read_sectors(IF_MD(cur_cmd.lun,)
732 cur_cmd.sector, 732 cur_cmd.sector,
733 MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), 733 MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
734 cur_cmd.data[cur_cmd.data_select]); 734 cur_cmd.data[cur_cmd.data_select]);
@@ -1087,7 +1087,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
1087 ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE, 1087 ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
1088 MIN(READ_BUFFER_SIZE/SECTOR_SIZE,cur_cmd.count)*SECTOR_SIZE); 1088 MIN(READ_BUFFER_SIZE/SECTOR_SIZE,cur_cmd.count)*SECTOR_SIZE);
1089#else 1089#else
1090 cur_cmd.last_result = storage_read_sectors(IF_MD2(cur_cmd.lun,) 1090 cur_cmd.last_result = storage_read_sectors(IF_MD(cur_cmd.lun,)
1091 cur_cmd.sector, 1091 cur_cmd.sector,
1092 MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), 1092 MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
1093 cur_cmd.data[cur_cmd.data_select]); 1093 cur_cmd.data[cur_cmd.data_select]);