1
0
Fork 0
forked from len0rd/rockbox

Adjusted for new ata code.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@171 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-04-22 12:33:04 +00:00
parent 3c031c5ab9
commit 0f532a0041

View file

@ -28,6 +28,7 @@
#define BLOCK_SIZE 512 #define BLOCK_SIZE 512
#include "fat.h" #include "fat.h"
#include "ata.h"
#define NUM_ROOT_DIR_ENTRIES 512 #define NUM_ROOT_DIR_ENTRIES 512
#define NUM_FATS 2 #define NUM_FATS 2
@ -311,9 +312,8 @@ int fat_format(struct disk_info *di, char *vol_name)
buf[BPB_LAST_WORD+1] = 0xaa; buf[BPB_LAST_WORD+1] = 0xaa;
/* Now write the sector to disk */ /* Now write the sector to disk */
err = write_block(buf, 0); err = ata_write_sectors(0,1,buf);
if(err)
if(err < 0)
{ {
fprintf(stderr, "fat_format() - Couldn't write BSB (error code %i)\n", fprintf(stderr, "fat_format() - Couldn't write BSB (error code %i)\n",
err); err);
@ -352,8 +352,8 @@ int fat_get_bpb(struct bpb *bpb)
int countofclusters; int countofclusters;
/* Read the sector */ /* Read the sector */
err = read_block(buf, 0); err = ata_read_sectors(0,1,buf);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_get_bpb() - Couldn't read BPB (error code %i)\n", fprintf(stderr, "fat_get_bpb() - Couldn't read BPB (error code %i)\n",
err); err);
@ -526,7 +526,7 @@ int fat_create_fat(struct bpb* bpb)
if(!sec) if(!sec)
{ {
fprintf(stderr, "fat_create_fat() - Couldn't cache fat sector" fprintf(stderr, "fat_create_fat() - Couldn't cache fat sector"
" (%d)\n", i); " (%d)\n", secnum);
return -1; return -1;
} }
@ -587,7 +587,7 @@ int fat_dbg_read_block(char *name, unsigned char *buf)
return -1; return -1;
} }
/* Now write the sector to disk */ /* Now write the sector to disk */
write_block(buf, 0); ata_write_sectors(0,1,buf);
fclose(f); fclose(f);
} }
else else
@ -612,7 +612,7 @@ unsigned char *fat_cache_fat_sector(struct bpb *bpb, int secnum)
fprintf(stderr, "fat_cache_fat_sector() - Out of memory\n"); fprintf(stderr, "fat_cache_fat_sector() - Out of memory\n");
return NULL; return NULL;
} }
if(read_block(sec, secnum + bpb->bpb_rsvdseccnt) < 0) if(ata_read_sectors(secnum + bpb->bpb_rsvdseccnt,1,sec))
{ {
fprintf(stderr, "fat_cache_fat_sector() - Could" fprintf(stderr, "fat_cache_fat_sector() - Could"
" not read sector %d\n", " not read sector %d\n",
@ -715,7 +715,7 @@ int fat_read_entry(struct bpb *bpb, int entry)
int fatoffset; int fatoffset;
int thisfatsecnum; int thisfatsecnum;
int thisfatentoffset; int thisfatentoffset;
unsigned int val; int val = -1;
fatsz = fat_get_fatsize(bpb); fatsz = fat_get_fatsize(bpb);
@ -799,15 +799,15 @@ int fat_flush_fat(struct bpb *bpb)
{ {
printf("Flushing FAT sector %d\n", i); printf("Flushing FAT sector %d\n", i);
sec = fat_cache[i]; sec = fat_cache[i];
err = write_block(sec, i + bpb->bpb_rsvdseccnt); err = ata_write_sectors(i + bpb->bpb_rsvdseccnt,1,sec);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_flush_fat() - Couldn't write" fprintf(stderr, "fat_flush_fat() - Couldn't write"
" sector (%d)\n", i + bpb->bpb_rsvdseccnt); " sector (%d)\n", i + bpb->bpb_rsvdseccnt);
return -1; return -1;
} }
err = write_block(sec, i + bpb->bpb_rsvdseccnt + fatsz); err = ata_write_sectors(i + bpb->bpb_rsvdseccnt + fatsz,1,sec);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_flush_fat() - Couldn't write" fprintf(stderr, "fat_flush_fat() - Couldn't write"
" sector (%d)\n", i + bpb->bpb_rsvdseccnt + fatsz); " sector (%d)\n", i + bpb->bpb_rsvdseccnt + fatsz);
@ -873,8 +873,8 @@ int fat_create_root_dir(struct bpb *bpb)
printf("Writing rootdir to sector %d...\n", sec); printf("Writing rootdir to sector %d...\n", sec);
res = write_block(buf, sec); res = ata_write_sectors(sec,1,buf);
if(res < 0) if(res)
{ {
fprintf(stderr, "fat_create_root_dir() - Couldn't write sector (%d)\n", fprintf(stderr, "fat_create_root_dir() - Couldn't write sector (%d)\n",
sec); sec);
@ -888,7 +888,7 @@ int fat_create_root_dir(struct bpb *bpb)
for(i = 1;i < num_root_sectors;i++) for(i = 1;i < num_root_sectors;i++)
{ {
if(write_block(buf, sec++) < 0) if(ata_write_sectors(sec++,1,buf))
{ {
fprintf(stderr, "fat_create_root_dir() - " fprintf(stderr, "fat_create_root_dir() - "
" Couldn't write sector (%d)\n", sec); " Couldn't write sector (%d)\n", sec);
@ -976,8 +976,8 @@ int fat_add_dir_entry(struct bpb *bpb, unsigned int currdir,
printf("Reading sector %d...\n", sec); printf("Reading sector %d...\n", sec);
/* Read the next sector in the current dir */ /* Read the next sector in the current dir */
err = read_block(buf, sec); err = ata_read_sectors(sec,1,buf);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_add_dir_entry() - Couldn't read dir sector" fprintf(stderr, "fat_add_dir_entry() - Couldn't read dir sector"
" (error code %i)\n", err); " (error code %i)\n", err);
@ -1041,8 +1041,8 @@ int fat_add_dir_entry(struct bpb *bpb, unsigned int currdir,
} }
} }
err = write_block(buf, sec); err = ata_write_sectors(sec,1,buf);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_add_dir_entry() - " fprintf(stderr, "fat_add_dir_entry() - "
" Couldn't write dir" " Couldn't write dir"
@ -1232,8 +1232,8 @@ int fat_opendir(struct bpb *bpb, struct fat_dirent *ent, unsigned int currdir)
} }
/* Read the first sector in the current dir */ /* Read the first sector in the current dir */
err = read_block(ent->cached_buf, sec); err = ata_read_sectors(sec,1,ent->cached_buf);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_getfirst() - Couldn't read dir sector" fprintf(stderr, "fat_getfirst() - Couldn't read dir sector"
" (error code %i)\n", err); " (error code %i)\n", err);
@ -1295,8 +1295,8 @@ int fat_getnext(struct bpb *bpb, struct fat_dirent *ent,
} }
/* Read the next sector */ /* Read the next sector */
err = read_block(ent->cached_buf, ent->cached_sec); err = ata_read_sectors(ent->cached_sec,1,ent->cached_buf);
if(err < 0) if(err)
{ {
fprintf(stderr, "fat_getnext() - Couldn't read dir sector" fprintf(stderr, "fat_getnext() - Couldn't read dir sector"
" (error code %i)\n", err); " (error code %i)\n", err);