summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-04-22 12:33:04 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-04-22 12:33:04 +0000
commit0f532a00411ef071549b37cde9d795be444319eb (patch)
tree1c22e6f0ef3c4ba525ee361a57c192db8bfe2080
parent3c031c5ab96818783c4381a6ace397c76fe3f34a (diff)
downloadrockbox-0f532a00411ef071549b37cde9d795be444319eb.tar.gz
rockbox-0f532a00411ef071549b37cde9d795be444319eb.zip
Adjusted for new ata code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@171 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/fat.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/firmware/fat.c b/firmware/fat.c
index 58f4f36bac..328428a941 100644
--- a/firmware/fat.c
+++ b/firmware/fat.c
@@ -28,6 +28,7 @@
28#define BLOCK_SIZE 512 28#define BLOCK_SIZE 512
29 29
30#include "fat.h" 30#include "fat.h"
31#include "ata.h"
31 32
32#define NUM_ROOT_DIR_ENTRIES 512 33#define NUM_ROOT_DIR_ENTRIES 512
33#define NUM_FATS 2 34#define NUM_FATS 2
@@ -311,9 +312,8 @@ int fat_format(struct disk_info *di, char *vol_name)
311 buf[BPB_LAST_WORD+1] = 0xaa; 312 buf[BPB_LAST_WORD+1] = 0xaa;
312 313
313 /* Now write the sector to disk */ 314 /* Now write the sector to disk */
314 err = write_block(buf, 0); 315 err = ata_write_sectors(0,1,buf);
315 316 if(err)
316 if(err < 0)
317 { 317 {
318 fprintf(stderr, "fat_format() - Couldn't write BSB (error code %i)\n", 318 fprintf(stderr, "fat_format() - Couldn't write BSB (error code %i)\n",
319 err); 319 err);
@@ -352,8 +352,8 @@ int fat_get_bpb(struct bpb *bpb)
352 int countofclusters; 352 int countofclusters;
353 353
354 /* Read the sector */ 354 /* Read the sector */
355 err = read_block(buf, 0); 355 err = ata_read_sectors(0,1,buf);
356 if(err < 0) 356 if(err)
357 { 357 {
358 fprintf(stderr, "fat_get_bpb() - Couldn't read BPB (error code %i)\n", 358 fprintf(stderr, "fat_get_bpb() - Couldn't read BPB (error code %i)\n",
359 err); 359 err);
@@ -526,7 +526,7 @@ int fat_create_fat(struct bpb* bpb)
526 if(!sec) 526 if(!sec)
527 { 527 {
528 fprintf(stderr, "fat_create_fat() - Couldn't cache fat sector" 528 fprintf(stderr, "fat_create_fat() - Couldn't cache fat sector"
529 " (%d)\n", i); 529 " (%d)\n", secnum);
530 return -1; 530 return -1;
531 } 531 }
532 532
@@ -587,7 +587,7 @@ int fat_dbg_read_block(char *name, unsigned char *buf)
587 return -1; 587 return -1;
588 } 588 }
589 /* Now write the sector to disk */ 589 /* Now write the sector to disk */
590 write_block(buf, 0); 590 ata_write_sectors(0,1,buf);
591 fclose(f); 591 fclose(f);
592 } 592 }
593 else 593 else
@@ -612,7 +612,7 @@ unsigned char *fat_cache_fat_sector(struct bpb *bpb, int secnum)
612 fprintf(stderr, "fat_cache_fat_sector() - Out of memory\n"); 612 fprintf(stderr, "fat_cache_fat_sector() - Out of memory\n");
613 return NULL; 613 return NULL;
614 } 614 }
615 if(read_block(sec, secnum + bpb->bpb_rsvdseccnt) < 0) 615 if(ata_read_sectors(secnum + bpb->bpb_rsvdseccnt,1,sec))
616 { 616 {
617 fprintf(stderr, "fat_cache_fat_sector() - Could" 617 fprintf(stderr, "fat_cache_fat_sector() - Could"
618 " not read sector %d\n", 618 " not read sector %d\n",
@@ -715,7 +715,7 @@ int fat_read_entry(struct bpb *bpb, int entry)
715 int fatoffset; 715 int fatoffset;
716 int thisfatsecnum; 716 int thisfatsecnum;
717 int thisfatentoffset; 717 int thisfatentoffset;
718 unsigned int val; 718 int val = -1;
719 719
720 fatsz = fat_get_fatsize(bpb); 720 fatsz = fat_get_fatsize(bpb);
721 721
@@ -799,15 +799,15 @@ int fat_flush_fat(struct bpb *bpb)
799 { 799 {
800 printf("Flushing FAT sector %d\n", i); 800 printf("Flushing FAT sector %d\n", i);
801 sec = fat_cache[i]; 801 sec = fat_cache[i];
802 err = write_block(sec, i + bpb->bpb_rsvdseccnt); 802 err = ata_write_sectors(i + bpb->bpb_rsvdseccnt,1,sec);
803 if(err < 0) 803 if(err)
804 { 804 {
805 fprintf(stderr, "fat_flush_fat() - Couldn't write" 805 fprintf(stderr, "fat_flush_fat() - Couldn't write"
806 " sector (%d)\n", i + bpb->bpb_rsvdseccnt); 806 " sector (%d)\n", i + bpb->bpb_rsvdseccnt);
807 return -1; 807 return -1;
808 } 808 }
809 err = write_block(sec, i + bpb->bpb_rsvdseccnt + fatsz); 809 err = ata_write_sectors(i + bpb->bpb_rsvdseccnt + fatsz,1,sec);
810 if(err < 0) 810 if(err)
811 { 811 {
812 fprintf(stderr, "fat_flush_fat() - Couldn't write" 812 fprintf(stderr, "fat_flush_fat() - Couldn't write"
813 " sector (%d)\n", i + bpb->bpb_rsvdseccnt + fatsz); 813 " sector (%d)\n", i + bpb->bpb_rsvdseccnt + fatsz);
@@ -873,8 +873,8 @@ int fat_create_root_dir(struct bpb *bpb)
873 873
874 printf("Writing rootdir to sector %d...\n", sec); 874 printf("Writing rootdir to sector %d...\n", sec);
875 875
876 res = write_block(buf, sec); 876 res = ata_write_sectors(sec,1,buf);
877 if(res < 0) 877 if(res)
878 { 878 {
879 fprintf(stderr, "fat_create_root_dir() - Couldn't write sector (%d)\n", 879 fprintf(stderr, "fat_create_root_dir() - Couldn't write sector (%d)\n",
880 sec); 880 sec);
@@ -888,7 +888,7 @@ int fat_create_root_dir(struct bpb *bpb)
888 888
889 for(i = 1;i < num_root_sectors;i++) 889 for(i = 1;i < num_root_sectors;i++)
890 { 890 {
891 if(write_block(buf, sec++) < 0) 891 if(ata_write_sectors(sec++,1,buf))
892 { 892 {
893 fprintf(stderr, "fat_create_root_dir() - " 893 fprintf(stderr, "fat_create_root_dir() - "
894 " Couldn't write sector (%d)\n", sec); 894 " Couldn't write sector (%d)\n", sec);
@@ -976,8 +976,8 @@ int fat_add_dir_entry(struct bpb *bpb, unsigned int currdir,
976 976
977 printf("Reading sector %d...\n", sec); 977 printf("Reading sector %d...\n", sec);
978 /* Read the next sector in the current dir */ 978 /* Read the next sector in the current dir */
979 err = read_block(buf, sec); 979 err = ata_read_sectors(sec,1,buf);
980 if(err < 0) 980 if(err)
981 { 981 {
982 fprintf(stderr, "fat_add_dir_entry() - Couldn't read dir sector" 982 fprintf(stderr, "fat_add_dir_entry() - Couldn't read dir sector"
983 " (error code %i)\n", err); 983 " (error code %i)\n", err);
@@ -1041,8 +1041,8 @@ int fat_add_dir_entry(struct bpb *bpb, unsigned int currdir,
1041 } 1041 }
1042 } 1042 }
1043 1043
1044 err = write_block(buf, sec); 1044 err = ata_write_sectors(sec,1,buf);
1045 if(err < 0) 1045 if(err)
1046 { 1046 {
1047 fprintf(stderr, "fat_add_dir_entry() - " 1047 fprintf(stderr, "fat_add_dir_entry() - "
1048 " Couldn't write dir" 1048 " Couldn't write dir"
@@ -1232,8 +1232,8 @@ int fat_opendir(struct bpb *bpb, struct fat_dirent *ent, unsigned int currdir)
1232 } 1232 }
1233 1233
1234 /* Read the first sector in the current dir */ 1234 /* Read the first sector in the current dir */
1235 err = read_block(ent->cached_buf, sec); 1235 err = ata_read_sectors(sec,1,ent->cached_buf);
1236 if(err < 0) 1236 if(err)
1237 { 1237 {
1238 fprintf(stderr, "fat_getfirst() - Couldn't read dir sector" 1238 fprintf(stderr, "fat_getfirst() - Couldn't read dir sector"
1239 " (error code %i)\n", err); 1239 " (error code %i)\n", err);
@@ -1295,8 +1295,8 @@ int fat_getnext(struct bpb *bpb, struct fat_dirent *ent,
1295 } 1295 }
1296 1296
1297 /* Read the next sector */ 1297 /* Read the next sector */
1298 err = read_block(ent->cached_buf, ent->cached_sec); 1298 err = ata_read_sectors(ent->cached_sec,1,ent->cached_buf);
1299 if(err < 0) 1299 if(err)
1300 { 1300 {
1301 fprintf(stderr, "fat_getnext() - Couldn't read dir sector" 1301 fprintf(stderr, "fat_getnext() - Couldn't read dir sector"
1302 " (error code %i)\n", err); 1302 " (error code %i)\n", err);