OSDev.org

The Place to Start for Operating System Developers
It is currently Fri May 10, 2024 6:31 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re:Hard Disk query
PostPosted: Sun Jan 25, 2004 3:37 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Neo wrote:
just wanted to know does the Execeute Diagnostic fire an IRQ?


according to the above-providen link, section 9.10 (execute device diagnostic protocol), an IRQ will be issued if the nIRQ bit is cleared in the controller registers. Otherwise, you should wait 2ms and then check the status ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Sun Jan 25, 2004 5:47 pm 
Offline
Member
Member

Joined: Sat Nov 25, 2006 12:50 am
Posts: 454
..


Last edited by Perica on Tue Dec 05, 2006 9:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Sun Jan 25, 2004 6:04 pm 
ATA and ATAPI are the official names for what started as IDE and Enhanced IDE. ATA generally refers to hard disks, while ATAPI refers to CD and DVD readers and writers.

http://www.t13.org/ is the official web site of the T13 committee, who decide what goes into each new ATA/ATAPI spec.

http://www.ata-atapi.com/ is a useful site with information on how to actually program these devices, with some useful source code and discussion that goes deeper than what's in the spec.


Top
  
 
 Post subject: Re:Hard Disk query
PostPosted: Sun Feb 01, 2004 11:28 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
just thought i'd add this piece of info. I had cleared nIEN(enabled HDC ints) before the "Exceute Diagnostic" command but received no INT from the HDC. After reading the doc sec 9.10 i just added a delay(just to test) and to my surprise the ISR was called. Now I'm not sure why this happened i think it was because i had called another "Identify Drive" function right after the "Execute Diagnostic" and the HDC had to respond to this before the completion of the "Execute Diagnostic" function. SO if this is right I hope it helps anyone programming the HDC.
btw the "identify drive" caused an older 20GB drive(old BIOS also) to "hang" the system when i tried it out. Any comments on this?
Also how does Linux use the HDD's? LBA or CHS mode?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Mon Feb 02, 2004 4:37 am 
Hi
The delay is part of the ATA spec. I am also doing a ATA/ATAPI driver, i have found many quercks with differant sys, for instance i have about 10 pc's all differant specs, i have written a unit that detects the address of all the hard drives and the cd drives on the pc, this code worked fine on 9 of them, but faild to detect a master cd drive on the 10th one, the only way to over come this problem is to put quite a large delay, i dont know why this is differant from the others.
Another problem was that most of the code i had writen was writen as small com files which could be tested from a com file boot loader , i got them all working, but had to do a lot of work to get them working in pmode :'(
Some of the code is run at bootup other when in pmode.

PS: One of the things to make sure of is in your IRQ code make sure you cancel the IRQ, there are two codes for this one used for the lower IRQs keyboard ect and one for the higher make sure that you use the higher one .

ASHLEY4


Top
  
 
 Post subject: Re:Hard Disk query
PostPosted: Mon Feb 02, 2004 6:30 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Neo wrote:
After reading the doc sec 9.10 i just added a delay(just to test) and to my surprise the ISR was called.

what exactly do you mean by "adding a delay" ? You're expected to *wait* for the interrupt anyway ...

Quote:
Now I'm not sure why this happened i think it was because i had called another "Identify Drive" function right after the "Execute Diagnostic" and the HDC had to respond to this before the completion of the "Execute Diagnostic" function.

Are you issueing two commands (ExecDiag and then IdDrive) one after the other and expecting the disk to reply to them in sequence ? this is not the way hardware usually works (well, not with ATA, at least). You should not issue a new command before the previous command completed. The exception is if you send a RESET command between the two, in which case you shouldn't expect to get the result of the first one ...

Quote:
Also how does Linux use the HDD's? LBA or CHS mode?

afaik, it uses LBA, unless the drive reported no LBA support ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Mon Feb 02, 2004 1:18 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Quote:
PS: One of the things to make sure of is in your IRQ code make sure you cancel the IRQ, there are two codes for this one used for the lower IRQs keyboard ect and one for the higher make sure that you use the higher one .

