[Solved] Location of ACPI tables, purpose of AML at runtime.

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
onelastdevalex
Posts: 6
Joined: Sat Aug 03, 2024 3:21 pm

[Solved] Location of ACPI tables, purpose of AML at runtime.

Post by onelastdevalex »

Hi,

I was wondering whether ACPI tables are always located inside a memory region marked as EfiACPIReclaimMemory on UEFI systems, could anybody confirm this please? I looked at the ACPI specifications and it says it should (ACPI 6.2 figure 16-82).

However, what troubles me the most is that if those tables are in such memory regions, which can be freely overwritten by the OS later on, doesn't this mean that ACPI tables are only meant to be read during the boot/loading process of the OS? Then what's the point of having an AML interpreter at runtime?

I'm pretty sure I'm missing a ton of details, but I'm trying to learn as much as I can (I never really bothered using ACPI before, and I don't want to use ACPICA yet as my brain would be too lazy to learn ACPI stuff afterwards :D). I know AML can be needed for SMP, and HPET but those tables are available at boot time ; are there any tables that can appear during runtime?

Forgive me if those questions sound stupid, I've been stuck on them for a while now, so I guessed asking here would not be a bad idea.

Thanks in advance, Alex.
Last edited by onelastdevalex on Tue Aug 13, 2024 12:02 pm, edited 1 time in total.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Location of ACPI tables, purpose of AML at runtime.

Post by Octocontrabass »

onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmI was wondering whether ACPI tables are always located inside a memory region marked as EfiACPIReclaimMemory on UEFI systems, could anybody confirm this please?
ACPI tables are often located in ACPI reclaim memory, but not always.
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmdoesn't this mean that ACPI tables are only meant to be read during the boot/loading process of the OS?
That's up to you. You'll need information from the ACPI tables the entire time your OS is running. You don't need to keep the original ACPI tables around if you've got a copy of that information somewhere else.
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmI know AML can be needed for SMP, and HPET
Neither of those require AML...
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmbut those tables are available at boot time ; are there any tables that can appear during runtime?
You might need to load definition blocks (basically SSDTs) at runtime, but they'll never be in ACPI reclaim memory.
onelastdevalex
Posts: 6
Joined: Sat Aug 03, 2024 3:21 pm

Re: Location of ACPI tables, purpose of AML at runtime.

Post by onelastdevalex »

Octocontrabass wrote: Mon Aug 12, 2024 3:04 pm
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmI was wondering whether ACPI tables are always located inside a memory region marked as EfiACPIReclaimMemory on UEFI systems, could anybody confirm this please?
ACPI tables are often located in ACPI reclaim memory, but not always.
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmdoesn't this mean that ACPI tables are only meant to be read during the boot/loading process of the OS?
That's up to you. You'll need information from the ACPI tables the entire time your OS is running. You don't need to keep the original ACPI tables around if you've got a copy of that information somewhere else.
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmbut those tables are available at boot time ; are there any tables that can appear during runtime?
You might need to load definition blocks (basically SSDTs) at runtime, but they'll never be in ACPI reclaim memory.
So if I understand correctly, making a copy of these tables is enough (that is, they don't contain data that is needed by something else than the OS at runtime?), meaning I can remap them where I want and I should be good? (also, can I remap the NVS memory where I want, and calling SetVirtualAddressMap with the new addresses?)
Octocontrabass wrote: Mon Aug 12, 2024 3:04 pm
onelastdevalex wrote: Mon Aug 12, 2024 1:21 pmI know AML can be needed for SMP, and HPET
Neither of those require AML...
Oh my bad, I thought I read this somewhere... :D

Thank you!
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Location of ACPI tables, purpose of AML at runtime.

Post by Octocontrabass »

onelastdevalex wrote: Mon Aug 12, 2024 3:18 pmSo if I understand correctly, making a copy of these tables is enough (that is, they don't contain data that is needed by something else than the OS at runtime?), meaning I can remap them where I want and I should be good?
Copying and remapping are two completely different things. But yes, you can do whatever you want with ACPI reclaim memory, your OS is the only thing allowed to use it.
onelastdevalex wrote: Mon Aug 12, 2024 3:18 pm(also, can I remap the NVS memory where I want, and calling SetVirtualAddressMap with the new addresses?)
Yes, you can remap ACPI NVS memory however you like.

ACPI NVS memory isn't supposed to have the EFI_MEMORY_RUNTIME attribute, but if it does, you'll need to handle it the same as anything else with the EFI_MEMORY_RUNTIME attribute: assign a virtual address when you call SetVirtualAddressMap, then make sure it's mapped at that virtual address any time you call runtime services.
onelastdevalex
Posts: 6
Joined: Sat Aug 03, 2024 3:21 pm

Re: Location of ACPI tables, purpose of AML at runtime.

Post by onelastdevalex »

Octocontrabass wrote: Mon Aug 12, 2024 6:04 pm
onelastdevalex wrote: Mon Aug 12, 2024 3:18 pmSo if I understand correctly, making a copy of these tables is enough (that is, they don't contain data that is needed by something else than the OS at runtime?), meaning I can remap them where I want and I should be good?
Copying and remapping are two completely different things. But yes, you can do whatever you want with ACPI reclaim memory, your OS is the only thing allowed to use it.
Yes my bad, I was a bit tired when I wrote this, I meant to copy and unmap the original ACPI tables, but I get what you mean. Thanks.
Octocontrabass wrote: Mon Aug 12, 2024 6:04 pm
onelastdevalex wrote: Mon Aug 12, 2024 3:18 pm(also, can I remap the NVS memory where I want, and calling SetVirtualAddressMap with the new addresses?)
Yes, you can remap ACPI NVS memory however you like.

ACPI NVS memory isn't supposed to have the EFI_MEMORY_RUNTIME attribute, but if it does, you'll need to handle it the same as anything else with the EFI_MEMORY_RUNTIME attribute: assign a virtual address when you call SetVirtualAddressMap, then make sure it's mapped at that virtual address any time you call runtime services.
Again, I'm so sorry if my questions seem really basic. If I can remap the NVS space however I like, then it means that the firmware accesses it using physical addressing and not virtual addressing, otherwise it would not make a lot of sense, especially when switching to/from S4 and S5 states (ACPI 6.2 figure 15-363)?

Following the same logic, can I remap the PCI devices configuration spaces wherever I want because the devices/peripherals also use physical addressing instead of virtual addressing, or am I completely wrong for doing this?

I think my biggest misunderstanding lies in what uses physical addressing and what does not...

(I went though the PCIe specification again, and read other related posts and found my answer to this)

Anyway, thank you for your answers and your patience :D, theses are probably my last questions regarding this topic anyway.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Location of ACPI tables, purpose of AML at runtime.

Post by Octocontrabass »

onelastdevalex wrote: Tue Aug 13, 2024 2:55 amAgain, I'm so sorry if my questions seem really basic. If I can remap the NVS space however I like, then it means that the firmware accesses it using physical addressing and not virtual addressing, otherwise it would not make a lot of sense, especially when switching to/from S4 and S5 states (ACPI 6.2 figure 15-363)?
Any addresses you see will be physical addresses. ACPI is not a UEFI runtime service.
onelastdevalex
Posts: 6
Joined: Sat Aug 03, 2024 3:21 pm

Re: Location of ACPI tables, purpose of AML at runtime.

Post by onelastdevalex »

Okay thank you very much!
Post Reply