ACPI: Fix AppleSMC _STA size

Minimize the storage used for AppleSMC's _STA (8bit), relying on ASL
to implicitly convert it to the officially specified 32bit value.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Gabriel L. Somlo 2014-01-13 15:27:13 -05:00 committed by Michael S. Tsirkin
parent 15bce1b7c5
commit 8977557ae4
2 changed files with 7 additions and 8 deletions

View file

@ -81,7 +81,7 @@ typedef struct AcpiMiscInfo {
static void acpi_get_dsdt(AcpiMiscInfo *info) static void acpi_get_dsdt(AcpiMiscInfo *info)
{ {
unsigned short applesmc_sta_val, *applesmc_sta_off; uint16_t *applesmc_sta;
Object *piix = piix4_pm_find(); Object *piix = piix4_pm_find();
Object *lpc = ich9_lpc_find(); Object *lpc = ich9_lpc_find();
assert(!!piix != !!lpc); assert(!!piix != !!lpc);
@ -89,18 +89,17 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)
if (piix) { if (piix) {
info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_code = AcpiDsdtAmlCode;
info->dsdt_size = sizeof AcpiDsdtAmlCode; info->dsdt_size = sizeof AcpiDsdtAmlCode;
applesmc_sta_off = piix_dsdt_applesmc_sta; applesmc_sta = piix_dsdt_applesmc_sta;
} }
if (lpc) { if (lpc) {
info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_code = Q35AcpiDsdtAmlCode;
info->dsdt_size = sizeof Q35AcpiDsdtAmlCode; info->dsdt_size = sizeof Q35AcpiDsdtAmlCode;
applesmc_sta_off = q35_dsdt_applesmc_sta; applesmc_sta = q35_dsdt_applesmc_sta;
} }
/* Patch in appropriate value for AppleSMC _STA */ /* Patch in appropriate value for AppleSMC _STA */
applesmc_sta_val = applesmc_find() ? 0x0b : 0x00; *(uint8_t *)(info->dsdt_code + *applesmc_sta) =
*(uint16_t *)(info->dsdt_code + *applesmc_sta_off) = applesmc_find() ? 0x0b : 0x00;
cpu_to_le16(applesmc_sta_val);
} }
static static

View file

@ -19,8 +19,8 @@ Scope(\_SB.PCI0.ISA) {
Device (SMC) { Device (SMC) {
Name(_HID, EisaId("APP0001")) Name(_HID, EisaId("APP0001"))
/* _STA will be patched to 0x0B if AppleSMC is present */ /* _STA will be patched to 0x0B if AppleSMC is present */
ACPI_EXTRACT_NAME_WORD_CONST DSDT_APPLESMC_STA ACPI_EXTRACT_NAME_BYTE_CONST DSDT_APPLESMC_STA
Name(_STA, 0xFF00) Name(_STA, 0xF0)
Name(_CRS, ResourceTemplate () { Name(_CRS, ResourceTemplate () {
IO (Decode16, 0x0300, 0x0300, 0x01, 0x20) IO (Decode16, 0x0300, 0x0300, 0x01, 0x20)
IRQNoFlags() { 6 } IRQNoFlags() { 6 }