Subversion Repositories shark

Rev

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 <kernel/func.h>
9
 
10
#include <fs/bdevinit.h>
11
#include <fs/bdev.h>
12
 
13
#include <stdlib.h>
14
#include <string.h>
15
 
16
#include "common.h"
17
 
18
#define DISKDEVICE "ide/hda"
19
 
20
#define TEST_MB  16
21
 
22
#define NUMBLOCK (TEST_MB*1024l*1024l/512l)
23
 
24
__dev_t dev;
25
 
26
__uint8_t buffer[2048];
27
 
28
int main(int argc,char *argv[])
29
{
30
  __blkcnt_t blk;
31
  int res;
32
  int errors;
33
  TIME sttime,etime;
34
 
35
  showmessage("\n"
36
              "This test read data from first hard disk to test\n"
37
              "disk throughtput.\n"
38
              "Remeber that the reads are made block by block so\n"
39
              "don't worry if you see a low throughtput.\n"
40
              );
41
 
42
  dev=bdev_find_byname(DISKDEVICE);
43
  if (dev<0) {
44
    cprintf("\nCan't find device to operate with\n");
45
    return -1;
46
  }
47
  cprintf("\nUsing device %s (dev=%04x)\n",DISKDEVICE,dev);
48
 
49
  cprintf("Please wait (reading %i MB linearly?!?)...",TEST_MB);
50
 
51
  sttime=sys_gettime(NULL);  
52
  errors=0;
53
  for (blk=0;blk<NUMBLOCK;blk++) {
54
    res=bdev_read(dev,blk,buffer);
55
    //res=bdev_seek(dev,blk);
56
    if (res!=0) errors++;
57
  }
58
  etime=sys_gettime(NULL)-sttime;
59
 
60
  cprintf("\nDone\n\n");
61
  cprintf("elapse time    : %li sec %li msec\n",
62
          etime/1000000l,
63
          (etime/1000l)%1000l);
64
  cprintf("throughtput    : %6.3f MB/s\n",
65
          NUMBLOCK*512.0/1024.0/1024.0/etime*1000000.0);
66
  //cprintf("soft reset made: %i\n",ide[0].errors);
67
  cprintf("errors         : %i\n",errors);
68
  cprintf("\n");
69
 
70
  return 0;
71
}