Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 *
3
 *
4
 *
5
 */
6
 
7
#include <ll/ll.h>
8
#include <ll/stdlib.h>
9
#include <kernel/func.h>
10
#include <drivers/keyb.h>
11
 
12
#include <fs/bdevinit.h>
13
#include <fs/util.h>
14
#include <fs/bdev.h>
15
 
16
#include "../ide.h"
17
#include "../debug.h"
18
 
19
#define DISKDEVICE "ide/hda1"
20
 
21
#define NUMBLOCK 1000
22
 
23
__dev_t dev;
24
 
25
int __bdev_sub_init(void)
26
{
27
  BDEV_PARMS bdev=BASE_BDEV;
28
  bdev_def_showinfo(bdev,TRUE);
29
  bdev_init(&bdev);
30
 
31
  dev=bdev_find_byname(DISKDEVICE);
32
  if (dev<0) {
33
    cprintf("Can't find device to operate with\n");
34
    sys_end();
35
    return -1;
36
  }
37
  cprintf("Using device %s (dev=%04x)\n",DISKDEVICE,dev);
38
 
39
  return 0;
40
}
41
 
42
int __fs_sub_init(void)
43
{
44
  return 0;
45
}
46
 
47
__uint8_t buffer[2048];
48
 
49
int main(int argc,char *argv[])
50
{
51
  __blkcnt_t blk;
52
  int res;
53
  int c,i,errors;
54
  TIME sttime,etime;
55
 
56
  cprintf("Press a key to continue\n\n");
57
  c=keyb_getchar();
58
  cprintf("Please wait (reading 100 blocks for 10 times)...");
59
 
60
  sttime=sys_gettime(NULL);  
61
  errors=0;
62
  for (blk=0;blk<100;blk++) {
63
    for (i=0;i<10;i++) {
64
      res=bdev_read(dev,blk,buffer);
65
      if (res!=0) errors++;
66
    }
67
  }
68
  etime=sys_gettime(NULL)-sttime;
69
 
70
  cprintf("\nDone\n\n");
71
  cprintf("elapse time    : %li sec %li msec\n",
72
          etime/1000000l,
73
          (etime/1000l)%1000l);
74
  cprintf("soft reset made: %i\n",ide[0].errors);
75
  cprintf("errors         : %i\n",errors);
76
  cprintf("\n");
77
 
78
  return 0;
79
}