IDE HDD control

  • Follow


Hey again friendly peoples :)

Looking at the I/O IDE interface again and seeing how for example:

Primary IDE Controller, master drive:
Address: 1F0-1F7h
8 Bytes

Primary IDE Controller, slave drive:
Address: 3F6-3F7h
2 Bytes

I'm programming an LBA hard disk driver that can work both the master and
slave drives of an IDE channel.
Speaking about testing for drive readiness using the Status registers (byte
7 of master, byte 0 of slave).
For testing purposes, does anyone know precisely if one needs to use the
slave drive registers at all?
I ask this because from what I read, the Alternate Status register of the
slave drive appears to just hold the same information as byte 7 of the
master interface.

Are the "Slave" registers active weather there is a slave drive attached or
not?

Appreciating any help.
Thanks from Cameron.
--
______________________________
Reply to the group.
______________________________
I could have the cure for cancer on my system.
       Computer Viruses mess with us all.

The PC & Electronic Data Map Project:
http://members.dodo.com.au/~cameron111



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 9/10/04

0
Reply Cameron 9/23/2004 2:53:42 PM

Cameron Gibbs asked:

| Hey again friendly peoples :)
:) sure?
| Looking at the I/O IDE interface again and seeing how for example:

| Primary IDE Controller, master drive:
| Address: 1F0-1F7h
| 8 Bytes

Same ports for 'Primary slave drive'.

port 1f0 is four (two on older) bytes wide.

Some controllers allow dword writes to 01f3 (LBA 0..27)
bits 28..31 (high nibble of 01f6) are 'E' for master and 'F' for slave.

| Primary IDE Controller, slave drive:
| Address: 3F6-3F7h
| 2 Bytes

03f7 is marked obsolete in recent ATA-specs for HD,
it's used by FD only (previously shared with HD-reset) then.

| I'm programming an LBA hard disk driver that can work both the master and
| slave drives of an IDE channel.
| Speaking about testing for drive readiness using the Status registers
| (byte 7 of master, byte 0 of slave).

?? the master/slave bit is found at 'bit4 port 01f6'

| For testing purposes, does anyone know precisely if one needs to use the
| slave drive registers at all?

There are no additional ports.
I would just check during boot if there is a slave HD/CD present.

| I ask this because from what I read, the Alternate Status register of the
| slave drive appears to just hold the same information as byte 7 of the
| master interface.

A read of 03f6 'alternate status' doesn't clear the IRQ-bit,
while a read of 01f7 will clear it (the IRQ-acknowledge).

| Are the "Slave" registers active weather there is a slave drive
| attached or not?

There is only one set of ports per IDE-controller (for two drives each),
perhaps you mixed this up with the second controller at 0170..0177/01f6 ?

[if you call the 'I/O-ports' registers or bytes, this may be confusing
 and can lead to misinterpretation with memory-locations]

__
wolfgang



0
Reply wolfgang 9/24/2004 9:03:08 AM


Reply embedded.

_________________________________
"wolfgang kern" <nowhere@nevernet.at> wrote in message news:<cj0n6a$hpm$2@newsreader1.utanet.at>...
> Cameron Gibbs asked:
> 
> | Hey again friendly peoples :)
> :) sure?
> | Looking at the I/O IDE interface again and seeing how for example:
>  
> | Primary IDE Controller, master drive:
> | Address: 1F0-1F7h
> | 8 Bytes
> 
> Same ports for 'Primary slave drive'.

That basically answers my question.
Thanks!

> port 1f0 is four (two on older) bytes wide.

I was thinking that some knowledgeable person would pick up on the 8
byte reference.
Speaking just about the older interface (negating newer improvements):
I was aware that the register at 1F0 was actually 16 bits making the
interface 9 bytes (I should perhaps say 8 registers).

However I was not aware that one could have 32 bit registers mapped to
the 16 bit I/O address space.
Might the 16 bits for the I/O space refer only to the number of
possible I/O addresses?
Otherwise maybe the HDD controller just handles the doubleword hit
using the 16 bit register. Squeezing it through one clock strike or
whatever?

> Some controllers allow dword writes to 01f3 (LBA 0..27)
> bits 28..31 (high nibble of 01f6) are 'E' for master and 'F' for slave.

Any idea how to determine what HDDs would accept such a write and what
HDDs would not?
While I am asking that, how would one go about determining the
presence or absence of a drive?

No further confusion at this time.
Thanks wolfgang

