diff options
Diffstat (limited to 'firmware/test/fat/ata-sim.c')
-rw-r--r-- | firmware/test/fat/ata-sim.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c index a64e0a4d4d..661cc79a1f 100644 --- a/firmware/test/fat/ata-sim.c +++ b/firmware/test/fat/ata-sim.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "debug.h" | 4 | #include "debug.h" |
5 | #include "panic.h" | ||
5 | 6 | ||
6 | #define BLOCK_SIZE 512 | 7 | #define BLOCK_SIZE 512 |
7 | 8 | ||
@@ -9,7 +10,10 @@ static FILE* file; | |||
9 | 10 | ||
10 | int ata_read_sectors(unsigned long start, unsigned char count, void* buf) | 11 | int ata_read_sectors(unsigned long start, unsigned char count, void* buf) |
11 | { | 12 | { |
12 | DEBUGF("[Reading block 0x%lx]\n",start); | 13 | int i; |
14 | for (i=0; i<count; i++ ) | ||
15 | DEBUGF("[Reading block 0x%lx]\n",start+i); | ||
16 | |||
13 | if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { | 17 | if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { |
14 | perror("fseek"); | 18 | perror("fseek"); |
15 | return -1; | 19 | return -1; |
@@ -17,6 +21,7 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf) | |||
17 | if(!fread(buf,BLOCK_SIZE,count,file)) { | 21 | if(!fread(buf,BLOCK_SIZE,count,file)) { |
18 | printf("Failed reading %d blocks starting at block 0x%lx\n",count,start); | 22 | printf("Failed reading %d blocks starting at block 0x%lx\n",count,start); |
19 | perror("fread"); | 23 | perror("fread"); |
24 | panicf("Disk error\n"); | ||
20 | return -2; | 25 | return -2; |
21 | } | 26 | } |
22 | return 0; | 27 | return 0; |
@@ -24,20 +29,22 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf) | |||
24 | 29 | ||
25 | int ata_write_sectors(unsigned long start, unsigned char count, void* buf) | 30 | int ata_write_sectors(unsigned long start, unsigned char count, void* buf) |
26 | { | 31 | { |
27 | DEBUGF("[Writing block 0x%lx]\n",start); | 32 | int i; |
33 | for (i=0; i<count; i++ ) | ||
34 | DEBUGF("[Writing block 0x%lx]\n",start+i); | ||
28 | 35 | ||
29 | if (start == 0) { | 36 | if (start == 0) |
30 | DEBUGF("Holy crap! You're writing on sector 0!\n"); | 37 | panicf("Writing on sector 0!\n"); |
31 | exit(0); | ||
32 | } | ||
33 | 38 | ||
34 | if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { | 39 | if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { |
35 | perror("fseek"); | 40 | perror("fseek"); |
36 | return -1; | 41 | return -1; |
42 | panicf("Disk error\n"); | ||
37 | } | 43 | } |
38 | if(!fwrite(buf,BLOCK_SIZE,count,file)) { | 44 | if(!fwrite(buf,BLOCK_SIZE,count,file)) { |
39 | perror("fwrite"); | 45 | perror("fwrite"); |
40 | return -2; | 46 | return -2; |
47 | panicf("Disk error\n"); | ||
41 | } | 48 | } |
42 | return 0; | 49 | return 0; |
43 | } | 50 | } |