Page 1 of 1

When to read ACPI Tables?

Posted: Tue Jan 18, 2011 6:58 am
by itportal
Hello everyone,

I was wondering, at which point of the OS booting/initialization is the OS supposed to read the ACPI tables?
Real mode or protected mode? And why? At which point do you do this in your OS?

Greets,
Martin

Re: When to read ACPI Tables?

Posted: Tue Jan 18, 2011 8:28 am
by xenos
My OS reads the ACPI tables after setting up a basic protected mode execution environment, consisting of a simple memory manager and some fault handlers, and after looking at the memory information passed in the Multiboot info in order to figure out which regions of memory it may use and which are reserved for things like ACPI tables. Currently the only information I use is the MADT if it is present, in order to determine the number of APICs / CPUs in the system and startup application processors, and the number and addresses of IOAPICs. It also reads the HPET information if present, and prints some message. While booting up additional processors (if present), the task manager initializes itself and creates a sufficient number of idle threads. It finally enables timer interrupts on all processors in order to enable multitasking, and then executes additional Multiboot modules, which perform the remaining hardware initialization.

So far my OS does not really support ACPI except for reading the MADT and HPET information, but one of my planned tasks is to write an AML interpreter in order to do something useful with the SSDT / DSDT...

Re: When to read ACPI Tables?

Posted: Tue Jan 18, 2011 12:52 pm
by gravaera
Yo:
itportal wrote:...at which point of the OS booting/initialization is the OS supposed to read the ACPI tables?
Real mode or protected mode? And why? At which point do you do this in your OS?
Your kernel isn't supposed to read them at any particular time, or even at all: when you choose to read them is up to you, and it basically depends on what information you need at various points in your bootstrap sequence :) . For example, if you want to know about CPUs present, you may read the ACPI tables to find that out. But there's no particular time when you must do it. Some people parse the information before pmode switch since their kernel is virtuall addressed, and they for some reason can't map the ACPI tables into their kernel's address space after paging is enabled (?). Otherwise, you can do it later on from pmode after your memory manager is working.

When do I do it? ACPI holds multiple repositories of information: I read it more than once, at specific times. It's all based on your design.

--Have fun,
gravaera

Re: When to read ACPI Tables?

Posted: Tue Jan 18, 2011 1:45 pm
by itportal
Thank you for your answers!

I need to read the MADT table for the exact same reason. I am trying to make my OS use the additional cores if such are present. I was not sure if the tables are still present after switching to protected mode. Who knows - the tables itself could be somehow memory mapped? The official specification of ACPI doesn't say anything about it.

I still find it a lot easier to read the tables after switching to protected mode (and more specially, in the kernel itself). It is somehow too messy to accomplish it in the bootloader.