OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 29, 2024 2:19 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Questions about BIOS configuring AHCI controllers
PostPosted: Sat Aug 19, 2023 2:22 pm 
Offline

Joined: Sun Dec 25, 2022 1:16 pm
Posts: 5
Hello, I have 3 questions about how the BIOS configures AHCI controllers:

1. The wiki says “BIOS may have already configured all the necessary AHCI memory spaces. But the OS usually needs to reconfigure them to make them fit its requirements”. What are these ‘requirements’? As far as I can see, the BIOS can be fully trusted with its allocations (unless its buggy, but thats unlikely, isn’t it? AHCI is pretty crucial to boot the OS, if its installed on a SATA drive).
2. I’m assuming that these ‘memory spaces’ that the BIOS configures are the ABAR, the command lists and the received FISes. What about command tables? I mean, I’m assuming NOT because they are variable length (the PRDT can have different amounts of entries). I have to allocate my own command tables, correct?
3. When I allocate my command tables, do I need to set the memory region to uncached? I know AHCI uses DMA for data transfers, and so it participates in the cache coherency protocol, but does it use it for reading the command tables aswell?


Top
 Profile  
 
 Post subject: Re: Questions about BIOS configuring AHCI controllers
PostPosted: Sat Aug 19, 2023 2:50 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
ThisIsAnEpicUsername wrote:
As far as I can see, the BIOS can be fully trusted with its allocations (unless its buggy, but thats unlikely, isn’t it? AHCI is pretty crucial to boot the OS, if its installed on a SATA drive).

It's actually very likely to be buggy. Firmware developers usually only check to make sure Windows can boot, so if Windows doesn't care that the firmware initialized something wrong, they won't bother to fix it.

ThisIsAnEpicUsername wrote:
What about command tables?

The firmware probably did set some of those up, but like everything else, you shouldn't rely on them.

ThisIsAnEpicUsername wrote:
When I allocate my command tables, do I need to set the memory region to uncached?

No. DMA is just a fancy name for when a device can read or write memory by itself instead of relying on the CPU to move data around.


Top
 Profile  
 
 Post subject: Re: Questions about BIOS configuring AHCI controllers
PostPosted: Sun Aug 20, 2023 1:45 am 
Offline

Joined: Sun Dec 25, 2022 1:16 pm
Posts: 5
Ok. I will reinitialise the controller and use new memory structures (except for the ABAR, because that is one thing that can be trusted, right?)

Quote:
No. DMA is just a fancy name for when a device can read or write memory by itself instead of relying on the CPU to move data around.

So, basically all PCI MMIO that maps to some memory structure in RAM is accessed via DMA, and therefore doesn’t need to be set to uncached?


Top
 Profile  
 
 Post subject: Re: Questions about BIOS configuring AHCI controllers
PostPosted: Sun Aug 20, 2023 1:35 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
ThisIsAnEpicUsername wrote:
(except for the ABAR, because that is one thing that can be trusted, right?)

Right.

ThisIsAnEpicUsername wrote:
So, basically all PCI MMIO that maps to some memory structure in RAM is accessed via DMA, and therefore doesn’t need to be set to uncached?

Correct. RAM should always be set to WB.


Top
 Profile  
 
 Post subject: Re: Questions about BIOS configuring AHCI controllers
PostPosted: Sun Aug 20, 2023 1:56 pm 
Offline

Joined: Sun Dec 25, 2022 1:16 pm
Posts: 5
Ok, thanks for the help.


Top
 Profile  
 
 Post subject: Re: Questions about BIOS configuring AHCI controllers
PostPosted: Sun Aug 20, 2023 4:55 pm 
Offline
Member
Member

Joined: Mon Jul 05, 2021 6:57 pm
Posts: 118
Octocontrabass wrote:
ThisIsAnEpicUsername wrote:
So, basically all PCI MMIO that maps to some memory structure in RAM is accessed via DMA, and therefore doesn’t need to be set to uncached?

Correct. RAM should always be set to WB.


Wait. RAM should always be set to WB, but MMIO regions aren't RAM. I don't think it is correct at all.

For example, a graphics framebuffer is an MMIO region and should not be WB (write-combining/WC is ok for a framebuffer in most cases).

I think the issue is that the premise of your question is wrong:

Quote:
So, basically all PCI MMIO that maps to some memory structure in RAM is accessed via DMA


NOT correct. MMIO and DMA are two different ways of communicating with a device.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 33 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