VBoxAcpi.cpp revision ec7708c74d7fc8feb18fbe1f84b320ec86fb11ef
616c4e73368513b3c835881ff9f2386083afad01vboxsync * VBoxAcpi - VirtualBox ACPI maniputation functionality.
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * available from http://www.virtualbox.org. This file is free software;
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * you can redistribute it and/or modify it under the terms of the GNU
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * General Public License (GPL) as published by the Free Software
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * additional information or have any questions.
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync#if !defined(IN_RING3)
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync/* vbox.dsl - input to generate proper DSDT on the fly */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/* Statically compiled AML */
ecb074924ed761fe89e91113482db5b7374441b0vboxsyncstatic int patchAml(PPDMDEVINS pDevIns, uint8_t* pAml, size_t uAmlLen)
ecb074924ed761fe89e91113482db5b7374441b0vboxsync rc = CFGMR3QueryU16Def(pDevIns->pCfg, "NumCPUs", &cNumCpus, 1);
3854599844436d009da0f32760d657fc7690a5a8vboxsync /* Clear CPU objects at all, if needed */
3854599844436d009da0f32760d657fc7690a5a8vboxsync rc = CFGMR3QueryBoolDef(pDevIns->pCfg, "ShowCpu", &fShowCpu, false);
616c4e73368513b3c835881ff9f2386083afad01vboxsync * Now search AML for:
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * AML_PROCESSOR_OP (UINT16) 0x5b83
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * and replace whole block with
3854599844436d009da0f32760d657fc7690a5a8vboxsync * AML_NOOP_OP (UINT16) 0xa3
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * for VCPU not configured
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * AML_PROCESSOR_OP
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * DefProcessor := ProcessorOp PkgLength NameString ProcID
ecb074924ed761fe89e91113482db5b7374441b0vboxsync PblkAddr PblkLen ObjectList
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * ProcessorOp := ExtOpPrefix 0x83
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * ProcID := ByteData
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * PblkAddr := DwordData
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * PblkLen := ByteData
3854599844436d009da0f32760d657fc7690a5a8vboxsync /* false alarm, not named starting CP */
ecb074924ed761fe89e91113482db5b7374441b0vboxsync /* Processor ID */
616c4e73368513b3c835881ff9f2386083afad01vboxsync /* Will fill unwanted CPU block with NOOPs */
ecb074924ed761fe89e91113482db5b7374441b0vboxsync * See 18.2.4 Package Length Encoding in ACPI spec
616c4e73368513b3c835881ff9f2386083afad01vboxsync * for full format
ecb074924ed761fe89e91113482db5b7374441b0vboxsync ("So far, we only understand simple package length"));
ecb074924ed761fe89e91113482db5b7374441b0vboxsync /* including AML_PROCESSOR_OP itself */
ecb074924ed761fe89e91113482db5b7374441b0vboxsync /* Can increase i by cBytes + 1, but not really worth it */
ecb074924ed761fe89e91113482db5b7374441b0vboxsync /* now recompute checksum, whole file byte sum must be 0 */
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync/* Two only public functions */
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsyncint acpiPrepareDsdt(PPDMDEVINS pDevIns, void * *ppPtr, size_t *puDsdtLen)
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync return prepareDynamicDsdt(pDevIns, ppPtr, puDsdtLen);
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync int rc = CFGMR3QueryStringAlloc(pDevIns->pCfg, "AmlFilePath", &pszAmlFilePath);
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /* Load from file. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync rc = RTFileOpen(&FileAml, pszAmlFilePath, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * An AML file contains the raw DSDT thus the size of the file
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * is equal to the size of the DSDT.
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync /* Don't use AML files over 4GB ;) */
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync rc = RTFileReadAt(FileAml, 0, pbAmlCode, cbAmlCode, NULL);
7f8a04081173dbe3c72bddd0ffeb237e7f9070b0vboxsync * We fail if reading failed or the identifier at the
616c4e73368513b3c835881ff9f2386083afad01vboxsync * beginning is wrong.
return rc;
#ifdef VBOX_WITH_DYNAMIC_DSDT
if (pbAmlCodeDsdt)
return rc;
#ifdef VBOX_WITH_DYNAMIC_DSDT
if (pPtr)
return VINF_SUCCESS;
bool fCpuHotPlug = false;
return rc;
if (fCpuHotPlug)
if (pbAmlCodeSsdt)
return VINF_SUCCESS;
if (pPtr)
return VINF_SUCCESS;