OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:41 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 3:09 am 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
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


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 3:18 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 3:29 am 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
OK, I will keep that in mind. Thank's.
But still for my understanding, I would like to know - what the difference between them?


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 6:11 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 6:16 am 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
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.

Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 6:28 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 6:32 am 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
So what mode is it from the two?
And where can I find the ATA specification?


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 8:09 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
avibag wrote:
And where can I find the ATA specification?

http://web.archive.org/web/20160304111133/https://www.t13.org/Documents/UploadedDocuments/project/d1410r3b-ATA-ATAPI-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


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 11:15 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 12:48 pm 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Fri Aug 13, 2021 1:05 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Sat Aug 14, 2021 11:46 am 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
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!


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Sat Aug 14, 2021 11:53 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Sat Aug 14, 2021 12:14 pm 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
1. I understand. Thank you.
2. So should I use the command spec?


Top
 Profile  
 
 Post subject: Re: What's the difference between the two ATA tutorials?
PostPosted: Sat Aug 14, 2021 12:21 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 31 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