Page 1 of 2
What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 3:09 am
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
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 3:18 am
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.
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 3:29 am
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?
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 6:11 am
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.
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 6:16 am
by avibag
Do you mean that the ATA PIO is about the compatibility mode, and the PCI IDE is about the PCI native mode?
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 6:28 am
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.
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 6:32 am
by avibag
So what mode is it from the two?
And where can I find the ATA specification?
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 8:09 am
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)
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 11:15 am
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.
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 12:48 pm
by nexos
ATA is still in development? I thought everybody moved to SATA?
Re: What's the difference between the two ATA tutorials?
Posted: Fri Aug 13, 2021 1:05 pm
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.
Re: What's the difference between the two ATA tutorials?
Posted: Sat Aug 14, 2021 11:46 am
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!
Re: What's the difference between the two ATA tutorials?
Posted: Sat Aug 14, 2021 11:53 am
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
Re: What's the difference between the two ATA tutorials?
Posted: Sat Aug 14, 2021 12:14 pm
by avibag
1. I understand. Thank you.
2. So should I use the command spec?
Re: What's the difference between the two ATA tutorials?
Posted: Sat Aug 14, 2021 12:21 pm
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.