Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1624 giacomo 1
/*
2
 *
3
 *
4
 *
5
 */
6
 
7
#include <ll/i386/cons.h>
8
#include <drivers/keyb.h>
9
 
10
#include <fs/bdevinit.h>
11
#include <fs/bdev.h>
12
 
13
#include <string.h>
14
 
15
#include "common.h"
16
 
17
#define DISKDEVICE "ide/hda1"
18
 
19
__uint8_t buffer[2048] __attribute__ ((aligned (4)));
20
__dev_t dev;
21
 
22
extern char *ide_error_msg[];
23
 
24
int main(int argc,char *argv[])
25
{
26
  __blkcnt_t blk;
27
  int res;
28
  int c;
29
 
30
  showmessage("This test try to read some blocks from first hard disk\n");
31
 
32
  dev=bdev_find_byname(DISKDEVICE);
33
  if (dev<0) {
34
    cprintf("Can't find device to operate with\n");
35
    return -1;
36
  }
37
  cprintf("Using device %s (dev=%04x)\n",DISKDEVICE,dev);
38
 
39
  blk=0;
40
  for (;;) {    
41
    cprintf("Commands: x-exit r-read n-next block p-prev block\n");
42
    c = keyb_getchar();
43
    switch(c) {
44
      case 'x':
45
        return 0;
46
 
47
      case 'n':
48
        blk++;
49
        cprintf("Block %li\n",(long)blk);
50
        break;
51
 
52
      case 'p':
53
        if (blk>=0) blk--;
54
        cprintf("Block %li\n",(long)blk);
55
        break;
56
 
57
      case 'r':
58
        cprintf("Reading block %li...\n",(long)blk);
59
        memset(buffer,0xff,sizeof(buffer));
60
        res=bdev_read(dev,blk,buffer);
61
        cprintf("Result %i\n",res);
62
        //cprintf("Soft reset done %i\n",ide[0].errors);
63
        if (res!=0) {
64
          cprintf("  %s\n",(char*)ide_error_msg[-res]);
65
        }
66
        debug_dump_buffer(buffer,64);
67
        break;
68
 
69
      default:
70
        cprintf("Invalid command!\n");
71
        break;
72
    }
73
    cprintf("\n");
74
  }
75
 
76
  return 0;
77
}