iPXE
|
ACPI power off. More...
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include <ipxe/acpi.h>
#include <ipxe/acpipwr.h>
Go to the source code of this file.
Macros | |
#define | colour FADT_SIGNATURE |
Colour for debug messages. More... | |
#define | S5_SIGNATURE ACPI_SIGNATURE ( '_', 'S', '5', '_' ) |
S5 signature More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | acpi_extract_sx (userptr_t zsdt, size_t len, size_t offset, void *data) |
Extract _Sx value from DSDT/SSDT. More... | |
int | acpi_poweroff (void) |
Power off the computer using ACPI. More... | |
ACPI power off.
Definition in file acpipwr.c.
#define colour FADT_SIGNATURE |
#define S5_SIGNATURE ACPI_SIGNATURE ( '_', 'S', '5', '_' ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Extract _Sx value from DSDT/SSDT.
zsdt | DSDT or SSDT |
len | Length of DSDT/SSDT |
offset | Offset of signature within DSDT/SSDT |
data | Data buffer |
rc | Return status code |
In theory, extracting the _Sx value from the DSDT/SSDT requires a full ACPI parser plus some heuristics to work around the various broken encodings encountered in real ACPI implementations.
In practice, we can get the same result by scanning through the DSDT/SSDT for the signature (e.g. "_S5_"), extracting the first four bytes, removing any bytes with bit 3 set, and treating whatever is left as a little-endian value. This is one of the uglier hacks I have ever implemented, but it's still prettier than the ACPI specification itself.
Definition at line 65 of file acpipwr.c.
References bytes, colour, copy_from_user(), data, DBGC, EINVAL, len, and offset.
Referenced by acpi_poweroff().
int acpi_poweroff | ( | void | ) |
Power off the computer using ACPI.
rc | Return status code |
Definition at line 113 of file acpipwr.c.
References acpi_extract(), acpi_extract_sx(), ACPI_PM1_CNT, ACPI_PM1_CNT_SLP_EN, ACPI_PM1_CNT_SLP_TYP, acpi_table(), colour, copy_from_user(), DBGC, ENOENT, EPROTO, FADT_SIGNATURE, le32_to_cpu, mdelay(), outw, acpi_fadt::pm1a_cnt_blk, acpi_fadt::pm1b_cnt_blk, rc, S5_SIGNATURE, and strerror().
Referenced by bios_poweroff().