diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-04-26 16:44:58 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-04-26 16:44:58 +0000 |
commit | 1dff4b65f725c2174c65698e498b1d58d61e3968 (patch) | |
tree | 14403dd8415cc0fd6389bb873ae166ded43dd6ee /firmware/test/fat/ata-sim.c | |
parent | cfc2bbeef28cfd0159d59ef813ac2a7b956f13a8 (diff) |
FAT update
Added fat test code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@254 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/fat/ata-sim.c')
-rw-r--r-- | firmware/test/fat/ata-sim.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c new file mode 100644 index 0000000000..d8c28d9467 --- /dev/null +++ b/firmware/test/fat/ata-sim.c @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "ata.h" + +#define BLOCK_SIZE 512 + +static FILE* file; + +int ata_read_sectors(unsigned long start, unsigned char count, void* buf) +{ + if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { + perror("fseek"); + return -1; + } + if(!fread(buf,BLOCK_SIZE,count,file)) { + printf("Failed reading %d blocks starting at block %ld\n",count,start); + perror("fread"); + return -1; + } + return 0; +} + +int ata_write_sectors(unsigned long start, unsigned char count, void* buf) +{ + if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { + perror("fseek"); + return -1; + } + if(!fwrite(buf,BLOCK_SIZE,count,file)) { + perror("fwrite"); + return -1; + } + return 0; +} + +int ata_init(void) +{ + /* check disk size */ + file=fopen("disk.img","r+"); + if(!file) { + fprintf(stderr, "read_disk() - Could not find \"disk.img\"\n"); + return -1; + } + return 0; +} + +void ata_exit(void) +{ + fclose(file); +} |