When to read ACPI Tables?

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
itportal
Posts: 18
Joined: Tue May 18, 2010 1:34 am

When to read ACPI Tables?

Post 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
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: When to read ACPI Tables?

Post 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...
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: When to read ACPI Tables?

Post 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
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
itportal
Posts: 18
Joined: Tue May 18, 2010 1:34 am

Re: When to read ACPI Tables?

Post 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.
Post Reply