[Solved] Is UEFI supposed to reserve AHCI memory regions?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
codyd51
Member
Member
Posts: 77
Joined: Fri May 20, 2016 2:29 pm
Location: London, UK
GitHub: https://github.com/codyd51
Contact:

[Solved] Is UEFI supposed to reserve AHCI memory regions?

Post by codyd51 »

Hi!

I see that an AHCI descriptor block's location is given by the corresponding PCI device's BAR. However, I do not see this same memory range being reserved in the UEFI memory map (in QEMU).

Since UEFI performs some initialization of SATA drives, I would have hoped that it would reserve the appropriate memory regions. I haven't found the documentation declaring whether this is UEFI's remit, but perhaps I've missed it in the UEFI spec.

If I am intended to preserve this memory region, I am concerned that I am clobbering other device's memory without realizing. I am also concerned that my driver might not come up fast enough to prevent this memory being handed out, though this seems like a theoretical worry only for the moment.

If anyone could shed info or insight, I would be grateful. Thanks!
Last edited by codyd51 on Mon Apr 11, 2022 12:05 am, edited 1 time in total.
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: Is UEFI supposed to reserve AHCI memory regions?

Post by Ethin »

I assume your writing a UEFI driver. In that case, the driver itself will reserve the memory so long as exitBootServices has not been called. I'm not sure though how that affects the memory map -- I'd assume such memory would be marked as reserved if you acquire the memory map *before* you call ExitBootServices.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Is UEFI supposed to reserve AHCI memory regions?

Post by Octocontrabass »

Are you talking about the HBA memory registers, or are you talking about the RAM used by the UEFI AHCI driver?

If you're talking about the HBA memory registers, those aren't in the memory map at all.

If you're talking about the RAM used by the UEFI AHCI driver, that's not supposed to be reserved because your AHCI driver must allocate its own memory instead of trying to reuse the same memory as the UEFI AHCI driver.
codyd51
Member
Member
Posts: 77
Joined: Fri May 20, 2016 2:29 pm
Location: London, UK
GitHub: https://github.com/codyd51
Contact:

Re: Is UEFI supposed to reserve AHCI memory regions?

Post by codyd51 »

Thanks, both. I'll mark this post as [Solved].
Octocontrabass wrote:Are you talking about the HBA memory registers, or are you talking about the RAM used by the UEFI AHCI driver?
I was talking about the HBA memory registers.
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: [Solved] Is UEFI supposed to reserve AHCI memory regions

Post by Ethin »

Oh, I thought you were talking about the driver that TianoCore/EDK2/<insert UEFI implementation here> uses. In that case no, those definitely won't appear in the memory map -- they're not supposed to. They would most likely show up as a huge block of free memory or MMIO RAM. I suspect that it'd be marked as free RAM though.
Post Reply