Commit 15bce1b7 authored by Gabriel L. Somlo's avatar Gabriel L. Somlo Committed by Michael S. Tsirkin
Browse files

Add DSDT node for AppleSMC



AppleSMC (-device isa-applesmc) is required to boot OS X guests.
OS X expects a SMC node to be present in the ACPI DSDT. This patch
adds a SMC node to the DSDT, and dynamically patches the return value
of SMC._STA to either 0x0B if the chip is present, or otherwise to 0x00,
before booting the guest.

Signed-off-by: default avatarGabriel Somlo <somlo@cmu.edu>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 3e16d14f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "hw/nvram/fw_cfg.h"
#include "bios-linker-loader.h"
#include "hw/loader.h"
#include "hw/isa/isa.h"

/* Supported chipsets: */
#include "hw/acpi/piix4.h"
@@ -80,6 +81,7 @@ typedef struct AcpiMiscInfo {

static void acpi_get_dsdt(AcpiMiscInfo *info)
{
    unsigned short applesmc_sta_val, *applesmc_sta_off;
    Object *piix = piix4_pm_find();
    Object *lpc = ich9_lpc_find();
    assert(!!piix != !!lpc);
@@ -87,11 +89,18 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)
    if (piix) {
        info->dsdt_code = AcpiDsdtAmlCode;
        info->dsdt_size = sizeof AcpiDsdtAmlCode;
        applesmc_sta_off = piix_dsdt_applesmc_sta;
    }
    if (lpc) {
        info->dsdt_code = Q35AcpiDsdtAmlCode;
        info->dsdt_size = sizeof Q35AcpiDsdtAmlCode;
        applesmc_sta_off = q35_dsdt_applesmc_sta;
    }

    /* Patch in appropriate value for AppleSMC _STA */
    applesmc_sta_val = applesmc_find() ? 0x0b : 0x00;
    *(uint16_t *)(info->dsdt_code + *applesmc_sta_off) =
        cpu_to_le16(applesmc_sta_val);
}

static
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,17 @@
/* Common legacy ISA style devices. */
Scope(\_SB.PCI0.ISA) {

    Device (SMC) {
        Name(_HID, EisaId("APP0001"))
        /* _STA will be patched to 0x0B if AppleSMC is present */
        ACPI_EXTRACT_NAME_WORD_CONST DSDT_APPLESMC_STA
        Name(_STA, 0xFF00)
        Name(_CRS, ResourceTemplate () {
            IO (Decode16, 0x0300, 0x0300, 0x01, 0x20)
            IRQNoFlags() { 6 }
        })
    }

    Device(RTC) {
        Name(_HID, EisaId("PNP0B00"))
        Name(_CRS, ResourceTemplate() {
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ DefinitionBlock (
        }
    }

#define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta
#include "acpi-dsdt-isa.dsl"


+1 −0
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ DefinitionBlock (
        }
    }

#define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
#include "acpi-dsdt-isa.dsl"


+0 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ struct AppleSMCData {
    QLIST_ENTRY(AppleSMCData) node;
};

#define TYPE_APPLE_SMC "isa-applesmc"
#define APPLE_SMC(obj) OBJECT_CHECK(AppleSMCState, (obj), TYPE_APPLE_SMC)

typedef struct AppleSMCState AppleSMCState;
Loading