What's the difference between the two ATA tutorials?

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
avibag
Posts: 8
Joined: Sat Oct 24, 2020 11:24 am

What's the difference between the two ATA tutorials?

Post by avibag »

Hi

I am not really sure what's the difference between the article "PCI IDE Controller" and "ATA PIO Mode". What's exactly the difference? Which one should I use for developing an ATA driver?

Thank's
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: What's the difference between the two ATA tutorials?

Post by iansjack »

You shouldn't rely upon a single source of information. Read both articles and combine the information from them to produce your own code.

But you might want to note that one of them is marked "The factual accuracy of this article or section is disputed.* and make your own decisions about it.

Other than the manufacturer's specifications, don't rely on any online information as the last word. This is why following a single tutorial, or blindly cutting and pasting code, almost always ens in failure. Try to understand the information from a multitude of sources and you can then make a considered judgement.
avibag
Posts: 8
Joined: Sat Oct 24, 2020 11:24 am

Re: What's the difference between the two ATA tutorials?

Post by avibag »

OK, I will keep that in mind. Thank's.
But still for my understanding, I would like to know - what the difference between them?
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: What's the difference between the two ATA tutorials?

Post by nexos »

The ATA PIO mode one uses "standard" port numbers and IRQs, while the PCI IDE uses PCI to obtain these values. As iansjack said, in my current OS, I no longer read tutorials, but instead look at the actual specifications. The ATA spec if freely available AFAIK, so I would recommend following that.

Also, it is better to detect from PCI rather then assume. Modern hardware probably violates those assumptions (if there even is an ATA controller to begin with). If you are targeting real hardware, I would recommend looking into AHCI (SATA), or NVMe if you have an SSD.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
avibag
Posts: 8
Joined: Sat Oct 24, 2020 11:24 am

Re: What's the difference between the two ATA tutorials?

Post by avibag »

Do you mean that the ATA PIO is about the compatibility mode, and the PCI IDE is about the PCI native mode?
Last edited by avibag on Fri Aug 13, 2021 6:32 am, edited 2 times in total.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: What's the difference between the two ATA tutorials?

Post by nexos »

avibag wrote:Do you mean that the ATA PIO uses the compatibility mode, and the PCI IDE uses the PCI native mode?
No, AFAIK (I am no ATA expert), its the same mode, just that the info is obtained via PCI, which is a lot more reliable. If this is wrong, please correct me.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
avibag
Posts: 8
Joined: Sat Oct 24, 2020 11:24 am

Re: What's the difference between the two ATA tutorials?

Post by avibag »

So what mode is it from the two?
And where can I find the ATA specification?
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: What's the difference between the two ATA tutorials?

Post by nexos »

avibag wrote:And where can I find the ATA specification?
http://web.archive.org/web/201603041111 ... TAPI-6.pdf

This is for ATA-6. I believe ATA-8 is the newest one (from 2007)
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Octocontrabass
Member
Member
Posts: 5577
Joined: Mon Mar 25, 2013 7:01 pm

Re: What's the difference between the two ATA tutorials?

Post by Octocontrabass »

avibag wrote:What's exactly the difference? Which one should I use for developing an ATA driver?
The biggest difference is that "ATA PIO Mode" assumes ancient hardware that uses fixed I/O ports and IRQs, whereas "PCI IDE Controller" detects the I/O ports and IRQs through PCI. Other than that, they describe the same thing. (PCI IDE controllers usually have an extension to support DMA, but the wiki doesn't seem to cover that.)

Unless you have some ancient pre-PCI hardware to run your OS, you should develop your driver according to the PCI IDE controller specification.
nexos wrote:I believe ATA-8 is the newest one (from 2007)
If you're looking for the command set, the newest one is ACS-4, approved in 2018. Here's a draft. Work is in progress on the next version, ACS-5. The latest draft is available here, for now. But the command set has evolved a lot over the years, so you'll probably want to look at older versions too.

If you're looking for the host bus adapter, here's a draft of the ATA adapter specification.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: What's the difference between the two ATA tutorials?

Post by nexos »

ATA is still in development? I thought everybody moved to SATA?
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Octocontrabass
Member
Member
Posts: 5577
Joined: Mon Mar 25, 2013 7:01 pm

Re: What's the difference between the two ATA tutorials?

Post by Octocontrabass »

They have.

ATA-8 split the standard into two standards: ATA8-APT and ATA8-ACS. APT is the parallel connection, ACS is the command set. The command set still gets updated.
avibag
Posts: 8
Joined: Sat Oct 24, 2020 11:24 am

Re: What's the difference between the two ATA tutorials?

Post by avibag »

Hi.

Thank's for the specifications.
I am a little confuesd.
1: I was sure that the difference between PCI native mode and compatibility mode is that PCI mode uses PCI for determining the ports, and compatibility mode uses fixed ports.. From your reply I understand that I was wrong. So what's exactly the difference between them?
2. What's the difference between the ATA specification and the ATA command set?

Thank you!
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: What's the difference between the two ATA tutorials?

Post by nexos »

1: You don't obtain the ISA port numbers via PCI, you have to either assume or use ACPI (which is very, very hard). As for difference, basically, the ISA ports should be the same on most hardware, the difference is that ISA mode supports only 2 drives and use IRQs 14 and 15 on the PIC. In PCI mode, there are an arbitrary number of drives, and IRQ mapping is obtained via the MP tables or ACPI. Personally, if you don't plan on writing an ACPI implementation, I would use ISA mode, as most ATA disks that use PCI mode probably will use different IRQs in that mode.

2: ATA is the hardware spec, ACS is the command set that software uses. I might have shown use the hardware spec, if so, do a quick Google for it
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
avibag
Posts: 8
Joined: Sat Oct 24, 2020 11:24 am

Re: What's the difference between the two ATA tutorials?

Post by avibag »

1. I understand. Thank you.
2. So should I use the command spec?
Octocontrabass
Member
Member
Posts: 5577
Joined: Mon Mar 25, 2013 7:01 pm

Re: What's the difference between the two ATA tutorials?

Post by Octocontrabass »

avibag wrote:1: I was sure that the difference between PCI native mode and compatibility mode is that PCI mode uses PCI for determining the ports, and compatibility mode uses fixed ports.. From your reply I understand that I was wrong. So what's exactly the difference between them?
In compatibility mode, the PCI IDE controller uses fixed legacy ports, so ancient software that doesn't support PCI will be able to use the PCI IDE controller. Your OS will support PCI, so you should use PCI to detect the ports. The PCI IDE controller specification explains how to detect which mode the controller is in, and how to detect which ports it's using in both modes.
avibag wrote:2. What's the difference between the ATA specification and the ATA command set?
The ATA command set is a subset of the ATA specification. No one uses the hardware part of the ATA specification anymore, so they split it into separate hardware and command set specifications, and periodically release updates to the command set specification.
nexos wrote:In PCI mode, there are an arbitrary number of drives, and IRQ mapping is obtained via the MP tables or ACPI. Personally, if you don't plan on writing an ACPI implementation, I would use ISA mode, as most ATA disks that use PCI mode probably will use different IRQs in that mode.
You only need MP tables or ACPI if you're using the APIC. The PCI configuration registers will include the PIC IRQ mapping. Some controllers won't support ISA mode anyway.
avibag wrote:2. So should I use the command spec?
Use whichever spec the drive says it supports.
Post Reply