Hard Disk Drive Read/Write Problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ahmedhalawa
Member
Member
Posts: 28
Joined: Wed Jul 02, 2008 9:28 am

Hard Disk Drive Read/Write Problem

Post 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
User avatar
-m32
Member
Member
Posts: 120
Joined: Thu Feb 21, 2008 5:59 am
Location: Ottawa, Canada

Re: hdd read write

Post 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.
User avatar
ahmedhalawa
Member
Member
Posts: 28
Joined: Wed Jul 02, 2008 9:28 am

Re: hdd read write

Post 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);
Post Reply