summaryrefslogtreecommitdiff
path: root/firmware/test/fat/ata-sim.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-10-31 19:06:14 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-10-31 19:06:14 +0000
commit6b104a6c69e3e77f399cdd34ac35648b492b3d75 (patch)
tree3d8c6a4be325a62199e03dc92933c2339e465dfd /firmware/test/fat/ata-sim.c
parent08356fb50a70bc44e598ff49ab61bd149060a668 (diff)
downloadrockbox-6b104a6c69e3e77f399cdd34ac35648b492b3d75.tar.gz
rockbox-6b104a6c69e3e77f399cdd34ac35648b492b3d75.zip
Improved tests.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2794 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/fat/ata-sim.c')
-rw-r--r--firmware/test/fat/ata-sim.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
index 661cc79a1f..10bc3d9dc5 100644
--- a/firmware/test/fat/ata-sim.c
+++ b/firmware/test/fat/ata-sim.c
@@ -10,28 +10,23 @@ static FILE* file;
10 10
11int ata_read_sectors(unsigned long start, unsigned char count, void* buf) 11int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
12{ 12{
13 int i; 13 DEBUGF("[Reading block 0x%lx, %d]\n", start, count);
14 for (i=0; i<count; i++ )
15 DEBUGF("[Reading block 0x%lx]\n",start+i);
16 14
17 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 15 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
18 perror("fseek"); 16 perror("fseek");
19 return -1; 17 return -1;
20 } 18 }
21 if(!fread(buf,BLOCK_SIZE,count,file)) { 19 if(!fread(buf,BLOCK_SIZE,count,file)) {
22 printf("Failed reading %d blocks starting at block 0x%lx\n",count,start); 20 DEBUGF("ata_write_sectors(0x%x, 0x%x, 0x%x)\n", start, count, buf );
23 perror("fread"); 21 perror("fread");
24 panicf("Disk error\n"); 22 panicf("Disk error\n");
25 return -2;
26 } 23 }
27 return 0; 24 return 0;
28} 25}
29 26
30int ata_write_sectors(unsigned long start, unsigned char count, void* buf) 27int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
31{ 28{
32 int i; 29 DEBUGF("[Writing block 0x%lx, %d]\n", start, count);
33 for (i=0; i<count; i++ )
34 DEBUGF("[Writing block 0x%lx]\n",start+i);
35 30
36 if (start == 0) 31 if (start == 0)
37 panicf("Writing on sector 0!\n"); 32 panicf("Writing on sector 0!\n");
@@ -39,11 +34,10 @@ int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
39 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 34 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
40 perror("fseek"); 35 perror("fseek");
41 return -1; 36 return -1;
42 panicf("Disk error\n");
43 } 37 }
44 if(!fwrite(buf,BLOCK_SIZE,count,file)) { 38 if(!fwrite(buf,BLOCK_SIZE,count,file)) {
39 DEBUGF("ata_write_sectors(0x%x, 0x%x, 0x%x)\n", start, count, buf );
45 perror("fwrite"); 40 perror("fwrite");
46 return -2;
47 panicf("Disk error\n"); 41 panicf("Disk error\n");
48 } 42 }
49 return 0; 43 return 0;