Page 1 of 1

Hard Disk Drive Read/Write Problem

Posted: Sun Aug 23, 2009 7:05 am
by ahmedhalawa
Hello every body
Really i'm not sur my problem is problem or not :!:
Now i tring to write hard disk driver when i try to read sector 1 ,bochs give this messag(will show after)
with out reading
in microsoft virtual pc my system print all buffer all buffer equal zero also when i try to read from my real hard disk
is there is any error with my code thanks

Code: Select all

rw(1,true,0,0,0,1,0x2000);
void hardd::rw(uint n,bool read,uint C,uint c,uint h,uint s, void *buf)
{
	ushort*b = (ushort*)buf;video v;
	while((inb(0x1F7)&0x80) == 0x80){};
	outb(0x1F2,n);
	outb(0x1F3,s);
	outb(0x1F4,c);
	outb(0x1F5,C);
	outb(0x1F6,0xa0|(h&0xF));
             if(read==true )outb(0x1F7,0x20);
             if(read==false)outb(0x1F7,0x30);
	if(read==true )for(int i=0;i<n*512;i++)b[i] = inw(0x1F0);
	if(read==false)for(int i=0;i<n*512;i++)outw(0x1F0,b[i]);
}
bochs msg here

Code: Select all

write to port 0x01F0 with len 1 ignored

Re: hdd read write

Posted: Sun Aug 23, 2009 7:32 am
by -m32
You need to poll the status (or wait for an IRQ) to see if the device is ready before you can read the buffer.

Re: hdd read write

Posted: Sun Aug 23, 2009 11:38 am
by ahmedhalawa
poll the status
Sorry i think i deleted it while code while i was removing debug instructions
to show my code which shown befor
Bochs some time give msg tell me that it cann't read from
hdd img at byte 0 am i right when i say the error may be come from
here

Code: Select all

   outb(0x1F2,n);
   outb(0x1F3,s);
   outb(0x1F4,c);
   outb(0x1F5,C);