[coreboot] what happened when power button is pressed and a machine begins to shutdown?
stefan.reinauer at coreboot.org
Fri Apr 22 01:50:08 CEST 2011
* Jiang Wang <jwangzju at gmail.com> [110422 01:33]:
> I am trying to understand how the power button pressing event triggers
> the machine to shutdown. From the ACPI spec 126.96.36.199.1, it mentioned
> that the power button can be implemented either as a fixed hardware or
> a generic hardware programming method. So, for ASUS M2V-MX SE, how
> the power button is implemented?
> I tested coreboot with Linux on M2V-MX SE. When the Linux stops at
> login window, pressing the power button can lead the machine to
> shutdown. So what are the concrete steps between the power button is
> pressed to the Linux begins to shutdown? Is it a AML code get
> executed? (but I read the M2V-MX SE dsdt source file, and didn't find
> anything related to power button.) Will the event go to the BIOS
> first? Then go to the OS? Or it is completely handled by OS?
Check ICH7 sleepstates.asl and fadt.c Some values are taken from there
to power off the machine.
Look at FILO source code or ich7 SMI code to see how that can be done
outside of ACPI.
> The problem I try to solve is to find out whether BIOS can get the
> button event before the OS and do something without OS.
If the OS is an ACPI OS, it will (usually) get the event through a SCI. If not, a
SMI can be caused and the SMI handler can handle the event. You could
possibly hack something like having POWERBTN cause a SMI, then do
something in the smi handler, then retrigger a SCI to the OS. It seems
like the wrong thing though. If you want to execute "BIOS" code in the
OS context, put it into the DSDT, or even better just put it in user
land to begin with.
> Also, for the power button override event, it is completely handled by
> hardware, right? Is it possible to trigger this event from the BIOS?
Yes, that is done in hardware. You can catch a power press in SMM and
just switch the machine off immediately. In the ICH7 code this is done
when ACPI is not active.
More information about the coreboot