OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 5:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: ACPI shutdown on real hardware with ACPICA
PostPosted: Fri Apr 12, 2019 2:53 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
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:
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:
status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_EC, &acpi_ec_handler, NULL, NULL);


Cheers, Leo

_________________
managarm


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 120 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group