ACPI shutdown on real hardware with ACPICA

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
no92
Member
Member
Posts: 306
Joined: Wed Oct 30, 2013 1:57 pm
Freenode IRC: no92
Location: Germany
Contact:

ACPI shutdown on real hardware with ACPICA

Post by no92 »

Hi,

I've been busy with ACPICA the time I was able to allocate to osdev (wish it could be more, but that's life -.-). This really is a heads up, which should go in the wiki, but that will have to wait because the entire ACPICA page needs a lot more info to be seriously useful (working on it, albeit slowly!).

So after you've completed incorporating ACPICA, got rid of all the bugs in your OS-specific layer (yay), you'll want to enter some sleep state (say S5, the soft shutdown, for the sake of argument). You do whatever the manual says and it works - in your emulator at least (I tested qemu and VirtualBox, and IIRC VMWare, too). On real hardware, things will change: ACPICA will spit out errors regarding some AML, and with the two machines I tested, the following warning appeared when calling AcpiInitializeObjects:
ACPICA wrote:ACPI Error: No handler for Region [ECOR] (fffffe00000d28b0) [EmbeddedControl] (2019/evregion-180)
ACPI Error: Region EmbeddedControl (ID=3) has no handler (20190405/exfldio-320)
This is no fun, because when you decide to call AcpiEnterSleepStatePrep(5), it will reappear with a bit more information:
ACPICA wrote:ACPI Error: No handler for Region [ECOR] (fffffe00000d28b0) [EmbeddedControl] (2019/evregion-180)
ACPI Error: Region EmbeddedControl (ID=3) has no handler (20190405/exfldio-320)
ACPI Error: Aborting method \OPTS due to previous error (AE_NOT_EXIST) (20190405/psparse-581)
ACPI Error: Aborting method \_PTS due to previous error (AE_NOT_EXIST) (20190405/psparse-581)
evxfevnt-0166 Disable: ACPI mode disabled
It will return with error code 6, which should be AE_NOT_EXIST. Needless to say, this is bad.

By methods of trial and error (given my superficial understanding of ACPI for now), I found a simple fix. You will install an address space handler for the Embedded Controller, which doesn't necessarily have to do everything. Should you be content with that, the additional code becomes:

Code: Select all

static ACPI_STATUS acpi_ex_handler(uint32_t function, ACPI_PHYSICAL_ADDRESS address, uint32_t bits, uint64_t *value, void *handler_context, void *region_context) {
	return AE_OK;
}
This goes just before the call to AcpiEnableSubsystem:

Code: Select all

status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_EC, &acpi_ec_handler, NULL, NULL);
Cheers, Leo
Post Reply