summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-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
5 files changed, 75 insertions, 75 deletions
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;