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.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
deleted file mode 100644
index 07b772f433..0000000000
--- a/firmware/test/fat/ata-sim.c
+++ /dev/null
@@ -1,68 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include "debug.h"
5
6static FILE* file;
7
8void panicf( const char *fmt, ... );
9
10int storage_read_sectors(unsigned long start, int count, void* buf)
11{
12 if ( count > 1 )
13 DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n",
14 count, start, start+count-1);
15 else
16 DEBUGF("[Reading block 0x%lx]\n", start);
17
18 if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
19 perror("fseek");
20 return -1;
21 }
22 if(!fread(buf,SECTOR_SIZE,count,file)) {
23 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
24 perror("fread");
25 panicf("Disk error\n");
26 }
27 return 0;
28}
29
30int storage_write_sectors(unsigned long start, int count, void* buf)
31{
32 if ( count > 1 )
33 DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n",
34 count, start, start+count-1);
35 else
36 DEBUGF("[Writing block 0x%lx]\n", start);
37
38 if (start == 0)
39 panicf("Writing on sector 0!\n");
40
41 if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) {
42 perror("fseek");
43 return -1;
44 }
45 if(!fwrite(buf,SECTOR_SIZE,count,file)) {
46 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf );
47 perror("fwrite");
48 panicf("Disk error\n");
49 }
50 return 0;
51}
52
53int ata_init(void)
54{
55 char* filename = "disk.img";
56 /* check disk size */
57 file=fopen(filename,"rb+");
58 if(!file) {
59 fprintf(stderr, "read_disk() - Could not find \"%s\"\n",filename);
60 return -1;
61 }
62 return 0;
63}
64
65void ata_exit(void)
66{
67 fclose(file);
68}