>From Cameron.

0
Reply spamtrap 9/25/2004 6:14:56 PM

Hi Cameron,

[]
| > | Primary IDE Controller, master drive:
| > | Address: 1F0-1F7h
| > | 8 Bytes
| > Same ports for 'Primary slave drive'.

| That basically answers my question.
| Thanks!

| > port 1f0 is four (two on older) bytes wide.
|
| I was thinking that some knowledgeable person would pick up on the 8
| byte reference.
| Speaking just about the older interface (negating newer improvements):
| I was aware that the register at 1F0 was actually 16 bits making the
| interface 9 bytes (I should perhaps say 8 registers).
|
| However I was not aware that one could have 32 bit registers mapped to
| the 16 bit I/O address space.
| Might the 16 bits for the I/O space refer only to the number of
| possible I/O addresses?

Right.
Data-bus width: 32 bits
Address-bus:    32(36/40) bits
I/O-address limit: 16 bits
I/O-space and MEMORY share data and address bus,
but use separated bus-control-lines (I/O vs. MEM RD/WR cycles)

| Otherwise maybe the HDD controller just handles the doubleword hit
| using the 16 bit register. Squeezing it through one clock strike or
| whatever?

32-bit ports allow faster HD-RD/WR  (even not really double).
Most newer (~+1996) controllers have port[01F0] 32 bit wide,
without writing to ports [01f1,2,3] (but work also with 16 bit),
while the same chip may offer the ability to write
16 or 32 bits to [01f4&5 or 01f3..01f6] as this ports
are configured for byte access.

| > Some controllers allow dword writes to 01f3 (LBA 0..27)
| > bits 28..31 (high nibble of 01f6) are 'E' for master and 'F' for slave.

| Any idea how to determine what HDDs would accept such a write and what
| HDDs would not?

It is merely the IDE-controllers ability, even ATA-2 mentioned a
16/32-I/O bit in the identify device block (obsolete since long yet).

So I check this by trying first to read 32-bits from 01f0
(after any command which set the data-ready bit of course),
if the resulting high-word is identical to the low-word
then it is for sure that it supports only 16 bits.
Write (after wait_ready) a dword to 01f3 and read it back
as four single bytes, compare and you know.

| While I am asking that, how would one go about determining the
| presence or absence of a drive?

1. reset drives (clear any previous error condition),
   here you can also decide to enable legacy IRQ(15/14) or not.
2. enable timer interrupt (at least..)
   wait_ready or timeout (I still give it two seconds, just for oldies)
3. send a identify-device command  (this works also if in sleep-mode)
4. wait_ready or timeout or error
5. check 'data-request bit' (data ready for read here yet)
6. if no_error,no_timeout then read the 512 bytes into a buffer.
   if error or timeout then there is either no drive or no controller
   or in some rare occasions a hardware or setup fault (like PCI-only).
7. optionally repeat 1..5 with a 'indentify packet' command for CD-drives.

ready:        b7=0 b6=1 b0=0
error:        b7=0 b6=? b0=1
data ready:   b7=0 b6=1 b3=1 b0=0
timeout:      b7=1 time elapsed

BUT: most controllers return b0=1 on all slave activity,
     so the error indication is the 'masters job' only.
IIRC yet I used   and 58h| cmp 58h |jnz error  before all I/O-RD/WR.

| No further confusion at this time.
| Thanks wolfgang

We sure find some more confusing things in this wild grown circuits :)
Always welcome,

__
wolfgang



0
Reply wolfgang 9/27/2004 11:09:59 AM

I wrote and correct myself:

[]
| BUT: most controllers return b0=1 on all slave activity,
|      so the error indication is the 'masters job' only.
| IIRC yet I used   and 58h| cmp 58h |jnz error  before all I/O-RD/WR.
[]
The last should read as:   "before all HD-block-RD/WR"

__
wolfgang



0
Reply wolfgang 9/28/2004 2:32:48 PM

Thanks buddy :)
--
______________________________
Reply to the group.
______________________________
I could have the cure for cancer on my system.
       Computer Viruses mess with us all.

The PC & Electronic Data Map Project:
http://members.dodo.com.au/~cameron111



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.769 / Virus Database: 516 - Release Date: 9/24/04

0
Reply Cameron 10/9/2004 11:10:03 AM

5 Replies
280 Views

(page loaded in 0.11 seconds)

Similiar Articles:













7/27/2012 4:33:13 PM


Reply: