Page 1 of 1

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

Posted: Sun Apr 10, 2022 4:48 pm
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!

Re: Is UEFI supposed to reserve AHCI memory regions?

Posted: Sun Apr 10, 2022 5:35 pm
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.

Re: Is UEFI supposed to reserve AHCI memory regions?

Posted: Sun Apr 10, 2022 6:43 pm
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.

Re: Is UEFI supposed to reserve AHCI memory regions?

Posted: Mon Apr 11, 2022 12:05 am
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.

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

Posted: Mon Apr 11, 2022 5:21 pm
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.