Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
*
*
*
*/
#include <ll/i386/cons.h>
#include <drivers/keyb.h>
#include <fs/bdevinit.h>
#include <fs/bdev.h>
#include <string.h>
#include "common.h"
#define DISKDEVICE "ide/hda1"
__uint8_t buffer
[2048] __attribute__
((aligned
(4)));
__dev_t dev
;
extern char *ide_error_msg
[];
int main
(int argc
,char *argv
[])
{
__blkcnt_t blk
;
int res
;
int c
;
showmessage
("This test try to read some blocks from first hard disk\n");
dev
=bdev_find_byname
(DISKDEVICE
);
if (dev
<0) {
cprintf
("Can't find device to operate with\n");
return -1;
}
cprintf
("Using device %s (dev=%04x)\n",DISKDEVICE
,dev
);
blk
=0;
for (;;) {
cprintf
("Commands: x-exit r-read n-next block p-prev block\n");
c
= keyb_getchar
();
switch(c
) {
case 'x':
return 0;
case 'n':
blk
++;
cprintf
("Block %li\n",(long)blk
);
break;
case 'p':
if (blk
>=0) blk
--;
cprintf
("Block %li\n",(long)blk
);
break;
case 'r':
cprintf
("Reading block %li...\n",(long)blk
);
memset(buffer
,0xff,sizeof(buffer
));
res
=bdev_read
(dev
,blk
,buffer
);
cprintf
("Result %i\n",res
);
//cprintf("Soft reset done %i\n",ide[0].errors);
if (res
!=0) {
cprintf
(" %s\n",(char*)ide_error_msg
[-res
]);
}
debug_dump_buffer
(buffer
,64);
break;
default:
cprintf
("Invalid command!\n");
break;
}
cprintf
("\n");
}
return 0;
}