10 void panicf( const char *fmt
, ... );
12 int storage_read_sectors(unsigned long start
, int count
, void* buf
)
15 DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n",
16 count
, start
, start
+count
-1);
18 DEBUGF("[Reading block 0x%lx]\n", start
);
20 if(fseek(file
,start
*BLOCK_SIZE
,SEEK_SET
)) {
24 if(!fread(buf
,BLOCK_SIZE
,count
,file
)) {
25 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start
, count
, buf
);
27 panicf("Disk error\n");
32 int storage_write_sectors(unsigned long start
, int count
, void* buf
)
35 DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n",
36 count
, start
, start
+count
-1);
38 DEBUGF("[Writing block 0x%lx]\n", start
);
41 panicf("Writing on sector 0!\n");
43 if(fseek(file
,start
*BLOCK_SIZE
,SEEK_SET
)) {
47 if(!fwrite(buf
,BLOCK_SIZE
,count
,file
)) {
48 DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start
, count
, buf
);
50 panicf("Disk error\n");
57 char* filename
= "disk.img";
59 file
=fopen(filename
,"rb+");
61 fprintf(stderr
, "read_disk() - Could not find \"%s\"\n",filename
);