Subversion Repositories shark

Rev

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

/*
 *
 *
 *
 */


#include <ll/ll.h>
#include <ll/stdlib.h>
#include <kernel/func.h>
#include <drivers/keyb.h>

#include <fs/bdevinit.h>
#include <fs/util.h>
#include <fs/bdev.h>

#include "../ide.h"
#include "../debug.h"

#define DISKDEVICE "ide/hda1"

#define NUMBLOCK 1000

__dev_t dev;

int __bdev_sub_init(void)
{
  BDEV_PARMS bdev=BASE_BDEV;
  bdev_def_showinfo(bdev,TRUE);
  bdev_init(&bdev);
 
  dev=bdev_find_byname(DISKDEVICE);
  if (dev<0) {
    cprintf("Can't find device to operate with\n");
    sys_end();
    return -1;
  }
  cprintf("Using device %s (dev=%04x)\n",DISKDEVICE,dev);
 
  return 0;
}

int __fs_sub_init(void)
{
  return 0;
}

__uint8_t buffer[2048];

int main(int argc,char *argv[])
{
  __blkcnt_t blk;
  int res;
  int c,i,errors;
  TIME sttime,etime;
 
  cprintf("Press a key to continue\n\n");
  c=keyb_getchar();
  cprintf("Please wait (reading 100 blocks for 10 times)...");

  sttime=sys_gettime(NULL);  
  errors=0;
  for (blk=0;blk<100;blk++) {
    for (i=0;i<10;i++) {
      res=bdev_read(dev,blk,buffer);
      if (res!=0) errors++;
    }
  }
  etime=sys_gettime(NULL)-sttime;

  cprintf("\nDone\n\n");
  cprintf("elapse time    : %li sec %li msec\n",
          etime/1000000l,
          (etime/1000l)%1000l);
  cprintf("soft reset made: %i\n",ide[0].errors);
  cprintf("errors         : %i\n",errors);
  cprintf("\n");
 
  return 0;
}