summaryrefslogtreecommitdiff
path: root/firmware/test/fat/ata-sim.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/test/fat/ata-sim.c')
-rw-r--r--firmware/test/fat/ata-sim.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
index 97abb33f56..ab7266d6a0 100644
--- a/firmware/test/fat/ata-sim.c
+++ b/firmware/test/fat/ata-sim.c
@@ -1,6 +1,7 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h> 3#include <string.h>
4#include "debug.h"
4 5
5#define BLOCK_SIZE 512 6#define BLOCK_SIZE 512
6 7
@@ -8,7 +9,7 @@ static FILE* file;
8 9
9int ata_read_sectors(unsigned long start, unsigned char count, void* buf) 10int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
10{ 11{
11 printf("Reading block 0x%lx\n",start); 12 DEBUGF("Reading block 0x%lx\n",start);
12 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 13 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
13 perror("fseek"); 14 perror("fseek");
14 return -1; 15 return -1;
@@ -36,10 +37,12 @@ int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
36 37
37int ata_init(char* filename) 38int ata_init(char* filename)
38{ 39{
40 if (!filename)
41 filename = "disk.img";
39 /* check disk size */ 42 /* check disk size */
40 file=fopen(filename,"r+"); 43 file=fopen(filename,"r+");
41 if(!file) { 44 if(!file) {
42 fprintf(stderr, "read_disk() - Could not find \"disk.img\"\n"); 45 fprintf(stderr, "read_disk() - Could not find \"%s\"\n",filename);
43 return -1; 46 return -1;
44 } 47 }
45 return 0; 48 return 0;