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
#define BLOCKNUMBER 58549
19
 
20
__uint8_t buffer[2048] __attribute__ ((aligned (4)));
21
 
22
extern char *ide_error_msg[];
23
 
24
int main(int argc,char *argv[])
25
{
26
  __dev_t dev;
27
  __blkcnt_t blk;
28
  int res;
29
  //  int c;
30
 
31
  showmessage("This test tries to read a block from the first hard disk\n"
32
              "and then it tries to write it to disk\n"
33
              "Press [CTRL-C] to abort...");
34
 
35
  dev=bdev_find_byname(DISKDEVICE);
36
  if ((int)dev<0) {
37
    cprintf("Can't find device to operate with\n");
38
    cprintf("%s not present!\n",DISKDEVICE);
39
    return -1;
40
  }
41
  cprintf("Using device %s (dev=%04x)\n",DISKDEVICE,dev);
42
 
43
  blk=BLOCKNUMBER;
44
 
45
  cprintf("Reading block %li...\n",(long)blk);
46
  memset(buffer,0xff,sizeof(buffer));
47
  res=bdev_read(dev,blk,buffer);
48
  cprintf("Result %i\n",res);
49
  //cprintf("Soft reset done %i\n",ide[0].errors);
50
  if (res!=0) {
51
    cprintf("  %s\n",(char*)ide_error_msg[-res]);
52
    return -1;
53
  }
54
  debug_dump_buffer(buffer,64);
55
 
56
  cprintf("Writing block %li...\n",(long)blk);
57
  res=bdev_write(dev,blk,buffer);
58
  cprintf("Result %i\n",res);
59
  //cprintf("Soft reset done %i\n",ide[0].errors);
60
  if (res!=0) {
61
    cprintf("  %s\n",(char*)ide_error_msg[-res]);
62
  }
63
 
64
  waitend();
65
  return 0;
66
}