are you referring to the PICs? and sending the EOI to them? i am doing both.
Quote:
what exactly do you mean by "adding a delay" ? You're expected to *wait* for the interrupt anyway ...

@Pype I was waiting for the interrupt but it was never called. thats when i tried the delay and got it working? I cant understand why the handler wasn't called beofre that?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Mon Feb 02, 2004 3:33 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
just to be sure ... did you unmasked the ATA interrupt properly on the PIC (iirc, you should clear the bit 2 of the master PIC's mask to receive the cascaded interrupts and the bit 6 of the slave PIC's mask, as primary ATA controller is bound to IRQ 14) ?

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Fri Feb 06, 2004 12:53 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
I just thought i'd post my code here to see if you can find anything wrong with it. The variable hdc_flag is changed in the Handler to NULL but the handler never gets called after this command so the function loops infinitely.
Here's the code

Code:
void execute_diagnostic(void)
{
  BUSY_wait();
  outb(HDD_BASE+DRV_HEAD,0xA0);
  hdc_flag= HDC_DIAGNOSE;
  EnableHDC_int();
  DRDY_wait();
  outb(HDD_BASE+CMD,EXEC_DIAGNOSTIC);
  while(hdc_flag!=NULL);
}

the BUSY_wait() ,EnableHDC_int() and DRDY_wait() functions are here
Code:
_BUSY_wait:
push   dx
push   ax
   mov   dx,HDD_BASE+STATUS
.cont: in   al,dx
   bt   ax,7
   jc   .cont
pop   ax
pop   dx
retn

Code:
_EnableHDC_int:
push   dx
push   ax
   mov   dx,CTRL_REG
   in   al,dx
   and   al,0xFD
   out   dx,al
pop   ax
pop   dx
retn


Code:
_DRDY_wait:
  push   dx
  push   ax
   mov   dx,HDD_BASE+STATUS
.cont   in   al,dx
   bt   ax,6
   jnc   .cont
  pop   ax
  pop   dx
  retn


@Pype btw i've unmasked all IRQ's ie sent 0 to both MASTER and SLAVE.

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Sat Feb 07, 2004 11:09 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
I just realised that this works on the real hardware but not in BOCHS now i'm wondering is there some bug in BOCHS? Does anyone here have any experience with ATA code that runs fine in BOCHS or do you use something else?
btw I use BOCHS 2.0.2 and was wondering if you have to give it any additional parameters right now i only use this
Code:
ata0-master: type=disk,path="c.img", cylinders=20, heads=16, spt=63
ata0-slave: type=disk,path="hdd.img", cylinders=20, heads=16, spt=63

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Sun Feb 08, 2004 9:25 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
i have faced some strange behaviours with BOCHS and ATA drives, indeed, especially when no ATA0 controller were defined. make sure you read properly the configuration files for *your* version of BOCHS for this stuff seems to be subject to frequent changes ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Sun Feb 08, 2004 11:19 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
The BOCHS line i posted above are from my BOCHS 2.0.2 manual. And still they dont work. Well I'm going to write this error off as a BOCHS bug.
btw any BOCHS devers here please take note of this.

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Tue Feb 17, 2004 9:59 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
any news ? did it finally work ?

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Tue Feb 17, 2004 11:20 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
well i'm sort of doing somethin else at this time :-\ and have kept this aside. But yeah the thing works on real hardware and not in BOCHS of course i was a firm believer in the fact that if my program was 100% right in BOCHS then it would run on most hardware but after this well...... :-\

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Hard Disk query
PostPosted: Wed Feb 18, 2004 2:12 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
maybe you could drop us an image to test in the 'OS test' section ... i have a small laptop that could be used to know if your driver is 100% on that hardware too (and i'm sure other people also have ;:)

_________________
Image May the source be with you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group