From 80377d9af5201fe454909421747e1cbf86d036b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 14 Sep 2009 22:18:58 +0000 Subject: [PATCH] merging acpica-20090903 into trunk git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33140 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/bus_managers/acpi/Jamfile | 12 +- .../kernel/bus_managers/acpi/acpi_busman.c | 9 +- .../kernel/bus_managers/acpi/common/a16find.c | 962 ------------- .../bus_managers/acpi/common/a16utils.asm | 915 ------------ .../bus_managers/acpi/common/a16utils.obj | Bin 2665 -> 0 bytes .../kernel/bus_managers/acpi/common/adfile.c | 21 +- .../kernel/bus_managers/acpi/common/adisasm.c | 159 ++- .../kernel/bus_managers/acpi/common/adwalk.c | 91 +- .../bus_managers/acpi/common/dmrestag.c | 19 +- .../kernel/bus_managers/acpi/common/dmtable.c | 174 ++- .../bus_managers/acpi/common/dmtbdump.c | 446 +++++- .../bus_managers/acpi/common/dmtbinfo.c | 553 +++++++- .../kernel/bus_managers/acpi/common/getopt.c | 6 +- .../bus_managers/acpi/compiler/Makefile | 3 + .../bus_managers/acpi/compiler/aslanalyze.c | 73 +- .../bus_managers/acpi/compiler/aslcodegen.c | 39 +- .../bus_managers/acpi/compiler/aslcompile.c | 15 +- .../bus_managers/acpi/compiler/aslcompiler.h | 12 +- .../bus_managers/acpi/compiler/aslcompiler.l | 7 +- .../bus_managers/acpi/compiler/asldefine.h | 7 +- .../bus_managers/acpi/compiler/aslerror.c | 8 +- .../bus_managers/acpi/compiler/aslfiles.c | 214 ++- .../bus_managers/acpi/compiler/aslfold.c | 5 +- .../bus_managers/acpi/compiler/aslglobal.h | 7 +- .../bus_managers/acpi/compiler/asllength.c | 3 +- .../bus_managers/acpi/compiler/asllisting.c | 9 +- .../bus_managers/acpi/compiler/aslload.c | 178 ++- .../bus_managers/acpi/compiler/asllookup.c | 42 +- .../bus_managers/acpi/compiler/aslmain.c | 276 +++- .../bus_managers/acpi/compiler/aslmap.c | 42 +- .../bus_managers/acpi/compiler/aslopcodes.c | 3 +- .../bus_managers/acpi/compiler/asloperands.c | 3 +- .../bus_managers/acpi/compiler/aslopt.c | 11 +- .../bus_managers/acpi/compiler/aslresource.c | 3 +- .../bus_managers/acpi/compiler/aslrestype1.c | 3 +- .../bus_managers/acpi/compiler/aslrestype2.c | 28 +- .../bus_managers/acpi/compiler/aslstartup.c | 10 +- .../bus_managers/acpi/compiler/aslstubs.c | 35 +- .../bus_managers/acpi/compiler/asltransform.c | 5 +- .../bus_managers/acpi/compiler/asltree.c | 3 +- .../bus_managers/acpi/compiler/asltypes.h | 25 +- .../bus_managers/acpi/compiler/aslutils.c | 3 +- .../bus_managers/acpi/debugger/dbcmds.c | 329 ++++- .../bus_managers/acpi/debugger/dbdisply.c | 62 +- .../bus_managers/acpi/debugger/dbexec.c | 57 +- .../bus_managers/acpi/debugger/dbfileio.c | 16 +- .../bus_managers/acpi/debugger/dbhistry.c | 4 +- .../bus_managers/acpi/debugger/dbinput.c | 20 +- .../bus_managers/acpi/debugger/dbstats.c | 10 +- .../bus_managers/acpi/debugger/dbutils.c | 4 +- .../bus_managers/acpi/debugger/dbxface.c | 8 +- .../bus_managers/acpi/disassembler/dmbuffer.c | 10 +- .../bus_managers/acpi/disassembler/dmnames.c | 6 +- .../bus_managers/acpi/disassembler/dmobject.c | 79 +- .../bus_managers/acpi/disassembler/dmopcode.c | 4 +- .../bus_managers/acpi/disassembler/dmresrc.c | 4 +- .../bus_managers/acpi/disassembler/dmresrcl.c | 6 +- .../bus_managers/acpi/disassembler/dmresrcs.c | 4 +- .../bus_managers/acpi/disassembler/dmutils.c | 4 +- .../bus_managers/acpi/disassembler/dmwalk.c | 92 +- .../bus_managers/acpi/dispatcher/dsfield.c | 22 +- .../bus_managers/acpi/dispatcher/dsinit.c | 19 +- .../bus_managers/acpi/dispatcher/dsmethod.c | 24 +- .../bus_managers/acpi/dispatcher/dsmthdat.c | 97 +- .../bus_managers/acpi/dispatcher/dsobject.c | 82 +- .../bus_managers/acpi/dispatcher/dsopcode.c | 97 +- .../bus_managers/acpi/dispatcher/dsutils.c | 6 +- .../bus_managers/acpi/dispatcher/dswexec.c | 20 +- .../bus_managers/acpi/dispatcher/dswload.c | 43 +- .../bus_managers/acpi/dispatcher/dswscope.c | 4 +- .../bus_managers/acpi/dispatcher/dswstate.c | 8 +- .../kernel/bus_managers/acpi/events/evevent.c | 37 +- .../kernel/bus_managers/acpi/events/evgpe.c | 70 +- .../bus_managers/acpi/events/evgpeblk.c | 122 +- .../kernel/bus_managers/acpi/events/evmisc.c | 71 +- .../bus_managers/acpi/events/evregion.c | 154 +- .../bus_managers/acpi/events/evrgnini.c | 113 +- .../kernel/bus_managers/acpi/events/evsci.c | 14 +- .../kernel/bus_managers/acpi/events/evxface.c | 14 +- .../bus_managers/acpi/events/evxfevnt.c | 224 ++- .../bus_managers/acpi/events/evxfregn.c | 7 +- .../bus_managers/acpi/executer/exconfig.c | 168 ++- .../bus_managers/acpi/executer/exconvrt.c | 48 +- .../bus_managers/acpi/executer/excreate.c | 6 +- .../bus_managers/acpi/executer/exdump.c | 180 +-- .../bus_managers/acpi/executer/exfield.c | 103 +- .../bus_managers/acpi/executer/exfldio.c | 49 +- .../bus_managers/acpi/executer/exmisc.c | 32 +- .../bus_managers/acpi/executer/exmutex.c | 45 +- .../bus_managers/acpi/executer/exnames.c | 4 +- .../bus_managers/acpi/executer/exoparg1.c | 38 +- .../bus_managers/acpi/executer/exoparg2.c | 10 +- .../bus_managers/acpi/executer/exoparg3.c | 8 +- .../bus_managers/acpi/executer/exoparg6.c | 4 +- .../bus_managers/acpi/executer/exprep.c | 6 +- .../bus_managers/acpi/executer/exregion.c | 8 +- .../bus_managers/acpi/executer/exresnte.c | 27 +- .../bus_managers/acpi/executer/exresolv.c | 71 +- .../bus_managers/acpi/executer/exresop.c | 67 +- .../bus_managers/acpi/executer/exstore.c | 81 +- .../bus_managers/acpi/executer/exstoren.c | 21 +- .../bus_managers/acpi/executer/exstorob.c | 18 +- .../bus_managers/acpi/executer/exsystem.c | 4 +- .../bus_managers/acpi/executer/exutils.c | 65 +- .../bus_managers/acpi/hardware/hwacpi.c | 13 +- .../kernel/bus_managers/acpi/hardware/hwgpe.c | 64 +- .../bus_managers/acpi/hardware/hwregs.c | 954 +++++-------- .../bus_managers/acpi/hardware/hwsleep.c | 245 ++-- .../bus_managers/acpi/hardware/hwtimer.c | 6 +- .../bus_managers/acpi/hardware/hwvalid.c | 424 ++++++ .../bus_managers/acpi/hardware/hwxface.c | 710 ++++++++++ .../kernel/bus_managers/acpi/include/acapps.h | 12 +- .../bus_managers/acpi/include/accommon.h | 136 ++ .../bus_managers/acpi/include/acconfig.h | 43 +- .../bus_managers/acpi/include/acdebug.h | 10 +- .../bus_managers/acpi/include/acdisasm.h | 46 +- .../bus_managers/acpi/include/acdispat.h | 9 +- .../bus_managers/acpi/include/acevents.h | 11 +- .../bus_managers/acpi/include/acexcep.h | 140 +- .../bus_managers/acpi/include/acglobal.h | 59 +- .../bus_managers/acpi/include/achware.h | 70 +- .../bus_managers/acpi/include/acinterp.h | 13 +- .../bus_managers/acpi/include/aclocal.h | 285 ++-- .../bus_managers/acpi/include/acmacros.h | 137 +- .../bus_managers/acpi/include/acnames.h | 3 +- .../bus_managers/acpi/include/acnamesp.h | 65 +- .../bus_managers/acpi/include/acobject.h | 46 +- .../bus_managers/acpi/include/acopcode.h | 3 +- .../bus_managers/acpi/include/acoutput.h | 142 +- .../bus_managers/acpi/include/acparser.h | 4 +- .../kernel/bus_managers/acpi/include/acpi.h | 35 +- .../bus_managers/acpi/include/acpiosxf.h | 21 +- .../kernel/bus_managers/acpi/include/acpixf.h | 176 ++- .../bus_managers/acpi/include/acpredef.h | 598 ++++++++ .../bus_managers/acpi/include/acresrc.h | 3 +- .../bus_managers/acpi/include/acrestyp.h | 544 ++++++++ .../bus_managers/acpi/include/acstruct.h | 3 +- .../bus_managers/acpi/include/actables.h | 16 +- .../kernel/bus_managers/acpi/include/actbl.h | 174 ++- .../kernel/bus_managers/acpi/include/actbl1.h | 1061 ++++---------- .../kernel/bus_managers/acpi/include/actbl2.h | 1007 +++++++++++++- .../bus_managers/acpi/include/actypes.h | 771 ++++------ .../bus_managers/acpi/include/acutils.h | 142 +- .../bus_managers/acpi/include/amlcode.h | 6 +- .../bus_managers/acpi/include/amlresrc.h | 3 +- .../16bit.h => include/platform/accygwin.h} | 82 +- .../acpi/include/platform/acefi.h | 3 +- .../acpi/include/platform/acenv.h | 326 +++-- .../acpi/include/platform/acfreebsd.h | 76 +- .../acpi/include/platform/acgcc.h | 4 +- .../acpi/include/platform/achaiku.h | 2 +- .../acpi/include/platform/acintel.h | 3 +- .../acpi/include/platform/aclinux.h | 79 +- .../acpi/include/platform/acmsvc.h | 3 +- .../acpi/include/platform/acnetbsd.h | 5 +- .../acpi/include/platform/acos2.h | 172 +++ .../acpi/include/platform/acwin.h | 11 +- .../acpi/include/platform/acwin64.h | 9 +- .../bus_managers/acpi/namespace/nsaccess.c | 67 +- .../bus_managers/acpi/namespace/nsalloc.c | 118 +- .../bus_managers/acpi/namespace/nsdump.c | 60 +- .../bus_managers/acpi/namespace/nsdumpdv.c | 3 +- .../bus_managers/acpi/namespace/nseval.c | 217 ++- .../bus_managers/acpi/namespace/nsinit.c | 39 +- .../bus_managers/acpi/namespace/nsload.c | 11 +- .../bus_managers/acpi/namespace/nsnames.c | 52 +- .../bus_managers/acpi/namespace/nsobject.c | 34 +- .../bus_managers/acpi/namespace/nsparse.c | 10 +- .../bus_managers/acpi/namespace/nspredef.c | 1237 +++++++++++++++++ .../bus_managers/acpi/namespace/nsrepair.c | 291 ++++ .../bus_managers/acpi/namespace/nssearch.c | 31 +- .../bus_managers/acpi/namespace/nsutils.c | 44 +- .../bus_managers/acpi/namespace/nswalk.c | 85 +- .../bus_managers/acpi/namespace/nsxfeval.c | 136 +- .../bus_managers/acpi/namespace/nsxfname.c | 416 +++++- .../bus_managers/acpi/namespace/nsxfobj.c | 13 +- .../kernel/bus_managers/acpi/oshaiku.c | 29 +- .../kernel/bus_managers/acpi/parser/psargs.c | 4 +- .../kernel/bus_managers/acpi/parser/psloop.c | 133 +- .../bus_managers/acpi/parser/psopcode.c | 4 +- .../kernel/bus_managers/acpi/parser/psparse.c | 45 +- .../kernel/bus_managers/acpi/parser/psscope.c | 4 +- .../kernel/bus_managers/acpi/parser/pstree.c | 4 +- .../kernel/bus_managers/acpi/parser/psutils.c | 4 +- .../kernel/bus_managers/acpi/parser/pswalk.c | 4 +- .../kernel/bus_managers/acpi/parser/psxface.c | 44 +- .../bus_managers/acpi/resources/rsaddr.c | 4 +- .../bus_managers/acpi/resources/rscalc.c | 24 +- .../bus_managers/acpi/resources/rscreate.c | 24 +- .../bus_managers/acpi/resources/rsdump.c | 4 +- .../bus_managers/acpi/resources/rsinfo.c | 4 +- .../kernel/bus_managers/acpi/resources/rsio.c | 4 +- .../bus_managers/acpi/resources/rsirq.c | 4 +- .../bus_managers/acpi/resources/rslist.c | 4 +- .../bus_managers/acpi/resources/rsmemory.c | 4 +- .../bus_managers/acpi/resources/rsmisc.c | 4 +- .../bus_managers/acpi/resources/rsutils.c | 4 +- .../bus_managers/acpi/resources/rsxface.c | 8 +- .../kernel/bus_managers/acpi/tables/tbfadt.c | 449 ++++-- .../kernel/bus_managers/acpi/tables/tbfind.c | 4 +- .../bus_managers/acpi/tables/tbinstal.c | 100 +- .../kernel/bus_managers/acpi/tables/tbutils.c | 227 ++- .../kernel/bus_managers/acpi/tables/tbxface.c | 89 +- .../bus_managers/acpi/tables/tbxfroot.c | 9 +- .../bus_managers/acpi/utilities/utalloc.c | 72 +- .../bus_managers/acpi/utilities/utcache.c | 12 +- .../bus_managers/acpi/utilities/utclib.c | 4 +- .../bus_managers/acpi/utilities/utcopy.c | 100 +- .../bus_managers/acpi/utilities/utdebug.c | 43 +- .../bus_managers/acpi/utilities/utdelete.c | 45 +- .../bus_managers/acpi/utilities/uteval.c | 481 ++----- .../bus_managers/acpi/utilities/utglobal.c | 99 +- .../bus_managers/acpi/utilities/utids.c | 497 +++++++ .../bus_managers/acpi/utilities/utinit.c | 28 +- .../bus_managers/acpi/utilities/utlock.c | 277 ++++ .../bus_managers/acpi/utilities/utmath.c | 4 +- .../bus_managers/acpi/utilities/utmisc.c | 135 +- .../bus_managers/acpi/utilities/utmutex.c | 57 +- .../bus_managers/acpi/utilities/utobject.c | 40 +- .../bus_managers/acpi/utilities/utresrc.c | 4 +- .../bus_managers/acpi/utilities/utstate.c | 6 +- .../bus_managers/acpi/utilities/uttrack.c | 4 +- .../bus_managers/acpi/utilities/utxface.c | 57 +- 223 files changed, 14831 insertions(+), 7697 deletions(-) delete mode 100644 src/add-ons/kernel/bus_managers/acpi/common/a16find.c delete mode 100644 src/add-ons/kernel/bus_managers/acpi/common/a16utils.asm delete mode 100644 src/add-ons/kernel/bus_managers/acpi/common/a16utils.obj create mode 100644 src/add-ons/kernel/bus_managers/acpi/hardware/hwvalid.c create mode 100644 src/add-ons/kernel/bus_managers/acpi/hardware/hwxface.c create mode 100644 src/add-ons/kernel/bus_managers/acpi/include/accommon.h create mode 100644 src/add-ons/kernel/bus_managers/acpi/include/acpredef.h create mode 100644 src/add-ons/kernel/bus_managers/acpi/include/acrestyp.h rename src/add-ons/kernel/bus_managers/acpi/{common/16bit.h => include/platform/accygwin.h} (84%) create mode 100644 src/add-ons/kernel/bus_managers/acpi/include/platform/acos2.h create mode 100644 src/add-ons/kernel/bus_managers/acpi/namespace/nspredef.c create mode 100644 src/add-ons/kernel/bus_managers/acpi/namespace/nsrepair.c create mode 100644 src/add-ons/kernel/bus_managers/acpi/utilities/utids.c create mode 100644 src/add-ons/kernel/bus_managers/acpi/utilities/utlock.c diff --git a/src/add-ons/kernel/bus_managers/acpi/Jamfile b/src/add-ons/kernel/bus_managers/acpi/Jamfile index 7194df38ef..073c6fc1ee 100644 --- a/src/add-ons/kernel/bus_managers/acpi/Jamfile +++ b/src/add-ons/kernel/bus_managers/acpi/Jamfile @@ -25,6 +25,8 @@ local hardware_src = hwregs.c hwsleep.c hwtimer.c + hwvalid.c + hwxface.c ; local debugger_src = @@ -99,6 +101,8 @@ local namespace_src = nsnames.c nsobject.c nsparse.c + nspredef.c + nsrepair.c nssearch.c nsutils.c nswalk.c @@ -140,7 +144,9 @@ local utilities_src = utdelete.c uteval.c utglobal.c + utids.c utinit.c + utlock.c utmath.c utmisc.c utmutex.c @@ -165,13 +171,13 @@ StaticLibrary libacpi_ca.a : # this is a workaround for an optimization bug in our GCC4 with -O1 and -O2, this should be dropped when we upgrade -oldOPTIM = $(OPTIM) ; -OPTIM = -O3 ; +#oldOPTIM = $(OPTIM) ; +#OPTIM = -O3 ; StaticLibrary libacpi_ca.a : tbutils.c ; -OPTIM = $(oldOPTIM) ; +#OPTIM = $(oldOPTIM) ; SEARCH on [ FGristFiles $(events_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi events ] ; SEARCH on [ FGristFiles $(hardware_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi hardware ] ; diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c b/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c index 5aa23a63c9..83d24253cc 100644 --- a/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c +++ b/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c @@ -20,7 +20,7 @@ #include #include "acpi.h" -#include "acpixf.h" +#include "accommon.h" #include "acpi_priv.h" //#define TRACE_ACPI_BUS @@ -32,6 +32,7 @@ #define ERROR(x...) dprintf("acpi: " x) +#define ACPI_DEVICE_ID_LENGTH 0x08 extern pci_module_info* gPCIManager; @@ -541,11 +542,11 @@ reboot(void) TRACE("reboot\n"); - if (AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER == 0) + if ((AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) == 0) return B_UNSUPPORTED; - status = AcpiHwLowLevelWrite(AcpiGbl_FADT.ResetRegister.BitWidth, - AcpiGbl_FADT.ResetValue, &AcpiGbl_FADT.ResetRegister); + status = AcpiWrite(AcpiGbl_FADT.ResetValue, + &AcpiGbl_FADT.ResetRegister); if (status != AE_OK) { ERROR("Reset failed, status = %d\n", status); diff --git a/src/add-ons/kernel/bus_managers/acpi/common/a16find.c b/src/add-ons/kernel/bus_managers/acpi/common/a16find.c deleted file mode 100644 index 07675a2677..0000000000 --- a/src/add-ons/kernel/bus_managers/acpi/common/a16find.c +++ /dev/null @@ -1,962 +0,0 @@ -/****************************************************************************** - * - * Module Name: a16find - 16-bit (real mode) routines to find ACPI - * tables in memory - * $Revision: 1.43 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include -#include -#include -#include "acpi.h" -#include "amlcode.h" -#include "acparser.h" -#include "actables.h" - -#include "16bit.h" - - -#define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("a16find") - -/* - * This module finds ACPI tables located in memory. - * It is only generated for the 16-bit (real-mode) version of the utility. - */ - -#define ACPI_TABLE_FILE_SUFFIX ".dat" - - -#if ACPI_MACHINE_WIDTH == 16 - -UINT32 ACPI_INTERNAL_VAR_XFACE dIn32 (UINT16 port); -void ACPI_INTERNAL_VAR_XFACE vOut32 (UINT16 port, UINT32 Val); -#define ACPI_ENABLE_HPET 0x00020000 - -char FilenameBuf[20]; -ACPI_TABLE_HEADER AcpiTblHeader; -UINT32 TableSize; - -UINT32 AcpiGbl_SystemFlags; -UINT32 AcpiGbl_RsdpOriginalLocation; - -#if 0 -/****************************************************************************** - * - * FUNCTION: AfWriteBuffer - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Open a file and write out a single buffer - * - ******************************************************************************/ - -ACPI_NATIVE_INT -AfWriteBuffer ( - char *Filename, - char *Buffer, - UINT32 Length) -{ - FILE *fp; - ACPI_NATIVE_INT Actual; - - - fp = fopen (Filename, "wb"); - if (!fp) - { - printf ("Couldn't open %s\n", Filename); - return -1; - } - - Actual = fwrite (Buffer, (size_t) Length, 1, fp); - fclose (fp); - return Actual; -} - - -/****************************************************************************** - * - * FUNCTION: AfGenerateFilename - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Build an output filename from an ACPI table ID string - * - ******************************************************************************/ - -char * -AfGenerateFilename (char *TableId) -{ - UINT16 i; - - - for (i = 0; i < 8 && TableId[i] != ' ' && TableId[i] != 0; i++) - { - FilenameBuf [i] = TableId[i]; - } - - FilenameBuf [i] = 0; - strcat (FilenameBuf, ACPI_TABLE_FILE_SUFFIX); - return FilenameBuf; -} - - -/****************************************************************************** - * - * FUNCTION: AfDumpTables - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Dump the loaded tables to a file (or files) - * - ******************************************************************************/ - -void -AfDumpTables (void) -{ - char *Filename; - - - if (!AcpiGbl_DSDT) - { - AcpiOsPrintf ("No DSDT!\n"); - return; - } - - - Filename = AfGenerateFilename (AcpiGbl_DSDT->OemTableId); - AfWriteBuffer (Filename, - (char *) AcpiGbl_DSDT, AcpiGbl_DSDT->Length); - - AcpiOsPrintf ("DSDT AML written to \"%s\"\n", Filename); -} - -#endif - -void pascal -cprint ( - UINT32 value) -{ - - AcpiOsPrintf ("Seq: 0x%8.8X\n", value); -} - - -/****************************************************************************** - * - * FUNCTION: CopyExtendedToReal - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Copy memory above 1meg - * - ******************************************************************************/ - -int -CopyExtendedToReal ( - void *Destination, - UINT32 PhysicalSource, - UINT32 Size) -{ - int RetVal; - - - RetVal = FlatMove32 (GET_PHYSICAL_ADDRESS (Destination), - PhysicalSource, (UINT16) Size); - - AcpiOsPrintf ("FlatMove return: 0x%hX From %X To %X Len %X\n", - (int) RetVal, PhysicalSource, GET_PHYSICAL_ADDRESS (Destination), Size); - return (RetVal); -} - - -/****************************************************************************** - * - * FUNCTION: AfFindRsdp - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Scan memory to find the RSDP - * - ******************************************************************************/ - -BOOLEAN -AfFindRsdp (RSDP_DESCRIPTOR **RSDP) -{ - PTR_OVL Rove; - - - PTR_OVL_BUILD_PTR (Rove, 0, 0); - - - /* Scan low memory */ - - do - { - if (strncmp (Rove.ptr, ACPI_SIG_RSDP, (size_t) 8) == 0) - { - - /* TBD: Checksum check is invalid for X descriptor */ - -/* if (AcpiTbSumTable (Rove.ptr, sizeof(RSDP_DESCRIPTOR)) != 0) - { - */ - AcpiOsPrintf ("RSDP found at %p (Lo block)\n", Rove.ptr); - *RSDP = Rove.ptr; - return (TRUE); - } - - Rove.ovl.base++; - } - while (Rove.ovl.base < 0x3F); - - /* Scan high memory */ - - PTR_OVL_BUILD_PTR (Rove, 0xE000, 0); - do - { - if (strncmp (Rove.ptr, ACPI_SIG_RSDP, (size_t) 8) == 0) - { - AcpiOsPrintf ("RSDP found at %p (Hi block)\n", Rove.ptr); - *RSDP = Rove.ptr; - return (TRUE); - } - - Rove.ovl.base++; - } - while (Rove.ovl.base < 0xFFFF); - - return (FALSE); -} - - -/****************************************************************************** - * - * FUNCTION: AfRecognizeTable - * - * PARAMETERS: TablePtr - Input buffer pointer, optional - * TableInfo - Return value from AcpiTbGetTable - * - * RETURN: Status - * - * DESCRIPTION: Check a table signature for a match against known table types - * - ******************************************************************************/ - -ACPI_STATUS -AfRecognizeTable ( - char *TablePtr, - UINT32 PhysAddr, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_TABLE_HEADER *TableHeader; - ACPI_STATUS Status; - ACPI_TABLE_TYPE TableType = 0; - void **TableGlobalPtr; - UINT32 i; - - - ACPI_FUNCTION_TRACE (AfRecognizeTable); - - - /* Ensure that we have a valid table pointer */ - - TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer; - if (!TableHeader) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Search for a signature match among the known table types */ - - Status = AE_SUPPORT; - for (i = 1; i < NUM_ACPI_TABLE_TYPES; i++) /* Start at one -> Skip RSDP */ - { - if (!ACPI_STRNCMP (TableHeader->Signature, - AcpiGbl_TableData[i].Signature, - AcpiGbl_TableData[i].SigLength)) - { - AcpiOsPrintf ("Found table [%s] Length 0x%X\n", - AcpiGbl_TableData[i].Signature, (UINT32) TableHeader->Length); - - TableType = i; - TableGlobalPtr = AcpiGbl_TableData[i].GlobalPtr; - Status = AE_OK; - break; - } - } - - /* Return the table type via the info struct */ - - TableInfo->Type = (UINT8) TableType; - TableInfo->Length = (ACPI_SIZE) TableHeader->Length; - - /* - * An AE_SUPPORT means that the table was not recognized. - * We ignore this table; just print a debug message - */ - if (Status == AE_SUPPORT) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Unsupported table %s (Type %d) was found and discarded\n", - AcpiGbl_TableData[TableType].Name, (UINT32) TableType)); - - return_ACPI_STATUS (Status); - } - - Status = AcpiTbValidateTableHeader (TableHeader); - if (ACPI_FAILURE (Status)) - { - /* Table failed verification, map all errors to BAD_DATA */ - - ACPI_ERROR ((AE_INFO, - "Invalid table header found in table named %s (Type %d)", - AcpiGbl_TableData[TableType].Name, (UINT32) TableType)); - - return_ACPI_STATUS (AE_BAD_DATA); - } - - /* Now get the rest of the table */ - - *TableGlobalPtr = ACPI_ALLOCATE (AcpiTblHeader.Length); - if (!*TableGlobalPtr) - { - AcpiOsPrintf ( - "Could not allocate buffer for Acpi table of length 0x%X\n", - (UINT32) ((FACS_DESCRIPTOR *) &AcpiTblHeader)->Length); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - TableInfo->Pointer = *TableGlobalPtr; - - CopyExtendedToReal (*TableGlobalPtr, PhysAddr, AcpiTblHeader.Length); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s=%p, (TableGlobalPtr=%p)\n", - AcpiGbl_TableData[TableType].Signature, - *TableGlobalPtr, TableGlobalPtr)); - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer (*TableGlobalPtr, 48, 0, 0); - } - - /* - * Validate checksum for _most_ tables, - * even the ones whose signature we don't recognize - */ - if (TableType != ACPI_TABLE_FACS) - { - /* But don't abort if the checksum is wrong */ - /* TBD: make this a configuration option? */ - - AcpiTbVerifyTableChecksum (*TableGlobalPtr); - } - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AfGetAllTables - * - * PARAMETERS: Root - Root of the parse tree - * - * RETURN: None - * - * DESCRIPTION: - * - *****************************************************************************/ - -ACPI_STATUS -AfGetAllTables ( - UINT32 NumberOfTables, - char *TablePtr) -{ - ACPI_STATUS Status = AE_OK; - UINT32 Index; - ACPI_TABLE_DESC TableInfo; - - - ACPI_FUNCTION_TRACE (AfGetAllTables); - - - if (AcpiGbl_DbOpt_verbose) - { - AcpiOsPrintf ("Number of tables: %d\n", (UINT32) NumberOfTables); - } - - /* - * Loop through all table pointers found in RSDT. - * This will NOT include the FACS and DSDT - we must get - * them after the loop - */ - for (Index = 0; Index < NumberOfTables; Index++) - { - /* Get the table via the RSDT */ - - CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]), - sizeof (ACPI_TABLE_HEADER)); - - TableInfo.Pointer = &AcpiTblHeader; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Table pointer: %X\n", - (UINT32) ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]))); - - Status = AfRecognizeTable (NULL, ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]), &TableInfo); - if (ACPI_SUCCESS (Status)) - { - AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo); - } - - /* Ignore errors, just move on to next table */ - } - - if (!AcpiGbl_FADT) - { - AcpiOsPrintf ("FADT was not found, cannot obtain FACS and DSDT!\n"); - return (AE_NO_ACPI_TABLES); - } - - Status = AcpiTbConvertTableFadt (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Get the FACS - */ - CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), - sizeof (ACPI_TABLE_HEADER)); - AcpiGbl_FACS = ACPI_ALLOCATE (AcpiTblHeader.Length); - if (!AcpiGbl_FACS) - { - AcpiOsPrintf ("Could not allocate buffer for FADT length 0x%X\n", - (UINT32) AcpiTblHeader.Length); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - CopyExtendedToReal (AcpiGbl_FACS, ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), AcpiTblHeader.Length); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "FACS at %p (Phys %8.8X) length %X FADT at%p\n", - AcpiGbl_FACS, (UINT32) ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), - (UINT32) AcpiTblHeader.Length, AcpiGbl_FADT)); - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) AcpiGbl_FADT, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - TableInfo.Type = ACPI_TABLE_FADT; - TableInfo.Pointer = (void *) AcpiGbl_FADT; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - /* There is no checksum for the FACS, nothing to verify */ - - AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo); - - AcpiTbBuildCommonFacs (&TableInfo); - - /* - * Get the DSDT - */ - CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), sizeof (ACPI_TABLE_HEADER)); - AcpiGbl_DSDT = ACPI_ALLOCATE (AcpiTblHeader.Length); - if (!AcpiGbl_DSDT) - { - AcpiOsPrintf ("Could not allocate buffer for DSDT length 0x%X\n", (UINT32) AcpiTblHeader.Length); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - CopyExtendedToReal (AcpiGbl_DSDT, ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), AcpiTblHeader.Length); - - AcpiOsPrintf ("DSDT at %p (Phys %8.8X) length %X FADT at %p\n", - AcpiGbl_DSDT, (UINT32) ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), - (UINT32) AcpiTblHeader.Length, AcpiGbl_FADT); - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - TableInfo.Type = ACPI_TABLE_DSDT; - TableInfo.Pointer = (void *) AcpiGbl_DSDT; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo); - AcpiTbVerifyTableChecksum ((ACPI_TABLE_HEADER *) AcpiGbl_DSDT); - - return_ACPI_STATUS (AE_OK); -} - - -ACPI_STATUS -AfGetRsdt (void) -{ - BOOLEAN Found; - UINT32 PhysicalAddress; - UINT32 SignatureLength; - char *TableSignature; - ACPI_STATUS Status; - ACPI_TABLE_DESC TableInfo; - - - ACPI_FUNCTION_TRACE (AfGetRsdt); - - if (AcpiGbl_XSDT) - { - return (AE_OK); - } - - Found = AfFindRsdp (&AcpiGbl_RSDP); - if (!Found) - { - AcpiOsPrintf ("Could not find RSDP in the low megabyte\n"); - return (AE_NO_ACPI_TABLES); - } - - /* Use XSDT if it is present */ - - if ((AcpiGbl_RSDP->Revision >= 2) && - ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress)) - { - PhysicalAddress = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); - TableSignature = ACPI_SIG_XSDT; - SignatureLength = sizeof (ACPI_SIG_XSDT) -1; - AcpiGbl_RootTableType = ACPI_TABLE_TYPE_XSDT; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found XSDT\n")); - } - else - { - /* No XSDT, use the RSDT */ - - PhysicalAddress = AcpiGbl_RSDP->RsdtPhysicalAddress; - TableSignature = ACPI_SIG_RSDT; - SignatureLength = sizeof (ACPI_SIG_RSDT) -1; - AcpiGbl_RootTableType = ACPI_TABLE_TYPE_RSDT; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found RSDT\n")); - } - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) AcpiGbl_RSDP, sizeof (RSDP_DESCRIPTOR), 0, ACPI_UINT32_MAX); - } - - /* Get the RSDT/XSDT header to determine the table length */ - - CopyExtendedToReal (&AcpiTblHeader, PhysicalAddress, sizeof (ACPI_TABLE_HEADER)); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDT/XSDT at %8.8X\n", (UINT32) PhysicalAddress)); - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, ACPI_UINT32_MAX); - } - - /* Validate the table header */ - - Status = AcpiTbValidateTableHeader (&AcpiTblHeader); - if (ACPI_FAILURE (Status)) - { - /* Table failed verification, map all errors to BAD_DATA */ - - ACPI_ERROR ((AE_INFO, "Invalid RSDT table header")); - return (AE_BAD_DATA); - } - - /* Allocate a buffer for the entire table */ - - AcpiGbl_XSDT = (void *) malloc ((size_t) AcpiTblHeader.Length); - if (!AcpiGbl_XSDT) - { - AcpiOsPrintf ("Could not allocate buffer for RSDT length 0x%X\n", - (UINT32) AcpiTblHeader.Length); - return AE_NO_MEMORY; - } - - /* Get the entire RSDT/XSDT */ - - CopyExtendedToReal (AcpiGbl_XSDT, PhysicalAddress, AcpiTblHeader.Length); - AcpiOsPrintf ("%s at %p (Phys %8.8X)\n", - TableSignature, AcpiGbl_XSDT, (UINT32) PhysicalAddress); - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - /* Convert to common format XSDT */ - - TableInfo.Pointer = (ACPI_TABLE_HEADER *) AcpiGbl_XSDT; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer); - - Status = AcpiTbConvertToXsdt (&TableInfo); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer; - -ErrorExit: - return (Status); -} - - -void -AfDumpRsdt (void) -{ - UINT32 i; - UINT32 NumTables; - UINT32 PhysicalAddress; - ACPI_TABLE_HEADER **Table; - ACPI_TABLE_HEADER ThisTable; - - - NumTables = (AcpiGbl_XSDT->Length - sizeof (ACPI_TABLE_HEADER)) / 8; - - AcpiOsPrintf ("%d Tables defined in RSDT/XSDT:\n", NumTables); - - for (i = 0; i < NumTables; i++) - { - PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo; - CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER)); - AcpiOsPrintf ("[%4.4s] ", ThisTable.Signature); - ((char *) Table) += 8; - } - - AcpiOsPrintf ("\n"); -} - -ACPI_STATUS -AfGetTable ( - ACPI_TABLE_HEADER *TableHeader, - UINT32 PhysicalAddress, - UINT8 **TablePtr) -{ - - /* Allocate a buffer for the entire table */ - - *TablePtr = (void *) malloc ((size_t) TableHeader->Length); - if (!*TablePtr) - { - AcpiOsPrintf ("Could not allocate buffer for table length 0x%X\n", - (UINT32) TableHeader->Length); - return AE_NO_MEMORY; - } - - /* Get the entire table */ - - CopyExtendedToReal (*TablePtr, PhysicalAddress, TableHeader->Length); - AcpiOsPrintf ("%4.4s at %p (Phys %8.8X)\n", - TableHeader->Signature, *TablePtr, (UINT32) PhysicalAddress); - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) TableHeader, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - return (AE_OK); -} - - -ACPI_STATUS -AfGetTableFromXsdt ( - char *TableName, - UINT8 **TablePtr) -{ - UINT32 i; - UINT32 NumTables; - UINT32 PhysicalAddress; - ACPI_TABLE_HEADER ThisTable; - - - NumTables = (AcpiGbl_XSDT->Length - sizeof (ACPI_TABLE_HEADER)) / 8; - - for (i = 0; i < NumTables; i++) - { - PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo; - CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER)); - - if (ACPI_COMPARE_NAME (TableName, ThisTable.Signature)) - { - AfGetTable (&ThisTable, PhysicalAddress, TablePtr); - return (AE_OK); - } - } - - return (AE_NOT_FOUND); -} - - -/****************************************************************************** - * - * FUNCTION: AfFindTable - * - * PARAMETERS: - * - * RETURN: Status - * - * DESCRIPTION: Load the DSDT from the file pointer - * - *****************************************************************************/ - -ACPI_STATUS -AfFindTable ( - char *TableName, - UINT8 **TablePtr, - UINT32 *TableLength) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AfFindTable); - - - if (!AcpiGbl_DSDT) - { - Status = AfGetRsdt (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - AfDumpRsdt (); - - /* Get the rest of the required tables (DSDT, FADT) */ - - Status = AfGetAllTables (AcpiGbl_RsdtTableCount, NULL); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); - } - - - if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_DSDT)) - { - *TablePtr = (UINT8 *) AcpiGbl_DSDT; - *TableLength = AcpiGbl_DSDT->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_FADT)) - { - *TablePtr = (UINT8 *) AcpiGbl_FADT; - *TableLength = AcpiGbl_FADT->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_FACS)) - { - *TablePtr = (UINT8 *) AcpiGbl_FACS; - *TableLength = AcpiGbl_FACS->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_RSDT)) - { - *TablePtr = (UINT8 *) AcpiGbl_XSDT; - *TableLength = AcpiGbl_XSDT->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_SSDT)) - { - AcpiOsPrintf ("Unsupported table signature: [%4.4s]\n", TableName); - *TablePtr = NULL; - return AE_SUPPORT; - } - else - { - Status = AfGetTableFromXsdt (TableName, TablePtr); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - *TableLength = (*((ACPI_TABLE_HEADER **)TablePtr))->Length; - } - - return AE_OK; - -ErrorExit: - - ACPI_EXCEPTION ((AE_INFO, Status, "During ACPI Table initialization"); - return (Status); -} - -#ifdef _HPET -UINT8 Hbuf[1024]; - -void -AfGetHpet (void) -{ - HPET_DESCRIPTION_TABLE *NewTable; - ACPI_TABLE_HEADER TableHeader; - ACPI_STATUS Status; - UINT16 i; - UINT32 Value; - UINT32 Value2; - - - /* Get HPET TEMP! */ - - ACPI_STRNCPY (TableHeader.Signature, "HPET", 4); - Status = AcpiOsTableOverride (&TableHeader, (ACPI_TABLE_HEADER **) &NewTable); - if (ACPI_FAILURE (Status)) - { - return; - } - - AcpiDbgLevel |= ACPI_LV_TABLES; - AcpiOsPrintf ("HPET table :\n"); - AcpiUtDumpBuffer ((char *) NewTable, NewTable->Header.Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); - - for (i = 0; i < 1024; i++) - { - Hbuf[i] = (UINT8) i; - } - - /* enable HPET */ - - CopyExtendedToReal (&Value, 0xD0, 4); - AcpiOsPrintf ("Reg 0xD0: %8.8X\n", Value); - - Value = dIn32 (0xD0); - AcpiOsPrintf ("Port 0xD0: %8.8X\n", Value); - Value |= ACPI_ENABLE_HPET; - - vOut32 (0xD0, Value); - Value2 = dIn32 (0xD0); - AcpiOsPrintf ("Port 0xD0: Wrote: %8.8X got %8.8X\n", Value, Value2); - - AcpiOsPrintf ("HPET block(at %8.8X):\n", NewTable->BaseAddress[2]); - CopyExtendedToReal (Hbuf, NewTable->BaseAddress[2], 1024); - AcpiUtDumpBuffer ((char *) Hbuf, 1024, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); -} -#endif /* _HPET */ - -#endif /* IA16 */ - diff --git a/src/add-ons/kernel/bus_managers/acpi/common/a16utils.asm b/src/add-ons/kernel/bus_managers/acpi/common/a16utils.asm deleted file mode 100644 index 534aad4e4b..0000000000 --- a/src/add-ons/kernel/bus_managers/acpi/common/a16utils.asm +++ /dev/null @@ -1,915 +0,0 @@ -NAME BU_ASM -TITLE BU_ASM.ASM -- ASM support for DOS BU_LIB - -;**************************************************************************** -;* Copyright (C) Intel Corporation 1994-1999 -;* -;* All rights reserved. No part of this program or publication -;* may be reproduced, transmitted, transcribed, stored in a -;* retrieval system, or translated into any language or computer -;* language, in any form or by any means, electronic, mechanical, -;* magnetic, optical, chemical, manual, or otherwise, without -;* the prior written permission of Intel Corporation. -;**************************************************************************** -; -; To assemble with MASM61 -- ml /c a16utils.asm -; -;**************************************************************************** - -.286 -.MODEL large, c - -IFDEF MODEL_S -.MODEL small, c -ENDIF - -IFDEF MODEL_M -.MODEL medium, c -ENDIF - -IFDEF MODEL_L -.MODEL large, c -ENDIF - -IFDEF MODEL_C -.MODEL compact, c -ENDIF - -IFDEF MODEL_H -.MODEL huge, c -ENDIF - -;-------------------------------------------------------------------- - -GOREAL MACRO - LOCAL here - - mov eax, cr0 - and eax, 0fffffffeh - mov cr0, eax - jmp here -here: -ENDM - -;-------------------------------------------------------------------- - -GOPROT MACRO - LOCAL here - - xor eax, eax - xor edx, edx - - mov ax, ds - shl eax, 4 - lea edx, _gdt - add eax, edx - - mov [_gdt_ptr+2], ax - shr eax, 16 - mov [_gdt_ptr+4], ax - - lgdt FWORD PTR _gdt_ptr - mov eax, cr0 - or eax, 1 - mov cr0, eax - jmp here -here: -ENDM -;-------------------------------------------------------------------- - -.STACK -.DATA - -PUBLIC _dAPAwake, _dAPDone, _dAPFuncPtr, _wProcNumber, _bSPValid -PUBLIC _wCSegDS, _wCSegES, _wCSegSS, _wCSegSP, _wASegDS, _wASegES -PUBLIC _dAPHltJmp - - - - emsfilename DB 'EMMXXXX0',0 - - _dAPAwake DD 0 - _dAPDone DD 0 - _dAPFuncPtr DD 0 - _wProcNumber DW 0 - _bSPValid DB 0 - - _wASegDS DW 0 - _wASegES DW 0 - _wCSegDS DW 0 - _wCSegES DW 0 - _wCSegSS DW 0 - _wCSegSP DW 0 - - _block DW 0 - _gdt_ptr DW 23 - DD 0 - _gdt DD 0 ; NULL descriptor - DD 0 ; NULL descriptor - - ; 64K real mode style data segment - DD 0ffffh ; base 0, limit 0xffff - DD 00009200h ; data, CPL=0, 16-bit, 1 byte granularity, r/w - - ; 4G flat data segment - DD 0ffffh ; base 0, limit 0xfffff - DD 008f9200h ; data, CPL=0, 16-bit, 4K granularity, r/w - _old_es DW 0 - _old_ds DW 0 - _old_fs DW 0 - _old_gs DW 0 - _dAPHltJmp DD 0 ; jump to halt location - -.CODE -EXTERNDEF pascal cprint:proc - -PUBLIC ems_present -ems_present PROC C - mov ah,3dh ; open file - xor al,al ; read only operation - mov dx,offset emsfilename ; look for EMMXXXX0 - int 21h - jc emserror1 ; if carry flag set, then no EMM driver - - mov di,ax ; save file handle - mov bx,ax ; set up handle - mov ax,4400h ; get device (channel) info - int 21h - - mov ah,3eh ; close file - mov bx,di ; close the file handle up - int 21h - jc emserror1 ; if carry flag set, then no driver is present - - test dx,10000000b ; if bit 7 not set, then the channel is a file - jz emserror1 ; otherwise the channel is a device driver - - mov ax,1 ; 1 = EMS present - ret - -emserror1: - xor ax,ax ; 0 = EMS not present - ret -ems_present ENDP - -PUBLIC vm86 -vm86 PROC C - smsw ax - and ax, 1 - ret -vm86 ENDP - - -PUBLIC _set_rows -_set_rows PROC C rows:WORD - cmp rows, 25 - je set_25 - cmp rows, 50 - je set_50 - cmp rows, 132 - je set_132 - jmp invalid_input -set_25: - mov ah, 00 - mov al, 03 - int 10h - mov ax, rows - jmp end_set_rows -set_50: - mov ah, 00 - mov al, 03 - int 10h - xor bx, bx - mov ah, 11h - mov al, 12h - int 10h - mov ax, rows - jmp end_set_rows -set_132: - mov ah, 00 - mov al, 14h - int 10h - xor bx, bx - mov ah, 11h - mov al, 12h - int 10h - mov ax, rows - jmp end_set_rows -invalid_input: - xor ax, ax - jmp end_set_rows -end_set_rows: - ret -_set_rows ENDP - - -PUBLIC _cpuid_asm -_cpuid_asm PROC C hv:DWORD, regs:PTR DWORD - -check_8086: -.8086 - pushf - pop ax - mov cx, ax - and ax, 0fffh - push ax - popf - pushf - pop ax - and ax, 0f000h - cmp ax, 0f000h - mov ax, 10h - je end_cpuid - -check_80286: -.286 - or cx, 0f000h - push cx - popf - pushf - pop ax - and ax, 0f000h - mov ax, 20h - jz end_cpuid - -check_80386: -.386 - mov bx, sp - and sp, not 3 - pushfd - pop eax - mov ecx, eax - xor eax, 40000h - push eax - popfd - pushfd - pop eax - cmp ecx, eax - jne check_80486 - mov ax, 30h - mov sp, bx - jmp end_cpuid - -check_80486: -.486 - pushfd - pop ecx - mov ecx, eax - xor eax, 200000h - push eax - popfd - pushfd - pop eax - xor eax, ecx - mov ax, 40h - je end_cpuid - -check_cpuid: -.586 - mov eax, hv - cpuid - push ebx - IF @DataSize ; segment is far - les bx, regs - mov dword ptr es:[bx], eax - pop eax - mov dword ptr es:[bx + 4], eax - mov dword ptr es:[bx + 8], ecx - mov dword ptr es:[bx + 12], edx - ELSE ; segment is near - mov bx, regs - mov dword ptr [bx], eax - pop eax - mov dword ptr [bx + 4], eax - mov dword ptr [bx + 8], ecx - mov dword ptr [bx + 12], edx - ENDIF - mov ax, 5 -end_cpuid: - ret -_cpuid_asm ENDP - -.386p -;-------------------------------------------------------------------- -; Pentium Pro MSRs - from Pentium Pro Developer's Manual -; January 1996 - Appendix C -; -; MTRRs: 200h - 20Fh, 250h, 258h - 259h, 268h - 26Fh, 2FFh -;-------------------------------------------------------------------- -PUBLIC _read_msr -_read_msr PROC C dmsr:DWORD, pqmsr:PTR DWORD - pushad - mov ecx, dmsr - dw 320fh ; RDMSR - les bx, pqmsr - mov DWORD ptr es:[bx], eax - mov DWORD ptr es:[bx + 4], edx - popad - ret -_read_msr ENDP - -;-------------------------------------------------------------------- - -PUBLIC _write_msr -_write_msr PROC C dmsr:DWORD, pqmsr:PTR DWORD - pushad - les bx, pqmsr - mov eax, DWORD ptr es:[bx] - mov edx, DWORD ptr es:[bx + 4] - mov ecx, dmsr - dw 300fh ; WRMSR - popad - ret -_write_msr ENDP - -;---------------------------------------------------------------------------- -; Procedure: dReadCR0 - Reads CR0 CPU Register -; -; Output: dx:ax and eax - Contents of CR0 -; -; Registers: All registers preserved except EAX and EDX -;---------------------------------------------------------------------------- -PUBLIC dReadCR0 -dReadCR0 PROC C - mov eax, cr0 - mov edx, eax - shr edx, 16 ; upper 16 bits in dx - ret -dReadCR0 ENDP - -;---------------------------------------------------------------------------- -; Procedure: dReadCR2 - Reads CR2 CPU Register -; -; Output: dx:ax and eax - Contents of CR2 -; -; Registers: All registers preserved except EAX and EDX -;---------------------------------------------------------------------------- -PUBLIC dReadCR2 -dReadCR2 PROC C - mov eax, cr2 - mov edx, eax - shr edx, 16 ; upper 16 bits in dx - ret -dReadCR2 ENDP - -;---------------------------------------------------------------------------- -; Procedure: dReadCR3 - Reads CR3 CPU Register -; -; Output: dx:ax and eax - Contents of CR3 -; -; Registers: All registers preserved except EAX and EDX -;---------------------------------------------------------------------------- -PUBLIC dReadCR3 -dReadCR3 PROC C - mov eax, cr3 - mov edx, eax - shr edx, 16 ; upper 16 bits in dx - ret -dReadCR3 ENDP - - -.586 -;---------------------------------------------------------------------------- -; Procedure: dGetProcUpdateRev_asm - Reads PPP Update Revision via an MSR -; -; Output: dx:ax and eax - PPP Update Revision -; -; Registers: All registers preserved except EAX, ECX, and EDX -;---------------------------------------------------------------------------- -PUBLIC _dGetProcUpdateRev_asm -_dGetProcUpdateRev_asm PROC C - mov ecx, 08Bh ; model specific register to write - xor eax, eax - xor edx, edx - dw 300Fh ; WRMSR ==> load 0 to MSR at 8Bh - mov eax, 1 - cpuid - mov ecx, 08Bh ; model specific register to read - dw 320Fh ; RDMSR ==> EDX = (read) MSR 8Bh - mov eax, edx ; return EAX - shr edx, 16 ; return DX:AX - ret -_dGetProcUpdateRev_asm ENDP - -;-------------------------------------------------------------------- - -PUBLIC iInterruptFlagState -iInterruptFlagState PROC - pushf - pop ax - and ax, 200h - shr ax, 9 - ret -iInterruptFlagState ENDP - -;-------------------------------------------------------------------- - -.586P -PUBLIC vRealFsGs -vRealFsGs PROC C - - ; TBD: verify this on an AMD K6-2 266 MHz - ; Assert A20M# via system control port A (This is a - ; system dependent feature). - in al, 92h - and al, 0fdh - out 92h, al ; re-assert A20M# - - GOPROT - - mov ax, 8 - mov gs, ax - - GOREAL - - mov ax, [_old_fs] ; restore original - mov fs, ax - mov ax, [_old_gs] ; restore original - mov gs, ax - sti - ret -vRealFsGs ENDP - -;-------------------------------------------------------------------- -PUBLIC vFlatFsGs -vFlatFsGs PROC C - cli - mov ax, fs - mov [_old_fs], ax ; save original fs - mov ax, gs - mov [_old_gs], ax ; save original gs - - ; Deassert A20M# via system control port A (This is a - ; system dependent feature) - in al, 92h - or al, 2 - out 92h, al ; de-assert A20M# - - GOPROT - - mov ax, 10h - mov fs, ax - mov gs, ax - - GOREAL - - ret -vFlatFsGs ENDP - - -PUBLIC vRealEsDs -vRealEsDs PROC C - - ; TBD: verify this on an AMD K6-2 266 MHz - ; Assert A20M# via system control port A (This is a - ; system dependent feature). - in al, 92h - and al, 0fdh - out 92h, al ; re-assert A20M# - - GOPROT - - mov ax, 8 - mov gs, ax - - GOREAL - - mov ax, [_old_es] ; restore original - mov es, ax - mov ax, [_old_gs] ; restore original - mov gs, ax - sti - ret -vRealEsDs ENDP - -;-------------------------------------------------------------------- -PUBLIC vFlatEsDs -vFlatEsDs PROC C - cli - mov ax, es - mov [_old_es], ax ; save original - mov ax, gs - mov [_old_gs], ax ; save original - - ; Deassert A20M# via system control port A (This is a - ; system dependent feature) - in al, 92h - or al, 2 - out 92h, al ; de-assert A20M# - - GOPROT - - mov ax, 10h - mov es, ax - mov gs, ax - - GOREAL - - ret -vFlatEsDs ENDP - -PUBLIC print -print PROC PASCAL Seq:DWORD - - - pushad - mov eax, Seq - push eax - call cprint - popad - - ret -print ENDP - -PUBLIC DoMove -DoMove PROC - - push edx -; GOPROT - pop edx - - mov ecx, edx - shr ecx, 2 ; byte count / 4 = dword count - cmp ecx, 0 - je DoBytes - -NextDword: - xor eax, eax - lock or eax, gs:[esi] -; mov eax, gs:[esi] - - mov gs:[edi], eax - - add esi, 4 - add edi, 4 - loop NextDword - -DoBytes: - mov ecx, edx - and ecx, 3 - cmp ecx, 0 - je Exit ; no extra bytes to move - -NextByte: - mov al, byte ptr gs:[esi] - mov byte ptr gs:[edi], al - inc esi - inc edi - loop NextByte - -Exit: -; GOREAL - ret - -DoMove ENDP - .586 - - -;-------------------------------------------------------------------- - -PUBLIC _WriteApic -_WriteApic PROC C - call vFlatFsGs - xor ecx, ecx - xor edx, edx - - mov cx, [esp+6] ; high word of apic address - shl ecx, 16 - mov cx, [esp+4] ; low word of apic address - - mov dx, [esp+10] ; high word of apic command - shl edx, 16 - mov dx, [esp+8] ; low word of apic command - - mov gs:[ecx], edx - - call vRealFsGs - ret -_WriteApic ENDP - -;-------------------------------------------------------------------- - -PUBLIC _ReadApic -_ReadApic PROC C - call vFlatFsGs - xor ecx, ecx - - mov cx, [esp+6] ; low word of apic address - shl ecx, 16 - mov cx, [esp+4] ; high word of apic address - - mov eax, gs:[ecx] - - push eax ; save eax - call vRealFsGs - pop eax ; restore eax - - mov edx, eax - shr edx, 16 - ret -_ReadApic ENDP - -;-------------------------------------------------------------------- -; Since the AP shares the BSP's stack, coordination is needed to avoid -; simultaneous usage by both processors, which would cause corruption. -; -; While the AP is executing here, the BSP is executing the code -; which follows the call to vAPStartupAll() or vAPStartupOne() -; in bu_apic.c:vExecuteOnAPs(). After disabling interrupts, -; the BSP stores the sp value in _wCSegSP, sets _bSPValid to 1, -; and spins while _dAPDone != _dAPAwake. (Both are initially zero; -; the code below increments _dAPAwake before spinning on _bSPValid.) -; -; XXX - There is a race condition here: if the BSP makes it all -; XXX - the way to its spin loop on _dAPDone != _dAPAwake before -; XXX - the AP increments _dAPAwake, the BSP will exit the spin -; XXX - loop without actually having waited for the AP to finish. - -PUBLIC _vSetupAP -_vSetupAP PROC C - cli - mov ax, @data - mov ds, ax - mov esp, 0 - lock inc dword ptr [_dAPAwake] -spin1: - mov al, [_bSPValid] - cmp al, 1 - jne spin1 -; XXX - The following line is supposed to provide some validity checking, -; XXX - but it does not entirely succeed. It is possible for > 1 AP to -; XXX - see _bSPValid == 1, and exit the spin1 loop just above, before -; XXX - the first one out has had time to decrement _bSPValid; this race -; XXX - defeats the purpose of decrementing it. The decrement is likely -; XXX - not needed anyway due to the exclusion provided by the spin2 loop -; XXX - below. - lock dec byte ptr[_bSPValid] - - mov ax, [_wCSegSS] - mov ss, ax - mov sp, [_wCSegSP] - -; critical section - determining unique cpu signatures - -spin2: - mov eax, 1 -; XXX - Should the following line have a 'lock' prefix? - xchg word ptr [_block], ax - test ax, ax - jne spin2 - - mov ax, ds ; Save ASM DS and ES in global vars - mov [_wASegDS], ax - mov ax, es - mov [_wASegES], ax - - mov ax, [_wCSegES] - mov es, ax - mov ax, [_wCSegDS] ; Restore C DS and ES from global vars - mov ds, ax - -; Update Current Processor Number. Mutual exclusion from other AP's is -; guaranteed by the spin2 loop above. -; Note that the "processor number" determined here represents the order -; in which the processors happened to get through the spin2 lock, and -; has nothing to do with APIC numbers. A system having > 1 AP will not -; necessarily number the AP's consistently from one run to the next. - mov eax, [_dAPDone] - inc eax - mov [_wProcNumber], ax - - call [_dAPFuncPtr] ; _dAPFuncPtr needs to point to a void function - - mov ax, [_wASegDS] ; Restore ASM DS and ES from global vars - mov ds, ax - mov ax, [_wASegES] - mov es, ax - - lock inc dword ptr [_dAPDone] - lock inc byte ptr [_bSPValid] - - xor eax, eax -; A simple 'mov' would serve as well as the following 'xchg'. - xchg word ptr [_block], ax - wbinvd - mov si, offset _dAPHltJmp - jmp dword ptr [si] ; Jump to HLT, JMP $-1 in F000 segment - hlt ; Should never get here -_vSetupAP ENDP - -;-------------------------------------------------------------------- - -PUBLIC bIn8 -bIn8 PROC C wPort:WORD - xor ax, ax - mov dx, wPort - in al, dx - ret -bIn8 ENDP - -;-------------------------------------------------------------------- - -PUBLIC wIn16 -wIn16 PROC C wPort:WORD - mov dx, wPort - in ax, dx - ret -wIn16 ENDP - -;-------------------------------------------------------------------- - -PUBLIC dIn32 -dIn32 PROC C wPort:WORD - mov dx, wPort - in eax, dx - mov edx, eax - shr edx, 16 - ret -dIn32 ENDP - -;-------------------------------------------------------------------- - -PUBLIC vOut8 -vOut8 PROC C wPort:WORD, bValue:BYTE - mov dx, wPort - mov al, bValue - out dx, al - ret -vOut8 ENDP - -;-------------------------------------------------------------------- - -PUBLIC vOut16 -vOut16 PROC C wPort:WORD, wValue:WORD - mov dx, wPort - mov ax, wValue - out dx, ax - ret -vOut16 ENDP - -;-------------------------------------------------------------------- - -PUBLIC vOut32 -vOut32 PROC C wPort:WORD, dValue:DWORD - mov dx, wPort - mov eax, dValue - out dx, eax - ret -vOut32 ENDP - -;-------------------------------------------------------------------- - -; int FlatMove (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize) -PUBLIC FlatMoveX -FlatMoveX PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD - call vm86 ; check if VM86 mode - cmp ax, 0 - jne NotRealMode ; skip memory move if not in real mode - - call vFlatFsGs ; set up FS and GS as 4GB limit selectors with - ; base 0:0 and de-assert A20M# - - movzx ecx, sSize - cmp ecx, 0 - je SKipMemoryMove ; skip memory move if 0==sSize - - mov eax, dDest - cmp eax, 400h - jbe SkipMemoryMove ; skip memory move if destination is 40:0 - ; BIOS Data Area or less (IVT) - - mov ebx, dSrc -NextByte: - mov dl, gs:[ebx][ecx - 1] - mov gs:[eax][ecx - 1], dl - loop NextByte - - call vRealFsGs - xor ax, ax -NotRealMode: - ret - -SkipMemoryMove: - mov ax, 1 ; return error code - ret -FlatMoveX ENDP - - -; int FlatMove32 (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize) -PUBLIC FlatMove32 -FlatMove32 PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD - - call vm86 ; check if VM86 mode - cmp ax, 0 - jne NotRealMode ; skip memory move if not in real mode - - call vFlatFsGs ; set up FS and GS as 4GB limit selectors with - ; base 0:0 and de-assert A20M# - movzx edx, sSize - mov esi, dSrc - mov edi, dDest - - push edx - call print - push esi - call print - push edi - call print - - cmp edx, 0 - je SkipMemoryMove ; skip memory move if 0==sSize - - cmp edi, 400h - jbe SkipMemoryMove ; skip memory move if destination is 40:0 - ; BIOS Data Area or less (IVT) - call DoMove ; edx=Count, esi=src, edi=dst - - movzx ecx, sSize - shr ecx, 2 - mov edi, dDest -PrintLoop: - mov eax, gs:[edi] - push eax - call print - add edi, 4 - loop PrintLoop - - call vRealFsGs - xor ax, ax - -NotRealMode: - ret - -SkipMemoryMove: - call print - call vRealEsDs - mov ax, 1 ; return error code - ret - -FlatMove32 ENDP - - -; int FlatMove32 (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize) -PUBLIC FlatMove32x -FlatMove32x PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD - call vm86 ; check if VM86 mode - cmp ax, 0 - jne NotRealMode ; skip memory move if not in real mode - - call vFlatFsGs ; set up FS and GS as 4GB limit selectors with - ; base 0:0 and de-assert A20M# - movzx ecx, sSize - cmp ecx, 0 - je SKipMemoryMove ; skip memory move if 0==sSize - - mov eax, dDest - cmp eax, 400h - jbe SkipMemoryMove ; skip memory move if destination is 40:0 - ; BIOS Data Area or less (IVT) - - mov ebx, dSrc - mov esi, 0 - - push ecx - call print - push ebx - call print - push eax - call print - - shr ecx, 2 ; byte count / 4 = dword count - cmp ecx, 0 - je DoBytes - -NextDword: - mov edx, dword ptr gs:[ebx][esi] - mov dword ptr gs:[eax][esi], edx - push edx - call print - add esi, 4 - loop NextDword - -DoBytes: - movzx ecx, sSize - and ecx, 3 - cmp ecx, 0 - je Exit ; no extra bytes to move - -NextByte: - mov dl, gs:[ebx][esi] - mov gs:[eax][esi], dl - inc esi - loop NextByte - -Exit: - call vRealFsGs - xor ax, ax - -NotRealMode: - ret - -SkipMemoryMove: - mov ax, 1 ; return error code - ret -FlatMove32x ENDP -END diff --git a/src/add-ons/kernel/bus_managers/acpi/common/a16utils.obj b/src/add-ons/kernel/bus_managers/acpi/common/a16utils.obj deleted file mode 100644 index fac87b16b55cf2d56a47f64535fe69fe7ae172c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2665 zcmb_deQZ-z6hE(h?b>a5?Ql4lfCINBA~9@@3qdfHbsghl>(*{ef;`Ih?y|VAw6C3i zAVR8f@CG)E0+Nv+B$8+}7#6LHq$OLsv7l%$E{btXf=|cCL=y(1t>?bCvdJGNM*GM8 zopbK*o^$Rw=f3XdAk$q`;uD)&yidEmt%-vc0G-oiE#08wZC01nT2xZ&s@Uk{U1jwy zy{){as@9?Ivviv+t+JI398QCE@9J0s*99&|}fQd{3`1bwNa zrlQgXZv__uFloHM$|n|;tYsmC=Qn$rMZwz9+^|{;5VQfKG4gz8sZ(ewb1ni%DK_T< zRk12NxigB*Id6vMbmjrP9DD@BWb*bFx45a@FIb9S%F)61!7Oy1&htB*jyiWsb7Kxb zSMW(>rt^MEE%VyE2Q)CP*}dgnnE}0$?1~Z=j-<{vS{>F-_ltrN-~+VL^SoCOc~5(% zcR9dB(5zkpdA9a80f0jbFh;(yMsPQl)-1O(kbx;OnoOQYlHJ$V;1E6NX)t&gi5asJ zKh9!4ya&(mtzM6rfo#6HqD>S$9$$xuNjEt~wn!WgodJ3ZPm_fS++8u ztX0ufIyUKGo>;4^sM$inbM5EUXO9!Gy72nDDw5aeZsY zMgR>OX})|zhp)Mj$4PnxV0$ndnb<>zr@f)l*SbUS%*E*nZa}I|nS(JJCDokztt_Y$ zVJWU;AqOLr3nD#R+tG-3s}cOvaT9|qTRUy%qy~Jc8Y_e1bSwdw46amj>7)ZitMwG^ zUS~yHQON?Oihidc`Z}zRLt4n>g;p=$;Ssz-n+O2mE*9W8^Yt+oXaLGKZK}r~_VS;8 zI6kv}$s{U004lyQYX{)lV^dlNpl@|?_%nbDi#?A?lhQ~CY!?>yJtzHyhV(nF0|kT#Lo*J-hU;f|xg6)CZ@u7tE4fKfY8IEkE>SotmSX za?q50!93feT|0I)zDm=S`O0B<7-fVewvUsL$E|bYe0O0V0NbC#M!?sofPg(Lsx}+ z%UN8i47hC04C&N_$aW%C>P^Kd9`3Qk{Q}LEY*&m@8Yz^}NNLOImMJexq>Ci-n;FH6 zGvY`}B%exHePRg{%QtugYYKq5C{|N3k+kOW$1KASvJC&{EW;0FskDvuo;Z%s7eL%Y=W%*!$QB}DoSX~a&-$8HaE^2r3T3}H{3q>cG{61ifg z0^20H^3zFV3^iB2fjZ3M@L3Q~en(-DFqS%an|{%=w9h_dJFeVpmn zWiy(A_sxuE84P@cPzVDd6~0j6M}&1SFov)m2Cl2x?}`>RAS{C@hfoO7xhmwUP_6E5 zR<&&^G^h|jutBs7VLe29RPB(eeTaZQ`w-CQ=PHC1`0{2QGyHZf6FZ5j5n}HlKcL<9hb{Sy-#OReE_6x3aAvTVX1+kk5$o~T& z7YxTvGt3>WTKkCvRu~6_7TRPyi^W{_CytdREY<0+D<3fwZlnZqW4ene!#=y=W=fXq zhFd8ahtfb)jgzBOfl2ULIC*EBm_DiGlz}T$=5{rH?ZBT)q;2UqfUfyT96=Y89J|fQ z@%xtW&@fJc;**niD_*v6atZZP#}Ub&PNZFWQp3p$6Qqula}s1TCub!{;2ww;vL~rH zU&_hZ2{kT#5qJWp7C&=1me=CSL%7AsK_wU`Uy9>2$7h0OC_#5}a^(I@>g}^qZ=k6Y ztQ%Ibnv>s*6DKDhh*R%f@tG$`LuN0c&m~()xCJ9e=@V4zG3yZ`OXxz9oz~#))PowV f?Oh1{EH)7OjkxAOzZoGP`ssXbgo1teM=JgW)v1&1 diff --git a/src/add-ons/kernel/bus_managers/acpi/common/adfile.c b/src/add-ons/kernel/bus_managers/acpi/common/adfile.c index b4879544cb..1de4b248f8 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/adfile.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/adfile.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: adfile - Application-level disassembler file support routines - * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acapps.h" #include @@ -125,6 +125,13 @@ #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("adfile") +/* Local prototypes */ + +INT32 +AdWriteBuffer ( + char *Filename, + char *Buffer, + UINT32 Length); char FilenameBuf[20]; @@ -185,12 +192,12 @@ AdGenerateFilename ( INT32 AdWriteBuffer ( - char *Filename, - char *Buffer, - UINT32 Length) + char *Filename, + char *Buffer, + UINT32 Length) { - FILE *fp; - ACPI_SIZE Actual; + FILE *fp; + ACPI_SIZE Actual; fp = fopen (Filename, "wb"); diff --git a/src/add-ons/kernel/bus_managers/acpi/common/adisasm.c b/src/add-ons/kernel/bus_managers/acpi/common/adisasm.c index b3c2fabb55..8aaa3b4bb5 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/adisasm.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/adisasm.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: adisasm - Application-level disassembler routines - * $Revision: 1.112 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdebug.h" @@ -153,7 +153,25 @@ void AdDisassemblerHeader ( char *Filename); -ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; +void +AdAddExternalsToNamespace ( + void); + +UINT32 +AdMethodExternalCount ( + void); + +ACPI_STATUS +AdDeferredParse ( + ACPI_PARSE_OBJECT *Op, + UINT8 *Aml, + UINT32 AmlLength); + +ACPI_STATUS +AdParseDeferredOps ( + ACPI_PARSE_OBJECT *Root); + +ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; /* Stubs for ASL compiler */ @@ -245,18 +263,27 @@ AdInitialize ( /* ACPI CA subsystem initialization */ Status = AcpiOsInitialize (); - AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } Status = AcpiUtMutexInitialize (); if (ACPI_FAILURE (Status)) { - return Status; + return (Status); } Status = AcpiNsRootInitialize (); if (ACPI_FAILURE (Status)) { - return Status; + return (Status); } /* Setup the Table Manager (cheat - there is no RSDT) */ @@ -265,7 +292,7 @@ AdInitialize ( AcpiGbl_RootTableList.Count = 0; AcpiGbl_RootTableList.Tables = LocalTables; - return Status; + return (Status); } @@ -275,7 +302,7 @@ AdInitialize ( * * PARAMETERS: * - * RETURN: Status + * RETURN: None * * DESCRIPTION: * @@ -371,14 +398,17 @@ AdAmlDisassemble ( { ACPI_STATUS Status; char *DisasmFilename = NULL; + char *ExternalFilename; FILE *File = NULL; ACPI_TABLE_HEADER *Table = NULL; ACPI_TABLE_HEADER *ExternalTable; + ACPI_OWNER_ID OwnerId; + ACPI_EXTERNAL_LIST *NextExternal; /* - * Input: AML Code from either a file, - * or via GetTables (memory or registry) + * Input: AML Code from either a file, + * or via GetTables (memory or registry) */ if (Filename) { @@ -388,12 +418,56 @@ AdAmlDisassemble ( return Status; } + /* + * External filenames separated by commas + * Example: iasl -e file1,file2,file3 -d xxx.aml + */ if (Gbl_ExternalFilename) { - Status = AcpiDbGetTableFromFile (Gbl_ExternalFilename, &ExternalTable); - if (ACPI_FAILURE (Status)) + ExternalFilename = strtok (Gbl_ExternalFilename, ","); + + while (ExternalFilename) { - return Status; + Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable); + if (ACPI_FAILURE (Status)) + { + return Status; + } + + /* Load external table for symbol resolution */ + + if (ExternalTable) + { + Status = AdParseTable (ExternalTable, &OwnerId, TRUE, TRUE); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", + AcpiFormatException (Status)); + return Status; + } + + /* + * Load namespace from names created within control methods + * Set owner id of nodes in external table + */ + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); + } + + /* Next external file name */ + + ExternalFilename = strtok (NULL, ","); + } + + /* Clear external list generated by Scope in external tables */ + + while (AcpiGbl_ExternalList) + { + NextExternal = AcpiGbl_ExternalList->Next; + ACPI_FREE (AcpiGbl_ExternalList->Path); + ACPI_FREE (AcpiGbl_ExternalList); + AcpiGbl_ExternalList = NextExternal; } } } @@ -470,7 +544,7 @@ AdAmlDisassemble ( { /* Always parse the tables, only option is what to display */ - Status = AdParseTable (Table, TRUE); + Status = AdParseTable (Table, &OwnerId, TRUE, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not parse ACPI tables, %s\n", @@ -490,12 +564,12 @@ AdAmlDisassemble ( /* * Load namespace from names created within control methods */ - AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode, OwnerId); /* * Cross reference the namespace here, in order to generate External() statements */ - AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); + AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode, OwnerId); if (AslCompilerdebug) { @@ -510,14 +584,6 @@ AdAmlDisassemble ( AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); - if (AslCompilerdebug) - { - AcpiOsPrintf ("/**** After second load and resource conversion\n"); - LsSetupNsList (File); - LsDisplayNamespace (); - AcpiOsPrintf ("*****/\n"); - } - /* * If we found any external control methods, we must reparse the entire * tree with the new information (namely, the number of arguments per @@ -549,7 +615,7 @@ AdAmlDisassemble ( /* Parse table. No need to reload it, however (FALSE) */ - Status = AdParseTable (Table, FALSE); + Status = AdParseTable (Table, NULL, FALSE, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not parse ACPI tables, %s\n", @@ -559,6 +625,11 @@ AdAmlDisassemble ( if (AslCompilerdebug) { + AcpiOsPrintf ("/**** After second load and resource conversion\n"); + LsSetupNsList (File); + LsDisplayNamespace (); + AcpiOsPrintf ("*****/\n"); + AcpiDmDumpTree (AcpiGbl_ParseOpRoot); } } @@ -1015,6 +1086,11 @@ AdGetLocalTables ( fprintf (stderr, "Could not obtain RSDT\n"); return AE_NO_ACPI_TABLES; } + else + { + AdWriteTable (NewTable, NewTable->Length, + ACPI_SIG_RSDT, NewTable->OemTableId); + } if (ACPI_COMPARE_NAME (NewTable->Signature, ACPI_SIG_RSDT)) { @@ -1094,6 +1170,9 @@ AdGetLocalTables ( * FUNCTION: AdParseTable * * PARAMETERS: Table - Pointer to the raw table + * OwnerId - Returned OwnerId of the table + * LoadTable - If add table to the global table list + * External - If this is an external table * * RETURN: Status * @@ -1104,7 +1183,9 @@ AdGetLocalTables ( ACPI_STATUS AdParseTable ( ACPI_TABLE_HEADER *Table, - BOOLEAN LoadTable) + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External) { ACPI_STATUS Status = AE_OK; ACPI_WALK_STATE *WalkState; @@ -1158,6 +1239,10 @@ AdParseTable ( return Status; } + /* If LoadTable is FALSE, we are parsing the last loaded table */ + + TableIndex = AcpiGbl_RootTableList.Count - 1; + /* Pass 2 */ if (LoadTable) @@ -1168,16 +1253,36 @@ AdParseTable ( { return Status; } + Status = AcpiTbAllocateOwnerId (TableIndex); + if (ACPI_FAILURE (Status)) + { + return Status; + } + if (OwnerId) + { + Status = AcpiTbGetOwnerId (TableIndex, OwnerId); + if (ACPI_FAILURE (Status)) + { + return Status; + } + } } fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature); - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, 0, NULL); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL); if (ACPI_FAILURE (Status)) { return (Status); } + /* No need to parse control methods of external table */ + + if (External) + { + return AE_OK; + } + /* Pass 3: Parse control methods and link their parse trees into the main parse tree */ Status = AdParseDeferredOps (AcpiGbl_ParseOpRoot); diff --git a/src/add-ons/kernel/bus_managers/acpi/common/adwalk.c b/src/add-ons/kernel/bus_managers/acpi/common/adwalk.c index 0cf22736cc..67d9b11389 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/adwalk.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/adwalk.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: adwalk - Application-level disassembler parse tree walk routines - * $Revision: 1.7 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdebug.h" @@ -252,6 +252,7 @@ AcpiDmFindOrphanMethods ( * * PARAMETERS: ParseTreeRoot - Root of the parse tree * NamespaceRoot - Root of the internal namespace + * OwnerId - OwnerId of the table to be disassembled * * RETURN: None * @@ -263,7 +264,8 @@ AcpiDmFindOrphanMethods ( void AcpiDmFinishNamespaceLoad ( ACPI_PARSE_OBJECT *ParseTreeRoot, - ACPI_NAMESPACE_NODE *NamespaceRoot) + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId) { ACPI_STATUS Status; ACPI_OP_WALK_INFO Info; @@ -277,7 +279,7 @@ AcpiDmFinishNamespaceLoad ( /* Create and initialize a new walk state */ - WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL); + WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL); if (!WalkState) { return; @@ -304,6 +306,7 @@ AcpiDmFinishNamespaceLoad ( * * PARAMETERS: ParseTreeRoot - Root of the parse tree * NamespaceRoot - Root of the internal namespace + * OwnerId - OwnerId of the table to be disassembled * * RETURN: None * @@ -314,7 +317,8 @@ AcpiDmFinishNamespaceLoad ( void AcpiDmCrossReferenceNamespace ( ACPI_PARSE_OBJECT *ParseTreeRoot, - ACPI_NAMESPACE_NODE *NamespaceRoot) + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId) { ACPI_STATUS Status; ACPI_OP_WALK_INFO Info; @@ -328,7 +332,7 @@ AcpiDmCrossReferenceNamespace ( /* Create and initialize a new walk state */ - WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL); + WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL); if (!WalkState) { return; @@ -470,6 +474,9 @@ AcpiDmDumpDescending ( case AML_INT_NAMEDFIELD_OP: AcpiOsPrintf ("%4.4s", &Op->Named.Name); break; + + default: + break; } AcpiOsPrintf ("\n"); @@ -618,6 +625,9 @@ AcpiDmFindOrphanDescending ( } break; + + default: + break; } return (AE_OK); @@ -650,6 +660,9 @@ AcpiDmLoadDescendingOp ( char *Path = NULL; ACPI_PARSE_OBJECT *NextOp; ACPI_NAMESPACE_NODE *Node; + char FieldPath[5]; + BOOLEAN PreDefined = FALSE; + UINT8 PreDefineIndex = 0; WalkState = Info->WalkState; @@ -672,6 +685,13 @@ AcpiDmLoadDescendingOp ( /* For all named operators, get the new name */ Path = (char *) Op->Named.Path; + + if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name; + FieldPath[4] = 0; + Path = FieldPath; + } } else if (OpInfo->Flags & AML_CREATE) { @@ -699,6 +719,36 @@ AcpiDmLoadDescendingOp ( Op->Common.Node = Node; + if (ACPI_SUCCESS (Status)) + { + /* Check if it's a predefined node */ + + while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name) + { + if (!ACPI_STRNCMP (Node->Name.Ascii, + AcpiGbl_PreDefinedNames[PreDefineIndex].Name, 4)) + { + PreDefined = TRUE; + break; + } + + PreDefineIndex++; + } + + /* + * Set node owner id if it satisfies all the following conditions: + * 1) Not a predefined node, _SB_ etc + * 2) Not the root node + * 3) Not a node created by Scope + */ + + if (!PreDefined && Node != AcpiGbl_RootNode && + Op->Common.AmlOpcode != AML_SCOPE_OP) + { + Node->OwnerId = WalkState->OwnerId; + } + } + Exit: @@ -740,10 +790,12 @@ AcpiDmXrefDescendingOp ( const ACPI_OPCODE_INFO *OpInfo; ACPI_WALK_STATE *WalkState; ACPI_OBJECT_TYPE ObjectType; + ACPI_OBJECT_TYPE ObjectType2; ACPI_STATUS Status; char *Path = NULL; ACPI_PARSE_OBJECT *NextOp; ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; WalkState = Info->WalkState; @@ -819,6 +871,33 @@ AcpiDmXrefDescendingOp ( #endif } } + + /* + * Found the node in external table, add it to external list + * Node->OwnerId == 0 indicates built-in ACPI Names, _OS_ etc + */ + else if (Node->OwnerId && WalkState->OwnerId != Node->OwnerId) + { + ObjectType2 = ObjectType; + + Object = AcpiNsGetAttachedObject (Node); + if (Object) + { + ObjectType2 = Object->Common.Type; + } + + if (ObjectType2 == ACPI_TYPE_METHOD) + { + AcpiDmAddToExternalList (Path, ACPI_TYPE_METHOD, + Object->Method.ParamCount); + } + else + { + AcpiDmAddToExternalList (Path, (UINT8) ObjectType2, 0); + } + + Op->Common.Node = Node; + } else { Op->Common.Node = Node; diff --git a/src/add-ons/kernel/bus_managers/acpi/common/dmrestag.c b/src/add-ons/kernel/bus_managers/acpi/common/dmrestag.c index 22aaedc0c3..e314b318af 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/dmrestag.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/dmrestag.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dmrestag - Add tags to resource descriptors (Application-level) - * $Revision: 1.12 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acdisasm.h" #include "acnamesp.h" @@ -387,7 +387,7 @@ static ACPI_RESOURCE_TAG *AcpiGbl_ResourceTags [] = static UINT32 AcpiGbl_NextResourceId = 0; static UINT8 AcpiGbl_NextPrefix = 0; -static UINT8 AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] = +static char AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] = {'Y','Z','J','K','X'}; @@ -636,13 +636,22 @@ AcpiGetTagPathname ( /* Get the full pathname to the parent buffer */ RequiredSize = AcpiNsGetPathnameLength (BufferNode); + if (!RequiredSize) + { + return (NULL); + } + Pathname = ACPI_ALLOCATE_ZEROED (RequiredSize + ACPI_PATH_SEGMENT_LENGTH); if (!Pathname) { return (NULL); } - AcpiNsBuildExternalPath (BufferNode, RequiredSize, Pathname); + Status = AcpiNsBuildExternalPath (BufferNode, RequiredSize, Pathname); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } /* * Create the full path to the resource and tag by: remove the buffer name, @@ -720,7 +729,7 @@ AcpiDmUpdateResourceName ( /* Change the resource descriptor name */ - ResourceNode->Name.Integer = *(UINT32 *) Name; + ResourceNode->Name.Integer = *ACPI_CAST_PTR (UINT32, &Name[0]); } diff --git a/src/add-ons/kernel/bus_managers/acpi/common/dmtable.c b/src/add-ons/kernel/bus_managers/acpi/common/dmtable.c index 92b5578c9d..9b0e1e50a3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/dmtable.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/dmtable.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dmtable - Support for ACPI tables that contain no AML code - * $Revision: 1.16 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acdisasm.h" #include "actables.h" @@ -132,8 +132,13 @@ AcpiDmGetTableData ( static void AcpiDmCheckAscii ( UINT8 *Target, + char *RepairedName, UINT32 Count); +UINT8 +AcpiTbGenerateChecksum ( + ACPI_TABLE_HEADER *Table); + /* These tables map a subtable type to a description string */ @@ -152,20 +157,21 @@ static const char *AcpiDmDmarSubnames[] = "Hardware Unit Definition", "Reserved Memory Region", "Root Port ATS Capability", + "Remapping Hardware Static Affinity", "Unknown SubTable Type" /* Reserved */ }; static const char *AcpiDmHestSubnames[] = { - "XPF Machine Check Exception", - "XPF Corrected Machine Check", - "NOT USED???", - "XPF Non-Maskable Interrupt", - "IPF Corrected Machine Check", - "IPF Corrected Platform Error", + "IA-32 Machine Check Exception", + "IA-32 Corrected Machine Check", + "IA-32 Non-Maskable Interrupt", + "Unknown SubTable Type", /* 3 - Reserved */ + "Unknown SubTable Type", /* 4 - Reserved */ + "Unknown SubTable Type", /* 5 - Reserved */ "PCI Express Root Port AER", "PCI Express AER (AER Endpoint)", - "PCI Express/PCI-X Bridge AERn", + "PCI Express/PCI-X Bridge AER", "Generic Hardware Error Source", "Unknown SubTable Type" /* Reserved */ }; @@ -191,6 +197,8 @@ static const char *AcpiDmMadtSubnames[] = "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ + "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ + "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ "Unknown SubTable Type" /* Reserved */ }; @@ -198,14 +206,40 @@ static const char *AcpiDmSratSubnames[] = { "Processor Local APIC/SAPIC Affinity", "Memory Affinity", + "Processor Local x2APIC Affinity", + "Unknown SubTable Type" /* Reserved */ +}; + +static const char *AcpiDmIvrsSubnames[] = +{ + "Hardware Definition Block", + "Memory Definition Block", "Unknown SubTable Type" /* Reserved */ }; + +#define ACPI_FADT_PM_RESERVED 8 + +static const char *AcpiDmFadtProfiles[] = +{ + "Unspecified", + "Desktop", + "Mobile", + "Workstation", + "Enterprise Server", + "SOHO Server", + "Appliance PC", + "Performance Server", + "Unknown Profile Type" +}; + /******************************************************************************* * * ACPI Table Data, indexed by signature. * + * Each entry contains: Signature, Table Info, Handler, Description + * * Simple tables have only a TableInfo structure, complex tables have a handler. * This table must be NULL terminated. RSDP and FACS are special-cased * elsewhere. @@ -226,8 +260,10 @@ static ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, "Fixed ACPI Description Table"}, {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, "Hardware Error Source Table"}, {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, "High Precision Event Timer table"}, + {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, "I/O Virtualization Reporting Structure"}, {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, "Multiple APIC Description Table"}, {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, "Memory Mapped Configuration table"}, + {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, "Maximum System Characteristics Table"}, {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, "Root System Description Table"}, {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, "Smart Battery Specification Table"}, {ACPI_SIG_SLIC, AcpiDmTableInfoSlic, NULL, "Software Licensing Description Table"}, @@ -236,6 +272,9 @@ static ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, "Server Platform Management Interface table"}, {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, "System Resource Affinity Table"}, {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, "Trusted Computing Platform Alliance table"}, + {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, "UEFI Boot Optimization Table"}, + {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, "Windows ACPI Emulated Devices Table"}, + {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, "Watchdog Action Table"}, {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, "Watchdog Resource Table"}, {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, "Extended System Description Table"}, {NULL, NULL, NULL, NULL} @@ -426,12 +465,12 @@ AcpiDmLineHeader ( if (ByteLength) { - AcpiOsPrintf ("[%3.3Xh %3.3d% 3d] %28s : ", + AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %28s : ", Offset, Offset, ByteLength, Name); } else { - AcpiOsPrintf ("%42s : ", + AcpiOsPrintf ("%43s : ", Name); } } @@ -446,12 +485,12 @@ AcpiDmLineHeader2 ( if (ByteLength) { - AcpiOsPrintf ("[%3.3Xh %3.3d% 3d] %24s % 3d : ", + AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %24s % 3d : ", Offset, Offset, ByteLength, Name, Value); } else { - AcpiOsPrintf ("[%3.3Xh %3.3d ] %24s % 3d : ", + AcpiOsPrintf ("[%3.3Xh %4.4d ] %24s % 3d : ", Offset, Offset, Name, Value); } } @@ -488,7 +527,9 @@ AcpiDmDumpTable ( UINT8 Temp8; UINT16 Temp16; ACPI_DMTABLE_DATA *TableData; + const char *Name; BOOLEAN LastOutputBlankLine = FALSE; + char RepairedName[8]; if (!Info) @@ -524,10 +565,12 @@ AcpiDmDumpTable ( case ACPI_DMT_UINT8: case ACPI_DMT_CHKSUM: case ACPI_DMT_SPACEID: + case ACPI_DMT_IVRS: case ACPI_DMT_MADT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: case ACPI_DMT_HESTNTYP: + case ACPI_DMT_FADTPM: ByteLength = 1; break; case ACPI_DMT_UINT16: @@ -553,6 +596,9 @@ AcpiDmDumpTable ( case ACPI_DMT_NAME8: ByteLength = 8; break; + case ACPI_DMT_BUF16: + ByteLength = 16; + break; case ACPI_DMT_STRING: ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1; break; @@ -653,17 +699,28 @@ AcpiDmDumpTable ( ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); break; + case ACPI_DMT_BUF16: + + /* Buffer of length 16 */ + + for (Temp8 = 0; Temp8 < 16; Temp8++) + { + AcpiOsPrintf ("%2.2X,", Target[Temp8]); + } + AcpiOsPrintf ("\n"); + break; + case ACPI_DMT_STRING: - AcpiOsPrintf ("%s\n", ACPI_CAST_PTR (char, Target)); + AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target)); break; /* Fixed length ASCII name fields */ case ACPI_DMT_SIG: - AcpiDmCheckAscii (Target, 4); - AcpiOsPrintf ("\"%4.4s\" ", Target); + AcpiDmCheckAscii (Target, RepairedName, 4); + AcpiOsPrintf ("\"%.4s\" ", RepairedName); TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target)); if (TableData) { @@ -674,20 +731,20 @@ AcpiDmDumpTable ( case ACPI_DMT_NAME4: - AcpiDmCheckAscii (Target, 4); - AcpiOsPrintf ("\"%4.4s\"\n", Target); + AcpiDmCheckAscii (Target, RepairedName, 4); + AcpiOsPrintf ("\"%.4s\"\n", RepairedName); break; case ACPI_DMT_NAME6: - AcpiDmCheckAscii (Target, 6); - AcpiOsPrintf ("\"%6.6s\"\n", Target); + AcpiDmCheckAscii (Target, RepairedName, 6); + AcpiOsPrintf ("\"%.6s\"\n", RepairedName); break; case ACPI_DMT_NAME8: - AcpiDmCheckAscii (Target, 8); - AcpiOsPrintf ("\"%8.8s\"\n", Target); + AcpiDmCheckAscii (Target, RepairedName, 8); + AcpiOsPrintf ("\"%.8s\"\n", RepairedName); break; /* Special Data Types */ @@ -718,8 +775,8 @@ AcpiDmDumpTable ( /* Generic Address Structure */ AcpiOsPrintf ("\n"); - AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, - CurrentOffset, Target, 0, AcpiDmTableInfoGas); + AcpiDmDumpTable (TableLength, CurrentOffset, Target, + sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas); AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; break; @@ -741,33 +798,33 @@ AcpiDmDumpTable ( /* DMAR subtable types */ - Temp16 = *Target; + Temp16 = ACPI_GET16 (Target); if (Temp16 > ACPI_DMAR_TYPE_RESERVED) { Temp16 = ACPI_DMAR_TYPE_RESERVED; } - AcpiOsPrintf ("%4.4X <%s>\n", *Target, AcpiDmDmarSubnames[Temp16]); + AcpiOsPrintf ("%4.4X <%s>\n", ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]); break; case ACPI_DMT_HEST: /* HEST subtable types */ - Temp16 = *Target; + Temp16 = ACPI_GET16 (Target); if (Temp16 > ACPI_HEST_TYPE_RESERVED) { Temp16 = ACPI_HEST_TYPE_RESERVED; } - AcpiOsPrintf ("%4.4X (%s)\n", *Target, AcpiDmHestSubnames[Temp16]); + AcpiOsPrintf ("%4.4X (%s)\n", ACPI_GET16 (Target), AcpiDmHestSubnames[Temp16]); break; case ACPI_DMT_HESTNTFY: AcpiOsPrintf ("\n"); - AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, - CurrentOffset, Target, 0, AcpiDmTableInfoHestNotify); + AcpiDmDumpTable (TableLength, CurrentOffset, Target, + sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify); AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; break; @@ -812,6 +869,44 @@ AcpiDmDumpTable ( AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmSratSubnames[Temp8]); break; + case ACPI_DMT_FADTPM: + + /* FADT Preferred PM Profile names */ + + Temp8 = *Target; + if (Temp8 > ACPI_FADT_PM_RESERVED) + { + Temp8 = ACPI_FADT_PM_RESERVED; + } + + AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmFadtProfiles[Temp8]); + break; + + case ACPI_DMT_IVRS: + + /* IVRS subtable types */ + + Temp8 = *Target; + switch (Temp8) + { + case ACPI_IVRS_TYPE_HARDWARE: + Name = AcpiDmIvrsSubnames[0]; + break; + + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + Name = AcpiDmIvrsSubnames[1]; + break; + + default: + Name = AcpiDmIvrsSubnames[2]; + break; + } + + AcpiOsPrintf ("%2.2X <%s>\n", *Target, Name); + break; + case ACPI_DMT_EXIT: return (AE_OK); @@ -822,6 +917,14 @@ AcpiDmDumpTable ( } } + if (TableOffset && !SubtableLength) + { + /* If this table is not the main table, subtable must have valid length */ + + AcpiOsPrintf ("Invalid zero length subtable\n"); + return (AE_BAD_DATA); + } + return (AE_OK); } @@ -843,6 +946,7 @@ AcpiDmDumpTable ( static void AcpiDmCheckAscii ( UINT8 *Name, + char *RepairedName, UINT32 Count) { UINT32 i; @@ -850,9 +954,15 @@ AcpiDmCheckAscii ( for (i = 0; i < Count; i++) { - if (!Name[i] || !isprint (Name[i])) + RepairedName[i] = Name[i]; + + if (!Name[i]) { - Name[i] = ' '; + return; + } + if (!isprint (Name[i])) + { + RepairedName[i] = ' '; } } } diff --git a/src/add-ons/kernel/bus_managers/acpi/common/dmtbdump.c b/src/add-ons/kernel/bus_managers/acpi/common/dmtbdump.c index 98504886bb..e2dd8090fa 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/dmtbdump.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/dmtbdump.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dmtbdump - Dump ACPI data tables that contain no AML code - * $Revision: 1.18 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acdisasm.h" #include "actables.h" @@ -260,13 +260,20 @@ AcpiDmDumpFadt ( AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt1); - /* Check for ACPI 2.0+ extended data (cannot depend on Revision field) */ + /* Check for ACPI 1.0B MS extensions (FADT revision 2) */ - if (Table->Length >= sizeof (ACPI_TABLE_FADT)) + if (Table->Revision == 2) { AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt2); } + /* Check for ACPI 2.0+ extended data (FADT revision 3+) */ + + else if (Table->Length >= sizeof (ACPI_TABLE_FADT)) + { + AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt3); + } + /* Validate various fields in the FADT, including length */ AcpiTbCreateLocalFadt (Table, Table->Length); @@ -299,6 +306,7 @@ AcpiDmDumpAsf ( UINT32 DataLength = 0; UINT32 DataOffset = 0; UINT32 i; + UINT8 Type; /* No main table, only sub-tables */ @@ -315,7 +323,11 @@ AcpiDmDumpAsf ( return; } - switch (SubTable->Header.Type & 0x7F) /* Mask off top bit */ + /* The actual type is the lower 7 bits of Type */ + + Type = (UINT8) (SubTable->Header.Type & 0x7F); + + switch (Type) { case ACPI_ASF_TYPE_INFO: InfoTable = AcpiDmTableInfoAsf0; @@ -325,8 +337,8 @@ AcpiDmDumpAsf ( InfoTable = AcpiDmTableInfoAsf1; DataInfoTable = AcpiDmTableInfoAsf1a; DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ALERT)); - DataCount = ((ACPI_ASF_ALERT *) SubTable)->Alerts; - DataLength = ((ACPI_ASF_ALERT *) SubTable)->DataLength; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->Alerts; + DataLength = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->DataLength; DataOffset = Offset + sizeof (ACPI_ASF_ALERT); break; @@ -334,8 +346,8 @@ AcpiDmDumpAsf ( InfoTable = AcpiDmTableInfoAsf2; DataInfoTable = AcpiDmTableInfoAsf2a; DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_REMOTE)); - DataCount = ((ACPI_ASF_REMOTE *) SubTable)->Controls; - DataLength = ((ACPI_ASF_REMOTE *) SubTable)->DataLength; + DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->Controls; + DataLength = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->DataLength; DataOffset = Offset + sizeof (ACPI_ASF_REMOTE); break; @@ -346,7 +358,7 @@ AcpiDmDumpAsf ( case ACPI_ASF_TYPE_ADDRESS: InfoTable = AcpiDmTableInfoAsf4; DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ADDRESS)); - DataLength = ((ACPI_ASF_ADDRESS *) SubTable)->Devices; + DataLength = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, SubTable)->Devices; DataOffset = Offset + sizeof (ACPI_ASF_ADDRESS); break; @@ -364,7 +376,7 @@ AcpiDmDumpAsf ( /* Dump variable-length extra data */ - switch (SubTable->Header.Type & 0x7F) /* Mask off top bit */ + switch (Type) { case ACPI_ASF_TYPE_ALERT: case ACPI_ASF_TYPE_CONTROL: @@ -405,6 +417,9 @@ AcpiDmDumpAsf ( AcpiOsPrintf ("\n"); break; + + default: + break; } AcpiOsPrintf ("\n"); @@ -461,7 +476,7 @@ AcpiDmDumpCpep ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoCpep0); + SubTable->Header.Length, AcpiDmTableInfoCpep0); if (ACPI_FAILURE (Status)) { return; @@ -469,8 +484,9 @@ AcpiDmDumpCpep ( /* Point to next sub-table */ - Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, SubTable->Length); + Offset += SubTable->Header.Length; + SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, + SubTable->Header.Length); } } @@ -538,7 +554,11 @@ AcpiDmDumpDmar ( break; case ACPI_DMAR_TYPE_ATSR: InfoTable = AcpiDmTableInfoDmar2; - ScopeOffset = sizeof (ACPI_DMAR_TYPE_ATSR); + ScopeOffset = sizeof (ACPI_DMAR_ATSR); + break; + case ACPI_DMAR_HARDWARE_AFFINITY: + InfoTable = AcpiDmTableInfoDmar3; + ScopeOffset = sizeof (ACPI_DMAR_RHSA); break; default: AcpiOsPrintf ("\n**** Unknown DMAR sub-table type %X\n\n", SubTable->Type); @@ -636,7 +656,7 @@ AcpiDmDumpEinj ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - 0, AcpiDmTableInfoEinj0); + sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0); if (ACPI_FAILURE (Status)) { return; @@ -689,7 +709,7 @@ AcpiDmDumpErst ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - 0, AcpiDmTableInfoEinj0); + sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0); if (ACPI_FAILURE (Status)) { return; @@ -727,6 +747,8 @@ AcpiDmDumpHest ( UINT32 Offset = sizeof (ACPI_TABLE_HEST); ACPI_DMTABLE_INFO *InfoTable; UINT32 SubTableLength; + UINT32 BankCount; + ACPI_HEST_IA_ERROR_BANK *BankTable; /* Main table */ @@ -742,36 +764,269 @@ AcpiDmDumpHest ( SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset); while (Offset < Table->Length) { - /* TBD: add new subtable types as examples become available */ - + BankCount = 0; switch (SubTable->Type) { - case ACPI_HEST_TYPE_GENERIC_HARDWARE_ERROR_SOURCE: + case ACPI_HEST_TYPE_IA32_CHECK: + InfoTable = AcpiDmTableInfoHest0; + SubTableLength = sizeof (ACPI_HEST_IA_MACHINE_CHECK); + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, + SubTable))->NumHardwareBanks; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + InfoTable = AcpiDmTableInfoHest1; + SubTableLength = sizeof (ACPI_HEST_IA_CORRECTED); + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, + SubTable))->NumHardwareBanks; + break; + + case ACPI_HEST_TYPE_IA32_NMI: + InfoTable = AcpiDmTableInfoHest2; + SubTableLength = sizeof (ACPI_HEST_IA_NMI); + break; + + case ACPI_HEST_TYPE_AER_ROOT_PORT: + InfoTable = AcpiDmTableInfoHest6; + SubTableLength = sizeof (ACPI_HEST_AER_ROOT); + break; + + case ACPI_HEST_TYPE_AER_ENDPOINT: + InfoTable = AcpiDmTableInfoHest7; + SubTableLength = sizeof (ACPI_HEST_AER); + break; + + case ACPI_HEST_TYPE_AER_BRIDGE: + InfoTable = AcpiDmTableInfoHest8; + SubTableLength = sizeof (ACPI_HEST_AER_BRIDGE); + break; + + case ACPI_HEST_TYPE_GENERIC_ERROR: InfoTable = AcpiDmTableInfoHest9; SubTableLength = sizeof (ACPI_HEST_GENERIC); break; default: + /* Cannot continue on unknown type - no length */ + AcpiOsPrintf ("\n**** Unknown HEST sub-table type %X\n", SubTable->Type); return; } AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - 0, InfoTable); + SubTableLength, InfoTable); if (ACPI_FAILURE (Status)) { return; } - /* Point to next sub-table (each subtable is of fixed length) */ + /* Point to end of current subtable (each subtable above is of fixed length) */ Offset += SubTableLength; + + /* If there are any (fixed-length) Error Banks from above, dump them now */ + + if (BankCount) + { + BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, SubTable, SubTableLength); + SubTableLength += BankCount * sizeof (ACPI_HEST_IA_ERROR_BANK); + + while (BankCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, BankTable, + sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank); + if (ACPI_FAILURE (Status)) + { + return; + } + Offset += sizeof (ACPI_HEST_IA_ERROR_BANK); + BankTable++; + BankCount--; + } + } + + /* Point to next sub-table */ + SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, SubTable, SubTableLength); } } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpIvrs + * + * PARAMETERS: Table - A IVRS table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a IVRS + * + ******************************************************************************/ + +static UINT8 EntrySizes[] = {4,8,16,32}; + +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_IVRS); + UINT32 EntryOffset; + UINT32 EntryLength; + UINT32 EntryType; + ACPI_IVRS_DE_HEADER *DeviceEntry; + ACPI_IVRS_HEADER *SubTable; + ACPI_DMTABLE_INFO *InfoTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIvrs); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoIvrsHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + switch (SubTable->Type) + { + case ACPI_IVRS_TYPE_HARDWARE: + InfoTable = AcpiDmTableInfoIvrs0; + break; + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + InfoTable = AcpiDmTableInfoIvrs1; + break; + default: + AcpiOsPrintf ("\n**** Unknown IVRS sub-table type %X\n", + SubTable->Type); + + /* Attempt to continue */ + + if (!SubTable->Length) + { + AcpiOsPrintf ("Invalid zero length subtable\n"); + return; + } + goto NextSubTable; + } + + /* Dump the subtable */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + SubTable->Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* The hardware subtable can contain multiple device entries */ + + if (SubTable->Type == ACPI_IVRS_TYPE_HARDWARE) + { + EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE); + DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, SubTable, + sizeof (ACPI_IVRS_HARDWARE)); + + while (EntryOffset < (Offset + SubTable->Length)) + { + AcpiOsPrintf ("\n"); + /* + * Upper 2 bits of Type encode the length of the device entry + * + * 00 = 4 byte + * 01 = 8 byte + * 10 = 16 byte - currently no entries defined + * 11 = 32 byte - currently no entries defined + */ + EntryType = DeviceEntry->Type; + EntryLength = EntrySizes [EntryType >> 6]; + + switch (EntryType) + { + /* 4-byte device entries */ + + case ACPI_IVRS_TYPE_PAD4: + case ACPI_IVRS_TYPE_ALL: + case ACPI_IVRS_TYPE_SELECT: + case ACPI_IVRS_TYPE_START: + case ACPI_IVRS_TYPE_END: + + InfoTable = AcpiDmTableInfoIvrs4; + break; + + /* 8-byte entries, type A */ + + case ACPI_IVRS_TYPE_ALIAS_SELECT: + case ACPI_IVRS_TYPE_ALIAS_START: + + InfoTable = AcpiDmTableInfoIvrs8a; + break; + + /* 8-byte entries, type B */ + + case ACPI_IVRS_TYPE_PAD8: + case ACPI_IVRS_TYPE_EXT_SELECT: + case ACPI_IVRS_TYPE_EXT_START: + + InfoTable = AcpiDmTableInfoIvrs8b; + break; + + /* 8-byte entries, type C */ + + case ACPI_IVRS_TYPE_SPECIAL: + + InfoTable = AcpiDmTableInfoIvrs8c; + break; + + default: + InfoTable = AcpiDmTableInfoIvrs4; + AcpiOsPrintf ( + "\n**** Unknown IVRS device entry type/length: " + "%.2X/%X at offset %.4X: (header below)\n", + EntryType, EntryLength, EntryOffset); + break; + } + + /* Dump the Device Entry */ + + Status = AcpiDmDumpTable (Table->Length, EntryOffset, + DeviceEntry, EntryLength, InfoTable); + + EntryOffset += EntryLength; + DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, DeviceEntry, + EntryLength); + } + } + +NextSubTable: + /* Point to next sub-table */ + + Offset += SubTable->Length; + SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, SubTable, SubTable->Length); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpMadt @@ -848,9 +1103,23 @@ AcpiDmDumpMadt ( case ACPI_MADT_TYPE_INTERRUPT_SOURCE: InfoTable = AcpiDmTableInfoMadt8; break; + case ACPI_MADT_TYPE_LOCAL_X2APIC: + InfoTable = AcpiDmTableInfoMadt9; + break; + case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: + InfoTable = AcpiDmTableInfoMadt10; + break; default: AcpiOsPrintf ("\n**** Unknown MADT sub-table type %X\n\n", SubTable->Type); - return; + + /* Attempt to continue */ + + if (!SubTable->Length) + { + AcpiOsPrintf ("Invalid zero length subtable\n"); + return; + } + goto NextSubTable; } Status = AcpiDmDumpTable (Length, Offset, SubTable, @@ -860,6 +1129,7 @@ AcpiDmDumpMadt ( return; } +NextSubTable: /* Point to next sub-table */ Offset += SubTable->Length; @@ -910,7 +1180,8 @@ AcpiDmDumpMcfg ( } AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, 0, AcpiDmTableInfoMcfg0); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + sizeof (ACPI_MCFG_ALLOCATION), AcpiDmTableInfoMcfg0); if (ACPI_FAILURE (Status)) { return; @@ -925,6 +1196,58 @@ AcpiDmDumpMcfg ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpMsct + * + * PARAMETERS: Table - A MSCT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a MSCT + * + ******************************************************************************/ + +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_MSCT); + ACPI_MSCT_PROXIMITY *SubTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMsct); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + sizeof (ACPI_MSCT_PROXIMITY), AcpiDmTableInfoMsct0); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to next sub-table */ + + Offset += sizeof (ACPI_MSCT_PROXIMITY); + SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, SubTable, sizeof (ACPI_MSCT_PROXIMITY)); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpSlit @@ -1033,6 +1356,16 @@ AcpiDmDumpSrat ( SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset); while (Offset < Table->Length) { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoSratHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + switch (SubTable->Type) { case ACPI_SRAT_TYPE_CPU_AFFINITY: @@ -1041,9 +1374,20 @@ AcpiDmDumpSrat ( case ACPI_SRAT_TYPE_MEMORY_AFFINITY: InfoTable = AcpiDmTableInfoSrat1; break; + case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: + InfoTable = AcpiDmTableInfoSrat2; + break; default: AcpiOsPrintf ("\n**** Unknown SRAT sub-table type %X\n", SubTable->Type); - return; + + /* Attempt to continue */ + + if (!SubTable->Length) + { + AcpiOsPrintf ("Invalid zero length subtable\n"); + return; + } + goto NextSubTable; } AcpiOsPrintf ("\n"); @@ -1054,6 +1398,7 @@ AcpiDmDumpSrat ( return; } +NextSubTable: /* Point to next sub-table */ Offset += SubTable->Length; @@ -1061,3 +1406,54 @@ AcpiDmDumpSrat ( } } + +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpWdat + * + * PARAMETERS: Table - A WDAT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a WDAT + * + ******************************************************************************/ + +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_WDAT); + ACPI_WDAT_ENTRY *SubTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to next sub-table */ + + Offset += sizeof (ACPI_WDAT_ENTRY); + SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, SubTable, sizeof (ACPI_WDAT_ENTRY)); + } +} diff --git a/src/add-ons/kernel/bus_managers/acpi/common/dmtbinfo.c b/src/add-ons/kernel/bus_managers/acpi/common/dmtbinfo.c index 5db076fde4..832914905d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/dmtbinfo.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/dmtbinfo.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dmtbinfo - Table info for non-AML tables - * $Revision: 1.17 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acdisasm.h" /* This module used for application-level code only */ @@ -139,14 +139,19 @@ #define ACPI_ERST_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_ERST,f) #define ACPI_HEST_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_HEST,f) #define ACPI_HPET_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_HPET,f) +#define ACPI_IVRS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_IVRS,f) #define ACPI_MADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MADT,f) #define ACPI_MCFG_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MCFG,f) +#define ACPI_MSCT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MSCT,f) #define ACPI_SBST_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SBST,f) #define ACPI_SLIT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SLIT,f) #define ACPI_SPCR_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SPCR,f) #define ACPI_SPMI_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SPMI,f) #define ACPI_SRAT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SRAT,f) #define ACPI_TCPA_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_TCPA,f) +#define ACPI_UEFI_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_UEFI,f) +#define ACPI_WAET_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WAET,f) +#define ACPI_WDAT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WDAT,f) #define ACPI_WDRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WDRT,f) /* Subtables */ @@ -163,9 +168,24 @@ #define ACPI_DMAR0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_HARDWARE_UNIT,f) #define ACPI_DMAR1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_RESERVED_MEMORY,f) #define ACPI_DMAR2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_ATSR,f) +#define ACPI_DMAR3_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_RHSA,f) #define ACPI_EINJ0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_WHEA_HEADER,f) +#define ACPI_HEST0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_MACHINE_CHECK,f) +#define ACPI_HEST1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_CORRECTED,f) +#define ACPI_HEST2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_NMI,f) +#define ACPI_HEST6_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_AER_ROOT,f) +#define ACPI_HEST7_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_AER,f) +#define ACPI_HEST8_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_AER_BRIDGE,f) #define ACPI_HEST9_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_GENERIC,f) #define ACPI_HESTN_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_NOTIFY,f) +#define ACPI_HESTB_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_ERROR_BANK,f) +#define ACPI_IVRSH_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_HEADER,f) +#define ACPI_IVRS0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_HARDWARE,f) +#define ACPI_IVRS1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_MEMORY,f) +#define ACPI_IVRSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DE_HEADER,f) +#define ACPI_IVRS8A_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DEVICE8A,f) +#define ACPI_IVRS8B_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DEVICE8B,f) +#define ACPI_IVRS8C_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DEVICE8C,f) #define ACPI_MADT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_LOCAL_APIC,f) #define ACPI_MADT1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_IO_APIC,f) #define ACPI_MADT2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_INTERRUPT_OVERRIDE,f) @@ -175,10 +195,16 @@ #define ACPI_MADT6_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_IO_SAPIC,f) #define ACPI_MADT7_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_LOCAL_SAPIC,f) #define ACPI_MADT8_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_INTERRUPT_SOURCE,f) +#define ACPI_MADT9_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_LOCAL_X2APIC,f) +#define ACPI_MADT10_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f) #define ACPI_MADTH_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_MCFG0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MCFG_ALLOCATION,f) +#define ACPI_MSCT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MSCT_PROXIMITY,f) +#define ACPI_SRATH_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_SRAT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SRAT_CPU_AFFINITY,f) #define ACPI_SRAT1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SRAT_MEM_AFFINITY,f) +#define ACPI_SRAT2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f) +#define ACPI_WDAT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_WDAT_ENTRY,f) /* * Simplify access to flag fields by breaking them up into bytes @@ -192,6 +218,7 @@ #define ACPI_HPET_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_HPET,f,o) #define ACPI_SRAT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_CPU_AFFINITY,f,o) #define ACPI_SRAT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_MEM_AFFINITY,f,o) +#define ACPI_SRAT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f,o) #define ACPI_MADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_MADT,f,o) #define ACPI_MADT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_APIC,f,o) #define ACPI_MADT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_INTERRUPT_OVERRIDE,f,o) @@ -199,6 +226,8 @@ #define ACPI_MADT4_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_APIC_NMI,f,o) #define ACPI_MADT7_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_SAPIC,f,o) #define ACPI_MADT8_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_INTERRUPT_SOURCE,f,o) +#define ACPI_MADT9_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC,f,o) +#define ACPI_MADT10_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f,o) /* @@ -284,12 +313,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] = {ACPI_DMT_NAME4, ACPI_FACS_OFFSET (Signature[0]), "Signature"}, {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Length), "Length"}, {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (HardwareSignature), "Hardware Signature"}, - {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (FirmwareWakingVector), "Firmware Waking Vector(32)"}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (FirmwareWakingVector), "32 Firmware Waking Vector"}, {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (GlobalLock), "Global Lock"}, {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Flags), "Flags (decoded below)"}, {ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (Flags,0), "S4BIOS Support Present"}, - {ACPI_DMT_UINT64, ACPI_FACS_OFFSET (XFirmwareWakingVector), "Firmware Waking Vector(64)"}, + {ACPI_DMT_FLAG1, ACPI_FACS_FLAG_OFFSET (Flags,0), "64-bit Wake Supported (V2)"}, + {ACPI_DMT_UINT64, ACPI_FACS_OFFSET (XFirmwareWakingVector), "64 Firmware Waking Vector"}, {ACPI_DMT_UINT8, ACPI_FACS_OFFSET (Version), "Version"}, + {ACPI_DMT_UINT24, ACPI_FACS_OFFSET (Reserved[0]), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (OspmFlags), "OspmFlags (decoded below)"}, + {ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (OspmFlags,0), "64-bit Wake Env Required (V2)"}, {ACPI_DMT_EXIT, 0, NULL} }; @@ -300,12 +333,14 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] = * ******************************************************************************/ +/* ACPI 1.0 FADT (Version 1) */ + ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = { {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Facs), "FACS Address"}, {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Dsdt), "DSDT Address"}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Model), "Model"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PreferredProfile), "PM Profile"}, + {ACPI_DMT_FADTPM, ACPI_FADT_OFFSET (PreferredProfile), "PM Profile"}, {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (SciInterrupt), "SCI Interrupt"}, {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (SmiCommand), "SMI Command Port"}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiEnable), "ACPI Enable Value"}, @@ -337,46 +372,64 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DayAlarm), "RTC Day Alarm Index"}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MonthAlarm), "RTC Month Alarm Index"}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Century), "RTC Century Index"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (BootFlags), "Boot Architecture Flags"}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (BootFlags), "Boot Flags (decoded below)"}, + + /* Boot Architecture Flags byte 0 */ + + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "Legacy Devices Supported (V2)"}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "8042 Present on ports 60/64 (V2)"}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "VGA Not Present (V4)"}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "MSI Not Supported (V4)"}, + {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "PCIe ASPM Not Supported (V4)"}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Reserved), "Reserved"}, {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Flags), "Flags (decoded below)"}, /* Flags byte 0 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD is operational"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD does not invalidate"}, - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,0), "All CPUs support C1"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,0), "C2 works on MP system"}, - {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,0), "Power button is generic"}, - {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,0), "Sleep button is generic"}, - {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC wakeup not fixed"}, - {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC wakeup/S4 not possible"}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD instruction is operational (V1)"}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD flushes all caches (V1)"}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,0), "All CPUs support C1 (V1)"}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,0), "C2 works on MP system (V1)"}, + {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Power Button (V1)"}, + {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Sleep Button (V1)"}, + {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC wake not in fixed reg space (V1)"}, + {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC can wake system from S4 (V1)"}, /* Flags byte 1 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,1), "32-bit PM Timer"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,1), "Docking Supported"}, - {ACPI_DMT_EXIT, 0, NULL} -}; - -/* ACPI 2.0+ Extensions */ - -ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = -{ - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,1), "Reset Register Supported"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,1), "Sealed Case"}, - {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,1), "Headless - No Video"}, - {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,1), "Native instr after SLP_TYP"}, - {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,1), "PCIEXP_WAK Supported"}, - {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use Platform Timer"}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,1), "32-bit PM Timer (V1)"}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,1), "Docking Supported (V1)"}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,1), "Reset Register Supported (V2)"}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,1), "Sealed Case (V3)"}, + {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,1), "Headless - No Video (V3)"}, + {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use native instr after SLP_TYPx (V3)"}, + {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,1), "PCIEXP_WAK Bits Supported (V4)"}, + {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use Platform Timer (V4)"}, /* Flags byte 2 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,2), "RTC_STS valid after S4"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,2), "Remote Power-on capable"}, - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,2), "APIC Cluster Model"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,2), "APIC Physical Dest Mode"}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,2), "RTC_STS valid on S4 wake (V4)"}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,2), "Remote Power-on capable (V4)"}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Cluster Model (V4)"}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Physical Destination Mode (V4)"}, + {ACPI_DMT_EXIT, 0, NULL} +}; +/* ACPI 1.0 MS Extensions (FADT version 2) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = +{ + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register"}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset"}, + {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* ACPI 2.0+ Extensions (FADT version 3+) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = +{ {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register"}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset"}, {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved"}, @@ -419,9 +472,9 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoAsfHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoAsf0[] = { {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinResetValue), "Minimum Reset Value"}, - {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinResetValue), "Minimum Polling Interval"}, + {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinPollInterval), "Minimum Polling Interval"}, {ACPI_DMT_UINT16, ACPI_ASF0_OFFSET (SystemId), "System ID"}, - {ACPI_DMT_UINT32, ACPI_ASF0_OFFSET (SystemId), "Manufacturer ID"}, + {ACPI_DMT_UINT32, ACPI_ASF0_OFFSET (MfgId), "Manufacturer ID"}, {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (Flags), "Flags"}, {ACPI_DMT_UINT24, ACPI_ASF0_OFFSET (Reserved2[0]), "Reserved"}, {ACPI_DMT_EXIT, 0, NULL} @@ -544,8 +597,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoCpep[] = ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[] = { - {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Length), "Length"}, + {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Header.Type), "Subtable Type"}, + {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Header.Length), "Length"}, {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Id), "Processor ID"}, {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Eid), "Processor EID"}, {ACPI_DMT_UINT32, ACPI_CPEP0_OFFSET (Interval), "Polling Interval"}, @@ -636,6 +689,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[] = {ACPI_DMT_EXIT, 0, NULL} }; +/* 3: Remapping Hardware Static Affinity Structure */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[] = +{ + {ACPI_DMT_UINT32, ACPI_DMAR3_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT64, ACPI_DMAR3_OFFSET (BaseAddress), "Base Address"}, + {ACPI_DMT_UINT32, ACPI_DMAR3_OFFSET (ProximityDomain), "Proximity Domain"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + /******************************************************************************* * @@ -663,7 +726,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[] = ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[] = { {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (HeaderLength), "Injection Header Length"}, - {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT8, ACPI_EINJ_OFFSET (Flags), "Flags"}, + {ACPI_DMT_UINT24, ACPI_EINJ_OFFSET (Reserved[0]), "Reserved"}, {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (Entries), "Injection Entry Count"}, {ACPI_DMT_EXIT, 0, NULL} }; @@ -708,23 +772,126 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHest[] = {ACPI_DMT_EXIT, 0, NULL} }; +/* Common HEST structures for subtables */ + +#define ACPI_DM_HEST_HEADER \ + {ACPI_DMT_HEST, ACPI_HEST0_OFFSET (Header.Type), "Subtable Type"}, \ + {ACPI_DMT_UINT16, ACPI_HEST0_OFFSET (Header.SourceId), "Source Id"} + +#define ACPI_DM_HEST_AER \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved1), "Reserved"}, \ + {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Flags), "Flags"}, \ + {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Enabled), "Enabled"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.RecordsToPreallocate), "Records To Preallocate"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.MaxSectionsPerRecord), "Max Sections Per Record"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.Bus), "Bus"}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Device), "Device"}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Function), "Function"}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.DeviceControl), "DeviceControl"}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved2), "Reserved"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableMask), "Uncorrectable Mask"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableSeverity), "Uncorrectable Severity"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.CorrectableMask), "Correctable Mask"}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.AdvancedCapabilities), "Advanced Capabilities"} + + +/* HEST Subtables */ + +/* 0: IA32 Machine Check Exception */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[] = +{ + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT16, ACPI_HEST0_OFFSET (Reserved1), "Reserved"}, + {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (Flags), "Flags"}, + {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (Enabled), "Enabled"}, + {ACPI_DMT_UINT32, ACPI_HEST0_OFFSET (RecordsToPreallocate), "Records To Preallocate"}, + {ACPI_DMT_UINT32, ACPI_HEST0_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, + {ACPI_DMT_UINT64, ACPI_HEST0_OFFSET (GlobalCapabilityData), "Global Capability Data"}, + {ACPI_DMT_UINT64, ACPI_HEST0_OFFSET (GlobalControlData), "Global Control Data"}, + {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (NumHardwareBanks), "Num Hardware Banks"}, + {ACPI_DMT_UINT56, ACPI_HEST0_OFFSET (Reserved3[0]), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 1: IA32 Corrected Machine Check */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[] = +{ + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT16, ACPI_HEST1_OFFSET (Reserved1), "Reserved"}, + {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (Flags), "Flags"}, + {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (Enabled), "Enabled"}, + {ACPI_DMT_UINT32, ACPI_HEST1_OFFSET (RecordsToPreallocate), "Records To Preallocate"}, + {ACPI_DMT_UINT32, ACPI_HEST1_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, + {ACPI_DMT_HESTNTFY, ACPI_HEST1_OFFSET (Notify), "Notify"}, + {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (NumHardwareBanks), "Num Hardware Banks"}, + {ACPI_DMT_UINT24, ACPI_HEST1_OFFSET (Reserved2[0]), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 2: IA32 Non-Maskable Interrupt */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest2[] = +{ + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (RecordsToPreallocate), "Records To Preallocate"}, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (MaxRawDataLength), "Max Raw Data Length"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + +/* 6: PCI Express Root Port AER */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[] = +{ + ACPI_DM_HEST_HEADER, + ACPI_DM_HEST_AER, + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (RootErrorCommand), "Root Error Command"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 7: PCI Express AER (AER Endpoint) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[] = +{ + ACPI_DM_HEST_HEADER, + ACPI_DM_HEST_AER, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 8: PCI Express/PCI-X Bridge AER */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[] = +{ + ACPI_DM_HEST_HEADER, + ACPI_DM_HEST_AER, + {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (UncorrectableMask2), "2nd Uncorrectable Mask"}, + {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (UncorrectableSeverity2), "2nd Uncorrectable Severity"}, + {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (AdvancedCapabilities2), "2nd Advanced Capabilities"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 9: Generic Hardware Error Source */ + ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[] = { - {ACPI_DMT_HEST, ACPI_HEST9_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST9_OFFSET (SourceId), "Source Id"}, + ACPI_DM_HEST_HEADER, {ACPI_DMT_UINT16, ACPI_HEST9_OFFSET (RelatedSourceId), "Related Source Id"}, - {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (ConfigWriteEnable), "Configuration Write Enable"}, + {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (Reserved), "Reserved"}, {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (Enabled), "Enabled"}, - {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (RecordsToPreAllocate), "Records To Preallocate"}, + {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (RecordsToPreallocate), "Records To Preallocate"}, {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (MaxRawDataLength), "Max Raw Data Length"}, {ACPI_DMT_GAS, ACPI_HEST9_OFFSET (ErrorStatusAddress), "Error Status Address"}, {ACPI_DMT_HESTNTFY, ACPI_HEST9_OFFSET (Notify), "Notify"}, - {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (ErrorStatusBlockLength), "Error Status Block Length"}, + {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (ErrorBlockLength), "Error Status Block Length"}, {ACPI_DMT_EXIT, 0, NULL} }; -ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[10] = +ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[] = { {ACPI_DMT_HESTNTYP, ACPI_HESTN_OFFSET (Type), "Notify Type"}, {ACPI_DMT_UINT8, ACPI_HESTN_OFFSET (Length), "Notify Length"}, @@ -739,6 +906,25 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[10] = }; +/* + * IA32 Error Bank(s) - Follows the ACPI_HEST_IA_MACHINE_CHECK and + * ACPI_HEST_IA_CORRECTED structures. + */ +ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[] = +{ + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (BankNumber), "Bank Number"}, + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (ClearStatusOnInit), "Clear Status On Init"}, + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (StatusFormat), "Status Format"}, + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (ControlRegister), "Control Register"}, + {ACPI_DMT_UINT64, ACPI_HESTB_OFFSET (ControlData), "Control Data"}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (StatusRegister), "Status Register"}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (AddressRegister), "Address Register"}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (MiscRegister), "Misc Register"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + /******************************************************************************* * * HPET - High Precision Event Timer table @@ -752,9 +938,104 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[] = {ACPI_DMT_UINT8, ACPI_HPET_OFFSET (Sequence), "Sequence Number"}, {ACPI_DMT_UINT16, ACPI_HPET_OFFSET (MinimumTick), "Minimum Clock Ticks"}, {ACPI_DMT_UINT8, ACPI_HPET_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_HPET_FLAG_OFFSET (Flags,0), "Page Protect"}, - {ACPI_DMT_FLAG1, ACPI_HPET_FLAG_OFFSET (Flags,0), "4K Page Protect"}, - {ACPI_DMT_FLAG2, ACPI_HPET_FLAG_OFFSET (Flags,0), "64K Page Protect"}, + {ACPI_DMT_FLAG0, ACPI_HPET_FLAG_OFFSET (Flags,0), "4K Page Protect"}, + {ACPI_DMT_FLAG1, ACPI_HPET_FLAG_OFFSET (Flags,0), "64K Page Protect"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + +/******************************************************************************* + * + * IVRS - I/O Virtualization Reporting Structure + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[] = +{ + {ACPI_DMT_UINT32, ACPI_IVRS_OFFSET (Info), "Virtualization Info"}, + {ACPI_DMT_UINT64, ACPI_IVRS_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* Common Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrsHdr[] = +{ + {ACPI_DMT_IVRS, ACPI_IVRSH_OFFSET (Type), "Subtable Type"}, + {ACPI_DMT_UINT8, ACPI_IVRSH_OFFSET (Flags), "Flags"}, + {ACPI_DMT_UINT16, ACPI_IVRSH_OFFSET (Length), "Length"}, + {ACPI_DMT_UINT16, ACPI_IVRSH_OFFSET (DeviceId), "DeviceId"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* IVRS subtables */ + +/* 0x10: I/O Virtualization Hardware Definition (IVHD) Block */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[] = +{ + {ACPI_DMT_UINT16, ACPI_IVRS0_OFFSET (CapabilityOffset), "Capability Offset"}, + {ACPI_DMT_UINT64, ACPI_IVRS0_OFFSET (BaseAddress), "Base Address"}, + {ACPI_DMT_UINT16, ACPI_IVRS0_OFFSET (PciSegmentGroup), "PCI Segment Group"}, + {ACPI_DMT_UINT16, ACPI_IVRS0_OFFSET (Info), "Virtualization Info"}, + {ACPI_DMT_UINT32, ACPI_IVRS0_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 0x20, 0x21, 0x22: I/O Virtualization Memory Definition (IVMD) Block */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[] = +{ + {ACPI_DMT_UINT16, ACPI_IVRS1_OFFSET (AuxData), "Auxiliary Data"}, + {ACPI_DMT_UINT64, ACPI_IVRS1_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT64, ACPI_IVRS1_OFFSET (StartAddress), "Start Address"}, + {ACPI_DMT_UINT64, ACPI_IVRS1_OFFSET (MemoryLength), "Memory Length"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* Device entry header for IVHD block */ + +#define ACPI_DMT_IVRS_DE_HEADER \ + {ACPI_DMT_UINT8, ACPI_IVRSD_OFFSET (Type), "Entry Type"}, \ + {ACPI_DMT_UINT16, ACPI_IVRSD_OFFSET (Id), "Device ID"}, \ + {ACPI_DMT_UINT8, ACPI_IVRSD_OFFSET (DataSetting), "Data Setting"} + +/* 4-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs4[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 8-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8a[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_UINT8, ACPI_IVRS8A_OFFSET (Reserved1), "Reserved"}, + {ACPI_DMT_UINT16, ACPI_IVRS8A_OFFSET (UsedId), "Source Used Device ID"}, + {ACPI_DMT_UINT8, ACPI_IVRS8A_OFFSET (Reserved2), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 8-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8b[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_UINT32, ACPI_IVRS8B_OFFSET (ExtendedData), "Extended Data"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 8-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_UINT8, ACPI_IVRS8C_OFFSET (Handle), "Handle"}, + {ACPI_DMT_UINT16, ACPI_IVRS8C_OFFSET (UsedId), "Source Used Device ID"}, + {ACPI_DMT_UINT8, ACPI_IVRS8C_OFFSET (Variety), "Variety"}, {ACPI_DMT_EXIT, 0, NULL} }; @@ -894,6 +1175,31 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[] = {ACPI_DMT_EXIT, 0, NULL} }; +/* 9: Processor Local X2_APIC (ACPI 4.0) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT9_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (LocalApicId), "Processor x2Apic ID"}, + {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (LapicFlags), "Flags (decoded below)"}, + {ACPI_DMT_FLAG0, ACPI_MADT9_FLAG_OFFSET (LapicFlags,0), "Processor Enabled"}, + {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (Uid), "Processor UID"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 10: Local X2_APIC NMI (ACPI 4.0) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT10_OFFSET (IntiFlags), "Flags (decoded below)"}, + {ACPI_DMT_FLAGS0, ACPI_MADT10_FLAG_OFFSET (IntiFlags,0), "Polarity"}, + {ACPI_DMT_FLAGS2, ACPI_MADT10_FLAG_OFFSET (IntiFlags,0), "Trigger Mode"}, + {ACPI_DMT_UINT32, ACPI_MADT10_OFFSET (Uid), "Processor UID"}, + {ACPI_DMT_UINT8, ACPI_MADT10_OFFSET (Lint), "Interrupt Input LINT"}, + {ACPI_DMT_UINT24, ACPI_MADT10_OFFSET (Reserved[0]), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + /******************************************************************************* * @@ -918,6 +1224,35 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[] = }; +/******************************************************************************* + * + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[] = +{ + {ACPI_DMT_UINT32, ACPI_MSCT_OFFSET (ProximityOffset), "Proximity Offset"}, + {ACPI_DMT_UINT32, ACPI_MSCT_OFFSET (MaxProximityDomains), "Max Proximity Domains"}, + {ACPI_DMT_UINT32, ACPI_MSCT_OFFSET (MaxClockDomains), "Max Clock Domains"}, + {ACPI_DMT_UINT64, ACPI_MSCT_OFFSET (MaxAddress), "Max Physical Address"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* Subtable - Maximum Proximity Domain Information. Version 1 */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[] = +{ + {ACPI_DMT_UINT8, ACPI_MSCT0_OFFSET (Revision), "Revision"}, + {ACPI_DMT_UINT8, ACPI_MSCT0_OFFSET (Length), "Length"}, + {ACPI_DMT_UINT32, ACPI_MSCT0_OFFSET (RangeStart), "Domain Range Start"}, + {ACPI_DMT_UINT32, ACPI_MSCT0_OFFSET (RangeEnd), "Domain Range End"}, + {ACPI_DMT_UINT32, ACPI_MSCT0_OFFSET (ProcessorCapacity), "Processor Capacity"}, + {ACPI_DMT_UINT64, ACPI_MSCT0_OFFSET (MemoryCapacity), "Memory Capacity"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + /******************************************************************************* * * SBST - Smart Battery Specification Table @@ -998,8 +1333,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[] = { - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved"}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterfaceType), "Interface Type"}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved"}, {ACPI_DMT_UINT16, ACPI_SPMI_OFFSET (SpecRevision), "IPMI Spec Version"}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterruptType), "Interrupt Type"}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (GpeNumber), "GPE Number"}, @@ -1011,6 +1346,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[] = {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciBus), "PCI Bus"}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDevice), "PCI Device"}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciFunction), "PCI Function"}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved2), "Reserved"}, {ACPI_DMT_EXIT, 0, NULL} }; @@ -1028,10 +1364,21 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[] = {ACPI_DMT_EXIT, 0, NULL} }; +/* Common Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[] = +{ + {ACPI_DMT_SRAT, ACPI_SRATH_OFFSET (Type), "Subtable Type"}, + {ACPI_DMT_UINT8, ACPI_SRATH_OFFSET (Length), "Length"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* SRAT Subtables */ + +/* 0: Processor Local APIC/SAPIC Affinity */ + ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[] = { - {ACPI_DMT_SRAT, ACPI_SRAT0_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (Header.Length), "Length"}, {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ProximityDomainLo), "Proximity Domain Low(8)"}, {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ApicId), "Apic ID"}, {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Flags), "Flags (decoded below)"}, @@ -1042,19 +1389,34 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[] = {ACPI_DMT_EXIT, 0, NULL} }; +/* 1: Memory Affinity */ + ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[] = { - {ACPI_DMT_SRAT, ACPI_SRAT1_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_SRAT1_OFFSET (Header.Length), "Length"}, {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (ProximityDomain), "Proximity Domain"}, {ACPI_DMT_UINT16, ACPI_SRAT1_OFFSET (Reserved), "Reserved"}, {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (BaseAddress), "Base Address"}, {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Length), "Address Length"}, + {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Reserved1), "Reserved"}, {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Flags), "Flags (decoded below)"}, {ACPI_DMT_FLAG0, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Enabled"}, {ACPI_DMT_FLAG1, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Hot Pluggable"}, {ACPI_DMT_FLAG2, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Non-Volatile"}, - {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Reserved1), "Reserved"}, + {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Reserved2), "Reserved"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[] = +{ + {ACPI_DMT_UINT16, ACPI_SRAT2_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ProximityDomain), "Proximity Domain"}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ApicId), "Apic ID"}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Flags), "Flags (decoded below)"}, + {ACPI_DMT_FLAG0, ACPI_SRAT2_FLAG_OFFSET (Flags,0), "Enabled"}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ClockDomain), "Clock Domain"}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Reserved2), "Reserved"}, {ACPI_DMT_EXIT, 0, NULL} }; @@ -1074,6 +1436,74 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] = }; +/******************************************************************************* + * + * UEFI - UEFI Boot optimization Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[] = +{ + {ACPI_DMT_BUF16, ACPI_UEFI_OFFSET (Identifier[0]), "UUID Identifier"}, + {ACPI_DMT_UINT16, ACPI_UEFI_OFFSET (DataOffset), "Data Offset"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + +/******************************************************************************* + * + * WAET - Windows ACPI Emulated devices Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[] = +{ + {ACPI_DMT_UINT32, ACPI_WAET_OFFSET (Flags), "Flags (decoded below)"}, + {ACPI_DMT_FLAG0, ACPI_WAET_OFFSET (Flags), "RTC needs no INT ack"}, + {ACPI_DMT_FLAG1, ACPI_WAET_OFFSET (Flags), "PM timer, one read only"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + +/******************************************************************************* + * + * WDAT - Watchdog Action Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[] = +{ + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (HeaderLength), "Header Length"}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciSegment), "PCI Segment"}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciBus), "PCI Bus"}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciDevice), "PCI Device"}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciFunction), "PCI Function"}, + {ACPI_DMT_UINT24, ACPI_WDAT_OFFSET (Reserved[0]), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (TimerPeriod), "Timer Period"}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (MaxCount), "Max Count"}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (MinCount), "Min Count"}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (Flags), "Flags (decoded below)"}, + {ACPI_DMT_FLAG0, ACPI_WDAT_OFFSET (Flags), "Enabled"}, + {ACPI_DMT_FLAG7, ACPI_WDAT_OFFSET (Flags), "Stopped When Asleep"}, + {ACPI_DMT_UINT24, ACPI_WDAT_OFFSET (Reserved2[0]), "Reserved"}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (Entries), "Watchdog Entry Count"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + +/* WDAT Subtables - Watchdog Instruction Entries */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[] = +{ + {ACPI_DMT_UINT8, ACPI_WDAT0_OFFSET (Action), "Watchdog Action"}, + {ACPI_DMT_UINT8, ACPI_WDAT0_OFFSET (Instruction), "Instruction"}, + {ACPI_DMT_UINT16, ACPI_WDAT0_OFFSET (Reserved), "Reserved"}, + {ACPI_DMT_GAS, ACPI_WDAT0_OFFSET (RegisterRegion), "Register Region"}, + {ACPI_DMT_UINT32, ACPI_WDAT0_OFFSET (Value), "Value"}, + {ACPI_DMT_UINT32, ACPI_WDAT0_OFFSET (Mask), "Register Mask"}, + {ACPI_DMT_EXIT, 0, NULL} +}; + + /******************************************************************************* * * WDRT - Watchdog Resource Table @@ -1082,19 +1512,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] = ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[] = { - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (HeaderLength), "Header Length"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciSegment), "PCI Segment"}, + {ACPI_DMT_GAS, ACPI_WDRT_OFFSET (ControlRegister), "Control Register"}, + {ACPI_DMT_GAS, ACPI_WDRT_OFFSET (CountRegister), "Count Register"}, + {ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (PciDeviceId), "PCI Device ID"}, + {ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (PciVendorId), "PCI Vendor ID"}, {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciBus), "PCI Bus"}, {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciDevice), "PCI Device"}, {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciFunction), "PCI Function"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (TimerPeriod), "Timer Period"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (MaxCount), "Max Count"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (MinCount), "Min Count"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_WDRT_OFFSET (Flags), "Enabled"}, - {ACPI_DMT_FLAG7, ACPI_WDRT_OFFSET (Flags), "Stopped When Asleep"}, - {ACPI_DMT_UINT24, ACPI_WDRT_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (Entries), "Watchdog Entries"}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciSegment), "PCI Segment"}, + {ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (MaxCount), "Max Count"}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (Units), "Counter Units"}, {ACPI_DMT_EXIT, 0, NULL} }; diff --git a/src/add-ons/kernel/bus_managers/acpi/common/getopt.c b/src/add-ons/kernel/bus_managers/acpi/common/getopt.c index 0bda43c4e7..54cff3ec2d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/getopt.c +++ b/src/add-ons/kernel/bus_managers/acpi/common/getopt.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: getopt - * $Revision: 1.11 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,9 @@ #include #include +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" #define ERR(szz,czz) if(AcpiGbl_Opterr){fprintf(stderr,"%s%s%c\n",argv[0],szz,czz);} diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/Makefile b/src/add-ons/kernel/bus_managers/acpi/compiler/Makefile index 85b52a83b3..740842c023 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/Makefile +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/Makefile @@ -14,6 +14,7 @@ SRCS= aslcompilerparse.c aslcompilerlex.c aslanalyze.c aslcodegen.c \ ../utilities/utdelete.c \ ../utilities/utglobal.c \ ../utilities/utinit.c \ + ../utilities/utlock.c \ ../utilities/utobject.c \ ../utilities/utmisc.c \ ../utilities/utmath.c \ @@ -105,6 +106,8 @@ YFLAGS+= -y -pAslCompiler #CFLAGS+= -D_USE_BERKELEY_YACC #.endif +LDLIBS = -lpthread -lrt + aslmain : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) \ $(LOADLIBES) $(LDLIBS) -o iasl diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslanalyze.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslanalyze.c index ca58948bb4..d44adda8ff 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslanalyze.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslanalyze.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslanalyze.c - check for semantic errors - * $Revision: 1.118 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -121,8 +120,6 @@ #include "acparser.h" #include "amlcode.h" -#include - #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslanalyze") @@ -179,6 +176,10 @@ static UINT32 AnGetInternalMethodReturnType ( ACPI_PARSE_OBJECT *Op); +BOOLEAN +AnIsResultUsed ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -686,7 +687,15 @@ AnCheckForReservedName ( return (ACPI_NOT_RESERVED_NAME); } - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName); + /* + * Was not actually emitted by the compiler. This is a special case, + * however. If the ASL code being compiled was the result of a + * dissasembly, it may possibly contain valid compiler-emitted names + * of the form "_T_x". We don't want to issue an error or even a + * warning and force the user to manually change the names. So, we + * will issue a remark instead. + */ + AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); return (ACPI_COMPILER_RESERVED_NAME); } @@ -722,6 +731,8 @@ AnCheckForReservedMethod ( ASL_METHOD_INFO *MethodInfo) { UINT32 Index; + UINT32 RequiredArgsCurrent; + UINT32 RequiredArgsOld; /* Check for a match against the reserved name list */ @@ -758,15 +769,23 @@ AnCheckForReservedMethod ( Gbl_ReservedMethods++; - /* Matched a reserved method name */ + /* + * Matched a reserved method name + * + * Validate the ASL-defined argument count. Allow two different legal + * arg counts. + */ + RequiredArgsCurrent = ReservedMethods[Index].NumArguments & 0x0F; + RequiredArgsOld = ReservedMethods[Index].NumArguments >> 4; - if (MethodInfo->NumArguments != ReservedMethods[Index].NumArguments) + if ((MethodInfo->NumArguments != RequiredArgsCurrent) && + (MethodInfo->NumArguments != RequiredArgsOld)) { sprintf (MsgBuffer, "%s requires %d", ReservedMethods[Index].Name, - ReservedMethods[Index].NumArguments); + RequiredArgsCurrent); - if (MethodInfo->NumArguments > ReservedMethods[Index].NumArguments) + if (MethodInfo->NumArguments > RequiredArgsCurrent) { AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); @@ -1014,10 +1033,10 @@ AnMethodAnalysisWalkBegin ( if (!MethodInfo) { /* - * Probably was an error in the method declaration, - * no additional error here + * Local was used outside a control method, or there was an error + * in the method declaration. */ - ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); return (AE_ERROR); } @@ -1058,10 +1077,10 @@ AnMethodAnalysisWalkBegin ( if (!MethodInfo) { /* - * Probably was an error in the method declaration, - * no additional error here + * Arg was used outside a control method, or there was an error + * in the method declaration. */ - ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); return (AE_ERROR); } @@ -1709,6 +1728,30 @@ AnOperandTypecheckWalkEnd ( RuntimeArgTypes = OpInfo->RuntimeArgs; OpcodeClass = OpInfo->Class; +#ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE + /* + * Update 11/2008: In practice, we can't perform this check. A simple + * analysis is not sufficient. Also, it can cause errors when compiling + * disassembled code because of the way Switch operators are implemented + * (a While(One) loop with a named temp variable created within.) + */ + + /* + * If we are creating a named object, check if we are within a while loop + * by checking if the parent is a WHILE op. This is a simple analysis, but + * probably sufficient for many cases. + * + * Allow Scope(), Buffer(), and Package(). + */ + if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) || + ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE))) + { + if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP) + { + AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL); + } + } +#endif /* * Special case for control opcodes IF/RETURN/WHILE since they diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcodegen.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcodegen.c index bfbcef3c3a..af3f292e3f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcodegen.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcodegen.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslcodegen - AML code generation - * $Revision: 1.63 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -235,24 +234,24 @@ CgAmlWriteWalk ( DbgPrint (ASL_TREE_OUTPUT, " "); } - DbgPrint (ASL_TREE_OUTPUT, - "%08X %04X %04X %01X %04X %04X %04X %04X %08X %08X %08X %08X %08X %04X %02d %02d\n", - /* 1 */ (UINT32) Op->Asl.Value.Integer, - /* 2 */ Op->Asl.ParseOpcode, - /* 3 */ Op->Asl.AmlOpcode, - /* 4 */ Op->Asl.AmlOpcodeLength, - /* 5 */ Op->Asl.AmlPkgLenBytes, - /* 6 */ Op->Asl.AmlLength, - /* 7 */ Op->Asl.AmlSubtreeLength, - /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, - /* 9 */ Op, - /* 10 */ Op->Asl.Child, - /* 11 */ Op->Asl.Parent, - /* 12 */ Op->Asl.CompileFlags, - /* 13 */ Op->Asl.AcpiBtype, - /* 14 */ Op->Asl.FinalAmlLength, - /* 15 */ Op->Asl.Column, - /* 16 */ Op->Asl.LineNumber); + DbgPrint (ASL_TREE_OUTPUT, + "%08X %04X %04X %01X %04X %04X %04X %04X %08X %08X %08X %08X %08X %04X %02d %02d\n", + /* 1 */ (UINT32) Op->Asl.Value.Integer, + /* 2 */ Op->Asl.ParseOpcode, + /* 3 */ Op->Asl.AmlOpcode, + /* 4 */ Op->Asl.AmlOpcodeLength, + /* 5 */ Op->Asl.AmlPkgLenBytes, + /* 6 */ Op->Asl.AmlLength, + /* 7 */ Op->Asl.AmlSubtreeLength, + /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, + /* 9 */ Op, + /* 10 */ Op->Asl.Child, + /* 11 */ Op->Asl.Parent, + /* 12 */ Op->Asl.CompileFlags, + /* 13 */ Op->Asl.AcpiBtype, + /* 14 */ Op->Asl.FinalAmlLength, + /* 15 */ Op->Asl.Column, + /* 16 */ Op->Asl.LineNumber); /* Generate the AML for this node */ diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompile.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompile.c index 32359f6e7b..07de1fe63c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompile.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompile.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslcompile - top level compile module - * $Revision: 1.99 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -132,6 +131,16 @@ static ACPI_STATUS FlCheckForAscii ( ASL_FILE_INFO *FileInfo); +void +FlConsumeAnsiComment ( + ASL_FILE_INFO *FileInfo, + ASL_FILE_STATUS *Status); + +void +FlConsumeNewComment ( + ASL_FILE_INFO *FileInfo, + ASL_FILE_STATUS *Status); + /******************************************************************************* * @@ -466,7 +475,7 @@ FlCheckForAscii ( /* Check for an ASCII character */ - if (!isascii (Byte)) + if (!ACPI_IS_ASCII (Byte)) { if (BadBytes < 10) { diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.h b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.h index 9f23deaf91..2678c596a2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.h +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.h @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslcompiler.h - common include file for iASL - * $Revision: 1.151 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -140,6 +139,7 @@ #include "acpi.h" +#include "accommon.h" #include "amlresrc.h" #include "acdebug.h" @@ -195,6 +195,10 @@ ACPI_STATUS AslDoOnePathname ( char *Pathname); +ACPI_STATUS +AslDoOneFile ( + char *Filename); + /* * aslcompile - compile mainline */ @@ -551,6 +555,10 @@ void AslAbort ( void); +void +FlAddIncludeDirectory ( + char *Dir); + void FlOpenIncludeFile ( ACPI_PARSE_OBJECT *Op); diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.l b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.l index 5934b83151..d64dbf6a0a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.l +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslcompiler.l @@ -3,7 +3,6 @@ /****************************************************************************** * * Module Name: aslcompiler.l - Flex input file - * $Revision: 1.80 $ * *****************************************************************************/ @@ -11,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -169,7 +168,8 @@ NamePathTail [.]{NameSeg} %% [ ] { count (0); } -[\n] { count (0); } +[\n] { count (0); } /* Handle files with both LF and CR/LF */ +[\r] { count (0); } /* termination on both Unix and Windows */ [ \t] { count (0); } @@ -386,6 +386,7 @@ NamePathTail [.]{NameSeg} "SMBus" { count (0); return (PARSEOP_REGIONSPACE_SMBUS); } "SystemCMOS" { count (0); return (PARSEOP_REGIONSPACE_CMOS); } "PciBarTarget" { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); } +"IPMI" { count (0); return (PARSEOP_REGIONSPACE_IPMI); } "FFixedHW" { count (0); return (PARSEOP_ADDRESSSPACE_FFIXEDHW); } diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asldefine.h b/src/add-ons/kernel/bus_managers/acpi/compiler/asldefine.h index 577cb0a95e..aeb368fa06 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asldefine.h +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asldefine.h @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asldefine.h - Common defines for the iASL compiler - * $Revision: 1.9 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -128,8 +127,8 @@ #define IntelAcpiCA "Intel ACPI Component Architecture" #define CompilerId "ASL Optimizing Compiler" #define DisassemblerId "AML Disassembler" -#define CompilerCopyright "Copyright (C) 2000 - 2008 Intel Corporation" -#define CompilerCompliance "Supports ACPI Specification Revision 3.0a" +#define CompilerCopyright "Copyright (C) 2000 - 2009 Intel Corporation" +#define CompilerCompliance "Supports ACPI Specification Revision 4.0" #define CompilerName "iasl" #define CompilerCreatorId "INTL" diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslerror.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslerror.c index 37a24af84d..87300b1529 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslerror.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslerror.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslerror - Error handling and statistics - * $Revision: 1.95 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -248,6 +247,11 @@ AePrintException ( FILE *SourceFile; + if (Gbl_NoErrors) + { + return; + } + /* * Only listing files have a header, and remarks/optimizations * are always output diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslfiles.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslfiles.c index e6d9304801..3d24ab3970 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslfiles.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslfiles.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslfiles - file I/O suppoert - * $Revision: 1.56 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -129,10 +128,11 @@ FlOpenFile ( char *Filename, char *Mode); -static FILE * -FlOpenLocalFile ( - char *LocalName, - char *Mode); +FILE * +FlOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename); + #ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS @@ -171,34 +171,6 @@ AslAbort ( } -/******************************************************************************* - * - * FUNCTION: FlOpenLocalFile - * - * PARAMETERS: LocalName - Single filename (not a pathname) - * Mode - Open mode for fopen - * - * RETURN: File descriptor - * - * DESCRIPTION: Build a complete pathname for the input filename and open - * the file. - * - ******************************************************************************/ - -static FILE * -FlOpenLocalFile ( - char *LocalName, - char *Mode) -{ - - strcpy (StringBuffer, Gbl_DirectoryPath); - strcat (StringBuffer, LocalName); - - DbgPrint (ASL_PARSE_OUTPUT, "FlOpenLocalFile: %s\n", StringBuffer); - return (fopen (StringBuffer, (const char *) Mode)); -} - - /******************************************************************************* * * FUNCTION: FlFileError @@ -469,6 +441,122 @@ FlSetLineNumber ( } +/******************************************************************************* + * + * FUNCTION: FlAddIncludeDirectory + * + * PARAMETERS: Dir - Directory pathname string + * + * RETURN: None + * + * DESCRIPTION: Add a directory the list of include prefix directories. + * + ******************************************************************************/ + +void +FlAddIncludeDirectory ( + char *Dir) +{ + ASL_INCLUDE_DIR *NewDir; + ASL_INCLUDE_DIR *NextDir; + ASL_INCLUDE_DIR *PrevDir = NULL; + UINT32 NeedsSeparator = 0; + size_t DirLength; + + + DirLength = strlen (Dir); + if (!DirLength) + { + return; + } + + /* Make sure that the pathname ends with a path separator */ + + if ((Dir[DirLength-1] != '/') && + (Dir[DirLength-1] != '\\')) + { + NeedsSeparator = 1; + } + + NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR)); + NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator); + strcpy (NewDir->Dir, Dir); + if (NeedsSeparator) + { + strcat (NewDir->Dir, "/"); + } + + /* + * Preserve command line ordering of -I options by adding new elements + * at the end of the list + */ + NextDir = Gbl_IncludeDirList; + while (NextDir) + { + PrevDir = NextDir; + NextDir = NextDir->Next; + } + + if (PrevDir) + { + PrevDir->Next = NewDir; + } + else + { + Gbl_IncludeDirList = NewDir; + } +} + + +/******************************************************************************* + * + * FUNCTION: FlOpenIncludeWithPrefix + * + * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero + * length string. + * Filename - The include filename from the source ASL. + * + * RETURN: Valid file descriptor if successful. Null otherwise. + * + * DESCRIPTION: Open an include file and push it on the input file stack. + * + ******************************************************************************/ + +FILE * +FlOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename) +{ + FILE *IncludeFile; + char *Pathname; + + + /* Build the full pathname to the file */ + + Pathname = ACPI_ALLOCATE (strlen (PrefixDir) + strlen (Filename) + 1); + + strcpy (Pathname, PrefixDir); + strcat (Pathname, Filename); + + DbgPrint (ASL_PARSE_OUTPUT, "\nAttempt to open include file: path %s\n\n", + Pathname); + + /* Attempt to open the file, push if successful */ + + IncludeFile = fopen (Pathname, "r"); + if (IncludeFile) + { + /* Push the include file on the open input file stack */ + + AslPushInputFileStack (IncludeFile, Pathname); + return (IncludeFile); + } + + ACPI_FREE (Pathname); + return (NULL); +} + + /******************************************************************************* * * FUNCTION: FlOpenIncludeFile @@ -485,7 +573,8 @@ void FlOpenIncludeFile ( ACPI_PARSE_OBJECT *Op) { - FILE *IncFile; + FILE *IncludeFile; + ASL_INCLUDE_DIR *NextDir; /* Op must be valid */ @@ -508,21 +597,58 @@ FlOpenIncludeFile ( FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n"); Gbl_CurrentLineOffset++; - /* Prepend the directory pathname and open the include file */ - DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n", - Op->Asl.Value.String); - IncFile = FlOpenLocalFile (Op->Asl.Value.String, "r"); - if (!IncFile) + /* Attempt to open the include file */ + + /* If the file specifies an absolute path, just open it */ + + if ((Op->Asl.Value.String[0] == '/') || + (Op->Asl.Value.String[0] == '\\') || + (Op->Asl.Value.String[1] == ':')) { - sprintf (MsgBuffer, "%s (%s)", Op->Asl.Value.String, strerror (errno)); - AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer); + IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String); + if (!IncludeFile) + { + goto ErrorExit; + } return; } - /* Push the include file on the open input file stack */ + /* + * The include filename is not an absolute path. + * + * First, search for the file within the "local" directory -- meaning + * the same directory that contains the source file. + * + * Construct the file pathname from the global directory name. + */ + IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String); + if (IncludeFile) + { + return; + } - AslPushInputFileStack (IncFile, Op->Asl.Value.String); + /* + * Second, search for the file within the (possibly multiple) directories + * specified by the -I option on the command line. + */ + NextDir = Gbl_IncludeDirList; + while (NextDir) + { + IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String); + if (IncludeFile) + { + return; + } + + NextDir = NextDir->Next; + } + + /* We could not open the include file after trying very hard */ + +ErrorExit: + sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno)); + AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer); } diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslfold.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslfold.c index 0d8ddf75e1..4bb305ef1c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslfold.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslfold.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslfold - Constant folding - * $Revision: 1.21 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -481,7 +480,7 @@ OpcAmlConstantWalk ( * Because we know we executed type 3/4/5 opcodes above, we know that * the result must be either an Integer, String, or Buffer. */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_INTEGER: diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslglobal.h b/src/add-ons/kernel/bus_managers/acpi/compiler/aslglobal.h index 5e7dad2b4d..6aecfb6fb4 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslglobal.h +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslglobal.h @@ -3,7 +3,6 @@ /****************************************************************************** * * Module Name: aslglobal.h - Global variable definitions - * $Revision: 1.58 $ * *****************************************************************************/ @@ -11,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -149,7 +148,7 @@ extern char HexLookup[]; #define ASL_LINE_BUFFER_SIZE 512 #define ASL_MSG_BUFFER_SIZE 4096 #define HEX_TABLE_LINE_SIZE 8 -#define HEX_LISTING_LINE_SIZE 16 +#define HEX_LISTING_LINE_SIZE 8 /* Source code buffers and pointers for error reporting */ @@ -189,6 +188,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ParseOnlyFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE); @@ -212,6 +212,7 @@ ASL_EXTERN char *Gbl_DirectoryPath; ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_ExternalFilename, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL); +ASL_EXTERN ASL_INCLUDE_DIR ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL); ASL_EXTERN char *Gbl_CurrentInputFilename; ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE); diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asllength.c b/src/add-ons/kernel/bus_managers/acpi/compiler/asllength.c index 45184dd4e9..bd222e68f4 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asllength.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asllength.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asllength - Tree walk to determine package and opcode lengths - * $Revision: 1.38 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asllisting.c b/src/add-ons/kernel/bus_managers/acpi/compiler/asllisting.c index 2c1675856a..f229d5fb78 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asllisting.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asllisting.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asllisting - Listing file generation - * $Revision: 1.64 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -199,6 +198,12 @@ static void LsDoHexOutputAsm ( void); +ACPI_STATUS +LsTreeWriteWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + /******************************************************************************* * diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslload.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslload.c index 9691ab3cf7..8d06544e7d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslload.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslload.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * $Revision: 1.79 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -145,7 +144,13 @@ LdNamespace1Begin ( void *Context); static ACPI_STATUS -LdNamespace1End ( +LdNamespace2Begin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +LdCommonNamespaceEnd ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); @@ -160,7 +165,7 @@ LdNamespace1End ( * RETURN: Status * * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the - * named ASL/AML objects into the namespace. The namespace is + * named ASL/AML objects into the namespace. The namespace is * constructed in order to resolve named references and references * to named fields within resource templates/descriptors. * @@ -183,10 +188,15 @@ LdLoadNamespace ( return AE_NO_MEMORY; } - /* Perform the walk of the parse tree */ + /* Walk the entire parse tree, first pass */ TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, - LdNamespace1End, WalkState); + LdCommonNamespaceEnd, WalkState); + + /* Second pass to handle forward references */ + + TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace2Begin, + LdCommonNamespaceEnd, WalkState); /* Dump the namespace if debug is enabled */ @@ -304,7 +314,7 @@ LdLoadFieldElements ( * DESCRIPTION: Enter the named elements of the resource descriptor (children * of the parent) into the namespace. * - * NOTE: In the real AML namespace, these named elements never exist. But + * NOTE: In the real AML namespace, these named elements never exist. But * we simply use the namespace here as a symbol table so we can look * them up as they are referenced. * @@ -343,6 +353,7 @@ LdLoadResourceElements ( Node->Value = (UINT32) Op->Asl.Value.Integer; Node->Op = Op; + Op->Asl.Node = Node; /* * Now enter the predefined fields, for easy lookup when referenced @@ -395,7 +406,7 @@ LdLoadResourceElements ( * * RETURN: Status * - * DESCRIPTION: Descending callback used during the parse tree walk. If this + * DESCRIPTION: Descending callback used during the parse tree walk. If this * is a named AML opcode, enter into the namespace * ******************************************************************************/ @@ -536,7 +547,7 @@ LdNamespace1Begin ( * The name referenced by Scope(Name) must already exist at this point. * In other words, forward references for Scope() are not supported. * The only real reason for this is that the MS interpreter cannot - * handle this case. Perhaps someday this case can go away. + * handle this case. Perhaps someday this case can go away. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, @@ -621,7 +632,7 @@ LdNamespace1Begin ( /* * However, switch the type to be an actual scope so * that compilation can continue without generating a whole - * cascade of additional errors. Open the new scope. + * cascade of additional errors. Open the new scope. */ Node->Type = ACPI_TYPE_LOCAL_SCOPE; Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, @@ -652,8 +663,8 @@ LdNamespace1Begin ( Flags |= ACPI_NS_ERROR_IF_FOUND; /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that * involve arguments to the opcode must be created as we go back up the * parse tree later. */ @@ -753,7 +764,143 @@ Exit: /******************************************************************************* * - * FUNCTION: LdNamespace1End + * FUNCTION: LdNamespace2Begin + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the pass 2 parse tree walk. + * Second pass resolves some forward references. + * + * Notes: + * Currently only needs to handle the Alias operator. + * Could be used to allow forward references from the Scope() operator, but + * the MS interpreter does not allow this, so this compiler does not either. + * + ******************************************************************************/ + +static ACPI_STATUS +LdNamespace2Begin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE ObjectType; + BOOLEAN ForceNewScope = FALSE; + ACPI_PARSE_OBJECT *Arg; + char *Path; + ACPI_NAMESPACE_NODE *TargetNode; + + + ACPI_FUNCTION_NAME (LdNamespace2Begin); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", + Op, Op->Asl.ParseOpName)); + + + /* Ignore Ops with no namespace node */ + + Node = Op->Asl.Node; + if (!Node) + { + return (AE_OK); + } + + /* Get the type to determine if we should push the scope */ + + if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && + (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)) + { + ObjectType = ACPI_TYPE_LOCAL_RESOURCE; + } + else + { + ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); + } + + /* Push scope for Resource Templates */ + + if (Op->Asl.ParseOpcode == PARSEOP_NAME) + { + if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) + { + ForceNewScope = TRUE; + } + } + + /* Push the scope stack */ + + if (ForceNewScope || AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (Op->Asl.ParseOpcode == PARSEOP_ALIAS) + { + /* Complete the alias node by getting and saving the target node */ + + /* First child is the alias target */ + + Arg = Op->Asl.Child; + + /* Get the target pathname */ + + Path = Arg->Asl.Namepath; + if (!Path) + { + Status = UtInternalizeName (Arg->Asl.ExternalName, &Path); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* Get the NS node associated with the target. It must exist. */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &TargetNode); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, + Op->Asl.ExternalName); + + /* + * The name was not found, go ahead and create it. + * This prevents more errors later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, + ACPI_TYPE_ANY, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, + WalkState, &(Node)); + return (AE_OK); + } + + AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE); + return (AE_OK); + } + + /* Save the target node within the alias node */ + + Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: LdCommonNamespaceEnd * * PARAMETERS: ASL_WALK_CALLBACK * @@ -765,7 +912,7 @@ Exit: ******************************************************************************/ static ACPI_STATUS -LdNamespace1End ( +LdCommonNamespaceEnd ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) @@ -775,7 +922,7 @@ LdNamespace1End ( BOOLEAN ForceNewScope = FALSE; - ACPI_FUNCTION_NAME (LdNamespace1End); + ACPI_FUNCTION_NAME (LdCommonNamespaceEnd); /* We are only interested in opcodes that have an associated name */ @@ -813,7 +960,6 @@ LdNamespace1End ( if (ForceNewScope || AcpiNsOpensScope (ObjectType)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op [%s] %p\n", AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asllookup.c b/src/add-ons/kernel/bus_managers/acpi/compiler/asllookup.c index 3592be3ba6..51c036967c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asllookup.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asllookup.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: asllookup- Namespace lookup - * $Revision: 1.106 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -181,6 +180,14 @@ LsDoOnePathname ( void *Context, void **ReturnValue); +void +LsSetupNsList ( + void *Handle); + +ACPI_PARSE_OBJECT * +LkGetNameOp ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -436,7 +443,8 @@ LsDoOneNamespaceObject ( ******************************************************************************/ void -LsSetupNsList (void * Handle) +LsSetupNsList ( + void *Handle) { Gbl_NsOutputFlag = TRUE; @@ -922,6 +930,17 @@ LkNamespaceLocateBegin ( return (AE_OK); } + /* + * One special case: CondRefOf operator - we don't care if the name exists + * or not at this point, just ignore it, the point of the operator is to + * determine if the name exists at runtime. + */ + if ((Op->Asl.Parent) && + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) + { + return (AE_OK); + } + /* * We must enable the "search-to-root" for single NameSegs, but * we have to be very careful about opening up scopes @@ -1010,14 +1029,6 @@ LkNamespaceLocateBegin ( { /* The name doesn't exist, period */ - if ((Op->Asl.Parent) && - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) - { - /* Ignore not found if parent is CondRefOf */ - - return (AE_OK); - } - AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName); } @@ -1030,14 +1041,6 @@ LkNamespaceLocateBegin ( { /* Gave full path, the object does not exist */ - if ((Op->Asl.Parent) && - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) - { - /* Ignore not found if parent is CondRefOf */ - - return (AE_OK); - } - AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName); } @@ -1334,6 +1337,7 @@ LkNamespaceLocateBegin ( break; case REGION_SMBUS: + case REGION_IPMI: if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER) { diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslmain.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslmain.c index 780f7d56de..aa29ab82f8 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslmain.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslmain.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslmain - compiler main and utilities - * $Revision: 1.99 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,8 +118,6 @@ #define _DECLARE_GLOBALS #include "aslcompiler.h" -#include "acnamesp.h" -#include "actables.h" #include "acapps.h" #ifdef _DEBUG @@ -153,6 +150,28 @@ AslCommandLine ( int argc, char **argv); +static int +AslDoOptions ( + int argc, + char **argv, + BOOLEAN IsResponseFile); + +static void +AslMergeOptionTokens ( + char *InBuffer, + char *OutBuffer); + +static int +AslDoResponseFile ( + char *Filename); + +extern int AcpiGbl_Opterr; +extern int AcpiGbl_Optind; + + +#define ASL_TOKEN_SEPARATORS " \t\n" +#define ASL_SUPPORTED_OPTIONS "@:2b:cd^e:fgh^i^I:l^o:p:r:s:t:v:w:x:" + /******************************************************************************* * @@ -171,8 +190,13 @@ Options ( void) { - printf ("General Output:\n"); - printf (" -p Specify path/filename prefix for all output files\n"); + printf ("Global:\n"); + printf (" -@ Specify command file\n"); + printf (" -I Specify additional include directory\n"); + + printf ("\nGeneral Output:\n"); + printf (" -p Specify path/filename prefix for all output files\n"); + printf (" -va Disable all errors and warnings (summary only)\n"); printf (" -vi Less verbose errors and warnings for use with IDEs\n"); printf (" -vo Enable optimization comments\n"); printf (" -vr Disable remarks\n"); @@ -200,7 +224,7 @@ Options ( printf (" -d [file] Disassemble or decode binary ACPI table to file (*.dsl)\n"); printf (" -dc [file] Disassemble AML and immediately compile it\n"); printf (" (Obtain DSDT from current system if no input file)\n"); - printf (" -e [file] Include ACPI table for external symbol resolution\n"); + printf (" -e [f1,f2] Include ACPI table(s) for external symbol resolution\n"); printf (" -2 Emit ACPI 2.0 compatible ASL code\n"); printf (" -g Get ACPI tables and write to files (*.dat)\n"); @@ -312,39 +336,149 @@ AslInitialize ( /******************************************************************************* * - * FUNCTION: AslCommandLine + * FUNCTION: AslMergeOptionTokens * - * PARAMETERS: argc/argv + * PARAMETERS: InBuffer - Input containing an option string + * OutBuffer - Merged output buffer * * RETURN: None * - * DESCRIPTION: Command line processing + * DESCRIPTION: Remove all whitespace from an option string. + * + ******************************************************************************/ + +static void +AslMergeOptionTokens ( + char *InBuffer, + char *OutBuffer) +{ + char *Token; + + + *OutBuffer = 0; + + Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); + while (Token) + { + strcat (OutBuffer, Token); + Token = strtok (NULL, ASL_TOKEN_SEPARATORS); + } +} + + +/******************************************************************************* + * + * FUNCTION: AslDoResponseFile + * + * PARAMETERS: Filename - Name of the response file + * + * RETURN: Status + * + * DESCRIPTION: Open a response file and process all options within. * ******************************************************************************/ static int -AslCommandLine ( - int argc, - char **argv) +AslDoResponseFile ( + char *Filename) +{ + char *argv = StringBuffer2; + FILE *ResponseFile; + int OptStatus = 0; + int Opterr; + int Optind; + + + ResponseFile = fopen (Filename, "r"); + if (!ResponseFile) + { + printf ("Could not open command file %s, %s\n", + Filename, strerror (errno)); + return -1; + } + + /* Must save the current GetOpt globals */ + + Opterr = AcpiGbl_Opterr; + Optind = AcpiGbl_Optind; + + /* + * Process all lines in the response file. There must be one complete + * option per line + */ + while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) + { + /* Compress all tokens, allowing us to use a single argv entry */ + + AslMergeOptionTokens (StringBuffer, StringBuffer2); + + /* Process the option */ + + AcpiGbl_Opterr = 0; + AcpiGbl_Optind = 0; + + OptStatus = AslDoOptions (1, &argv, TRUE); + if (OptStatus) + { + printf ("Invalid option in command file %s: %s\n", + Filename, StringBuffer); + break; + } + } + + /* Restore the GetOpt globals */ + + AcpiGbl_Opterr = Opterr; + AcpiGbl_Optind = Optind; + + fclose (ResponseFile); + return (OptStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AslDoOptions + * + * PARAMETERS: argc/argv - Standard argc/argv + * IsResponseFile - TRUE if executing a response file. + * + * RETURN: Status + * + * DESCRIPTION: Command line option processing + * + ******************************************************************************/ + +static int +AslDoOptions ( + int argc, + char **argv, + BOOLEAN IsResponseFile) { - BOOLEAN BadCommandLine = FALSE; int j; - /* Minimum command line contains at least one option or an input file */ - - if (argc < 2) - { - AslCompilerSignon (ASL_FILE_STDOUT); - Usage (); - exit (1); - } - /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, "2b:cd^e:fgh^i^l^o:p:r:s:t:v:w:x:")) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) { + case '@': /* Begin a response file */ + + if (IsResponseFile) + { + printf ("Nested command files are not supported\n"); + return -1; + } + + if (AslDoResponseFile (AcpiGbl_Optarg)) + { + return -1; + } + break; + + case '2': + Gbl_Acpi2 = TRUE; break; @@ -366,8 +500,7 @@ AslCommandLine ( default: printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } /* Produce debug output file */ @@ -396,8 +529,7 @@ AslCommandLine ( default: printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } Gbl_DisasmFlag = TRUE; @@ -446,12 +578,17 @@ AslCommandLine ( default: printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; + case 'I': /* Add an include file search directory */ + + FlAddIncludeDirectory (AcpiGbl_Optarg); + break; + + case 'i': switch (AcpiGbl_Optarg[0]) @@ -472,8 +609,7 @@ AslCommandLine ( default: printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -502,8 +638,7 @@ AslCommandLine ( default: printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -551,8 +686,7 @@ AslCommandLine ( default: printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -591,8 +725,7 @@ AslCommandLine ( default: printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -613,8 +746,7 @@ AslCommandLine ( default: printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -623,6 +755,12 @@ AslCommandLine ( switch (AcpiGbl_Optarg[0]) { + case 'a': + /* Disable All error/warning messages */ + + Gbl_NoErrors = TRUE; + break; + case 'i': /* Less verbose error messages */ @@ -643,8 +781,7 @@ AslCommandLine ( default: printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -667,8 +804,7 @@ AslCommandLine ( default: printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -681,10 +817,46 @@ AslCommandLine ( default: - BadCommandLine = TRUE; - break; + return (-1); } + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AslCommandLine + * + * PARAMETERS: argc/argv + * + * RETURN: Last argv index + * + * DESCRIPTION: Command line processing + * + ******************************************************************************/ + +static int +AslCommandLine ( + int argc, + char **argv) +{ + int BadCommandLine = 0; + + + /* Minimum command line contains at least the command and an input file */ + + if (argc < 2) + { + AslCompilerSignon (ASL_FILE_STDOUT); + Usage (); + exit (1); + } + + /* Process all command line options */ + + BadCommandLine = AslDoOptions (argc, argv, FALSE); + /* Next parameter must be the input filename */ if (!argv[AcpiGbl_Optind] && @@ -745,6 +917,18 @@ main ( AslInitialize (); Index = AslCommandLine (argc, argv); + /* Options that have no additional parameters or pathnames */ + + if (Gbl_GetAllTables) + { + Status = AslDoOneFile (NULL); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + return (0); + } + /* Process each pathname/filename in the list, with possible wildcards */ while (argv[Index]) diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslmap.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslmap.c index 9c2242214b..4c1fdf0c6f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslmap.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslmap.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslmap - parser to AML opcode mapping table - * $Revision: 1.88 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -205,7 +204,7 @@ MpDisplayReservedNames ( else { printf ("Method with %d arguments, ", - ReservedMethods[i].NumArguments); + ReservedMethods[i].NumArguments & 0x0F); if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE) { @@ -233,7 +232,8 @@ MpDisplayReservedNames ( * * Name - The ACPI reserved name * Args - Number of arguments to the method - * Flags - Whether this method must return a value or not + * Flags - Whether this method must return a value or not. Or if the + * name is a resource descriptor label. * ******************************************************************************/ @@ -265,24 +265,30 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_ALP", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_ALR", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_ALT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_ART", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_ASI", 0, ASL_RSVD_RESOURCE_NAME}, {"_ASZ", 0, ASL_RSVD_RESOURCE_NAME}, {"_BAS", 0, ASL_RSVD_RESOURCE_NAME}, {"_BBN", 0, ASL_RSVD_RETURN_VALUE}, {"_BCL", 0, ASL_RSVD_RETURN_VALUE}, {"_BCM", 1, 0}, + {"_BCT", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_BDN", 0, ASL_RSVD_RETURN_VALUE}, {"_BFS", 1, 0}, {"_BIF", 0, ASL_RSVD_RETURN_VALUE}, + {"_BIX", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_BLT", 3, 0}, /* Acpi 3.0 */ {"_BM_", 0, ASL_RSVD_RESOURCE_NAME}, + {"_BMA", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_BMC", 1, 0}, /* Acpi 3.0 */ {"_BMD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_BMS", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_BQC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_BST", 0, ASL_RSVD_RETURN_VALUE}, {"_BTM", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_BTP", 1, 0}, {"_CBA", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_CDM", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_CID", 0, ASL_RSVD_RETURN_VALUE}, {"_CRS", 0, ASL_RSVD_RETURN_VALUE}, {"_CRT", 0, ASL_RSVD_RETURN_VALUE}, @@ -301,6 +307,7 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_DSM", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_DSS", 1, 0}, {"_DSW", 3, 0}, /* Acpi 3.0 */ + {"_DTI", 1, 0}, /* Acpi 4.0 */ {"_EC_", 0, ASL_RSVD_RETURN_VALUE}, {"_EDL", 0, ASL_RSVD_RETURN_VALUE}, {"_EJ0", 1, 0}, @@ -313,7 +320,13 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_FDE", 0, ASL_RSVD_RETURN_VALUE}, {"_FDI", 0, ASL_RSVD_RETURN_VALUE}, {"_FDM", 1, 0}, + {"_FIF", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_FIX", 0, ASL_RSVD_RETURN_VALUE}, + {"_FPS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_FSL", 1, 0}, /* Acpi 4.0 */ + {"_FST", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_GAI", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_GHL", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_GL_", 0, ASL_RSVD_RETURN_VALUE}, {"_GLK", 0, ASL_RSVD_RETURN_VALUE}, {"_GPD", 0, ASL_RSVD_RETURN_VALUE}, @@ -339,28 +352,39 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_MAF", 0, ASL_RSVD_RESOURCE_NAME}, {"_MAT", 0, ASL_RSVD_RETURN_VALUE}, {"_MAX", 0, ASL_RSVD_RESOURCE_NAME}, + {"_MBM", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_MEM", 0, ASL_RSVD_RESOURCE_NAME}, {"_MIF", 0, ASL_RSVD_RESOURCE_NAME}, {"_MIN", 0, ASL_RSVD_RESOURCE_NAME}, {"_MLS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_MSG", 1, 0}, + {"_MSM", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_MTP", 0, ASL_RSVD_RESOURCE_NAME}, + {"_NTT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_OFF", 0, 0}, {"_ON_", 0, 0}, {"_OS_", 0, ASL_RSVD_RETURN_VALUE}, {"_OSC", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_OSI", 1, ASL_RSVD_RETURN_VALUE}, {"_OST", 3, 0}, /* Acpi 3.0 */ + {"_PAI", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PCL", 0, ASL_RSVD_RETURN_VALUE}, {"_PCT", 0, ASL_RSVD_RETURN_VALUE}, {"_PDC", 1, 0}, + {"_PDL", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PIC", 1, 0}, + {"_PIF", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PLD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_PMC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_PMD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_PMM", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PPC", 0, ASL_RSVD_RETURN_VALUE}, {"_PPE", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_PR0", 0, ASL_RSVD_RETURN_VALUE}, {"_PR1", 0, ASL_RSVD_RETURN_VALUE}, {"_PR2", 0, ASL_RSVD_RETURN_VALUE}, + {"_PR3", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_PRL", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PRS", 0, ASL_RSVD_RETURN_VALUE}, {"_PRT", 0, ASL_RSVD_RETURN_VALUE}, {"_PRW", 0, ASL_RSVD_RETURN_VALUE}, @@ -376,7 +400,9 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_PSV", 0, ASL_RSVD_RETURN_VALUE}, {"_PSW", 1, 0}, {"_PTC", 0, ASL_RSVD_RETURN_VALUE}, + {"_PTP", 2, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PTS", 1, 0}, + {"_PUR", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_PXM", 0, ASL_RSVD_RETURN_VALUE}, {"_RBO", 0, ASL_RSVD_RESOURCE_NAME}, {"_RBW", 0, ASL_RSVD_RESOURCE_NAME}, @@ -405,9 +431,10 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_S4W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_SB_", 0, ASL_RSVD_SCOPE}, {"_SBS", 0, ASL_RSVD_RETURN_VALUE}, - {"_SCP", 1, 0}, + {"_SCP", 0x13, 0}, /* Acpi 1.0 - one arg; Acpi 3.0 - three args */ {"_SDD", 1, 0}, /* Acpi 3.0 */ {"_SEG", 0, ASL_RSVD_RETURN_VALUE}, + {"_SHL", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_SHR", 0, ASL_RSVD_RESOURCE_NAME}, {"_SI_", 0, ASL_RSVD_SCOPE}, {"_SIZ", 0, ASL_RSVD_RESOURCE_NAME}, @@ -418,12 +445,16 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_SST", 1, 0}, {"_STA", 0, ASL_RSVD_RETURN_VALUE}, {"_STM", 3, 0}, + {"_STP", 2, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_STR", 0, ASL_RSVD_RETURN_VALUE}, + {"_STV", 2, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_SUN", 0, ASL_RSVD_RETURN_VALUE}, {"_SWS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_TC1", 0, ASL_RSVD_RETURN_VALUE}, {"_TC2", 0, ASL_RSVD_RETURN_VALUE}, {"_TDL", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0b */ + {"_TIP", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ + {"_TIV", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 4.0 */ {"_TMP", 0, ASL_RSVD_RETURN_VALUE}, {"_TPC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_TPT", 1, 0}, /* Acpi 3.0 */ @@ -682,6 +713,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_CMOS, 0, 0), /* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_EC, 0, 0), /* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IO, 0, 0), +/* REGIONSPACE_IPMI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IPMI, 0, 0), /* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_MEMORY, 0, 0), /* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_CONFIG, 0, 0), /* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_BAR, 0, 0), diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslopcodes.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslopcodes.c index 4da2d95769..e386266427 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslopcodes.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslopcodes.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslopcode - AML opcode generation - * $Revision: 1.75 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asloperands.c b/src/add-ons/kernel/bus_managers/acpi/compiler/asloperands.c index 7dc2e3ed6c..c354855dd6 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asloperands.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asloperands.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asloperands - AML operand processing - * $Revision: 1.64 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslopt.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslopt.c index c54143ec92..3013f4cbd2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslopt.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslopt.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: aslopt- Compiler optimizations - * $Revision: 1.27 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -437,7 +436,7 @@ OptBuildShortestPath ( { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %u old %u)", - ACPI_STRLEN (NewPath), AmlNameStringLength)); + (UINT32) ACPI_STRLEN (NewPath), (UINT32) AmlNameStringLength)); ACPI_FREE (NewPathExternal); return (AE_NOT_FOUND); } @@ -753,8 +752,8 @@ OptOptimizeNamePath ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "%37s (%2u) ==> %-32s(%2u) %-32s", - (char *) CurrentPath.Pointer, CurrentPath.Length, - (char *) TargetPath.Pointer, TargetPath.Length, ExternalNameString)); + (char *) CurrentPath.Pointer, (UINT32) CurrentPath.Length, + (char *) TargetPath.Pointer, (UINT32) TargetPath.Length, ExternalNameString)); ACPI_FREE (ExternalNameString); @@ -812,7 +811,7 @@ OptOptimizeNamePath ( OptTotal += HowMuchShorter; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED %2u (%u)", - HowMuchShorter, OptTotal)); + (UINT32) HowMuchShorter, OptTotal)); if (Flags & AML_NAMED) { diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslresource.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslresource.c index 5228102a42..ceebd9c1e8 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslresource.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslresource.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslresource - Resource templates and descriptors - * $Revision: 1.44 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype1.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype1.c index d1c01a78c0..edc8405403 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype1.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype1.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslrestype1 - Short (type1) resource templates and descriptors - * $Revision: 1.41 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype2.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype2.c index 5aee3cb1b5..7074a5576e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype2.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslrestype2.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslrestype2 - Long (type2) resource templates and descriptors - * $Revision: 1.52 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -2488,20 +2487,25 @@ RsDoInterruptDescriptor ( InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - if (StringLength) - { - /* Make room for the ResourceSourceIndex */ - - OptionIndex++; - } /* Count the interrupt numbers */ for (i = 0; InitializerOp; i++) { InitializerOp = ASL_GET_PEER_NODE (InitializerOp); + if (i <= 6) { + if (i == 3 && + InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* + * ResourceSourceIndex was specified, always make room for + * it, even if the ResourceSource was omitted. + */ + OptionIndex++; + } + continue; } @@ -2636,6 +2640,14 @@ RsDoInterruptDescriptor ( if (i == 7) { + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + /* Must be at least one interrupt */ + + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN, + InitializerOp, NULL); + } + /* Check now for duplicates in list */ RsCheckListForDuplicates (InitializerOp); diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslstartup.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslstartup.c index f3238bb92e..87e102bd9e 100755 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslstartup.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslstartup.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslstartup - Compiler startup routines, called from main - * $Revision: 1.5 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +116,6 @@ #include "aslcompiler.h" -#include "acnamesp.h" #include "actables.h" #include "acapps.h" @@ -142,10 +140,6 @@ AsDoWildcard ( char *DirectoryPathname, char *FileSpecifier); -static ACPI_STATUS -AslDoOneFile ( - char *Filename); - /******************************************************************************* * @@ -275,7 +269,7 @@ AsDoWildcard ( * ******************************************************************************/ -static ACPI_STATUS +ACPI_STATUS AslDoOneFile ( char *Filename) { diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslstubs.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslstubs.c index cc7ca7bd3d..b352a68a9d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslstubs.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslstubs.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslstubs - Stubs used to link to Aml interpreter - * $Revision: 1.23 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +114,12 @@ * *****************************************************************************/ -#include #include "aslcompiler.h" #include "acdispat.h" #include "actables.h" #include "acevents.h" #include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslstubs") @@ -138,6 +137,30 @@ AeLocalGetRootPointer ( return 0; } +void +AcpiNsExecModuleCodeList ( + void) +{ +} + +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + return (AE_OK); +} + ACPI_STATUS AcpiDsMethodError ( ACPI_STATUS Status, @@ -148,7 +171,7 @@ AcpiDsMethodError ( ACPI_STATUS AcpiDsMethodDataGetValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc) @@ -158,7 +181,7 @@ AcpiDsMethodDataGetValue ( ACPI_STATUS AcpiDsMethodDataGetNode ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node) @@ -168,7 +191,7 @@ AcpiDsMethodDataGetNode ( ACPI_STATUS AcpiDsStoreObjectToLocal ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *SrcDesc, ACPI_WALK_STATE *WalkState) diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asltransform.c b/src/add-ons/kernel/bus_managers/acpi/compiler/asltransform.c index 2063cbd3b8..eb4546818c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asltransform.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asltransform.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asltransform - Parse tree transforms - * $Revision: 1.44 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -778,7 +777,7 @@ TrDoSwitch ( case ACPI_BTYPE_STRING: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, - (ACPI_INTEGER) ""); + (ACPI_INTEGER) ACPI_TO_INTEGER ("")); break; case ACPI_BTYPE_BUFFER: diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asltree.c b/src/add-ons/kernel/bus_managers/acpi/compiler/asltree.c index 6eb2e78ef2..30f59ee46d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asltree.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asltree.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asltree - parse tree management - * $Revision: 1.65 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/asltypes.h b/src/add-ons/kernel/bus_managers/acpi/compiler/asltypes.h index f02fe2abfc..fb2396f4dd 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/asltypes.h +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/asltypes.h @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: asltypes.h - compiler data types and struct definitions - * $Revision: 1.91 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -256,6 +255,14 @@ typedef enum #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +typedef struct asl_include_dir +{ + char *Dir; + struct asl_include_dir *Next; + +} ASL_INCLUDE_DIR; + + /* An entry in the exception list, one for each error/warning */ typedef struct asl_error_msg @@ -340,6 +347,7 @@ typedef enum ASL_MSG_EARLY_EOF, ASL_MSG_ENCODING_LENGTH, ASL_MSG_EX_INTERRUPT_LIST, + ASL_MSG_EX_INTERRUPT_LIST_MIN, ASL_MSG_EX_INTERRUPT_NUMBER, ASL_MSG_FIELD_ACCESS_WIDTH, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, @@ -423,7 +431,10 @@ typedef enum ASL_MSG_NOT_REFERENCED, ASL_MSG_NON_ZERO, ASL_MSG_STRING_LENGTH, - ASL_MSG_SERIALIZED + ASL_MSG_SERIALIZED, + ASL_MSG_COMPILER_RESERVED, + ASL_MSG_NAMED_OBJECT_IN_WHILE, + ASL_MSG_LOCAL_OUTSIDE_METHOD } ASL_MESSAGE_IDS; @@ -455,6 +466,7 @@ char *AslMessages [] = { /* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", /* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode", /* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", +/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)", /* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", /* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", /* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", @@ -511,7 +523,7 @@ char *AslMessages [] = { /* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid operand type for reserved name, must be", /* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", /* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", -/* ASL_MSG_RESERVED_WORD */ "Use of reserved word", +/* ASL_MSG_RESERVED_WORD */ "Use of reserved name", /* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", /* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", /* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", @@ -538,7 +550,10 @@ char *AslMessages [] = { /* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced", /* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", /* ASL_MSG_STRING_LENGTH */ "String literal too long", -/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized" +/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", +/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", +/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", +/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method" }; diff --git a/src/add-ons/kernel/bus_managers/acpi/compiler/aslutils.c b/src/add-ons/kernel/bus_managers/acpi/compiler/aslutils.c index 5437d92f6d..ecba7c32cf 100644 --- a/src/add-ons/kernel/bus_managers/acpi/compiler/aslutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/compiler/aslutils.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: aslutils -- compiler utilities - * $Revision: 1.74 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbcmds.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbcmds.c index f2182b8757..5504535af3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbcmds.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbcmds.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * $Revision: 1.157 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,8 +115,8 @@ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" -#include "amlcode.h" #include "acnamesp.h" #include "acevents.h" #include "acdebug.h" @@ -387,6 +386,225 @@ AcpiDbFindReferences ( } +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForPredefinedNames + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Detect and display predefined ACPI names (names that start with + * an underscore) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForPredefinedNames ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + UINT32 *Count = (UINT32 *) Context; + const ACPI_PREDEFINED_INFO *Predefined; + const ACPI_PREDEFINED_INFO *Package = NULL; + char *Pathname; + + + Predefined = AcpiNsCheckForPredefinedName (Node); + if (!Predefined) + { + return (AE_OK); + } + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); + } + + /* If method returns a package, the info is in the next table entry */ + + if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE) + { + Package = Predefined + 1; + } + + AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname, + Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes); + + if (Package) + { + AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X", + Package->RetInfo.Type, Package->RetInfo.ObjectType1, + Package->RetInfo.Count1); + } + + AcpiOsPrintf("\n"); + + AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined); + ACPI_FREE (Pathname); + (*Count)++; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCheckPredefinedNames + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Validate all predefined names in the namespace + * + ******************************************************************************/ + +void +AcpiDbCheckPredefinedNames ( + void) +{ + UINT32 Count = 0; + + + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForPredefinedNames, (void *) &Count, NULL); + + AcpiOsPrintf ("Found %d predefined names in the namespace\n", Count); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForExecute + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Batch execution module. Currently only executes predefined + * ACPI names. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForExecute ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + UINT32 *Count = (UINT32 *) Context; + ACPI_BUFFER ReturnObj; + ACPI_STATUS Status; + char *Pathname; + UINT32 i; + ACPI_DEVICE_INFO *ObjInfo; + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; + const ACPI_PREDEFINED_INFO *Predefined; + + + Predefined = AcpiNsCheckForPredefinedName (Node); + if (!Predefined) + { + return (AE_OK); + } + + if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) + { + return (AE_OK); + } + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); + } + + /* Get the object info for number of method parameters */ + + Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParamObjects.Pointer = NULL; + ParamObjects.Count = 0; + + if (ObjInfo->Type == ACPI_TYPE_METHOD) + { + + /* Setup default parameters */ + + for (i = 0; i < ObjInfo->ParamCount; i++) + { + Params[i].Type = ACPI_TYPE_INTEGER; + Params[i].Integer.Value = 1; + } + + ParamObjects.Pointer = Params; + ParamObjects.Count = ObjInfo->ParamCount; + } + + ACPI_FREE (ObjInfo); + + ReturnObj.Pointer = NULL; + ReturnObj.Length = ACPI_ALLOCATE_BUFFER; + + + /* Do the actual method execution */ + + AcpiGbl_MethodExecuting = TRUE; + + Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); + + AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); + AcpiGbl_MethodExecuting = FALSE; + + ACPI_FREE (Pathname); + (*Count)++; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbBatchExecute + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Namespace batch execution. + * + ******************************************************************************/ + +void +AcpiDbBatchExecute ( + void) +{ + UINT32 Count = 0; + + + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForExecute, (void *) &Count, NULL); + + AcpiOsPrintf ("Executed %d predefined names in the namespace\n", Count); +} + + /******************************************************************************* * * FUNCTION: AcpiDbDisplayLocks @@ -434,6 +652,7 @@ AcpiDbDisplayTableInfo ( { UINT32 i; ACPI_TABLE_DESC *TableDesc; + ACPI_STATUS Status; /* Walk the entire root table list */ @@ -445,7 +664,11 @@ AcpiDbDisplayTableInfo ( /* Make sure that the table is mapped */ - AcpiTbVerifyTable (TableDesc); + Status = AcpiTbVerifyTable (TableDesc); + if (ACPI_FAILURE (Status)) + { + return; + } /* Dump the table header */ @@ -943,7 +1166,7 @@ AcpiDbSetMethodData ( goto Cleanup; } - Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { @@ -966,7 +1189,7 @@ AcpiDbSetMethodData ( goto Cleanup; } - Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { @@ -1173,6 +1396,9 @@ ACPI_STATUS AcpiDbFindNameInNamespace ( char *NameArg) { + char AcpiName[5] = "____"; + char *AcpiNamePtr = AcpiName; + if (ACPI_STRLEN (NameArg) > 4) { @@ -1180,11 +1406,20 @@ AcpiDbFindNameInNamespace ( return (AE_OK); } - /* Walk the namespace from the root */ + /* Pad out name with underscores as necessary to create a 4-char name */ AcpiUtStrupr (NameArg); + while (*NameArg) + { + *AcpiNamePtr = *NameArg; + AcpiNamePtr++; + NameArg++; + } + + /* Walk the namespace from the root */ + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkAndMatchName, NameArg, NULL); + AcpiDbWalkAndMatchName, AcpiName, NULL); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); return (AE_OK); @@ -1755,12 +1990,17 @@ AcpiDbBusWalk ( ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ACPI_STATUS Status; ACPI_BUFFER Buffer; - ACPI_INTEGER ADR; - ACPI_DEVICE_ID Id; - ACPI_COMPATIBLE_ID_LIST *Cid; ACPI_NAMESPACE_NODE *TempNode; + ACPI_DEVICE_INFO *Info; + UINT32 i; + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR)) + { + return (AE_OK); + } + /* Exit if there is no _PRT under this device */ Status = AcpiGetHandle (Node, METHOD_NAME__PRT, @@ -1780,57 +2020,70 @@ AcpiDbBusWalk ( return (AE_OK); } + Status = AcpiGetObjectInfo (ObjHandle, &Info); + if (ACPI_FAILURE (Status)) + { + return (AE_OK); + } + /* Display the full path */ - AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer); + AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type); ACPI_FREE (Buffer.Pointer); + if (Info->Flags & ACPI_PCI_ROOT_BRIDGE) + { + AcpiOsPrintf (" - Is PCI Root Bridge"); + } + AcpiOsPrintf ("\n"); + /* _PRT info */ - AcpiOsPrintf ("_PRT=%p", TempNode); + AcpiOsPrintf ("_PRT: %p\n", TempNode); - /* Get the _ADR value */ + /* Dump _ADR, _HID, _UID, _CID */ - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR); - if (ACPI_FAILURE (Status)) + if (Info->Valid & ACPI_VALID_ADR) { - AcpiOsPrintf (" No _ADR "); + AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address)); } else { - AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR); + AcpiOsPrintf ("_ADR: \n"); } - /* Get the _HID if present */ - - Status = AcpiUtExecute_HID (Node, &Id); - if (ACPI_SUCCESS (Status)) + if (Info->Valid & ACPI_VALID_HID) { - AcpiOsPrintf (" _HID=%s", Id.Value); + AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String); } else { - AcpiOsPrintf (" "); + AcpiOsPrintf ("_HID: \n"); } - /* Get the _UID if present */ - - Status = AcpiUtExecute_UID (Node, &Id); - if (ACPI_SUCCESS (Status)) + if (Info->Valid & ACPI_VALID_UID) { - AcpiOsPrintf (" _UID=%s", Id.Value); + AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String); } - - /* Get the _CID if present */ - - Status = AcpiUtExecute_CID (Node, &Cid); - if (ACPI_SUCCESS (Status)) + else { - AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value); - ACPI_FREE (Cid); + AcpiOsPrintf ("_UID: \n"); } - AcpiOsPrintf ("\n"); + if (Info->Valid & ACPI_VALID_CID) + { + for (i = 0; i < Info->CompatibleIdList.Count; i++) + { + AcpiOsPrintf ("_CID: %s\n", + Info->CompatibleIdList.Ids[i].String); + } + } + else + { + AcpiOsPrintf ("_CID: \n"); + } + + ACPI_FREE (Info); return (AE_OK); } @@ -1853,7 +2106,7 @@ AcpiDbGetBusInfo ( { /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL); } diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbdisply.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbdisply.c index abc437d90e..fbcb8f10d3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbdisply.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbdisply.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbdisply - debug display commands - * $Revision: 1.121 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdispat.h" #include "acnamesp.h" @@ -682,42 +682,52 @@ AcpiDbDisplayObjectType ( char *ObjectArg) { ACPI_HANDLE Handle; - ACPI_BUFFER Buffer; ACPI_DEVICE_INFO *Info; ACPI_STATUS Status; UINT32 i; Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetObjectInfo (Handle, &Buffer); - if (ACPI_SUCCESS (Status)) + Status = AcpiGetObjectInfo (Handle, &Info); + if (ACPI_FAILURE (Status)) { - Info = Buffer.Pointer; - AcpiOsPrintf ( - "S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", - Info->HighestDstates[0], Info->HighestDstates[1], - Info->HighestDstates[2], Info->HighestDstates[3], - Info->HardwareId.Value, - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus); + AcpiOsPrintf ("Could not get object info, %s\n", + AcpiFormatException (Status)); + return; + } - if (Info->Valid & ACPI_VALID_CID) + AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus, Info->Flags); + + AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3]); + + AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", + Info->LowestDstates[0], Info->LowestDstates[1], + Info->LowestDstates[2], Info->LowestDstates[3], + Info->LowestDstates[4]); + + if (Info->Valid & ACPI_VALID_HID) + { + AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); + } + if (Info->Valid & ACPI_VALID_UID) + { + AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); + } + if (Info->Valid & ACPI_VALID_CID) + { + for (i = 0; i < Info->CompatibleIdList.Count; i++) { - for (i = 0; i < Info->CompatibilityId.Count; i++) - { - AcpiOsPrintf ("CID #%d: %s\n", i, - Info->CompatibilityId.Id[i].Value); - } + AcpiOsPrintf ("CID %d: %s\n", i, + Info->CompatibleIdList.Ids[i].String); } + } - ACPI_FREE (Info); - } - else - { - AcpiOsPrintf ("%s\n", AcpiFormatException (Status)); - } + ACPI_FREE (Info); } diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbexec.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbexec.c index 108032b0eb..f6e20ce55c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbexec.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbexec.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbexec - debugger control method execution - * $Revision: 1.83 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdebug.h" #include "acnamesp.h" @@ -176,7 +176,6 @@ AcpiDbExecuteMethod ( ACPI_OBJECT_LIST ParamObjects; ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; ACPI_HANDLE Handle; - ACPI_BUFFER Buffer; UINT32 i; ACPI_DEVICE_INFO *ObjInfo; @@ -196,14 +195,15 @@ AcpiDbExecuteMethod ( /* Get the object info for number of method parameters */ - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetObjectInfo (Handle, &Buffer); + Status = AcpiGetObjectInfo (Handle, &ObjInfo); if (ACPI_FAILURE (Status)) { return (Status); } - ObjInfo = Buffer.Pointer; + ParamObjects.Pointer = NULL; + ParamObjects.Count = 0; + if (ObjInfo->Type == ACPI_TYPE_METHOD) { /* Are there arguments to the method? */ @@ -253,7 +253,7 @@ AcpiDbExecuteMethod ( } } - ACPI_FREE (Buffer.Pointer); + ACPI_FREE (ObjInfo); /* Prepare for a return object of arbitrary size */ @@ -548,25 +548,47 @@ AcpiDbMethodThread ( { ACPI_STATUS Status; ACPI_DB_METHOD_INFO *Info = Context; + ACPI_DB_METHOD_INFO LocalInfo; UINT32 i; UINT8 Allow; ACPI_BUFFER ReturnObj; + /* + * AcpiGbl_DbMethodInfo.Arguments will be passed as method arguments. + * Prevent AcpiGbl_DbMethodInfo from being modified by multiple threads + * concurrently. + * + * Note: The arguments we are passing are used by the ASL test suite + * (aslts). Do not change them without updating the tests. + */ + (void) AcpiOsWaitSemaphore (Info->InfoGate, 1, ACPI_WAIT_FOREVER); + if (Info->InitArgs) { AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); - AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); + AcpiDbUInt32ToHexString (ACPI_TO_INTEGER (AcpiOsGetThreadId ()), + Info->IdOfThreadStr); } if (Info->Threads && (Info->NumCreated < Info->NumThreads)) { - Info->Threads[Info->NumCreated++] = (UINT32) AcpiOsGetThreadId(); + Info->Threads[Info->NumCreated++] = + ACPI_TO_INTEGER (AcpiOsGetThreadId()); } + LocalInfo = *Info; + LocalInfo.Args = LocalInfo.Arguments; + LocalInfo.Arguments[0] = LocalInfo.NumThreadsStr; + LocalInfo.Arguments[1] = LocalInfo.IdOfThreadStr; + LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr; + LocalInfo.Arguments[3] = NULL; + + (void) AcpiOsSignalSemaphore (Info->InfoGate, 1); + for (i = 0; i < Info->NumLoops; i++) { - Status = AcpiDbExecuteMethod (Info, &ReturnObj); + Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("%s During execution of %s at iteration %X\n", @@ -645,6 +667,8 @@ AcpiDbCreateExecutionThreads ( UINT32 Size; ACPI_MUTEX MainThreadGate; ACPI_MUTEX ThreadCompleteGate; + ACPI_MUTEX InfoGate; + /* Get the arguments */ @@ -683,6 +707,16 @@ AcpiDbCreateExecutionThreads ( return; } + Status = AcpiOsCreateSemaphore (1, 1, &InfoGate); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n", + AcpiFormatException (Status)); + (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); + (void) AcpiOsDeleteSemaphore (MainThreadGate); + return; + } + ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); /* Array to store IDs of threads */ @@ -695,6 +729,7 @@ AcpiDbCreateExecutionThreads ( AcpiOsPrintf ("No memory for thread IDs array\n"); (void) AcpiOsDeleteSemaphore (MainThreadGate); (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); + (void) AcpiOsDeleteSemaphore (InfoGate); return; } ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); @@ -706,6 +741,7 @@ AcpiDbCreateExecutionThreads ( AcpiGbl_DbMethodInfo.NumLoops = NumLoops; AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate; AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate; + AcpiGbl_DbMethodInfo.InfoGate = InfoGate; /* Init arguments to be passed to method */ @@ -746,6 +782,7 @@ AcpiDbCreateExecutionThreads ( (void) AcpiOsDeleteSemaphore (MainThreadGate); (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); + (void) AcpiOsDeleteSemaphore (InfoGate); AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); AcpiGbl_DbMethodInfo.Threads = NULL; diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbfileio.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbfileio.c index 9288ea5d32..d52a72caa6 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbfileio.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbfileio.c @@ -1,8 +1,7 @@ /******************************************************************************* * - * Module Name: dbfileio - Debugger file I/O commands. These can't usually + * Module Name: dbfileio - Debugger file I/O commands. These can't usually * be used when running the debugger in Ring 0 (Kernel mode) - * $Revision: 1.96 $ * ******************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdebug.h" #ifdef ACPI_APPLICATION @@ -129,7 +129,7 @@ ACPI_MODULE_NAME ("dbfileio") /* - * NOTE: this is here for lack of a better place. It is used in all + * NOTE: this is here for lack of a better place. It is used in all * flavors of the debugger, need LCD file */ #ifdef ACPI_APPLICATION @@ -264,7 +264,7 @@ AcpiDbCheckTextModeCorruption ( { if (Table[i - 1] != 0x0D) { - /* The LF does not have a preceeding CR, table not corrupted */ + /* The LF does not have a preceding CR, table not corrupted */ return (AE_OK); } @@ -356,7 +356,7 @@ AcpiDbReadTable ( } else { - /* Read the table header */ + /* Read the table header */ if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (ACPI_TABLE_HEADER)) @@ -463,8 +463,8 @@ AcpiDbReadTable ( * RETURN: Status * * DESCRIPTION: This function is called to load a table from the caller's - * buffer. The buffer must contain an entire ACPI Table including - * a valid header. The header fields will be verified, and if it + * buffer. The buffer must contain an entire ACPI Table including + * a valid header. The header fields will be verified, and if it * is determined that the table is invalid, the call will fail. * ******************************************************************************/ diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbhistry.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbhistry.c index 5b64315d83..e8e8a76bf1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbhistry.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbhistry.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dbhistry - debugger HISTORY command - * $Revision: 1.35 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdebug.h" #ifdef ACPI_DEBUGGER diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbinput.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbinput.c index f1f6ddd89e..a64d547fdc 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbinput.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbinput.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * $Revision: 1.116 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdebug.h" @@ -160,6 +160,7 @@ enum AcpiExDebuggerCommands CMD_ALLOCATIONS, CMD_ARGS, CMD_ARGUMENTS, + CMD_BATCH, CMD_BREAKPOINT, CMD_BUSINFO, CMD_CALL, @@ -194,6 +195,7 @@ enum AcpiExDebuggerCommands CMD_OBJECT, CMD_OPEN, CMD_OWNER, + CMD_PREDEFINED, CMD_PREFIX, CMD_QUIT, CMD_REFERENCES, @@ -214,6 +216,9 @@ enum AcpiExDebuggerCommands #define CMD_FIRST_VALID 2 + +/* Second parameter is the required argument count */ + static const COMMAND_INFO AcpiGbl_DbCommands[] = { {"", 0}, @@ -221,6 +226,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"ALLOCATIONS", 0}, {"ARGS", 0}, {"ARGUMENTS", 0}, + {"BATCH", 0}, {"BREAKPOINT", 1}, {"BUSINFO", 0}, {"CALL", 0}, @@ -255,6 +261,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"OBJECT", 1}, {"OPEN", 1}, {"OWNER", 1}, + {"PREDEFINED", 0}, {"PREFIX", 0}, {"QUIT", 0}, {"REFERENCES", 1}, @@ -360,6 +367,7 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Notify Send a notification on Object\n"); AcpiOsPrintf ("Objects Display all objects of the given type\n"); AcpiOsPrintf ("Owner [Depth] Display loaded namespace by object owner\n"); + AcpiOsPrintf ("Predefined Check all predefined names\n"); AcpiOsPrintf ("Prefix [] Set or Get current execution prefix\n"); AcpiOsPrintf ("References Find all references to object at addr\n"); AcpiOsPrintf ("Resources Get and display Device resources\n"); @@ -635,6 +643,10 @@ AcpiDbCommandDispatch ( AcpiDbDisplayArguments (); break; + case CMD_BATCH: + AcpiDbBatchExecute (); + break; + case CMD_BREAKPOINT: AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); break; @@ -812,6 +824,10 @@ AcpiDbCommandDispatch ( AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; + case CMD_PREDEFINED: + AcpiDbCheckPredefinedNames (); + break; + case CMD_PREFIX: AcpiDbSetScope (AcpiGbl_DbArgs[1]); break; diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbstats.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbstats.c index aec1833161..f2f2f78f6a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbstats.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbstats.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbstats - Generation and display of ACPI table statistics - * $Revision: 1.90 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdebug.h" #include "acnamesp.h" @@ -276,18 +276,18 @@ AcpiDbEnumerateObject ( AcpiGbl_NumObjects++; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) > ACPI_TYPE_NS_NODE_MAX) + if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX) { AcpiGbl_ObjTypeCountMisc++; } else { - AcpiGbl_ObjTypeCount [ACPI_GET_OBJECT_TYPE (ObjDesc)]++; + AcpiGbl_ObjTypeCount [ObjDesc->Common.Type]++; } /* Count the sub-objects */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_PACKAGE: diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbutils.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbutils.c index d867904b1f..b49726369b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbutils.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbutils - AML debugger utilities - * $Revision: 1.87 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acdebug.h" #include "acdisasm.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/debugger/dbxface.c b/src/add-ons/kernel/bus_managers/acpi/debugger/dbxface.c index e82292630d..f3f7a44746 100644 --- a/src/add-ons/kernel/bus_managers/acpi/debugger/dbxface.c +++ b/src/add-ons/kernel/bus_managers/acpi/debugger/dbxface.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dbxface - AML Debugger external interfaces - * $Revision: 1.79 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdebug.h" #include "acdisasm.h" @@ -563,10 +563,6 @@ AcpiDbTerminate ( void) { - if (AcpiGbl_DbTablePtr) - { - AcpiOsFree (AcpiGbl_DbTablePtr); - } if (AcpiGbl_DbBuffer) { AcpiOsFree (AcpiGbl_DbBuffer); diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmbuffer.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmbuffer.c index 3f4cb50eac..5a4d1742f3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmbuffer.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmbuffer.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmbuffer - AML disassembler, buffer and string support - * $Revision: 1.26 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdisasm.h" #include "acparser.h" #include "amlcode.h" @@ -132,6 +132,10 @@ static void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op); +static void +AcpiDmIsEisaIdElement ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -452,7 +456,7 @@ AcpiDmUnicode ( * ******************************************************************************/ -void +static void AcpiDmIsEisaIdElement ( ACPI_PARSE_OBJECT *Op) { diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmnames.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmnames.c index bb9a31e39a..b09d3d35f5 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmnames.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmnames.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmnames - AML disassembler, names, namestrings, pathnames - * $Revision: 1.19 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acnamesp.h" @@ -159,7 +159,7 @@ AcpiDmDumpName ( /* Copy name locally in case the original name is not writeable */ - *(UINT32 *) NewName = Name; + *ACPI_CAST_PTR (UINT32, &NewName[0]) = Name; /* Ensure that the name is printable, even if we have to fix it */ diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmobject.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmobject.c index ec585f005c..0f569922ad 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmobject.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmobject.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmobject - ACPI object decode and display - * $Revision: 1.24 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,10 +115,9 @@ #include "acpi.h" -#include "amlcode.h" +#include "accommon.h" #include "acnamesp.h" #include "acdisasm.h" -#include "acparser.h" #ifdef ACPI_DISASSEMBLER @@ -280,7 +278,7 @@ AcpiDmDecodeInternalObject ( AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc)); - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_INTEGER: @@ -418,7 +416,7 @@ AcpiDmDisplayInternalObject ( case ACPI_DESC_TYPE_OPERAND: - Type = ACPI_GET_OBJECT_TYPE (ObjDesc); + Type = ObjDesc->Common.Type; if (Type > ACPI_TYPE_LOCAL_MAX) { AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type); @@ -427,50 +425,48 @@ AcpiDmDisplayInternalObject ( /* Decode the ACPI object type */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: - switch (ObjDesc->Reference.Opcode) + AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc)); + + /* Decode the refererence */ + + switch (ObjDesc->Reference.Class) { - case AML_LOCAL_OP: + case ACPI_REFCLASS_LOCAL: - AcpiOsPrintf ("[Local%d] ", ObjDesc->Reference.Offset); + AcpiOsPrintf ("%X ", ObjDesc->Reference.Value); if (WalkState) { - ObjDesc = WalkState->LocalVariables[ - ObjDesc->Reference.Offset].Object; + ObjDesc = WalkState->LocalVariables + [ObjDesc->Reference.Value].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDmDecodeInternalObject (ObjDesc); } break; - case AML_ARG_OP: + case ACPI_REFCLASS_ARG: - AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); + AcpiOsPrintf ("%X ", ObjDesc->Reference.Value); if (WalkState) { - ObjDesc = WalkState->Arguments[ - ObjDesc->Reference.Offset].Object; + ObjDesc = WalkState->Arguments + [ObjDesc->Reference.Value].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDmDecodeInternalObject (ObjDesc); } break; - case AML_DEBUG_OP: + case ACPI_REFCLASS_INDEX: - AcpiOsPrintf ("[Debug] "); - break; - - - case AML_INDEX_OP: - - AcpiOsPrintf ("[Index] "); switch (ObjDesc->Reference.TargetType) { case ACPI_TYPE_BUFFER_FIELD: + AcpiOsPrintf ("%p", ObjDesc->Reference.Object); AcpiDmDecodeInternalObject (ObjDesc->Reference.Object); break; @@ -480,7 +476,7 @@ AcpiDmDisplayInternalObject ( AcpiOsPrintf ("%p", ObjDesc->Reference.Where); if (!ObjDesc->Reference.Where) { - AcpiOsPrintf (" Uninitialized WHERE ptr"); + AcpiOsPrintf (" Uninitialized WHERE pointer"); } else { @@ -490,25 +486,18 @@ AcpiDmDisplayInternalObject ( break; default: + AcpiOsPrintf ("Unknown index target type"); break; } break; - case AML_LOAD_OP: - - AcpiOsPrintf ("[DdbHandle] "); - break; - - - case AML_REF_OF_OP: - - AcpiOsPrintf ("[RefOf] "); + case ACPI_REFCLASS_REFOF: if (!ObjDesc->Reference.Object) { - AcpiOsPrintf ("Uninitialized reference subobject ptr"); + AcpiOsPrintf ("Uninitialized reference subobject pointer"); break; } @@ -529,20 +518,28 @@ AcpiDmDisplayInternalObject ( } break; - case AML_INT_NAMEPATH_OP: + + case ACPI_REFCLASS_NAME: AcpiDmDecodeNode (ObjDesc->Reference.Node); break; - default: - AcpiOsPrintf ("Unknown Reference opcode %X (%s)\n", - ObjDesc->Reference.Opcode, - AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); + case ACPI_REFCLASS_DEBUG: + case ACPI_REFCLASS_TABLE: + + AcpiOsPrintf ("\n"); + break; + + + default: /* Unknown reference class */ + + AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); break; } break; + default: AcpiOsPrintf (" "); @@ -555,7 +552,7 @@ AcpiDmDisplayInternalObject ( default: AcpiOsPrintf (" [%s]", - AcpiUtGetDescriptorName (ObjDesc)); + AcpiUtGetDescriptorName (ObjDesc)); break; } diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmopcode.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmopcode.c index 7b398313c1..931ef6c0db 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmopcode.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmopcode.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmopcode - AML disassembler, specific AML opcodes - * $Revision: 1.106 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdisasm.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrc.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrc.c index e9aed02b77..f0fc4b1bd6 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrc.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrc.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmresrc.c - Resource Descriptor disassembly - * $Revision: 1.36 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdisasm.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcl.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcl.c index 659554feb0..b1b86db2f3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcl.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcl.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly - * $Revision: 1.38 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdisasm.h" @@ -1026,7 +1026,7 @@ AcpiDmInterruptDescriptor ( */ AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_EXTENDED_IRQ) + - (Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32), + ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32), Resource->ExtendedIrq.ResourceLength); /* Insert a descriptor name */ diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcs.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcs.c index c3c0c8a78e..50898527fb 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcs.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmresrcs.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly - * $Revision: 1.17 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acdisasm.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmutils.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmutils.c index 0b1313c2a0..75794b9f70 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmutils.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmutils - AML disassembler utilities - * $Revision: 1.26 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdisasm.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmwalk.c b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmwalk.c index b79a7ccd10..156e2dd5b1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/disassembler/dmwalk.c +++ b/src/add-ons/kernel/bus_managers/acpi/disassembler/dmwalk.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dmwalk - AML disassembly tree walk - * $Revision: 1.35 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdisasm.h" @@ -148,6 +148,69 @@ static UINT32 AcpiDmBlockType ( ACPI_PARSE_OBJECT *Op); +static const char * +AcpiDmGetObjectTypeName ( + ACPI_OBJECT_TYPE Type); + +/* + * This table maps ACPI_OBJECT_TYPEs to the corresponding ASL + * ObjectTypeKeyword. Used to generate typed external declarations + */ +static const char *AcpiGbl_DmTypeNames[] = +{ + /* 00 */ "", /* Type ANY */ + /* 01 */ ", IntObj", + /* 02 */ ", StrObj", + /* 03 */ ", BuffObj", + /* 04 */ ", PkgObj", + /* 05 */ ", FieldUnitObj", + /* 06 */ ", DeviceObj", + /* 07 */ ", EventObj", + /* 08 */ ", MethodObj", + /* 09 */ ", MutexObj", + /* 10 */ ", OpRegionObj", + /* 11 */ ", PowerResObj", + /* 12 */ ", ProcessorObj", + /* 13 */ ", ThermalZoneObj", + /* 14 */ ", BuffFieldObj", + /* 15 */ ", DDBHandleObj", + /* 16 */ "", /* Debug object */ + /* 17 */ ", FieldUnitObj", + /* 18 */ ", FieldUnitObj", + /* 19 */ ", FieldUnitObj" +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGetObjectTypeName + * + * PARAMETERS: Type - An ACPI_OBJECT_TYPE + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Map an object type to the ASL object type string. + * + ******************************************************************************/ + +static const char * +AcpiDmGetObjectTypeName ( + ACPI_OBJECT_TYPE Type) +{ + + if (Type == ACPI_TYPE_LOCAL_SCOPE) + { + Type = ACPI_TYPE_DEVICE; + } + + else if (Type > ACPI_TYPE_LOCAL_INDEX_FIELD) + { + return (""); + } + + return (AcpiGbl_DmTypeNames[Type]); +} + /******************************************************************************* * @@ -499,28 +562,9 @@ AcpiDmDescendingOp ( */ while (AcpiGbl_ExternalList) { - AcpiOsPrintf (" External (%s", - AcpiGbl_ExternalList->Path); - - /* TBD: should be a lookup table */ - - switch (AcpiGbl_ExternalList->Type) - { - case ACPI_TYPE_DEVICE: - AcpiOsPrintf (", DeviceObj"); - break; - - case ACPI_TYPE_METHOD: - AcpiOsPrintf (", MethodObj"); - break; - - case ACPI_TYPE_INTEGER: - AcpiOsPrintf (", IntObj"); - break; - - default: - break; - } + AcpiOsPrintf (" External (%s%s", + AcpiGbl_ExternalList->Path, + AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type)); if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) { diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsfield.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsfield.c index 8e35db4bcc..12d55f40c4 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsfield.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsfield.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dsfield - Dispatcher field routines - * $Revision: 1.87 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSFIELD_C__ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" @@ -211,9 +211,12 @@ AcpiDsCreateBufferField ( Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; - /* Mark node temporary if we are executing a method */ - - if (WalkState->MethodNode) + /* + * Mark node temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) { Flags |= ACPI_NS_TEMPORARY; } @@ -566,9 +569,12 @@ AcpiDsInitFieldObjects ( Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; - /* Mark node(s) temporary if we are executing a method */ - - if (WalkState->MethodNode) + /* + * Mark node(s) temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) { Flags |= ACPI_NS_TEMPORARY; } diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsinit.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsinit.c index 3f00b51348..af29476410 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsinit.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsinit.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dsinit - Object initialization namespace walk - * $Revision: 1.29 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSINIT_C__ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" #include "acnamesp.h" #include "actables.h" @@ -272,12 +272,23 @@ AcpiDsInitializeObjects ( /* Walk entire namespace from the supplied root */ - Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, - AcpiDsInitOneObject, &Info, NULL); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We don't use AcpiWalkNamespace since we do not want to acquire + * the namespace reader lock. + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmethod.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmethod.c index 4b7ded59a6..1766fc353d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmethod.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmethod.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * $Revision: 1.140 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSMETHOD_C__ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" @@ -520,6 +520,10 @@ AcpiDsCallControlMethod ( if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) { Status = ObjDesc->Method.Implementation (NextWalkState); + if (Status == AE_OK) + { + Status = AE_CTRL_TERMINATE; + } } return_ACPI_STATUS (Status); @@ -689,10 +693,15 @@ AcpiDsTerminateControlMethod ( } /* - * Delete any namespace objects created anywhere within - * the namespace by the execution of this method + * Delete any namespace objects created anywhere within the + * namespace by the execution of this method. Unless this method + * is a module-level executable code method, in which case we + * want make the objects permanent. */ - AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + } } /* Decrement the thread count on the method */ @@ -741,7 +750,10 @@ AcpiDsTerminateControlMethod ( /* No more threads, we can free the OwnerId */ - AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + } } return_VOID; diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmthdat.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmthdat.c index 18079b1260..43777ab80f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmthdat.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsmthdat.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * $Revision: 1.94 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,8 +116,8 @@ #define __DSMTHDAT_C__ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" -#include "amlcode.h" #include "acnamesp.h" #include "acinterp.h" @@ -130,13 +129,13 @@ static void AcpiDsMethodDataDeleteValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState); static ACPI_STATUS AcpiDsMethodDataSetValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState); @@ -263,8 +262,6 @@ AcpiDsMethodDataDeleteAll ( } } - AcpiDsClearImplicitReturn (WalkState); - return_VOID; } @@ -315,7 +312,7 @@ AcpiDsMethodDataInitArgs ( * Store the argument in the method/walk descriptor. * Do not copy the arg in order to implement call by reference */ - Status = AcpiDsMethodDataSetValue (AML_ARG_OP, Index, + Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index, Params[Index], WalkState); if (ACPI_FAILURE (Status)) { @@ -334,7 +331,8 @@ AcpiDsMethodDataInitArgs ( * * FUNCTION: AcpiDsMethodDataGetNode * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG * Index - Which Local or Arg whose type to get * WalkState - Current walk state object * Node - Where the node is returned. @@ -347,7 +345,7 @@ AcpiDsMethodDataInitArgs ( ACPI_STATUS AcpiDsMethodDataGetNode ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node) @@ -358,9 +356,9 @@ AcpiDsMethodDataGetNode ( /* * Method Locals and Arguments are supported */ - switch (Opcode) + switch (Type) { - case AML_LOCAL_OP: + case ACPI_REFCLASS_LOCAL: if (Index > ACPI_METHOD_MAX_LOCAL) { @@ -375,7 +373,7 @@ AcpiDsMethodDataGetNode ( *Node = &WalkState->LocalVariables[Index]; break; - case AML_ARG_OP: + case ACPI_REFCLASS_ARG: if (Index > ACPI_METHOD_MAX_ARG) { @@ -391,8 +389,8 @@ AcpiDsMethodDataGetNode ( break; default: - ACPI_ERROR ((AE_INFO, "Opcode %d is invalid", Opcode)); - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + ACPI_ERROR ((AE_INFO, "Type %d is invalid", Type)); + return_ACPI_STATUS (AE_TYPE); } return_ACPI_STATUS (AE_OK); @@ -403,7 +401,8 @@ AcpiDsMethodDataGetNode ( * * FUNCTION: AcpiDsMethodDataSetValue * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG * Index - Which Local or Arg to get * Object - Object to be inserted into the stack entry * WalkState - Current walk state object @@ -417,7 +416,7 @@ AcpiDsMethodDataGetNode ( static ACPI_STATUS AcpiDsMethodDataSetValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState) @@ -430,13 +429,13 @@ AcpiDsMethodDataSetValue ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "NewObj %p Opcode %X, Refs=%d [%s]\n", Object, - Opcode, Object->Common.ReferenceCount, + "NewObj %p Type %2.2X, Refs=%d [%s]\n", Object, + Type, Object->Common.ReferenceCount, AcpiUtGetTypeName (Object->Common.Type))); /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -461,7 +460,8 @@ AcpiDsMethodDataSetValue ( * * FUNCTION: AcpiDsMethodDataGetValue * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG * Index - Which localVar or argument to get * WalkState - Current walk state object * DestDesc - Where Arg or Local value is returned @@ -475,7 +475,7 @@ AcpiDsMethodDataSetValue ( ACPI_STATUS AcpiDsMethodDataGetValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc) @@ -498,7 +498,7 @@ AcpiDsMethodDataGetValue ( /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -536,9 +536,9 @@ AcpiDsMethodDataGetValue ( /* Otherwise, return the error */ - else switch (Opcode) + else switch (Type) { - case AML_ARG_OP: + case ACPI_REFCLASS_ARG: ACPI_ERROR ((AE_INFO, "Uninitialized Arg[%d] at node %p", @@ -546,16 +546,17 @@ AcpiDsMethodDataGetValue ( return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); - case AML_LOCAL_OP: - - ACPI_ERROR ((AE_INFO, - "Uninitialized Local[%d] at node %p", - Index, Node)); + case ACPI_REFCLASS_LOCAL: + /* + * No error message for this case, will be trapped again later to + * detect and ignore cases of Store(LocalX,LocalX) + */ return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); default: - ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Opcode)); + + ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Type)); return_ACPI_STATUS (AE_AML_INTERNAL); } } @@ -575,7 +576,8 @@ AcpiDsMethodDataGetValue ( * * FUNCTION: AcpiDsMethodDataDeleteValue * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG * Index - Which localVar or argument to delete * WalkState - Current walk state object * @@ -588,7 +590,7 @@ AcpiDsMethodDataGetValue ( static void AcpiDsMethodDataDeleteValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState) { @@ -602,7 +604,7 @@ AcpiDsMethodDataDeleteValue ( /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_VOID; @@ -638,7 +640,8 @@ AcpiDsMethodDataDeleteValue ( * * FUNCTION: AcpiDsStoreObjectToLocal * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG * Index - Which Local or Arg to set * ObjDesc - Value to be stored * WalkState - Current walk state @@ -653,7 +656,7 @@ AcpiDsMethodDataDeleteValue ( ACPI_STATUS AcpiDsStoreObjectToLocal ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) @@ -665,8 +668,8 @@ AcpiDsStoreObjectToLocal ( ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", - Opcode, Index, ObjDesc)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", + Type, Index, ObjDesc)); /* Parameter validation */ @@ -677,7 +680,7 @@ AcpiDsStoreObjectToLocal ( /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -732,7 +735,7 @@ AcpiDsStoreObjectToLocal ( * * Weird, but true. */ - if (Opcode == AML_ARG_OP) + if (Type == ACPI_REFCLASS_ARG) { /* * If we have a valid reference object that came from RefOf(), @@ -740,7 +743,7 @@ AcpiDsStoreObjectToLocal ( */ if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - (CurrentObjDesc->Reference.Opcode == AML_REF_OF_OP)) + (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Arg (%p) is an ObjRef(Node), storing in node %p\n", @@ -765,11 +768,9 @@ AcpiDsStoreObjectToLocal ( } } - /* - * Delete the existing object - * before storing the new one - */ - AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); + /* Delete the existing object before storing the new one */ + + AcpiDsMethodDataDeleteValue (Type, Index, WalkState); } /* @@ -777,7 +778,7 @@ AcpiDsStoreObjectToLocal ( * the descriptor for the Arg or Local. * (increments the object reference count by one) */ - Status = AcpiDsMethodDataSetValue (Opcode, Index, NewObjDesc, WalkState); + Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState); /* Remove local reference if we copied the object above */ @@ -839,7 +840,7 @@ AcpiDsMethodDataGetType ( /* Get the object type */ - return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); + return_VALUE (Object->Type); } #endif diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsobject.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsobject.c index c077b2bc47..57e78c1b33 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsobject.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsobject.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 1.140 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSOBJECT_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" @@ -570,15 +570,28 @@ AcpiDsBuildInternalPackageObj ( { /* * NumElements was exhausted, but there are remaining elements in the - * PackageList. + * PackageList. Truncate the package to NumElements. * * Note: technically, this is an error, from ACPI spec: "It is an error * for NumElements to be less than the number of elements in the - * PackageList". However, for now, we just print an error message and - * no exception is returned. + * PackageList". However, we just print an error message and + * no exception is returned. This provides Windows compatibility. Some + * BIOSs will alter the NumElements on the fly, creating this type + * of ill-formed package object. */ while (Arg) { + /* + * We must delete any package elements that were created earlier + * and are not going to be used because of the package truncation. + */ + if (Arg->Common.Node) + { + AcpiUtRemoveReference ( + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node)); + Arg->Common.Node = NULL; + } + /* Find out how many elements there really are */ i++; @@ -586,7 +599,7 @@ AcpiDsBuildInternalPackageObj ( } ACPI_ERROR ((AE_INFO, - "Package List length (%X) larger than NumElements count (%X), truncated\n", + "Package List length (0x%X) larger than NumElements count (0x%X), truncated\n", i, ElementCount)); } else if (i < ElementCount) @@ -596,7 +609,7 @@ AcpiDsBuildInternalPackageObj ( * Note: this is not an error, the package is padded out with NULLs. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Package List length (%X) smaller than NumElements count (%X), padded with null elements\n", + "Package List length (0x%X) smaller than NumElements count (0x%X), padded with null elements\n", i, ElementCount)); } @@ -661,7 +674,7 @@ AcpiDsCreateNode ( /* Re-type the object according to its argument */ - Node->Type = ACPI_GET_OBJECT_TYPE (ObjDesc); + Node->Type = ObjDesc->Common.Type; /* Attach obj to node */ @@ -719,7 +732,7 @@ AcpiDsInitObjectFromOp ( /* Perform per-object initialization */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER: @@ -839,46 +852,59 @@ AcpiDsInitObjectFromOp ( { case AML_TYPE_LOCAL_VARIABLE: - /* Split the opcode into a base opcode + offset */ + /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */ - ObjDesc->Reference.Opcode = AML_LOCAL_OP; - ObjDesc->Reference.Offset = Opcode - AML_LOCAL_OP; + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL; #ifndef ACPI_NO_METHOD_EXECUTION - Status = AcpiDsMethodDataGetNode (AML_LOCAL_OP, - ObjDesc->Reference.Offset, - WalkState, - (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); #endif break; case AML_TYPE_METHOD_ARGUMENT: - /* Split the opcode into a base opcode + offset */ + /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */ - ObjDesc->Reference.Opcode = AML_ARG_OP; - ObjDesc->Reference.Offset = Opcode - AML_ARG_OP; + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_ARG; #ifndef ACPI_NO_METHOD_EXECUTION - Status = AcpiDsMethodDataGetNode (AML_ARG_OP, - ObjDesc->Reference.Offset, - WalkState, - (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); #endif break; - default: /* Other literals, etc.. */ + default: /* Object name or Debug object */ - if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + switch (Op->Common.AmlOpcode) { + case AML_INT_NAMEPATH_OP: + /* Node was saved in Op */ ObjDesc->Reference.Node = Op->Common.Node; ObjDesc->Reference.Object = Op->Common.Node->Object; - } + ObjDesc->Reference.Class = ACPI_REFCLASS_NAME; + break; - ObjDesc->Reference.Opcode = Opcode; + case AML_DEBUG_OP: + + ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented reference type for AML opcode: %4.4X", Opcode)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } break; } break; @@ -887,7 +913,7 @@ AcpiDsInitObjectFromOp ( default: ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X", - ACPI_GET_OBJECT_TYPE (ObjDesc))); + ObjDesc->Common.Type)); Status = AE_AML_OPERAND_TYPE; break; diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsopcode.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsopcode.c index 3d10c3ddac..3edbacc1d9 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsopcode.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsopcode.c @@ -2,7 +2,6 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 1.115 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __DSOPCODE_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" @@ -507,28 +507,6 @@ AcpiDsGetRegionArguments ( Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Validate the region address/length via the host OS */ - - Status = AcpiOsValidateAddress (ObjDesc->Region.SpaceId, - ObjDesc->Region.Address, (ACPI_SIZE) ObjDesc->Region.Length); - if (ACPI_FAILURE (Status)) - { - /* - * Invalid address/length. We will emit an error message and mark - * the region as invalid, so that it will cause an additional error if - * it is ever used. Then return AE_OK. - */ - ACPI_EXCEPTION ((AE_INFO, Status, - "During address validation of OpRegion [%4.4s]", Node->Name.Ascii)); - ObjDesc->Common.Flags |= AOPOBJ_INVALID; - Status = AE_OK; - } - return_ACPI_STATUS (Status); } @@ -600,7 +578,7 @@ AcpiDsInitBufferField ( /* Host object must be a Buffer */ - if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER) + if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER) { ACPI_ERROR ((AE_INFO, "Target of Create Field is not a Buffer object - %s", @@ -1303,9 +1281,28 @@ AcpiDsExecBeginControlOp ( switch (Op->Common.AmlOpcode) { - case AML_IF_OP: case AML_WHILE_OP: + /* + * If this is an additional iteration of a while loop, continue. + * There is no need to allocate a new control state. + */ + if (WalkState->ControlState) + { + if (WalkState->ControlState->Control.AmlPredicateStart == + (WalkState->ParserState.Aml - 1)) + { + /* Reset the state to start-of-loop */ + + WalkState->ControlState->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + break; + } + } + + /*lint -fallthrough */ + + case AML_IF_OP: + /* * IF/WHILE: Create a new control state to manage these * constructs. We need to manage these as a stack, in order @@ -1412,21 +1409,41 @@ AcpiDsExecEndControlOp ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); - if (WalkState->ControlState->Common.Value) + ControlState = WalkState->ControlState; + if (ControlState->Common.Value) { - /* Predicate was true, go back and evaluate it again! */ + /* Predicate was true, the body of the loop was just executed */ + /* + * This loop counter mechanism allows the interpreter to escape + * possibly infinite loops. This can occur in poorly written AML + * when the hardware does not respond within a while loop and the + * loop does not implement a timeout. + */ + ControlState->Control.LoopCount++; + if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS) + { + Status = AE_AML_INFINITE_LOOP; + break; + } + + /* + * Go back and evaluate the predicate and maybe execute the loop + * another time + */ Status = AE_CTRL_PENDING; + WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + break; } + /* Predicate was false, terminate this while loop */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n",Op)); /* Pop this control state and free it */ ControlState = AcpiUtPopGenericState (&WalkState->ControlState); - - WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; AcpiUtDeleteGenericState (ControlState); break; @@ -1489,8 +1506,8 @@ AcpiDsExecEndControlOp ( * Allow references created by the Index operator to return unchanged. */ if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && - ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) + ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX)) { Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); if (ACPI_FAILURE (Status)) @@ -1534,12 +1551,20 @@ AcpiDsExecEndControlOp ( case AML_BREAK_POINT_OP: - /* Call up to the OS service layer to handle this */ + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + ACPI_DEBUGGER_EXEC ( + AcpiGbl_CmSingleStep = TRUE); + ACPI_DEBUGGER_EXEC ( + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n")); - Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); - - /* If and when it returns, all done. */ + /* Call to the OSL in case OS wants a piece of the action */ + Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, + "Executed AML Breakpoint opcode"); break; diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsutils.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsutils.c index 78a2eb97f5..6c211ace8c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dsutils.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: dsutils - Dispatcher utilities - * $Revision: 1.127 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSUTILS_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" @@ -953,7 +953,7 @@ AcpiDsEvaluateNamePath ( goto PushResult; } - Type = ACPI_GET_OBJECT_TYPE (*Operand); + Type = (*Operand)->Common.Type; Status = AcpiExResolveToValue (Operand, WalkState); if (ACPI_FAILURE (Status)) diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswexec.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswexec.c index eba860bf79..9485c62bb1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswexec.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswexec.c @@ -2,7 +2,6 @@ * * Module Name: dswexec - Dispatcher method execution callbacks; * dispatch to interpreter. - * $Revision: 1.138 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __DSWEXEC_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" @@ -224,11 +224,11 @@ AcpiDsGetPredicateValue ( goto Cleanup; } - if (ACPI_GET_OBJECT_TYPE (LocalObjDesc) != ACPI_TYPE_INTEGER) + if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", - ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc))); + ObjDesc, WalkState, ObjDesc->Common.Type)); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -256,6 +256,10 @@ AcpiDsGetPredicateValue ( Status = AE_CTRL_FALSE; } + /* Predicate can be used for an implicit return value */ + + (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE); + Cleanup: @@ -536,10 +540,10 @@ AcpiDsExecEndOp ( (WalkState->Opcode == AML_STORE_OP) && (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - (WalkState->Operands[0]->Reference.Opcode == - WalkState->Operands[1]->Reference.Opcode) && - (WalkState->Operands[0]->Reference.Offset == - WalkState->Operands[1]->Reference.Offset)) + (WalkState->Operands[0]->Reference.Class == + WalkState->Operands[1]->Reference.Class) && + (WalkState->Operands[0]->Reference.Value == + WalkState->Operands[1]->Reference.Value)) { Status = AE_OK; } diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswload.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswload.c index 21d56dbd52..2c067f14d9 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswload.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswload.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * $Revision: 1.120 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSWLOAD_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" @@ -672,20 +672,6 @@ AcpiDsLoad2BeginOp ( (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || (!(WalkState->OpInfo->Flags & AML_NAMED))) { -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Begin/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, - WalkState->OpInfo->Flags)); - - /* Executing a type1 or type2 opcode outside of a method */ - - Status = AcpiDsExecBeginOp (WalkState, OutOp); - return_ACPI_STATUS (Status); - } -#endif return_ACPI_STATUS (AE_OK); } @@ -862,7 +848,12 @@ AcpiDsLoad2BeginOp ( { /* Execution mode, node cannot already exist, node is temporary */ - Flags |= (ACPI_NS_ERROR_IF_FOUND | ACPI_NS_TEMPORARY); + Flags |= ACPI_NS_ERROR_IF_FOUND; + + if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } } /* Add new entry or lookup existing entry */ @@ -952,24 +943,6 @@ AcpiDsLoad2EndOp ( if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) { -#ifndef ACPI_NO_METHOD_EXECUTION -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - /* No namespace object. Executable opcode? */ - - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "End/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, - WalkState->OpInfo->Flags)); - - /* Executing a type1 or type2 opcode outside of a method */ - - Status = AcpiDsExecEndOp (WalkState); - return_ACPI_STATUS (Status); - } -#endif -#endif return_ACPI_STATUS (AE_OK); } diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswscope.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswscope.c index f8143e6281..023f9ef666 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswscope.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswscope.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dswscope - Scope stack manipulation - * $Revision: 1.70 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __DSWSCOPE_C__ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswstate.c b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswstate.c index 0d1defec2c..f0962bf53f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswstate.c +++ b/src/add-ons/kernel/bus_managers/acpi/dispatcher/dswstate.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 1.105 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __DSWSTATE_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acdispat.h" #include "acnamesp.h" @@ -189,7 +189,7 @@ AcpiDsResultPop ( /* Return object of the top element and clean that top element result stack */ WalkState->ResultCount--; - Index = WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; *Object = State->Results.ObjDesc [Index]; if (!*Object) @@ -284,7 +284,7 @@ AcpiDsResultPush ( /* Assign the address of object to the top free element of result stack */ - Index = WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; State->Results.ObjDesc [Index] = Object; WalkState->ResultCount++; diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evevent.c b/src/add-ons/kernel/bus_managers/acpi/events/evevent.c index ed8299a4a3..16f40271fc 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evevent.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evevent.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evevent - Fixed Event handling and dispatch - * $Revision: 1.127 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #define _COMPONENT ACPI_EVENTS @@ -155,8 +155,8 @@ AcpiEvInitializeEvents ( /* * Initialize the Fixed and General Purpose Events. This is done prior to - * enabling SCIs to prevent interrupts from occurring before the handlers are - * installed. + * enabling SCIs to prevent interrupts from occurring before the handlers + * are installed. */ Status = AcpiEvFixedEventInitialize (); if (ACPI_FAILURE (Status)) @@ -281,7 +281,7 @@ AcpiEvInstallXruptHandlers ( * * RETURN: Status * - * DESCRIPTION: Install the fixed event handlers and enable the fixed events. + * DESCRIPTION: Install the fixed event handlers and disable all fixed events. * ******************************************************************************/ @@ -294,20 +294,21 @@ AcpiEvFixedEventInitialize ( /* - * Initialize the structure that keeps track of fixed event handlers - * and enable the fixed events. + * Initialize the structure that keeps track of fixed event handlers and + * enable the fixed events. */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { AcpiGbl_FixedEventHandlers[i].Handler = NULL; AcpiGbl_FixedEventHandlers[i].Context = NULL; - /* Enable the fixed event */ + /* Disable the fixed event */ if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) { - Status = AcpiSetRegister ( - AcpiGbl_FixedEventInfo[i].EnableRegisterId, 0); + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + ACPI_DISABLE_EVENT); if (ACPI_FAILURE (Status)) { return (Status); @@ -346,7 +347,7 @@ AcpiEvFixedEventDetect ( /* * Read the fixed feature status and enable registers, as all the cases - * depend on their values. Ignore errors here. + * depend on their values. Ignore errors here. */ (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, &FixedStatus); (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable); @@ -399,15 +400,19 @@ AcpiEvFixedEventDispatch ( /* Clear the status bit */ - (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 1); + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); /* - * Make sure we've got a handler. If not, report an error. - * The event is disabled to prevent further interrupts. + * Make sure we've got a handler. If not, report an error. The event is + * disabled to prevent further interrupts. */ if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) { - (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 0); + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); ACPI_ERROR ((AE_INFO, "No installed handler for fixed event [%08X]", @@ -419,7 +424,7 @@ AcpiEvFixedEventDispatch ( /* Invoke the Fixed Event handler */ return ((AcpiGbl_FixedEventHandlers[Event].Handler)( - AcpiGbl_FixedEventHandlers[Event].Context)); + AcpiGbl_FixedEventHandlers[Event].Context)); } diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evgpe.c b/src/add-ons/kernel/bus_managers/acpi/events/evgpe.c index 92694b5392..17738b3840 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evgpe.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evgpe.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evgpe - General Purpose Event handling and dispatch - * $Revision: 1.72 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" @@ -173,10 +173,10 @@ AcpiEvSetGpeType ( Status = AcpiEvDisableGpe (GpeEventInfo); - /* Type was validated above */ + /* Clear the type bits and insert the new Type */ - GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ - GpeEventInfo->Flags |= Type; /* Insert type */ + GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; + GpeEventInfo->Flags |= Type; return_ACPI_STATUS (Status); } @@ -212,10 +212,11 @@ AcpiEvUpdateGpeEnableMasks ( { return_ACPI_STATUS (AE_NOT_EXIST); } + RegisterBit = (UINT8) (1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); - /* 1) Disable case. Simply clear all enable bits */ + /* 1) Disable case. Simply clear all enable bits */ if (Type == ACPI_GPE_DISABLE) { @@ -224,7 +225,7 @@ AcpiEvUpdateGpeEnableMasks ( return_ACPI_STATUS (AE_OK); } - /* 2) Enable case. Set/Clear the appropriate enable bits */ + /* 2) Enable case. Set/Clear the appropriate enable bits */ switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) { @@ -406,10 +407,10 @@ AcpiEvDisableGpe ( * * FUNCTION: AcpiEvGetGpeEventInfo * - * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1 + * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1 * GpeNumber - Raw GPE number * - * RETURN: A GPE EventInfo struct. NULL if not a valid GPE + * RETURN: A GPE EventInfo struct. NULL if not a valid GPE * * DESCRIPTION: Returns the EventInfo struct associated with this GPE. * Validates the GpeBlock and the GpeNumber @@ -488,7 +489,7 @@ AcpiEvGetGpeEventInfo ( * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * - * DESCRIPTION: Detect if any GP events have occurred. This function is + * DESCRIPTION: Detect if any GP events have occurred. This function is * executed at interrupt level. * ******************************************************************************/ @@ -520,8 +521,8 @@ AcpiEvGpeDetect ( /* * We need to obtain the GPE lock for both the data structs and registers - * Note: Not necessary to obtain the hardware lock, since the GPE registers - * are owned by the GpeLock. + * Note: Not necessary to obtain the hardware lock, since the GPE + * registers are owned by the GpeLock. */ Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); @@ -531,9 +532,8 @@ AcpiEvGpeDetect ( while (GpeBlock) { /* - * Read all of the 8-bit GPE status and enable registers - * in this GPE block, saving all of them. - * Find all currently active GP events. + * Read all of the 8-bit GPE status and enable registers in this GPE + * block, saving all of them. Find all currently active GP events. */ for (i = 0; i < GpeBlock->RegisterCount; i++) { @@ -543,8 +543,7 @@ AcpiEvGpeDetect ( /* Read the Status Register */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &StatusReg, - &GpeRegisterInfo->StatusAddress); + Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -552,8 +551,7 @@ AcpiEvGpeDetect ( /* Read the Enable Register */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &EnableReg, - &GpeRegisterInfo->EnableAddress); + Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -586,7 +584,8 @@ AcpiEvGpeDetect ( * or method. */ IntStatus |= AcpiEvGpeDispatch ( - &GpeBlock->EventInfo[((ACPI_SIZE) i * ACPI_GPE_REGISTER_WIDTH) + j], + &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j], j + GpeRegisterInfo->BaseGpeNumber); } } @@ -660,8 +659,8 @@ AcpiEvAsynchExecuteGpeMethod ( (void) AcpiEvEnableGpe (GpeEventInfo, FALSE); /* - * Take a snapshot of the GPE info for this level - we copy the - * info to prevent a race condition with RemoveHandler/RemoveBlock. + * Take a snapshot of the GPE info for this level - we copy the info to + * prevent a race condition with RemoveHandler/RemoveBlock. */ ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo, sizeof (ACPI_GPE_EVENT_INFO)); @@ -673,8 +672,8 @@ AcpiEvAsynchExecuteGpeMethod ( } /* - * Must check for control method type dispatch one more - * time to avoid race with EvGpeInstallHandler + * Must check for control method type dispatch one more time to avoid a + * race with EvGpeInstallHandler */ if ((LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) @@ -744,8 +743,8 @@ AcpiEvAsynchEnableGpe ( ACPI_GPE_LEVEL_TRIGGERED) { /* - * GPE is level-triggered, we clear the GPE status bit after - * handling the event. + * GPE is level-triggered, we clear the GPE status bit after handling + * the event. */ Status = AcpiHwClearGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) @@ -794,7 +793,7 @@ AcpiEvGpeDispatch ( AcpiGpeCount++; /* - * If edge-triggered, clear the GPE status bit now. Note that + * If edge-triggered, clear the GPE status bit now. Note that * level-triggered events are cleared after the GPE is serviced. */ if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == @@ -809,18 +808,6 @@ AcpiEvGpeDispatch ( } } - if (!AcpiGbl_SystemAwakeAndRunning) - { - /* - * We just woke up because of a wake GPE. Disable any further GPEs - * until we are fully up and running (Only wake GPEs should be enabled - * at this time, but we just brute-force disable them all.) - * 1) We must disable this particular wake GPE so it won't fire again - * 2) We want to disable all wake GPEs, since we are now awake - */ - (void) AcpiHwDisableAllGpes (); - } - /* * Dispatch the GPE to either an installed handler, or the control method * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke @@ -834,7 +821,8 @@ AcpiEvGpeDispatch ( /* * Invoke the installed handler (at interrupt level) - * Ignore return status for now. TBD: leave GPE disabled on error? + * Ignore return status for now. + * TBD: leave GPE disabled on error? */ (void) GpeEventInfo->Dispatch.Handler->Address ( GpeEventInfo->Dispatch.Handler->Context); @@ -891,7 +879,7 @@ AcpiEvGpeDispatch ( GpeNumber)); /* - * Disable the GPE. The GPE will remain disabled until the ACPI + * Disable the GPE. The GPE will remain disabled until the ACPICA * Core Subsystem is restarted, or a handler is installed. */ Status = AcpiEvDisableGpe (GpeEventInfo); diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evgpeblk.c b/src/add-ons/kernel/bus_managers/acpi/events/evgpeblk.c index 5095009d54..343a31d28e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evgpeblk.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evgpeblk.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evgpeblk - GPE block creation and initialization. - * $Revision: 1.62 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" @@ -194,7 +194,8 @@ AcpiEvValidGpeEvent ( while (GpeBlock) { if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && - (&GpeBlock->EventInfo[((ACPI_SIZE) GpeBlock->RegisterCount) * 8] > GpeEventInfo)) + (&GpeBlock->EventInfo[((ACPI_SIZE) + GpeBlock->RegisterCount) * 8] > GpeEventInfo)) { return (TRUE); } @@ -214,6 +215,7 @@ AcpiEvValidGpeEvent ( * FUNCTION: AcpiEvWalkGpeList * * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Context - Value passed to callback * * RETURN: Status * @@ -223,7 +225,8 @@ AcpiEvValidGpeEvent ( ACPI_STATUS AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback) + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; @@ -248,9 +251,13 @@ AcpiEvWalkGpeList ( { /* One callback per GPE block */ - Status = GpeWalkCallback (GpeXruptInfo, GpeBlock); + Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); if (ACPI_FAILURE (Status)) { + if (Status == AE_CTRL_END) /* Callback abort */ + { + Status = AE_OK; + } goto UnlockAndExit; } @@ -283,7 +290,8 @@ UnlockAndExit: ACPI_STATUS AcpiEvDeleteGpeHandlers ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock) + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { ACPI_GPE_EVENT_INFO *GpeEventInfo; UINT32 i; @@ -301,7 +309,8 @@ AcpiEvDeleteGpeHandlers ( for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * ACPI_GPE_REGISTER_WIDTH) + j]; + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) @@ -387,7 +396,8 @@ AcpiEvSaveMethodInfo ( /* Unknown method type, just ignore it! */ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Ignoring unknown GPE method type: %s (name not of form _Lxx or _Exx)", + "Ignoring unknown GPE method type: %s " + "(name not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } @@ -400,7 +410,8 @@ AcpiEvSaveMethodInfo ( /* Conversion failed; invalid method, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)", + "Could not extract GPE number from name: %s " + "(name is not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } @@ -408,20 +419,21 @@ AcpiEvSaveMethodInfo ( /* Ensure that we have a valid GPE number for this GPE block */ if ((GpeNumber < GpeBlock->BlockBaseNumber) || - (GpeNumber >= (GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8)))) + (GpeNumber >= (GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8)))) { /* - * Not valid for this GPE block, just ignore it - * However, it may be valid for a different GPE block, since GPE0 and GPE1 - * methods both appear under \_GPE. + * Not valid for this GPE block, just ignore it. However, it may be + * valid for a different GPE block, since GPE0 and GPE1 methods both + * appear under \_GPE. */ return_ACPI_STATUS (AE_OK); } /* - * Now we can add this information to the GpeEventInfo block - * for use during dispatch of this GPE. Default type is RUNTIME, although - * this may change when the _PRW methods are executed later. + * Now we can add this information to the GpeEventInfo block for use + * during dispatch of this GPE. Default type is RUNTIME, although this may + * change when the _PRW methods are executed later. */ GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; @@ -501,12 +513,12 @@ AcpiEvMatchPrwAndGpe ( GpeBlock = GpeInfo->GpeBlock; /* - * The _PRW object must return a package, we are only interested - * in the first element + * The _PRW object must return a package, we are only interested in the + * first element */ ObjDesc = PkgDesc->Package.Elements[0]; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) { /* Use FADT-defined GPE device (from definition of _PRW) */ @@ -516,13 +528,15 @@ AcpiEvMatchPrwAndGpe ( GpeNumber = (UINT32) ObjDesc->Integer.Value; } - else if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE) + else if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) { /* Package contains a GPE reference and GPE number within a GPE block */ if ((ObjDesc->Package.Count < 2) || - (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) || - (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER)) + ((ObjDesc->Package.Elements[0])->Common.Type != + ACPI_TYPE_LOCAL_REFERENCE) || + ((ObjDesc->Package.Elements[1])->Common.Type != + ACPI_TYPE_INTEGER)) { goto Cleanup; } @@ -542,16 +556,18 @@ AcpiEvMatchPrwAndGpe ( /* * Is this GPE within this block? * - * TRUE iff these conditions are true: + * TRUE if and only if these conditions are true: * 1) The GPE devices match. * 2) The GPE index(number) is within the range of the Gpe Block * associated with the GPE device. */ if ((GpeDevice == TargetGpeDevice) && (GpeNumber >= GpeBlock->BlockBaseNumber) && - (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) { - GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; + GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]; /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ @@ -562,6 +578,7 @@ AcpiEvMatchPrwAndGpe ( { goto Cleanup; } + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); } @@ -580,9 +597,9 @@ Cleanup: * RETURN: A GPE interrupt block * * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt - * block per unique interrupt level used for GPEs. - * Should be called only when the GPE lists are semaphore locked - * and not subject to change. + * block per unique interrupt level used for GPEs. Should be + * called only when the GPE lists are semaphore locked and not + * subject to change. * ******************************************************************************/ @@ -733,8 +750,9 @@ AcpiEvDeleteGpeXrupt ( * * FUNCTION: AcpiEvInstallGpeBlock * - * PARAMETERS: GpeBlock - New GPE block - * InterruptNumber - Xrupt to be associated with this GPE block + * PARAMETERS: GpeBlock - New GPE block + * InterruptNumber - Xrupt to be associated with this + * GPE block * * RETURN: Status * @@ -802,7 +820,7 @@ UnlockAndExit: * * FUNCTION: AcpiEvDeleteGpeBlock * - * PARAMETERS: GpeBlock - Existing GPE block + * PARAMETERS: GpeBlock - Existing GPE block * * RETURN: Status * @@ -829,7 +847,7 @@ AcpiEvDeleteGpeBlock ( /* Disable all GPEs in this block */ - Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock); + Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock, NULL); if (!GpeBlock->Previous && !GpeBlock->Next) { @@ -862,6 +880,8 @@ AcpiEvDeleteGpeBlock ( AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); } + AcpiCurrentGpeCount -= GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH; + /* Free the GpeBlock */ ACPI_FREE (GpeBlock->RegisterInfo); @@ -937,9 +957,9 @@ AcpiEvCreateGpeInfoBlocks ( /* * Initialize the GPE Register and Event structures. A goal of these - * tables is to hide the fact that there are two separate GPE register sets - * in a given GPE hardware block, the status registers occupy the first half, - * and the enable registers occupy the second half. + * tables is to hide the fact that there are two separate GPE register + * sets in a given GPE hardware block, the status registers occupy the + * first half, and the enable registers occupy the second half. */ ThisRegister = GpeRegisterInfo; ThisEvent = GpeEventInfo; @@ -961,8 +981,8 @@ AcpiEvCreateGpeInfoBlocks ( ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; - ThisRegister->StatusAddress.BitOffset = ACPI_GPE_REGISTER_WIDTH; - ThisRegister->EnableAddress.BitOffset = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->StatusAddress.BitOffset = 0; + ThisRegister->EnableAddress.BitOffset = 0; /* Init the EventInfo for each GPE within this register */ @@ -975,8 +995,7 @@ AcpiEvCreateGpeInfoBlocks ( /* Disable all GPEs within this register */ - Status = AcpiHwLowLevelWrite (ACPI_GPE_REGISTER_WIDTH, 0x00, - &ThisRegister->EnableAddress); + Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -984,8 +1003,7 @@ AcpiEvCreateGpeInfoBlocks ( /* Clear any pending GPE events within this register */ - Status = AcpiHwLowLevelWrite (ACPI_GPE_REGISTER_WIDTH, 0xFF, - &ThisRegister->StatusAddress); + Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1110,6 +1128,9 @@ AcpiEvCreateGpeBlock ( GpeBlock->RegisterCount, InterruptNumber)); + /* Update global count of currently available GPEs */ + + AcpiCurrentGpeCount += RegisterCount * ACPI_GPE_REGISTER_WIDTH; return_ACPI_STATUS (AE_OK); } @@ -1179,8 +1200,8 @@ AcpiEvInitializeGpeBlock ( * 1) are "runtime" or "run/wake" GPEs, and * 2) have a corresponding _Lxx or _Exx method * - * Any other GPEs within this block must be enabled via the AcpiEnableGpe() - * external interface. + * Any other GPEs within this block must be enabled via the + * AcpiEnableGpe() external interface. */ WakeGpeCount = 0; GpeEnabledCount = 0; @@ -1191,9 +1212,11 @@ AcpiEvInitializeGpeBlock ( { /* Get the info block for this particular GPE */ - GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * ACPI_GPE_REGISTER_WIDTH) + j]; + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; - if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && + if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) && (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME)) { GpeEnabledCount++; @@ -1212,7 +1235,7 @@ AcpiEvInitializeGpeBlock ( /* Enable all valid runtime GPEs found above */ - Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock); + Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock, NULL); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "Could not enable GPEs in GpeBlock %p", @@ -1257,8 +1280,8 @@ AcpiEvGpeInitialize ( /* * Initialize the GPE Block(s) defined in the FADT * - * Why the GPE register block lengths are divided by 2: From the ACPI Spec, - * section "General-Purpose Event Registers", we have: + * Why the GPE register block lengths are divided by 2: From the ACPI + * Spec, section "General-Purpose Event Registers", we have: * * "Each register block contains two registers of equal length * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the @@ -1314,7 +1337,8 @@ AcpiEvGpeInitialize ( (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) { ACPI_ERROR ((AE_INFO, - "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1", + "GPE0 block (GPE 0 to %d) overlaps the GPE1 block " + "(GPE %d to %d) - Ignoring GPE1", GpeNumberMax, AcpiGbl_FADT.Gpe1Base, AcpiGbl_FADT.Gpe1Base + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evmisc.c b/src/add-ons/kernel/bus_managers/acpi/events/evmisc.c index e77235f04c..1e7f9e1cb5 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evmisc.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evmisc.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evmisc - Miscellaneous event manager support functions - * $Revision: 1.109 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,6 +114,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" #include "acinterp.h" @@ -123,10 +123,6 @@ ACPI_MODULE_NAME ("evmisc") -/* Pointer to FACS needed for the Global Lock */ - -static ACPI_TABLE_FACS *Facs = NULL; - /* Local prototypes */ static void ACPI_SYSTEM_XFACE @@ -242,7 +238,9 @@ AcpiEvQueueNotifyRequest ( break; default: + /* All other types are not supported */ + return (AE_TYPE); } } @@ -254,8 +252,10 @@ AcpiEvQueueNotifyRequest ( * 2) Global device notify handler * 3) Per-device notify handler */ - if ((AcpiGbl_SystemNotify.Handler && (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || - (AcpiGbl_DeviceNotify.Handler && (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || + if ((AcpiGbl_SystemNotify.Handler && + (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || + (AcpiGbl_DeviceNotify.Handler && + (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || HandlerObj) { NotifyInfo = AcpiUtCreateGenericState (); @@ -267,7 +267,8 @@ AcpiEvQueueNotifyRequest ( if (!HandlerObj) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Executing system notify handler for Notify (%4.4s, %X) node %p\n", + "Executing system notify handler for Notify (%4.4s, %X) " + "node %p\n", AcpiUtGetNodeName (Node), NotifyValue, Node)); } @@ -285,9 +286,8 @@ AcpiEvQueueNotifyRequest ( } else { - /* - * There is no notify handler (per-device or system) for this device. - */ + /* There is no notify handler (per-device or system) for this device */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for Notify (%4.4s, %X) node %p\n", AcpiUtGetNodeName (Node), NotifyValue, Node)); @@ -324,9 +324,8 @@ AcpiEvNotifyDispatch ( /* - * We will invoke a global notify handler if installed. - * This is done _before_ we invoke the per-device handler attached - * to the device. + * We will invoke a global notify handler if installed. This is done + * _before_ we invoke the per-device handler attached to the device. */ if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) { @@ -405,7 +404,7 @@ AcpiEvGlobalLockHandler ( * If we don't get it now, it will be marked pending and we will * take another interrupt when it becomes free. */ - ACPI_ACQUIRE_GLOBAL_LOCK (Facs, Acquired); + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); if (Acquired) { /* Got the lock, now wake the thread waiting for it */ @@ -447,23 +446,16 @@ AcpiEvInitGlobalLockHandler ( ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler); - Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, - ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Attempt installation of the global lock handler */ - AcpiGbl_GlobalLockPresent = TRUE; Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AcpiEvGlobalLockHandler, NULL); /* - * If the global lock does not exist on this platform, the attempt - * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) - * Map to AE_OK, but mark global lock as not present. - * Any attempt to actually use the global lock will be flagged - * with an error. + * If the global lock does not exist on this platform, the attempt to + * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). + * Map to AE_OK, but mark global lock as not present. Any attempt to + * actually use the global lock will be flagged with an error. */ if (Status == AE_NO_HARDWARE_RESPONSE) { @@ -471,9 +463,10 @@ AcpiEvInitGlobalLockHandler ( "No response from Global Lock hardware, disabling lock")); AcpiGbl_GlobalLockPresent = FALSE; - Status = AE_OK; + return_ACPI_STATUS (AE_OK); } + AcpiGbl_GlobalLockPresent = TRUE; return_ACPI_STATUS (Status); } @@ -566,8 +559,8 @@ AcpiEvAcquireGlobalLock ( } /* - * Make sure that a global lock actually exists. If not, just treat - * the lock as a standard mutex. + * Make sure that a global lock actually exists. If not, just treat the + * lock as a standard mutex. */ if (!AcpiGbl_GlobalLockPresent) { @@ -577,7 +570,7 @@ AcpiEvAcquireGlobalLock ( /* Attempt to acquire the actual hardware lock */ - ACPI_ACQUIRE_GLOBAL_LOCK (Facs, Acquired); + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); if (Acquired) { /* We got the lock */ @@ -641,7 +634,7 @@ AcpiEvReleaseGlobalLock ( { /* Allow any thread to release the lock */ - ACPI_RELEASE_GLOBAL_LOCK (Facs, Pending); + ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_FACS, Pending); /* * If the pending bit was set, we must write GBL_RLS to the control @@ -649,8 +642,8 @@ AcpiEvReleaseGlobalLock ( */ if (Pending) { - Status = AcpiSetRegister ( - ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1); + Status = AcpiWriteBitRegister ( + ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n")); @@ -691,8 +684,8 @@ AcpiEvTerminate ( if (AcpiGbl_EventsInitialized) { /* - * Disable all event-related functionality. - * In all cases, on error, print a message but obviously we don't abort. + * Disable all event-related functionality. In all cases, on error, + * print a message but obviously we don't abort. */ /* Disable all fixed events */ @@ -709,7 +702,7 @@ AcpiEvTerminate ( /* Disable all GPEs in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); /* Remove SCI handler */ @@ -730,7 +723,7 @@ AcpiEvTerminate ( /* Deallocate all handler objects installed within GPE info structs */ - Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers); + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL); /* Return to original mode if necessary */ diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evregion.c b/src/add-ons/kernel/bus_managers/acpi/events/evregion.c index bc555903e5..32d7b642f9 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evregion.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evregion.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * $Revision: 1.171 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EVREGION_C__ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" #include "acinterp.h" @@ -125,15 +125,6 @@ #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evregion") -#define ACPI_NUM_DEFAULT_SPACES 4 - -static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = -{ - ACPI_ADR_SPACE_SYSTEM_MEMORY, - ACPI_ADR_SPACE_SYSTEM_IO, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_ADR_SPACE_DATA_TABLE -}; /* Local prototypes */ @@ -151,6 +142,18 @@ AcpiEvInstallHandler ( void *Context, void **ReturnValue); +/* These are the address spaces that will get default handlers */ + +#define ACPI_NUM_DEFAULT_SPACES 4 + +static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_DATA_TABLE +}; + /******************************************************************************* * @@ -182,18 +185,19 @@ AcpiEvInstallRegionHandlers ( } /* - * All address spaces (PCI Config, EC, SMBus) are scope dependent - * and registration must occur for a specific device. + * All address spaces (PCI Config, EC, SMBus) are scope dependent and + * registration must occur for a specific device. * - * In the case of the system memory and IO address spaces there is currently - * no device associated with the address space. For these we use the root. + * In the case of the system memory and IO address spaces there is + * currently no device associated with the address space. For these we + * use the root. * - * We install the default PCI config space handler at the root so - * that this space is immediately available even though the we have - * not enumerated all the PCI Root Buses yet. This is to conform - * to the ACPI specification which states that the PCI config - * space must be always available -- even though we are nowhere - * near ready to find the PCI root buses at this point. + * We install the default PCI config space handler at the root so that + * this space is immediately available even though the we have not + * enumerated all the PCI Root Buses yet. This is to conform to the ACPI + * specification which states that the PCI config space must be always + * available -- even though we are nowhere near ready to find the PCI root + * buses at this point. * * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler * has already been installed (via AcpiInstallAddressSpaceHandler). @@ -257,12 +261,12 @@ AcpiEvInitializeOpRegions ( return_ACPI_STATUS (Status); } - /* - * Run the _REG methods for OpRegions in each default address space - */ + /* Run the _REG methods for OpRegions in each default address space */ + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { - /* TBD: Make sure handler is the DEFAULT handler, otherwise + /* + * TBD: Make sure handler is the DEFAULT handler, otherwise * _REG will have already been run. */ Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, @@ -378,7 +382,7 @@ Cleanup1: * * PARAMETERS: RegionObj - Internal region object * Function - Read or Write operation - * Address - Where in the space to read or write + * RegionOffset - Where in the region to read or write * BitWidth - Field width in bits (8, 16, 32, or 64) * Value - Pointer to in or out value, must be * full 64-bit ACPI_INTEGER @@ -394,7 +398,7 @@ ACPI_STATUS AcpiEvAddressSpaceDispatch ( ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, + UINT32 RegionOffset, UINT32 BitWidth, ACPI_INTEGER *Value) { @@ -429,14 +433,13 @@ AcpiEvAddressSpaceDispatch ( } /* - * It may be the case that the region has never been initialized + * It may be the case that the region has never been initialized. * Some types of regions require special init code */ if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) { - /* - * This region has not been initialized yet, do it - */ + /* This region has not been initialized yet, do it */ + RegionSetup = HandlerDesc->AddressSpace.Setup; if (!RegionSetup) { @@ -449,9 +452,9 @@ AcpiEvAddressSpaceDispatch ( } /* - * We must exit the interpreter because the region - * setup will potentially execute control methods - * (e.g., _REG method for this region) + * We must exit the interpreter because the region setup will + * potentially execute control methods (for example, the _REG method + * for this region) */ AcpiExExitInterpreter (); @@ -472,9 +475,8 @@ AcpiEvAddressSpaceDispatch ( return_ACPI_STATUS (Status); } - /* - * Region initialization may have been completed by RegionSetup - */ + /* Region initialization may have been completed by RegionSetup */ + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) { RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE; @@ -503,7 +505,7 @@ AcpiEvAddressSpaceDispatch ( ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", &RegionObj->Region.Handler->AddressSpace, Handler, - ACPI_FORMAT_NATIVE_UINT (Address), + ACPI_FORMAT_NATIVE_UINT (RegionObj->Region.Address + RegionOffset), AcpiUtGetRegionName (RegionObj->Region.SpaceId))); if (!(HandlerDesc->AddressSpace.HandlerFlags & @@ -519,7 +521,8 @@ AcpiEvAddressSpaceDispatch ( /* Call the handler */ - Status = Handler (Function, Address, BitWidth, Value, + Status = Handler (Function, + (RegionObj->Region.Address + RegionOffset), BitWidth, Value, HandlerDesc->AddressSpace.Context, RegionObj2->Extra.RegionContext); if (ACPI_FAILURE (Status)) @@ -608,7 +611,7 @@ AcpiEvDetachRegion( /* This is it, remove it from the handler's list */ *LastObjPtr = ObjDesc->Region.Next; - ObjDesc->Region.Next = NULL; /* Must clear field */ + ObjDesc->Region.Next = NULL; /* Must clear field */ if (AcpiNsIsLocked) { @@ -638,8 +641,8 @@ AcpiEvDetachRegion( } /* - * If the region has been activated, call the setup handler - * with the deactivate notification + * If the region has been activated, call the setup handler with + * the deactivate notification */ if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) { @@ -792,8 +795,8 @@ AcpiEvInstallHandler ( } /* - * We only care about regions.and objects - * that are allowed to have address space handlers + * We only care about regions and objects that are allowed to have + * address space handlers */ if ((Node->Type != ACPI_TYPE_DEVICE) && (Node->Type != ACPI_TYPE_REGION) && @@ -814,7 +817,7 @@ AcpiEvInstallHandler ( /* Devices are handled different than regions */ - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_DEVICE) + if (ObjDesc->Common.Type == ACPI_TYPE_DEVICE) { /* Check if this Device already has a handler for this address space */ @@ -823,19 +826,21 @@ AcpiEvInstallHandler ( { /* Found a handler, is it for the same address space? */ - if (NextHandlerObj->AddressSpace.SpaceId == HandlerObj->AddressSpace.SpaceId) + if (NextHandlerObj->AddressSpace.SpaceId == + HandlerObj->AddressSpace.SpaceId) { ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Found handler for region [%s] in device %p(%p) handler %p\n", + "Found handler for region [%s] in device %p(%p) " + "handler %p\n", AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId), ObjDesc, NextHandlerObj, HandlerObj)); /* * Since the object we found it on was a device, then it * means that someone has already installed a handler for - * the branch of the namespace from this device on. Just + * the branch of the namespace from this device on. Just * bail out telling the walk routine to not traverse this - * branch. This preserves the scoping rule for handlers. + * branch. This preserves the scoping rule for handlers. */ return (AE_CTRL_DEPTH); } @@ -846,9 +851,8 @@ AcpiEvInstallHandler ( } /* - * As long as the device didn't have a handler for this - * space we don't care about it. We just ignore it and - * proceed. + * As long as the device didn't have a handler for this space we + * don't care about it. We just ignore it and proceed. */ return (AE_OK); } @@ -857,16 +861,13 @@ AcpiEvInstallHandler ( if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId) { - /* - * This region is for a different address space - * -- just ignore it - */ + /* This region is for a different address space, just ignore it */ + return (AE_OK); } /* - * Now we have a region and it is for the handler's address - * space type. + * Now we have a region and it is for the handler's address space type. * * First disconnect region for any previous handler (if any) */ @@ -915,9 +916,8 @@ AcpiEvInstallSpaceHandler ( /* - * This registration is valid for only the types below - * and the root. This is where the default handlers - * get placed. + * This registration is valid for only the types below and the root. This + * is where the default handlers get placed. */ if ((Node->Type != ACPI_TYPE_DEVICE) && (Node->Type != ACPI_TYPE_PROCESSOR) && @@ -983,8 +983,8 @@ AcpiEvInstallSpaceHandler ( if (ObjDesc) { /* - * The attached device object already exists. - * Make sure the handler is not already installed. + * The attached device object already exists. Make sure the handler + * is not already installed. */ HandlerObj = ObjDesc->Device.Handler; @@ -1000,8 +1000,8 @@ AcpiEvInstallSpaceHandler ( { /* * It is (relatively) OK to attempt to install the SAME - * handler twice. This can easily happen - * with PCI_Config space. + * handler twice. This can easily happen with the + * PCI_Config space. */ Status = AE_SAME_HANDLER; goto UnlockAndExit; @@ -1069,9 +1069,8 @@ AcpiEvInstallSpaceHandler ( /* * Install the handler * - * At this point there is no existing handler. - * Just allocate the object for the handler and link it - * into the list. + * At this point there is no existing handler. Just allocate the object + * for the handler and link it into the list. */ HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); if (!HandlerObj) @@ -1147,11 +1146,10 @@ AcpiEvExecuteRegMethods ( /* - * Run all _REG methods for all Operation Regions for this - * space ID. This is a separate walk in order to handle any - * interdependencies between regions and _REG methods. (i.e. handlers - * must be installed for all regions of this Space ID before we - * can run any _REG methods) + * Run all _REG methods for all Operation Regions for this space ID. This + * is a separate walk in order to handle any interdependencies between + * regions and _REG methods. (i.e. handlers must be installed for all + * regions of this Space ID before we can run any _REG methods) */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, @@ -1195,8 +1193,8 @@ AcpiEvRegRun ( } /* - * We only care about regions.and objects - * that are allowed to have address space handlers + * We only care about regions.and objects that are allowed to have address + * space handlers */ if ((Node->Type != ACPI_TYPE_REGION) && (Node != AcpiGbl_RootNode)) @@ -1218,10 +1216,8 @@ AcpiEvRegRun ( if (ObjDesc->Region.SpaceId != SpaceId) { - /* - * This region is for a different address space - * -- just ignore it - */ + /* This region is for a different address space, just ignore it */ + return (AE_OK); } diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evrgnini.c b/src/add-ons/kernel/bus_managers/acpi/events/evrgnini.c index c89f700e8b..9c45ee84f0 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evrgnini.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evrgnini.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init - * $Revision: 1.89 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EVRGNINI_C__ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" @@ -126,10 +126,6 @@ /* Local prototypes */ -static BOOLEAN -AcpiEvMatchPciRootBridge ( - char *Id); - static BOOLEAN AcpiEvIsPciRootBridge ( ACPI_NAMESPACE_NODE *Node); @@ -335,16 +331,17 @@ AcpiEvPciConfigRegionSetup ( if (Status == AE_SAME_HANDLER) { /* - * It is OK if the handler is already installed on the root - * bridge. Still need to return a context object for the - * new PCI_Config operation region, however. + * It is OK if the handler is already installed on the + * root bridge. Still need to return a context object + * for the new PCI_Config operation region, however. */ Status = AE_OK; } else { ACPI_EXCEPTION ((AE_INFO, Status, - "Could not install PciConfig handler for Root Bridge %4.4s", + "Could not install PciConfig handler " + "for Root Bridge %4.4s", AcpiUtGetNodeName (PciRootNode))); } } @@ -379,8 +376,8 @@ AcpiEvPciConfigRegionSetup ( } /* - * For PCI_Config space access, we need the segment, bus, - * device and function numbers. Acquire them here. + * For PCI_Config space access, we need the segment, bus, device and + * function numbers. Acquire them here. * * Find the parent device object. (This allows the operation region to be * within a subscope under the device, such as a control method.) @@ -398,14 +395,15 @@ AcpiEvPciConfigRegionSetup ( } /* - * Get the PCI device and function numbers from the _ADR object - * contained in the parent's scope. + * Get the PCI device and function numbers from the _ADR object contained + * in the parent's scope. */ - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, PciDeviceNode, &PciValue); + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, + PciDeviceNode, &PciValue); /* - * The default is zero, and since the allocation above zeroed - * the data, just do nothing on failure. + * The default is zero, and since the allocation above zeroed the data, + * just do nothing on failure. */ if (ACPI_SUCCESS (Status)) { @@ -415,7 +413,8 @@ AcpiEvPciConfigRegionSetup ( /* The PCI segment number comes from the _SEG method */ - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, PciRootNode, &PciValue); + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, + PciRootNode, &PciValue); if (ACPI_SUCCESS (Status)) { PciId->Segment = ACPI_LOWORD (PciValue); @@ -423,7 +422,8 @@ AcpiEvPciConfigRegionSetup ( /* The PCI bus number comes from the _BBN method */ - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, PciRootNode, &PciValue); + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, + PciRootNode, &PciValue); if (ACPI_SUCCESS (Status)) { PciId->Bus = ACPI_LOWORD (PciValue); @@ -438,42 +438,6 @@ AcpiEvPciConfigRegionSetup ( } -/******************************************************************************* - * - * FUNCTION: AcpiEvMatchPciRootBridge - * - * PARAMETERS: Id - The HID/CID in string format - * - * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge - * - * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. - * - ******************************************************************************/ - -static BOOLEAN -AcpiEvMatchPciRootBridge ( - char *Id) -{ - - /* - * Check if this is a PCI root. - * ACPI 3.0+: check for a PCI Express root also. - */ - if (!(ACPI_STRNCMP (Id, - PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING))) || - - !(ACPI_STRNCMP (Id, - PCI_EXPRESS_ROOT_HID_STRING, - sizeof (PCI_EXPRESS_ROOT_HID_STRING)))) - { - return (TRUE); - } - - return (FALSE); -} - - /******************************************************************************* * * FUNCTION: AcpiEvIsPciRootBridge @@ -492,29 +456,30 @@ AcpiEvIsPciRootBridge ( ACPI_NAMESPACE_NODE *Node) { ACPI_STATUS Status; - ACPI_DEVICE_ID Hid; - ACPI_COMPATIBLE_ID_LIST *Cid; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; UINT32 i; + BOOLEAN Match; - /* - * Get the _HID and check for a PCI Root Bridge - */ + /* Get the _HID and check for a PCI Root Bridge */ + Status = AcpiUtExecute_HID (Node, &Hid); if (ACPI_FAILURE (Status)) { return (FALSE); } - if (AcpiEvMatchPciRootBridge (Hid.Value)) + Match = AcpiUtIsPciRootBridge (Hid->String); + ACPI_FREE (Hid); + + if (Match) { return (TRUE); } - /* - * The _HID did not match. - * Get the _CID and check for a PCI Root Bridge - */ + /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ + Status = AcpiUtExecute_CID (Node, &Cid); if (ACPI_FAILURE (Status)) { @@ -525,7 +490,7 @@ AcpiEvIsPciRootBridge ( for (i = 0; i < Cid->Count; i++) { - if (AcpiEvMatchPciRootBridge (Cid->Id[i].Value)) + if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) { ACPI_FREE (Cid); return (TRUE); @@ -652,9 +617,9 @@ AcpiEvDefaultRegionSetup ( * Get the appropriate address space handler for a newly * created region. * - * This also performs address space specific initialization. For + * This also performs address space specific initialization. For * example, PCI regions must have an _ADR object that contains - * a PCI address in the scope of the definition. This address is + * a PCI address in the scope of the definition. This address is * required to perform an access to PCI config space. * * MUTEX: Interpreter should be unlocked, because we may run the _REG @@ -714,7 +679,7 @@ AcpiEvInitializeRegion ( { /* * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached + * definition. This will be executed when the handler is attached * or removed */ RegionObj2->Extra.Method_REG = MethodNode; @@ -772,8 +737,8 @@ AcpiEvInitializeRegion ( AcpiNsLocked); /* - * Tell all users that this region is usable by running the _REG - * method + * Tell all users that this region is usable by + * running the _REG method */ if (AcpiNsLocked) { @@ -804,10 +769,8 @@ AcpiEvInitializeRegion ( } } - /* - * This node does not have the handler we need; - * Pop up one level - */ + /* This node does not have the handler we need; Pop up one level */ + Node = AcpiNsGetParentNode (Node); } diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evsci.c b/src/add-ons/kernel/bus_managers/acpi/events/evsci.c index 1746d84b6f..cde433ce3e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evsci.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evsci.c @@ -2,7 +2,6 @@ * * Module Name: evsci - System Control Interrupt configuration and * legacy to ACPI mode state transition functions - * $Revision: 1.104 $ * ******************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acevents.h" @@ -204,10 +204,8 @@ AcpiEvGpeXruptHandler ( * if this interrupt handler is installed, ACPI is enabled. */ - /* - * GPEs: - * Check for and dispatch any GPEs that have occurred - */ + /* GPEs: Check for and dispatch any GPEs that have occurred */ + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); return_UINT32 (InterruptHandled); @@ -251,11 +249,11 @@ AcpiEvInstallSciHandler ( * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not * installed to begin with * - * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be + * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be * taken. * * Note: It doesn't seem important to disable all events or set the event - * enable registers to their original values. The OS should disable + * enable registers to their original values. The OS should disable * the SCI interrupt level when the handler is removed, so no more * events will come in. * diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evxface.c b/src/add-ons/kernel/bus_managers/acpi/events/evxface.c index 64fcd8a5e1..f816abad3a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evxface.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evxface.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * $Revision: 1.167 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EVXFACE_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acevents.h" #include "acinterp.h" @@ -378,7 +378,7 @@ AcpiInstallNotifyHandler ( /* * Root Object: * Registering a notify handler on the root object indicates that the - * caller wishes to receive notifications for all objects. Note that + * caller wishes to receive notifications for all objects. Note that * only one global handler can be regsitered (per notify type). */ if (Device == ACPI_ROOT_OBJECT) @@ -727,7 +727,8 @@ AcpiInstallGpeHandler ( /* Make sure that there isn't a handler there already */ - if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; @@ -761,7 +762,7 @@ AcpiInstallGpeHandler ( /* Setup up dispatch flags to indicate handler (vs. method) */ - GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ + GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); @@ -829,7 +830,8 @@ AcpiRemoveGpeHandler ( /* Make sure that a handler is indeed installed */ - if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_HANDLER) { Status = AE_NOT_EXIST; goto UnlockAndExit; diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evxfevnt.c b/src/add-ons/kernel/bus_managers/acpi/events/evxfevnt.c index 1318fa1d50..bc24f18c51 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evxfevnt.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evxfevnt.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * $Revision: 1.94 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EVXFEVNT_C__ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" #include "actables.h" @@ -125,6 +125,14 @@ #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfevnt") +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + /******************************************************************************* * @@ -264,10 +272,12 @@ AcpiEnableEvent ( } /* - * Enable the requested fixed event (by writing a one to the - * enable register bit) + * Enable the requested fixed event (by writing a one to the enable + * register bit) */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 1); + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_ENABLE_EVENT); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -275,8 +285,8 @@ AcpiEnableEvent ( /* Make sure that the hardware responded */ - Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - &Value); + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -504,17 +514,19 @@ AcpiDisableEvent ( } /* - * Disable the requested fixed event (by writing a zero to the - * enable register bit) + * Disable the requested fixed event (by writing a zero to the enable + * register bit) */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 0); + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - &Value); + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -563,10 +575,12 @@ AcpiClearEvent ( } /* - * Clear the requested fixed event (By writing a one to the - * status register bit) + * Clear the requested fixed event (By writing a one to the status + * register bit) */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 1); + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); return_ACPI_STATUS (Status); } @@ -673,8 +687,8 @@ AcpiGetEventStatus ( /* Get the status of the requested fixed event */ - Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - EventStatus); + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus); return_ACPI_STATUS (Status); } @@ -803,7 +817,7 @@ AcpiInstallGpeBlock ( * is always zero */ Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, - 0, InterruptNumber, &GpeBlock); + 0, InterruptNumber, &GpeBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -922,3 +936,177 @@ UnlockAndExit: ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) + +/******************************************************************************* + * + * FUNCTION: AcpiGetGpeDevice + * + * PARAMETERS: Index - System GPE index (0-CurrentGpeCount) + * GpeDevice - Where the parent GPE Device is returned + * + * RETURN: Status + * + * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL + * gpe device indicates that the gpe number is contained in one of + * the FADT-defined gpe blocks. Otherwise, the GPE block device. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 Index, + ACPI_HANDLE *GpeDevice) +{ + ACPI_GPE_DEVICE_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetGpeDevice); + + + if (!GpeDevice) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Index >= AcpiCurrentGpeCount) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Setup and walk the GPE list */ + + Info.Index = Index; + Info.Status = AE_NOT_EXIST; + Info.GpeDevice = NULL; + Info.NextBlockBaseIndex = 0; + + Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice); + return_ACPI_STATUS (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeDevice + * + * PARAMETERS: GPE_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE + * block device. NULL if the GPE is one of the FADT-defined GPEs. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + ACPI_GPE_DEVICE_INFO *Info = Context; + + + /* Increment Index by the number of GPEs in this block */ + + Info->NextBlockBaseIndex += + (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH); + + if (Info->Index < Info->NextBlockBaseIndex) + { + /* + * The GPE index is within this block, get the node. Leave the node + * NULL for the FADT-defined GPEs + */ + if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) + { + Info->GpeDevice = GpeBlock->Node; + } + + Info->Status = AE_OK; + return (AE_CTRL_END); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDisableAllGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableAllGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwDisableAllGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwEnableAllRuntimeGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return_ACPI_STATUS (Status); +} + + diff --git a/src/add-ons/kernel/bus_managers/acpi/events/evxfregn.c b/src/add-ons/kernel/bus_managers/acpi/events/evxfregn.c index 8cfeca5725..d4f499130a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/events/evxfregn.c +++ b/src/add-ons/kernel/bus_managers/acpi/events/evxfregn.c @@ -2,7 +2,6 @@ * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. - * $Revision: 1.71 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EVXFREGN_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acevents.h" @@ -285,7 +285,8 @@ AcpiRemoveAddressSpaceHandler ( /* Matched SpaceId, first dereference this in the Regions */ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Removing address handler %p(%p) for region %s on Device %p(%p)\n", + "Removing address handler %p(%p) for region %s " + "on Device %p(%p)\n", HandlerObj, Handler, AcpiUtGetRegionName (SpaceId), Node, ObjDesc)); diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exconfig.c b/src/add-ons/kernel/bus_managers/acpi/executer/exconfig.c index 650ef3ad9c..8c08165251 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exconfig.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exconfig.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 1.113 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,11 +117,12 @@ #define __EXCONFIG_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" -#include "amlcode.h" #include "acnamesp.h" #include "actables.h" #include "acdispat.h" +#include "acevents.h" #define _COMPONENT ACPI_EXECUTER @@ -136,6 +136,12 @@ AcpiExAddTable ( ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle); +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer); + /******************************************************************************* * @@ -175,12 +181,13 @@ AcpiExAddTable ( /* Init the table handle */ - ObjDesc->Reference.Opcode = AML_LOAD_OP; + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; *DdbHandle = ObjDesc; /* Install the new table into the local data structures */ - ObjDesc->Reference.Object = ACPI_TO_POINTER (TableIndex); + ObjDesc->Reference.Value = TableIndex; /* Add the table to the namespace */ @@ -189,8 +196,15 @@ AcpiExAddTable ( { AcpiUtRemoveReference (ObjDesc); *DdbHandle = NULL; + return_ACPI_STATUS (Status); } + /* Execute any module-level code that was found in the table */ + + AcpiExExitInterpreter (); + AcpiNsExecModuleCodeList (); + AcpiExEnterInterpreter (); + return_ACPI_STATUS (Status); } @@ -326,6 +340,8 @@ AcpiExLoadTableOp ( if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); + + AcpiUtRemoveReference (DdbHandle); return_ACPI_STATUS (Status); } } @@ -351,6 +367,53 @@ AcpiExLoadTableOp ( } +/******************************************************************************* + * + * FUNCTION: AcpiExRegionRead + * + * PARAMETERS: ObjDesc - Region descriptor + * Length - Number of bytes to read + * Buffer - Pointer to where to put the data + * + * RETURN: Status + * + * DESCRIPTION: Read data from an operation region. The read starts from the + * beginning of the region. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer) +{ + ACPI_STATUS Status; + ACPI_INTEGER Value; + UINT32 RegionOffset = 0; + UINT32 i; + + + /* Bytewise reads */ + + for (i = 0; i < Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, + RegionOffset, 8, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Buffer = (UINT8) Value; + Buffer++; + RegionOffset++; + } + + return (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiExLoadOp @@ -393,7 +456,7 @@ AcpiExLoadOp ( /* Source Object can be either an OpRegion or a Buffer/Field */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_REGION: @@ -420,19 +483,23 @@ AcpiExLoadOp ( } } - /* - * Map the table header and get the actual table length. The region - * length is not guaranteed to be the same as the table length. - */ - Table = AcpiOsMapMemory (ObjDesc->Region.Address, - sizeof (ACPI_TABLE_HEADER)); + /* Get the table header first so we can get the table length */ + + Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); if (!Table) { return_ACPI_STATUS (AE_NO_MEMORY); } + Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), + ACPI_CAST_PTR (UINT8, Table)); Length = Table->Length; - AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + ACPI_FREE (Table); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Must have at least an ACPI table header */ @@ -442,10 +509,19 @@ AcpiExLoadOp ( } /* - * The memory region is not guaranteed to remain stable and we must - * copy the table to a local buffer. For example, the memory region - * is corrupted after suspend on some machines. Dynamically loaded - * tables are usually small, so this overhead is minimal. + * The original implementation simply mapped the table, with no copy. + * However, the memory region is not guaranteed to remain stable and + * we must copy the table to a local buffer. For example, the memory + * region is corrupted after suspend on some machines. Dynamically + * loaded tables are usually small, so this overhead is minimal. + * + * The latest implementation (5/2009) does not use a mapping at all. + * We use the low-level operation region interface to read the table + * instead of the obvious optimization of using a direct mapping. + * This maintains a consistent use of operation regions across the + * entire subsystem. This is important if additional processing must + * be performed in the (possibly user-installed) operation region + * handler. For example, AcpiExec and ASLTS depend on this. */ /* Allocate a buffer for the table */ @@ -456,18 +532,16 @@ AcpiExLoadOp ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* Map the entire table and copy it */ + /* Read the entire table */ - Table = AcpiOsMapMemory (ObjDesc->Region.Address, Length); - if (!Table) + Status = AcpiExRegionRead (ObjDesc, Length, + ACPI_CAST_PTR (UINT8, TableDesc.Pointer)); + if (ACPI_FAILURE (Status)) { ACPI_FREE (TableDesc.Pointer); - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS (Status); } - ACPI_MEMCPY (TableDesc.Pointer, Table, Length); - AcpiOsUnmapMemory (Table, Length); - TableDesc.Address = ObjDesc->Region.Address; break; @@ -569,6 +643,10 @@ AcpiExLoadOp ( return_ACPI_STATUS (Status); } + /* Remove the reference by added by AcpiExStore above */ + + AcpiUtRemoveReference (DdbHandle); + /* Invoke table handler if present */ if (AcpiGbl_TableHandler) @@ -615,20 +693,32 @@ AcpiExUnloadTable ( /* * Validate the handle - * Although the handle is partially validated in AcpiExReconfiguration(), + * Although the handle is partially validated in AcpiExReconfiguration() * when it calls AcpiExResolveOperands(), the handle is more completely * validated here. + * + * Handle must be a valid operand object of type reference. Also, the + * DdbHandle must still be marked valid (table has not been previously + * unloaded) */ if ((!DdbHandle) || (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (DdbHandle) != ACPI_TYPE_LOCAL_REFERENCE)) + (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) || + (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID))) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get the table index from the DdbHandle (ACPI_SIZE for 64-bit case) */ + /* Get the table index from the DdbHandle */ - TableIndex = (UINT32) (ACPI_SIZE) TableDesc->Reference.Object; + TableIndex = TableDesc->Reference.Value; + + /* Ensure the table is still loaded */ + + if (!AcpiTbIsTableLoaded (TableIndex)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } /* Invoke table handler if present */ @@ -642,18 +732,22 @@ AcpiExUnloadTable ( } } - /* - * Delete the entire namespace under this table Node - * (Offset contains the TableId) - */ - AcpiTbDeleteNamespaceByOwner (TableIndex); - (void) AcpiTbReleaseOwnerId (TableIndex); + /* Delete the portion of the namespace owned by this table */ + Status = AcpiTbDeleteNamespaceByOwner (TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + (void) AcpiTbReleaseOwnerId (TableIndex); AcpiTbSetTableLoadedFlag (TableIndex, FALSE); - /* Table unloaded, remove a reference to the DdbHandle object */ - - AcpiUtRemoveReference (DdbHandle); + /* + * Invalidate the handle. We do this because the handle may be stored + * in a named object and may not be actually deleted until much later. + */ + DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; return_ACPI_STATUS (AE_OK); } diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exconvrt.c b/src/add-ons/kernel/bus_managers/acpi/executer/exconvrt.c index 9ddbfab98a..e7d8530329 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exconvrt.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exconvrt.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: exconvrt - Object conversion routines - * $Revision: 1.75 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXCONVRT_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" @@ -139,7 +139,7 @@ AcpiExConvertToAscii ( * * FUNCTION: AcpiExConvertToInteger * - * PARAMETERS: ObjDesc - Object to be converted. Must be an + * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the new Integer object is returned * Flags - Used for string conversion @@ -167,7 +167,7 @@ AcpiExConvertToInteger ( ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_INTEGER: @@ -190,7 +190,7 @@ AcpiExConvertToInteger ( } /* - * Convert the buffer/string to an integer. Note that both buffers and + * Convert the buffer/string to an integer. Note that both buffers and * strings are treated as raw data - we don't convert ascii to hex for * strings. * @@ -202,13 +202,13 @@ AcpiExConvertToInteger ( /* String conversion is different than Buffer conversion */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_STRING: /* * Convert string to an integer - for most cases, the string must be - * hexadecimal as per the ACPI specification. The only exception (as + * hexadecimal as per the ACPI specification. The only exception (as * of ACPI 3.0) is that the ToInteger() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ @@ -253,6 +253,7 @@ AcpiExConvertToInteger ( default: + /* No other types can get here */ break; } @@ -281,7 +282,7 @@ AcpiExConvertToInteger ( * * FUNCTION: AcpiExConvertToBuffer * - * PARAMETERS: ObjDesc - Object to be converted. Must be an + * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the new buffer object is returned * @@ -303,7 +304,7 @@ AcpiExConvertToBuffer ( ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc); - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER: @@ -476,7 +477,7 @@ AcpiExConvertToAscii ( } /* - * Since leading zeros are supressed, we must check for the case where + * Since leading zeros are suppressed, we must check for the case where * the integer equals 0 * * Finally, null terminate the string and return the length @@ -496,7 +497,7 @@ AcpiExConvertToAscii ( * * FUNCTION: AcpiExConvertToString * - * PARAMETERS: ObjDesc - Object to be converted. Must be an + * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the string object is returned * Type - String flags (base and conversion type) @@ -524,7 +525,7 @@ AcpiExConvertToString ( ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc); - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_STRING: @@ -592,7 +593,7 @@ AcpiExConvertToString ( Base = 10; /* - * Calculate the final string length. Individual string values + * Calculate the final string length. Individual string values * are variable length (include separator for each) */ for (i = 0; i < ObjDesc->Buffer.Length; i++) @@ -637,8 +638,14 @@ AcpiExConvertToString ( /* * Create a new string object and string buffer * (-1 because of extra separator included in StringLength from above) + * Allow creation of zero-length strings from zero-length buffers. */ - ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) (StringLength - 1)); + if (StringLength) + { + StringLength--; + } + + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -662,7 +669,10 @@ AcpiExConvertToString ( * Null terminate the string * (overwrites final comma/space from above) */ - NewBuf--; + if (ObjDesc->Buffer.Length) + { + NewBuf--; + } *NewBuf = 0; break; @@ -728,7 +738,7 @@ AcpiExConvertToTargetType ( default: /* No conversion allowed for these types */ - if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc)) + if (DestinationType != SourceDesc->Common.Type) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Explicit operator, will store (%s) over existing type (%s)\n", @@ -749,7 +759,7 @@ AcpiExConvertToTargetType ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: /* - * These types require an Integer operand. We can convert + * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, @@ -759,7 +769,7 @@ AcpiExConvertToTargetType ( case ACPI_TYPE_STRING: /* - * The operand must be a String. We can convert an + * The operand must be a String. We can convert an * Integer or Buffer if necessary */ Status = AcpiExConvertToString (SourceDesc, ResultDesc, @@ -769,7 +779,7 @@ AcpiExConvertToTargetType ( case ACPI_TYPE_BUFFER: /* - * The operand must be a Buffer. We can convert an + * The operand must be a Buffer. We can convert an * Integer or String if necessary */ Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/excreate.c b/src/add-ons/kernel/bus_managers/acpi/executer/excreate.c index dc397dea9a..e5463187a8 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/excreate.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/excreate.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: excreate - Named object creation - * $Revision: 1.117 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXCREATE_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" @@ -614,7 +614,7 @@ AcpiExCreateMethod ( * ACPI 2.0: SyncLevel = SyncLevel in method declaration */ ObjDesc->Method.SyncLevel = (UINT8) - ((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4); + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); } /* Attach the new object to the method Node */ diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exdump.c b/src/add-ons/kernel/bus_managers/acpi/executer/exdump.c index 3fc9acde45..5de5a6f6e4 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exdump.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exdump.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: exdump - Interpreter debug output routines - * $Revision: 1.206 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,10 +116,11 @@ #define __EXDUMP_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" -#include "acparser.h" + #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exdump") @@ -213,10 +213,11 @@ static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"} }; -static ACPI_EXDUMP_INFO AcpiExDumpMethod[8] = +static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "ParamCount"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.MethodFlags), "Method Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"}, @@ -305,12 +306,12 @@ static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} }; - -static ACPI_EXDUMP_INFO AcpiExDumpReference[7] = +static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Offset), "Offset"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, @@ -345,7 +346,6 @@ static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] = {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"} }; - static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL}, @@ -449,6 +449,7 @@ AcpiExDumpObject ( break; case ACPI_EXD_TYPE: + AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); break; @@ -470,7 +471,7 @@ AcpiExDumpObject ( case ACPI_EXD_UINT64: AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value", - ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); + ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); break; case ACPI_EXD_POINTER: @@ -505,13 +506,15 @@ AcpiExDumpObject ( case ACPI_EXD_REFERENCE: - AcpiExOutString ("Opcode", - (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); + AcpiExOutString ("Class Name", + ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc))); AcpiExDumpReferenceObj (ObjDesc); break; default: - AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", Info->Opcode); + + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Info->Opcode); return; } @@ -589,91 +592,57 @@ AcpiExDumpOperand ( /* Decode object type */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: - switch (ObjDesc->Reference.Opcode) + AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc)); + + switch (ObjDesc->Reference.Class) { - case AML_DEBUG_OP: - - AcpiOsPrintf ("Reference: Debug\n"); - break; - - - case AML_INDEX_OP: - - AcpiOsPrintf ("Reference: Index %p\n", - ObjDesc->Reference.Object); - break; - - - case AML_LOAD_OP: - - AcpiOsPrintf ("Reference: [DdbHandle] TableIndex %p\n", - ObjDesc->Reference.Object); - break; - - - case AML_REF_OF_OP: - - AcpiOsPrintf ("Reference: (RefOf) %p [%s]\n", - ObjDesc->Reference.Object, - AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) ObjDesc->Reference.Object)->Common.Type)); - break; - - - case AML_ARG_OP: - - AcpiOsPrintf ("Reference: Arg%d", - ObjDesc->Reference.Offset); - - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) - { - /* Value is an Integer */ - - AcpiOsPrintf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); - } + case ACPI_REFCLASS_DEBUG: AcpiOsPrintf ("\n"); break; - case AML_LOCAL_OP: + case ACPI_REFCLASS_INDEX: - AcpiOsPrintf ("Reference: Local%d", - ObjDesc->Reference.Offset); - - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) - { - - /* Value is an Integer */ - - AcpiOsPrintf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); - } - - AcpiOsPrintf ("\n"); + AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object); break; - case AML_INT_NAMEPATH_OP: + case ACPI_REFCLASS_TABLE: - AcpiOsPrintf ("Reference: Namepath %X [%4.4s]\n", - ObjDesc->Reference.Node->Name.Integer, - ObjDesc->Reference.Node->Name.Ascii); + AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value); break; - default: + case ACPI_REFCLASS_REFOF: - /* Unknown opcode */ - - AcpiOsPrintf ("Unknown Reference opcode=%X\n", - ObjDesc->Reference.Opcode); + AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); break; + + case ACPI_REFCLASS_NAME: + + AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii); + break; + + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + + AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value); + break; + + + default: /* Unknown reference class */ + + AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); + break; } break; @@ -683,7 +652,6 @@ AcpiExDumpOperand ( AcpiOsPrintf ("Buffer length %.2X @ %p\n", ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); - /* Debug only -- dump the buffer contents */ if (ObjDesc->Buffer.Pointer) @@ -694,7 +662,8 @@ AcpiExDumpOperand ( Length = 128; } - AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", Length); + AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", + Length); ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); } break; @@ -770,8 +739,8 @@ AcpiExDumpOperand ( case ACPI_TYPE_LOCAL_REGION_FIELD: - AcpiOsPrintf ( - "RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", + AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at " + "byte=%X bit=%X of below:\n", ObjDesc->Field.BitLength, ObjDesc->Field.AccessByteWidth, ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, @@ -791,8 +760,7 @@ AcpiExDumpOperand ( case ACPI_TYPE_BUFFER_FIELD: - AcpiOsPrintf ( - "BufferField: %X bits at byte %X bit %X of\n", + AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n", ObjDesc->BufferField.BitLength, ObjDesc->BufferField.BaseByteOffset, ObjDesc->BufferField.StartFieldBitOffset); @@ -801,7 +769,7 @@ AcpiExDumpOperand ( { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); } - else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) != + else if ((ObjDesc->BufferField.BufferObj)->Common.Type != ACPI_TYPE_BUFFER) { AcpiOsPrintf ("*not a Buffer*\n"); @@ -861,7 +829,7 @@ AcpiExDumpOperand ( default: /* Unknown Type */ - AcpiOsPrintf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc)); + AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type); break; } @@ -977,10 +945,10 @@ AcpiExDumpNamespaceNode ( } } - AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); - AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); - AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); - AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); + AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); + AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); + AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); + AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), AcpiExDumpNode); @@ -1007,9 +975,9 @@ AcpiExDumpReferenceObj ( RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - if (ObjDesc->Reference.Opcode == AML_INT_NAMEPATH_OP) + if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME) { - AcpiOsPrintf (" Named Object %p ", ObjDesc->Reference.Node); + AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); if (ACPI_FAILURE (Status)) @@ -1027,25 +995,20 @@ AcpiExDumpReferenceObj ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) { AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object); - if (ObjDesc->Reference.Opcode == AML_LOAD_OP) + if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) { - /* - * For DDBHandle reference, - * ObjDesc->Reference.Object is the table index - */ - AcpiOsPrintf (" [DDBHandle]\n"); + AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value); } else { - AcpiOsPrintf (" [%s]\n", + AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object, AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) ObjDesc->Reference.Object)->Common.Type)); } } else { - AcpiOsPrintf (" Target: %p\n", - ObjDesc->Reference.Object); + AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object); } } } @@ -1096,12 +1059,12 @@ AcpiExDumpPackageObj ( /* Packages may only contain a few object types */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_INTEGER: AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; @@ -1122,7 +1085,7 @@ AcpiExDumpPackageObj ( if (ObjDesc->Buffer.Length) { AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), - ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); } else { @@ -1134,7 +1097,7 @@ AcpiExDumpPackageObj ( case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("[Package] Contains %d Elements:\n", - ObjDesc->Package.Count); + ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) { @@ -1145,15 +1108,16 @@ AcpiExDumpPackageObj ( case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("[Object Reference] %s", - (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); + AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class); AcpiExDumpReferenceObj (ObjDesc); break; default: - AcpiOsPrintf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc)); + AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type); break; } } diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exfield.c b/src/add-ons/kernel/bus_managers/acpi/executer/exfield.c index 3f28224c39..0ee522c572 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exfield.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exfield.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 1.133 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXFIELD_C__ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" #include "acinterp.h" @@ -151,6 +151,7 @@ AcpiExReadDataFromField ( ACPI_OPERAND_OBJECT *BufferDesc; ACPI_SIZE Length; void *Buffer; + UINT32 Function; ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); @@ -167,7 +168,7 @@ AcpiExReadDataFromField ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) { /* * If the BufferField arguments have not been previously evaluated, @@ -182,14 +183,28 @@ AcpiExReadDataFromField ( } } } - else if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)) + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus read. We must create a buffer to hold the data - * and directly access the region handler. + * This is an SMBus or IPMI read. We must create a buffer to hold + * the data and then directly access the region handler. + * + * Note: Smbus protocol value is passed in upper 16-bits of Function */ - BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE); + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_READ; + } + + BufferDesc = AcpiUtCreateBufferObject (Length); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -199,13 +214,11 @@ AcpiExReadDataFromField ( AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - /* - * Perform the read. - * Note: Smbus protocol value is passed in upper 16-bits of Function - */ + /* Call the region handler for the read */ + Status = AcpiExAccessRegion (ObjDesc, 0, ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), - ACPI_READ | (ObjDesc->Field.Attribute << 16)); + Function); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); goto Exit; } @@ -249,7 +262,7 @@ AcpiExReadDataFromField ( ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", - ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc), Buffer, (UINT32) Length)); + ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", ObjDesc->CommonField.BitLength, @@ -304,6 +317,7 @@ AcpiExWriteDataToField ( UINT32 Length; void *Buffer; ACPI_OPERAND_OBJECT *BufferDesc; + UINT32 Function; ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); @@ -316,7 +330,7 @@ AcpiExWriteDataToField ( return_ACPI_STATUS (AE_AML_NO_OPERAND); } - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) { /* * If the BufferField arguments have not been previously evaluated, @@ -331,41 +345,60 @@ AcpiExWriteDataToField ( } } } - else if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)) + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus write. We will bypass the entire field mechanism - * and handoff the buffer directly to the handler. + * This is an SMBus or IPMI write. We will bypass the entire field + * mechanism and handoff the buffer directly to the handler. For + * these address spaces, the buffer is bi-directional; on a write, + * return data is returned in the same buffer. * - * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). + * Source must be a buffer of sufficient size: + * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE. + * + * Note: SMBus protocol type is passed in upper 16-bits of Function */ - if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) { - ACPI_ERROR ((AE_INFO, "SMBus write requires Buffer, found type %s", + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer, found type %s", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - if (SourceDesc->Buffer.Length < ACPI_SMBUS_BUFFER_SIZE) + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_WRITE; + } + + if (SourceDesc->Buffer.Length < Length) { ACPI_ERROR ((AE_INFO, - "SMBus write requires Buffer of length %X, found length %X", - ACPI_SMBUS_BUFFER_SIZE, SourceDesc->Buffer.Length)); + "SMBus or IPMI write requires Buffer of length %X, found length %X", + Length, SourceDesc->Buffer.Length)); return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); } - BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE); + /* Create the bi-directional buffer */ + + BufferDesc = AcpiUtCreateBufferObject (Length); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } Buffer = BufferDesc->Buffer.Pointer; - ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, - ACPI_SMBUS_BUFFER_SIZE); + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); /* Lock entire transaction if requested */ @@ -374,11 +407,9 @@ AcpiExWriteDataToField ( /* * Perform the write (returns status and perhaps data in the * same buffer) - * Note: SMBus protocol type is passed in upper 16-bits of Function. */ Status = AcpiExAccessRegion (ObjDesc, 0, - (ACPI_INTEGER *) Buffer, - ACPI_WRITE | (ObjDesc->Field.Attribute << 16)); + (ACPI_INTEGER *) Buffer, Function); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); *ResultDesc = BufferDesc; @@ -387,7 +418,7 @@ AcpiExWriteDataToField ( /* Get a pointer to the data to be written */ - switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) + switch (SourceDesc->Common.Type) { case ACPI_TYPE_INTEGER: Buffer = &SourceDesc->Integer.Value; @@ -410,13 +441,13 @@ AcpiExWriteDataToField ( ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", - SourceDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (SourceDesc)), - ACPI_GET_OBJECT_TYPE (SourceDesc), Buffer, Length)); + SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), + SourceDesc->Common.Type, Buffer, Length)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", - ObjDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)), - ACPI_GET_OBJECT_TYPE (ObjDesc), + ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type), + ObjDesc->Common.Type, ObjDesc->CommonField.BitLength, ObjDesc->CommonField.StartFieldBitOffset, ObjDesc->CommonField.BaseByteOffset)); diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exfldio.c b/src/add-ons/kernel/bus_managers/acpi/executer/exfldio.c index a7ca38827c..37a6786551 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exfldio.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exfldio.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * $Revision: 1.131 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXFLDIO_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" #include "acevents.h" @@ -179,10 +179,10 @@ AcpiExSetupRegion ( /* We must have a valid region */ - if (ACPI_GET_OBJECT_TYPE (RgnDesc) != ACPI_TYPE_REGION) + if (RgnDesc->Common.Type != ACPI_TYPE_REGION) { ACPI_ERROR ((AE_INFO, "Needed Region, found type %X (%s)", - ACPI_GET_OBJECT_TYPE (RgnDesc), + RgnDesc->Common.Type, AcpiUtGetObjectTypeName (RgnDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -201,20 +201,14 @@ AcpiExSetupRegion ( } } - /* Exit if Address/Length have been disallowed by the host OS */ - - if (RgnDesc->Common.Flags & AOPOBJ_INVALID) - { - return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS); - } - /* - * Exit now for SMBus address space, it has a non-linear address space + * Exit now for SMBus or IPMI address space, it has a non-linear address space * and the request cannot be directly validated */ - if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_IPMI) { - /* SMBus has a non-linear address space */ + /* SMBus or IPMI has a non-linear address space */ return_ACPI_STATUS (AE_OK); } @@ -321,7 +315,7 @@ AcpiExAccessRegion ( { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *RgnDesc; - ACPI_PHYSICAL_ADDRESS Address; + UINT32 RegionOffset; ACPI_FUNCTION_TRACE (ExAccessRegion); @@ -345,9 +339,9 @@ AcpiExAccessRegion ( * 3) The current offset into the field */ RgnDesc = ObjDesc->CommonField.RegionObj; - Address = RgnDesc->Region.Address + - ObjDesc->CommonField.BaseByteOffset + - FieldDatumByteOffset; + RegionOffset = + ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset; if ((Function & ACPI_IO_MASK) == ACPI_READ) { @@ -365,12 +359,11 @@ AcpiExAccessRegion ( ObjDesc->CommonField.AccessByteWidth, ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, - ACPI_CAST_PTR (void, Address))); + ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset)))); /* Invoke the appropriate AddressSpace/OpRegion handler */ - Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, - Address, + Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, RegionOffset, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) @@ -499,7 +492,7 @@ AcpiExFieldDatumIo ( * IndexField - Write to an Index Register, then read/write from/to a * Data Register */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER_FIELD: /* @@ -614,13 +607,13 @@ AcpiExFieldDatumIo ( return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "I/O to Data Register: ValuePtr %p\n", Value)); - if (ReadWrite == ACPI_READ) { /* Read the datum from the DataRegister */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Read from Data Register\n")); + Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, Value, sizeof (ACPI_INTEGER)); } @@ -628,6 +621,10 @@ AcpiExFieldDatumIo ( { /* Write the datum to the DataRegister */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Data Register: Value %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (*Value))); + Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, Value, sizeof (ACPI_INTEGER)); } @@ -637,7 +634,7 @@ AcpiExFieldDatumIo ( default: ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %X", - ACPI_GET_OBJECT_TYPE (ObjDesc))); + ObjDesc->Common.Type)); Status = AE_AML_INTERNAL; break; } diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exmisc.c b/src/add-ons/kernel/bus_managers/acpi/executer/exmisc.c index d0a754c59c..41e4a9752e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exmisc.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exmisc.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 1.145 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __EXMISC_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" #include "amlresrc.h" @@ -162,7 +162,7 @@ AcpiExGetObjectReference ( { case ACPI_DESC_TYPE_OPERAND: - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_LOCAL_REFERENCE) + if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -170,11 +170,11 @@ AcpiExGetObjectReference ( /* * Must be a reference to a Local or Arg */ - switch (ObjDesc->Reference.Opcode) + switch (ObjDesc->Reference.Class) { - case AML_LOCAL_OP: - case AML_ARG_OP: - case AML_DEBUG_OP: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_DEBUG: /* The referenced object is the pseudo-node for the local/arg */ @@ -183,8 +183,8 @@ AcpiExGetObjectReference ( default: - ACPI_ERROR ((AE_INFO, "Unknown Reference opcode %X", - ObjDesc->Reference.Opcode)); + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_INTERNAL); } break; @@ -215,7 +215,7 @@ AcpiExGetObjectReference ( return_ACPI_STATUS (AE_NO_MEMORY); } - ReferenceObj->Reference.Opcode = AML_REF_OF_OP; + ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF; ReferenceObj->Reference.Object = ReferencedObj; *ReturnDesc = ReferenceObj; @@ -357,7 +357,7 @@ AcpiExDoConcatenate ( * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ - switch (ACPI_GET_OBJECT_TYPE (Operand0)) + switch (Operand0->Common.Type) { case ACPI_TYPE_INTEGER: Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); @@ -374,7 +374,7 @@ AcpiExDoConcatenate ( default: ACPI_ERROR ((AE_INFO, "Invalid object type: %X", - ACPI_GET_OBJECT_TYPE (Operand0))); + Operand0->Common.Type)); Status = AE_AML_INTERNAL; } @@ -396,7 +396,7 @@ AcpiExDoConcatenate ( * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ - switch (ACPI_GET_OBJECT_TYPE (Operand0)) + switch (Operand0->Common.Type) { case ACPI_TYPE_INTEGER: @@ -476,7 +476,7 @@ AcpiExDoConcatenate ( /* Invalid object type, should not happen here */ ACPI_ERROR ((AE_INFO, "Invalid object type: %X", - ACPI_GET_OBJECT_TYPE (Operand0))); + Operand0->Common.Type)); Status =AE_AML_INTERNAL; goto Cleanup; } @@ -709,7 +709,7 @@ AcpiExDoLogicalOp ( * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ - switch (ACPI_GET_OBJECT_TYPE (Operand0)) + switch (Operand0->Common.Type) { case ACPI_TYPE_INTEGER: Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); @@ -737,7 +737,7 @@ AcpiExDoLogicalOp ( /* * Two cases: 1) Both Integers, 2) Both Strings or Buffers */ - if (ACPI_GET_OBJECT_TYPE (Operand0) == ACPI_TYPE_INTEGER) + if (Operand0->Common.Type == ACPI_TYPE_INTEGER) { /* * 1) Both operands are of type integer diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exmutex.c b/src/add-ons/kernel/bus_managers/acpi/executer/exmutex.c index 8e6e8d5899..db5ab9e77a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exmutex.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exmutex.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * $Revision: 1.43 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXMUTEX_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "acevents.h" @@ -166,6 +166,15 @@ AcpiExUnlinkMutex ( if (ObjDesc->Mutex.Prev) { (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; + + /* + * Migrate the previous sync level associated with this mutex to the + * previous mutex on the list so that it may be preserved. This handles + * the case where several mutexes have been acquired at the same level, + * but are not released in opposite order. + */ + (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel = + ObjDesc->Mutex.OriginalSyncLevel; } else { @@ -461,6 +470,7 @@ AcpiExReleaseMutex ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; + UINT8 PreviousSyncLevel; ACPI_FUNCTION_TRACE (ExReleaseMutex); @@ -488,10 +498,10 @@ AcpiExReleaseMutex ( (ObjDesc != AcpiGbl_GlobalLockMutex)) { ACPI_ERROR ((AE_INFO, - "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", - WalkState->Thread->ThreadId, + "Thread %p cannot release Mutex [%4.4s] acquired by thread %p", + ACPI_CAST_PTR (void, WalkState->Thread->ThreadId), AcpiUtGetNodeName (ObjDesc->Mutex.Node), - ObjDesc->Mutex.OwnerThread->ThreadId)); + ACPI_CAST_PTR (void, ObjDesc->Mutex.OwnerThread->ThreadId))); return_ACPI_STATUS (AE_AML_NOT_OWNER); } @@ -505,10 +515,13 @@ AcpiExReleaseMutex ( } /* - * The sync level of the mutex must be less than or equal to the current - * sync level + * The sync level of the mutex must be equal to the current sync level. In + * other words, the current level means that at least one mutex at that + * level is currently being held. Attempting to release a mutex of a + * different level can only mean that the mutex ordering rule is being + * violated. This behavior is clarified in ACPI 4.0 specification. */ - if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) + if (ObjDesc->Mutex.SyncLevel != WalkState->Thread->CurrentSyncLevel) { ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", @@ -517,13 +530,25 @@ AcpiExReleaseMutex ( return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } + /* + * Get the previous SyncLevel from the head of the acquired mutex list. + * This handles the case where several mutexes at the same level have been + * acquired, but are not released in reverse order. + */ + PreviousSyncLevel = + WalkState->Thread->AcquiredMutexList->Mutex.OriginalSyncLevel; + Status = AcpiExReleaseMutexObject (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } if (ObjDesc->Mutex.AcquisitionDepth == 0) { - /* Restore the original SyncLevel */ + /* Restore the previous SyncLevel */ - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + WalkState->Thread->CurrentSyncLevel = PreviousSyncLevel; } return_ACPI_STATUS (Status); } diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exnames.c b/src/add-ons/kernel/bus_managers/acpi/executer/exnames.c index 65dff5e24f..89fa2d4874 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exnames.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exnames.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exnames - interpreter/scanner name load/execute - * $Revision: 1.112 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXNAMES_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg1.c b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg1.c index 8aeeff591a..70085693ba 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg1.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg1.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * $Revision: 1.186 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXOPARG1_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acdispat.h" #include "acinterp.h" @@ -947,8 +947,8 @@ AcpiExOpcode_1A_0T_1R ( TempDesc = AcpiNsGetAttachedObject ( (ACPI_NAMESPACE_NODE *) Operand[0]); if (TempDesc && - ((ACPI_GET_OBJECT_TYPE (TempDesc) == ACPI_TYPE_STRING) || - (ACPI_GET_OBJECT_TYPE (TempDesc) == ACPI_TYPE_LOCAL_REFERENCE))) + ((TempDesc->Common.Type == ACPI_TYPE_STRING) || + (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE))) { Operand[0] = TempDesc; AcpiUtAddReference (TempDesc); @@ -961,7 +961,7 @@ AcpiExOpcode_1A_0T_1R ( } else { - switch (ACPI_GET_OBJECT_TYPE (Operand[0])) + switch ((Operand[0])->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: /* @@ -969,16 +969,16 @@ AcpiExOpcode_1A_0T_1R ( * * Must resolve/dereference the local/arg reference first */ - switch (Operand[0]->Reference.Opcode) + switch (Operand[0]->Reference.Class) { - case AML_LOCAL_OP: - case AML_ARG_OP: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: /* Set Operand[0] to the value of the local/arg */ Status = AcpiDsMethodDataGetValue ( - Operand[0]->Reference.Opcode, - Operand[0]->Reference.Offset, + Operand[0]->Reference.Class, + Operand[0]->Reference.Value, WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { @@ -993,7 +993,7 @@ AcpiExOpcode_1A_0T_1R ( Operand[0] = TempDesc; break; - case AML_REF_OF_OP: + case ACPI_REFCLASS_REFOF: /* Get the object to which the reference refers */ @@ -1020,7 +1020,7 @@ AcpiExOpcode_1A_0T_1R ( if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) { - if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_STRING) + if ((Operand[0])->Common.Type == ACPI_TYPE_STRING) { /* * This is a DerefOf (String). The string is a reference @@ -1068,9 +1068,9 @@ AcpiExOpcode_1A_0T_1R ( * This must be a reference object produced by either the * Index() or RefOf() operator */ - switch (Operand[0]->Reference.Opcode) + switch (Operand[0]->Reference.Class) { - case AML_INDEX_OP: + case ACPI_REFCLASS_INDEX: /* * The target type for the Index operator must be @@ -1103,7 +1103,7 @@ AcpiExOpcode_1A_0T_1R ( * reference to the buffer itself. */ ReturnDesc->Integer.Value = - TempDesc->Buffer.Pointer[Operand[0]->Reference.Offset]; + TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]; break; @@ -1124,7 +1124,7 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Unknown Index TargetType %X in obj %p", + "Unknown Index TargetType %X in reference object %p", Operand[0]->Reference.TargetType, Operand[0])); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -1132,7 +1132,7 @@ AcpiExOpcode_1A_0T_1R ( break; - case AML_REF_OF_OP: + case ACPI_REFCLASS_REFOF: ReturnDesc = Operand[0]->Reference.Object; @@ -1151,8 +1151,8 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Unknown opcode in reference(%p) - %X", - Operand[0], Operand[0]->Reference.Opcode)); + "Unknown class in reference(%p) - %2.2X", + Operand[0], Operand[0]->Reference.Class)); Status = AE_TYPE; goto Cleanup; diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg2.c b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg2.c index 2e0b4c915c..7c42652cc4 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg2.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg2.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * $Revision: 1.146 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXOPARG2_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acinterp.h" #include "acevents.h" @@ -504,14 +504,14 @@ AcpiExOpcode_2A_1T_1R ( /* Initialize the Index reference object */ Index = Operand[1]->Integer.Value; - ReturnDesc->Reference.Offset = (UINT32) Index; - ReturnDesc->Reference.Opcode = AML_INDEX_OP; + ReturnDesc->Reference.Value = (UINT32) Index; + ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX; /* * At this point, the Source operand is a String, Buffer, or Package. * Verify that the index is within range. */ - switch (ACPI_GET_OBJECT_TYPE (Operand[0])) + switch ((Operand[0])->Common.Type) { case ACPI_TYPE_STRING: diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg3.c b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg3.c index fad6272b2f..591d6aceb1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg3.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg3.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * $Revision: 1.36 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __EXOPARG3_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "acparser.h" #include "amlcode.h" @@ -256,7 +256,7 @@ AcpiExOpcode_3A_1T_1R ( * either a String or a Buffer, so just use its type. */ ReturnDesc = AcpiUtCreateInternalObject ( - ACPI_GET_OBJECT_TYPE (Operand[0])); + (Operand[0])->Common.Type); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -287,7 +287,7 @@ AcpiExOpcode_3A_1T_1R ( /* Strings always have a sub-pointer, not so for buffers */ - switch (ACPI_GET_OBJECT_TYPE (Operand[0])) + switch ((Operand[0])->Common.Type) { case ACPI_TYPE_STRING: diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg6.c b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg6.c index 2b3bc3cf4c..96c16a33bd 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exoparg6.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exoparg6.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exoparg6 - AML execution - opcodes with 6 arguments - * $Revision: 1.30 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __EXOPARG6_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "acparser.h" #include "amlcode.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exprep.c b/src/add-ons/kernel/bus_managers/acpi/executer/exprep.c index a99c6c5738..c915361e81 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exprep.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exprep.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities - * $Revision: 1.144 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXPREP_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" @@ -367,7 +367,7 @@ AcpiExDecodeFieldAccess ( return_UINT32 (0); } - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) { /* * BufferField access can be on any byte boundary, so the diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exregion.c b/src/add-ons/kernel/bus_managers/acpi/executer/exregion.c index 8fcf845114..958dc4e067 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exregion.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exregion.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exregion - ACPI default OpRegion (address space) handlers - * $Revision: 1.103 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __EXREGION_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" @@ -384,14 +384,14 @@ AcpiExSystemIoSpaceHandler ( { case ACPI_READ: - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, &Value32, BitWidth); *Value = Value32; break; case ACPI_WRITE: - Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address, + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address, (UINT32) *Value, BitWidth); break; diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exresnte.c b/src/add-ons/kernel/bus_managers/acpi/executer/exresnte.c index 278858d248..5481bc899a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exresnte.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exresnte.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exresnte - AML Interpreter object resolution - * $Revision: 1.78 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,11 +117,10 @@ #define __EXRESNTE_C__ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" -#include "acparser.h" -#include "amlcode.h" #define _COMPONENT ACPI_EXECUTER @@ -222,7 +220,7 @@ AcpiExResolveNodeToValue ( { case ACPI_TYPE_PACKAGE: - if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_PACKAGE) + if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) { ACPI_ERROR ((AE_INFO, "Object not a Package, type %s", AcpiUtGetObjectTypeName (SourceDesc))); @@ -242,7 +240,7 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_BUFFER: - if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) { ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s", AcpiUtGetObjectTypeName (SourceDesc))); @@ -262,7 +260,7 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_STRING: - if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) + if (SourceDesc->Common.Type != ACPI_TYPE_STRING) { ACPI_ERROR ((AE_INFO, "Object not a String, type %s", AcpiUtGetObjectTypeName (SourceDesc))); @@ -278,7 +276,7 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_INTEGER: - if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) + if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s", AcpiUtGetObjectTypeName (SourceDesc))); @@ -330,11 +328,11 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_LOCAL_REFERENCE: - switch (SourceDesc->Reference.Opcode) + switch (SourceDesc->Reference.Class) { - case AML_LOAD_OP: /* This is a DdbHandle */ - case AML_REF_OF_OP: - case AML_INDEX_OP: + case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */ + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_INDEX: /* Return an additional reference to the object */ @@ -346,9 +344,8 @@ AcpiExResolveNodeToValue ( /* No named references are allowed here */ ACPI_ERROR ((AE_INFO, - "Unsupported Reference opcode %X (%s)", - SourceDesc->Reference.Opcode, - AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); + "Unsupported Reference type %X", + SourceDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exresolv.c b/src/add-ons/kernel/bus_managers/acpi/executer/exresolv.c index 6f1c956c58..a3c8ab9b5c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exresolv.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exresolv.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exresolv - AML Interpreter object resolution - * $Revision: 1.146 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,11 +117,11 @@ #define __EXRESOLV_C__ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" -#include "acparser.h" #define _COMPONENT ACPI_EXECUTER @@ -230,7 +229,7 @@ AcpiExResolveObjectToValue ( ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *StackDesc; ACPI_OPERAND_OBJECT *ObjDesc = NULL; - UINT16 Opcode; + UINT8 RefType; ACPI_FUNCTION_TRACE (ExResolveObjectToValue); @@ -240,30 +239,30 @@ AcpiExResolveObjectToValue ( /* This is an ACPI_OPERAND_OBJECT */ - switch (ACPI_GET_OBJECT_TYPE (StackDesc)) + switch (StackDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: - Opcode = StackDesc->Reference.Opcode; + RefType = StackDesc->Reference.Class; - switch (Opcode) + switch (RefType) { - case AML_LOCAL_OP: - case AML_ARG_OP: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: /* * Get the local from the method's state info * Note: this increments the local's object reference count */ - Status = AcpiDsMethodDataGetValue (Opcode, - StackDesc->Reference.Offset, WalkState, &ObjDesc); + Status = AcpiDsMethodDataGetValue (RefType, + StackDesc->Reference.Value, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", - StackDesc->Reference.Offset, ObjDesc)); + StackDesc->Reference.Value, ObjDesc)); /* * Now we can delete the original Reference Object and @@ -274,7 +273,7 @@ AcpiExResolveObjectToValue ( break; - case AML_INDEX_OP: + case ACPI_REFCLASS_INDEX: switch (StackDesc->Reference.TargetType) { @@ -335,15 +334,15 @@ AcpiExResolveObjectToValue ( break; - case AML_REF_OF_OP: - case AML_DEBUG_OP: - case AML_LOAD_OP: + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_DEBUG: + case ACPI_REFCLASS_TABLE: /* Just leave the object as-is, do not dereference */ break; - case AML_INT_NAMEPATH_OP: /* Reference to a named object */ + case ACPI_REFCLASS_NAME: /* Reference to a named object */ /* Dereference the name */ @@ -368,8 +367,7 @@ AcpiExResolveObjectToValue ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference opcode %X (%s) in %p", - Opcode, AcpiPsGetOpcodeName (Opcode), StackDesc)); + "Unknown Reference type %X in %p", RefType, StackDesc)); Status = AE_AML_INTERNAL; break; } @@ -394,7 +392,7 @@ AcpiExResolveObjectToValue ( case ACPI_TYPE_LOCAL_INDEX_FIELD: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", - StackDesc, ACPI_GET_OBJECT_TYPE (StackDesc))); + StackDesc, StackDesc->Common.Type)); Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); @@ -482,16 +480,16 @@ AcpiExResolveMultiple ( * specification of the ObjectType and SizeOf operators). This means * traversing the list of possibly many nested references. */ - while (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REFERENCE) + while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) { - switch (ObjDesc->Reference.Opcode) + switch (ObjDesc->Reference.Class) { - case AML_REF_OF_OP: - case AML_INT_NAMEPATH_OP: + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_NAME: /* Dereference the reference pointer */ - if (ObjDesc->Reference.Opcode == AML_REF_OF_OP) + if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) { Node = ObjDesc->Reference.Object; } @@ -530,7 +528,7 @@ AcpiExResolveMultiple ( break; - case AML_INDEX_OP: + case ACPI_REFCLASS_INDEX: /* Get the type of this reference (index into another object) */ @@ -558,19 +556,19 @@ AcpiExResolveMultiple ( break; - case AML_LOAD_OP: + case ACPI_REFCLASS_TABLE: Type = ACPI_TYPE_DDB_HANDLE; goto Exit; - case AML_LOCAL_OP: - case AML_ARG_OP: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: if (ReturnDesc) { - Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Opcode, - ObjDesc->Reference.Offset, WalkState, &ObjDesc); + Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -579,8 +577,8 @@ AcpiExResolveMultiple ( } else { - Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Opcode, - ObjDesc->Reference.Offset, WalkState, &Node); + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -596,7 +594,7 @@ AcpiExResolveMultiple ( break; - case AML_DEBUG_OP: + case ACPI_REFCLASS_DEBUG: /* The Debug Object is of type "DebugObject" */ @@ -607,8 +605,7 @@ AcpiExResolveMultiple ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference subtype %X", - ObjDesc->Reference.Opcode)); + "Unknown Reference Class %2.2X", ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_INTERNAL); } } @@ -617,7 +614,7 @@ AcpiExResolveMultiple ( * Now we are guaranteed to have an object that has not been created * via the RefOf or Index operators. */ - Type = ACPI_GET_OBJECT_TYPE (ObjDesc); + Type = ObjDesc->Common.Type; Exit: diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exresop.c b/src/add-ons/kernel/bus_managers/acpi/executer/exresop.c index eebd9fc8e6..ecc63f6135 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exresop.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exresop.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exresop - AML Interpreter operand/object resolution - * $Revision: 1.96 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXRESOP_C__ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acparser.h" #include "acinterp.h" @@ -302,52 +302,48 @@ AcpiExResolveOperands ( /* ACPI internal object */ - ObjectType = ACPI_GET_OBJECT_TYPE (ObjDesc); + ObjectType = ObjDesc->Common.Type; /* Check for bad ACPI_OBJECT_TYPE */ if (!AcpiUtValidObjectType (ObjectType)) { ACPI_ERROR ((AE_INFO, - "Bad operand object type [%X]", - ObjectType)); + "Bad operand object type [%X]", ObjectType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) { - /* Decode the Reference */ + /* Validate the Reference */ - OpInfo = AcpiPsGetOpcodeInfo (Opcode); - if (OpInfo->Class == AML_CLASS_UNKNOWN) + switch (ObjDesc->Reference.Class) { - return_ACPI_STATUS (AE_AML_BAD_OPCODE); - } + case ACPI_REFCLASS_DEBUG: - switch (ObjDesc->Reference.Opcode) - { - case AML_DEBUG_OP: TargetOp = AML_DEBUG_OP; /*lint -fallthrough */ - case AML_INDEX_OP: - case AML_REF_OF_OP: - case AML_ARG_OP: - case AML_LOCAL_OP: - case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ - case AML_INT_NAMEPATH_OP: /* Reference to a named object */ + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_INDEX: + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case ACPI_REFCLASS_NAME: /* Reference to a named object */ - ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Operand is a Reference, RefOpcode [%s]\n", - (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name))); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Operand is a Reference, Class [%s] %2.2X\n", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class)); break; default: + ACPI_ERROR ((AE_INFO, - "Operand is a Reference, Unknown Reference Opcode: %X", - ObjDesc->Reference.Opcode)); + "Unknown Reference Class %2.2X in %p", + ObjDesc->Reference.Class, ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -359,8 +355,7 @@ AcpiExResolveOperands ( /* Invalid descriptor */ - ACPI_ERROR ((AE_INFO, - "Invalid descriptor %p [%s]", + ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -380,7 +375,7 @@ AcpiExResolveOperands ( case ARGI_REF_OR_STRING: /* Can be a String or Reference */ if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING)) + (ObjDesc->Common.Type == ACPI_TYPE_STRING)) { /* * String found - the string references a named object and @@ -430,8 +425,8 @@ AcpiExResolveOperands ( * -- All others must be resolved below. */ if ((Opcode == AML_STORE_OP) && - (ACPI_GET_OBJECT_TYPE (*StackPtr) == ACPI_TYPE_LOCAL_REFERENCE) && - ((*StackPtr)->Reference.Opcode == AML_INDEX_OP)) + ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) { goto NextOperand; } @@ -595,7 +590,7 @@ AcpiExResolveOperands ( /* Need an operand of type INTEGER, STRING or BUFFER */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: @@ -618,7 +613,7 @@ AcpiExResolveOperands ( /* Need an operand of type STRING or BUFFER */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -660,7 +655,7 @@ AcpiExResolveOperands ( * The only reference allowed here is a direct reference to * a namespace node. */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: @@ -684,7 +679,7 @@ AcpiExResolveOperands ( /* Need a buffer or package or (ACPI 2.0) String */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: @@ -707,7 +702,7 @@ AcpiExResolveOperands ( /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER: case ACPI_TYPE_REGION: @@ -729,7 +724,7 @@ AcpiExResolveOperands ( /* Used by the Store() operator only */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_PACKAGE: @@ -789,7 +784,7 @@ AcpiExResolveOperands ( * required object type (Simple cases only). */ Status = AcpiExCheckObjectType (TypeNeeded, - ACPI_GET_OBJECT_TYPE (*StackPtr), *StackPtr); + (*StackPtr)->Common.Type, *StackPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exstore.c b/src/add-ons/kernel/bus_managers/acpi/executer/exstore.c index 824fb50cdf..8ec8a23cff 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exstore.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exstore.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * $Revision: 1.210 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,11 +117,11 @@ #define __EXSTORE_C__ #include "acpi.h" +#include "accommon.h" #include "acdispat.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" -#include "acparser.h" #define _COMPONENT ACPI_EXECUTER @@ -217,7 +216,7 @@ AcpiExDoDebugObject ( /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ - switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) + switch (SourceDesc->Common.Type) { case ACPI_TYPE_INTEGER: @@ -265,22 +264,28 @@ AcpiExDoDebugObject ( case ACPI_TYPE_LOCAL_REFERENCE: - if (SourceDesc->Reference.Opcode == AML_INDEX_OP) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n", - AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode), - SourceDesc->Reference.Offset)); - } - else - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]", - AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); - } + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s] ", + AcpiUtGetReferenceName (SourceDesc))); - if (SourceDesc->Reference.Opcode == AML_LOAD_OP) /* Load and LoadTable */ + /* Decode the reference */ + + switch (SourceDesc->Reference.Class) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, - " Table OwnerId %p\n", SourceDesc->Reference.Object)); + case ACPI_REFCLASS_INDEX: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X\n", + SourceDesc->Reference.Value)); + break; + + case ACPI_REFCLASS_TABLE: + + /* Case for DdbHandle */ + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Table Index 0x%X\n", + SourceDesc->Reference.Value)); + return; + + default: break; } @@ -407,7 +412,7 @@ AcpiExStore ( /* Destination object must be a Reference or a Constant object */ - switch (ACPI_GET_OBJECT_TYPE (DestDesc)) + switch (DestDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: break; @@ -435,16 +440,16 @@ AcpiExStore ( } /* - * Examine the Reference opcode. These cases are handled: + * Examine the Reference class. These cases are handled: * * 1) Store to Name (Change the object associated with a name) * 2) Store to an indexed area of a Buffer or Package * 3) Store to a Method Local or Arg * 4) Store to the debug object */ - switch (RefDesc->Reference.Opcode) + switch (RefDesc->Reference.Class) { - case AML_REF_OF_OP: + case ACPI_REFCLASS_REFOF: /* Storing an object into a Name "container" */ @@ -454,7 +459,7 @@ AcpiExStore ( break; - case AML_INDEX_OP: + case ACPI_REFCLASS_INDEX: /* Storing to an Index (pointer into a packager or buffer) */ @@ -462,17 +467,17 @@ AcpiExStore ( break; - case AML_LOCAL_OP: - case AML_ARG_OP: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: /* Store to a method local/arg */ - Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, - RefDesc->Reference.Offset, SourceDesc, WalkState); + Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, + RefDesc->Reference.Value, SourceDesc, WalkState); break; - case AML_DEBUG_OP: + case ACPI_REFCLASS_DEBUG: /* * Storing to the Debug object causes the value stored to be @@ -488,9 +493,9 @@ AcpiExStore ( default: - ACPI_ERROR ((AE_INFO, "Unknown Reference opcode %X", - RefDesc->Reference.Opcode)); - ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + RefDesc->Reference.Class)); + ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); Status = AE_AML_INTERNAL; break; @@ -548,8 +553,8 @@ AcpiExStoreObjectToIndex ( */ ObjDesc = *(IndexDesc->Reference.Where); - if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE && - SourceDesc->Reference.Opcode == AML_LOAD_OP) + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && + SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) { /* This is a DDBHandle, just add a reference to it */ @@ -612,8 +617,8 @@ AcpiExStoreObjectToIndex ( * by the INDEX_OP code. */ ObjDesc = IndexDesc->Reference.Object; - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) && - (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) + if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -622,7 +627,7 @@ AcpiExStoreObjectToIndex ( * The assignment of the individual elements will be slightly * different for each source type. */ - switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) + switch (SourceDesc->Common.Type) { case ACPI_TYPE_INTEGER: @@ -651,7 +656,7 @@ AcpiExStoreObjectToIndex ( /* Store the source value into the target buffer byte */ - ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; + ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; break; @@ -807,7 +812,7 @@ AcpiExStoreObjectToNode ( /* No conversions for all other types. Just attach the source object */ Status = AcpiNsAttachObject (Node, SourceDesc, - ACPI_GET_OBJECT_TYPE (SourceDesc)); + SourceDesc->Common.Type); break; } diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exstoren.c b/src/add-ons/kernel/bus_managers/acpi/executer/exstoren.c index b93bd1527d..0810560d39 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exstoren.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exstoren.c @@ -3,7 +3,6 @@ * * Module Name: exstoren - AML Interpreter object store support, * Store to Node (namespace object) - * $Revision: 1.72 $ * *****************************************************************************/ @@ -11,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __EXSTOREN_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" @@ -177,7 +177,7 @@ AcpiExResolveObject ( * are all essentially the same. This case handles the * "interchangeable" types Integer, String, and Buffer. */ - if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) { /* Resolve a reference object first */ @@ -197,10 +197,11 @@ AcpiExResolveObject ( /* Must have a Integer, Buffer, or String */ - if ((ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) && - (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) && - (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) && - !((ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) && (SourceDesc->Reference.Opcode == AML_LOAD_OP))) + if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING) && + !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) { /* Conversion successful but still not a valid type */ @@ -300,7 +301,7 @@ AcpiExStoreObjectToObject ( return_ACPI_STATUS (Status); } - if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_GET_OBJECT_TYPE (DestDesc)) + if (SourceDesc->Common.Type != DestDesc->Common.Type) { /* * The source type does not match the type of the destination. @@ -311,7 +312,7 @@ AcpiExStoreObjectToObject ( * Otherwise, ActualSrcDesc is a temporary object to hold the * converted object. */ - Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), + Status = AcpiExConvertToTargetType (DestDesc->Common.Type, SourceDesc, &ActualSrcDesc, WalkState); if (ACPI_FAILURE (Status)) { @@ -333,7 +334,7 @@ AcpiExStoreObjectToObject ( * We now have two objects of identical types, and we can perform a * copy of the *value* of the source object. */ - switch (ACPI_GET_OBJECT_TYPE (DestDesc)) + switch (DestDesc->Common.Type) { case ACPI_TYPE_INTEGER: diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exstorob.c b/src/add-ons/kernel/bus_managers/acpi/executer/exstorob.c index 3057ea6e65..b2f125d01f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exstorob.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exstorob.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exstorob - AML Interpreter object store support, store to object - * $Revision: 1.63 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXSTOROB_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" @@ -150,6 +150,13 @@ AcpiExStoreBufferToBuffer ( ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + /* We know that SourceDesc is a buffer by now */ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); @@ -248,6 +255,13 @@ AcpiExStoreStringToString ( ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + /* We know that SourceDesc is a string by now */ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exsystem.c b/src/add-ons/kernel/bus_managers/acpi/executer/exsystem.c index a3c6424c76..19674606a6 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exsystem.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exsystem.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exsystem - Interface to OS services - * $Revision: 1.95 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __EXSYSTEM_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #define _COMPONENT ACPI_EXECUTER diff --git a/src/add-ons/kernel/bus_managers/acpi/executer/exutils.c b/src/add-ons/kernel/bus_managers/acpi/executer/exutils.c index 3314fa71be..1f5e861b68 100644 --- a/src/add-ons/kernel/bus_managers/acpi/executer/exutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/executer/exutils.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * $Revision: 1.131 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -134,6 +133,7 @@ #define DEFINE_AML_GLOBALS #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "amlcode.h" @@ -323,7 +323,7 @@ AcpiExTruncateFor32bitTable ( */ if ((!ObjDesc) || (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)) + (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) { return; } @@ -482,59 +482,76 @@ AcpiExDigitsNeeded ( * * FUNCTION: AcpiExEisaIdToString * - * PARAMETERS: NumericId - EISA ID to be converted + * PARAMETERS: CompressedId - EISAID to be converted * OutString - Where to put the converted string (8 bytes) * * RETURN: None * - * DESCRIPTION: Convert a numeric EISA ID to string representation + * DESCRIPTION: Convert a numeric EISAID to string representation. Return + * buffer must be large enough to hold the string. The string + * returned is always exactly of length ACPI_EISAID_STRING_SIZE + * (includes null terminator). The EISAID is always 32 bits. * ******************************************************************************/ void AcpiExEisaIdToString ( - UINT32 NumericId, - char *OutString) + char *OutString, + ACPI_INTEGER CompressedId) { - UINT32 EisaId; + UINT32 SwappedId; ACPI_FUNCTION_ENTRY (); + /* The EISAID should be a 32-bit integer */ + + if (CompressedId > ACPI_UINT32_MAX) + { + ACPI_WARNING ((AE_INFO, + "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + ACPI_FORMAT_UINT64 (CompressedId))); + } + /* Swap ID to big-endian to get contiguous bits */ - EisaId = AcpiUtDwordByteSwap (NumericId); + SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId); - OutString[0] = (char) ('@' + (((unsigned long) EisaId >> 26) & 0x1f)); - OutString[1] = (char) ('@' + ((EisaId >> 21) & 0x1f)); - OutString[2] = (char) ('@' + ((EisaId >> 16) & 0x1f)); - OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 12); - OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 8); - OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 4); - OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 0); + /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */ + + OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F)); + OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F)); + OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F)); + OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 12); + OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 8); + OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 4); + OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 0); OutString[7] = 0; } /******************************************************************************* * - * FUNCTION: AcpiExUnsignedIntegerToString + * FUNCTION: AcpiExIntegerToString * - * PARAMETERS: Value - Value to be converted - * OutString - Where to put the converted string (8 bytes) + * PARAMETERS: OutString - Where to put the converted string. At least + * 21 bytes are needed to hold the largest + * possible 64-bit integer. + * Value - Value to be converted * * RETURN: None, string * - * DESCRIPTION: Convert a number to string representation. Assumes string - * buffer is large enough to hold the string. + * DESCRIPTION: Convert a 64-bit integer to decimal string representation. + * Assumes string buffer is large enough to hold the string. The + * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1). * ******************************************************************************/ void -AcpiExUnsignedIntegerToString ( - ACPI_INTEGER Value, - char *OutString) +AcpiExIntegerToString ( + char *OutString, + ACPI_INTEGER Value) { UINT32 Count; UINT32 DigitsNeeded; diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwacpi.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwacpi.c index 9bb15ea2e2..6b6d90ee02 100644 --- a/src/add-ons/kernel/bus_managers/acpi/hardware/hwacpi.c +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwacpi.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface - * $Revision: 1.79 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __HWACPI_C__ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_HARDWARE @@ -167,7 +167,8 @@ AcpiHwSetMode ( if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable) { ACPI_ERROR ((AE_INFO, - "No ACPI mode transition supported in this system (enable/disable both zero)")); + "No ACPI mode transition supported in this system " + "(enable/disable both zero)")); return_ACPI_STATUS (AE_OK); } @@ -177,7 +178,7 @@ AcpiHwSetMode ( /* BIOS should have disabled ALL fixed and GP events */ - Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, (UINT32) AcpiGbl_FADT.AcpiEnable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); break; @@ -188,7 +189,7 @@ AcpiHwSetMode ( * BIOS should clear all fixed status bits and restore fixed event * enable bits to default */ - Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, (UINT32) AcpiGbl_FADT.AcpiDisable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable Legacy (non-ACPI) mode\n")); @@ -260,7 +261,7 @@ AcpiHwGetMode ( return_UINT32 (ACPI_SYS_MODE_ACPI); } - Status = AcpiGetRegister (ACPI_BITREG_SCI_ENABLE, &Value); + Status = AcpiReadBitRegister (ACPI_BITREG_SCI_ENABLE, &Value); if (ACPI_FAILURE (Status)) { return_UINT32 (ACPI_SYS_MODE_LEGACY); diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwgpe.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwgpe.c index 473c1d62da..a45603d9d5 100644 --- a/src/add-ons/kernel/bus_managers/acpi/hardware/hwgpe.c +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwgpe.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: hwgpe - Low level GPE enable/disable/clear functions - * $Revision: 1.76 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #define _COMPONENT ACPI_HARDWARE @@ -126,8 +126,8 @@ static ACPI_STATUS AcpiHwEnableWakeupGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); - + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); /****************************************************************************** @@ -161,8 +161,7 @@ AcpiHwLowDisableGpe ( /* Get current value of the enable register that contains this GPE */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &EnableMask, - &GpeRegisterInfo->EnableAddress); + Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); @@ -170,15 +169,13 @@ AcpiHwLowDisableGpe ( /* Clear just the bit that corresponds to this GPE */ - ACPI_CLEAR_BIT (EnableMask, - ((UINT32) 1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber))); + ACPI_CLEAR_BIT (EnableMask, ((UINT32) 1 << + (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber))); /* Write the updated enable mask */ - Status = AcpiHwLowLevelWrite (ACPI_GPE_REGISTER_WIDTH, EnableMask, - &GpeRegisterInfo->EnableAddress); - + Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); return (Status); } @@ -218,7 +215,7 @@ AcpiHwWriteGpeEnableReg ( /* Write the entire GPE (runtime) enable register */ - Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->EnableForRun, + Status = AcpiHwWrite (GpeRegisterInfo->EnableForRun, &GpeRegisterInfo->EnableAddress); return (Status); @@ -248,14 +245,14 @@ AcpiHwClearGpe ( ACPI_FUNCTION_ENTRY (); - RegisterBit = (UINT8) - (1 << (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); /* * Write a one to the appropriate bit in the status register to * clear this GPE. */ - Status = AcpiHwLowLevelWrite (8, RegisterBit, + Status = AcpiHwWrite (RegisterBit, &GpeEventInfo->RegisterInfo->StatusAddress); return (Status); @@ -301,8 +298,8 @@ AcpiHwGetGpeStatus ( /* Get the register bitmask for this GPE */ - RegisterBit = (UINT8) - (1 << (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); /* GPE currently enabled? (enabled for runtime?) */ @@ -320,7 +317,7 @@ AcpiHwGetGpeStatus ( /* GPE currently active (status bit == 1)? */ - Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress); + Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -357,7 +354,8 @@ UnlockAndExit: ACPI_STATUS AcpiHwDisableGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock) + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { UINT32 i; ACPI_STATUS Status; @@ -369,8 +367,7 @@ AcpiHwDisableGpeBlock ( { /* Disable all GPEs in this register */ - Status = AcpiHwLowLevelWrite (8, 0x00, - &GpeBlock->RegisterInfo[i].EnableAddress); + Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); @@ -397,7 +394,8 @@ AcpiHwDisableGpeBlock ( ACPI_STATUS AcpiHwClearGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock) + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { UINT32 i; ACPI_STATUS Status; @@ -409,8 +407,7 @@ AcpiHwClearGpeBlock ( { /* Clear status on all GPEs in this register */ - Status = AcpiHwLowLevelWrite (8, 0xFF, - &GpeBlock->RegisterInfo[i].StatusAddress); + Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); if (ACPI_FAILURE (Status)) { return (Status); @@ -438,7 +435,8 @@ AcpiHwClearGpeBlock ( ACPI_STATUS AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock) + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { UINT32 i; ACPI_STATUS Status; @@ -457,7 +455,7 @@ AcpiHwEnableRuntimeGpeBlock ( /* Enable all "runtime" GPEs in this register */ - Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForRun, + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { @@ -486,7 +484,8 @@ AcpiHwEnableRuntimeGpeBlock ( static ACPI_STATUS AcpiHwEnableWakeupGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock) + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { UINT32 i; ACPI_STATUS Status; @@ -503,8 +502,7 @@ AcpiHwEnableWakeupGpeBlock ( /* Enable all "wake" GPEs in this register */ - Status = AcpiHwLowLevelWrite (8, - GpeBlock->RegisterInfo[i].EnableForWake, + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { @@ -538,8 +536,8 @@ AcpiHwDisableAllGpes ( ACPI_FUNCTION_TRACE (HwDisableAllGpes); - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); return_ACPI_STATUS (Status); } @@ -566,7 +564,7 @@ AcpiHwEnableAllRuntimeGpes ( ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes); - Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL); return_ACPI_STATUS (Status); } @@ -593,7 +591,7 @@ AcpiHwEnableAllWakeupGpes ( ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes); - Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL); return_ACPI_STATUS (Status); } diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwregs.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwregs.c index 10b8c0d734..163840d7f4 100644 --- a/src/add-ons/kernel/bus_managers/acpi/hardware/hwregs.c +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwregs.c @@ -3,7 +3,6 @@ * * Module Name: hwregs - Read/write access functions for the various ACPI * control and status registers. - * $Revision: 1.188 $ * ******************************************************************************/ @@ -11,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,23 +118,240 @@ #define __HWREGS_C__ #include "acpi.h" -#include "acnamesp.h" +#include "accommon.h" #include "acevents.h" #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwregs") +/* Local Prototypes */ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateRegister + * + * PARAMETERS: Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * Address - Pointer to where the gas->address + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS + * pointer, Address, SpaceId, BitWidth, and BitOffset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address) +{ + + /* Must have a valid pointer to a GAS structure */ + + if (!Reg) + { + return (AE_BAD_PARAMETER); + } + + /* + * Copy the target address. This handles possible alignment issues. + * Address must not be null. A null address also indicates an optional + * ACPI register that is not supported, so no error message. + */ + ACPI_MOVE_64_TO_64 (Address, &Reg->Address); + if (!(*Address)) + { + return (AE_BAD_ADDRESS); + } + + /* Validate the SpaceID */ + + if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported address space: 0x%X", Reg->SpaceId)); + return (AE_SUPPORT); + } + + /* Validate the BitWidth */ + + if ((Reg->BitWidth != 8) && + (Reg->BitWidth != 16) && + (Reg->BitWidth != 32) && + (Reg->BitWidth != MaxBitWidth)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported register bit width: 0x%X", Reg->BitWidth)); + return (AE_SUPPORT); + } + + /* Validate the BitOffset. Just a warning for now. */ + + if (Reg->BitOffset != 0) + { + ACPI_WARNING ((AE_INFO, + "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max + * version of AcpiRead, used internally since the overhead of + * 64-bit values is not needed. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, or 32. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwRead); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Initialize entire 32-bit return value to zero */ + + *Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max + * version of AcpiWrite, used internally since the overhead of + * 64-bit values is not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwWrite); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiHwClearAcpiStatus * * PARAMETERS: None * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Clears all fixed and general purpose status bits - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ @@ -150,12 +366,14 @@ AcpiHwClearAcpiStatus ( ACPI_FUNCTION_TRACE (HwClearAcpiStatus); - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n", ACPI_BITMASK_ALL_FIXED_STATUS, - (UINT16) AcpiGbl_FADT.XPm1aEventBlock.Address)); + ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address))); LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + /* Clear the fixed events in PM1 A/B */ + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, ACPI_BITMASK_ALL_FIXED_STATUS); if (ACPI_FAILURE (Status)) @@ -163,21 +381,9 @@ AcpiHwClearAcpiStatus ( goto UnlockAndExit; } - /* Clear the fixed events */ - - if (AcpiGbl_FADT.XPm1bEventBlock.Address) - { - Status = AcpiHwLowLevelWrite (16, ACPI_BITMASK_ALL_FIXED_STATUS, - &AcpiGbl_FADT.XPm1bEventBlock); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - } - /* Clear the GPE Bits in all GPE registers in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); UnlockAndExit: AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); @@ -185,136 +391,6 @@ UnlockAndExit: } -/******************************************************************************* - * - * FUNCTION: AcpiGetSleepTypeData - * - * PARAMETERS: SleepState - Numeric sleep state - * *SleepTypeA - Where SLP_TYPa is returned - * *SleepTypeB - Where SLP_TYPb is returned - * - * RETURN: Status - ACPI status - * - * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep - * state. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetSleepTypeData ( - UINT8 SleepState, - UINT8 *SleepTypeA, - UINT8 *SleepTypeB) -{ - ACPI_STATUS Status = AE_OK; - ACPI_EVALUATE_INFO *Info; - - - ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData); - - - /* Validate parameters */ - - if ((SleepState > ACPI_S_STATES_MAX) || - !SleepTypeA || !SleepTypeB) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Allocate the evaluation information block */ - - Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); - if (!Info) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); - - /* Evaluate the namespace object containing the values for this state */ - - Status = AcpiNsEvaluate (Info); - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%s while evaluating SleepState [%s]\n", - AcpiFormatException (Status), Info->Pathname)); - - goto Cleanup; - } - - /* Must have a return object */ - - if (!Info->ReturnObject) - { - ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", - Info->Pathname)); - Status = AE_NOT_EXIST; - } - - /* It must be of type Package */ - - else if (ACPI_GET_OBJECT_TYPE (Info->ReturnObject) != ACPI_TYPE_PACKAGE) - { - ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); - Status = AE_AML_OPERAND_TYPE; - } - - /* - * The package must have at least two elements. NOTE (March 2005): This - * goes against the current ACPI spec which defines this object as a - * package with one encoded DWORD element. However, existing practice - * by BIOS vendors seems to be to have 2 or more elements, at least - * one per sleep type (A/B). - */ - else if (Info->ReturnObject->Package.Count < 2) - { - ACPI_ERROR ((AE_INFO, - "Sleep State return package does not have at least two elements")); - Status = AE_AML_NO_OPERAND; - } - - /* The first two elements must both be of type Integer */ - - else if ((ACPI_GET_OBJECT_TYPE (Info->ReturnObject->Package.Elements[0]) - != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE (Info->ReturnObject->Package.Elements[1]) - != ACPI_TYPE_INTEGER)) - { - ACPI_ERROR ((AE_INFO, - "Sleep State return package elements are not both Integers (%s, %s)", - AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]), - AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1]))); - Status = AE_AML_OPERAND_TYPE; - } - else - { - /* Valid _Sx_ package size, type, and value */ - - *SleepTypeA = (UINT8) - (Info->ReturnObject->Package.Elements[0])->Integer.Value; - *SleepTypeB = (UINT8) - (Info->ReturnObject->Package.Elements[1])->Integer.Value; - } - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "While evaluating SleepState [%s], bad Sleep object %p type %s", - Info->Pathname, Info->ReturnObject, - AcpiUtGetObjectTypeName (Info->ReturnObject))); - } - - AcpiUtRemoveReference (Info->ReturnObject); - -Cleanup: - ACPI_FREE (Info); - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData) - - /******************************************************************************* * * FUNCTION: AcpiHwGetRegisterBitMask @@ -344,247 +420,47 @@ AcpiHwGetBitRegisterInfo ( } -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiGetRegisterUnlocked + * FUNCTION: AcpiHwWritePm1Control * - * PARAMETERS: RegisterId - ID of ACPI BitRegister to access - * ReturnValue - Value that was read from the register - * - * RETURN: Status and the value read from specified Register. Value - * returned is normalized to bit0 (is shifted all the way right) - * - * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetRegisterUnlocked ( - UINT32 RegisterId, - UINT32 *ReturnValue) -{ - UINT32 RegisterValue = 0; - ACPI_BIT_REGISTER_INFO *BitRegInfo; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiGetRegisterUnlocked); - - - /* Get the info structure corresponding to the requested ACPI Register */ - - BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); - if (!BitRegInfo) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Read from the register */ - - Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, - &RegisterValue); - - if (ACPI_SUCCESS (Status)) - { - /* Normalize the value that was read */ - - RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) - >> BitRegInfo->BitPosition); - - *ReturnValue = RegisterValue; - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n", - RegisterValue, BitRegInfo->ParentRegister)); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiGetRegister - * - * PARAMETERS: RegisterId - ID of ACPI BitRegister to access - * ReturnValue - Value that was read from the register - * - * RETURN: Status and the value read from specified Register. Value - * returned is normalized to bit0 (is shifted all the way right) - * - * DESCRIPTION: ACPI BitRegister read function. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetRegister ( - UINT32 RegisterId, - UINT32 *ReturnValue) -{ - ACPI_STATUS Status; - ACPI_CPU_FLAGS Flags; - - - Flags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); - Status = AcpiGetRegisterUnlocked (RegisterId, ReturnValue); - AcpiOsReleaseLock (AcpiGbl_HardwareLock, Flags); - - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetRegister) - - -/******************************************************************************* - * - * FUNCTION: AcpiSetRegister - * - * PARAMETERS: RegisterId - ID of ACPI BitRegister to access - * Value - (only used on write) value to write to the - * Register, NOT pre-normalized to the bit pos + * PARAMETERS: Pm1aControl - Value to be written to PM1A control + * Pm1bControl - Value to be written to PM1B control * * RETURN: Status * - * DESCRIPTION: ACPI Bit Register write function. + * DESCRIPTION: Write the PM1 A/B control registers. These registers are + * different than than the PM1 A/B status and enable registers + * in that different values can be written to the A/B registers. + * Most notably, the SLP_TYP bits can be different, as per the + * values returned from the _Sx predefined methods. * ******************************************************************************/ ACPI_STATUS -AcpiSetRegister ( - UINT32 RegisterId, - UINT32 Value) +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl) { - UINT32 RegisterValue = 0; - ACPI_BIT_REGISTER_INFO *BitRegInfo; ACPI_STATUS Status; - ACPI_CPU_FLAGS LockFlags; - ACPI_FUNCTION_TRACE_U32 (AcpiSetRegister, RegisterId); + ACPI_FUNCTION_TRACE (HwWritePm1Control); - /* Get the info structure corresponding to the requested ACPI Register */ - - BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); - if (!BitRegInfo) - { - ACPI_ERROR ((AE_INFO, "Bad ACPI HW RegisterId: %X", RegisterId)); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); - - /* Always do a register read first so we can insert the new bits */ - - Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, - &RegisterValue); + Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock); if (ACPI_FAILURE (Status)) { - goto UnlockAndExit; + return_ACPI_STATUS (Status); } - /* - * Decode the Register ID - * Register ID = [Register block ID] | [bit ID] - * - * Check bit ID to fine locate Register offset. - * Check Mask to determine Register offset, and then read-write. - */ - switch (BitRegInfo->ParentRegister) + if (AcpiGbl_FADT.XPm1bControlBlock.Address) { - case ACPI_REGISTER_PM1_STATUS: - - /* - * Status Registers are different from the rest. Clear by - * writing 1, and writing 0 has no effect. So, the only relevant - * information is the single bit we're interested in, all others should - * be written as 0 so they will be left unchanged. - */ - Value = ACPI_REGISTER_PREPARE_BITS (Value, - BitRegInfo->BitPosition, BitRegInfo->AccessBitMask); - if (Value) - { - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, - (UINT16) Value); - RegisterValue = 0; - } - break; - - - case ACPI_REGISTER_PM1_ENABLE: - - ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, - BitRegInfo->AccessBitMask, Value); - - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_ENABLE, - (UINT16) RegisterValue); - break; - - - case ACPI_REGISTER_PM1_CONTROL: - - /* - * Write the PM1 Control register. - * Note that at this level, the fact that there are actually TWO - * registers (A and B - and B may not exist) is abstracted. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", - RegisterValue)); - - ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, - BitRegInfo->AccessBitMask, Value); - - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, - (UINT16) RegisterValue); - break; - - - case ACPI_REGISTER_PM2_CONTROL: - - Status = AcpiHwRegisterRead (ACPI_REGISTER_PM2_CONTROL, - &RegisterValue); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", - RegisterValue, - ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XPm2ControlBlock.Address))); - - ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, - BitRegInfo->AccessBitMask, Value); - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", - RegisterValue, - ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XPm2ControlBlock.Address))); - - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM2_CONTROL, - (UINT8) (RegisterValue)); - break; - - - default: - break; + Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock); } - - -UnlockAndExit: - - AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); - - /* Normalize the value that was read */ - - ACPI_DEBUG_EXEC (RegisterValue = - ((RegisterValue & BitRegInfo->AccessBitMask) >> - BitRegInfo->BitPosition)); - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", - Value, RegisterValue, BitRegInfo->ParentRegister)); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiSetRegister) - /****************************************************************************** * @@ -604,8 +480,7 @@ AcpiHwRegisterRead ( UINT32 RegisterId, UINT32 *ReturnValue) { - UINT32 Value1 = 0; - UINT32 Value2 = 0; + UINT32 Value = 0; ACPI_STATUS Status; @@ -614,65 +489,55 @@ AcpiHwRegisterRead ( switch (RegisterId) { - case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ - Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT.XPm1aEventBlock); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* PM1B is optional */ - - Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT.XPm1bEventBlock); - Value1 |= Value2; + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); break; - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ - Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_XPm1aEnable); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* PM1B is optional */ - - Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_XPm1bEnable); - Value1 |= Value2; + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); break; - case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ - Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT.XPm1aControlBlock); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); - Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT.XPm1bControlBlock); - Value1 |= Value2; + /* + * Zero the write-only bits. From the ACPI specification, "Hardware + * Write-Only Bits": "Upon reads to registers with write-only bits, + * software masks out all write-only bits." + */ + Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS; break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT.XPm2ControlBlock); + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); break; + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ - Status = AcpiOsReadPort (AcpiGbl_FADT.SmiCommand, &Value1, 8); + Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8); break; + default: ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", RegisterId)); @@ -680,10 +545,9 @@ AcpiHwRegisterRead ( break; } -Exit: if (ACPI_SUCCESS (Status)) { - *ReturnValue = Value1; + *ReturnValue = Value; } return_ACPI_STATUS (Status); @@ -730,58 +594,42 @@ AcpiHwRegisterWrite ( switch (RegisterId) { - case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + /* + * Handle the "ignored" bit in PM1 Status. According to the ACPI + * specification, ignored bits are to be preserved when writing. + * Normally, this would mean a read/modify/write sequence. However, + * preserving a bit in the status register is different. Writing a + * one clears the status, and writing a zero preserves the status. + * Therefore, we must always write zero to the ignored bit. + * + * This behavior is clarified in the ACPI 4.0 specification. + */ + Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS; - /* Perform a read first to preserve certain bits (per ACPI spec) */ - - Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, - &ReadValue); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* Insert the bits to be preserved */ - - ACPI_INSERT_BITS (Value, ACPI_PM1_STATUS_PRESERVED_BITS, ReadValue); - - /* Now we can write the data */ - - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1aEventBlock); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* PM1B is optional */ - - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1bEventBlock); + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); break; - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1aEnable); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* PM1B is optional */ - - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1bEnable); + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); break; - case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ /* * Perform a read first to preserve certain bits (per ACPI spec) - * * Note: This includes SCI_EN, we never want to change this bit */ - Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, - &ReadValue); + Status = AcpiHwReadMultiple (&ReadValue, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); if (ACPI_FAILURE (Status)) { goto Exit; @@ -793,37 +641,35 @@ AcpiHwRegisterWrite ( /* Now we can write the data */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1aControlBlock); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1bControlBlock); - break; - - - case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ - - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1aControlBlock); - break; - - - case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ - - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1bControlBlock); + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT.XPm2ControlBlock); + /* + * For control registers, all reserved bits must be preserved, + * as per the ACPI spec. + */ + Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue); + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock); break; @@ -831,11 +677,13 @@ AcpiHwRegisterWrite ( /* SMI_CMD is currently always in IO space */ - Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, Value, 8); + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8); break; default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); Status = AE_BAD_PARAMETER; break; } @@ -847,159 +695,111 @@ Exit: /****************************************************************************** * - * FUNCTION: AcpiHwLowLevelRead + * FUNCTION: AcpiHwReadMultiple * - * PARAMETERS: Width - 8, 16, or 32 - * Value - Where the value is returned - * Reg - GAS register structure + * PARAMETERS: Value - Where the register value is returned + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) * * RETURN: Status * - * DESCRIPTION: Read from either memory or IO space. + * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B) * ******************************************************************************/ -ACPI_STATUS -AcpiHwLowLevelRead ( - UINT32 Width, +static ACPI_STATUS +AcpiHwReadMultiple ( UINT32 *Value, - ACPI_GENERIC_ADDRESS *Reg) + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) { - UINT64 Address; + UINT32 ValueA = 0; + UINT32 ValueB = 0; ACPI_STATUS Status; - ACPI_FUNCTION_NAME (HwLowLevelRead); + /* The first register is always required */ + Status = AcpiHwRead (&ValueA, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Second register is optional */ + + if (RegisterB->Address) + { + Status = AcpiHwRead (&ValueB, RegisterB); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } /* - * Must have a valid pointer to a GAS structure, and - * a non-zero address within. However, don't return an error - * because the PM1A/B code must not fail if B isn't present. + * OR the two return values together. No shifting or masking is necessary, + * because of how the PM1 registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" */ - if (!Reg) - { - return (AE_OK); - } - - /* Get a local copy of the address. Handles possible alignment issues */ - - ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); - if (!Address) - { - return (AE_OK); - } - *Value = 0; - - /* - * Two address spaces supported: Memory or IO. - * PCI_Config is not supported here because the GAS struct is insufficient - */ - switch (Reg->SpaceId) - { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - - Status = AcpiOsReadMemory ( - (ACPI_PHYSICAL_ADDRESS) Address, Value, Width); - break; - - - case ACPI_ADR_SPACE_SYSTEM_IO: - - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, Value, Width); - break; - - - default: - ACPI_ERROR ((AE_INFO, - "Unsupported address space: %X", Reg->SpaceId)); - return (AE_BAD_PARAMETER); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Width, ACPI_FORMAT_UINT64 (Address), - AcpiUtGetRegionName (Reg->SpaceId))); - - return (Status); + *Value = (ValueA | ValueB); + return (AE_OK); } /****************************************************************************** * - * FUNCTION: AcpiHwLowLevelWrite + * FUNCTION: AcpiHwWriteMultiple * - * PARAMETERS: Width - 8, 16, or 32 - * Value - To be written - * Reg - GAS register structure + * PARAMETERS: Value - The value to write + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) * * RETURN: Status * - * DESCRIPTION: Write to either memory or IO space. + * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B) * ******************************************************************************/ -ACPI_STATUS -AcpiHwLowLevelWrite ( - UINT32 Width, +static ACPI_STATUS +AcpiHwWriteMultiple ( UINT32 Value, - ACPI_GENERIC_ADDRESS *Reg) + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) { - UINT64 Address; ACPI_STATUS Status; - ACPI_FUNCTION_NAME (HwLowLevelWrite); + /* The first register is always required */ - - /* - * Must have a valid pointer to a GAS structure, and - * a non-zero address within. However, don't return an error - * because the PM1A/B code must not fail if B isn't present. - */ - if (!Reg) + Status = AcpiHwWrite (Value, RegisterA); + if (ACPI_FAILURE (Status)) { - return (AE_OK); - } - - /* Get a local copy of the address. Handles possible alignment issues */ - - ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); - if (!Address) - { - return (AE_OK); + return (Status); } /* - * Two address spaces supported: Memory or IO. - * PCI_Config is not supported here because the GAS struct is insufficient + * Second register is optional + * + * No bit shifting or clearing is necessary, because of how the PM1 + * registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" */ - switch (Reg->SpaceId) + if (RegisterB->Address) { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - - Status = AcpiOsWriteMemory ( - (ACPI_PHYSICAL_ADDRESS) Address, Value, Width); - break; - - - case ACPI_ADR_SPACE_SYSTEM_IO: - - Status = AcpiOsWritePort ( - (ACPI_IO_ADDRESS) Address, Value, Width); - break; - - - default: - ACPI_ERROR ((AE_INFO, - "Unsupported address space: %X", Reg->SpaceId)); - return (AE_BAD_PARAMETER); + Status = AcpiHwWrite (Value, RegisterB); } - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Width, ACPI_FORMAT_UINT64 (Address), - AcpiUtGetRegionName (Reg->SpaceId))); - return (Status); } + diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwsleep.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwsleep.c index 34f13c9e4f..fed4f1ddbf 100644 --- a/src/add-ons/kernel/bus_managers/acpi/hardware/hwsleep.c +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwsleep.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * $Revision: 1.89 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwsleep") @@ -125,50 +125,31 @@ * * FUNCTION: AcpiSetFirmwareWakingVector * - * PARAMETERS: PhysicalAddress - Physical address of ACPI real mode + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode * entry point. * * RETURN: Status * - * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS + * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS * ******************************************************************************/ ACPI_STATUS AcpiSetFirmwareWakingVector ( - ACPI_PHYSICAL_ADDRESS PhysicalAddress) + UINT32 PhysicalAddress) { - ACPI_TABLE_FACS *Facs; - ACPI_STATUS Status; - - ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); - /* Get the FACS */ - Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, - ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Set the 32-bit vector */ - /* Set the vector */ + AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; - if ((Facs->Length < 32) || - (!(Facs->XFirmwareWakingVector))) + /* Clear the 64-bit vector if it exists */ + + if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) { - /* - * ACPI 1.0 FACS or short table or optional X_ field is zero - */ - Facs->FirmwareWakingVector = (UINT32) PhysicalAddress; - } - else - { - /* - * ACPI 2.0 FACS with valid X_ field - */ - Facs->XFirmwareWakingVector = PhysicalAddress; + AcpiGbl_FACS->XFirmwareWakingVector = 0; } return_ACPI_STATUS (AE_OK); @@ -177,69 +158,45 @@ AcpiSetFirmwareWakingVector ( ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) +#if ACPI_MACHINE_WIDTH == 64 /******************************************************************************* * - * FUNCTION: AcpiGetFirmwareWakingVector + * FUNCTION: AcpiSetFirmwareWakingVector64 * - * PARAMETERS: *PhysicalAddress - Where the contents of - * the FirmwareWakingVector field of - * the FACS will be returned. + * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected + * mode entry point. * - * RETURN: Status, vector + * RETURN: Status * - * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS + * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if + * it exists in the table. This function is intended for use with + * 64-bit host operating systems. * ******************************************************************************/ ACPI_STATUS -AcpiGetFirmwareWakingVector ( - ACPI_PHYSICAL_ADDRESS *PhysicalAddress) +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress) { - ACPI_TABLE_FACS *Facs; - ACPI_STATUS Status; + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); - ACPI_FUNCTION_TRACE (AcpiGetFirmwareWakingVector); + /* Determine if the 64-bit vector actually exists */ - - if (!PhysicalAddress) + if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_NOT_EXIST); } - /* Get the FACS */ - - Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, - ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the vector */ - - if ((Facs->Length < 32) || - (!(Facs->XFirmwareWakingVector))) - { - /* - * ACPI 1.0 FACS or short table or optional X_ field is zero - */ - *PhysicalAddress = - (ACPI_PHYSICAL_ADDRESS) Facs->FirmwareWakingVector; - } - else - { - /* - * ACPI 2.0 FACS with valid X_ field - */ - *PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) Facs->XFirmwareWakingVector; - } + /* Clear 32-bit vector, set the 64-bit X_ vector */ + AcpiGbl_FACS->FirmwareWakingVector = 0; + AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; return_ACPI_STATUS (AE_OK); } -ACPI_EXPORT_SYMBOL (AcpiGetFirmwareWakingVector) - +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) +#endif /******************************************************************************* * @@ -268,9 +225,8 @@ AcpiEnterSleepStatePrep ( ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); - /* - * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. - */ + /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ + Status = AcpiGetSleepTypeData (SleepState, &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); if (ACPI_FAILURE (Status)) @@ -347,8 +303,8 @@ ACPI_STATUS AcpiEnterSleepState ( UINT8 SleepState) { - UINT32 PM1AControl; - UINT32 PM1BControl; + UINT32 Pm1aControl; + UINT32 Pm1bControl; ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; UINT32 InValue; @@ -368,12 +324,12 @@ AcpiEnterSleepState ( return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } - SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A); + SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); /* Clear wake status */ - Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1); + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -389,10 +345,13 @@ AcpiEnterSleepState ( if (SleepState != ACPI_STATE_S5) { - /* Disable BM arbitration */ - - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1); - if (ACPI_FAILURE (Status)) + /* + * Disable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) { return_ACPI_STATUS (Status); } @@ -430,8 +389,8 @@ AcpiEnterSleepState ( /* Get current value of PM1A control */ - Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, - &PM1AControl); + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -439,56 +398,42 @@ AcpiEnterSleepState ( ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", SleepState)); - /* Clear SLP_EN and SLP_TYP fields */ + /* Clear the SLP_EN and SLP_TYP fields */ - PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask); - PM1BControl = PM1AControl; + Pm1bControl = Pm1aControl; - /* Insert SLP_TYP bits */ + /* Insert the SLP_TYP bits */ - PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); - PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); + Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); /* * We split the writes of SLP_TYP and SLP_EN to workaround * poorly implemented hardware. */ - /* Write #1: fill in SLP_TYP data */ + /* Write #1: write the SLP_TYP data to the PM1 Control registers */ - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1A_CONTROL, - PM1AControl); + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1B_CONTROL, - PM1BControl); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Insert the sleep enable (SLP_EN) bit */ - /* Insert SLP_ENABLE bit */ + Pm1aControl |= SleepEnableRegInfo->AccessBitMask; + Pm1bControl |= SleepEnableRegInfo->AccessBitMask; - PM1AControl |= SleepEnableRegInfo->AccessBitMask; - PM1BControl |= SleepEnableRegInfo->AccessBitMask; - - /* Write #2: SLP_TYP + SLP_EN */ + /* Flush caches, as per ACPI specification */ ACPI_FLUSH_CPU_CACHE (); - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1A_CONTROL, - PM1AControl); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Write #2: Write both SLP_TYP + SLP_EN */ - Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1B_CONTROL, - PM1BControl); + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -503,8 +448,8 @@ AcpiEnterSleepState ( * Wait ten seconds, then try again. This is to get S4/S5 to work on * all machines. * - * We wait so long to allow chipsets that poll this reg very slowly to - * still read the right value. Ideally, this block would go + * We wait so long to allow chipsets that poll this reg very slowly + * to still read the right value. Ideally, this block would go * away entirely. */ AcpiOsStall (10000000); @@ -521,7 +466,7 @@ AcpiEnterSleepState ( do { - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -561,7 +506,9 @@ AcpiEnterSleepStateS4bios ( ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); - Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1); + /* Clear the wake status bit (PM1) */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -592,12 +539,12 @@ AcpiEnterSleepStateS4bios ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); do { AcpiOsStall(1000); - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -632,8 +579,8 @@ AcpiLeaveSleepState ( ACPI_STATUS Status; ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; - UINT32 PM1AControl; - UINT32 PM1BControl; + UINT32 Pm1aControl; + UINT32 Pm1bControl; ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); @@ -648,32 +595,33 @@ AcpiLeaveSleepState ( &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); if (ACPI_SUCCESS (Status)) { - SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A); - SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + SleepTypeRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); /* Get current value of PM1A control */ - Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, - &PM1AControl); + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); if (ACPI_SUCCESS (Status)) { - /* Clear SLP_EN and SLP_TYP fields */ + /* Clear the SLP_EN and SLP_TYP fields */ - PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | - SleepEnableRegInfo->AccessBitMask); - PM1BControl = PM1AControl; + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; - /* Insert SLP_TYP bits */ + /* Insert the SLP_TYP bits */ - PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); - PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); + Pm1aControl |= (AcpiGbl_SleepTypeA << + SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << + SleepTypeRegInfo->BitPosition); - /* Just ignore any errors */ + /* Write the control registers and ignore any errors */ - (void) AcpiHwRegisterWrite (ACPI_REGISTER_PM1A_CONTROL, - PM1AControl); - (void) AcpiHwRegisterWrite (ACPI_REGISTER_PM1B_CONTROL, - PM1BControl); + (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); } } @@ -730,16 +678,21 @@ AcpiLeaveSleepState ( /* Enable power button */ - (void) AcpiSetRegister( - AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, 1); + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + ACPI_ENABLE_EVENT); - (void) AcpiSetRegister( - AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, 1); + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + ACPI_CLEAR_STATUS); - /* Enable BM arbitration */ - - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0); - if (ACPI_FAILURE (Status)) + /* + * Enable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) { return_ACPI_STATUS (Status); } diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwtimer.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwtimer.c index 41b1e9bcfc..f86fb7f865 100644 --- a/src/add-ons/kernel/bus_managers/acpi/hardware/hwtimer.c +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwtimer.c @@ -2,7 +2,6 @@ /****************************************************************************** * * Name: hwtimer.c - ACPI Power Management Timer Interface - * $Revision: 1.38 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ *****************************************************************************/ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwtimer") @@ -187,7 +187,7 @@ AcpiGetTimer ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - Status = AcpiHwLowLevelRead (32, Ticks, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); return_ACPI_STATUS (Status); } diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwvalid.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwvalid.c new file mode 100644 index 0000000000..650b695b2c --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwvalid.c @@ -0,0 +1,424 @@ + +/****************************************************************************** + * + * Module Name: hwvalid - I/O request validation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWVALID_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwvalid") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth); + + +/* + * Protected I/O ports. Some ports are always illegal, and some are + * conditionally illegal. This table must remain ordered by port address. + * + * The table is used to implement the Microsoft port access rules that + * first appeared in Windows XP. Some ports are always illegal, and some + * ports are only illegal if the BIOS calls _OSI with a WinXP string or + * later (meaning that the BIOS itelf is post-XP.) + * + * This provides ACPICA with the desired port protections and + * Microsoft compatibility. + * + * Description of port entries: + * DMA: DMA controller + * PIC0: Programmable Interrupt Controller (8259A) + * PIT1: System Timer 1 + * PIT2: System Timer 2 failsafe + * RTC: Real-time clock + * CMOS: Extended CMOS + * DMA1: DMA 1 page registers + * DMA1L: DMA 1 Ch 0 low page + * DMA2: DMA 2 page registers + * DMA2L: DMA 2 low page refresh + * ARBC: Arbitration control + * SETUP: Reserved system board setup + * POS: POS channel select + * PIC1: Cascaded PIC + * IDMA: ISA DMA + * ELCR: PIC edge/level registers + * PCI: PCI configuration space + */ +static const ACPI_PORT_INFO AcpiProtectedPorts[] = +{ + {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, + {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL}, + {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP}, + {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, + {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, + {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, + {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, + {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, + {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, + {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, + {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, + {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, + {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP}, + {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, + {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, + {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, + {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP} +}; + +#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts) + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateIoRequest + * + * PARAMETERS: Address Address of I/O port/register + * BitWidth Number of bits (8,16,32) + * + * RETURN: Status + * + * DESCRIPTION: Validates an I/O request (address/length). Certain ports are + * always illegal and some ports are only illegal depending on + * the requests the BIOS AML code makes to the predefined + * _OSI method. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth) +{ + UINT32 i; + UINT32 ByteWidth; + ACPI_IO_ADDRESS LastAddress; + const ACPI_PORT_INFO *PortInfo; + + + ACPI_FUNCTION_TRACE (HwValidateIoRequest); + + + /* Supported widths are 8/16/32 */ + + if ((BitWidth != 8) && + (BitWidth != 16) && + (BitWidth != 32)) + { + return (AE_BAD_PARAMETER); + } + + PortInfo = AcpiProtectedPorts; + ByteWidth = ACPI_DIV_8 (BitWidth); + LastAddress = Address + ByteWidth - 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X", + ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress), + ByteWidth)); + + /* Maximum 16-bit address in I/O space */ + + if (LastAddress > ACPI_UINT16_MAX) + { + ACPI_ERROR ((AE_INFO, + "Illegal I/O port address/length above 64K: 0x%p/%X", + ACPI_CAST_PTR (void, Address), ByteWidth)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* Exit if requested address is not within the protected port table */ + + if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End) + { + return_ACPI_STATUS (AE_OK); + } + + /* Check request against the list of protected I/O ports */ + + for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++) + { + /* + * Check if the requested address range will write to a reserved + * port. Four cases to consider: + * + * 1) Address range is contained completely in the port address range + * 2) Address range overlaps port range at the port range start + * 3) Address range overlaps port range at the port range end + * 4) Address range completely encompasses the port range + */ + if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start)) + { + /* Port illegality may depend on the _OSI calls made by the BIOS */ + + if (AcpiGbl_OsiData >= PortInfo->OsiDependency) + { + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", + ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name, + PortInfo->Start, PortInfo->End)); + + return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS); + } + } + + /* Finished if address range ends before the end of this port */ + + if (LastAddress <= PortInfo->End) + { + break; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadPort + * + * PARAMETERS: Address Address of I/O port/register to read + * Value Where value is placed + * Width Number of bits + * + * RETURN: Status and value read from port + * + * DESCRIPTION: Read data from an I/O port or register. This is a front-end + * to AcpiOsReadPort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 OneByte; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsReadPort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0, *Value = 0; i < Width; i += 8) + { + /* Validate and read one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsReadPort (Address, &OneByte, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Value |= (OneByte << i); + } + + Address++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePort + * + * PARAMETERS: Address Address of I/O port/register to write + * Value Value to write + * Width Number of bits + * + * RETURN: Status + * + * DESCRIPTION: Write data to an I/O port or register. This is a front-end + * to AcpiOsWritePort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsWritePort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0; i < Width; i += 8) + { + /* Validate and write one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + Address++; + } + + return (AE_OK); +} + + diff --git a/src/add-ons/kernel/bus_managers/acpi/hardware/hwxface.c b/src/add-ons/kernel/bus_managers/acpi/hardware/hwxface.c new file mode 100644 index 0000000000..6c345a593e --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/hardware/hwxface.c @@ -0,0 +1,710 @@ + +/****************************************************************************** + * + * Module Name: hwxface - Public ACPICA hardware interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwxface") + + +/****************************************************************************** + * + * FUNCTION: AcpiReset + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Set reset register in memory or IO space. Note: Does not + * support reset register in PCI config space, this must be + * handled separately. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReset ( + void) +{ + ACPI_GENERIC_ADDRESS *ResetReg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiReset); + + + ResetReg = &AcpiGbl_FADT.ResetRegister; + + /* Check if the reset register is supported */ + + if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) || + !ResetReg->Address) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + /* + * For I/O space, write directly to the OSL. This bypasses the port + * validation mechanism, which may block a valid write to the reset + * register. + */ + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address, + AcpiGbl_FADT.ResetValue, ResetReg->BitWidth); + } + else + { + /* Write the reset value to the reset register */ + + Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReset) + + +/****************************************************************************** + * + * FUNCTION: AcpiRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, 32, or 64. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRead ( + UINT64 *ReturnValue, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Value; + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiRead); + + + if (!ReturnValue) + { + return (AE_BAD_PARAMETER); + } + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* Initialize entire 64-bit return value to zero */ + + *ReturnValue = 0; + Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRead) + + +/****************************************************************************** + * + * FUNCTION: AcpiWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiWrite); + + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (Value), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWrite) + + +/******************************************************************************* + * + * FUNCTION: AcpiReadBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * ReturnValue - Value that was read from the register, + * normalized to bit position zero. + * + * RETURN: Status and the value read from the specified Register. Value + * returned is normalized to bit0 (is shifted all the way right) + * + * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note: The hardware lock is not required when reading the ACPI bit registers + * since almost all of them are single bit and it does not matter that + * the parent hardware register can be split across two physical + * registers. The only multi-bit field is SLP_TYP in the PM1 control + * register, but this field does not cross an 8-bit boundary (nor does + * it make much sense to actually read this field.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + UINT32 RegisterValue; + UINT32 Value; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Read the entire parent register */ + + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Normalize the value that was read, mask off other bits */ + + Value = ((RegisterValue & BitRegInfo->AccessBitMask) + >> BitRegInfo->BitPosition); + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value)); + + *ReturnValue = Value; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReadBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiWriteBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * Value - Value to write to the register, in bit + * position zero. The bit is automaticallly + * shifted to the correct position. + * + * RETURN: Status + * + * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock + * since most operations require a read/modify/write sequence. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note that at this level, the fact that there may be actually two + * hardware registers (A and B - and B may not exist) is abstracted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + ACPI_CPU_FLAGS LockFlags; + UINT32 RegisterValue; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* + * At this point, we know that the parent register is one of the + * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control + */ + if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS) + { + /* + * 1) Case for PM1 Enable, PM1 Control, and PM2 Control + * + * Perform a register read to preserve the bits that we are not + * interested in + */ + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* + * Insert the input bit into the value that was just read + * and write the register + */ + ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, + BitRegInfo->AccessBitMask, Value); + + Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister, + RegisterValue); + } + else + { + /* + * 2) Case for PM1 Status + * + * The Status register is different from the rest. Clear an event + * by writing 1, writing 0 has no effect. So, the only relevant + * information is the single bit we're interested in, all others + * should be written as 0 so they will be left unchanged. + */ + RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value, + BitRegInfo->BitPosition, BitRegInfo->AccessBitMask); + + /* No need to write the register if value is all zeros */ + + if (RegisterValue) + { + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + RegisterValue); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue)); + + +UnlockAndExit: + + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSleepTypeData + * + * PARAMETERS: SleepState - Numeric sleep state + * *SleepTypeA - Where SLP_TYPa is returned + * *SleepTypeB - Where SLP_TYPb is returned + * + * RETURN: Status - ACPI status + * + * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep + * state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *SleepTypeA, + UINT8 *SleepTypeB) +{ + ACPI_STATUS Status = AE_OK; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData); + + + /* Validate parameters */ + + if ((SleepState > ACPI_S_STATES_MAX) || + !SleepTypeA || + !SleepTypeB) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); + + /* Evaluate the namespace object containing the values for this state */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s while evaluating SleepState [%s]\n", + AcpiFormatException (Status), Info->Pathname)); + + goto Cleanup; + } + + /* Must have a return object */ + + if (!Info->ReturnObject) + { + ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", + Info->Pathname)); + Status = AE_NOT_EXIST; + } + + /* It must be of type Package */ + + else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); + Status = AE_AML_OPERAND_TYPE; + } + + /* + * The package must have at least two elements. NOTE (March 2005): This + * goes against the current ACPI spec which defines this object as a + * package with one encoded DWORD element. However, existing practice + * by BIOS vendors seems to be to have 2 or more elements, at least + * one per sleep type (A/B). + */ + else if (Info->ReturnObject->Package.Count < 2) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package does not have at least two elements")); + Status = AE_AML_NO_OPERAND; + } + + /* The first two elements must both be of type Integer */ + + else if (((Info->ReturnObject->Package.Elements[0])->Common.Type + != ACPI_TYPE_INTEGER) || + ((Info->ReturnObject->Package.Elements[1])->Common.Type + != ACPI_TYPE_INTEGER)) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package elements are not both Integers " + "(%s, %s)", + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1]))); + Status = AE_AML_OPERAND_TYPE; + } + else + { + /* Valid _Sx_ package size, type, and value */ + + *SleepTypeA = (UINT8) + (Info->ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) + (Info->ReturnObject->Package.Elements[1])->Integer.Value; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While evaluating SleepState [%s], bad Sleep object %p type %s", + Info->Pathname, Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + + AcpiUtRemoveReference (Info->ReturnObject); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData) diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acapps.h b/src/add-ons/kernel/bus_managers/acpi/include/acapps.h index 87dcc2a43a..e1f31b791b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acapps.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acapps.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -169,7 +169,9 @@ AdGetLocalTables ( ACPI_STATUS AdParseTable ( ACPI_TABLE_HEADER *Table, - BOOLEAN LoadTable); + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External); ACPI_STATUS AdDisplayTables ( @@ -185,7 +187,8 @@ AdDisplayStatistics (void); void AcpiDmCrossReferenceNamespace ( ACPI_PARSE_OBJECT *ParseTreeRoot, - ACPI_NAMESPACE_NODE *NamespaceRoot); + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); void AcpiDmDumpTree ( @@ -198,7 +201,8 @@ AcpiDmFindOrphanMethods ( void AcpiDmFinishNamespaceLoad ( ACPI_PARSE_OBJECT *ParseTreeRoot, - ACPI_NAMESPACE_NODE *NamespaceRoot); + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); void AcpiDmConvertResourceIndexes ( diff --git a/src/add-ons/kernel/bus_managers/acpi/include/accommon.h b/src/add-ons/kernel/bus_managers/acpi/include/accommon.h new file mode 100644 index 0000000000..690d3cdba9 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/include/accommon.h @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Name: accommon.h - Common include files for generation of ACPICA source + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACCOMMON_H__ +#define __ACCOMMON_H__ + +/* + * Common set of includes for all ACPICA source files. + * We put them here because we don't want to duplicate them + * in the the source code again and again. + * + * Note: The order of these include files is important. + */ +#include "acconfig.h" /* Global configuration constants */ +#include "acmacros.h" /* C macros */ +#include "aclocal.h" /* Internal data types */ +#include "acobject.h" /* ACPI internal object */ +#include "acstruct.h" /* Common structures */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "acutils.h" /* Utility interfaces */ + + +#endif /* __ACCOMMON_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acconfig.h b/src/add-ons/kernel/bus_managers/acpi/include/acconfig.h index 0ba5782feb..1fcc45a364 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acconfig.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acconfig.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * $Revision: 1.243 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -135,10 +134,6 @@ * */ -/* Current ACPICA subsystem version in YYYYMMDD format */ - -#define ACPI_CA_VERSION 0x20080701 - /* * OS name, used for the _OS object. The _OS object is essentially obsolete, * but there is a large base of ASL/AML code in existing machines that check @@ -194,6 +189,10 @@ #define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 +/* Maximum number of While() loop iterations before forced abort */ + +#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF + /****************************************************************************** * @@ -201,11 +200,6 @@ * *****************************************************************************/ -/* Number of distinct GPE register blocks and register width */ - -#define ACPI_MAX_GPE_BLOCKS 2 -#define ACPI_GPE_REGISTER_WIDTH 8 - /* Method info (in WALK_STATE), containing local variables and argumetns */ #define ACPI_METHOD_NUM_LOCALS 8 @@ -214,12 +208,6 @@ #define ACPI_METHOD_NUM_ARGS 7 #define ACPI_METHOD_MAX_ARG 6 -/* Length of _HID, _UID, _CID, and UUID values */ - -#define ACPI_DEVICE_ID_LENGTH 0x09 -#define ACPI_MAX_CID_LENGTH 48 -#define ACPI_UUID_LENGTH 16 - /* * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG */ @@ -237,17 +225,6 @@ */ #define ACPI_RESULTS_OBJ_NUM_MAX 255 -/* Names within the namespace are 4 bytes long */ - -#define ACPI_NAME_SIZE 4 -#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ -#define ACPI_PATH_SEPARATOR '.' - -/* Sizes for ACPI table headers */ - -#define ACPI_OEM_ID_SIZE 6 -#define ACPI_OEM_TABLE_ID_SIZE 8 - /* Constants used in searching for the RSDP in low memory */ #define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ @@ -259,7 +236,7 @@ /* Operation regions */ -#define ACPI_NUM_PREDEFINED_REGIONS 8 +#define ACPI_NUM_PREDEFINED_REGIONS 9 #define ACPI_USER_REGION_BEGIN 0x80 /* Maximum SpaceIds for Operation Regions */ @@ -275,9 +252,15 @@ #define ACPI_RSDP_CHECKSUM_LENGTH 20 #define ACPI_RSDP_XCHECKSUM_LENGTH 36 -/* SMBus bidirectional buffer size */ +/* SMBus and IPMI bidirectional buffer size */ #define ACPI_SMBUS_BUFFER_SIZE 34 +#define ACPI_IPMI_BUFFER_SIZE 66 + +/* _SxD and _SxW control methods */ + +#define ACPI_NUM_SxD_METHODS 4 +#define ACPI_NUM_SxW_METHODS 5 /****************************************************************************** diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acdebug.h b/src/add-ons/kernel/bus_managers/acpi/include/acdebug.h index da91fddbc2..dedaa649ea 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acdebug.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acdebug.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * $Revision: 1.85 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -260,6 +259,13 @@ AcpiDbGenerateGpe ( char *GpeArg, char *BlockArg); +void +AcpiDbCheckPredefinedNames ( + void); + +void +AcpiDbBatchExecute ( + void); /* * dbdisply - debug display commands diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acdisasm.h b/src/add-ons/kernel/bus_managers/acpi/include/acdisasm.h index 07dc1d4851..50c5f677c7 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acdisasm.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acdisasm.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acdisasm.h - AML disassembler - * $Revision: 1.45 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -183,6 +182,10 @@ typedef const struct acpi_dmtable_info #define ACPI_DMT_SRAT 29 #define ACPI_DMT_EXIT 30 #define ACPI_DMT_SIG 31 +#define ACPI_DMT_FADTPM 32 +#define ACPI_DMT_BUF16 33 +#define ACPI_DMT_IVRS 34 + typedef void (*ACPI_DMTABLE_HANDLER) ( @@ -250,6 +253,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[]; @@ -257,12 +261,28 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8b[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrsHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt1[]; @@ -273,9 +293,13 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt5[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt7[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[]; @@ -284,9 +308,15 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[]; @@ -350,6 +380,10 @@ void AcpiDmDumpHest ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpMcfg ( ACPI_TABLE_HEADER *Table); @@ -358,6 +392,10 @@ void AcpiDmDumpMadt ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table); + UINT32 AcpiDmDumpRsdp ( ACPI_TABLE_HEADER *Table); @@ -374,6 +412,10 @@ void AcpiDmDumpSrat ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpXsdt ( ACPI_TABLE_HEADER *Table); diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acdispat.h b/src/add-ons/kernel/bus_managers/acpi/include/acdispat.h index 7d2c3d187e..2aa86232b2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acdispat.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acdispat.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acdispat.h - dispatcher (parser to interpreter interface) - * $Revision: 1.79 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -273,7 +272,7 @@ AcpiDsInitCallbacks ( */ ACPI_STATUS AcpiDsStoreObjectToLocal ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *SrcDesc, ACPI_WALK_STATE *WalkState); @@ -295,7 +294,7 @@ AcpiDsIsMethodValue ( ACPI_STATUS AcpiDsMethodDataGetValue ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc); @@ -308,7 +307,7 @@ AcpiDsMethodDataInitArgs ( ACPI_STATUS AcpiDsMethodDataGetNode ( - UINT16 Opcode, + UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node); diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acevents.h b/src/add-ons/kernel/bus_managers/acpi/include/acevents.h index 5884d378fe..0cd5e2e286 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acevents.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acevents.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acevents.h - Event subcomponent prototypes and defines - * $Revision: 1.110 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -199,12 +198,14 @@ AcpiEvValidGpeEvent ( ACPI_STATUS AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback); + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context); ACPI_STATUS AcpiEvDeleteGpeHandlers ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); ACPI_STATUS AcpiEvCreateGpeBlock ( @@ -262,7 +263,7 @@ ACPI_STATUS AcpiEvAddressSpaceDispatch ( ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, + UINT32 RegionOffset, UINT32 BitWidth, ACPI_INTEGER *Value); diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acexcep.h b/src/add-ons/kernel/bus_managers/acpi/include/acexcep.h index 58b0e81bef..dfe2e2ee73 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acexcep.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acexcep.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acexcep.h - Exception codes returned by the ACPI subsystem - * $Revision: 1.80 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -152,25 +151,21 @@ #define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) #define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) #define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) -#define AE_VERSION_MISMATCH (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) -#define AE_SUPPORT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) -#define AE_SHARE (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) -#define AE_LIMIT (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) -#define AE_TIME (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) -#define AE_UNKNOWN_STATUS (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) -#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL) -#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL) -#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL) -#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) -#define AE_LOGICAL_ADDRESS (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) -#define AE_ABORT_METHOD (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL) -#define AE_SAME_HANDLER (ACPI_STATUS) (0x001D | AE_CODE_ENVIRONMENTAL) -#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001E | AE_CODE_ENVIRONMENTAL) -#define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001F | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL) +#define AE_ABORT_METHOD (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL) +#define AE_SAME_HANDLER (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL) +#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) +#define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) -#define AE_CODE_ENV_MAX 0x001F +#define AE_CODE_ENV_MAX 0x001B /* @@ -180,14 +175,13 @@ #define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) #define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) #define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) -#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) -#define AE_ALIGNMENT (ACPI_STATUS) (0x0006 | AE_CODE_PROGRAMMER) -#define AE_BAD_HEX_CONSTANT (ACPI_STATUS) (0x0007 | AE_CODE_PROGRAMMER) -#define AE_BAD_OCTAL_CONSTANT (ACPI_STATUS) (0x0008 | AE_CODE_PROGRAMMER) -#define AE_BAD_DECIMAL_CONSTANT (ACPI_STATUS) (0x0009 | AE_CODE_PROGRAMMER) -#define AE_MISSING_ARGUMENTS (ACPI_STATUS) (0x000A | AE_CODE_PROGRAMMER) +#define AE_BAD_HEX_CONSTANT (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) +#define AE_BAD_OCTAL_CONSTANT (ACPI_STATUS) (0x0006 | AE_CODE_PROGRAMMER) +#define AE_BAD_DECIMAL_CONSTANT (ACPI_STATUS) (0x0007 | AE_CODE_PROGRAMMER) +#define AE_MISSING_ARGUMENTS (ACPI_STATUS) (0x0008 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0009 | AE_CODE_PROGRAMMER) -#define AE_CODE_PGM_MAX 0x000A +#define AE_CODE_PGM_MAX 0x0009 /* @@ -197,52 +191,50 @@ #define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) #define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) #define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) -#define AE_TABLE_NOT_SUPPORTED (ACPI_STATUS) (0x0005 | AE_CODE_ACPI_TABLES) -#define AE_INVALID_TABLE_LENGTH (ACPI_STATUS) (0x0006 | AE_CODE_ACPI_TABLES) +#define AE_INVALID_TABLE_LENGTH (ACPI_STATUS) (0x0005 | AE_CODE_ACPI_TABLES) -#define AE_CODE_TBL_MAX 0x0006 +#define AE_CODE_TBL_MAX 0x0005 /* * AML exceptions. These are caused by problems with * the actual AML byte stream */ -#define AE_AML_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_AML) -#define AE_AML_PARSE (ACPI_STATUS) (0x0002 | AE_CODE_AML) -#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0003 | AE_CODE_AML) -#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0004 | AE_CODE_AML) -#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0005 | AE_CODE_AML) -#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0006 | AE_CODE_AML) -#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0007 | AE_CODE_AML) -#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0008 | AE_CODE_AML) -#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0009 | AE_CODE_AML) -#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x000A | AE_CODE_AML) -#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) -#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000C | AE_CODE_AML) -#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000D | AE_CODE_AML) -#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000E | AE_CODE_AML) -#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000F | AE_CODE_AML) -#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x0010 | AE_CODE_AML) -#define AE_AML_INTERNAL (ACPI_STATUS) (0x0011 | AE_CODE_AML) -#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0012 | AE_CODE_AML) -#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML) -#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0014 | AE_CODE_AML) -#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0015 | AE_CODE_AML) -#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0016 | AE_CODE_AML) -#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0017 | AE_CODE_AML) -#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0018 | AE_CODE_AML) -#define AE_AML_INVALID_RESOURCE_TYPE (ACPI_STATUS) (0x0019 | AE_CODE_AML) -#define AE_AML_INVALID_INDEX (ACPI_STATUS) (0x001A | AE_CODE_AML) -#define AE_AML_REGISTER_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_AML) -#define AE_AML_NO_WHILE (ACPI_STATUS) (0x001C | AE_CODE_AML) -#define AE_AML_ALIGNMENT (ACPI_STATUS) (0x001D | AE_CODE_AML) -#define AE_AML_NO_RESOURCE_END_TAG (ACPI_STATUS) (0x001E | AE_CODE_AML) -#define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001F | AE_CODE_AML) -#define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x0020 | AE_CODE_AML) -#define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x0021 | AE_CODE_AML) -#define AE_AML_ILLEGAL_ADDRESS (ACPI_STATUS) (0x0022 | AE_CODE_AML) +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0011 | AE_CODE_AML) +#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0012 | AE_CODE_AML) +#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML) +#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0014 | AE_CODE_AML) +#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0015 | AE_CODE_AML) +#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0016 | AE_CODE_AML) +#define AE_AML_INVALID_RESOURCE_TYPE (ACPI_STATUS) (0x0017 | AE_CODE_AML) +#define AE_AML_INVALID_INDEX (ACPI_STATUS) (0x0018 | AE_CODE_AML) +#define AE_AML_REGISTER_LIMIT (ACPI_STATUS) (0x0019 | AE_CODE_AML) +#define AE_AML_NO_WHILE (ACPI_STATUS) (0x001A | AE_CODE_AML) +#define AE_AML_ALIGNMENT (ACPI_STATUS) (0x001B | AE_CODE_AML) +#define AE_AML_NO_RESOURCE_END_TAG (ACPI_STATUS) (0x001C | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001D | AE_CODE_AML) +#define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x001E | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x001F | AE_CODE_AML) +#define AE_AML_ILLEGAL_ADDRESS (ACPI_STATUS) (0x0020 | AE_CODE_AML) +#define AE_AML_INFINITE_LOOP (ACPI_STATUS) (0x0021 | AE_CODE_AML) -#define AE_CODE_AML_MAX 0x0022 +#define AE_CODE_AML_MAX 0x0021 /* @@ -265,8 +257,9 @@ #define AE_CODE_CTRL_MAX 0x000D -#ifdef DEFINE_ACPI_GLOBALS +/* Exception strings for AcpiFormatException */ +#ifdef DEFINE_ACPI_GLOBALS /* * String versions of the exception codes above @@ -289,19 +282,15 @@ char const *AcpiGbl_ExceptionNames_Env[] = "AE_STACK_OVERFLOW", "AE_STACK_UNDERFLOW", "AE_NOT_IMPLEMENTED", - "AE_VERSION_MISMATCH", "AE_SUPPORT", - "AE_SHARE", "AE_LIMIT", "AE_TIME", - "AE_UNKNOWN_STATUS", "AE_ACQUIRE_DEADLOCK", "AE_RELEASE_DEADLOCK", "AE_NOT_ACQUIRED", "AE_ALREADY_ACQUIRED", "AE_NO_HARDWARE_RESPONSE", "AE_NO_GLOBAL_LOCK", - "AE_LOGICAL_ADDRESS", "AE_ABORT_METHOD", "AE_SAME_HANDLER", "AE_WAKE_ONLY_GPE", @@ -315,12 +304,11 @@ char const *AcpiGbl_ExceptionNames_Pgm[] = "AE_BAD_CHARACTER", "AE_BAD_PATHNAME", "AE_BAD_DATA", - "AE_BAD_ADDRESS", - "AE_ALIGNMENT", "AE_BAD_HEX_CONSTANT", "AE_BAD_OCTAL_CONSTANT", "AE_BAD_DECIMAL_CONSTANT", - "AE_MISSING_ARGUMENTS" + "AE_MISSING_ARGUMENTS", + "AE_BAD_ADDRESS" }; char const *AcpiGbl_ExceptionNames_Tbl[] = @@ -330,15 +318,12 @@ char const *AcpiGbl_ExceptionNames_Tbl[] = "AE_BAD_HEADER", "AE_BAD_CHECKSUM", "AE_BAD_VALUE", - "AE_TABLE_NOT_SUPPORTED", "AE_INVALID_TABLE_LENGTH" }; char const *AcpiGbl_ExceptionNames_Aml[] = { NULL, - "AE_AML_ERROR", - "AE_AML_PARSE", "AE_AML_BAD_OPCODE", "AE_AML_NO_OPERAND", "AE_AML_OPERAND_TYPE", @@ -370,7 +355,8 @@ char const *AcpiGbl_ExceptionNames_Aml[] = "AE_AML_BAD_RESOURCE_VALUE", "AE_AML_CIRCULAR_REFERENCE", "AE_AML_BAD_RESOURCE_LENGTH", - "AE_AML_ILLEGAL_ADDRESS" + "AE_AML_ILLEGAL_ADDRESS", + "AE_AML_INFINITE_LOOP" }; char const *AcpiGbl_ExceptionNames_Ctrl[] = diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acglobal.h b/src/add-ons/kernel/bus_managers/acpi/include/acglobal.h index 9a0834ac13..42b0d82c9a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acglobal.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acglobal.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acglobal.h - Declarations for global variables - * $Revision: 1.199 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -133,6 +132,10 @@ #endif +#ifdef DEFINE_ACPI_GLOBALS + +/* Public globals, available from outside ACPICA subsystem */ + /***************************************************************************** * * Runtime configuration (static defaults that can be overriden at runtime) @@ -153,7 +156,7 @@ * 5) Allow unresolved references (invalid target name) in package objects * 6) Enable warning messages for behavior that is not ACPI spec compliant */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); /* * Automatically serialize ALL control methods? Default is FALSE, meaning @@ -161,22 +164,37 @@ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE) * Only change this if the ASL code is poorly written and cannot handle * reentrancy even though methods are marked "NotSerialized". */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); /* * Create the predefined _OSI method in the namespace? Default is TRUE * because ACPI CA is fully compatible with other ACPI implementations. * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); /* * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only * be enabled just before going to sleep. */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); +/* + * Optionally use default values for the ACPI register widths. Set this to + * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); + + +/* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ + +ACPI_TABLE_FADT AcpiGbl_FADT; +UINT32 AcpiCurrentGpeCount; +UINT32 AcpiGbl_TraceFlags; +ACPI_NAME AcpiGbl_TraceMethodName; + +#endif /***************************************************************************** * @@ -188,14 +206,16 @@ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); * AcpiGbl_RootTableList is the master list of ACPI tables found in the * RSDT/XSDT. * - * AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; -ACPI_EXTERN ACPI_TABLE_FADT AcpiGbl_FADT; +ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; -/* These addresses are calculated from FADT address values */ +/* These addresses are calculated from the FADT Event Block addresses */ +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aStatus; ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bStatus; ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; /* @@ -238,6 +258,10 @@ ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GpeLock; /* For GPE data structs and registers */ ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_HardwareLock; /* For ACPI H/W except GPE registers */ +/* Reader/Writer lock is used for namespace walk and dynamic table unload */ + +ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; + /***************************************************************************** * @@ -282,6 +306,7 @@ ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; +ACPI_EXTERN UINT8 AcpiGbl_OsiData; #ifndef DEFINE_ACPI_GLOBALS @@ -299,7 +324,8 @@ extern char const *AcpiGbl_ExceptionNames_Ctrl[]; extern BOOLEAN AcpiGbl_Shutdown; extern UINT32 AcpiGbl_StartupFlags; extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; -extern const char *AcpiGbl_HighestDstateNames[4]; +extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; +extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; #endif @@ -330,6 +356,8 @@ ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_FadtGpeDevice; +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ModuleCodeList; + extern const UINT8 AcpiGbl_NsProperties [ACPI_NUM_NS_TYPES]; extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; @@ -387,11 +415,6 @@ ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCK * ****************************************************************************/ -/* Runtime configuration of debug print levels */ - -extern UINT32 AcpiDbgLevel; -extern UINT32 AcpiDbgLayer; - /* Procedure nesting level for debug output */ extern UINT32 AcpiGbl_NestingLevel; @@ -407,10 +430,8 @@ ACPI_EXTERN UINT32 AcpiFixedEventCount[ACPI_NUM_FIXED_EVENT ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; -ACPI_EXTERN ACPI_NAME AcpiGbl_TraceMethodName; ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; -ACPI_EXTERN UINT32 AcpiGbl_TraceFlags; /***************************************************************************** @@ -434,9 +455,6 @@ extern BOOLEAN AcpiGbl_MethodExecuting; extern BOOLEAN AcpiGbl_AbortMethod; extern BOOLEAN AcpiGbl_DbTerminateThreads; -ACPI_EXTERN int optind; -ACPI_EXTERN char *optarg; - ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; @@ -452,7 +470,6 @@ ACPI_EXTERN char *AcpiGbl_DbBuffer; ACPI_EXTERN char *AcpiGbl_DbFilename; ACPI_EXTERN UINT32 AcpiGbl_DbDebugLevel; ACPI_EXTERN UINT32 AcpiGbl_DbConsoleDebugLevel; -ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DbTablePtr; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_DbScopeNode; /* diff --git a/src/add-ons/kernel/bus_managers/acpi/include/achware.h b/src/add-ons/kernel/bus_managers/acpi/include/achware.h index d7af631600..c171a5fc1d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/achware.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/achware.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: achware.h -- hardware specific interfaces - * $Revision: 1.84 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,11 +117,7 @@ #define __ACHWARE_H__ -/* PM Timer ticks per second (HZ) */ - -#define PM_TIMER_FREQUENCY 3579545 - -/* Values for the _SST reserved method */ +/* Values for the _SST predefined method */ #define ACPI_SST_INDICATOR_OFF 0 #define ACPI_SST_WORKING 1 @@ -131,9 +126,6 @@ #define ACPI_SST_SLEEP_CONTEXT 4 -/* Prototypes */ - - /* * hwacpi - high level functions */ @@ -149,10 +141,31 @@ AcpiHwGetMode ( /* * hwregs - ACPI Register I/O */ +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address); + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg); + ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo ( UINT32 RegisterId); +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl); + ACPI_STATUS AcpiHwRegisterRead ( UINT32 RegisterId, @@ -163,23 +176,27 @@ AcpiHwRegisterWrite ( UINT32 RegisterId, UINT32 Value); -ACPI_STATUS -AcpiHwLowLevelRead ( - UINT32 Width, - UINT32 *Value, - ACPI_GENERIC_ADDRESS *Reg); - -ACPI_STATUS -AcpiHwLowLevelWrite ( - UINT32 Width, - UINT32 Value, - ACPI_GENERIC_ADDRESS *Reg); - ACPI_STATUS AcpiHwClearAcpiStatus ( void); +/* + * hwvalid - Port I/O with validation + */ +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + /* * hwgpe - GPE support */ @@ -194,7 +211,8 @@ AcpiHwWriteGpeEnableReg ( ACPI_STATUS AcpiHwDisableGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); ACPI_STATUS AcpiHwClearGpe ( @@ -203,7 +221,8 @@ AcpiHwClearGpe ( ACPI_STATUS AcpiHwClearGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); ACPI_STATUS AcpiHwGetGpeStatus ( @@ -225,7 +244,8 @@ AcpiHwEnableAllWakeupGpes ( ACPI_STATUS AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); /* diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acinterp.h b/src/add-ons/kernel/bus_managers/acpi/include/acinterp.h index 268a9edada..74c5f0b4eb 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acinterp.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acinterp.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 1.173 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -697,13 +696,13 @@ AcpiExReleaseGlobalLock ( void AcpiExEisaIdToString ( - UINT32 NumericId, - char *OutString); + char *Dest, + ACPI_INTEGER CompressedId); void -AcpiExUnsignedIntegerToString ( - ACPI_INTEGER Value, - char *OutString); +AcpiExIntegerToString ( + char *Dest, + ACPI_INTEGER Value); /* diff --git a/src/add-ons/kernel/bus_managers/acpi/include/aclocal.h b/src/add-ons/kernel/bus_managers/acpi/include/aclocal.h index 95815e6715..b8ea4f1432 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/aclocal.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/aclocal.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 1.250 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,10 +116,9 @@ #ifndef __ACLOCAL_H__ #define __ACLOCAL_H__ + /* acpisrc:StructDefs -- for acpisrc conversion */ -#define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ -#define ACPI_DO_NOT_WAIT 0 #define ACPI_SERIALIZED 0xFF typedef UINT32 ACPI_MUTEX_HANDLE; @@ -187,6 +185,16 @@ static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = #endif #endif +/* Lock structure for reader/writer interfaces */ + +typedef struct acpi_rw_lock +{ + ACPI_MUTEX WriterMutex; + ACPI_MUTEX ReaderMutex; + UINT32 NumReaders; + +} ACPI_RW_LOCK; + /* * Predefined handles for spinlocks used within the subsystem. @@ -199,14 +207,9 @@ static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = #define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 -/* Owner IDs are used to track namespace nodes for selective deletion */ - -typedef UINT8 ACPI_OWNER_ID; -#define ACPI_OWNER_ID_MAX 0xFF - /* This Thread ID means that the mutex is not in use (unlocked) */ -#define ACPI_MUTEX_NOT_ACQUIRED (UINT32) -1 +#define ACPI_MUTEX_NOT_ACQUIRED (ACPI_THREAD_ID) -1 /* Table for the global mutexes */ @@ -252,13 +255,6 @@ typedef enum } ACPI_INTERPRETER_MODE; -typedef union acpi_name_union -{ - UINT32 Integer; - char Ascii[4]; - -} ACPI_NAME_UNION; - /* * The Namespace Node describes a named object that appears in the AML. @@ -301,6 +297,8 @@ typedef struct acpi_namespace_node #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ +#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ +#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (InstallMethod) */ #define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ #define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ @@ -308,27 +306,6 @@ typedef struct acpi_namespace_node #define ANOBJ_IS_BIT_OFFSET 0x40 /* iASL only: Reference is a bit offset */ #define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ -/* - * ACPI Table Descriptor. One per ACPI table - */ -typedef struct acpi_table_desc -{ - ACPI_PHYSICAL_ADDRESS Address; - ACPI_TABLE_HEADER *Pointer; - UINT32 Length; /* Length fixed at 32 bits */ - ACPI_NAME_UNION Signature; - ACPI_OWNER_ID OwnerId; - UINT8 Flags; - -} ACPI_TABLE_DESC; - -/* Flags for above */ - -#define ACPI_TABLE_ORIGIN_UNKNOWN (0) -#define ACPI_TABLE_ORIGIN_MAPPED (1) -#define ACPI_TABLE_ORIGIN_ALLOCATED (2) -#define ACPI_TABLE_ORIGIN_MASK (3) -#define ACPI_TABLE_IS_LOADED (4) /* One internal RSDT for table management */ @@ -370,18 +347,6 @@ typedef struct acpi_ns_search_data } ACPI_NS_SEARCH_DATA; -/* - * Predefined Namespace items - */ -typedef struct acpi_predefined_names -{ - char *Name; - UINT8 Type; - char *Val; - -} ACPI_PREDEFINED_NAMES; - - /* Object types used during package copies */ #define ACPI_COPY_TYPE_SIMPLE 0 @@ -458,6 +423,110 @@ ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF +/* + * Information structure for ACPI predefined names. + * Each entry in the table contains the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedReturnBtypes - Allowed type(s) for the return value + */ +typedef struct acpi_name_info +{ + char Name[ACPI_NAME_SIZE]; + UINT8 ParamCount; + UINT8 ExpectedBtypes; + +} ACPI_NAME_INFO; + +/* + * Secondary information structures for ACPI predefined objects that return + * package objects. This structure appears as the next entry in the table + * after the NAME_INFO structure above. + * + * The reason for this is to minimize the size of the predefined name table. + */ + +/* + * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, + * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT + */ +typedef struct acpi_package_info +{ + UINT8 Type; + UINT8 ObjectType1; + UINT8 Count1; + UINT8 ObjectType2; + UINT8 Count2; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO; + +/* Used for ACPI_PTYPE2_FIXED */ + +typedef struct acpi_package_info2 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[4]; + +} ACPI_PACKAGE_INFO2; + +/* Used for ACPI_PTYPE1_OPTION */ + +typedef struct acpi_package_info3 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[2]; + UINT8 TailObjectType; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO3; + +typedef union acpi_predefined_info +{ + ACPI_NAME_INFO Info; + ACPI_PACKAGE_INFO RetInfo; + ACPI_PACKAGE_INFO2 RetInfo2; + ACPI_PACKAGE_INFO3 RetInfo3; + +} ACPI_PREDEFINED_INFO; + + +/* Data block used during object validation */ + +typedef struct acpi_predefined_data +{ + char *Pathname; + const ACPI_PREDEFINED_INFO *Predefined; + UINT32 Flags; + UINT8 NodeFlags; + +} ACPI_PREDEFINED_DATA; + +/* Defines for Flags field above */ + +#define ACPI_OBJECT_REPAIRED 1 + + +/* + * Bitmapped return value types + * Note: the actual data types must be contiguous, a loop in nspredef.c + * depends on this. + */ +#define ACPI_RTYPE_ANY 0x00 +#define ACPI_RTYPE_NONE 0x01 +#define ACPI_RTYPE_INTEGER 0x02 +#define ACPI_RTYPE_STRING 0x04 +#define ACPI_RTYPE_BUFFER 0x08 +#define ACPI_RTYPE_PACKAGE 0x10 +#define ACPI_RTYPE_REFERENCE 0x20 +#define ACPI_RTYPE_ALL 0x3F + +#define ACPI_NUM_RTYPES 5 /* Number of actual object types */ + + /***************************************************************************** * * Event typedefs and structs @@ -535,7 +604,6 @@ typedef struct acpi_gpe_xrupt_info } ACPI_GPE_XRUPT_INFO; - typedef struct acpi_gpe_walk_info { ACPI_NAMESPACE_NODE *GpeDevice; @@ -543,10 +611,19 @@ typedef struct acpi_gpe_walk_info } ACPI_GPE_WALK_INFO; +typedef struct acpi_gpe_device_info +{ + UINT32 Index; + UINT32 NextBlockBaseIndex; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *GpeDevice; + +} ACPI_GPE_DEVICE_INFO; typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); /* Information about each particular fixed event */ @@ -644,6 +721,7 @@ typedef struct acpi_control_state union acpi_parse_object *PredicateOp; UINT8 *AmlPredicateStart; /* Start of if/while predicate */ UINT8 *PackageEnd; /* End of if/while block */ + UINT32 LoopCount; /* While() loop counter */ } ACPI_CONTROL_STATE; @@ -784,6 +862,13 @@ typedef union acpi_parse_value } ACPI_PARSE_VALUE; + +#ifdef ACPI_DISASSEMBLER +#define ACPI_DISASM_ONLY_MEMBERS(a) a; +#else +#define ACPI_DISASM_ONLY_MEMBERS(a) +#endif + #define ACPI_PARSE_COMMON \ union acpi_parse_object *Parent; /* Parent op */\ UINT8 DescriptorType; /* To differentiate various internal objs */\ @@ -921,9 +1006,6 @@ typedef struct acpi_parse_state * ****************************************************************************/ -#define PCI_ROOT_HID_STRING "PNP0A03" -#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" - typedef struct acpi_bit_register_info { UINT8 ParentRegister; @@ -938,8 +1020,27 @@ typedef struct acpi_bit_register_info * must be preserved. */ #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ -#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0201 /* Bit 9, Bit 0 (SCI_EN) */ +/* Write-only bits must be zeroed by software */ + +#define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ + +/* For control registers, both ignored and reserved bits must be preserved */ + +/* + * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the + * ACPI specification to be a "preserved" bit - "OSPM always preserves this + * bit position", section 4.7.3.2.1. However, on some machines the OS must + * write a one to this bit after resume for the machine to work properly. + * To enable this, we no longer attempt to preserve this bit. No machines + * are known to fail if the bit is not preserved. (May 2009) + */ +#define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */ +#define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ +#define ACPI_PM1_CONTROL_PRESERVED_BITS \ + (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) + +#define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ /* * Register IDs @@ -948,12 +1049,10 @@ typedef struct acpi_bit_register_info #define ACPI_REGISTER_PM1_STATUS 0x01 #define ACPI_REGISTER_PM1_ENABLE 0x02 #define ACPI_REGISTER_PM1_CONTROL 0x03 -#define ACPI_REGISTER_PM1A_CONTROL 0x04 -#define ACPI_REGISTER_PM1B_CONTROL 0x05 -#define ACPI_REGISTER_PM2_CONTROL 0x06 -#define ACPI_REGISTER_PM_TIMER 0x07 -#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08 -#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09 +#define ACPI_REGISTER_PM2_CONTROL 0x04 +#define ACPI_REGISTER_PM_TIMER 0x05 +#define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 +#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 /* Masks used to access the BitRegisters */ @@ -986,7 +1085,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITMASK_SCI_ENABLE 0x0001 #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 -#define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00 +#define ACPI_BITMASK_SLEEP_TYPE 0x1C00 #define ACPI_BITMASK_SLEEP_ENABLE 0x2000 #define ACPI_BITMASK_ARB_DISABLE 0x0001 @@ -1013,12 +1112,44 @@ typedef struct acpi_bit_register_info #define ACPI_BITPOSITION_SCI_ENABLE 0x00 #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 -#define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A +#define ACPI_BITPOSITION_SLEEP_TYPE 0x0A #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D #define ACPI_BITPOSITION_ARB_DISABLE 0x00 +/* Structs and definitions for _OSI support and I/O port validation */ + +#define ACPI_OSI_WIN_2000 0x01 +#define ACPI_OSI_WIN_XP 0x02 +#define ACPI_OSI_WIN_XP_SP1 0x03 +#define ACPI_OSI_WINSRV_2003 0x04 +#define ACPI_OSI_WIN_XP_SP2 0x05 +#define ACPI_OSI_WINSRV_2003_SP1 0x06 +#define ACPI_OSI_WIN_VISTA 0x07 +#define ACPI_OSI_WINSRV_2008 0x08 +#define ACPI_OSI_WIN_VISTA_SP1 0x09 +#define ACPI_OSI_WIN_7 0x0A + +#define ACPI_ALWAYS_ILLEGAL 0x00 + +typedef struct acpi_interface_info +{ + char *Name; + UINT8 Value; + +} ACPI_INTERFACE_INFO; + +typedef struct acpi_port_info +{ + char *Name; + UINT16 Start; + UINT16 End; + UINT8 OsiDependency; + +} ACPI_PORT_INFO; + + /***************************************************************************** * * Resource descriptors @@ -1095,6 +1226,7 @@ typedef struct acpi_db_method_info { ACPI_HANDLE MainThreadGate; ACPI_HANDLE ThreadCompleteGate; + ACPI_HANDLE InfoGate; UINT32 *Threads; UINT32 NumThreads; UINT32 NumCreated; @@ -1174,29 +1306,4 @@ typedef struct acpi_debug_mem_block #define ACPI_NUM_MEM_LISTS 2 -typedef struct acpi_memory_list -{ - char *ListName; - void *ListHead; - UINT16 ObjectSize; - UINT16 MaxDepth; - UINT16 CurrentDepth; - UINT16 LinkOffset; - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - - /* Statistics for debug memory tracking only */ - - UINT32 TotalAllocated; - UINT32 TotalFreed; - UINT32 MaxOccupied; - UINT32 TotalSize; - UINT32 CurrentTotalSize; - UINT32 Requests; - UINT32 Hits; -#endif - -} ACPI_MEMORY_LIST; - - #endif /* __ACLOCAL_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acmacros.h b/src/add-ons/kernel/bus_managers/acpi/include/acmacros.h index db6dfe10b1..28c934deb9 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acmacros.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acmacros.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acmacros.h - C macros for the entire subsystem. - * $Revision: 1.199 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,24 +117,6 @@ #define __ACMACROS_H__ -/* - * Data manipulation macros - */ -#define ACPI_LOWORD(l) ((UINT16)(UINT32)(l)) -#define ACPI_HIWORD(l) ((UINT16)((((UINT32)(l)) >> 16) & 0xFFFF)) -#define ACPI_LOBYTE(l) ((UINT8)(UINT16)(l)) -#define ACPI_HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) - -#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) -#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) -#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) -#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) - -/* Size calculation */ - -#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) - - /* * Extract data using a pointer. Any more than a byte and we * get into potential aligment issues -- see the STORE macros below. @@ -150,41 +131,6 @@ #define ACPI_SET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) #define ACPI_SET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) -/* - * Pointer manipulation - */ -#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) -#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) -#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) -#define ACPI_PTR_DIFF(a, b) (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))) - -/* Pointer/Integer type conversions */ - -#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) -#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) -#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) -#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) -#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) - -#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED -#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) -#else -#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) -#endif - -/* - * Full 64-bit integer must be available on both 32-bit and 64-bit platforms - */ -typedef struct acpi_integer_overlay -{ - UINT32 LoDword; - UINT32 HiDword; - -} ACPI_INTEGER_OVERLAY; - -#define ACPI_LODWORD(Integer) (ACPI_CAST_PTR (ACPI_INTEGER_OVERLAY, &Integer)->LoDword) -#define ACPI_HIDWORD(Integer) (ACPI_CAST_PTR (ACPI_INTEGER_OVERLAY, &Integer)->HiDword) - /* * printf() format helpers */ @@ -287,7 +233,7 @@ typedef struct acpi_integer_overlay /* * The hardware does not support unaligned transfers. We must move the * data one byte at a time. These macros work whether the source or - * the destination (or both) is/are unaligned. (Little-endian move) + * the destination (or both) is/are unaligned. (Little-endian move) */ /* 16-bit source, 16/32/64 destination */ @@ -409,10 +355,6 @@ typedef struct acpi_integer_overlay #define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType) #define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t) -/* Macro to test the object type */ - -#define ACPI_GET_OBJECT_TYPE(d) (((ACPI_OPERAND_OBJECT *)(void *)(d))->Common.Type) - /* * Macros for the master AML opcode table */ @@ -424,12 +366,6 @@ typedef struct acpi_integer_overlay {(UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} #endif -#ifdef ACPI_DISASSEMBLER -#define ACPI_DISASM_ONLY_MEMBERS(a) a; -#else -#define ACPI_DISASM_ONLY_MEMBERS(a) -#endif - #define ARG_TYPE_WIDTH 5 #define ARG_1(x) ((UINT32)(x)) #define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) @@ -455,84 +391,36 @@ typedef struct acpi_integer_overlay #define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) #define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) - -#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) -/* - * Module name is include in both debug and non-debug versions primarily for - * error messages. The __FILE__ macro is not very useful for this, because it - * often includes the entire pathname to the module - */ -#define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name; -#else -#define ACPI_MODULE_NAME(Name) -#endif - /* * Ascii error messages can be configured out */ #ifndef ACPI_NO_ERROR_MESSAGES -#define AE_INFO _AcpiModuleName, __LINE__ - /* * Error reporting. Callers module and line number are inserted by AE_INFO, * the plist contains a set of parens to allow variable-length lists. * These macros are used for both the debug and non-debug versions of the code. */ -#define ACPI_INFO(plist) AcpiUtInfo plist -#define ACPI_WARNING(plist) AcpiUtWarning plist -#define ACPI_EXCEPTION(plist) AcpiUtException plist -#define ACPI_ERROR(plist) AcpiUtError plist #define ACPI_ERROR_NAMESPACE(s, e) AcpiNsReportError (AE_INFO, s, e); #define ACPI_ERROR_METHOD(s, n, p, e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); +#define ACPI_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist #else /* No error messages */ -#define ACPI_INFO(plist) -#define ACPI_WARNING(plist) -#define ACPI_EXCEPTION(plist) -#define ACPI_ERROR(plist) #define ACPI_ERROR_NAMESPACE(s, e) #define ACPI_ERROR_METHOD(s, n, p, e) -#endif +#define ACPI_WARN_PREDEFINED(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ /* * Debug macros that are conditionally compiled */ #ifdef ACPI_DEBUG_OUTPUT - -/* - * Common parameters used for debug output functions: - * line number, function name, module(file) name, component ID - */ -#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT - /* * Function entry tracing */ - -/* - * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, - * define it now. This is the case where there the compiler does not support - * a __FUNCTION__ macro or equivalent. - */ -#ifndef ACPI_GET_FUNCTION_NAME -#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName -/* - * The Name parameter should be the procedure name as a quoted string. - * The function name is also used by the function exit macros below. - * Note: (const char) is used to be compatible with the debug interfaces - * and macros such as __FUNCTION__. - */ -#define ACPI_FUNCTION_NAME(Name) static const char _AcpiFunctionName[] = #Name; - -#else -/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ - -#define ACPI_FUNCTION_NAME(Name) -#endif - #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ AcpiUtTrace(ACPI_DEBUG_PARAMETERS) #define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ @@ -626,16 +514,6 @@ typedef struct acpi_integer_overlay #define ACPI_DUMP_PATHNAME(a, b, c, d) AcpiNsDumpPathname(a, b, c, d) #define ACPI_DUMP_BUFFER(a, b) AcpiUtDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) -/* - * Master debug print macros - * Print iff: - * 1) Debug print for the current component is enabled - * 2) Debug error level or trace level for the print statement is enabled - */ -#define ACPI_DEBUG_PRINT(plist) AcpiUtDebugPrint plist -#define ACPI_DEBUG_PRINT_RAW(plist) AcpiUtDebugPrintRaw plist - - #else /* * This is the non-debug case -- make everything go away, @@ -643,7 +521,6 @@ typedef struct acpi_integer_overlay */ #define ACPI_DEBUG_EXEC(a) #define ACPI_DEBUG_ONLY_MEMBERS(a) -#define ACPI_FUNCTION_NAME(a) #define ACPI_FUNCTION_TRACE(a) #define ACPI_FUNCTION_TRACE_PTR(a, b) #define ACPI_FUNCTION_TRACE_U32(a, b) @@ -668,7 +545,7 @@ typedef struct acpi_integer_overlay #define return_UINT32(s) return(s) #define return_PTR(s) return(s) -#endif +#endif /* ACPI_DEBUG_OUTPUT */ /* * Some code only gets executed when the debugger is built in. diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acnames.h b/src/add-ons/kernel/bus_managers/acpi/include/acnames.h index b054106c2c..eb9944aa16 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acnames.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acnames.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acnames.h - Global names and strings - * $Revision: 1.8 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acnamesp.h b/src/add-ons/kernel/bus_managers/acpi/include/acnamesp.h index cb4e5bd050..ce0ba2aa08 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acnamesp.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acnamesp.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 1.154 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -147,6 +146,14 @@ #define ACPI_NS_WALK_UNLOCK 0x01 #define ACPI_NS_WALK_TEMP_NODES 0x02 +/* Object is not a package element */ + +#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX + +/* Always emit warning message, not dependent on node flags */ + +#define ACPI_WARN_ALWAYS 0 + /* * nsinit - Namespace initialization @@ -188,10 +195,14 @@ AcpiNsWalkNamespace ( ACPI_NAMESPACE_NODE * AcpiNsGetNextNode ( - ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE *Parent, ACPI_NAMESPACE_NODE *Child); +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); /* * nsparse - table parsing @@ -237,6 +248,10 @@ void AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node); +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node); + void AcpiNsDeleteNamespaceSubtree ( ACPI_NAMESPACE_NODE *ParentHandle); @@ -307,6 +322,32 @@ ACPI_STATUS AcpiNsEvaluate ( ACPI_EVALUATE_INFO *Info); +void +AcpiNsExecModuleCodeList ( + void); + + +/* + * nspredef - Support for predefined/reserved names + */ +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObject); + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Info); + /* * nsnames - Name and Scope manipulation @@ -315,7 +356,7 @@ UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type); -void +ACPI_STATUS AcpiNsBuildExternalPath ( ACPI_NAMESPACE_NODE *Node, ACPI_SIZE Size, @@ -386,6 +427,22 @@ AcpiNsGetAttachedData ( void **Data); +/* + * nsrepair - return object repair for predefined methods/objects + */ +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr); + + /* * nssearch - Namespace searching and entry */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acobject.h b/src/add-ons/kernel/bus_managers/acpi/include/acobject.h index 02d6323750..5a33fdcf7b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acobject.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acobject.h @@ -2,7 +2,6 @@ /****************************************************************************** * * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * $Revision: 1.144 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -171,7 +170,7 @@ #define AOPOBJ_OBJECT_INITIALIZED 0x08 #define AOPOBJ_SETUP_COMPLETE 0x10 #define AOPOBJ_SINGLE_DATUM 0x20 -#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an OpRegion address */ +#define AOPOBJ_MODULE_LEVEL 0x40 /****************************************************************************** @@ -480,21 +479,39 @@ typedef struct acpi_object_addr_handler *****************************************************************************/ /* - * The Reference object type is used for these opcodes: - * Arg[0-6], Local[0-7], IndexOp, NameOp, ZeroOp, OneOp, OnesOp, DebugOp + * The Reference object is used for these opcodes: + * Arg[0-6], Local[0-7], IndexOp, NameOp, RefOfOp, LoadOp, LoadTableOp, DebugOp + * The Reference.Class differentiates these types. */ typedef struct acpi_object_reference { ACPI_OBJECT_COMMON_HEADER - UINT8 TargetType; /* Used for IndexOp */ - UINT16 Opcode; - void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ - ACPI_NAMESPACE_NODE *Node; - union acpi_operand_object **Where; - UINT32 Offset; /* Used for ArgOp, LocalOp, and IndexOp */ + UINT8 Class; /* Reference Class */ + UINT8 TargetType; /* Used for Index Op */ + UINT8 Reserved; + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */ + union acpi_operand_object **Where; /* Target of Index */ + UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */ } ACPI_OBJECT_REFERENCE; +/* Values for Reference.Class above */ + +typedef enum +{ + ACPI_REFCLASS_LOCAL = 0, /* Method local */ + ACPI_REFCLASS_ARG = 1, /* Method argument */ + ACPI_REFCLASS_REFOF = 2, /* Result of RefOf() TBD: Split to Ref/Node and Ref/OperandObj? */ + ACPI_REFCLASS_INDEX = 3, /* Result of Index() */ + ACPI_REFCLASS_TABLE = 4, /* DdbHandle - Load(), LoadTable() */ + ACPI_REFCLASS_NAME = 5, /* Reference to a named object */ + ACPI_REFCLASS_DEBUG = 6, /* Debug object */ + + ACPI_REFCLASS_MAX = 6 + +} ACPI_REFERENCE_CLASSES; + /* * Extra object is used as additional storage for types that @@ -569,6 +586,13 @@ typedef union acpi_operand_object ACPI_OBJECT_DATA Data; ACPI_OBJECT_CACHE_LIST Cache; + /* + * Add namespace node to union in order to simplify code that accepts both + * ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share + * a common DescriptorType field in order to differentiate them. + */ + ACPI_NAMESPACE_NODE Node; + } ACPI_OPERAND_OBJECT; diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acopcode.h b/src/add-ons/kernel/bus_managers/acpi/include/acopcode.h index ed543b442d..bb309c78d3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acopcode.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acopcode.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acopcode.h - AML opcode information for the AML parser and interpreter - * $Revision: 1.9 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acoutput.h b/src/add-ons/kernel/bus_managers/acpi/include/acoutput.h index 5133cd0fba..2b796b541a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acoutput.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acoutput.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acoutput.h -- debug output - * $Revision: 1.102 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,9 +117,9 @@ #define __ACOUTPUT_H__ /* - * Debug levels and component IDs. These are used to control the - * granularity of the output of the DEBUG_PRINT macro -- on a per- - * component basis and a per-exception-type basis. + * Debug levels and component IDs. These are used to control the + * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a + * per-component basis and a per-exception-type basis. */ /* Component IDs are used in the global "DebugLayer" */ @@ -142,25 +141,24 @@ #define ACPI_COMPILER 0x00001000 #define ACPI_TOOLS 0x00002000 +#define ACPI_EXAMPLE 0x00004000 +#define ACPI_DRIVER 0x00008000 -#define ACPI_ALL_COMPONENTS 0x00003FFF +#define ACPI_ALL_COMPONENTS 0x0000FFFF #define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) - /* Component IDs reserved for ACPI drivers */ #define ACPI_ALL_DRIVERS 0xFFFF0000 /* - * Raw debug output levels, do not use these in the DEBUG_PRINT macros + * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros */ -#define ACPI_LV_ERROR 0x00000001 -#define ACPI_LV_WARN 0x00000002 -#define ACPI_LV_INIT 0x00000004 -#define ACPI_LV_DEBUG_OBJECT 0x00000008 -#define ACPI_LV_INFO 0x00000010 -#define ACPI_LV_ALL_EXCEPTIONS 0x0000001F +#define ACPI_LV_INIT 0x00000001 +#define ACPI_LV_DEBUG_OBJECT 0x00000002 +#define ACPI_LV_INFO 0x00000004 +#define ACPI_LV_ALL_EXCEPTIONS 0x00000007 /* Trace verbosity level 1 [Standard Trace Level] */ @@ -202,7 +200,6 @@ #define ACPI_LV_VERBOSE_INFO 0x20000000 #define ACPI_LV_FULL_TABLES 0x40000000 #define ACPI_LV_EVENTS 0x80000000 - #define ACPI_LV_VERBOSE 0xF0000000 @@ -211,21 +208,17 @@ */ #define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,ACPI_DEBUG_PARAMETERS -/* Exception level -- used in the global "DebugLevel" */ - +/* + * Exception level -- used in the global "DebugLevel" + * + * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces. + * For warnings, use ACPI_WARNING. + */ #define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) #define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) #define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) #define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) -/* - * These two levels are essentially obsolete, all instances in the - * ACPICA core code have been replaced by ACPI_ERROR and ACPI_WARNING - * (Kept here because some drivers may still use them) - */ -#define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR) -#define ACPI_DB_WARN ACPI_DEBUG_LEVEL (ACPI_LV_WARN) - /* Trace level -- also used in the global "DebugLevel" */ #define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) @@ -249,15 +242,108 @@ #define ACPI_DB_USER_REQUESTS ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS) #define ACPI_DB_PACKAGE ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE) #define ACPI_DB_MUTEX ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX) +#define ACPI_DB_EVENTS ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS) #define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) - /* Defaults for DebugLevel, debug and normal */ -#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) -#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) +#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT) +#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT) #define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) +#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) +/* + * Module name is included in both debug and non-debug versions primarily for + * error messages. The __FILE__ macro is not very useful for this, because it + * often includes the entire pathname to the module + */ +#define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name; +#else +#define ACPI_MODULE_NAME(Name) +#endif + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +#define AE_INFO _AcpiModuleName, __LINE__ + +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * the plist contains a set of parens to allow variable-length lists. + * These macros are used for both the debug and non-debug versions of the code. + */ +#define ACPI_INFO(plist) AcpiInfo plist +#define ACPI_WARNING(plist) AcpiWarning plist +#define ACPI_EXCEPTION(plist) AcpiException plist +#define ACPI_ERROR(plist) AcpiError plist + +#else + +/* No error messages */ + +#define ACPI_INFO(plist) +#define ACPI_WARNING(plist) +#define ACPI_EXCEPTION(plist) +#define ACPI_ERROR(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ + + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT + +/* + * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, + * define it now. This is the case where there the compiler does not support + * a __FUNCTION__ macro or equivalent. + */ +#ifndef ACPI_GET_FUNCTION_NAME +#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName + +/* + * The Name parameter should be the procedure name as a quoted string. + * The function name is also used by the function exit macros below. + * Note: (const char) is used to be compatible with the debug interfaces + * and macros such as __FUNCTION__. + */ +#define ACPI_FUNCTION_NAME(Name) static const char _AcpiFunctionName[] = #Name; + +#else +/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ + +#define ACPI_FUNCTION_NAME(Name) +#endif /* ACPI_GET_FUNCTION_NAME */ + +/* + * Common parameters used for debug output functions: + * line number, function name, module(file) name, component ID + */ +#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT + +/* + * Master debug print macros + * Print message if and only if: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + */ +#define ACPI_DEBUG_PRINT(plist) AcpiDebugPrint plist +#define ACPI_DEBUG_PRINT_RAW(plist) AcpiDebugPrintRaw plist + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_FUNCTION_NAME(a) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#endif /* ACPI_DEBUG_OUTPUT */ + + #endif /* __ACOUTPUT_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acparser.h b/src/add-ons/kernel/bus_managers/acpi/include/acparser.h index c45bd63764..086688e322 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acparser.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acparser.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * $Revision: 1.84 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -138,6 +137,7 @@ #define ACPI_PARSE_DEFERRED_OP 0x0100 #define ACPI_PARSE_DISASSEMBLE 0x0200 +#define ACPI_PARSE_MODULE_LEVEL 0x0400 /****************************************************************************** * diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acpi.h b/src/add-ons/kernel/bus_managers/acpi/include/acpi.h index dcdf2ebaa5..ac0af0387b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acpi.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acpi.h @@ -1,7 +1,6 @@ /****************************************************************************** * - * Name: acpi.h - Master include file, Publics and external data. - * $Revision: 1.62 $ + * Name: acpi.h - Master public include file used to interface to ACPICA * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,26 +117,22 @@ #define __ACPI_H__ /* - * Common includes for all ACPI driver files - * We put them here because we don't want to duplicate them - * in the rest of the source code again and again. + * Public include files for use by code that will interface to ACPICA. + * + * Information includes the ACPICA data types, names, exceptions, and + * external interface prototypes. Also included are the definitions for + * all ACPI tables (FADT, MADT, etc.) + * + * Note: The order of these include files is important. */ -#include "acnames.h" /* Global ACPI names and strings */ -#include "acconfig.h" /* Configuration constants */ -#include "platform/acenv.h" /* Target environment specific items */ -#include "actypes.h" /* Fundamental common data types */ -#include "acexcep.h" /* ACPI exception codes */ -#include "acmacros.h" /* C macros */ +#include "platform/acenv.h" /* Environment-specific items */ +#include "acnames.h" /* Common ACPI names and strings */ +#include "actypes.h" /* ACPICA data types and structures */ +#include "acexcep.h" /* ACPICA exceptions */ #include "actbl.h" /* ACPI table definitions */ -#include "aclocal.h" /* Internal data types */ #include "acoutput.h" /* Error output and Debug macros */ -#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer*/ +#include "acrestyp.h" /* Resource Descriptor structs */ +#include "acpiosxf.h" /* OSL interfaces (ACPICA-to-OS) */ #include "acpixf.h" /* ACPI core subsystem external interfaces */ -#include "acobject.h" /* ACPI internal object */ -#include "acstruct.h" /* Common structures */ -#include "acglobal.h" /* All global variables */ -#include "achware.h" /* Hardware defines and interfaces */ -#include "acutils.h" /* Utility interfaces */ - #endif /* __ACPI_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acpiosxf.h b/src/add-ons/kernel/bus_managers/acpi/include/acpiosxf.h index d3fb8074eb..730057d1ef 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acpiosxf.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acpiosxf.h @@ -12,7 +12,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -233,8 +233,11 @@ AcpiOsSignalSemaphore ( /* - * Mutex primitives + * Mutex primitives. May be configured to use semaphores instead via + * ACPI_MUTEX_TYPE (see platform/acenv.h) */ +#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) + ACPI_STATUS AcpiOsCreateMutex ( ACPI_MUTEX *OutHandle); @@ -251,13 +254,7 @@ AcpiOsAcquireMutex ( void AcpiOsReleaseMutex ( ACPI_MUTEX Handle); - -/* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */ - -#define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) -#define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) -#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) -#define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) +#endif /* @@ -425,12 +422,6 @@ ACPI_STATUS AcpiOsValidateInterface ( char *Interface); -ACPI_STATUS -AcpiOsValidateAddress ( - UINT8 SpaceId, - ACPI_PHYSICAL_ADDRESS Address, - ACPI_SIZE Length); - BOOLEAN AcpiOsReadable ( void *Pointer, diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acpixf.h b/src/add-ons/kernel/bus_managers/acpi/include/acpixf.h index 364e9c89ea..14f9b43381 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acpixf.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acpixf.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,9 +118,34 @@ #ifndef __ACXFACE_H__ #define __ACXFACE_H__ +/* Current ACPICA subsystem version in YYYYMMDD format */ + +#define ACPI_CA_VERSION 0x20090903 + #include "actypes.h" #include "actbl.h" +/* + * Globals that are publically available + */ +extern UINT32 AcpiCurrentGpeCount; +extern ACPI_TABLE_FADT AcpiGbl_FADT; + +/* Runtime configuration of debug print levels */ + +extern UINT32 AcpiDbgLevel; +extern UINT32 AcpiDbgLayer; + +/* ACPICA runtime options */ + +extern UINT8 AcpiGbl_EnableInterpreterSlack; +extern UINT8 AcpiGbl_AllMethodsSerialized; +extern UINT8 AcpiGbl_CreateOsiMethod; +extern UINT8 AcpiGbl_LeaveWakeGpesDisabled; +extern UINT8 AcpiGbl_UseDefaultRegisterWidths; +extern ACPI_NAME AcpiGbl_TraceMethodName; +extern UINT32 AcpiGbl_TraceFlags; + /* * Global interfaces @@ -175,10 +200,6 @@ ACPI_STATUS AcpiPurgeCachedObjects ( void); -ACPI_STATUS -AcpiInstallInitializationHandler ( - ACPI_INIT_HANDLER Handler, - UINT32 Function); /* * ACPI Memory managment @@ -315,7 +336,11 @@ AcpiEvaluateObjectTyped ( ACPI_STATUS AcpiGetObjectInfo ( ACPI_HANDLE Handle, - ACPI_BUFFER *ReturnBuffer); + ACPI_DEVICE_INFO **ReturnBuffer); + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer); ACPI_STATUS AcpiGetNextObject ( @@ -336,9 +361,14 @@ AcpiGetParent ( /* - * Event handler interfaces + * Handler interfaces */ ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function); + +ACPI_STATUS AcpiInstallFixedEventHandler ( UINT32 AcpiEvent, ACPI_EVENT_HANDLER Handler, @@ -384,6 +414,12 @@ AcpiInstallGpeHandler ( ACPI_EVENT_HANDLER Address, void *Context); +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_HANDLER Address); + ACPI_STATUS AcpiInstallExceptionHandler ( ACPI_EXCEPTION_HANDLER Handler); @@ -401,12 +437,6 @@ ACPI_STATUS AcpiReleaseGlobalLock ( UINT32 Handle); -ACPI_STATUS -AcpiRemoveGpeHandler ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - ACPI_EVENT_HANDLER Address); - ACPI_STATUS AcpiEnableEvent ( UINT32 Event, @@ -426,6 +456,10 @@ AcpiGetEventStatus ( UINT32 Event, ACPI_EVENT_STATUS *EventStatus); + +/* + * GPE Interfaces + */ ACPI_STATUS AcpiSetGpeType ( ACPI_HANDLE GpeDevice, @@ -457,6 +491,19 @@ AcpiGetGpeStatus ( UINT32 Flags, ACPI_EVENT_STATUS *EventStatus); +ACPI_STATUS +AcpiDisableAllGpes ( + void); + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 GpeIndex, + ACPI_HANDLE *GpeDevice); + ACPI_STATUS AcpiInstallGpeBlock ( ACPI_HANDLE GpeDevice, @@ -516,32 +563,34 @@ AcpiResourceToAddress64 ( ACPI_RESOURCE *Resource, ACPI_RESOURCE_ADDRESS64 *Out); + /* * Hardware (ACPI device) interfaces */ ACPI_STATUS -AcpiGetRegister ( +AcpiReset ( + void); + +ACPI_STATUS +AcpiRead ( + UINT64 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiReadBitRegister ( UINT32 RegisterId, UINT32 *ReturnValue); ACPI_STATUS -AcpiGetRegisterUnlocked ( - UINT32 RegisterId, - UINT32 *ReturnValue); - -ACPI_STATUS -AcpiSetRegister ( +AcpiWriteBitRegister ( UINT32 RegisterId, UINT32 Value); -ACPI_STATUS -AcpiSetFirmwareWakingVector ( - ACPI_PHYSICAL_ADDRESS PhysicalAddress); - -ACPI_STATUS -AcpiGetFirmwareWakingVector ( - ACPI_PHYSICAL_ADDRESS *PhysicalAddress); - ACPI_STATUS AcpiGetSleepTypeData ( UINT8 SleepState, @@ -562,7 +611,76 @@ AcpiEnterSleepStateS4bios ( ACPI_STATUS AcpiLeaveSleepState ( - UINT8 SleepState); + UINT8 SleepState) + ; +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress); +#if ACPI_MACHINE_WIDTH == 64 +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress); +#endif + + +/* + * Error/Warning output + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) ACPI_PRINTF_LIKE(4); + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + + +/* + * Debug output + */ +#ifdef ACPI_DEBUG_OUTPUT + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); +#endif #endif /* __ACXFACE_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acpredef.h b/src/add-ons/kernel/bus_managers/acpi/include/acpredef.h new file mode 100644 index 0000000000..2be401520b --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/include/acpredef.h @@ -0,0 +1,598 @@ +/****************************************************************************** + * + * Name: acpredef - Information table for ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPREDEF_H__ +#define __ACPREDEF_H__ + + +/****************************************************************************** + * + * Return Package types + * + * 1) PTYPE1 packages do not contain sub-packages. + * + * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types: + * object type + * count + * object type + * count + * + * ACPI_PTYPE1_VAR: Variable-length length: + * object type (Int/Buf/Ref) + * + * ACPI_PTYPE1_OPTION: Package has some required and some optional elements + * (Used for _PRW) + * + * + * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each + * of the different types describe the contents of each of the sub-packages. + * + * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) + * + * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: + * object type + * (Used for _CSD,_PSD,_TSD) + * + * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _CST) + * + * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length + * (Used for _PRT) + * + * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length + * (Used for _HPX) + * + * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length + * (Used for _ART, _FPS) + * + *****************************************************************************/ + +enum AcpiReturnPackageTypes +{ + ACPI_PTYPE1_FIXED = 1, + ACPI_PTYPE1_VAR = 2, + ACPI_PTYPE1_OPTION = 3, + ACPI_PTYPE2 = 4, + ACPI_PTYPE2_COUNT = 5, + ACPI_PTYPE2_PKG_COUNT = 6, + ACPI_PTYPE2_FIXED = 7, + ACPI_PTYPE2_MIN = 8, + ACPI_PTYPE2_REV_FIXED = 9 +}; + + +#ifdef ACPI_CREATE_PREDEFINED_TABLE +/* + * Predefined method/object information table. + * + * These are the names that can actually be evaluated via AcpiEvaluateObject. + * Not present in this table are the following: + * + * 1) Predefined/Reserved names that are never evaluated via + * AcpiEvaluateObject: + * _Lxx and _Exx GPE methods + * _Qxx EC methods + * _T_x compiler temporary variables + * + * 2) Predefined names that never actually exist within the AML code: + * Predefined resource descriptor field names + * + * 3) Predefined names that are implemented within ACPICA: + * _OSI + * + * 4) Some predefined names that are not documented within the ACPI spec. + * _WDG, _WED + * + * The main entries in the table each contain the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedBtypes - Allowed type(s) for the return value. + * 0 means that no return value is expected. + * + * For methods that return packages, the next entry in the table contains + * information about the expected structure of the package. This information + * is saved here (rather than in a separate table) in order to minimize the + * overall size of the stored data. + * + * Note: The additional braces are intended to promote portability. + */ +static const ACPI_PREDEFINED_INFO PredefinedNames[] = +{ + {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC3", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC4", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC5", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC6", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC7", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC8", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC9", 0, ACPI_RTYPE_INTEGER}}, + {{"_ADR", 0, ACPI_RTYPE_INTEGER}}, + {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL4", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL5", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL6", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL7", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL8", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL9", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_ALC", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALI", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALP", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALR", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 (Ints) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + + {{"_ALT", 0, ACPI_RTYPE_INTEGER}}, + {{"_ART", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 11,0}}, + + {{"_BBN", 0, ACPI_RTYPE_INTEGER}}, + {{"_BCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_BCM", 1, 0}}, + {{"_BCT", 1, ACPI_RTYPE_INTEGER}}, + {{"_BDN", 0, ACPI_RTYPE_INTEGER}}, + {{"_BFS", 1, 0}}, + {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4,0}}, + + {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4,0}}, + + {{"_BLT", 3, 0}}, + {{"_BMA", 1, ACPI_RTYPE_INTEGER}}, + {{"_BMC", 1, 0}}, + {{"_BMD", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (5 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_BMS", 1, ACPI_RTYPE_INTEGER}}, + {{"_BQC", 0, ACPI_RTYPE_INTEGER}}, + {{"_BST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_BTM", 1, ACPI_RTYPE_INTEGER}}, + {{"_BTP", 1, 0}}, + {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */ + {{"_CDM", 0, ACPI_RTYPE_INTEGER}}, + {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}}, + + {{"_CRS", 0, ACPI_RTYPE_BUFFER}}, + {{"_CRT", 0, ACPI_RTYPE_INTEGER}}, + {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ + {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}}, + + {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, + {{"_DCS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, + {{"_DDN", 0, ACPI_RTYPE_STRING}}, + {{"_DGS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DIS", 0, 0}}, + {{"_DMA", 0, ACPI_RTYPE_BUFFER}}, + {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_DOS", 1, 0}}, + {{"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */ + {{"_DSS", 1, 0}}, + {{"_DSW", 3, 0}}, + {{"_DTI", 1, 0}}, + {{"_EC_", 0, ACPI_RTYPE_INTEGER}}, + {{"_EDL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs)*/ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_EJ0", 1, 0}}, + {{"_EJ1", 1, 0}}, + {{"_EJ2", 1, 0}}, + {{"_EJ3", 1, 0}}, + {{"_EJ4", 1, 0}}, + {{"_EJD", 0, ACPI_RTYPE_STRING}}, + {{"_FDE", 0, ACPI_RTYPE_BUFFER}}, + {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}}, + + {{"_FDM", 1, 0}}, + {{"_FIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_FIX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_FPS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_INTEGER, 5, 0}, 0,0}}, + + {{"_FSL", 1, 0}}, + {{"_FST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3,0}, 0,0}}, + + + {{"_GAI", 0, ACPI_RTYPE_INTEGER}}, + {{"_GHL", 0, ACPI_RTYPE_INTEGER}}, + {{"_GLK", 0, ACPI_RTYPE_INTEGER}}, + {{"_GPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ + {{"_GSB", 0, ACPI_RTYPE_INTEGER}}, + {{"_GTF", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTM", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTS", 1, 0}}, + {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_HOT", 0, ACPI_RTYPE_INTEGER}}, + {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + /* + * For _HPX, a single package is returned, containing a Variable-length number + * of sub-packages. Each sub-package contains a PCI record setting. + * There are several different type of record settings, of different + * lengths, but all elements of all settings are Integers. + */ + {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */ + {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_INI", 0, 0}}, + {{"_IRC", 0, 0}}, + {{"_LCK", 1, 0}}, + {{"_LID", 0, ACPI_RTYPE_INTEGER}}, + {{"_MAT", 0, ACPI_RTYPE_BUFFER}}, + {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8,0}, 0,0}}, + + {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (2 Str) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 2,0}, 0,0}}, + + {{"_MSG", 1, 0}}, + {{"_MSM", 4, ACPI_RTYPE_INTEGER}}, + {{"_NTT", 0, ACPI_RTYPE_INTEGER}}, + {{"_OFF", 0, 0}}, + {{"_ON_", 0, 0}}, + {{"_OS_", 0, ACPI_RTYPE_STRING}}, + {{"_OSC", 4, ACPI_RTYPE_BUFFER}}, + {{"_OST", 3, 0}}, + {{"_PAI", 1, ACPI_RTYPE_INTEGER}}, + {{"_PCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PCT", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + + {{"_PDC", 1, 0}}, + {{"_PDL", 0, ACPI_RTYPE_INTEGER}}, + {{"_PIC", 1, 0}}, + {{"_PIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PLD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Bufs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0}, 0,0}}, + + {{"_PMC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (11 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PMD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PMM", 0, ACPI_RTYPE_INTEGER}}, + {{"_PPC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* See dig64 spec */ + {{"_PR0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRS", 0, ACPI_RTYPE_BUFFER}}, + + /* + * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source + * and SourceIndex). This bug is so prevalent that there is code in the + * ACPICA Resource Manager to detect this and switch them back. For now, + * do not allow and issue a warning. To allow this and eliminate the + * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3) + * in the statement below. + */ + {{"_PRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */ + {{{ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER,ACPI_RTYPE_INTEGER}, + ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, + ACPI_RTYPE_INTEGER}}, + + {{"_PRW", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */ + {{{ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE, + ACPI_RTYPE_INTEGER}, ACPI_RTYPE_REFERENCE,0}}, + + {{"_PS0", 0, 0}}, + {{"_PS1", 0, 0}}, + {{"_PS2", 0, 0}}, + {{"_PS3", 0, 0}}, + {{"_PSC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}}, + + {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PSR", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (6 Int) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0}, 0,0}}, + + {{"_PSV", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSW", 1, 0}}, + {{"_PTC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + + {{"_PTP", 2, ACPI_RTYPE_INTEGER}}, + {{"_PTS", 1, 0}}, + {{"_PUR", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + + {{"_PXM", 0, ACPI_RTYPE_INTEGER}}, + {{"_REG", 2, 0}}, + {{"_REV", 0, ACPI_RTYPE_INTEGER}}, + {{"_RMV", 0, ACPI_RTYPE_INTEGER}}, + {{"_ROM", 2, ACPI_RTYPE_BUFFER}}, + {{"_RTV", 0, ACPI_RTYPE_INTEGER}}, + + /* + * For _S0_ through _S5_, the ACPI spec defines a return Package + * containing 1 Integer, but most DSDTs have it wrong - 2,3, or 4 integers. + * Allow this by making the objects "Variable-length length", but all elements + * must be Integers. + */ + {{"_S0_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S2_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S3_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S4_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S5_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S0W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S1W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4W", 0, ACPI_RTYPE_INTEGER}}, + {{"_SBS", 0, ACPI_RTYPE_INTEGER}}, + {{"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */ + /* Note: the 3-arg definition may be removed for ACPI 4.0 */ + {{"_SDD", 1, 0}}, + {{"_SEG", 0, ACPI_RTYPE_INTEGER}}, + {{"_SHL", 1, ACPI_RTYPE_INTEGER}}, + {{"_SLI", 0, ACPI_RTYPE_BUFFER}}, + {{"_SPD", 1, ACPI_RTYPE_INTEGER}}, + {{"_SRS", 1, 0}}, + {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_SST", 1, 0}}, + {{"_STA", 0, ACPI_RTYPE_INTEGER}}, + {{"_STM", 3, 0}}, + {{"_STP", 2, ACPI_RTYPE_INTEGER}}, + {{"_STR", 0, ACPI_RTYPE_BUFFER}}, + {{"_STV", 2, ACPI_RTYPE_INTEGER}}, + {{"_SUN", 0, ACPI_RTYPE_INTEGER}}, + {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, + {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_TC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_TIP", 1, ACPI_RTYPE_INTEGER}}, + {{"_TIV", 1, ACPI_RTYPE_INTEGER}}, + {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TPC", 0, ACPI_RTYPE_INTEGER}}, + {{"_TPT", 1, 0}}, + {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2Ref/6Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}}, + + {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int with count */ + {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TSP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TST", 0, ACPI_RTYPE_INTEGER}}, + {{"_TTS", 1, 0}}, + {{"_TZD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_TZM", 0, ACPI_RTYPE_REFERENCE}}, + {{"_TZP", 0, ACPI_RTYPE_INTEGER}}, + {{"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_UPC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_UPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_UPP", 0, ACPI_RTYPE_INTEGER}}, + {{"_VPO", 0, ACPI_RTYPE_INTEGER}}, + + /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ + + {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ + + {{{0,0,0,0}, 0,0}} /* Table terminator */ +}; + +#if 0 + /* Not implemented */ + + {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, /* MS Extension */ + {{"_WED", 1, ACPI_RTYPE_PACKAGE}}, /* MS Extension */ + + /* This is an internally implemented control method, no need to check */ + {{"_OSI", 1, ACPI_RTYPE_INTEGER}}, + + /* TBD: */ + + _PRT - currently ignore reversed entries. Attempt to fix here? + Think about possibly fixing package elements like _BIF, etc. +#endif +#endif +#endif diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acresrc.h b/src/add-ons/kernel/bus_managers/acpi/include/acresrc.h index 5714f3acb2..c70aa5e23d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acresrc.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acresrc.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acresrc.h - Resource Manager function prototypes - * $Revision: 1.62 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acrestyp.h b/src/add-ons/kernel/bus_managers/acpi/include/acrestyp.h new file mode 100644 index 0000000000..7eb7600d98 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/include/acrestyp.h @@ -0,0 +1,544 @@ +/****************************************************************************** + * + * Name: acrestyp.h - Defines, types, and structures for resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESTYP_H__ +#define __ACRESTYP_H__ + + +/* + * Definitions for Resource Attributes + */ +typedef UINT16 ACPI_RS_LENGTH; /* Resource Length field is fixed at 16 bits */ +typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */ + +/* + * Memory Attributes + */ +#define ACPI_READ_ONLY_MEMORY (UINT8) 0x00 +#define ACPI_READ_WRITE_MEMORY (UINT8) 0x01 + +#define ACPI_NON_CACHEABLE_MEMORY (UINT8) 0x00 +#define ACPI_CACHABLE_MEMORY (UINT8) 0x01 +#define ACPI_WRITE_COMBINING_MEMORY (UINT8) 0x02 +#define ACPI_PREFETCHABLE_MEMORY (UINT8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. + * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. + */ +#define ACPI_NON_ISA_ONLY_RANGES (UINT8) 0x01 +#define ACPI_ISA_ONLY_RANGES (UINT8) 0x02 +#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) + +/* Type of translation - 1=Sparse, 0=Dense */ + +#define ACPI_SPARSE_TRANSLATION (UINT8) 0x01 + +/* + * IO Port Descriptor Decode + */ +#define ACPI_DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ +#define ACPI_DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define ACPI_LEVEL_SENSITIVE (UINT8) 0x00 +#define ACPI_EDGE_SENSITIVE (UINT8) 0x01 + +#define ACPI_ACTIVE_HIGH (UINT8) 0x00 +#define ACPI_ACTIVE_LOW (UINT8) 0x01 + +#define ACPI_EXCLUSIVE (UINT8) 0x00 +#define ACPI_SHARED (UINT8) 0x01 + +/* + * DMA Attributes + */ +#define ACPI_COMPATIBILITY (UINT8) 0x00 +#define ACPI_TYPE_A (UINT8) 0x01 +#define ACPI_TYPE_B (UINT8) 0x02 +#define ACPI_TYPE_F (UINT8) 0x03 + +#define ACPI_NOT_BUS_MASTER (UINT8) 0x00 +#define ACPI_BUS_MASTER (UINT8) 0x01 + +#define ACPI_TRANSFER_8 (UINT8) 0x00 +#define ACPI_TRANSFER_8_16 (UINT8) 0x01 +#define ACPI_TRANSFER_16 (UINT8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define ACPI_GOOD_CONFIGURATION (UINT8) 0x00 +#define ACPI_ACCEPTABLE_CONFIGURATION (UINT8) 0x01 +#define ACPI_SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define ACPI_MEMORY_RANGE (UINT8) 0x00 +#define ACPI_IO_RANGE (UINT8) 0x01 +#define ACPI_BUS_NUMBER_RANGE (UINT8) 0x02 + +#define ACPI_ADDRESS_NOT_FIXED (UINT8) 0x00 +#define ACPI_ADDRESS_FIXED (UINT8) 0x01 + +#define ACPI_POS_DECODE (UINT8) 0x00 +#define ACPI_SUB_DECODE (UINT8) 0x01 + +#define ACPI_PRODUCER (UINT8) 0x00 +#define ACPI_CONSUMER (UINT8) 0x01 + + +/* + * If possible, pack the following structures to byte alignment + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +/* UUID data structures for use in vendor-defined resource descriptors */ + +typedef struct acpi_uuid +{ + UINT8 Data[ACPI_UUID_LENGTH]; +} ACPI_UUID; + +typedef struct acpi_vendor_uuid +{ + UINT8 Subtype; + UINT8 Data[ACPI_UUID_LENGTH]; + +} ACPI_VENDOR_UUID; + +/* + * Structures used to describe device resources + */ +typedef struct acpi_resource_irq +{ + UINT8 DescriptorLength; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + UINT8 Interrupts[1]; + +} ACPI_RESOURCE_IRQ; + +typedef struct ACPI_RESOURCE_DMA +{ + UINT8 Type; + UINT8 BusMaster; + UINT8 Transfer; + UINT8 ChannelCount; + UINT8 Channels[1]; + +} ACPI_RESOURCE_DMA; + +typedef struct acpi_resource_start_dependent +{ + UINT8 DescriptorLength; + UINT8 CompatibilityPriority; + UINT8 PerformanceRobustness; + +} ACPI_RESOURCE_START_DEPENDENT; + + +/* + * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + + +typedef struct acpi_resource_io +{ + UINT8 IoDecode; + UINT8 Alignment; + UINT8 AddressLength; + UINT16 Minimum; + UINT16 Maximum; + +} ACPI_RESOURCE_IO; + +typedef struct acpi_resource_fixed_io +{ + UINT16 Address; + UINT8 AddressLength; + +} ACPI_RESOURCE_FIXED_IO; + +typedef struct acpi_resource_vendor +{ + UINT16 ByteLength; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR; + +/* Vendor resource with UUID info (introduced in ACPI 3.0) */ + +typedef struct acpi_resource_vendor_typed +{ + UINT16 ByteLength; + UINT8 UuidSubtype; + UINT8 Uuid[ACPI_UUID_LENGTH]; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR_TYPED; + +typedef struct acpi_resource_end_tag +{ + UINT8 Checksum; + +} ACPI_RESOURCE_END_TAG; + +typedef struct acpi_resource_memory24 +{ + UINT8 WriteProtect; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} ACPI_RESOURCE_MEMORY24; + +typedef struct acpi_resource_memory32 +{ + UINT8 WriteProtect; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} ACPI_RESOURCE_MEMORY32; + +typedef struct acpi_resource_fixed_memory32 +{ + UINT8 WriteProtect; + UINT32 Address; + UINT32 AddressLength; + +} ACPI_RESOURCE_FIXED_MEMORY32; + +typedef struct acpi_memory_attribute +{ + UINT8 WriteProtect; + UINT8 Caching; + UINT8 RangeType; + UINT8 Translation; + +} ACPI_MEMORY_ATTRIBUTE; + +typedef struct acpi_io_attribute +{ + UINT8 RangeType; + UINT8 Translation; + UINT8 TranslationType; + UINT8 Reserved1; + +} ACPI_IO_ATTRIBUTE; + +typedef union acpi_resource_attribute +{ + ACPI_MEMORY_ATTRIBUTE Mem; + ACPI_IO_ATTRIBUTE Io; + + /* Used for the *WordSpace macros */ + + UINT8 TypeSpecific; + +} ACPI_RESOURCE_ATTRIBUTE; + +typedef struct acpi_resource_source +{ + UINT8 Index; + UINT16 StringLength; + char *StringPtr; + +} ACPI_RESOURCE_SOURCE; + +/* Fields common to all address descriptors, 16/32/64 bit */ + +#define ACPI_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 ProducerConsumer; \ + UINT8 Decode; \ + UINT8 MinAddressFixed; \ + UINT8 MaxAddressFixed; \ + ACPI_RESOURCE_ATTRIBUTE Info; + +typedef struct acpi_resource_address +{ + ACPI_RESOURCE_ADDRESS_COMMON + +} ACPI_RESOURCE_ADDRESS; + +typedef struct acpi_resource_address16 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS16; + +typedef struct acpi_resource_address32 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS32; + +typedef struct acpi_resource_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS64; + +typedef struct acpi_resource_extended_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} ACPI_RESOURCE_EXTENDED_ADDRESS64; + +typedef struct acpi_resource_extended_irq +{ + UINT8 ProducerConsumer; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + ACPI_RESOURCE_SOURCE ResourceSource; + UINT32 Interrupts[1]; + +} ACPI_RESOURCE_EXTENDED_IRQ; + +typedef struct acpi_resource_generic_register +{ + UINT8 SpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; + UINT64 Address; + +} ACPI_RESOURCE_GENERIC_REGISTER; + + +/* ACPI_RESOURCE_TYPEs */ + +#define ACPI_RESOURCE_TYPE_IRQ 0 +#define ACPI_RESOURCE_TYPE_DMA 1 +#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 +#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 +#define ACPI_RESOURCE_TYPE_IO 4 +#define ACPI_RESOURCE_TYPE_FIXED_IO 5 +#define ACPI_RESOURCE_TYPE_VENDOR 6 +#define ACPI_RESOURCE_TYPE_END_TAG 7 +#define ACPI_RESOURCE_TYPE_MEMORY24 8 +#define ACPI_RESOURCE_TYPE_MEMORY32 9 +#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 +#define ACPI_RESOURCE_TYPE_ADDRESS16 11 +#define ACPI_RESOURCE_TYPE_ADDRESS32 12 +#define ACPI_RESOURCE_TYPE_ADDRESS64 13 +#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ +#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 +#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 +#define ACPI_RESOURCE_TYPE_MAX 16 + +/* Master union for resource descriptors */ + +typedef union acpi_resource_data +{ + ACPI_RESOURCE_IRQ Irq; + ACPI_RESOURCE_DMA Dma; + ACPI_RESOURCE_START_DEPENDENT StartDpf; + ACPI_RESOURCE_IO Io; + ACPI_RESOURCE_FIXED_IO FixedIo; + ACPI_RESOURCE_VENDOR Vendor; + ACPI_RESOURCE_VENDOR_TYPED VendorTyped; + ACPI_RESOURCE_END_TAG EndTag; + ACPI_RESOURCE_MEMORY24 Memory24; + ACPI_RESOURCE_MEMORY32 Memory32; + ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; + ACPI_RESOURCE_ADDRESS16 Address16; + ACPI_RESOURCE_ADDRESS32 Address32; + ACPI_RESOURCE_ADDRESS64 Address64; + ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; + ACPI_RESOURCE_GENERIC_REGISTER GenericReg; + + /* Common fields */ + + ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ + +} ACPI_RESOURCE_DATA; + + +/* Common resource header */ + +typedef struct acpi_resource +{ + UINT32 Type; + UINT32 Length; + ACPI_RESOURCE_DATA Data; + +} ACPI_RESOURCE; + +/* restore default alignment */ + +#pragma pack() + + +#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RS_SIZE_MIN (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) +#define ACPI_RS_SIZE(Type) (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type)) + +#define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) + + +typedef struct acpi_pci_routing_table +{ + UINT32 Length; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ + +} ACPI_PCI_ROUTING_TABLE; + +#endif /* __ACRESTYP_H__ */ + diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acstruct.h b/src/add-ons/kernel/bus_managers/acpi/include/acstruct.h index f01f73455c..45c85fe0b2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acstruct.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acstruct.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acstruct.h - Internal structs - * $Revision: 1.50 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/actables.h b/src/add-ons/kernel/bus_managers/acpi/include/actables.h index 93cc7907c6..e4428e6415 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/actables.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/actables.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: actables.h - ACPI table management - * $Revision: 1.65 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -127,8 +126,7 @@ AcpiAllocateRootTable ( */ void AcpiTbParseFadt ( - UINT32 TableIndex, - UINT8 Flags); + UINT32 TableIndex); void AcpiTbCreateLocalFadt ( @@ -179,7 +177,7 @@ void AcpiTbTerminate ( void); -void +ACPI_STATUS AcpiTbDeleteNamespaceByOwner ( UINT32 TableIndex); @@ -209,6 +207,10 @@ AcpiTbSetTableLoadedFlag ( /* * tbutils - table manager utilities */ +ACPI_STATUS +AcpiTbInitializeFacs ( + void); + BOOLEAN AcpiTbTablesLoaded ( void); @@ -231,13 +233,11 @@ AcpiTbVerifyChecksum ( void AcpiTbInstallTable ( ACPI_PHYSICAL_ADDRESS Address, - UINT8 Flags, char *Signature, UINT32 TableIndex); ACPI_STATUS AcpiTbParseRootTable ( - ACPI_PHYSICAL_ADDRESS RsdpAddress, - UINT8 Flags); + ACPI_PHYSICAL_ADDRESS RsdpAddress); #endif /* __ACTABLES_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/actbl.h b/src/add-ons/kernel/bus_managers/acpi/include/actbl.h index 1ad1e6bfea..caa3bdbe3b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/actbl.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/actbl.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: actbl.h - Basic ACPI Table Definitions - * $Revision: 1.85 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,9 +116,25 @@ #ifndef __ACTBL_H__ #define __ACTBL_H__ + +/******************************************************************************* + * + * Fundamental ACPI tables + * + * This file contains definitions for the ACPI tables that are directly consumed + * by ACPICA. All other tables are consumed by the OS-dependent ACPI-related + * device drivers and other OS support code. + * + * The RSDP and FACS do not use the common ACPI table header. All other ACPI + * tables use the header. + * + ******************************************************************************/ + + /* - * Values for description table header signatures. Useful because they make - * it more difficult to inadvertently type in the wrong signature. + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. */ #define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */ #define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */ @@ -138,23 +153,17 @@ */ #pragma pack(1) - /* - * These are the ACPI tables that are directly consumed by the subsystem. - * - * The RSDP and FACS do not use the common ACPI table header. All other ACPI - * tables use the header. - * * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. * This is the only type that is even remotely portable. Anything else is not * portable, so do not use any other bitfield types. */ + /******************************************************************************* * - * ACPI Table Header. This common header is used by all tables except the - * RSDP and FACS. The define is used for direct inclusion of header into - * other ACPI tables + * Master ACPI Table Header. This common header is used by all ACPI tables + * except the RSDP and FACS. * ******************************************************************************/ @@ -173,13 +182,16 @@ typedef struct acpi_table_header } ACPI_TABLE_HEADER; -/* +/******************************************************************************* + * * GAS - Generic Address Structure (ACPI 2.0+) * * Note: Since this structure is used in the ACPI tables, it is byte aligned. - * If misalignment is not supported, access to the Address field must be - * performed with care. - */ + * If misaliged access is not supported by the hardware, accesses to the + * 64-bit Address field must be performed with care. + * + ******************************************************************************/ + typedef struct acpi_generic_address { UINT8 SpaceId; /* Address space where struct or register exists */ @@ -194,6 +206,7 @@ typedef struct acpi_generic_address /******************************************************************************* * * RSDP - Root System Description Pointer (Signature is "RSD PTR ") + * Version 2 * ******************************************************************************/ @@ -217,6 +230,7 @@ typedef struct acpi_table_rsdp /******************************************************************************* * * RSDT/XSDT - Root System Description Tables + * Version 1 (both) * ******************************************************************************/ @@ -251,23 +265,31 @@ typedef struct acpi_table_facs UINT32 Flags; UINT64 XFirmwareWakingVector; /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */ UINT8 Version; /* Version of this table (ACPI 2.0+) */ - UINT8 Reserved[31]; /* Reserved, must be zero */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 OspmFlags; /* Flags to be set by OSPM (ACPI 4.0) */ + UINT8 Reserved1[24]; /* Reserved, must be zero */ } ACPI_TABLE_FACS; -/* Flag macros */ +/* Masks for GlobalLock flag field above */ -#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ +#define ACPI_GLOCK_PENDING (1) /* 00: Pending global lock ownership */ +#define ACPI_GLOCK_OWNED (1<<1) /* 01: Global lock is owned */ -/* Global lock flags */ +/* Masks for Flags field above */ -#define ACPI_GLOCK_PENDING 0x01 /* 00: Pending global lock ownership */ -#define ACPI_GLOCK_OWNED 0x02 /* 01: Global lock is owned */ +#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ +#define ACPI_FACS_64BIT_WAKE (1<<1) /* 01: 64-bit wake vector supported (ACPI 4.0) */ + +/* Masks for OspmFlags field above */ + +#define ACPI_FACS_64BIT_ENVIRONMENT (1) /* 00: 64-bit wake environment is required (ACPI 4.0) */ /******************************************************************************* * * FADT - Fixed ACPI Description Table (Signature "FACP") + * Version 4 * ******************************************************************************/ @@ -306,12 +328,12 @@ typedef struct acpi_table_fadt UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ UINT16 FlushSize; /* Processor's memory cache line width, in bytes */ UINT16 FlushStride; /* Number of flush strides that need to be read */ - UINT8 DutyOffset; /* Processor duty cycle index in processor's P_CNT reg*/ - UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register.*/ + UINT8 DutyOffset; /* Processor duty cycle index in processor's P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ UINT8 Century; /* Index to century in RTC CMOS RAM */ - UINT16 BootFlags; /* IA-PC Boot Architecture Flags. See Table 5-10 for description */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ UINT8 Reserved; /* Reserved, must be zero */ UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ @@ -331,33 +353,40 @@ typedef struct acpi_table_fadt } ACPI_TABLE_FADT; -/* FADT flags */ +/* Masks for FADT Boot Architecture Flags (BootFlags) */ -#define ACPI_FADT_WBINVD (1) /* 00: The wbinvd instruction works properly */ -#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: The wbinvd flushes but does not invalidate */ -#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: All processors support C1 state */ -#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: C2 state works on MP system */ -#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: Power button is handled as a generic feature */ -#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: Sleep button is handled as a generic feature, or not present */ -#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: RTC wakeup stat not in fixed register space */ -#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: RTC wakeup stat not possible from S4 */ -#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: tmr_val is 32 bits 0=24-bits */ -#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: Docking supported */ -#define ACPI_FADT_RESET_REGISTER (1<<10) /* 10: System reset via the FADT RESET_REG supported */ -#define ACPI_FADT_SEALED_CASE (1<<11) /* 11: No internal expansion capabilities and case is sealed */ -#define ACPI_FADT_HEADLESS (1<<12) /* 12: No local video capabilities or local input devices */ -#define ACPI_FADT_SLEEP_TYPE (1<<13) /* 13: Must execute native instruction after writing SLP_TYPx register */ -#define ACPI_FADT_PCI_EXPRESS_WAKE (1<<14) /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ -#define ACPI_FADT_PLATFORM_CLOCK (1<<15) /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ -#define ACPI_FADT_S4_RTC_VALID (1<<16) /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ -#define ACPI_FADT_REMOTE_POWER_ON (1<<17) /* 17: System is compatible with remote power on (ACPI 3.0) */ -#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: All local APICs must use cluster model (ACPI 3.0) */ -#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: All local xAPICs must use physical dest mode (ACPI 3.0) */ +#define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ +#define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ +#define ACPI_FADT_NO_VGA (1<<2) /* 02: [V4] It is not safe to probe for VGA hardware */ +#define ACPI_FADT_NO_MSI (1<<3) /* 03: [V4] Message Signaled Interrupts (MSI) must not be enabled */ +#define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ + +/* Masks for FADT flags */ + +#define ACPI_FADT_WBINVD (1) /* 00: [V1] The wbinvd instruction works properly */ +#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: [V1] wbinvd flushes but does not invalidate caches */ +#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: [V1] All processors support C1 state */ +#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: [V1] C2 state works on MP system */ +#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: [V1] Power button is handled as a control method device */ +#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: [V1] Sleep button is handled as a control method device */ +#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: [V1] RTC wakeup status not in fixed register space */ +#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: [V1] RTC alarm can wake system from S4 */ +#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */ +#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: [V1] Docking supported */ +#define ACPI_FADT_RESET_REGISTER (1<<10) /* 10: [V2] System reset via the FADT RESET_REG supported */ +#define ACPI_FADT_SEALED_CASE (1<<11) /* 11: [V3] No internal expansion capabilities and case is sealed */ +#define ACPI_FADT_HEADLESS (1<<12) /* 12: [V3] No local video capabilities or local input devices */ +#define ACPI_FADT_SLEEP_TYPE (1<<13) /* 13: [V3] Must execute native instruction after writing SLP_TYPx register */ +#define ACPI_FADT_PCI_EXPRESS_WAKE (1<<14) /* 14: [V4] System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ +#define ACPI_FADT_PLATFORM_CLOCK (1<<15) /* 15: [V4] OSPM should use platform-provided timer (ACPI 3.0) */ +#define ACPI_FADT_S4_RTC_VALID (1<<16) /* 16: [V4] Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ +#define ACPI_FADT_REMOTE_POWER_ON (1<<17) /* 17: [V4] System is compatible with remote power on (ACPI 3.0) */ +#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: [V4] All local APICs must use cluster model (ACPI 3.0) */ +#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local xAPICs must use physical dest mode (ACPI 3.0) */ -/* - * FADT Prefered Power Management Profiles - */ +/* Values for PreferredProfile (Prefered Power Management Profiles) */ + enum AcpiPreferedPmProfiles { PM_UNSPECIFIED = 0, @@ -370,23 +399,50 @@ enum AcpiPreferedPmProfiles }; -/* FADT Boot Arch Flags */ - -#define BAF_LEGACY_DEVICES 0x0001 -#define BAF_8042_KEYBOARD_CONTROLLER 0x0002 - -#define FADT2_REVISION_ID 3 -#define FADT2_MINUS_REVISION_ID 2 - - /* Reset to default packing */ #pragma pack() + +/* + * Internal table-related structures + */ +typedef union acpi_name_union +{ + UINT32 Integer; + char Ascii[4]; + +} ACPI_NAME_UNION; + + +/* Internal ACPI Table Descriptor. One per ACPI table. */ + +typedef struct acpi_table_desc +{ + ACPI_PHYSICAL_ADDRESS Address; + ACPI_TABLE_HEADER *Pointer; + UINT32 Length; /* Length fixed at 32 bits */ + ACPI_NAME_UNION Signature; + ACPI_OWNER_ID OwnerId; + UINT8 Flags; + +} ACPI_TABLE_DESC; + +/* Masks for Flags field above */ + +#define ACPI_TABLE_ORIGIN_UNKNOWN (0) +#define ACPI_TABLE_ORIGIN_MAPPED (1) +#define ACPI_TABLE_ORIGIN_ALLOCATED (2) +#define ACPI_TABLE_ORIGIN_OVERRIDE (4) +#define ACPI_TABLE_ORIGIN_MASK (7) +#define ACPI_TABLE_IS_LOADED (8) + + /* * Get the remaining ACPI tables */ #include "actbl1.h" +#include "actbl2.h" /* Macros used to generate offsets to specific table fields */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/actbl1.h b/src/add-ons/kernel/bus_managers/acpi/include/actbl1.h index 339e1abfc1..8af7a18380 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/actbl1.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/actbl1.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: actbl1.h - Additional ACPI table definitions - * $Revision: 1.51 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -120,42 +119,32 @@ /******************************************************************************* * - * Additional ACPI Tables + * Additional ACPI Tables (1) * * These tables are not consumed directly by the ACPICA subsystem, but are * included here to support device drivers and the AML disassembler. * + * The tables in this file are fully defined within the ACPI specification. + * ******************************************************************************/ /* - * Values for description table header signatures. Useful because they make - * it more difficult to inadvertently type in the wrong signature. + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. */ -#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ #define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ -#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ #define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */ -#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ -#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ #define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ #define ACPI_SIG_EINJ "EINJ" /* Error Injection table */ #define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */ #define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */ -#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ -#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ #define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ -#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ #define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ -#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ #define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ -#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ -#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ #define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ -#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ -#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ -#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ -#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ /* @@ -171,7 +160,13 @@ */ -/* Common Subtable header (used in MADT, SRAT, etc.) */ +/******************************************************************************* + * + * Common subtable headers + * + ******************************************************************************/ + +/* Generic subtable header (used in MADT, SRAT, etc.) */ typedef struct acpi_subtable_header { @@ -181,7 +176,7 @@ typedef struct acpi_subtable_header } ACPI_SUBTABLE_HEADER; -/* Common Subtable header for WHEA tables (EINJ, ERST, WDAT) */ +/* Subtable header for WHEA tables (EINJ, ERST, WDAT) */ typedef struct acpi_whea_header { @@ -198,138 +193,8 @@ typedef struct acpi_whea_header /******************************************************************************* * - * ASF - Alert Standard Format table (Signature "ASF!") - * - * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 - * - ******************************************************************************/ - -typedef struct acpi_table_asf -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - -} ACPI_TABLE_ASF; - - -/* ASF subtable header */ - -typedef struct acpi_asf_header -{ - UINT8 Type; - UINT8 Reserved; - UINT16 Length; - -} ACPI_ASF_HEADER; - - -/* Values for Type field above */ - -enum AcpiAsfType -{ - ACPI_ASF_TYPE_INFO = 0, - ACPI_ASF_TYPE_ALERT = 1, - ACPI_ASF_TYPE_CONTROL = 2, - ACPI_ASF_TYPE_BOOT = 3, - ACPI_ASF_TYPE_ADDRESS = 4, - ACPI_ASF_TYPE_RESERVED = 5 -}; - -/* - * ASF subtables - */ - -/* 0: ASF Information */ - -typedef struct acpi_asf_info -{ - ACPI_ASF_HEADER Header; - UINT8 MinResetValue; - UINT8 MinPollInterval; - UINT16 SystemId; - UINT32 MfgId; - UINT8 Flags; - UINT8 Reserved2[3]; - -} ACPI_ASF_INFO; - -/* 1: ASF Alerts */ - -typedef struct acpi_asf_alert -{ - ACPI_ASF_HEADER Header; - UINT8 AssertMask; - UINT8 DeassertMask; - UINT8 Alerts; - UINT8 DataLength; - -} ACPI_ASF_ALERT; - -typedef struct acpi_asf_alert_data -{ - UINT8 Address; - UINT8 Command; - UINT8 Mask; - UINT8 Value; - UINT8 SensorType; - UINT8 Type; - UINT8 Offset; - UINT8 SourceType; - UINT8 Severity; - UINT8 SensorNumber; - UINT8 Entity; - UINT8 Instance; - -} ACPI_ASF_ALERT_DATA; - -/* 2: ASF Remote Control */ - -typedef struct acpi_asf_remote -{ - ACPI_ASF_HEADER Header; - UINT8 Controls; - UINT8 DataLength; - UINT16 Reserved2; - -} ACPI_ASF_REMOTE; - -typedef struct acpi_asf_control_data -{ - UINT8 Function; - UINT8 Address; - UINT8 Command; - UINT8 Value; - -} ACPI_ASF_CONTROL_DATA; - -/* 3: ASF RMCP Boot Options */ - -typedef struct acpi_asf_rmcp -{ - ACPI_ASF_HEADER Header; - UINT8 Capabilities[7]; - UINT8 CompletionCode; - UINT32 EnterpriseId; - UINT8 Command; - UINT16 Parameter; - UINT16 BootOptions; - UINT16 OemParameters; - -} ACPI_ASF_RMCP; - -/* 4: ASF Address */ - -typedef struct acpi_asf_address -{ - ACPI_ASF_HEADER Header; - UINT8 EpromAddress; - UINT8 Devices; - -} ACPI_ASF_ADDRESS; - - -/******************************************************************************* - * - * BERT - Boot Error Record Table + * BERT - Boot Error Record Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -342,44 +207,47 @@ typedef struct acpi_table_bert } ACPI_TABLE_BERT; -/* Boot Error Region */ +/* Boot Error Region (not a subtable, pointed to by Address field above) */ typedef struct acpi_bert_region { - UINT32 BlockStatus; - UINT32 RawDataOffset; - UINT32 RawDataLength; - UINT32 DataLength; - UINT32 ErrorSeverity; + UINT32 BlockStatus; /* Type of error information */ + UINT32 RawDataOffset; /* Offset to raw error data */ + UINT32 RawDataLength; /* Length of raw error data */ + UINT32 DataLength; /* Length of generic error data */ + UINT32 ErrorSeverity; /* Severity code */ } ACPI_BERT_REGION; -/* BlockStatus Flags */ +/* Values for BlockStatus flags above */ #define ACPI_BERT_UNCORRECTABLE (1) -#define ACPI_BERT_CORRECTABLE (2) -#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (4) -#define ACPI_BERT_MULTIPLE_CORRECTABLE (8) +#define ACPI_BERT_CORRECTABLE (1<<1) +#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_BERT_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_BERT_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ +/* Values for ErrorSeverity above */ -/******************************************************************************* - * - * BOOT - Simple Boot Flag Table - * - ******************************************************************************/ - -typedef struct acpi_table_boot +enum AcpiBertErrorSeverity { - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ - UINT8 Reserved[3]; + ACPI_BERT_ERROR_CORRECTABLE = 0, + ACPI_BERT_ERROR_FATAL = 1, + ACPI_BERT_ERROR_CORRECTED = 2, + ACPI_BERT_ERROR_NONE = 3, + ACPI_BERT_ERROR_RESERVED = 4 /* 4 and greater are reserved */ +}; -} ACPI_TABLE_BOOT; +/* + * Note: The generic error data that follows the ErrorSeverity field above + * uses the ACPI_HEST_GENERIC_DATA defined under the HEST table below + */ /******************************************************************************* * - * CPEP - Corrected Platform Error Polling table + * CPEP - Corrected Platform Error Polling table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -395,8 +263,7 @@ typedef struct acpi_table_cpep typedef struct acpi_cpep_polling { - UINT8 Type; - UINT8 Length; + ACPI_SUBTABLE_HEADER Header; UINT8 Id; /* Processor ID */ UINT8 Eid; /* Processor EID */ UINT32 Interval; /* Polling interval (msec) */ @@ -404,145 +271,10 @@ typedef struct acpi_cpep_polling } ACPI_CPEP_POLLING; -/******************************************************************************* - * - * DBGP - Debug Port table - * - ******************************************************************************/ - -typedef struct acpi_table_dbgp -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ - UINT8 Reserved[3]; - ACPI_GENERIC_ADDRESS DebugPort; - -} ACPI_TABLE_DBGP; - - -/******************************************************************************* - * - * DMAR - DMA Remapping table - * From "Intel Virtualization Technology for Directed I/O", Sept. 2007 - * - ******************************************************************************/ - -typedef struct acpi_table_dmar -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Width; /* Host Address Width */ - UINT8 Flags; - UINT8 Reserved[10]; - -} ACPI_TABLE_DMAR; - -/* Flags */ - -#define ACPI_DMAR_INTR_REMAP (1) - -/* DMAR subtable header */ - -typedef struct acpi_dmar_header -{ - UINT16 Type; - UINT16 Length; - -} ACPI_DMAR_HEADER; - -/* Values for subtable type in ACPI_DMAR_HEADER */ - -enum AcpiDmarType -{ - ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, - ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, - ACPI_DMAR_TYPE_ATSR = 2, - ACPI_DMAR_TYPE_RESERVED = 3 /* 3 and greater are reserved */ -}; - -typedef struct acpi_dmar_device_scope -{ - UINT8 EntryType; - UINT8 Length; - UINT16 Reserved; - UINT8 EnumerationId; - UINT8 Bus; - -} ACPI_DMAR_DEVICE_SCOPE; - -/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ - -enum AcpiDmarScopeType -{ - ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, - ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, - ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, - ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, - ACPI_DMAR_SCOPE_TYPE_HPET = 4, - ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ -}; - -typedef struct acpi_dmar_pci_path -{ - UINT8 Device; - UINT8 Function; - -} ACPI_DMAR_PCI_PATH; - -/* - * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER - */ - -/* 0: Hardware Unit Definition */ - -typedef struct acpi_dmar_hardware_unit -{ - ACPI_DMAR_HEADER Header; - UINT8 Flags; - UINT8 Reserved; - UINT16 Segment; - UINT64 Address; /* Register Base Address */ - -} ACPI_DMAR_HARDWARE_UNIT; - -/* Flags */ - -#define ACPI_DMAR_INCLUDE_ALL (1) - -/* 1: Reserved Memory Defininition */ - -typedef struct acpi_dmar_reserved_memory -{ - ACPI_DMAR_HEADER Header; - UINT16 Reserved; - UINT16 Segment; - UINT64 BaseAddress; /* 4K aligned base address */ - UINT64 EndAddress; /* 4K aligned limit address */ - -} ACPI_DMAR_RESERVED_MEMORY; - -/* Flags */ - -#define ACPI_DMAR_ALLOW_ALL (1) - -/* 2: Root Port ATS Capability Reporting Structure */ - -typedef struct acpi_dmar_atsr -{ - ACPI_DMAR_HEADER Header; - UINT8 Flags; - UINT8 Reserved; - UINT16 Segment; - -} ACPI_DMAR_ATSR; - -/* Flags */ - -#define ACPI_DMAR_ALL_PORTS (1) - - /******************************************************************************* * * ECDT - Embedded Controller Boot Resources Table + * Version 1 * ******************************************************************************/ @@ -560,7 +292,8 @@ typedef struct acpi_table_ecdt /******************************************************************************* * - * EINJ - Error Injection Table + * EINJ - Error Injection Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -568,11 +301,13 @@ typedef struct acpi_table_einj { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ UINT32 HeaderLength; - UINT32 Reserved; + UINT8 Flags; + UINT8 Reserved[3]; UINT32 Entries; } ACPI_TABLE_EINJ; + /* EINJ Injection Instruction Entries (actions) */ typedef struct acpi_einj_entry @@ -581,6 +316,10 @@ typedef struct acpi_einj_entry } ACPI_EINJ_ENTRY; +/* Masks for Flags field above */ + +#define ACPI_EINJ_PRESERVE (1) + /* Values for Action field above */ enum AcpiEinjActions @@ -609,6 +348,7 @@ enum AcpiEinjInstructions ACPI_EINJ_INSTRUCTION_RESERVED = 5 /* 5 and greater are reserved */ }; + /* EINJ Trigger Error Action Table */ typedef struct acpi_einj_trigger @@ -620,10 +360,37 @@ typedef struct acpi_einj_trigger } ACPI_EINJ_TRIGGER; +/* Command status return values */ + +enum AcpiEinjCommandStatus +{ + ACPI_EINJ_SUCCESS = 0, + ACPI_EINJ_FAILURE = 1, + ACPI_EINJ_INVALID_ACCESS = 2, + ACPI_EINJ_STATUS_RESERVED = 3 /* 3 and greater are reserved */ +}; + + +/* Error types returned from ACPI_EINJ_GET_ERROR_TYPE (bitfield) */ + +#define ACPI_EINJ_PROCESSOR_CORRECTABLE (1) +#define ACPI_EINJ_PROCESSOR_UNCORRECTABLE (1<<1) +#define ACPI_EINJ_PROCESSOR_FATAL (1<<2) +#define ACPI_EINJ_MEMORY_CORRECTABLE (1<<3) +#define ACPI_EINJ_MEMORY_UNCORRECTABLE (1<<4) +#define ACPI_EINJ_MEMORY_FATAL (1<<5) +#define ACPI_EINJ_PCIX_CORRECTABLE (1<<6) +#define ACPI_EINJ_PCIX_UNCORRECTABLE (1<<7) +#define ACPI_EINJ_PCIX_FATAL (1<<8) +#define ACPI_EINJ_PLATFORM_CORRECTABLE (1<<9) +#define ACPI_EINJ_PLATFORM_UNCORRECTABLE (1<<10) +#define ACPI_EINJ_PLATFORM_FATAL (1<<11) + /******************************************************************************* * - * ERST - Error Record Serialization Table + * ERST - Error Record Serialization Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -636,6 +403,7 @@ typedef struct acpi_table_erst } ACPI_TABLE_ERST; + /* ERST Serialization Entries (actions) */ typedef struct acpi_erst_entry @@ -644,20 +412,24 @@ typedef struct acpi_erst_entry } ACPI_ERST_ENTRY; +/* Masks for Flags field above */ + +#define ACPI_ERST_PRESERVE (1) + /* Values for Action field above */ enum AcpiErstActions { - ACPI_ERST_BEGIN_WRITE_OPERATION = 0, - ACPI_ERST_BEGIN_READ_OPERATION = 1, - ACPI_ERST_BETGIN_CLEAR_OPERATION= 2, - ACPI_ERST_END_OPERATION = 3, + ACPI_ERST_BEGIN_WRITE = 0, + ACPI_ERST_BEGIN_READ = 1, + ACPI_ERST_BEGIN_CLEAR = 2, + ACPI_ERST_END = 3, ACPI_ERST_SET_RECORD_OFFSET = 4, ACPI_ERST_EXECUTE_OPERATION = 5, ACPI_ERST_CHECK_BUSY_STATUS = 6, ACPI_ERST_GET_COMMAND_STATUS = 7, - ACPI_ERST_GET_RECORD_IDENTIFIER = 8, - ACPI_ERST_SET_RECORD_IDENTIFIER = 9, + ACPI_ERST_GET_RECORD_ID = 8, + ACPI_ERST_SET_RECORD_ID = 9, ACPI_ERST_GET_RECORD_COUNT = 10, ACPI_ERST_BEGIN_DUMMY_WRIITE = 11, ACPI_ERST_NOT_USED = 12, @@ -693,10 +465,34 @@ enum AcpiErstInstructions ACPI_ERST_INSTRUCTION_RESERVED = 19 /* 19 and greater are reserved */ }; +/* Command status return values */ + +enum AcpiErstCommandStatus +{ + ACPI_ERST_SUCESS = 0, + ACPI_ERST_NO_SPACE = 1, + ACPI_ERST_NOT_AVAILABLE = 2, + ACPI_ERST_FAILURE = 3, + ACPI_ERST_RECORD_EMPTY = 4, + ACPI_ERST_NOT_FOUND = 5, + ACPI_ERST_STATUS_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* Error Record Serialization Information */ + +typedef struct acpi_erst_info +{ + UINT16 Signature; /* Should be "ER" */ + UINT8 Data[48]; + +} ACPI_ERST_INFO; + /******************************************************************************* * - * HEST - Hardware Error Source Table + * HEST - Hardware Error Source Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -713,6 +509,7 @@ typedef struct acpi_table_hest typedef struct acpi_hest_header { UINT16 Type; + UINT16 SourceId; } ACPI_HEST_HEADER; @@ -721,92 +518,69 @@ typedef struct acpi_hest_header enum AcpiHestTypes { - ACPI_HEST_TYPE_XPF_MACHINE_CHECK = 0, - ACPI_HEST_TYPE_XPF_CORRECTED_MACHINE_CHECK = 1, - ACPI_HEST_TYPE_XPF_UNUSED = 2, - ACPI_HEST_TYPE_XPF_NON_MASKABLE_INTERRUPT = 3, - ACPI_HEST_TYPE_IPF_CORRECTED_MACHINE_CHECK = 4, - ACPI_HEST_TYPE_IPF_CORRECTED_PLATFORM_ERROR = 5, - ACPI_HEST_TYPE_AER_ROOT_PORT = 6, - ACPI_HEST_TYPE_AER_ENDPOINT = 7, - ACPI_HEST_TYPE_AER_BRIDGE = 8, - ACPI_HEST_TYPE_GENERIC_HARDWARE_ERROR_SOURCE = 9, - ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ + ACPI_HEST_TYPE_IA32_CHECK = 0, + ACPI_HEST_TYPE_IA32_CORRECTED_CHECK = 1, + ACPI_HEST_TYPE_IA32_NMI = 2, + ACPI_HEST_TYPE_NOT_USED3 = 3, + ACPI_HEST_TYPE_NOT_USED4 = 4, + ACPI_HEST_TYPE_NOT_USED5 = 5, + ACPI_HEST_TYPE_AER_ROOT_PORT = 6, + ACPI_HEST_TYPE_AER_ENDPOINT = 7, + ACPI_HEST_TYPE_AER_BRIDGE = 8, + ACPI_HEST_TYPE_GENERIC_ERROR = 9, + ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ }; /* - * HEST Sub-subtables + * HEST substructures contained in subtables */ -/* XPF Machine Check Error Bank */ - -typedef struct acpi_hest_xpf_error_bank +/* + * IA32 Error Bank(s) - Follows the ACPI_HEST_IA_MACHINE_CHECK and + * ACPI_HEST_IA_CORRECTED structures. + */ +typedef struct acpi_hest_ia_error_bank { UINT8 BankNumber; UINT8 ClearStatusOnInit; UINT8 StatusFormat; - UINT8 ConfigWriteEnable; + UINT8 Reserved; UINT32 ControlRegister; - UINT64 ControlInitData; + UINT64 ControlData; UINT32 StatusRegister; UINT32 AddressRegister; UINT32 MiscRegister; -} ACPI_HEST_XPF_ERROR_BANK; +} ACPI_HEST_IA_ERROR_BANK; -/* Generic Error Status */ - -typedef struct acpi_hest_generic_status -{ - UINT32 BlockStatus; - UINT32 RawDataOffset; - UINT32 RawDataLength; - UINT32 DataLength; - UINT32 ErrorSeverity; - -} ACPI_HEST_GENERIC_STATUS; - - -/* Generic Error Data */ - -typedef struct acpi_hest_generic_data -{ - UINT8 SectionType[16]; - UINT32 ErrorSeverity; - UINT16 Revision; - UINT8 ValidationBits; - UINT8 Flags; - UINT32 ErrorDataLength; - UINT8 FruId[16]; - UINT8 FruText[20]; - -} ACPI_HEST_GENERIC_DATA; - - -/* Common HEST structure for PCI/AER types below (6,7,8) */ +/* Common HEST sub-structure for PCI/AER structures below (6,7,8) */ typedef struct acpi_hest_aer_common { - UINT16 SourceId; - UINT16 ConfigWriteEnable; + UINT16 Reserved1; UINT8 Flags; UINT8 Enabled; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT32 Bus; UINT16 Device; UINT16 Function; UINT16 DeviceControl; - UINT16 Reserved; - UINT32 UncorrectableErrorMask; - UINT32 UncorrectableErrorSeverity; - UINT32 CorrectableErrorMask; - UINT32 AdvancedErrorCababilities; + UINT16 Reserved2; + UINT32 UncorrectableMask; + UINT32 UncorrectableSeverity; + UINT32 CorrectableMask; + UINT32 AdvancedCapabilities; } ACPI_HEST_AER_COMMON; +/* Masks for HEST Flags fields */ + +#define ACPI_HEST_FIRMWARE_FIRST (1) +#define ACPI_HEST_GLOBAL (1<<1) + /* Hardware Error Notification */ @@ -836,87 +610,69 @@ enum AcpiHestNotifyTypes ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */ }; +/* Values for ConfigWriteEnable bitfield above */ + +#define ACPI_HEST_TYPE (1) +#define ACPI_HEST_POLL_INTERVAL (1<<1) +#define ACPI_HEST_POLL_THRESHOLD_VALUE (1<<2) +#define ACPI_HEST_POLL_THRESHOLD_WINDOW (1<<3) +#define ACPI_HEST_ERR_THRESHOLD_VALUE (1<<4) +#define ACPI_HEST_ERR_THRESHOLD_WINDOW (1<<5) + /* * HEST subtables - * - * From WHEA Design Document, 16 May 2007. - * Note: There is no subtable type 2 in this version of the document, - * and there are two different subtable type 3s. */ - /* 0: XPF Machine Check Exception */ +/* 0: IA32 Machine Check Exception */ -typedef struct acpi_hest_xpf_machine_check +typedef struct acpi_hest_ia_machine_check { ACPI_HEST_HEADER Header; - UINT16 SourceId; - UINT16 ConfigWriteEnable; + UINT16 Reserved1; UINT8 Flags; - UINT8 Reserved1; - UINT32 RecordsToPreAllocate; + UINT8 Enabled; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT64 GlobalCapabilityData; UINT64 GlobalControlData; UINT8 NumHardwareBanks; - UINT8 Reserved2[7]; + UINT8 Reserved3[7]; -} ACPI_HEST_XPF_MACHINE_CHECK; +} ACPI_HEST_IA_MACHINE_CHECK; -/* 1: XPF Corrected Machine Check */ +/* 1: IA32 Corrected Machine Check */ -typedef struct acpi_table_hest_xpf_corrected +typedef struct acpi_hest_ia_corrected { ACPI_HEST_HEADER Header; - UINT16 SourceId; - UINT16 ConfigWriteEnable; + UINT16 Reserved1; UINT8 Flags; UINT8 Enabled; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; ACPI_HEST_NOTIFY Notify; UINT8 NumHardwareBanks; - UINT8 Reserved[3]; + UINT8 Reserved2[3]; -} ACPI_HEST_XPF_CORRECTED; +} ACPI_HEST_IA_CORRECTED; -/* 3: XPF Non-Maskable Interrupt */ +/* 2: IA32 Non-Maskable Interrupt */ -typedef struct acpi_hest_xpf_nmi +typedef struct acpi_hest_ia_nmi { ACPI_HEST_HEADER Header; - UINT16 SourceId; UINT32 Reserved; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT32 MaxRawDataLength; -} ACPI_HEST_XPF_NMI; +} ACPI_HEST_IA_NMI; -/* 4: IPF Corrected Machine Check */ - -typedef struct acpi_hest_ipf_corrected -{ - ACPI_HEST_HEADER Header; - UINT8 Enabled; - UINT8 Reserved; - -} ACPI_HEST_IPF_CORRECTED; - - -/* 5: IPF Corrected Platform Error */ - -typedef struct acpi_hest_ipf_corrected_platform -{ - ACPI_HEST_HEADER Header; - UINT8 Enabled; - UINT8 Reserved; - -} ACPI_HEST_IPF_CORRECTED_PLATFORM; - +/* 3,4,5: Not used */ /* 6: PCI Express Root Port AER */ @@ -945,9 +701,9 @@ typedef struct acpi_hest_aer_bridge { ACPI_HEST_HEADER Header; ACPI_HEST_AER_COMMON Aer; - UINT32 SecondaryUncorrectableErrorMask; - UINT32 SecondaryUncorrectableErrorSeverity; - UINT32 SecondaryAdvancedCapabilities; + UINT32 UncorrectableMask2; + UINT32 UncorrectableSeverity2; + UINT32 AdvancedCapabilities2; } ACPI_HEST_AER_BRIDGE; @@ -957,156 +713,60 @@ typedef struct acpi_hest_aer_bridge typedef struct acpi_hest_generic { ACPI_HEST_HEADER Header; - UINT16 SourceId; UINT16 RelatedSourceId; - UINT8 ConfigWriteEnable; + UINT8 Reserved; UINT8 Enabled; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT32 MaxRawDataLength; ACPI_GENERIC_ADDRESS ErrorStatusAddress; ACPI_HEST_NOTIFY Notify; - UINT32 ErrorStatusBlockLength; + UINT32 ErrorBlockLength; } ACPI_HEST_GENERIC; -/******************************************************************************* - * - * HPET - High Precision Event Timer table - * - ******************************************************************************/ +/* Generic Error Status block */ -typedef struct acpi_table_hpet +typedef struct acpi_hest_generic_status { - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 Id; /* Hardware ID of event timer block */ - ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ - UINT8 Sequence; /* HPET sequence number */ - UINT16 MinimumTick; /* Main counter min tick, periodic mode */ + UINT32 BlockStatus; + UINT32 RawDataOffset; + UINT32 RawDataLength; + UINT32 DataLength; + UINT32 ErrorSeverity; + +} ACPI_HEST_GENERIC_STATUS; + +/* Values for BlockStatus flags above */ + +#define ACPI_HEST_UNCORRECTABLE (1) +#define ACPI_HEST_CORRECTABLE (1<<1) +#define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ + + +/* Generic Error Data entry */ + +typedef struct acpi_hest_generic_data +{ + UINT8 SectionType[16]; + UINT32 ErrorSeverity; + UINT16 Revision; + UINT8 ValidationBits; UINT8 Flags; + UINT32 ErrorDataLength; + UINT8 FruId[16]; + UINT8 FruText[20]; -} ACPI_TABLE_HPET; - -/*! Flags */ - -#define ACPI_HPET_PAGE_PROTECT (1) /* 00: No page protection */ -#define ACPI_HPET_PAGE_PROTECT_4 (1<<1) /* 01: 4KB page protected */ -#define ACPI_HPET_PAGE_PROTECT_64 (1<<2) /* 02: 64KB page protected */ - -/*! [End] no source code translation !*/ - - -/******************************************************************************* - * - * IBFT - Boot Firmware Table - * - ******************************************************************************/ - -typedef struct acpi_table_ibft -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Reserved[12]; - -} ACPI_TABLE_IBFT; - - -/* IBFT common subtable header */ - -typedef struct acpi_ibft_header -{ - UINT8 Type; - UINT8 Version; - UINT16 Length; - UINT8 Index; - UINT8 Flags; - -} ACPI_IBFT_HEADER; - - -/* Values for Type field above */ - -enum AcpiIbftType -{ - ACPI_IBFT_TYPE_NOT_USED = 0, - ACPI_IBFT_TYPE_CONTROL = 1, - ACPI_IBFT_TYPE_INITIATOR = 2, - ACPI_IBFT_TYPE_NIC = 3, - ACPI_IBFT_TYPE_TARGET = 4, - ACPI_IBFT_TYPE_EXTENSIONS = 5, - ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */ -}; - - -/* IBFT subtables */ - -typedef struct acpi_ibft_control -{ - ACPI_IBFT_HEADER Header; - UINT16 Extensions; - UINT16 InitiatorOffset; - UINT16 Nic0Offset; - UINT16 Target0Offset; - UINT16 Nic1Offset; - UINT16 Target1Offset; - -} ACPI_IBFT_CONTROL; - -typedef struct acpi_ibft_initiator -{ - ACPI_IBFT_HEADER Header; - UINT8 SnsServer[16]; - UINT8 SlpServer[16]; - UINT8 PrimaryServer[16]; - UINT8 SecondaryServer[16]; - UINT16 NameLength; - UINT16 NameOffset; - -} ACPI_IBFT_INITIATOR; - -typedef struct acpi_ibft_nic -{ - ACPI_IBFT_HEADER Header; - UINT8 IpAddress[16]; - UINT8 SubnetMaskPrefix; - UINT8 Origin; - UINT8 Gateway[16]; - UINT8 PrimaryDns[16]; - UINT8 SecondaryDns[16]; - UINT8 Dhcp[16]; - UINT16 Vlan; - UINT8 MacAddress[6]; - UINT16 PciAddress; - UINT16 NameLength; - UINT16 NameOffset; - -} ACPI_IBFT_NIC; - -typedef struct acpi_ibft_target -{ - ACPI_IBFT_HEADER Header; - UINT8 TargetIpAddress[16]; - UINT16 TargetIpSocket; - UINT8 TargetBootLun[8]; - UINT8 ChapType; - UINT8 NicAssociation; - UINT16 TargetNameLength; - UINT16 TargetNameOffset; - UINT16 ChapNameLength; - UINT16 ChapNameOffset; - UINT16 ChapSecretLength; - UINT16 ChapSecretOffset; - UINT16 ReverseChapNameLength; - UINT16 ReverseChapNameOffset; - UINT16 ReverseChapSecretLength; - UINT16 ReverseChapSecretOffset; - -} ACPI_IBFT_TARGET; +} ACPI_HEST_GENERIC_DATA; /******************************************************************************* * * MADT - Multiple APIC Description Table + * Version 3 * ******************************************************************************/ @@ -1118,9 +778,9 @@ typedef struct acpi_table_madt } ACPI_TABLE_MADT; -/* Flags */ +/* Masks for Flags field above */ -#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ +#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ /* Values for PCATCompat flag */ @@ -1128,7 +788,7 @@ typedef struct acpi_table_madt #define ACPI_MADT_MULTIPLE_APIC 1 -/* Values for subtable type in ACPI_SUBTABLE_HEADER */ +/* Values for MADT subtable type in ACPI_SUBTABLE_HEADER */ enum AcpiMadtType { @@ -1141,7 +801,9 @@ enum AcpiMadtType ACPI_MADT_TYPE_IO_SAPIC = 6, ACPI_MADT_TYPE_LOCAL_SAPIC = 7, ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, - ACPI_MADT_TYPE_RESERVED = 9 /* 9 and greater are reserved */ + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_RESERVED = 11 /* 11 and greater are reserved */ }; @@ -1160,6 +822,7 @@ typedef struct acpi_madt_local_apic } ACPI_MADT_LOCAL_APIC; + /* 1: IO APIC */ typedef struct acpi_madt_io_apic @@ -1172,6 +835,7 @@ typedef struct acpi_madt_io_apic } ACPI_MADT_IO_APIC; + /* 2: Interrupt Override */ typedef struct acpi_madt_interrupt_override @@ -1184,6 +848,7 @@ typedef struct acpi_madt_interrupt_override } ACPI_MADT_INTERRUPT_OVERRIDE; + /* 3: NMI Source */ typedef struct acpi_madt_nmi_source @@ -1194,6 +859,7 @@ typedef struct acpi_madt_nmi_source } ACPI_MADT_NMI_SOURCE; + /* 4: Local APIC NMI */ typedef struct acpi_madt_local_apic_nmi @@ -1205,6 +871,7 @@ typedef struct acpi_madt_local_apic_nmi } ACPI_MADT_LOCAL_APIC_NMI; + /* 5: Address Override */ typedef struct acpi_madt_local_apic_override @@ -1215,6 +882,7 @@ typedef struct acpi_madt_local_apic_override } ACPI_MADT_LOCAL_APIC_OVERRIDE; + /* 6: I/O Sapic */ typedef struct acpi_madt_io_sapic @@ -1227,6 +895,7 @@ typedef struct acpi_madt_io_sapic } ACPI_MADT_IO_SAPIC; + /* 7: Local Sapic */ typedef struct acpi_madt_local_sapic @@ -1242,6 +911,7 @@ typedef struct acpi_madt_local_sapic } ACPI_MADT_LOCAL_SAPIC; + /* 8: Platform Interrupt Source */ typedef struct acpi_madt_interrupt_source @@ -1257,11 +927,37 @@ typedef struct acpi_madt_interrupt_source } ACPI_MADT_INTERRUPT_SOURCE; -/* Flags field above */ +/* Masks for Flags field above */ #define ACPI_MADT_CPEI_OVERRIDE (1) +/* 9: Processor Local X2APIC (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 LocalApicId; /* Processor x2APIC ID */ + UINT32 LapicFlags; + UINT32 Uid; /* ACPI processor UID */ + +} ACPI_MADT_LOCAL_X2APIC; + + +/* 10: Local X2APIC NMI (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 Uid; /* ACPI processor UID */ + UINT8 Lint; /* LINTn to which NMI is connected */ + UINT8 Reserved[3]; /* Reserved - must be zero */ + +} ACPI_MADT_LOCAL_X2APIC_NMI; + + /* * Common flags fields for MADT subtables */ @@ -1290,34 +986,40 @@ typedef struct acpi_madt_interrupt_source /******************************************************************************* * - * MCFG - PCI Memory Mapped Configuration table and sub-table + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ -typedef struct acpi_table_mcfg +typedef struct acpi_table_msct { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Reserved[8]; + UINT32 ProximityOffset; /* Location of proximity info struct(s) */ + UINT32 MaxProximityDomains;/* Max number of proximity domains */ + UINT32 MaxClockDomains; /* Max number of clock domains */ + UINT64 MaxAddress; /* Max physical address in system */ -} ACPI_TABLE_MCFG; +} ACPI_TABLE_MSCT; -/* Subtable */ +/* Subtable - Maximum Proximity Domain Information. Version 1 */ -typedef struct acpi_mcfg_allocation +typedef struct acpi_msct_proximity { - UINT64 Address; /* Base address, processor-relative */ - UINT16 PciSegment; /* PCI segment group number */ - UINT8 StartBusNumber; /* Starting PCI Bus number */ - UINT8 EndBusNumber; /* Final PCI Bus number */ - UINT32 Reserved; + UINT8 Revision; + UINT8 Length; + UINT32 RangeStart; /* Start of domain range */ + UINT32 RangeEnd; /* End of domain range */ + UINT32 ProcessorCapacity; + UINT64 MemoryCapacity; /* In bytes */ -} ACPI_MCFG_ALLOCATION; +} ACPI_MSCT_PROXIMITY; /******************************************************************************* * * SBST - Smart Battery Specification Table + * Version 1 * ******************************************************************************/ @@ -1334,6 +1036,7 @@ typedef struct acpi_table_sbst /******************************************************************************* * * SLIT - System Locality Distance Information Table + * Version 1 * ******************************************************************************/ @@ -1346,68 +1049,10 @@ typedef struct acpi_table_slit } ACPI_TABLE_SLIT; -/******************************************************************************* - * - * SPCR - Serial Port Console Redirection table - * - ******************************************************************************/ - -typedef struct acpi_table_spcr -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ - UINT8 Reserved[3]; - ACPI_GENERIC_ADDRESS SerialPort; - UINT8 InterruptType; - UINT8 PcInterrupt; - UINT32 Interrupt; - UINT8 BaudRate; - UINT8 Parity; - UINT8 StopBits; - UINT8 FlowControl; - UINT8 TerminalType; - UINT8 Reserved1; - UINT16 PciDeviceId; - UINT16 PciVendorId; - UINT8 PciBus; - UINT8 PciDevice; - UINT8 PciFunction; - UINT32 PciFlags; - UINT8 PciSegment; - UINT32 Reserved2; - -} ACPI_TABLE_SPCR; - - -/******************************************************************************* - * - * SPMI - Server Platform Management Interface table - * - ******************************************************************************/ - -typedef struct acpi_table_spmi -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Reserved; - UINT8 InterfaceType; - UINT16 SpecRevision; /* Version of IPMI */ - UINT8 InterruptType; - UINT8 GpeNumber; /* GPE assigned */ - UINT8 Reserved1; - UINT8 PciDeviceFlag; - UINT32 Interrupt; - ACPI_GENERIC_ADDRESS IpmiRegister; - UINT8 PciSegment; - UINT8 PciBus; - UINT8 PciDevice; - UINT8 PciFunction; - -} ACPI_TABLE_SPMI; - - /******************************************************************************* * * SRAT - System Resource Affinity Table + * Version 3 * ******************************************************************************/ @@ -1423,12 +1068,17 @@ typedef struct acpi_table_srat enum AcpiSratType { - ACPI_SRAT_TYPE_CPU_AFFINITY = 0, - ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, - ACPI_SRAT_TYPE_RESERVED = 2 + ACPI_SRAT_TYPE_CPU_AFFINITY = 0, + ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, + ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, + ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ }; -/* SRAT sub-tables */ +/* + * SRAT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC/SAPIC Affinity */ typedef struct acpi_srat_cpu_affinity { @@ -1444,9 +1094,11 @@ typedef struct acpi_srat_cpu_affinity /* Flags */ -#define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ +#define ACPI_SRAT_CPU_USE_AFFINITY (1) /* 00: Use affinity structure */ +/* 1: Memory Affinity */ + typedef struct acpi_srat_mem_affinity { ACPI_SUBTABLE_HEADER Header; @@ -1467,130 +1119,23 @@ typedef struct acpi_srat_mem_affinity #define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ -/******************************************************************************* - * - * TCPA - Trusted Computing Platform Alliance table - * - ******************************************************************************/ +/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ -typedef struct acpi_table_tcpa +typedef struct acpi_srat_x2apic_cpu_affinity { - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT16 Reserved; - UINT32 MaxLogLength; /* Maximum length for the event log area */ - UINT64 LogAddress; /* Address of the event log area */ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT32 ProximityDomain; + UINT32 ApicId; + UINT32 Flags; + UINT32 ClockDomain; + UINT32 Reserved2; -} ACPI_TABLE_TCPA; +} ACPI_SRAT_X2APIC_CPU_AFFINITY; +/* Flags for ACPI_SRAT_CPU_AFFINITY and ACPI_SRAT_X2APIC_CPU_AFFINITY */ -/******************************************************************************* - * - * UEFI - UEFI Boot optimization Table - * - ******************************************************************************/ - -typedef struct acpi_table_uefi -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Identifier[16]; /* UUID identifier */ - UINT16 DataOffset; /* Offset of remaining data in table */ - UINT8 Data; - -} ACPI_TABLE_UEFI; - - -/******************************************************************************* - * - * WDAT - Watchdog Action Table - * - ******************************************************************************/ - -typedef struct acpi_table_wdat -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 HeaderLength; /* Watchdog Header Length */ - UINT16 PciSegment; /* PCI Segment number */ - UINT8 PciBus; /* PCI Bus number */ - UINT8 PciDevice; /* PCI Device number */ - UINT8 PciFunction; /* PCI Function number */ - UINT8 Reserved[3]; - UINT32 TimerPeriod; /* Period of one timer count (msec) */ - UINT32 MaxCount; /* Maximum counter value supported */ - UINT32 MinCount; /* Minimum counter value */ - UINT8 Flags; - UINT8 Reserved2[3]; - UINT32 Entries; /* Number of watchdog entries that follow */ - -} ACPI_TABLE_WDAT; - -/* WDAT Instruction Entries (actions) */ - -typedef struct acpi_wdat_entry -{ - ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ - -} ACPI_WDAT_ENTRY; - -/* Values for Action field above */ - -enum AcpiWdatActions -{ - ACPI_WDAT_RESET = 1, - ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4, - ACPI_WDAT_GET_COUNTDOWN = 5, - ACPI_WDAT_SET_COUNTDOWN = 6, - ACPI_WDAT_GET_RUNNING_STATE = 8, - ACPI_WDAT_SET_RUNNING_STATE = 9, - ACPI_WDAT_GET_STOPPED_STATE = 10, - ACPI_WDAT_SET_STOPPED_STATE = 11, - ACPI_WDAT_GET_REBOOT = 16, - ACPI_WDAT_SET_REBOOT = 17, - ACPI_WDAT_GET_SHUTDOWN = 18, - ACPI_WDAT_SET_SHUTDOWN = 19, - ACPI_WDAT_GET_STATUS = 32, - ACPI_WDAT_SET_STATUS = 33, - ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */ -}; - -/* Values for Instruction field above */ - -enum AcpiWdatInstructions -{ - ACPI_WDAT_READ_VALUE = 0, - ACPI_WDAT_READ_COUNTDOWN = 1, - ACPI_WDAT_WRITE_VALUE = 2, - ACPI_WDAT_WRITE_COUNTDOWN = 3, - ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */ - ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */ -}; - - -/******************************************************************************* - * - * WDRT - Watchdog Resource Table - * - ******************************************************************************/ - -typedef struct acpi_table_wdrt -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 HeaderLength; /* Watchdog Header Length */ - UINT8 PciSegment; /* PCI Segment number */ - UINT8 PciBus; /* PCI Bus number */ - UINT8 PciDevice; /* PCI Device number */ - UINT8 PciFunction; /* PCI Function number */ - UINT32 TimerPeriod; /* Period of one timer count (msec) */ - UINT32 MaxCount; /* Maximum counter value supported */ - UINT32 MinCount; /* Minimum counter value */ - UINT8 Flags; - UINT8 Reserved[3]; - UINT32 Entries; /* Number of watchdog entries that follow */ - -} ACPI_TABLE_WDRT; - -/* Flags */ - -#define ACPI_WDRT_TIMER_ENABLED (1) /* 00: Timer enabled */ +#define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ /* Reset to default packing */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/actbl2.h b/src/add-ons/kernel/bus_managers/acpi/include/actbl2.h index 0b6c47e9fa..e57c02356c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/actbl2.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/actbl2.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: actbl2.h - ACPI Specification Revision 2.0 Tables - * $Revision: 1.52 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +116,1009 @@ #ifndef __ACTBL2_H__ #define __ACTBL2_H__ -/* Code moved to both actbl.h and actbl1.h */ + +/******************************************************************************* + * + * Additional ACPI Tables (2) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are defined by third-party specifications, and are + * not defined directly by the ACPI specification itself. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ +#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ +#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ +#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ +#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ +#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ +#define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ +#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ +#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ +#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ +#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ +#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ +#define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ +#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ +#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ + + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * ASF - Alert Standard Format table (Signature "ASF!") + * Revision 0x10 + * + * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_asf +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_ASF; + + +/* ASF subtable header */ + +typedef struct acpi_asf_header +{ + UINT8 Type; + UINT8 Reserved; + UINT16 Length; + +} ACPI_ASF_HEADER; + + +/* Values for Type field above */ + +enum AcpiAsfType +{ + ACPI_ASF_TYPE_INFO = 0, + ACPI_ASF_TYPE_ALERT = 1, + ACPI_ASF_TYPE_CONTROL = 2, + ACPI_ASF_TYPE_BOOT = 3, + ACPI_ASF_TYPE_ADDRESS = 4, + ACPI_ASF_TYPE_RESERVED = 5 +}; + +/* + * ASF subtables + */ + +/* 0: ASF Information */ + +typedef struct acpi_asf_info +{ + ACPI_ASF_HEADER Header; + UINT8 MinResetValue; + UINT8 MinPollInterval; + UINT16 SystemId; + UINT32 MfgId; + UINT8 Flags; + UINT8 Reserved2[3]; + +} ACPI_ASF_INFO; + +/* Masks for Flags field above */ + +#define ACPI_ASF_SMBUS_PROTOCOLS (1) + + +/* 1: ASF Alerts */ + +typedef struct acpi_asf_alert +{ + ACPI_ASF_HEADER Header; + UINT8 AssertMask; + UINT8 DeassertMask; + UINT8 Alerts; + UINT8 DataLength; + +} ACPI_ASF_ALERT; + +typedef struct acpi_asf_alert_data +{ + UINT8 Address; + UINT8 Command; + UINT8 Mask; + UINT8 Value; + UINT8 SensorType; + UINT8 Type; + UINT8 Offset; + UINT8 SourceType; + UINT8 Severity; + UINT8 SensorNumber; + UINT8 Entity; + UINT8 Instance; + +} ACPI_ASF_ALERT_DATA; + + +/* 2: ASF Remote Control */ + +typedef struct acpi_asf_remote +{ + ACPI_ASF_HEADER Header; + UINT8 Controls; + UINT8 DataLength; + UINT16 Reserved2; + +} ACPI_ASF_REMOTE; + +typedef struct acpi_asf_control_data +{ + UINT8 Function; + UINT8 Address; + UINT8 Command; + UINT8 Value; + +} ACPI_ASF_CONTROL_DATA; + + +/* 3: ASF RMCP Boot Options */ + +typedef struct acpi_asf_rmcp +{ + ACPI_ASF_HEADER Header; + UINT8 Capabilities[7]; + UINT8 CompletionCode; + UINT32 EnterpriseId; + UINT8 Command; + UINT16 Parameter; + UINT16 BootOptions; + UINT16 OemParameters; + +} ACPI_ASF_RMCP; + + +/* 4: ASF Address */ + +typedef struct acpi_asf_address +{ + ACPI_ASF_HEADER Header; + UINT8 EpromAddress; + UINT8 Devices; + +} ACPI_ASF_ADDRESS; + + +/******************************************************************************* + * + * BOOT - Simple Boot Flag Table + * Version 1 + * + * Conforms to the "Simple Boot Flag Specification", Version 2.1 + * + ******************************************************************************/ + +typedef struct acpi_table_boot +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ + UINT8 Reserved[3]; + +} ACPI_TABLE_BOOT; + + +/******************************************************************************* + * + * DBGP - Debug Port table + * Version 1 + * + * Conforms to the "Debug Port Specification", Version 1.00, 2/9/2000 + * + ******************************************************************************/ + +typedef struct acpi_table_dbgp +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS DebugPort; + +} ACPI_TABLE_DBGP; + + +/******************************************************************************* + * + * DMAR - DMA Remapping table + * Version 1 + * + * Conforms to "Intel Virtualization Technology for Directed I/O", + * Version 1.2, Sept. 2008 + * + ******************************************************************************/ + +typedef struct acpi_table_dmar +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Width; /* Host Address Width */ + UINT8 Flags; + UINT8 Reserved[10]; + +} ACPI_TABLE_DMAR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INTR_REMAP (1) + + +/* DMAR subtable header */ + +typedef struct acpi_dmar_header +{ + UINT16 Type; + UINT16 Length; + +} ACPI_DMAR_HEADER; + +/* Values for subtable type in ACPI_DMAR_HEADER */ + +enum AcpiDmarType +{ + ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, + ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, + ACPI_DMAR_TYPE_ATSR = 2, + ACPI_DMAR_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ +}; + + +/* DMAR Device Scope structure */ + +typedef struct acpi_dmar_device_scope +{ + UINT8 EntryType; + UINT8 Length; + UINT16 Reserved; + UINT8 EnumerationId; + UINT8 Bus; + +} ACPI_DMAR_DEVICE_SCOPE; + +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ + +enum AcpiDmarScopeType +{ + ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, + ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, + ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, + ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, + ACPI_DMAR_SCOPE_TYPE_HPET = 4, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +}; + +typedef struct acpi_dmar_pci_path +{ + UINT8 Device; + UINT8 Function; + +} ACPI_DMAR_PCI_PATH; + + +/* + * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER + */ + +/* 0: Hardware Unit Definition */ + +typedef struct acpi_dmar_hardware_unit +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + UINT64 Address; /* Register Base Address */ + +} ACPI_DMAR_HARDWARE_UNIT; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INCLUDE_ALL (1) + + +/* 1: Reserved Memory Defininition */ + +typedef struct acpi_dmar_reserved_memory +{ + ACPI_DMAR_HEADER Header; + UINT16 Reserved; + UINT16 Segment; + UINT64 BaseAddress; /* 4K aligned base address */ + UINT64 EndAddress; /* 4K aligned limit address */ + +} ACPI_DMAR_RESERVED_MEMORY; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALLOW_ALL (1) + + +/* 2: Root Port ATS Capability Reporting Structure */ + +typedef struct acpi_dmar_atsr +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + +} ACPI_DMAR_ATSR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALL_PORTS (1) + + +/* 3: Remapping Hardware Static Affinity Structure */ + +typedef struct acpi_dmar_rhsa +{ + ACPI_DMAR_HEADER Header; + UINT32 Reserved; + UINT64 BaseAddress; + UINT32 ProximityDomain; + +} ACPI_DMAR_RHSA; + + +/******************************************************************************* + * + * HPET - High Precision Event Timer table + * Version 1 + * + * Conforms to "IA-PC HPET (High Precision Event Timers) Specification", + * Version 1.0a, October 2004 + * + ******************************************************************************/ + +typedef struct acpi_table_hpet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Id; /* Hardware ID of event timer block */ + ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ + UINT8 Sequence; /* HPET sequence number */ + UINT16 MinimumTick; /* Main counter min tick, periodic mode */ + UINT8 Flags; + +} ACPI_TABLE_HPET; + +/* Masks for Flags field above */ + +#define ACPI_HPET_PAGE_PROTECT_MASK (3) + +/* Values for Page Protect flags */ + +enum AcpiHpetPageProtect +{ + ACPI_HPET_NO_PAGE_PROTECT = 0, + ACPI_HPET_PAGE_PROTECT4 = 1, + ACPI_HPET_PAGE_PROTECT64 = 2 +}; + + +/******************************************************************************* + * + * IBFT - Boot Firmware Table + * Version 1 + * + * Conforms to "iSCSI Boot Firmware Table (iBFT) as Defined in ACPI 3.0b + * Specification", Version 1.01, March 1, 2007 + * + * Note: It appears that this table is not intended to appear in the RSDT/XSDT. + * Therefore, it is not currently supported by the disassembler. + * + ******************************************************************************/ + +typedef struct acpi_table_ibft +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[12]; + +} ACPI_TABLE_IBFT; + + +/* IBFT common subtable header */ + +typedef struct acpi_ibft_header +{ + UINT8 Type; + UINT8 Version; + UINT16 Length; + UINT8 Index; + UINT8 Flags; + +} ACPI_IBFT_HEADER; + +/* Values for Type field above */ + +enum AcpiIbftType +{ + ACPI_IBFT_TYPE_NOT_USED = 0, + ACPI_IBFT_TYPE_CONTROL = 1, + ACPI_IBFT_TYPE_INITIATOR = 2, + ACPI_IBFT_TYPE_NIC = 3, + ACPI_IBFT_TYPE_TARGET = 4, + ACPI_IBFT_TYPE_EXTENSIONS = 5, + ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* IBFT subtables */ + +typedef struct acpi_ibft_control +{ + ACPI_IBFT_HEADER Header; + UINT16 Extensions; + UINT16 InitiatorOffset; + UINT16 Nic0Offset; + UINT16 Target0Offset; + UINT16 Nic1Offset; + UINT16 Target1Offset; + +} ACPI_IBFT_CONTROL; + +typedef struct acpi_ibft_initiator +{ + ACPI_IBFT_HEADER Header; + UINT8 SnsServer[16]; + UINT8 SlpServer[16]; + UINT8 PrimaryServer[16]; + UINT8 SecondaryServer[16]; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_INITIATOR; + +typedef struct acpi_ibft_nic +{ + ACPI_IBFT_HEADER Header; + UINT8 IpAddress[16]; + UINT8 SubnetMaskPrefix; + UINT8 Origin; + UINT8 Gateway[16]; + UINT8 PrimaryDns[16]; + UINT8 SecondaryDns[16]; + UINT8 Dhcp[16]; + UINT16 Vlan; + UINT8 MacAddress[6]; + UINT16 PciAddress; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_NIC; + +typedef struct acpi_ibft_target +{ + ACPI_IBFT_HEADER Header; + UINT8 TargetIpAddress[16]; + UINT16 TargetIpSocket; + UINT8 TargetBootLun[8]; + UINT8 ChapType; + UINT8 NicAssociation; + UINT16 TargetNameLength; + UINT16 TargetNameOffset; + UINT16 ChapNameLength; + UINT16 ChapNameOffset; + UINT16 ChapSecretLength; + UINT16 ChapSecretOffset; + UINT16 ReverseChapNameLength; + UINT16 ReverseChapNameOffset; + UINT16 ReverseChapSecretLength; + UINT16 ReverseChapSecretOffset; + +} ACPI_IBFT_TARGET; + + +/******************************************************************************* + * + * IVRS - I/O Virtualization Reporting Structure + * Version 1 + * + * Conforms to "AMD I/O Virtualization Technology (IOMMU) Specification", + * Revision 1.26, February 2009. + * + ******************************************************************************/ + +typedef struct acpi_table_ivrs +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Info; /* Common virtualization info */ + UINT64 Reserved; + +} ACPI_TABLE_IVRS; + +/* Values for Info field above */ + +#define ACPI_IVRS_PHYSICAL_SIZE 0x00007F00 /* 7 bits, physical address size */ +#define ACPI_IVRS_VIRTUAL_SIZE 0x003F8000 /* 7 bits, virtual address size */ +#define ACPI_IVRS_ATS_RESERVED 0x00400000 /* ATS address translation range reserved */ + + +/* IVRS subtable header */ + +typedef struct acpi_ivrs_header +{ + UINT8 Type; /* Subtable type */ + UINT8 Flags; + UINT16 Length; /* Subtable length */ + UINT16 DeviceId; /* ID of IOMMU */ + +} ACPI_IVRS_HEADER; + +/* Values for subtable Type above */ + +enum AcpiIvrsType +{ + ACPI_IVRS_TYPE_HARDWARE = 0x10, + ACPI_IVRS_TYPE_MEMORY1 = 0x20, + ACPI_IVRS_TYPE_MEMORY2 = 0x21, + ACPI_IVRS_TYPE_MEMORY3 = 0x22 +}; + +/* Masks for Flags field above for IVHD subtable */ + +#define ACPI_IVHD_TT_ENABLE (1) +#define ACPI_IVHD_PASS_PW (1<<1) +#define ACPI_IVHD_RES_PASS_PW (1<<2) +#define ACPI_IVHD_ISOC (1<<3) +#define ACPI_IVHD_IOTLB (1<<4) + +/* Masks for Flags field above for IVMD subtable */ + +#define ACPI_IVMD_UNITY (1) +#define ACPI_IVMD_READ (1<<1) +#define ACPI_IVMD_WRITE (1<<2) +#define ACPI_IVMD_EXCLUSION_RANGE (1<<3) + + +/* + * IVRS subtables, correspond to Type in ACPI_IVRS_HEADER + */ + +/* 0x10: I/O Virtualization Hardware Definition Block (IVHD) */ + +typedef struct acpi_ivrs_hardware +{ + ACPI_IVRS_HEADER Header; + UINT16 CapabilityOffset; /* Offset for IOMMU control fields */ + UINT64 BaseAddress; /* IOMMU control registers */ + UINT16 PciSegmentGroup; + UINT16 Info; /* MSI number and unit ID */ + UINT32 Reserved; + +} ACPI_IVRS_HARDWARE; + +/* Masks for Info field above */ + +#define ACPI_IVHD_MSI_NUMBER_MASK 0x001F /* 5 bits, MSI message number */ +#define ACPI_IVHD_UNIT_ID_MASK 0x1F00 /* 5 bits, UnitID */ + + +/* + * Device Entries for IVHD subtable, appear after ACPI_IVRS_HARDWARE structure. + * Upper two bits of the Type field are the (encoded) length of the structure. + * Currently, only 4 and 8 byte entries are defined. 16 and 32 byte entries + * are reserved for future use but not defined. + */ +typedef struct acpi_ivrs_de_header +{ + UINT8 Type; + UINT16 Id; + UINT8 DataSetting; + +} ACPI_IVRS_DE_HEADER; + +/* Length of device entry is in the top two bits of Type field above */ + +#define ACPI_IVHD_ENTRY_LENGTH 0xC0 + +/* Values for device entry Type field above */ + +enum AcpiIvrsDeviceEntryType +{ + /* 4-byte device entries, all use ACPI_IVRS_DEVICE4 */ + + ACPI_IVRS_TYPE_PAD4 = 0, + ACPI_IVRS_TYPE_ALL = 1, + ACPI_IVRS_TYPE_SELECT = 2, + ACPI_IVRS_TYPE_START = 3, + ACPI_IVRS_TYPE_END = 4, + + /* 8-byte device entries */ + + ACPI_IVRS_TYPE_PAD8 = 64, + ACPI_IVRS_TYPE_NOT_USED = 65, + ACPI_IVRS_TYPE_ALIAS_SELECT = 66, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_ALIAS_START = 67, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_EXT_SELECT = 70, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_EXT_START = 71, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_SPECIAL = 72 /* Uses ACPI_IVRS_DEVICE8C */ +}; + +/* Values for Data field above */ + +#define ACPI_IVHD_INIT_PASS (1) +#define ACPI_IVHD_EINT_PASS (1<<1) +#define ACPI_IVHD_NMI_PASS (1<<2) +#define ACPI_IVHD_SYSTEM_MGMT (3<<4) +#define ACPI_IVHD_LINT0_PASS (1<<6) +#define ACPI_IVHD_LINT1_PASS (1<<7) + + +/* Types 0-4: 4-byte device entry */ + +typedef struct acpi_ivrs_device4 +{ + ACPI_IVRS_DE_HEADER Header; + +} ACPI_IVRS_DEVICE4; + +/* Types 66-67: 8-byte device entry */ + +typedef struct acpi_ivrs_device8a +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Reserved1; + UINT16 UsedId; + UINT8 Reserved2; + +} ACPI_IVRS_DEVICE8A; + +/* Types 70-71: 8-byte device entry */ + +typedef struct acpi_ivrs_device8b +{ + ACPI_IVRS_DE_HEADER Header; + UINT32 ExtendedData; + +} ACPI_IVRS_DEVICE8B; + +/* Values for ExtendedData above */ + +#define ACPI_IVHD_ATS_DISABLED (1<<31) + +/* Type 72: 8-byte device entry */ + +typedef struct acpi_ivrs_device8c +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Handle; + UINT16 UsedId; + UINT8 Variety; + +} ACPI_IVRS_DEVICE8C; + +/* Values for Variety field above */ + +#define ACPI_IVHD_IOAPIC 1 +#define ACPI_IVHD_HPET 2 + + +/* 0x20, 0x21, 0x22: I/O Virtualization Memory Definition Block (IVMD) */ + +typedef struct acpi_ivrs_memory +{ + ACPI_IVRS_HEADER Header; + UINT16 AuxData; + UINT64 Reserved; + UINT64 StartAddress; + UINT64 MemoryLength; + +} ACPI_IVRS_MEMORY; + + +/******************************************************************************* + * + * MCFG - PCI Memory Mapped Configuration table and sub-table + * Version 1 + * + * Conforms to "PCI Firmware Specification", Revision 3.0, June 20, 2005 + * + ******************************************************************************/ + +typedef struct acpi_table_mcfg +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[8]; + +} ACPI_TABLE_MCFG; + + +/* Subtable */ + +typedef struct acpi_mcfg_allocation +{ + UINT64 Address; /* Base address, processor-relative */ + UINT16 PciSegment; /* PCI segment group number */ + UINT8 StartBusNumber; /* Starting PCI Bus number */ + UINT8 EndBusNumber; /* Final PCI Bus number */ + UINT32 Reserved; + +} ACPI_MCFG_ALLOCATION; + + +/******************************************************************************* + * + * SPCR - Serial Port Console Redirection table + * Version 1 + * + * Conforms to "Serial Port Console Redirection Table", + * Version 1.00, January 11, 2002 + * + ******************************************************************************/ + +typedef struct acpi_table_spcr +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS SerialPort; + UINT8 InterruptType; + UINT8 PcInterrupt; + UINT32 Interrupt; + UINT8 BaudRate; + UINT8 Parity; + UINT8 StopBits; + UINT8 FlowControl; + UINT8 TerminalType; + UINT8 Reserved1; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT32 PciFlags; + UINT8 PciSegment; + UINT32 Reserved2; + +} ACPI_TABLE_SPCR; + +/* Masks for PciFlags field above */ + +#define ACPI_SPCR_DO_NOT_DISABLE (1) + + +/******************************************************************************* + * + * SPMI - Server Platform Management Interface table + * Version 5 + * + * Conforms to "Intelligent Platform Management Interface Specification + * Second Generation v2.0", Document Revision 1.0, February 12, 2004 with + * June 12, 2009 markup. + * + ******************************************************************************/ + +typedef struct acpi_table_spmi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; + UINT8 Reserved; /* Must be 1 */ + UINT16 SpecRevision; /* Version of IPMI */ + UINT8 InterruptType; + UINT8 GpeNumber; /* GPE assigned */ + UINT8 Reserved1; + UINT8 PciDeviceFlag; + UINT32 Interrupt; + ACPI_GENERIC_ADDRESS IpmiRegister; + UINT8 PciSegment; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT8 Reserved2; + +} ACPI_TABLE_SPMI; + +/* Values for InterfaceType above */ + +enum AcpiSpmiInterfaceTypes +{ + ACPI_SPMI_NOT_USED = 0, + ACPI_SPMI_KEYBOARD = 1, + ACPI_SPMI_SMI = 2, + ACPI_SPMI_BLOCK_TRANSFER = 3, + ACPI_SPMI_SMBUS = 4, + ACPI_SPMI_RESERVED = 5 /* 5 and above are reserved */ +}; + + +/******************************************************************************* + * + * TCPA - Trusted Computing Platform Alliance table + * Version 1 + * + * Conforms to "TCG PC Specific Implementation Specification", + * Version 1.1, August 18, 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_tcpa +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 Reserved; + UINT32 MaxLogLength; /* Maximum length for the event log area */ + UINT64 LogAddress; /* Address of the event log area */ + +} ACPI_TABLE_TCPA; + + +/******************************************************************************* + * + * UEFI - UEFI Boot optimization Table + * Version 1 + * + * Conforms to "Unified Extensible Firmware Interface Specification", + * Version 2.3, May 8, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_uefi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Identifier[16]; /* UUID identifier */ + UINT16 DataOffset; /* Offset of remaining data in table */ + +} ACPI_TABLE_UEFI; + + +/******************************************************************************* + * + * WAET - Windows ACPI Emulated devices Table + * Version 1 + * + * Conforms to "Windows ACPI Emulated Devices Table", version 1.0, April 6, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_waet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Flags; + +} ACPI_TABLE_WAET; + +/* Masks for Flags field above */ + +#define ACPI_WAET_RTC_NO_ACK (1) /* RTC requires no int acknowledge */ +#define ACPI_WAET_TIMER_ONE_READ (1<<1) /* PM timer requires only one read */ + + +/******************************************************************************* + * + * WDAT - Watchdog Action Table + * Version 1 + * + * Conforms to "Hardware Watchdog Timers Design Specification", + * Copyright 2006 Microsoft Corporation. + * + ******************************************************************************/ + +typedef struct acpi_table_wdat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; /* Watchdog Header Length */ + UINT16 PciSegment; /* PCI Segment number */ + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 Reserved[3]; + UINT32 TimerPeriod; /* Period of one timer count (msec) */ + UINT32 MaxCount; /* Maximum counter value supported */ + UINT32 MinCount; /* Minimum counter value */ + UINT8 Flags; + UINT8 Reserved2[3]; + UINT32 Entries; /* Number of watchdog entries that follow */ + +} ACPI_TABLE_WDAT; + +/* Masks for Flags field above */ + +#define ACPI_WDAT_ENABLED (1) +#define ACPI_WDAT_STOPPED 0x80 + + +/* WDAT Instruction Entries (actions) */ + +typedef struct acpi_wdat_entry +{ + UINT8 Action; + UINT8 Instruction; + UINT16 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT32 Value; /* Value used with Read/Write register */ + UINT32 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WDAT_ENTRY; + +/* Values for Action field above */ + +enum AcpiWdatActions +{ + ACPI_WDAT_RESET = 1, + ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4, + ACPI_WDAT_GET_COUNTDOWN = 5, + ACPI_WDAT_SET_COUNTDOWN = 6, + ACPI_WDAT_GET_RUNNING_STATE = 8, + ACPI_WDAT_SET_RUNNING_STATE = 9, + ACPI_WDAT_GET_STOPPED_STATE = 10, + ACPI_WDAT_SET_STOPPED_STATE = 11, + ACPI_WDAT_GET_REBOOT = 16, + ACPI_WDAT_SET_REBOOT = 17, + ACPI_WDAT_GET_SHUTDOWN = 18, + ACPI_WDAT_SET_SHUTDOWN = 19, + ACPI_WDAT_GET_STATUS = 32, + ACPI_WDAT_SET_STATUS = 33, + ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiWdatInstructions +{ + ACPI_WDAT_READ_VALUE = 0, + ACPI_WDAT_READ_COUNTDOWN = 1, + ACPI_WDAT_WRITE_VALUE = 2, + ACPI_WDAT_WRITE_COUNTDOWN = 3, + ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */ + ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */ +}; + + +/******************************************************************************* + * + * WDRT - Watchdog Resource Table + * Version 1 + * + * Conforms to "Watchdog Timer Hardware Requirements for Windows Server 2003", + * Version 1.01, August 28, 2006 + * + ******************************************************************************/ + +typedef struct acpi_table_wdrt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS ControlRegister; + ACPI_GENERIC_ADDRESS CountRegister; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 PciSegment; /* PCI Segment number */ + UINT16 MaxCount; /* Maximum counter value supported */ + UINT8 Units; + +} ACPI_TABLE_WDRT; + + +/* Reset to default packing */ + +#pragma pack() #endif /* __ACTBL2_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/actypes.h b/src/add-ons/kernel/bus_managers/acpi/include/actypes.h index 07ec23f053..0e01b97bbe 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/actypes.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/actypes.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 1.323 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -224,14 +223,12 @@ typedef int INT32; typedef INT64 ACPI_NATIVE_INT; - typedef UINT64 ACPI_SIZE; typedef UINT64 ACPI_IO_ADDRESS; typedef UINT64 ACPI_PHYSICAL_ADDRESS; #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX - #define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ /* @@ -265,7 +262,6 @@ typedef int INT32; typedef INT32 ACPI_NATIVE_INT; - typedef UINT32 ACPI_SIZE; typedef UINT32 ACPI_IO_ADDRESS; typedef UINT32 ACPI_PHYSICAL_ADDRESS; @@ -283,27 +279,19 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; /******************************************************************************* * - * OS-dependent and compiler-dependent types + * OS-dependent types * * If the defaults below are not appropriate for the host system, they can - * be defined in the compiler-specific or OS-specific header, and this will - * take precedence. + * be defined in the OS-specific header, and this will take precedence. * ******************************************************************************/ - /* Value returned by AcpiOsGetThreadId */ #ifndef ACPI_THREAD_ID #define ACPI_THREAD_ID ACPI_SIZE #endif -/* Object returned from AcpiOsCreateLock */ - -#ifndef ACPI_SPINLOCK -#define ACPI_SPINLOCK void * -#endif - /* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ #ifndef ACPI_CPU_FLAGS @@ -313,8 +301,51 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; /* Object returned from AcpiOsCreateCache */ #ifndef ACPI_CACHE_T +#ifdef ACPI_USE_LOCAL_CACHE #define ACPI_CACHE_T ACPI_MEMORY_LIST +#else +#define ACPI_CACHE_T void * #endif +#endif + +/* + * Synchronization objects - Mutexes, Semaphores, and SpinLocks + */ +#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE) +/* + * These macros are used if the host OS does not support a mutex object. + * Map the OSL Mutex interfaces to binary semaphores. + */ +#define ACPI_MUTEX ACPI_SEMAPHORE +#define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) +#define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) +#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) +#define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) +#endif + +/* Configurable types for synchronization objects */ + +#ifndef ACPI_SPINLOCK +#define ACPI_SPINLOCK void * +#endif + +#ifndef ACPI_SEMAPHORE +#define ACPI_SEMAPHORE void * +#endif + +#ifndef ACPI_MUTEX +#define ACPI_MUTEX void * +#endif + + +/******************************************************************************* + * + * Compiler-dependent types + * + * If the defaults below are not appropriate for the host compiler, they can + * be defined in the compiler-specific header, and this will take precedence. + * + ******************************************************************************/ /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ @@ -349,6 +380,44 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; #endif +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ + +#define ACPI_MAX_GPE_BLOCKS 2 + +/* Default ACPI register widths */ + +#define ACPI_GPE_REGISTER_WIDTH 8 +#define ACPI_PM1_REGISTER_WIDTH 16 +#define ACPI_PM2_REGISTER_WIDTH 8 +#define ACPI_PM_TIMER_WIDTH 32 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ +#define ACPI_PATH_SEPARATOR '.' + +/* Sizes for ACPI table headers */ + +#define ACPI_OEM_ID_SIZE 6 +#define ACPI_OEM_TABLE_ID_SIZE 8 + +/* ACPI/PNP hardware IDs */ + +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" + +/* PM Timer ticks per second (HZ) */ + +#define PM_TIMER_FREQUENCY 3579545 + + /******************************************************************************* * * Independent types @@ -373,13 +442,20 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; /* - * Mescellaneous types + * Miscellaneous types */ typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ typedef char * ACPI_STRING; /* Null terminated ASCII string */ typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ + +/* Owner IDs are used to track namespace nodes for selective deletion */ + +typedef UINT8 ACPI_OWNER_ID; +#define ACPI_OWNER_ID_MAX 0xFF + + typedef struct uint64_struct { UINT32 Lo; @@ -402,14 +478,8 @@ typedef struct uint32_struct } UINT32_STRUCT; -/* Synchronization objects */ - -#define ACPI_MUTEX void * -#define ACPI_SEMAPHORE void * - - /* - * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI + * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI * version 2, integers are 64 bits. Note that this pertains to the ACPI integer * type only, not other integers used in the implementation of the ACPI CA * subsystem. @@ -418,12 +488,6 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 #define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ - - -#if ACPI_MACHINE_WIDTH == 64 -#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ -#endif - #define ACPI_MAX64_DECIMAL_DIGITS 20 #define ACPI_MAX32_DECIMAL_DIGITS 10 #define ACPI_MAX16_DECIMAL_DIGITS 5 @@ -433,8 +497,62 @@ typedef UINT64 ACPI_INTEGER; * Constants with special meanings */ #define ACPI_ROOT_OBJECT ACPI_ADD_PTR (ACPI_HANDLE, NULL, ACPI_MAX_PTR) +#define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ +#define ACPI_DO_NOT_WAIT 0 +/******************************************************************************* + * + * Commonly used macros + * + ******************************************************************************/ + +/* Data manipulation */ + +#define ACPI_LOBYTE(Integer) ((UINT8) (UINT16)(Integer)) +#define ACPI_HIBYTE(Integer) ((UINT8) (((UINT16)(Integer)) >> 8)) +#define ACPI_LOWORD(Integer) ((UINT16) (UINT32)(Integer)) +#define ACPI_HIWORD(Integer) ((UINT16)(((UINT32)(Integer)) >> 16)) +#define ACPI_LODWORD(Integer64) ((UINT32) (UINT64)(Integer64)) +#define ACPI_HIDWORD(Integer64) ((UINT32)(((UINT64)(Integer64)) >> 32)) + +#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) +#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) +#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) +#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) + +/* Size calculation */ + +#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) + +/* Pointer manipulation */ + +#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) +#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) +#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) +#define ACPI_PTR_DIFF(a, b) (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))) + +/* Pointer/Integer type conversions */ + +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) +#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) +#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) +#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) +#else +#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) +#endif + + +/******************************************************************************* + * + * Miscellaneous constants + * + ******************************************************************************/ + /* * Initialization sequence */ @@ -506,9 +624,9 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_MAX 0x0B /* - * Types associated with ACPI names and objects. The first group of + * Types associated with ACPI names and objects. The first group of * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition - * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, + * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, * only add to the first group if the spec changes. * * NOTE: Types must be kept in sync with the global AcpiNsProperties @@ -698,14 +816,22 @@ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 #define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 #define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 -#define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 7 +#define ACPI_ADR_SPACE_IPMI (ACPI_ADR_SPACE_TYPE) 7 +#define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 8 #define ACPI_ADR_SPACE_FIXED_HARDWARE (ACPI_ADR_SPACE_TYPE) 127 /* * BitRegister IDs - * These are bitfields defined within the full ACPI registers + * + * These values are intended to be used by the hardware interfaces + * and are mapped to individual bitfields defined within the ACPI + * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c + * for this mapping. */ + +/* PM1 Status register */ + #define ACPI_BITREG_TIMER_STATUS 0x00 #define ACPI_BITREG_BUS_MASTER_STATUS 0x01 #define ACPI_BITREG_GLOBAL_LOCK_STATUS 0x02 @@ -715,27 +841,41 @@ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_BITREG_WAKE_STATUS 0x06 #define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 +/* PM1 Enable register */ + #define ACPI_BITREG_TIMER_ENABLE 0x08 #define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 #define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A #define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B #define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C -#define ACPI_BITREG_WAKE_ENABLE 0x0D -#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0E +#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0D -#define ACPI_BITREG_SCI_ENABLE 0x0F -#define ACPI_BITREG_BUS_MASTER_RLD 0x10 -#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x11 -#define ACPI_BITREG_SLEEP_TYPE_A 0x12 -#define ACPI_BITREG_SLEEP_TYPE_B 0x13 -#define ACPI_BITREG_SLEEP_ENABLE 0x14 +/* PM1 Control register */ -#define ACPI_BITREG_ARB_DISABLE 0x15 +#define ACPI_BITREG_SCI_ENABLE 0x0E +#define ACPI_BITREG_BUS_MASTER_RLD 0x0F +#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x10 +#define ACPI_BITREG_SLEEP_TYPE 0x11 +#define ACPI_BITREG_SLEEP_ENABLE 0x12 -#define ACPI_BITREG_MAX 0x15 +/* PM2 Control register */ + +#define ACPI_BITREG_ARB_DISABLE 0x13 + +#define ACPI_BITREG_MAX 0x13 #define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 +/* Status register values. A 1 clears a status bit. 0 = no effect */ + +#define ACPI_CLEAR_STATUS 1 + +/* Enable and Control register values */ + +#define ACPI_ENABLE_EVENT 1 +#define ACPI_DISABLE_EVENT 0 + + /* * External ACPI object definition */ @@ -833,6 +973,18 @@ typedef struct acpi_buffer #define ACPI_NAME_TYPE_MAX 1 +/* + * Predefined Namespace items + */ +typedef struct acpi_predefined_names +{ + char *Name; + UINT8 Type; + char *Val; + +} ACPI_PREDEFINED_NAMES; + + /* * Structure and flags for AcpiGetSystemInfo */ @@ -859,7 +1011,7 @@ typedef struct acpi_system_info /* - * System statistecs returned by AcpiGetStatistics() + * System statistics returned by AcpiGetStatistics() */ typedef struct acpi_statistics { @@ -905,7 +1057,6 @@ void (*ACPI_NOTIFY_HANDLER) ( typedef void (*ACPI_OBJECT_HANDLER) ( ACPI_HANDLE Object, - UINT32 Function, void *Data); typedef @@ -923,7 +1074,7 @@ ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( UINT32 AmlOffset, void *Context); -/* Table Event handler (Load, LoadTable etc) and types */ +/* Table Event handler (Load, LoadTable, etc.) and types */ typedef ACPI_STATUS (*ACPI_TABLE_HANDLER) ( @@ -949,7 +1100,6 @@ ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( #define ACPI_DEFAULT_HANDLER NULL - typedef ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( ACPI_HANDLE RegionHandle, @@ -973,40 +1123,67 @@ ACPI_STATUS (*ACPI_WALK_CALLBACK) ( #define ACPI_INTERRUPT_NOT_HANDLED 0x00 #define ACPI_INTERRUPT_HANDLED 0x01 +/* Length of 32-bit EISAID values when converted back to a string */ -/* Common string version of device HIDs and UIDs */ +#define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */ + +/* Length of UUID (string) values */ + +#define ACPI_UUID_LENGTH 16 + + +/* Structures used for device/processor HID, UID, CID */ typedef struct acpi_device_id { - char Value[ACPI_DEVICE_ID_LENGTH]; + UINT32 Length; /* Length of string + null */ + char *String; } ACPI_DEVICE_ID; -/* Common string version of device CIDs */ - -typedef struct acpi_compatible_id +typedef struct acpi_device_id_list { - char Value[ACPI_MAX_CID_LENGTH]; + UINT32 Count; /* Number of IDs in Ids array */ + UINT32 ListSize; /* Size of list, including ID strings */ + ACPI_DEVICE_ID Ids[1]; /* ID array */ -} ACPI_COMPATIBLE_ID; +} ACPI_DEVICE_ID_LIST; -typedef struct acpi_compatible_id_list +/* + * Structure returned from AcpiGetObjectInfo. + * Optimized for both 32- and 64-bit builds + */ +typedef struct acpi_device_info { - UINT32 Count; - UINT32 Size; - ACPI_COMPATIBLE_ID Id[1]; + UINT32 InfoSize; /* Size of info, including ID strings */ + UINT32 Name; /* ACPI object Name */ + ACPI_OBJECT_TYPE Type; /* ACPI object Type */ + UINT8 ParamCount; /* If a method, required parameter count */ + UINT8 Valid; /* Indicates which optional fields are valid */ + UINT8 Flags; /* Miscellaneous info */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ + UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */ + UINT32 CurrentStatus; /* _STA value */ + ACPI_INTEGER Address; /* _ADR value */ + ACPI_DEVICE_ID HardwareId; /* _HID value */ + ACPI_DEVICE_ID UniqueId; /* _UID value */ + ACPI_DEVICE_ID_LIST CompatibleIdList; /* _CID list */ -} ACPI_COMPATIBLE_ID_LIST; +} ACPI_DEVICE_INFO; +/* Values for Flags field above (AcpiGetObjectInfo) */ -/* Structure and flags for AcpiGetObjectInfo */ +#define ACPI_PCI_ROOT_BRIDGE 0x01 -#define ACPI_VALID_STA 0x0001 -#define ACPI_VALID_ADR 0x0002 -#define ACPI_VALID_HID 0x0004 -#define ACPI_VALID_UID 0x0008 -#define ACPI_VALID_CID 0x0010 -#define ACPI_VALID_SXDS 0x0020 +/* Flags for Valid field above (AcpiGetObjectInfo) */ + +#define ACPI_VALID_STA 0x01 +#define ACPI_VALID_ADR 0x02 +#define ACPI_VALID_HID 0x04 +#define ACPI_VALID_UID 0x08 +#define ACPI_VALID_CID 0x10 +#define ACPI_VALID_SXDS 0x20 +#define ACPI_VALID_SXWS 0x40 /* Flags for _STA method */ @@ -1018,36 +1195,6 @@ typedef struct acpi_compatible_id_list #define ACPI_STA_BATTERY_PRESENT 0x10 -#define ACPI_COMMON_OBJ_INFO \ - ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ - ACPI_NAME Name /* ACPI object Name */ - - -typedef struct acpi_obj_info_header -{ - ACPI_COMMON_OBJ_INFO; - -} ACPI_OBJ_INFO_HEADER; - - -/* Structure returned from Get Object Info */ - -typedef struct acpi_device_info -{ - ACPI_COMMON_OBJ_INFO; - - UINT32 ParamCount; /* If a method, required parameter count */ - UINT32 Valid; /* Indicates which fields below are valid */ - UINT32 CurrentStatus; /* _STA value */ - ACPI_INTEGER Address; /* _ADR value if any */ - ACPI_DEVICE_ID HardwareId; /* _HID value if any */ - ACPI_DEVICE_ID UniqueId; /* _UID value if any */ - UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ - ACPI_COMPATIBLE_ID_LIST CompatibilityId; /* List of _CIDs if any */ - -} ACPI_DEVICE_INFO; - - /* Context structs for address space handlers */ typedef struct acpi_pci_id @@ -1059,7 +1206,6 @@ typedef struct acpi_pci_id } ACPI_PCI_ID; - typedef struct acpi_mem_space_context { UINT32 Length; @@ -1072,424 +1218,31 @@ typedef struct acpi_mem_space_context /* - * Definitions for Resource Attributes + * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled */ -typedef UINT16 ACPI_RS_LENGTH; /* Resource Length field is fixed at 16 bits */ -typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */ +typedef struct acpi_memory_list +{ + char *ListName; + void *ListHead; + UINT16 ObjectSize; + UINT16 MaxDepth; + UINT16 CurrentDepth; + UINT16 LinkOffset; -/* - * Memory Attributes - */ -#define ACPI_READ_ONLY_MEMORY (UINT8) 0x00 -#define ACPI_READ_WRITE_MEMORY (UINT8) 0x01 +#ifdef ACPI_DBG_TRACK_ALLOCATIONS -#define ACPI_NON_CACHEABLE_MEMORY (UINT8) 0x00 -#define ACPI_CACHABLE_MEMORY (UINT8) 0x01 -#define ACPI_WRITE_COMBINING_MEMORY (UINT8) 0x02 -#define ACPI_PREFETCHABLE_MEMORY (UINT8) 0x03 + /* Statistics for debug memory tracking only */ -/* - * IO Attributes - * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. - * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. - */ -#define ACPI_NON_ISA_ONLY_RANGES (UINT8) 0x01 -#define ACPI_ISA_ONLY_RANGES (UINT8) 0x02 -#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) - -/* Type of translation - 1=Sparse, 0=Dense */ - -#define ACPI_SPARSE_TRANSLATION (UINT8) 0x01 - -/* - * IO Port Descriptor Decode - */ -#define ACPI_DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ -#define ACPI_DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ - -/* - * IRQ Attributes - */ -#define ACPI_LEVEL_SENSITIVE (UINT8) 0x00 -#define ACPI_EDGE_SENSITIVE (UINT8) 0x01 - -#define ACPI_ACTIVE_HIGH (UINT8) 0x00 -#define ACPI_ACTIVE_LOW (UINT8) 0x01 - -#define ACPI_EXCLUSIVE (UINT8) 0x00 -#define ACPI_SHARED (UINT8) 0x01 - -/* - * DMA Attributes - */ -#define ACPI_COMPATIBILITY (UINT8) 0x00 -#define ACPI_TYPE_A (UINT8) 0x01 -#define ACPI_TYPE_B (UINT8) 0x02 -#define ACPI_TYPE_F (UINT8) 0x03 - -#define ACPI_NOT_BUS_MASTER (UINT8) 0x00 -#define ACPI_BUS_MASTER (UINT8) 0x01 - -#define ACPI_TRANSFER_8 (UINT8) 0x00 -#define ACPI_TRANSFER_8_16 (UINT8) 0x01 -#define ACPI_TRANSFER_16 (UINT8) 0x02 - -/* - * Start Dependent Functions Priority definitions - */ -#define ACPI_GOOD_CONFIGURATION (UINT8) 0x00 -#define ACPI_ACCEPTABLE_CONFIGURATION (UINT8) 0x01 -#define ACPI_SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 - -/* - * 16, 32 and 64-bit Address Descriptor resource types - */ -#define ACPI_MEMORY_RANGE (UINT8) 0x00 -#define ACPI_IO_RANGE (UINT8) 0x01 -#define ACPI_BUS_NUMBER_RANGE (UINT8) 0x02 - -#define ACPI_ADDRESS_NOT_FIXED (UINT8) 0x00 -#define ACPI_ADDRESS_FIXED (UINT8) 0x01 - -#define ACPI_POS_DECODE (UINT8) 0x00 -#define ACPI_SUB_DECODE (UINT8) 0x01 - -#define ACPI_PRODUCER (UINT8) 0x00 -#define ACPI_CONSUMER (UINT8) 0x01 - - -/* - * If possible, pack the following structures to byte alignment - */ -#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED -#pragma pack(1) + UINT32 TotalAllocated; + UINT32 TotalFreed; + UINT32 MaxOccupied; + UINT32 TotalSize; + UINT32 CurrentTotalSize; + UINT32 Requests; + UINT32 Hits; #endif -/* UUID data structures for use in vendor-defined resource descriptors */ - -typedef struct acpi_uuid -{ - UINT8 Data[ACPI_UUID_LENGTH]; -} ACPI_UUID; - -typedef struct acpi_vendor_uuid -{ - UINT8 Subtype; - UINT8 Data[ACPI_UUID_LENGTH]; - -} ACPI_VENDOR_UUID; - -/* - * Structures used to describe device resources - */ -typedef struct acpi_resource_irq -{ - UINT8 DescriptorLength; - UINT8 Triggering; - UINT8 Polarity; - UINT8 Sharable; - UINT8 InterruptCount; - UINT8 Interrupts[1]; - -} ACPI_RESOURCE_IRQ; - -typedef struct ACPI_RESOURCE_DMA -{ - UINT8 Type; - UINT8 BusMaster; - UINT8 Transfer; - UINT8 ChannelCount; - UINT8 Channels[1]; - -} ACPI_RESOURCE_DMA; - -typedef struct acpi_resource_start_dependent -{ - UINT8 DescriptorLength; - UINT8 CompatibilityPriority; - UINT8 PerformanceRobustness; - -} ACPI_RESOURCE_START_DEPENDENT; - - -/* - * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not - * needed because it has no fields - */ - - -typedef struct acpi_resource_io -{ - UINT8 IoDecode; - UINT8 Alignment; - UINT8 AddressLength; - UINT16 Minimum; - UINT16 Maximum; - -} ACPI_RESOURCE_IO; - -typedef struct acpi_resource_fixed_io -{ - UINT16 Address; - UINT8 AddressLength; - -} ACPI_RESOURCE_FIXED_IO; - -typedef struct acpi_resource_vendor -{ - UINT16 ByteLength; - UINT8 ByteData[1]; - -} ACPI_RESOURCE_VENDOR; - -/* Vendor resource with UUID info (introduced in ACPI 3.0) */ - -typedef struct acpi_resource_vendor_typed -{ - UINT16 ByteLength; - UINT8 UuidSubtype; - UINT8 Uuid[ACPI_UUID_LENGTH]; - UINT8 ByteData[1]; - -} ACPI_RESOURCE_VENDOR_TYPED; - -typedef struct acpi_resource_end_tag -{ - UINT8 Checksum; - -} ACPI_RESOURCE_END_TAG; - -typedef struct acpi_resource_memory24 -{ - UINT8 WriteProtect; - UINT16 Minimum; - UINT16 Maximum; - UINT16 Alignment; - UINT16 AddressLength; - -} ACPI_RESOURCE_MEMORY24; - -typedef struct acpi_resource_memory32 -{ - UINT8 WriteProtect; - UINT32 Minimum; - UINT32 Maximum; - UINT32 Alignment; - UINT32 AddressLength; - -} ACPI_RESOURCE_MEMORY32; - -typedef struct acpi_resource_fixed_memory32 -{ - UINT8 WriteProtect; - UINT32 Address; - UINT32 AddressLength; - -} ACPI_RESOURCE_FIXED_MEMORY32; - -typedef struct acpi_memory_attribute -{ - UINT8 WriteProtect; - UINT8 Caching; - UINT8 RangeType; - UINT8 Translation; - -} ACPI_MEMORY_ATTRIBUTE; - -typedef struct acpi_io_attribute -{ - UINT8 RangeType; - UINT8 Translation; - UINT8 TranslationType; - UINT8 Reserved1; - -} ACPI_IO_ATTRIBUTE; - -typedef union acpi_resource_attribute -{ - ACPI_MEMORY_ATTRIBUTE Mem; - ACPI_IO_ATTRIBUTE Io; - - /* Used for the *WordSpace macros */ - - UINT8 TypeSpecific; - -} ACPI_RESOURCE_ATTRIBUTE; - -typedef struct acpi_resource_source -{ - UINT8 Index; - UINT16 StringLength; - char *StringPtr; - -} ACPI_RESOURCE_SOURCE; - -/* Fields common to all address descriptors, 16/32/64 bit */ - -#define ACPI_RESOURCE_ADDRESS_COMMON \ - UINT8 ResourceType; \ - UINT8 ProducerConsumer; \ - UINT8 Decode; \ - UINT8 MinAddressFixed; \ - UINT8 MaxAddressFixed; \ - ACPI_RESOURCE_ATTRIBUTE Info; - -typedef struct acpi_resource_address -{ - ACPI_RESOURCE_ADDRESS_COMMON - -} ACPI_RESOURCE_ADDRESS; - -typedef struct acpi_resource_address16 -{ - ACPI_RESOURCE_ADDRESS_COMMON - UINT16 Granularity; - UINT16 Minimum; - UINT16 Maximum; - UINT16 TranslationOffset; - UINT16 AddressLength; - ACPI_RESOURCE_SOURCE ResourceSource; - -} ACPI_RESOURCE_ADDRESS16; - -typedef struct acpi_resource_address32 -{ - ACPI_RESOURCE_ADDRESS_COMMON - UINT32 Granularity; - UINT32 Minimum; - UINT32 Maximum; - UINT32 TranslationOffset; - UINT32 AddressLength; - ACPI_RESOURCE_SOURCE ResourceSource; - -} ACPI_RESOURCE_ADDRESS32; - -typedef struct acpi_resource_address64 -{ - ACPI_RESOURCE_ADDRESS_COMMON - UINT64 Granularity; - UINT64 Minimum; - UINT64 Maximum; - UINT64 TranslationOffset; - UINT64 AddressLength; - ACPI_RESOURCE_SOURCE ResourceSource; - -} ACPI_RESOURCE_ADDRESS64; - -typedef struct acpi_resource_extended_address64 -{ - ACPI_RESOURCE_ADDRESS_COMMON - UINT8 RevisionID; - UINT64 Granularity; - UINT64 Minimum; - UINT64 Maximum; - UINT64 TranslationOffset; - UINT64 AddressLength; - UINT64 TypeSpecific; - -} ACPI_RESOURCE_EXTENDED_ADDRESS64; - -typedef struct acpi_resource_extended_irq -{ - UINT8 ProducerConsumer; - UINT8 Triggering; - UINT8 Polarity; - UINT8 Sharable; - UINT8 InterruptCount; - ACPI_RESOURCE_SOURCE ResourceSource; - UINT32 Interrupts[1]; - -} ACPI_RESOURCE_EXTENDED_IRQ; - -typedef struct acpi_resource_generic_register -{ - UINT8 SpaceId; - UINT8 BitWidth; - UINT8 BitOffset; - UINT8 AccessSize; - UINT64 Address; - -} ACPI_RESOURCE_GENERIC_REGISTER; - - -/* ACPI_RESOURCE_TYPEs */ - -#define ACPI_RESOURCE_TYPE_IRQ 0 -#define ACPI_RESOURCE_TYPE_DMA 1 -#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 -#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 -#define ACPI_RESOURCE_TYPE_IO 4 -#define ACPI_RESOURCE_TYPE_FIXED_IO 5 -#define ACPI_RESOURCE_TYPE_VENDOR 6 -#define ACPI_RESOURCE_TYPE_END_TAG 7 -#define ACPI_RESOURCE_TYPE_MEMORY24 8 -#define ACPI_RESOURCE_TYPE_MEMORY32 9 -#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 -#define ACPI_RESOURCE_TYPE_ADDRESS16 11 -#define ACPI_RESOURCE_TYPE_ADDRESS32 12 -#define ACPI_RESOURCE_TYPE_ADDRESS64 13 -#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ -#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 -#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 -#define ACPI_RESOURCE_TYPE_MAX 16 - - -typedef union acpi_resource_data -{ - ACPI_RESOURCE_IRQ Irq; - ACPI_RESOURCE_DMA Dma; - ACPI_RESOURCE_START_DEPENDENT StartDpf; - ACPI_RESOURCE_IO Io; - ACPI_RESOURCE_FIXED_IO FixedIo; - ACPI_RESOURCE_VENDOR Vendor; - ACPI_RESOURCE_VENDOR_TYPED VendorTyped; - ACPI_RESOURCE_END_TAG EndTag; - ACPI_RESOURCE_MEMORY24 Memory24; - ACPI_RESOURCE_MEMORY32 Memory32; - ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; - ACPI_RESOURCE_ADDRESS16 Address16; - ACPI_RESOURCE_ADDRESS32 Address32; - ACPI_RESOURCE_ADDRESS64 Address64; - ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; - ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; - ACPI_RESOURCE_GENERIC_REGISTER GenericReg; - - /* Common fields */ - - ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ - -} ACPI_RESOURCE_DATA; - - -typedef struct acpi_resource -{ - UINT32 Type; - UINT32 Length; - ACPI_RESOURCE_DATA Data; - -} ACPI_RESOURCE; - -/* restore default alignment */ - -#pragma pack() - - -#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ -#define ACPI_RS_SIZE_MIN (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) -#define ACPI_RS_SIZE(Type) (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type)) - -#define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) - - -typedef struct acpi_pci_routing_table -{ - UINT32 Length; - UINT32 Pin; - ACPI_INTEGER Address; /* here for 64-bit alignment */ - UINT32 SourceIndex; - char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ - -} ACPI_PCI_ROUTING_TABLE; +} ACPI_MEMORY_LIST; #endif /* __ACTYPES_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/acutils.h b/src/add-ons/kernel/bus_managers/acpi/include/acutils.h index 953d7d767d..33d33c2f47 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/acutils.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/acutils.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures - * $Revision: 1.204 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -190,7 +189,7 @@ typedef struct acpi_pkg_info /* * utglobal - Global data structures and procedures */ -void +ACPI_STATUS AcpiUtInitGlobals ( void); @@ -218,6 +217,10 @@ char * AcpiUtGetDescriptorName ( void *Object); +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object); + char * AcpiUtGetObjectTypeName ( ACPI_OPERAND_OBJECT *ObjDesc); @@ -352,7 +355,9 @@ extern const UINT8 _acpi_ctype[]; #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ +#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ + +#define ACPI_IS_ASCII(c) ((c) < 0x80) /* @@ -503,58 +508,6 @@ AcpiUtReportWarning ( char *ModuleName, UINT32 LineNumber); -/* Error and message reporting interfaces */ - -void ACPI_INTERNAL_VAR_XFACE -AcpiUtDebugPrint ( - UINT32 RequestedDebugLevel, - UINT32 LineNumber, - const char *FunctionName, - const char *ModuleName, - UINT32 ComponentId, - const char *Format, - ...) ACPI_PRINTF_LIKE(6); - -void ACPI_INTERNAL_VAR_XFACE -AcpiUtDebugPrintRaw ( - UINT32 RequestedDebugLevel, - UINT32 LineNumber, - const char *FunctionName, - const char *ModuleName, - UINT32 ComponentId, - const char *Format, - ...) ACPI_PRINTF_LIKE(6); - -void ACPI_INTERNAL_VAR_XFACE -AcpiUtError ( - const char *ModuleName, - UINT32 LineNumber, - const char *Format, - ...) ACPI_PRINTF_LIKE(3); - -void ACPI_INTERNAL_VAR_XFACE -AcpiUtException ( - const char *ModuleName, - UINT32 LineNumber, - ACPI_STATUS Status, - const char *Format, - ...) ACPI_PRINTF_LIKE(4); - -void ACPI_INTERNAL_VAR_XFACE -AcpiUtWarning ( - const char *ModuleName, - UINT32 LineNumber, - const char *Format, - ...) ACPI_PRINTF_LIKE(3); - -void ACPI_INTERNAL_VAR_XFACE -AcpiUtInfo ( - const char *ModuleName, - UINT32 LineNumber, - const char *Format, - ...) ACPI_PRINTF_LIKE(3); - - /* * utdelete - Object deletion and reference counts */ @@ -597,17 +550,7 @@ ACPI_STATUS AcpiUtEvaluateNumericObject ( char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_INTEGER *Address); - -ACPI_STATUS -AcpiUtExecute_HID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Hid); - -ACPI_STATUS -AcpiUtExecute_CID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_COMPATIBLE_ID_LIST **ReturnCidList); + ACPI_INTEGER *Value); ACPI_STATUS AcpiUtExecute_STA ( @@ -615,14 +558,58 @@ AcpiUtExecute_STA ( UINT32 *StatusFlags); ACPI_STATUS -AcpiUtExecute_UID ( +AcpiUtExecutePowerMethods ( ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Uid); + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues); + + +/* + * utids - device ID support + */ +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); ACPI_STATUS -AcpiUtExecute_Sxds ( +AcpiUtExecute_UID ( ACPI_NAMESPACE_NODE *DeviceNode, - UINT8 *Highest); + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList); + + +/* + * utlock - reader/writer locks + */ +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock); /* @@ -748,6 +735,10 @@ const char * AcpiUtValidateException ( ACPI_STATUS Status); +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id); + BOOLEAN AcpiUtIsAmlTable ( ACPI_TABLE_HEADER *Table); @@ -795,6 +786,15 @@ AcpiUtStrtoul64 ( UINT32 Base, ACPI_INTEGER *RetInteger); +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + /* Values for Base above (16=Hex, 10=Decimal) */ #define ACPI_ANY_BASE 0 diff --git a/src/add-ons/kernel/bus_managers/acpi/include/amlcode.h b/src/add-ons/kernel/bus_managers/acpi/include/amlcode.h index 9de6e51430..19740d9083 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/amlcode.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/amlcode.h @@ -3,7 +3,6 @@ * Name: amlcode.h - Definitions for AML, as included in "definition blocks" * Declarations and definitions contained herein are derived * directly from the ACPI specification. - * $Revision: 1.87 $ * *****************************************************************************/ @@ -11,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -486,6 +485,7 @@ typedef enum REGION_SMBUS, REGION_CMOS, REGION_PCI_BAR, + REGION_IPMI, REGION_DATA_TABLE, /* Internal use only */ REGION_FIXED_HW = 0x7F @@ -583,7 +583,7 @@ typedef enum #define AML_METHOD_ARG_COUNT 0x07 #define AML_METHOD_SERIALIZED 0x08 -#define AML_METHOD_SYNCH_LEVEL 0xF0 +#define AML_METHOD_SYNC_LEVEL 0xF0 /* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/amlresrc.h b/src/add-ons/kernel/bus_managers/acpi/include/amlresrc.h index ae6e3bf9ff..689564c628 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/amlresrc.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/amlresrc.h @@ -2,7 +2,6 @@ /****************************************************************************** * * Module Name: amlresrc.h - AML resource descriptors - * $Revision: 1.41 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/common/16bit.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/accygwin.h similarity index 84% rename from src/add-ons/kernel/bus_managers/acpi/common/16bit.h rename to src/add-ons/kernel/bus_managers/acpi/include/platform/accygwin.h index 4eebbe35d0..e9585b44b1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/common/16bit.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/accygwin.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: 16bit.h - 16-bit support + * Name: accygwin.h - OS specific defines, etc. for cygwin environment * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -113,53 +113,51 @@ * *****************************************************************************/ +#ifndef __ACCYGWIN_H__ +#define __ACCYGWIN_H__ -#define GET_SEGMENT(ptr) ((UINT16)(_segment)(ptr)) -#define GET_OFFSET(ptr) ((UINT16)(UINT32) (ptr)) -#define GET_PHYSICAL_ADDRESS(ptr) (((((UINT32)GET_SEGMENT(ptr)) << 4)) + GET_OFFSET(ptr)) -#define PTR_OVL_BUILD_PTR(p,b,o) {p.ovl.base=b;p.ovl.offset=o;} - -typedef union ptr_ovl -{ - void *ptr; - UINT32 dword; - struct - { - UINT16 offset; - UINT16 base; - } ovl; - -} PTR_OVL; +/* + * ACPICA configuration + */ +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_THREAD_ID pthread_t +#define ACPI_FLUSH_CPU_CACHE() +/* + * This is needed since sem_timedwait does not appear to work properly + * on cygwin (always hangs forever). + */ +#define ACPI_USE_ALTERNATE_TIMEOUT -int ACPI_INTERNAL_VAR_XFACE -FlatMove ( - UINT32 Dest, - UINT32 Src, - UINT16 Size); +#include +#include +#include +#include +#include -int ACPI_INTERNAL_VAR_XFACE -FlatMove32 ( - UINT32 Dest, - UINT32 Src, - UINT16 Size); +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif -ACPI_NATIVE_INT -AfWriteBuffer ( - char *Filename, - char *Buffer, - UINT32 Length); +#ifndef __cdecl +#define __cdecl +#endif -char * -AfGenerateFilename (char *TableId); +#ifdef _ANSI +#define inline +#endif -ACPI_STATUS -AfFindTable( - char *TableName, - UINT8 **TablePtr, - UINT32 *TableLength); +/* Cygwin uses GCC */ -void -AfDumpTables (void); +#include "acgcc.h" +#endif /* __ACCYGWIN_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acefi.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acefi.h index cb86bc70ee..40afaa401c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acefi.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acefi.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acefi.h - OS specific defines, etc. - * $Revision: 1.19 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acenv.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acenv.h index 6e89886945..eb0f795a19 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acenv.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acenv.h @@ -1,7 +1,6 @@ /****************************************************************************** * - * Name: acenv.h - Generation environment specific items - * $Revision: 1.133 $ + * Name: acenv.h - Host and compiler configuration * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,54 +116,64 @@ #ifndef __ACENV_H__ #define __ACENV_H__ - /* + * Environment configuration. The purpose of this file is to interface ACPICA + * to the local environment. This includes compiler-specific, OS-specific, + * and machine-specific configuration. + */ + +/* Types for ACPI_MUTEX_TYPE */ + +#define ACPI_BINARY_SEMAPHORE 0 +#define ACPI_OSL_MUTEX 1 + +/* Types for DEBUGGER_THREADING */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + + +/****************************************************************************** + * * Configuration for ACPI tools and utilities - */ + * + *****************************************************************************/ -#ifdef ACPI_LIBRARY -/* - * Note: The non-debug version of the AcpiLibrary does not contain any - * debug support, for minimimal size. The debug version uses ACPI_FULL_DEBUG - */ -#define ACPI_USE_LOCAL_CACHE -#endif +/* iASL configuration */ #ifdef ACPI_ASL_COMPILER -#define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_DISASSEMBLER +#define ACPI_DEBUG_OUTPUT #define ACPI_CONSTANT_EVAL_ONLY #define ACPI_LARGE_NAMESPACE_NODE #define ACPI_DATA_TABLE_DISASSEMBLY #endif +/* AcpiExec configuration */ + #ifdef ACPI_EXEC_APP -#undef DEBUGGER_THREADING -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED -#define ACPI_FULL_DEBUG #define ACPI_APPLICATION -#define ACPI_DEBUGGER +#define ACPI_FULL_DEBUG #define ACPI_MUTEX_DEBUG #define ACPI_DBG_TRACK_ALLOCATIONS #endif -#ifdef ACPI_DASM_APP -#ifndef MSDOS -#define ACPI_DEBUG_OUTPUT -#endif -#define ACPI_APPLICATION -#define ACPI_DISASSEMBLER -#define ACPI_NO_METHOD_EXECUTION -#define ACPI_LARGE_NAMESPACE_NODE -#define ACPI_DATA_TABLE_DISASSEMBLY +/* Linkable ACPICA library */ + +#ifdef ACPI_LIBRARY +#define ACPI_USE_LOCAL_CACHE #endif +/* Common for all ACPICA applications */ + #ifdef ACPI_APPLICATION #define ACPI_USE_SYSTEM_CLIBRARY #define ACPI_USE_LOCAL_CACHE #endif +/* Common debug support */ + #ifdef ACPI_FULL_DEBUG #define ACPI_DEBUGGER #define ACPI_DEBUG_OUTPUT @@ -172,60 +181,18 @@ #endif -/* - * Environment configuration. The purpose of this file is to interface to the - * local generation environment. - * - * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. - * Otherwise, local versions of string/memory functions will be used. - * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and - * the standard header files may be used. - * - * The ACPI subsystem only uses low level C library functions that do not call - * operating system services and may therefore be inlined in the code. - * - * It may be necessary to tailor these include files to the target - * generation environment. - * - * - * Functions and constants used from each header: - * - * string.h: memcpy - * memset - * strcat - * strcmp - * strcpy - * strlen - * strncmp - * strncat - * strncpy - * - * stdlib.h: strtoul - * - * stdarg.h: va_list - * va_arg - * va_start - * va_end - * - */ - /*! [Begin] no source code translation */ +/****************************************************************************** + * + * Host configuration files. The compiler configuration files are included + * by the host files. + * + *****************************************************************************/ + #if defined(_LINUX) || defined(__linux__) #include "aclinux.h" -#elif defined(_AED_EFI) -#include "acefi.h" - -#elif defined(WIN32) -#include "acwin.h" - -#elif defined(WIN64) -#include "acwin64.h" - -#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */ -#include "acdos16.h" - #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include "acfreebsd.h" @@ -235,29 +202,106 @@ #elif (defined(__BEOS__) || defined(__HAIKU__)) #include "achaiku.h" +#elif defined(__sun) +#include "acsolaris.h" + #elif defined(MODESTO) #include "acmodesto.h" #elif defined(NETWARE) #include "acnetware.h" -#elif defined(__sun) -#include "acsolaris.h" +#elif defined(_CYGWIN) +#include "accygwin.h" + +#elif defined(WIN32) +#include "acwin.h" + +#elif defined(WIN64) +#include "acwin64.h" + +#elif defined(_WRS_LIB_BUILD) +#include "acvxworks.h" + +#elif defined(__OS2__) +#include "acos2.h" + +#elif defined(_AED_EFI) +#include "acefi.h" #else -/* All other environments */ - -#define ACPI_USE_STANDARD_HEADERS - -#define COMPILER_DEPENDENT_INT64 long long -#define COMPILER_DEPENDENT_UINT64 unsigned long long +/* Unknown environment */ +#error Unknown target environment #endif /*! [End] no source code translation !*/ +/****************************************************************************** + * + * Setup defaults for the required symbols that were not defined in one of + * the host/compiler files above. + * + *****************************************************************************/ + +/* 64-bit data types */ + +#ifndef COMPILER_DEPENDENT_INT64 +#define COMPILER_DEPENDENT_INT64 long long +#endif + +#ifndef COMPILER_DEPENDENT_UINT64 +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#endif + +/* Type of mutex supported by host. Default is binary semaphores. */ + +#ifndef ACPI_MUTEX_TYPE +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE +#endif + +/* Global Lock acquire/release */ + +#ifndef ACPI_ACQUIRE_GLOBAL_LOCK +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = 1 +#endif + +#ifndef ACPI_RELEASE_GLOBAL_LOCK +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) Acq = 0 +#endif + +/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */ + +#ifndef ACPI_FLUSH_CPU_CACHE +#define ACPI_FLUSH_CPU_CACHE() +#endif + +/* + * Configurable calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#ifndef ACPI_SYSTEM_XFACE +#define ACPI_SYSTEM_XFACE +#endif + +#ifndef ACPI_EXTERNAL_XFACE +#define ACPI_EXTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_VAR_XFACE +#define ACPI_INTERNAL_VAR_XFACE +#endif + /* * Debugger threading model * Use single threaded if the entire subsystem is contained in an application @@ -266,9 +310,6 @@ * By default the model is single threaded if ACPI_APPLICATION is set, * multi-threaded if ACPI_APPLICATION is not set. */ -#define DEBUGGER_SINGLE_THREADED 0 -#define DEBUGGER_MULTI_THREADED 1 - #ifndef DEBUGGER_THREADING #ifdef ACPI_APPLICATION #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED @@ -285,17 +326,26 @@ * *****************************************************************************/ -#define ACPI_IS_ASCII(c) ((c) < 0x80) - +/* + * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPICA subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + */ #ifdef ACPI_USE_SYSTEM_CLIBRARY -/* - * Use the standard C library headers. - * We want to keep these to a minimum. - */ + +/* Use the standard C library headers. We want to keep these to a minimum */ + #ifdef ACPI_USE_STANDARD_HEADERS -/* - * Use the standard headers from the standard locations - */ + +/* Use the standard headers from the standard locations */ + #include #include #include @@ -303,9 +353,8 @@ #endif /* ACPI_USE_STANDARD_HEADERS */ -/* - * We will be linking to the standard Clib functions - */ +/* We will be linking to the standard Clib functions */ + #define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) #define ACPI_STRCHR(s1,c) strchr((s1), (c)) #define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) @@ -319,7 +368,6 @@ #define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) #define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) #define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) - #define ACPI_TOUPPER(i) toupper((int) (i)) #define ACPI_TOLOWER(i) tolower((int) (i)) #define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) @@ -337,13 +385,12 @@ * *****************************************************************************/ - /* - * Use local definitions of C library macros and functions - * NOTE: The function implementations may not be as efficient - * as an inline or assembly code implementation provided by a - * native C library. +/* + * Use local definitions of C library macros and functions. These function + * implementations may not be as efficient as an inline or assembly code + * implementation provided by a native C library, but they are functionally + * equivalent. */ - #ifndef va_arg #ifndef _VALIST @@ -351,15 +398,13 @@ typedef char *va_list; #endif /* _VALIST */ -/* - * Storage alignment properties - */ +/* Storage alignment properties */ + #define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) #define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) -/* - * Variable argument list macro definitions - */ +/* Variable argument list macro definitions */ + #define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) #define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) #define va_end(ap) (void) 0 @@ -367,6 +412,7 @@ typedef char *va_list; #endif /* va_arg */ +/* Use the local (ACPICA) definitions of the clib functions */ #define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) #define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) @@ -386,62 +432,4 @@ typedef char *va_list; #endif /* ACPI_USE_SYSTEM_CLIBRARY */ - -/****************************************************************************** - * - * Assembly code macros - * - *****************************************************************************/ - -/* - * Handle platform- and compiler-specific assembly language differences. - * These should already have been defined by the platform includes above. - * - * Notes: - * 1) Interrupt 3 is used to break into a debugger - * 2) Interrupts are turned off during ACPI register setup - */ - -/* Unrecognized compiler, use defaults */ - -#ifndef ACPI_ASM_MACROS - -/* - * Calling conventions: - * - * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) - * ACPI_EXTERNAL_XFACE - External ACPI interfaces - * ACPI_INTERNAL_XFACE - Internal ACPI interfaces - * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces - */ -#define ACPI_SYSTEM_XFACE -#define ACPI_EXTERNAL_XFACE -#define ACPI_INTERNAL_XFACE -#define ACPI_INTERNAL_VAR_XFACE - -#define ACPI_ASM_MACROS -#define BREAKPOINT3 -#define ACPI_DISABLE_IRQS() -#define ACPI_ENABLE_IRQS() -#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) -#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) - -#endif /* ACPI_ASM_MACROS */ - - -#ifdef ACPI_APPLICATION - -/* Don't want software interrupts within a ring3 application */ - -#undef BREAKPOINT3 -#define BREAKPOINT3 -#endif - - -/****************************************************************************** - * - * Compiler-specific information is contained in the compiler-specific - * headers. - * - *****************************************************************************/ #endif /* __ACENV_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acfreebsd.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acfreebsd.h index e7b2c825ce..20c5687c20 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acfreebsd.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acfreebsd.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acfreebsd.h - OS specific defines, etc. - * $Revision: 1.27 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +114,7 @@ *****************************************************************************/ #ifndef __ACFREEBSD_H__ -#define __ACFREEBSD_H__ +#define __ACFREEBSD_H__ /* FreeBSD uses GCC */ @@ -124,77 +123,58 @@ #include #include -#define ACPI_UINTPTR_T uintptr_t -#define ACPI_USE_LOCAL_CACHE -#define __cdecl +#define ACPI_UINTPTR_T uintptr_t + +#define ACPI_USE_LOCAL_CACHE +#define ACPI_USE_SYSTEM_CLIBRARY + +#define __cdecl #ifdef _KERNEL -#include "opt_acpi.h" -#endif -#ifdef ACPI_DEBUG -#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ -#define ACPI_DISASSEMBLER -#endif - -#ifdef _KERNEL #include #include #include #include #include -#ifdef DEBUGGER_THREADING -#undef DEBUGGER_THREADING -#endif /* DEBUGGER_THREADING */ +#include "opt_acpi.h" -#define DEBUGGER_THREADING 0 /* integrated with DDB */ +#define ACPI_THREAD_ID lwpid_t + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ +#define ACPI_DISASSEMBLER +#endif #ifdef ACPI_DEBUG_OUTPUT #include "opt_ddb.h" #ifdef DDB -#define ACPI_DEBUGGER +#define ACPI_DEBUGGER #endif /* DDB */ #endif /* ACPI_DEBUG_OUTPUT */ -#else /* _KERNEL */ +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ -/* Not building kernel code, so use libc */ -#define ACPI_USE_STANDARD_HEADERS -#define ACPI_FLUSH_CPU_CACHE() +#define DEBUGGER_THREADING 0 /* integrated with DDB */ + +#else /* _KERNEL */ #if __STDC_HOSTED__ #include #endif -#define __cli() -#define __sti() +#define ACPI_THREAD_ID pthread_t -#endif /* _KERNEL */ +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_FLUSH_CPU_CACHE() -/* Always use FreeBSD code over our local versions */ -#define ACPI_USE_SYSTEM_CLIBRARY +#define __cli() +#define __sti() -#if defined(_KERNEL) && (__FreeBSD_version < 700020) -/* Or strstr (used in debugging mode, also move to libkern) */ -static __inline char * -strstr (char *s, char *find) -{ - char c, sc; - size_t len; - - if ((c = *find++) != 0) { - len = strlen (find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while (sc != c); - } while (strncmp (s, find, len) != 0); - s--; - } - return ((char *) s); -} #endif /* _KERNEL */ #endif /* __ACFREEBSD_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acgcc.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acgcc.h index 0f19883bd3..449942278c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acgcc.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acgcc.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acgcc.h - GCC specific defines, etc. - * $Revision: 1.33 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -135,5 +134,4 @@ */ #define ACPI_UNUSED_VAR __attribute__ ((unused)) - #endif /* __ACGCC_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h index 68bab81ba0..e02d4e5ac3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acintel.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acintel.h index 92cd70b3e3..44197a0994 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acintel.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acintel.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acintel.h - VC specific defines, etc. - * $Revision: 1.19 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/aclinux.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/aclinux.h index 1322424704..c6f868cdbf 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/aclinux.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/aclinux.h @@ -1,7 +1,6 @@ /****************************************************************************** * - * Name: aclinux.h - OS specific defines, etc. - * $Revision: 1.44 $ + * Name: aclinux.h - OS specific defines, etc. for Linux * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,28 +116,39 @@ #ifndef __ACLINUX_H__ #define __ACLINUX_H__ +/* Common (in-kernel/user-space) ACPICA configuration */ + #define ACPI_USE_SYSTEM_CLIBRARY #define ACPI_USE_DO_WHILE_0 +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE + #ifdef __KERNEL__ -#include #include #include +#include #include +#include #include #include #include #include +#include +#include +#include -/* Host-dependent types and defines */ +/* Host-dependent types and defines for in-kernel ACPICA */ #define ACPI_MACHINE_WIDTH BITS_PER_LONG -#define ACPI_CACHE_T kmem_cache_t -#define ACPI_SPINLOCK spinlock_t -#define ACPI_EXPORT_SYMBOL(Symbol) EXPORT_SYMBOL(Symbol); +#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); #define strtoul simple_strtoul +#define ACPI_CACHE_T struct kmem_cache +#define ACPI_SPINLOCK spinlock_t * +#define ACPI_CPU_FLAGS unsigned long +#define ACPI_THREAD_ID struct task_struct * + #else /* !__KERNEL__ */ #include @@ -147,6 +157,11 @@ #include #include +/* Host-dependent types and defines for user-space ACPICA */ + +#define ACPI_FLUSH_CPU_CACHE() +#define ACPI_THREAD_ID pthread_t + #if defined(__ia64__) || defined(__x86_64__) #define ACPI_MACHINE_WIDTH 64 #define COMPILER_DEPENDENT_INT64 long @@ -162,11 +177,57 @@ #define __cdecl #endif -#define ACPI_FLUSH_CPU_CACHE() #endif /* __KERNEL__ */ /* Linux uses GCC */ #include "acgcc.h" + +#ifdef __KERNEL__ +/* + * Overrides for in-kernel ACPICA + */ +static inline acpi_thread_id acpi_os_get_thread_id(void) +{ + return current; +} + +/* + * The irqs_disabled() check is for resume from RAM. + * Interrupts are off during resume, just like they are for boot. + * However, boot has (system_state != SYSTEM_RUNNING) + * to quiet __might_sleep() in kmalloc() and resume does not. + */ +#include +static inline void *acpi_os_allocate(acpi_size size) +{ + return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_allocate_zeroed(acpi_size size) +{ + return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_acquire_object(acpi_cache_t * cache) +{ + return kmem_cache_zalloc(cache, + irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +#define ACPI_ALLOCATE(a) acpi_os_allocate(a) +#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a) +#define ACPI_FREE(a) kfree(a) + +/* Used within ACPICA to show where it is safe to preempt execution */ + +#define ACPI_PREEMPTION_POINT() \ + do { \ + if (!irqs_disabled()) \ + cond_resched(); \ + } while (0) + +#endif /* __KERNEL__ */ + #endif /* __ACLINUX_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acmsvc.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acmsvc.h index 3b065a8905..0320e74d1e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acmsvc.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acmsvc.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acmsvc.h - VC specific defines, etc. - * $Revision: 1.28 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acnetbsd.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acnetbsd.h index d120b54a10..c04851b926 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acnetbsd.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acnetbsd.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acnetbsd.h - OS specific defines, etc. - * $Revision: 1.10 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -142,8 +141,6 @@ #define ACPI_USE_NATIVE_DIVIDE -#define ACPI_ASM_MACROS /* tell acenv.h */ - #define ACPI_SYSTEM_XFACE #define ACPI_EXTERNAL_XFACE #define ACPI_INTERNAL_XFACE diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acos2.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acos2.h new file mode 100644 index 0000000000..21e3373c24 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acos2.h @@ -0,0 +1,172 @@ +/****************************************************************************** + * + * Name: acos2.h - OS/2 specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOS2_H__ +#define __ACOS2_H__ +#define INCL_LONGLONG +#include + + +#define ACPI_MACHINE_WIDTH 32 + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE APIENTRY +#define ACPI_EXTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_VAR_XFACE APIENTRY + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (most specifically for _THIS_MODULE). This allow us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR + +#define ACPI_USE_STANDARD_HEADERS +#include + +#define ACPI_FLUSH_CPU_CACHE() Wbinvd() +void Wbinvd(void); + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = OSPMAcquireGlobalLock(GLptr) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) Pnd = OSPMReleaseGlobalLock(GLptr) +unsigned short OSPMAcquireGlobalLock (void *); +unsigned short OSPMReleaseGlobalLock (void *); + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + unsigned long long val = 0LL; \ + val = n_lo | ( ((unsigned long long)h_hi) << 32 ); \ + __llrotr (val,1); \ + n_hi = (unsigned long)((val >> 32 ) & 0xffffffff ); \ + n_lo = (unsigned long)(val & 0xffffffff); \ +} + +/* IBM VAC does not have inline */ + +#if __IBMC__ || __IBMCPP__ +#define inline +#endif + +#ifndef ACPI_ASL_COMPILER +#define ACPI_USE_LOCAL_CACHE +#undef ACPI_DEBUGGER +#endif + +#endif /* __ACOS2_H__ */ diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin.h index 4845d7364c..d1fa2ee22b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acwin.h - OS specific defines, etc. - * $Revision: 1.30 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -127,7 +126,6 @@ #define ACPI_MACHINE_WIDTH 32 -#define isascii __isascii #define inline __inline #define ACPI_USE_STANDARD_HEADERS @@ -156,16 +154,9 @@ typedef COMPILER_DEPENDENT_UINT64 u64; /*! [Begin] no source code translation */ -#define ACPI_ASM_MACROS #ifdef ACPI_APPLICATION -#define BREAKPOINT3 -#define ACPI_DISABLE_IRQS() -#define ACPI_ENABLE_IRQS() #define ACPI_FLUSH_CPU_CACHE() #else -#define BREAKPOINT3 __asm {int 3} -#define ACPI_DISABLE_IRQS() __asm {cli} -#define ACPI_ENABLE_IRQS() __asm {sti} #define ACPI_FLUSH_CPU_CACHE() __asm {WBINVD} #endif diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin64.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin64.h index 6b289a439f..faec855e22 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin64.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/acwin64.h @@ -1,7 +1,6 @@ /****************************************************************************** * * Name: acwin.h - OS specific defines, etc. - * $Revision: 1.17 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -136,14 +135,8 @@ /*! [Begin] no source code translation */ -#define ACPI_ASM_MACROS -#define causeinterrupt(level) -#define BREAKPOINT3 -#define ACPI_DISABLE_IRQS() -#define ACPI_ENABLE_IRQS() #define ACPI_FLUSH_CPU_CACHE() - /* * For Acpi applications, we don't want to try to access the global lock */ diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsaccess.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsaccess.c index 810819d145..172b26d3ab 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsaccess.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsaccess.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * $Revision: 1.209 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __NSACCESS_C__ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acnamesp.h" #include "acdispat.h" @@ -202,9 +202,8 @@ AcpiNsRootInitialize ( } /* - * Name entered successfully. - * If entry in PreDefinedNames[] specifies an - * initial value, create the initial value. + * Name entered successfully. If entry in PreDefinedNames[] specifies + * an initial value, create the initial value. */ if (InitVal->Val) { @@ -252,10 +251,7 @@ AcpiNsRootInitialize ( /* Mark this as a very SPECIAL method */ ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; - -#ifndef ACPI_DUMP_APP ObjDesc->Method.Implementation = AcpiUtOsiImplementation; -#endif #endif break; @@ -267,9 +263,8 @@ AcpiNsRootInitialize ( case ACPI_TYPE_STRING: - /* - * Build an object around the static string - */ + /* Build an object around the static string */ + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); ObjDesc->String.Pointer = Val; ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; @@ -321,7 +316,7 @@ AcpiNsRootInitialize ( /* Store pointer to value descriptor in the Node */ Status = AcpiNsAttachObject (NewNode, ObjDesc, - ACPI_GET_OBJECT_TYPE (ObjDesc)); + ObjDesc->Common.Type); /* Remove local reference to the object */ @@ -409,10 +404,8 @@ AcpiNsLookup ( return_ACPI_STATUS (AE_NO_NAMESPACE); } - /* - * Get the prefix scope. - * A null scope means use the root scope - */ + /* Get the prefix scope. A null scope means use the root scope */ + if ((!ScopeInfo) || (!ScopeInfo->Scope.Node)) { @@ -436,8 +429,8 @@ AcpiNsLookup ( { /* * This node might not be a actual "scope" node (such as a - * Device/Method, etc.) It could be a Package or other object node. - * Backup up the tree to find the containing scope node. + * Device/Method, etc.) It could be a Package or other object + * node. Backup up the tree to find the containing scope node. */ while (!AcpiNsOpensScope (PrefixNode->Type) && PrefixNode->Type != ACPI_TYPE_ANY) @@ -447,7 +440,7 @@ AcpiNsLookup ( } } - /* Save type TBD: may be no longer necessary */ + /* Save type. TBD: may be no longer necessary */ TypeToCheckFor = Type; @@ -513,6 +506,7 @@ AcpiNsLookup ( /* Name is fully qualified, no search rules apply */ SearchParentFlag = ACPI_NS_NO_UPSEARCH; + /* * Point past this prefix to the name segment * part or the next Parent Prefix @@ -528,7 +522,8 @@ AcpiNsLookup ( /* Current scope has no parent scope */ ACPI_ERROR ((AE_INFO, - "ACPI path has too many parent prefixes (^) - reached beyond root node")); + "ACPI path has too many parent prefixes (^) " + "- reached beyond root node")); return_ACPI_STATUS (AE_NOT_FOUND); } } @@ -618,11 +613,11 @@ AcpiNsLookup ( /* - * Search namespace for each segment of the name. Loop through and + * Search namespace for each segment of the name. Loop through and * verify (or add to the namespace) each name segment. * * The object type is significant only at the last name - * segment. (We don't care about the types along the path, only + * segment. (We don't care about the types along the path, only * the type of the final target object.) */ ThisSearchType = ACPI_TYPE_ANY; @@ -632,9 +627,8 @@ AcpiNsLookup ( NumSegments--; if (!NumSegments) { - /* - * This is the last segment, enable typechecking - */ + /* This is the last segment, enable typechecking */ + ThisSearchType = Type; /* @@ -685,13 +679,19 @@ AcpiNsLookup ( { /* * If we have an alias to an object that opens a scope (such as a - * device or processor), we need to dereference the alias here so that - * we can access any children of the original node (via the remaining - * segments). + * device or processor), we need to dereference the alias here so + * that we can access any children of the original node (via the + * remaining segments). */ if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) { - if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) ThisNode->Object)->Type)) + if (!ThisNode->Object) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) + ThisNode->Object)->Type)) { ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; } @@ -733,8 +733,8 @@ AcpiNsLookup ( /* * If this is the last name segment and we are not looking for a - * specific type, but the type of found object is known, use that type - * to (later) see if it opens a scope. + * specific type, but the type of found object is known, use that + * type to (later) see if it opens a scope. */ if (Type == ACPI_TYPE_ANY) { @@ -748,9 +748,8 @@ AcpiNsLookup ( CurrentNode = ThisNode; } - /* - * Always check if we need to open a new scope - */ + /* Always check if we need to open a new scope */ + if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) { /* diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsalloc.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsalloc.c index 4fef3c1426..9693cb7835 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsalloc.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsalloc.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities - * $Revision: 1.109 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __NSALLOC_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" @@ -159,7 +159,8 @@ AcpiNsCreateNode ( ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); #ifdef ACPI_DBG_TRACK_ALLOCATIONS - Temp = AcpiGbl_NsNodeList->TotalAllocated - AcpiGbl_NsNodeList->TotalFreed; + Temp = AcpiGbl_NsNodeList->TotalAllocated - + AcpiGbl_NsNodeList->TotalFreed; if (Temp > AcpiGbl_NsNodeList->MaxOccupied) { AcpiGbl_NsNodeList->MaxOccupied = Temp; @@ -180,20 +181,78 @@ AcpiNsCreateNode ( * * RETURN: None * - * DESCRIPTION: Delete a namespace node + * DESCRIPTION: Delete a namespace node. All node deletions must come through + * here. Detaches any attached objects, including any attached + * data. If a handler is associated with attached data, it is + * invoked before the node is deleted. * ******************************************************************************/ void AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsDeleteNode); + + + /* Detach an object if there is one */ + + AcpiNsDetachObject (Node); + + /* + * Delete an attached data object if present (an object that was created + * and attached via AcpiAttachData). Note: After any normal object is + * detached above, the only possible remaining object is a data object. + */ + ObjDesc = Node->Object; + if (ObjDesc && + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + /* Invoke the attached data deletion handler if present */ + + if (ObjDesc->Data.Handler) + { + ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); + } + + AcpiUtRemoveReference (ObjDesc); + } + + /* Now we can delete the node */ + + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", + Node, AcpiGbl_CurrentNodeCount)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveNode + * + * PARAMETERS: Node - Node to be removed/deleted + * + * RETURN: None + * + * DESCRIPTION: Remove (unlink) and delete a namespace node + * + ******************************************************************************/ + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node) { ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *PrevNode; ACPI_NAMESPACE_NODE *NextNode; - ACPI_FUNCTION_TRACE_PTR (NsDeleteNode, Node); + ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node); ParentNode = AcpiNsGetParentNode (Node); @@ -236,13 +295,9 @@ AcpiNsDeleteNode ( } } - ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); + /* Delete the node and any attached objects */ - /* - * Detach an object if there is one, then delete the node - */ - AcpiNsDetachObject (Node); - (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); + AcpiNsDeleteNode (Node); return_VOID; } @@ -282,9 +337,8 @@ AcpiNsInstallNode ( /* - * Get the owner ID from the Walk state - * The owner ID is used to track table deletion and - * deletion of objects created by methods + * Get the owner ID from the Walk state. The owner ID is used to track + * table deletion and deletion of objects created by methods. */ if (WalkState) { @@ -369,9 +423,8 @@ AcpiNsDeleteChildren ( return_VOID; } - /* - * Deallocate all children at this level - */ + /* Deallocate all children at this level */ + do { /* Get the things we need */ @@ -387,33 +440,18 @@ AcpiNsDeleteChildren ( ParentNode, ChildNode)); } - /* Now we can free this child object */ - - ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); - - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", - ChildNode, AcpiGbl_CurrentNodeCount)); - /* - * Detach an object if there is one, then free the child node + * Delete this child node and move on to the next child in the list. + * No need to unlink the node since we are deleting the entire branch. */ - AcpiNsDetachObject (ChildNode); - - /* Now we can delete the node */ - - (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, ChildNode); - - /* And move on to the next child in the list */ - + AcpiNsDeleteNode (ChildNode); ChildNode = NextNode; } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); - /* Clear the parent's child pointer */ ParentNode->Child = NULL; - return_VOID; } @@ -455,7 +493,7 @@ AcpiNsDeleteNamespaceSubtree ( { /* Get the next node in this scope (NULL if none) */ - ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); if (ChildNode) { /* Found a child node - detach any attached object */ @@ -464,7 +502,7 @@ AcpiNsDeleteNamespaceSubtree ( /* Check if this node has any children */ - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) + if (ChildNode->Child) { /* * There is at least one child of this node, @@ -561,12 +599,12 @@ AcpiNsDeleteNamespaceByOwner ( * Get the next child of this parent node. When ChildNode is NULL, * the first child of the parent is returned */ - ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); if (DeletionNode) { AcpiNsDeleteChildren (DeletionNode); - AcpiNsDeleteNode (DeletionNode); + AcpiNsRemoveNode (DeletionNode); DeletionNode = NULL; } @@ -581,7 +619,7 @@ AcpiNsDeleteNamespaceByOwner ( /* Check if this node has any children */ - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) + if (ChildNode->Child) { /* * There is at least one child of this node, diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsdump.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsdump.c index 7e029442de..762437aa12 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsdump.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsdump.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * $Revision: 1.185 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,8 +117,8 @@ #define __NSDUMP_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" -#include "acparser.h" #define _COMPONENT ACPI_NAMESPACE @@ -288,6 +287,13 @@ AcpiNsDumpOneObject ( } ThisNode = AcpiNsMapHandleToNode (ObjHandle); + if (!ThisNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n", + ObjHandle)); + return (AE_OK); + } + Type = ThisNode->Type; /* Check if the owner matches */ @@ -314,9 +320,8 @@ AcpiNsDumpOneObject ( AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); } - /* - * Now we can print out the pertinent information - */ + /* Now we can print out the pertinent information */ + AcpiOsPrintf (" %-12s %p %2.2X ", AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); @@ -442,8 +447,7 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("[%s]\n", - AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); + AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc)); break; @@ -453,7 +457,8 @@ AcpiNsDumpOneObject ( ObjDesc->BufferField.BufferObj->Buffer.Node) { AcpiOsPrintf ("Buf [%4.4s]", - AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node)); + AcpiUtGetNodeName ( + ObjDesc->BufferField.BufferObj->Buffer.Node)); } break; @@ -461,23 +466,28 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_REGION_FIELD: AcpiOsPrintf ("Rgn [%4.4s]", - AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node)); + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node)); break; case ACPI_TYPE_LOCAL_BANK_FIELD: AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", - AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node), - AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node)); + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node), + AcpiUtGetNodeName ( + ObjDesc->BankField.BankObj->CommonField.Node)); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", - AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node), - AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node)); + AcpiUtGetNodeName ( + ObjDesc->IndexField.IndexObj->CommonField.Node), + AcpiUtGetNodeName ( + ObjDesc->IndexField.DataObj->CommonField.Node)); break; @@ -536,25 +546,25 @@ AcpiNsDumpOneObject ( /* Name is a Method and its AML offset/length are set */ AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength); + ObjDesc->Method.AmlLength); break; case ACPI_TYPE_INTEGER: AcpiOsPrintf (" I:%8.8X8.8%X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer, - ObjDesc->String.Length); + ObjDesc->String.Length); break; case ACPI_TYPE_BUFFER: AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer, - ObjDesc->Buffer.Length); + ObjDesc->Buffer.Length); break; default: @@ -577,7 +587,6 @@ AcpiNsDumpOneObject ( return (AE_OK); } - /* If there is an attached object, display it */ DbgLevel = AcpiDbgLevel; @@ -605,7 +614,7 @@ AcpiNsDumpOneObject ( case ACPI_DESC_TYPE_OPERAND: - ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc); + ObjType = ObjDesc->Common.Type; if (ObjType > ACPI_TYPE_LOCAL_MAX) { @@ -635,9 +644,8 @@ AcpiNsDumpOneObject ( goto Cleanup; } - /* - * Valid object, get the pointer to next level, if any - */ + /* Valid object, get the pointer to next level, if any */ + switch (ObjType) { case ACPI_TYPE_BUFFER: @@ -697,14 +705,14 @@ Cleanup: * DisplayType - 0 or ACPI_DISPLAY_SUMMARY * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX * for an effectively unlimited depth. - * OwnerId - Dump only objects owned by this ID. Use + * OwnerId - Dump only objects owned by this ID. Use * ACPI_UINT32_MAX to match all owners. * StartHandle - Where in namespace to start/end search * * RETURN: None * - * DESCRIPTION: Dump typed objects within the loaded namespace. - * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. + * DESCRIPTION: Dump typed objects within the loaded namespace. Uses + * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. * ******************************************************************************/ diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsdumpdv.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsdumpdv.c index a5584cab95..a2456b2429 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsdumpdv.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsdumpdv.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * $Revision: 1.21 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nseval.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nseval.c index 8d1196c20a..c84a4d58ce 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nseval.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nseval.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: nseval - Object evaluation, includes control method execution - * $Revision: 1.145 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __NSEVAL_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acinterp.h" #include "acnamesp.h" @@ -126,6 +126,13 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nseval") +/* Local prototypes */ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info); + /******************************************************************************* * @@ -159,6 +166,7 @@ AcpiNsEvaluate ( ACPI_EVALUATE_INFO *Info) { ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; ACPI_FUNCTION_TRACE (NsEvaluate); @@ -172,6 +180,7 @@ AcpiNsEvaluate ( /* Initialize the return value to an invalid object */ Info->ReturnObject = NULL; + Info->ParamCount = 0; /* * Get the actual namespace node for the target object. Handles these cases: @@ -200,6 +209,8 @@ AcpiNsEvaluate ( ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); + Node = Info->ResolvedNode; + /* * Two major cases here: * @@ -221,39 +232,21 @@ AcpiNsEvaluate ( return_ACPI_STATUS (AE_NULL_OBJECT); } - /* Calculate the number of arguments being passed to the method */ + /* Count the number of arguments being passed to the method */ - Info->ParamCount = 0; if (Info->Parameters) { while (Info->Parameters[Info->ParamCount]) { + if (Info->ParamCount > ACPI_METHOD_MAX_ARG) + { + return_ACPI_STATUS (AE_LIMIT); + } Info->ParamCount++; } } - /* Error if too few arguments were passed in */ - - if (Info->ParamCount < Info->ObjDesc->Method.ParamCount) - { - ACPI_ERROR ((AE_INFO, - "Insufficient arguments - method [%4.4s] needs %d, found %d", - AcpiUtGetNodeName (Info->ResolvedNode), - Info->ObjDesc->Method.ParamCount, Info->ParamCount)); - return_ACPI_STATUS (AE_MISSING_ARGUMENTS); - } - - /* Just a warning if too many arguments */ - - else if (Info->ParamCount > Info->ObjDesc->Method.ParamCount) - { - ACPI_WARNING ((AE_INFO, - "Excess arguments - method [%4.4s] needs %d, found %d", - AcpiUtGetNodeName (Info->ResolvedNode), - Info->ObjDesc->Method.ParamCount, Info->ParamCount)); - } - - ACPI_DUMP_PATHNAME (Info->ResolvedNode, "Execute Method:", + ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method", ACPI_LV_INFO, _COMPONENT); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -277,7 +270,28 @@ AcpiNsEvaluate ( { /* * 2) Object is not a method, return its current value + * + * Disallow certain object types. For these, "evaluation" is undefined. */ + switch (Info->ResolvedNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_REGION: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + ACPI_ERROR ((AE_INFO, + "[%4.4s] Evaluation of object type [%s] is not supported", + Info->ResolvedNode->Name.Ascii, + AcpiUtGetTypeName (Info->ResolvedNode->Type))); + + return_ACPI_STATUS (AE_TYPE); + + default: + break; + } /* * Objects require additional resolution steps (e.g., the Node may be @@ -319,8 +333,15 @@ AcpiNsEvaluate ( } /* - * Check if there is a return value that must be dealt with + * Check input argument count against the ASL-defined count for a method. + * Also check predefined names: argument count and return value against + * the ACPI specification. Some incorrect return value types are repaired. */ + (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount, + Status, &Info->ReturnObject); + + /* Check if there is a return value that must be dealt with */ + if (Status == AE_CTRL_RETURN_VALUE) { /* If caller does not want the return value, delete it */ @@ -346,3 +367,145 @@ AcpiNsEvaluate ( return_ACPI_STATUS (Status); } + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCodeList + * + * PARAMETERS: None + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute all elements of the global module-level code list. + * Each element is executed as a single control method. + * + ******************************************************************************/ + +void +AcpiNsExecModuleCodeList ( + void) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_EVALUATE_INFO *Info; + UINT32 MethodCount = 0; + + + ACPI_FUNCTION_TRACE (NsExecModuleCodeList); + + + /* Exit now if the list is empty */ + + Next = AcpiGbl_ModuleCodeList; + if (!Next) + { + return_VOID; + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_VOID; + } + + /* Walk the list, executing each "method" */ + + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + + /* Clear the link field and execute the method */ + + Prev->Method.Mutex = NULL; + AcpiNsExecModuleCode (Prev, Info); + MethodCount++; + + /* Delete the (temporary) method object */ + + AcpiUtRemoveReference (Prev); + } + + ACPI_INFO ((AE_INFO, + "Executed %u blocks of module-level executable AML code", + MethodCount)); + + ACPI_FREE (Info); + AcpiGbl_ModuleCodeList = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCode + * + * PARAMETERS: MethodObj - Object container for the module-level code + * Info - Info block for method evaluation + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute a control method containing a block of module-level + * executable AML code. The control method is temporarily + * installed to the root node, then evaluated. + * + ******************************************************************************/ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *RootObj; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsExecModuleCode); + + + /* Initialize the evaluation information block */ + + ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = AcpiGbl_RootNode; + + /* + * Get the currently attached root object. Add a reference, because the + * ref count will be decreased when the method object is installed to + * the root node. + */ + RootObj = AcpiNsGetAttachedObject (AcpiGbl_RootNode); + AcpiUtAddReference (RootObj); + + /* Install the method (module-level code) in the root node */ + + Status = AcpiNsAttachObject (AcpiGbl_RootNode, MethodObj, + ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Execute the root node as a control method */ + + Status = AcpiNsEvaluate (Info); + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", + MethodObj->Method.AmlStart)); + + /* Detach the temporary method object */ + + AcpiNsDetachObject (AcpiGbl_RootNode); + + /* Restore the original root object */ + + Status = AcpiNsAttachObject (AcpiGbl_RootNode, RootObj, ACPI_TYPE_DEVICE); + +Exit: + AcpiUtRemoveReference (RootObj); + return_VOID; +} + diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsinit.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsinit.c index e0116e0eb0..fcea63e7ac 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsinit.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsinit.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * $Revision: 1.88 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __NSXFINIT_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acdispat.h" #include "acinterp.h" @@ -193,7 +193,8 @@ AcpiNsInitializeObjects ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", + "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " + "Buffers %hd/%hd Packages (%hd nodes)\n", Info.OpRegionInit, Info.OpRegionCount, Info.FieldInit, Info.FieldCount, Info.BufferInit, Info.BufferCount, @@ -242,7 +243,8 @@ AcpiNsInitializeDevices ( Info.Num_INI = 0; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Initializing Device/Processor/Thermal objects by executing _INI methods:")); + "Initializing Device/Processor/Thermal objects " + "by executing _INI methods:")); /* Tree analysis: find all subtrees that contain _INI methods */ @@ -262,6 +264,22 @@ AcpiNsInitializeDevices ( goto ErrorExit; } + /* + * Execute the "global" _INI method that may appear at the root. This + * support is provided for Windows compatibility (Vista+) and is not + * part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->Pathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + /* Walk namespace to execute all _INIs on present devices */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, @@ -274,7 +292,8 @@ AcpiNsInitializeDevices ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nExecuted %hd _INI methods requiring %hd _STA executions (examined %hd objects)\n", + "\nExecuted %hd _INI methods requiring %hd _STA executions " + "(examined %hd objects)\n", Info.Num_INI, Info.Num_STA, Info.DeviceCount)); return_ACPI_STATUS (Status); @@ -364,17 +383,15 @@ AcpiNsInitOneObject ( return (AE_OK); } - /* - * If the object is already initialized, nothing else to do - */ + /* If the object is already initialized, nothing else to do */ + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { return (AE_OK); } - /* - * Must lock the interpreter before executing AML code - */ + /* Must lock the interpreter before executing AML code */ + AcpiExEnterInterpreter (); /* diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsload.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsload.c index 8e11306105..a9f3824718 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsload.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsload.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: nsload - namespace loading/expanding/contracting procedures - * $Revision: 1.83 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __NSLOAD_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acdispat.h" #include "actables.h" @@ -220,12 +220,12 @@ Unlock: * parse trees. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Begin Table Method Parsing and Object Initialization ****\n")); + "**** Begin Table Method Parsing and Object Initialization\n")); Status = AcpiDsInitializeObjects (TableIndex, Node); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Completed Table Method Parsing and Object Initialization ****\n")); + "**** Completed Table Method Parsing and Object Initialization\n")); return_ACPI_STATUS (Status); } @@ -376,8 +376,7 @@ AcpiNsDeleteSubtree ( /* Now delete the starting object, and we are done */ - AcpiNsDeleteNode (ChildHandle); - + AcpiNsRemoveNode (ChildHandle); return_ACPI_STATUS (AE_OK); } diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsnames.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsnames.c index 1d220bebaa..0dd148fa7c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsnames.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsnames.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: nsnames - Name manipulation and search - * $Revision: 1.101 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __NSNAMES_C__ #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acnamesp.h" @@ -133,14 +133,15 @@ * Size - Size of the pathname * *NameBuffer - Where to return the pathname * - * RETURN: Places the pathname into the NameBuffer, in external format + * RETURN: Status + * Places the pathname into the NameBuffer, in external format * (name segments separated by path separators) * * DESCRIPTION: Generate a full pathaname * ******************************************************************************/ -void +ACPI_STATUS AcpiNsBuildExternalPath ( ACPI_NAMESPACE_NODE *Node, ACPI_SIZE Size, @@ -160,7 +161,7 @@ AcpiNsBuildExternalPath ( { NameBuffer[0] = AML_ROOT_PREFIX; NameBuffer[1] = 0; - return; + return (AE_OK); } /* Store terminator byte, then build name backwards */ @@ -190,15 +191,16 @@ AcpiNsBuildExternalPath ( if (Index != 0) { ACPI_ERROR ((AE_INFO, - "Could not construct pathname; index=%X, size=%X, Path=%s", + "Could not construct external pathname; index=%X, size=%X, Path=%s", (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); + + return (AE_BAD_PARAMETER); } - return; + return (AE_OK); } -#ifdef ACPI_DEBUG_OUTPUT /******************************************************************************* * * FUNCTION: AcpiNsGetExternalPathname @@ -209,7 +211,8 @@ AcpiNsBuildExternalPath ( * the node, In external format (name segments separated by path * separators.) * - * DESCRIPTION: Used for debug printing in AcpiNsSearchTable(). + * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually + * for error and debug statements. * ******************************************************************************/ @@ -217,6 +220,7 @@ char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node) { + ACPI_STATUS Status; char *NameBuffer; ACPI_SIZE Size; @@ -227,22 +231,31 @@ AcpiNsGetExternalPathname ( /* Calculate required buffer size based on depth below root */ Size = AcpiNsGetPathnameLength (Node); + if (!Size) + { + return_PTR (NULL); + } /* Allocate a buffer to be returned to caller */ NameBuffer = ACPI_ALLOCATE_ZEROED (Size); if (!NameBuffer) { - ACPI_ERROR ((AE_INFO, "Allocation failure")); + ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size)); return_PTR (NULL); } /* Build the path in the allocated buffer */ - AcpiNsBuildExternalPath (Node, Size, NameBuffer); + Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (NameBuffer); + return_PTR (NULL); + } + return_PTR (NameBuffer); } -#endif /******************************************************************************* @@ -279,7 +292,8 @@ AcpiNsGetPathnameLength ( { if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED) { - ACPI_ERROR ((AE_INFO, "Invalid NS Node (%p) while traversing path", + ACPI_ERROR ((AE_INFO, + "Invalid Namespace Node (%p) while traversing namespace", NextNode)); return 0; } @@ -289,7 +303,7 @@ AcpiNsGetPathnameLength ( if (!Size) { - Size = 1; /* Root node case */ + Size = 1; /* Root node case */ } return (Size + 1); /* +1 for null string terminator */ @@ -332,6 +346,10 @@ AcpiNsHandleToPathname ( /* Determine size required for the caller buffer */ RequiredSize = AcpiNsGetPathnameLength (Node); + if (!RequiredSize) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } /* Validate/Allocate/Clear caller buffer */ @@ -343,7 +361,11 @@ AcpiNsHandleToPathname ( /* Build the path in the caller buffer */ - AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n", (char *) Buffer->Pointer, (UINT32) RequiredSize)); diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsobject.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsobject.c index d86a4fa34d..c0163f4ea2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsobject.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsobject.c @@ -2,7 +2,6 @@ * * Module Name: nsobject - Utilities for objects attached to namespace * table entries - * $Revision: 1.99 $ * ******************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __NSOBJECT_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" @@ -304,11 +304,21 @@ AcpiNsDetachObject ( ObjDesc = Node->Object; if (!ObjDesc || - (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA)) + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) { return_VOID; } + if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) + { + /* Free the dynamic aml buffer */ + + if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_FREE (ObjDesc->Method.AmlStart); + } + } + /* Clear the entry in all cases */ Node->Object = NULL; @@ -316,7 +326,7 @@ AcpiNsDetachObject ( { Node->Object = ObjDesc->Common.NextObject; if (Node->Object && - (ACPI_GET_OBJECT_TYPE (Node->Object) != ACPI_TYPE_LOCAL_DATA)) + ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) { Node->Object = Node->Object->Common.NextObject; } @@ -365,7 +375,7 @@ AcpiNsGetAttachedObject ( if (!Node->Object || ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || - (ACPI_GET_OBJECT_TYPE (Node->Object) == ACPI_TYPE_LOCAL_DATA)) + ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) { return_PTR (NULL); } @@ -394,10 +404,10 @@ AcpiNsGetSecondaryObject ( ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); - if ((!ObjDesc) || - (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) || - (!ObjDesc->Common.NextObject) || - (ACPI_GET_OBJECT_TYPE (ObjDesc->Common.NextObject) == ACPI_TYPE_LOCAL_DATA)) + if ((!ObjDesc) || + (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || + (!ObjDesc->Common.NextObject) || + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) { return_PTR (NULL); } @@ -437,7 +447,7 @@ AcpiNsAttachData ( ObjDesc = Node->Object; while (ObjDesc) { - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) && + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && (ObjDesc->Data.Handler == Handler)) { return (AE_ALREADY_EXISTS); @@ -500,7 +510,7 @@ AcpiNsDetachData ( ObjDesc = Node->Object; while (ObjDesc) { - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) && + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && (ObjDesc->Data.Handler == Handler)) { if (PrevObjDesc) @@ -551,7 +561,7 @@ AcpiNsGetAttachedData ( ObjDesc = Node->Object; while (ObjDesc) { - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) && + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && (ObjDesc->Data.Handler == Handler)) { *Data = ObjDesc->Data.Pointer; diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsparse.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsparse.c index 2bd28decfa..58301560ae 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsparse.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsparse.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: nsparse - namespace interface to AML parser - * $Revision: 1.19 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __NSPARSE_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acparser.h" #include "acdispat.h" @@ -267,7 +267,8 @@ AcpiNsParseTable ( * performs another complete parse of the AML. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, TableIndex, StartNode); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, + TableIndex, StartNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -283,7 +284,8 @@ AcpiNsParseTable ( * parse objects are all cached. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, StartNode); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, + TableIndex, StartNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nspredef.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nspredef.c new file mode 100644 index 0000000000..93bcbdef28 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nspredef.c @@ -0,0 +1,1237 @@ +/****************************************************************************** + * + * Module Name: nspredef - Validation of ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define ACPI_CREATE_PREDEFINED_TABLE + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nspredef") + + +/******************************************************************************* + * + * This module validates predefined ACPI objects that appear in the namespace, + * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this + * validation is to detect problems with BIOS-exposed predefined ACPI objects + * before the results are returned to the ACPI-related drivers. + * + * There are several areas that are validated: + * + * 1) The number of input arguments as defined by the method/object in the + * ASL is validated against the ACPI specification. + * 2) The type of the return object (if any) is validated against the ACPI + * specification. + * 3) For returned package objects, the count of package elements is + * validated, as well as the type of each package element. Nested + * packages are supported. + * + * For any problems found, a warning message is issued. + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex); + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex); + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject); + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); + +/* + * Names for the types that can be returned by the predefined objects. + * Used for warning messages. Must be in the same order as the ACPI_RTYPEs + */ +static const char *AcpiRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPredefinedNames + * + * PARAMETERS: Node - Namespace node for the method/object + * UserParamCount - Number of parameters actually passed + * ReturnStatus - Status from the object evaluation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check an ACPI name for a match in the predefined name list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + const ACPI_PREDEFINED_INFO *Predefined; + char *Pathname; + ACPI_PREDEFINED_DATA *Data; + + + /* Match the name for this method/object against the predefined list */ + + Predefined = AcpiNsCheckForPredefinedName (Node); + + /* Get the full pathname to the object, for use in warning messages */ + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); /* Could not get pathname, ignore */ + } + + /* + * Check that the parameter count for this method matches the ASL + * definition. For predefined names, ensure that both the caller and + * the method itself are in accordance with the ACPI specification. + */ + AcpiNsCheckParameterCount (Pathname, Node, UserParamCount, Predefined); + + /* If not a predefined name, we cannot validate the return object */ + + if (!Predefined) + { + goto Cleanup; + } + + /* + * If the method failed or did not actually return an object, we cannot + * validate the return object + */ + if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE)) + { + goto Cleanup; + } + + /* + * If there is no return value, check if we require a return value for + * this predefined name. Either one return value is expected, or none, + * for both methods and other objects. + * + * Exit now if there is no return object. Warning if one was expected. + */ + if (!ReturnObject) + { + if ((Predefined->Info.ExpectedBtypes) && + (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE))) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Missing expected return value")); + + Status = AE_AML_NO_RETURN_VALUE; + } + goto Cleanup; + } + + /* + * 1) We have a return value, but if one wasn't expected, just exit, this is + * not a problem. For example, if the "Implicit Return" feature is + * enabled, methods will always return a value. + * + * 2) If the return value can be of any type, then we cannot perform any + * validation, exit. + */ + if ((!Predefined->Info.ExpectedBtypes) || + (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) + { + goto Cleanup; + } + + /* Create the parameter data block for object validation */ + + Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA)); + if (!Data) + { + goto Cleanup; + } + Data->Predefined = Predefined; + Data->NodeFlags = Node->Flags; + Data->Pathname = Pathname; + + /* + * Check that the type of the return object is what is expected for + * this predefined name + */ + Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr, + Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); + if (ACPI_FAILURE (Status)) + { + goto CheckValidationStatus; + } + + /* For returned Package objects, check the type of all sub-objects */ + + if (ReturnObject->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiNsCheckPackage (Data, ReturnObjectPtr); + } + + +CheckValidationStatus: + /* + * If the object validation failed or if we successfully repaired one + * or more objects, mark the parent node to suppress further warning + * messages during the next evaluation of the same method/object. + */ + if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED)) + { + Node->Flags |= ANOBJ_EVALUATED; + } + ACPI_FREE (Data); + + +Cleanup: + ACPI_FREE (Pathname); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckParameterCount + * + * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * Node - Namespace node for the method/object + * UserParamCount - Number of args passed in by the caller + * Predefined - Pointer to entry in predefined name table + * + * RETURN: None + * + * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a + * predefined name is what is expected (i.e., what is defined in + * the ACPI specification for this predefined name.) + * + ******************************************************************************/ + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Predefined) +{ + UINT32 ParamCount; + UINT32 RequiredParamsCurrent; + UINT32 RequiredParamsOld; + + + /* Methods have 0-7 parameters. All other types have zero. */ + + ParamCount = 0; + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + if (!Predefined) + { + /* + * Check the parameter count for non-predefined methods/objects. + * + * Warning if too few or too many arguments have been passed by the + * caller. An incorrect number of arguments may not cause the method + * to fail. However, the method will fail if there are too few + * arguments and the method attempts to use one of the missing ones. + */ + if (UserParamCount < ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Insufficient arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + else if (UserParamCount > ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Excess arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + return; + } + + /* + * Validate the user-supplied parameter count. + * Allow two different legal argument counts (_SCP, etc.) + */ + RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F; + RequiredParamsOld = Predefined->Info.ParamCount >> 4; + + if (UserParamCount != ACPI_UINT32_MAX) + { + if ((UserParamCount != RequiredParamsCurrent) && + (UserParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Parameter count mismatch - " + "caller passed %u, ACPI requires %u", + UserParamCount, RequiredParamsCurrent)); + } + } + + /* + * Check that the ASL-defined parameter count is what is expected for + * this predefined name (parameter count as defined by the ACPI + * specification) + */ + if ((ParamCount != RequiredParamsCurrent) && + (ParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags, + "Parameter count mismatch - ASL declared %u, ACPI requires %u", + ParamCount, RequiredParamsCurrent)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckForPredefinedName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in predefined table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the predefined object list. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_PREDEFINED_INFO *ThisName; + + + /* Quick check for a predefined name, first character must be underscore */ + + if (Node->Name.Ascii[0] != '_') + { + return (NULL); + } + + /* Search info table for a predefined method/object name */ + + ThisName = PredefinedNames; + while (ThisName->Info.Name[0]) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name)) + { + return (ThisName); + } + + /* + * Skip next entry in the table if this name returns a Package + * (next entry contains the package info) + */ + if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + ThisName++; + } + + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackage + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + const ACPI_PREDEFINED_INFO *Package; + ACPI_OPERAND_OBJECT **Elements; + ACPI_STATUS Status = AE_OK; + UINT32 ExpectedCount; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsCheckPackage); + + + /* The package info for this name is in the next table entry */ + + Package = Data->Predefined + 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%s Validating return Package of Type %X, Count %X\n", + Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count)); + + /* Extract package count and elements array */ + + Elements = ReturnObject->Package.Elements; + Count = ReturnObject->Package.Count; + + /* The package must have at least one element, else invalid */ + + if (!Count) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package has no elements (empty)")); + + return (AE_AML_OPERAND_VALUE); + } + + /* + * Decode the type of the expected package contents + * + * PTYPE1 packages contain no subpackages + * PTYPE2 packages contain sub-packages + */ + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE1_FIXED: + + /* + * The package count is fixed and there are no sub-packages + * + * If package is too small, exit. + * If package is larger than expected, issue warning but continue + */ + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + else if (Count > ExpectedCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package is larger than needed - " + "found %u, expected %u", Count, ExpectedCount)); + } + + /* Validate all elements of the returned package */ + + Status = AcpiNsCheckPackageElements (Data, Elements, + Package->RetInfo.ObjectType1, Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); + break; + + + case ACPI_PTYPE1_VAR: + + /* + * The package count is variable, there are no sub-packages, and all + * elements must be of the same type + */ + for (i = 0; i < Count; i++) + { + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo.ObjectType1, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Elements++; + } + break; + + + case ACPI_PTYPE1_OPTION: + + /* + * The package count is variable, there are no sub-packages. There are + * a fixed number of required elements, and a variable number of + * optional elements. + * + * Check if package is at least as large as the minimum required + */ + ExpectedCount = Package->RetInfo3.Count; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Variable number of sub-objects */ + + for (i = 0; i < Count; i++) + { + if (i < Package->RetInfo3.Count) + { + /* These are the required package elements (0, 1, or 2) */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.ObjectType[i], i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else + { + /* These are the optional package elements */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.TailObjectType, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + Elements++; + } + break; + + + case ACPI_PTYPE2_REV_FIXED: + + /* First element is the (Integer) revision */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Elements++; + Count--; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2_PKG_COUNT: + + /* First element is the (Integer) count of sub-packages to follow */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Count cannot be larger than the parent package length, but allow it + * to be smaller. The >= accounts for the Integer above. + */ + ExpectedCount = (UINT32) (*Elements)->Integer.Value; + if (ExpectedCount >= Count) + { + goto PackageTooSmall; + } + + Count = ExpectedCount; + Elements++; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_COUNT: + + /* + * These types all return a single Package that consists of a + * variable number of sub-Packages. + * + * First, ensure that the first element is a sub-Package. If not, + * the BIOS may have incorrectly returned the object as a single + * package instead of a Package of Packages (a common error if + * there is only one entry). We may be able to repair this by + * wrapping the returned Package with a new outer Package. + */ + if ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE) + { + /* Create the new outer package and populate it */ + + Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update locals to point to the new package (of 1 element) */ + + ReturnObject = *ReturnObjectPtr; + Elements = ReturnObject->Package.Elements; + Count = 1; + } + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + default: + + /* Should not get here if predefined info table is correct */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid internal return type in table entry: %X", + Package->RetInfo.Type)); + + return (AE_AML_INTERNAL); + } + + return (Status); + + +PackageTooSmall: + + /* Error exit for the case with an incorrect package count */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * Package - Pointer to package-specific info for method + * Elements - Element list of parent package. All elements + * of this list should be of type Package. + * Count - Count of subpackages + * + * RETURN: Status + * + * DESCRIPTION: Examine a list of subpackages + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *SubPackage; + ACPI_OPERAND_OBJECT **SubElements; + ACPI_STATUS Status; + UINT32 ExpectedCount; + UINT32 i; + UINT32 j; + + + /* Validate each sub-Package in the parent Package */ + + for (i = 0; i < Count; i++) + { + SubPackage = *Elements; + SubElements = SubPackage->Package.Elements; + + /* Each sub-object must be of type Package */ + + Status = AcpiNsCheckObjectType (Data, &SubPackage, + ACPI_RTYPE_PACKAGE, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Examine the different types of expected sub-packages */ + + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE2: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_REV_FIXED: + + /* Each subpackage has a fixed number of elements */ + + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_FIXED: + + /* Each sub-package has a fixed length */ + + ExpectedCount = Package->RetInfo2.Count; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + for (j = 0; j < ExpectedCount; j++) + { + Status = AcpiNsCheckObjectType (Data, &SubElements[j], + Package->RetInfo2.ObjectType[j], j); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + break; + + + case ACPI_PTYPE2_MIN: + + /* Each sub-package has a variable but minimum length */ + + ExpectedCount = Package->RetInfo.Count1; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_COUNT: + + /* + * First element is the (Integer) count of elements, including + * the count field. + */ + Status = AcpiNsCheckObjectType (Data, SubElements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Make sure package is large enough for the Count and is + * is as large as the minimum size + */ + ExpectedCount = (UINT32) (*SubElements)->Integer.Value; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + if (SubPackage->Package.Count < Package->RetInfo.Count1) + { + ExpectedCount = Package->RetInfo.Count1; + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, (SubElements + 1), + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + default: /* Should not get here, type was validated by caller */ + + return (AE_AML_INTERNAL); + } + + Elements++; + } + + return (AE_OK); + + +PackageTooSmall: + + /* The sub-package count was smaller than required */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Sub-Package[%u] is too small - found %u elements, expected %u", + i, SubPackage->Package.Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageElements + * + * PARAMETERS: Data - Pointer to validation data structure + * Elements - Pointer to the package elements array + * Type1 - Object type for first group + * Count1 - Count for first group + * Type2 - Object type for second group + * Count2 - Count for second group + * StartIndex - Start of the first group of elements + * + * RETURN: Status + * + * DESCRIPTION: Check that all elements of a package are of the correct object + * type. Supports up to two groups of different object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex) +{ + ACPI_OPERAND_OBJECT **ThisElement = Elements; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Up to two groups of package elements are supported by the data + * structure. All elements in each group must be of the same type. + * The second group can have a count of zero. + */ + for (i = 0; i < Count1; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type1, i + StartIndex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + for (i = 0; i < Count2; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type2, (i + Count1 + StartIndex)); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckObjectType + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * ExpectedBtypes - Bitmap of expected return type(s) + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * + * RETURN: Status + * + * DESCRIPTION: Check the type of the return object against the expected object + * type(s). Use of Btype allows multiple expected object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + UINT32 ReturnBtype; + char TypeBuffer[48]; /* Room for 5 types */ + + + /* + * If we get a NULL ReturnObject here, it is a NULL package element, + * and this is always an error. + */ + if (!ReturnObject) + { + goto TypeErrorExit; + } + + /* A Namespace node should not get here, but make sure */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid return type - Found a Namespace node [%4.4s] type %s", + ReturnObject->Node.Name.Ascii, + AcpiUtGetTypeName (ReturnObject->Node.Type))); + return (AE_AML_OPERAND_TYPE); + } + + /* + * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. + * The bitmapped type allows multiple possible return types. + * + * Note, the cases below must handle all of the possible types returned + * from all of the predefined names (including elements of returned + * packages) + */ + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_RTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_RTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_RTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_RTYPE_PACKAGE; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + ReturnBtype = ACPI_RTYPE_REFERENCE; + break; + + default: + /* Not one of the supported objects, must be incorrect */ + + goto TypeErrorExit; + } + + /* Is the object one of the expected types? */ + + if (!(ReturnBtype & ExpectedBtypes)) + { + /* Type mismatch -- attempt repair of the returned object */ + + Status = AcpiNsRepairObject (Data, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); /* Repair was successful */ + } + goto TypeErrorExit; + } + + /* For reference objects, check that the reference type is correct */ + + if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + Status = AcpiNsCheckReference (Data, ReturnObject); + } + + return (Status); + + +TypeErrorExit: + + /* Create a string with all expected types for this predefined object */ + + AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); + + if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - found %s, expected %s", + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + else + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package type mismatch at index %u - " + "found %s, expected %s", PackageIndex, + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckReference + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Object returned from the evaluation of a + * method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned reference object for the correct reference + * type. The only reference type that can be returned from a + * predefined method is a named reference. All others are invalid. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject) +{ + + /* + * Check the reference object for the correct reference type (opcode). + * The only type of reference that can be converted to an ACPI_OBJECT is + * a reference to a named object (reference class: NAME) + */ + if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME) + { + return (AE_OK); + } + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - unexpected reference object type [%s] %2.2X", + AcpiUtGetReferenceName (ReturnObject), + ReturnObject->Reference.Class)); + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExpectedTypes + * + * PARAMETERS: Buffer - Pointer to where the string is returned + * ExpectedBtypes - Bitmap of expected return type(s) + * + * RETURN: Buffer is populated with type names. + * + * DESCRIPTION: Translate the expected types bitmap into a string of ascii + * names of expected types, for use in warning messages. + * + ******************************************************************************/ + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + ThisRtype <<= 1; /* Next Rtype */ + } +} diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsrepair.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsrepair.c new file mode 100644 index 0000000000..ae534264ab --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsrepair.c @@ -0,0 +1,291 @@ +/****************************************************************************** + * + * Module Name: nsrepair - Repair for objects returned by predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairObject + * + * PARAMETERS: Data - Pointer to validation data structure + * ExpectedBtypes - Object types expected + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *NewObject; + ACPI_SIZE Length; + + + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* Does the method/object legally return a string? */ + + if (!(ExpectedBtypes & ACPI_RTYPE_STRING)) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * Have a Buffer, expected a String, convert. Use a ToString + * conversion, no transform performed on the buffer data. The best + * example of this is the _BIF method, where the string data from + * the battery is often (incorrectly) returned as buffer object(s). + */ + Length = 0; + while ((Length < ReturnObject->Buffer.Length) && + (ReturnObject->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + NewObject = AcpiUtCreateStringObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* + * Copy the raw buffer data with no transform. String is already NULL + * terminated at Length+1. + */ + ACPI_MEMCPY (NewObject->String.Pointer, + ReturnObject->Buffer.Pointer, Length); + + /* + * If the original object is a package element, we need to: + * 1. Set the reference count of the new object to match the + * reference count of the old object. + * 2. Decrement the reference count of the original object. + */ + if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) + { + NewObject->Common.ReferenceCount = + ReturnObject->Common.ReferenceCount; + + if (ReturnObject->Common.ReferenceCount > 1) + { + ReturnObject->Common.ReferenceCount--; + } + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Converted Buffer to expected String at index %u", + PackageIndex)); + } + else + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Converted Buffer to expected String")); + } + + /* Delete old object, install the new return object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = NewObject; + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); + + default: + break; + } + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * ObjDescPtr - Pointer to the object to repair. The new + * package object is returned here, + * overwriting the old object. + * + * RETURN: Status, new object in *ObjDescPtr + * + * DESCRIPTION: Repair a common problem with objects that are defined to return + * a variable-length Package of Packages. If the variable-length + * is one, some BIOS code mistakenly simply declares a single + * Package instead of a Package with one sub-Package. This + * function attempts to repair this error by wrapping a Package + * object around the original Package, creating the correct + * Package with one sub-Package. + * + * Names that can be repaired in this manner include: + * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *PkgObjDesc; + + + /* + * Create the new outer package and populate it. The new package will + * have a single element, the lone subpackage. + */ + PkgObjDesc = AcpiUtCreatePackageObject (1); + if (!PkgObjDesc) + { + return (AE_NO_MEMORY); + } + + PkgObjDesc->Package.Elements[0] = *ObjDescPtr; + + /* Return the new object in the object pointer */ + + *ObjDescPtr = PkgObjDesc; + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Incorrectly formed Package, attempting repair")); + + return (AE_OK); +} diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nssearch.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nssearch.c index 223e0e9521..fce7c5ad4d 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nssearch.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nssearch.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: nssearch - Namespace search - * $Revision: 1.123 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,8 +116,12 @@ #define __NSSEARCH_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" +#ifdef ACPI_ASL_COMPILER +#include "amlcode.h" +#endif #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nssearch") @@ -245,7 +248,8 @@ AcpiNsSearchOneScope ( /* Searched entire namespace level, not found */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", + "Name [%4.4s] (%s) not found in search in scope [%4.4s] " + "%p first child %p\n", ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); @@ -319,9 +323,8 @@ AcpiNsSearchParentTree ( "Searching parent [%4.4s] for [%4.4s]\n", AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); - /* - * Search parents until target is found or we have backed up to the root - */ + /* Search parents until target is found or we have backed up to the root */ + while (ParentNode) { /* @@ -426,6 +429,13 @@ AcpiNsSearchAndEnter ( Status = AE_ALREADY_EXISTS; } +#ifdef ACPI_ASL_COMPILER + if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY) + { + (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + /* Either found it or there was an error: finished either way */ return_ACPI_STATUS (Status); @@ -473,10 +483,11 @@ AcpiNsSearchAndEnter ( } #ifdef ACPI_ASL_COMPILER - /* - * Node is an object defined by an External() statement - */ - if (Flags & ACPI_NS_EXTERNAL) + + /* Node is an object defined by an External() statement */ + + if (Flags & ACPI_NS_EXTERNAL || + (WalkState && WalkState->Opcode == AML_SCOPE_OP)) { NewNode->Flags |= ANOBJ_IS_EXTERNAL; } diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsutils.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsutils.c index 1c508a6afe..dffc0d4432 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsutils.c @@ -2,7 +2,6 @@ * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing * parents and siblings and Scope manipulation - * $Revision: 1.157 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __NSUTILS_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "amlcode.h" @@ -170,7 +170,7 @@ AcpiNsReportError ( { /* There is a non-ascii character in the name */ - ACPI_MOVE_32_TO_32 (&BadName, InternalName); + ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName)); AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName); } else @@ -434,16 +434,22 @@ AcpiNsGetInternalNameLength ( * * strlen() + 1 covers the first NameSeg, which has no path separator */ - if (AcpiNsValidRootPrefix (NextExternalChar[0])) + if (AcpiNsValidRootPrefix (*NextExternalChar)) { Info->FullyQualified = TRUE; NextExternalChar++; + + /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */ + + while (AcpiNsValidRootPrefix (*NextExternalChar)) + { + NextExternalChar++; + } } else { - /* - * Handle Carat prefixes - */ + /* Handle Carat prefixes */ + while (*NextExternalChar == '^') { Info->NumCarats++; @@ -716,9 +722,8 @@ AcpiNsExternalizeName ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Check for a prefix (one '\' | one or more '^'). - */ + /* Check for a prefix (one '\' | one or more '^') */ + switch (InternalName[0]) { case '\\': @@ -750,7 +755,7 @@ AcpiNsExternalizeName ( } /* - * Check for object names. Note that there could be 0-255 of these + * Check for object names. Note that there could be 0-255 of these * 4-byte elements. */ if (PrefixLength < InternalNameLength) @@ -810,9 +815,8 @@ AcpiNsExternalizeName ( return_ACPI_STATUS (AE_BAD_PATHNAME); } - /* - * Build ConvertedName - */ + /* Build the ConvertedName */ + *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); if (!(*ConvertedName)) { @@ -865,6 +869,9 @@ AcpiNsExternalizeName ( * and keep all pointers within this subsystem - however this introduces * more (and perhaps unnecessary) overhead. * + * The current implemenation is basically a placeholder until such time comes + * that it is needed. + * ******************************************************************************/ ACPI_NAMESPACE_NODE * @@ -875,9 +882,8 @@ AcpiNsMapHandleToNode ( ACPI_FUNCTION_ENTRY (); - /* - * Simple implementation - */ + /* Parameter validation */ + if ((!Handle) || (Handle == ACPI_ROOT_OBJECT)) { return (AcpiGbl_RootNode); @@ -1042,7 +1048,7 @@ AcpiNsGetNode ( char *InternalPath; - ACPI_FUNCTION_TRACE_PTR (NsGetNode, Pathname); + ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); if (!Pathname) @@ -1082,7 +1088,7 @@ AcpiNsGetNode ( NULL, ReturnNode); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", Pathname, AcpiFormatException (Status))); } diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nswalk.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nswalk.c index c946835d06..881573e905 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nswalk.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nswalk.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: nswalk - Functions for walking the ACPI namespace - * $Revision: 1.47 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __NSWALK_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" @@ -129,6 +129,55 @@ * * FUNCTION: AcpiNsGetNextNode * + * PARAMETERS: ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_FUNCTION_ENTRY (); + + + if (!ChildNode) + { + /* It's really the parent's _scope_ that we want */ + + return (ParentNode->Child); + } + + /* + * Get the next node. + * + * If we are at the end of this peer list, return NULL + */ + if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (ChildNode->Peer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNodeTyped + * * PARAMETERS: Type - Type of node to be searched for * ParentNode - Parent node whose children we are * getting @@ -145,7 +194,7 @@ ******************************************************************************/ ACPI_NAMESPACE_NODE * -AcpiNsGetNextNode ( +AcpiNsGetNextNodeTyped ( ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE *ParentNode, ACPI_NAMESPACE_NODE *ChildNode) @@ -156,19 +205,7 @@ AcpiNsGetNextNode ( ACPI_FUNCTION_ENTRY (); - if (!ChildNode) - { - /* It's really the parent's _scope_ that we want */ - - NextNode = ParentNode->Child; - } - - else - { - /* Start search at the NEXT node */ - - NextNode = AcpiNsGetNextValidNode (ChildNode); - } + NextNode = AcpiNsGetNextNode (ParentNode, ChildNode); /* If any type is OK, we are done */ @@ -220,8 +257,8 @@ AcpiNsGetNextNode ( * starting (and ending) at the node specified by StartHandle. * The UserFunction is called whenever a node that matches * the type parameter is found. If the user function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. + * a non-zero value, the search is terminated immediately and + * this value is returned to the caller. * * The point of this procedure is to provide a generic namespace * walk routine that can be called from multiple places to @@ -276,7 +313,7 @@ AcpiNsWalkNamespace ( /* Get the next node in this scope. Null if not found */ Status = AE_OK; - ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); if (ChildNode) { /* Found next child, get the type if we are not searching for ANY */ @@ -289,10 +326,10 @@ AcpiNsWalkNamespace ( /* * Ignore all temporary namespace nodes (created during control * method execution) unless told otherwise. These temporary nodes - * can cause a race condition because they can be deleted during the - * execution of the user function (if the namespace is unlocked before - * invocation of the user function.) Only the debugger namespace dump - * will examine the temporary nodes. + * can cause a race condition because they can be deleted during + * the execution of the user function (if the namespace is + * unlocked before invocation of the user function.) Only the + * debugger namespace dump will examine the temporary nodes. */ if ((ChildNode->Flags & ANOBJ_TEMPORARY) && !(Flags & ACPI_NS_WALK_TEMP_NODES)) @@ -358,7 +395,7 @@ AcpiNsWalkNamespace ( */ if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) { - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) + if (ChildNode->Child) { /* There is at least one child of this node, visit it */ diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfeval.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfeval.c index 85b40693e8..a0d1a95127 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfeval.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfeval.c @@ -2,7 +2,6 @@ * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces - * $Revision: 1.33 $ * ******************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __NSXFEVAL_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acinterp.h" @@ -126,6 +126,12 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsxfeval") +/* Local prototypes */ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info); + /******************************************************************************* * @@ -385,6 +391,10 @@ AcpiEvaluateObject ( if (ACPI_SUCCESS (Status)) { + /* Dereference Index and RefOf references */ + + AcpiNsResolveReferences (Info); + /* Get the size of the returned object */ Status = AcpiUtGetObjectSize (Info->ReturnObject, @@ -451,6 +461,82 @@ Cleanup: ACPI_EXPORT_SYMBOL (AcpiEvaluateObject) +/******************************************************************************* + * + * FUNCTION: AcpiNsResolveReferences + * + * PARAMETERS: Info - Evaluation info block + * + * RETURN: Info->ReturnObject is replaced with the dereferenced object + * + * DESCRIPTION: Dereference certain reference objects. Called before an + * internal return object is converted to an external ACPI_OBJECT. + * + * Performs an automatic dereference of Index and RefOf reference objects. + * These reference objects are not supported by the ACPI_OBJECT, so this is a + * last resort effort to return something useful. Also, provides compatibility + * with other ACPI implementations. + * + * NOTE: does not handle references within returned package objects or nested + * references, but this support could be added later if found to be necessary. + * + ******************************************************************************/ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + + + /* We are interested in reference objects only */ + + if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return; + } + + /* + * Two types of references are supported - those created by Index and + * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted + * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle + * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to + * an ACPI_OBJECT. + */ + switch (Info->ReturnObject->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + ObjDesc = *(Info->ReturnObject->Reference.Where); + break; + + case ACPI_REFCLASS_REFOF: + + Node = Info->ReturnObject->Reference.Object; + if (Node) + { + ObjDesc = Node->Object; + } + break; + + default: + return; + } + + /* Replace the existing reference object */ + + if (ObjDesc) + { + AcpiUtAddReference (ObjDesc); + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = ObjDesc; + } + + return; +} + + /******************************************************************************* * * FUNCTION: AcpiWalkNamespace @@ -506,22 +592,41 @@ AcpiWalkNamespace ( } /* - * Lock the namespace around the walk. - * The namespace will be unlocked/locked around each call - * to the user function - since this function - * must be allowed to make Acpi calls itself. + * Need to acquire the namespace reader lock to prevent interference + * with any concurrent table unloads (which causes the deletion of + * namespace objects). We cannot allow the deletion of a namespace node + * while the user function is using it. The exception to this are the + * nodes created and deleted during control method execution -- these + * nodes are marked as temporary nodes and are ignored by the namespace + * walk. Thus, control methods can be executed while holding the + * namespace deletion lock (and the user function can execute control + * methods.) + */ + Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Lock the namespace around the walk. The namespace will be + * unlocked/locked around each call to the user function - since the user + * function must be allowed to make ACPICA calls itself (for example, it + * will typically execute control methods during device enumeration.) */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto UnlockAndExit; } Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, - ACPI_NS_WALK_UNLOCK, - UserFunction, Context, ReturnValue); + ACPI_NS_WALK_UNLOCK, UserFunction, Context, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +UnlockAndExit: + (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock); return_ACPI_STATUS (Status); } @@ -553,10 +658,11 @@ AcpiNsGetDeviceCallback ( ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; UINT32 Flags; - ACPI_DEVICE_ID Hid; - ACPI_COMPATIBLE_ID_LIST *Cid; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; UINT32 i; BOOLEAN Found; + int NoMatch; Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -610,7 +716,10 @@ AcpiNsGetDeviceCallback ( return (AE_CTRL_DEPTH); } - if (ACPI_STRNCMP (Hid.Value, Info->Hid, sizeof (Hid.Value)) != 0) + NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + ACPI_FREE (Hid); + + if (NoMatch) { /* * HID does not match, attempt match within the @@ -631,8 +740,7 @@ AcpiNsGetDeviceCallback ( Found = FALSE; for (i = 0; i < Cid->Count; i++) { - if (ACPI_STRNCMP (Cid->Id[i].Value, Info->Hid, - sizeof (ACPI_COMPATIBLE_ID)) == 0) + if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) { /* Found a matching CID */ diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfname.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfname.c index c8825a2164..166862bc2a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfname.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfname.c @@ -2,7 +2,6 @@ * * Module Name: nsxfname - Public interfaces to the ACPI subsystem * ACPI Namespace oriented interfaces - * $Revision: 1.113 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,12 +117,23 @@ #define __NSXFNAME_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" +#include "acparser.h" +#include "amlcode.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsxfname") +/* Local prototypes */ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea); + /****************************************************************************** * @@ -304,12 +314,44 @@ UnlockAndExit: ACPI_EXPORT_SYMBOL (AcpiGetName) +/****************************************************************************** + * + * FUNCTION: AcpiNsCopyDeviceId + * + * PARAMETERS: Dest - Pointer to the destination DEVICE_ID + * Source - Pointer to the source DEVICE_ID + * StringArea - Pointer to where to copy the dest string + * + * RETURN: Pointer to the next string area + * + * DESCRIPTION: Copy a single DEVICE_ID, including the string data. + * + ******************************************************************************/ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea) +{ + /* Create the destination DEVICE_ID */ + + Dest->String = StringArea; + Dest->Length = Source->Length; + + /* Copy actual string and return a pointer to the next string area */ + + ACPI_MEMCPY (StringArea, Source->String, Source->Length); + return (StringArea + Source->Length); +} + + /****************************************************************************** * * FUNCTION: AcpiGetObjectInfo * - * PARAMETERS: Handle - Object Handle - * Buffer - Where the info is returned + * PARAMETERS: Handle - Object Handle + * ReturnBuffer - Where the info is returned * * RETURN: Status * @@ -317,40 +359,40 @@ ACPI_EXPORT_SYMBOL (AcpiGetName) * namespace node and possibly by running several standard * control methods (Such as in the case of a device.) * + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _ADR, _SxW, and _SxD methods. + * + * Note: Allocates the return buffer, must be freed by the caller. + * ******************************************************************************/ ACPI_STATUS AcpiGetObjectInfo ( ACPI_HANDLE Handle, - ACPI_BUFFER *Buffer) + ACPI_DEVICE_INFO **ReturnBuffer) { - ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_DEVICE_INFO *Info; - ACPI_DEVICE_INFO *ReturnInfo; - ACPI_COMPATIBLE_ID_LIST *CidList = NULL; - ACPI_SIZE Size; + ACPI_DEVICE_ID_LIST *CidList = NULL; + ACPI_DEVICE_ID *Hid = NULL; + ACPI_DEVICE_ID *Uid = NULL; + char *NextIdString; + ACPI_OBJECT_TYPE Type; + ACPI_NAME Name; + UINT8 ParamCount= 0; + UINT8 Valid = 0; + UINT32 InfoSize; + UINT32 i; + ACPI_STATUS Status; /* Parameter validation */ - if (!Handle || !Buffer) + if (!Handle || !ReturnBuffer) { return (AE_BAD_PARAMETER); } - Status = AcpiUtValidateBuffer (Buffer); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_INFO)); - if (!Info) - { - return (AE_NO_MEMORY); - } - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { @@ -361,56 +403,54 @@ AcpiGetObjectInfo ( if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - Status = AE_BAD_PARAMETER; - goto Cleanup; + return (AE_BAD_PARAMETER); } - /* Init return structure */ + /* Get the namespace node data while the namespace is locked */ - Size = sizeof (ACPI_DEVICE_INFO); - - Info->Type = Node->Type; - Info->Name = Node->Name.Integer; - Info->Valid = 0; + InfoSize = sizeof (ACPI_DEVICE_INFO); + Type = Node->Type; + Name = Node->Name.Integer; if (Node->Type == ACPI_TYPE_METHOD) { - Info->ParamCount = Node->Object->Method.ParamCount; + ParamCount = Node->Object->Method.ParamCount; } Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - goto Cleanup; + return (Status); } - /* If not a device, we are all done */ - - if (Info->Type == ACPI_TYPE_DEVICE) + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) { /* - * Get extra info for ACPI Devices objects only: - * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. + * Get extra info for ACPI Device/Processor objects only: + * Run the Device _HID, _UID, and _CID methods. * * Note: none of these methods are required, so they may or may - * not be present for this device. The Info->Valid bitfield is used - * to indicate which methods were found and ran successfully. + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. */ /* Execute the Device._HID method */ - Status = AcpiUtExecute_HID (Node, &Info->HardwareId); + Status = AcpiUtExecute_HID (Node, &Hid); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_HID; + InfoSize += Hid->Length; + Valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ - Status = AcpiUtExecute_UID (Node, &Info->UniqueId); + Status = AcpiUtExecute_UID (Node, &Uid); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_UID; + InfoSize += Uid->Length; + Valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ @@ -418,57 +458,151 @@ AcpiGetObjectInfo ( Status = AcpiUtExecute_CID (Node, &CidList); if (ACPI_SUCCESS (Status)) { - Size += CidList->Size; - Info->Valid |= ACPI_VALID_CID; + /* Add size of CID strings and CID pointer array */ + + InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST)); + Valid |= ACPI_VALID_CID; } + } + + /* + * Now that we have the variable-length data, we can allocate the + * return buffer + */ + Info = ACPI_ALLOCATE_ZEROED (InfoSize); + if (!Info) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the fixed-length data */ + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the _STA, _ADR and, SxW, and _SxD methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ /* Execute the Device._STA method */ Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_STA; + Valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info->Address); + &Info->Address); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_ADR; + Valid |= ACPI_VALID_ADR; + } + + /* Execute the Device._SxW methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXWS; } /* Execute the Device._SxD methods */ - Status = AcpiUtExecute_Sxds (Node, Info->HighestDstates); + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_SXDS; + Valid |= ACPI_VALID_SXDS; } } - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (Buffer, Size); - if (ACPI_FAILURE (Status)) + /* + * Create a pointer to the string area of the return buffer. + * Point to the end of the base ACPI_DEVICE_INFO structure. + */ + NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); + if (CidList) { - goto Cleanup; + /* Point past the CID DEVICE_ID array */ + + NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID)); } - /* Populate the return buffer */ + /* + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. + * + * For HID and CID, check if the ID is a PCI Root Bridge. + */ + if (Hid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, + Hid, NextIdString); - ReturnInfo = Buffer->Pointer; - ACPI_MEMCPY (ReturnInfo, Info, sizeof (ACPI_DEVICE_INFO)); + if (AcpiUtIsPciRootBridge (Hid->String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + + if (Uid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, + Uid, NextIdString); + } if (CidList) { - ACPI_MEMCPY (&ReturnInfo->CompatibilityId, CidList, CidList->Size); + Info->CompatibleIdList.Count = CidList->Count; + Info->CompatibleIdList.ListSize = CidList->ListSize; + + /* Copy each CID */ + + for (i = 0; i < CidList->Count; i++) + { + NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], + &CidList->Ids[i], NextIdString); + + if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } } + /* Copy the fixed-length data */ + + Info->InfoSize = InfoSize; + Info->Type = Type; + Info->Name = Name; + Info->ParamCount = ParamCount; + Info->Valid = Valid; + + *ReturnBuffer = Info; + Status = AE_OK; + Cleanup: - ACPI_FREE (Info); + if (Hid) + { + ACPI_FREE (Hid); + } + if (Uid) + { + ACPI_FREE (Uid); + } if (CidList) { ACPI_FREE (CidList); @@ -478,3 +612,165 @@ Cleanup: ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) + +/****************************************************************************** + * + * FUNCTION: AcpiInstallMethod + * + * PARAMETERS: Buffer - An ACPI table containing one control method + * + * RETURN: Status + * + * DESCRIPTION: Install a control method into the namespace. If the method + * name already exists in the namespace, it is overwritten. The + * input buffer must contain a valid DSDT or SSDT containing a + * single control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer) +{ + ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); + UINT8 *AmlBuffer; + UINT8 *AmlStart; + char *Path; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_PARSE_STATE ParserState; + UINT32 AmlLength; + UINT16 Opcode; + UINT8 MethodFlags; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Table must be a DSDT or SSDT */ + + if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (AE_BAD_HEADER); + } + + /* First AML opcode in the table must be a control method */ + + ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); + Opcode = AcpiPsPeekOpcode (&ParserState); + if (Opcode != AML_METHOD_OP) + { + return (AE_BAD_PARAMETER); + } + + /* Extract method information from the raw AML */ + + ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); + ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); + Path = AcpiPsGetNextNamestring (&ParserState); + MethodFlags = *ParserState.Aml++; + AmlStart = ParserState.Aml; + AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); + + /* + * Allocate resources up-front. We don't want to have to delete a new + * node from the namespace if we cannot allocate memory. + */ + AmlBuffer = ACPI_ALLOCATE (AmlLength); + if (!AmlBuffer) + { + return (AE_NO_MEMORY); + } + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + ACPI_FREE (AmlBuffer); + return (AE_NO_MEMORY); + } + + /* Lock namespace for AcpiNsLookup, we may be creating a new node */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* The lookup either returns an existing node or creates a new one */ + + Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) /* NsLookup */ + { + if (Status != AE_ALREADY_EXISTS) + { + goto ErrorExit; + } + + /* Node existed previously, make sure it is a method node */ + + if (Node->Type != ACPI_TYPE_METHOD) + { + Status = AE_TYPE; + goto ErrorExit; + } + } + + /* Copy the method AML to the local buffer */ + + ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength); + + /* Initialize the method object with the new method's information */ + + MethodObj->Method.AmlStart = AmlBuffer; + MethodObj->Method.AmlLength = AmlLength; + + MethodObj->Method.ParamCount = (UINT8) + (MethodFlags & AML_METHOD_ARG_COUNT); + + MethodObj->Method.MethodFlags = (UINT8) + (MethodFlags & ~AML_METHOD_ARG_COUNT); + + if (MethodFlags & AML_METHOD_SERIALIZED) + { + MethodObj->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* + * Now that it is complete, we can attach the new method object to + * the method Node (detaches/deletes any existing object) + */ + Status = AcpiNsAttachObject (Node, MethodObj, + ACPI_TYPE_METHOD); + + /* + * Flag indicates AML buffer is dynamic, must be deleted later. + * Must be set only after attach above. + */ + Node->Flags |= ANOBJ_ALLOCATED_BUFFER; + + /* Remove local reference to the method object */ + + AcpiUtRemoveReference (MethodObj); + return (Status); + + +ErrorExit: + + ACPI_FREE (AmlBuffer); + ACPI_FREE (MethodObj); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallMethod) diff --git a/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfobj.c b/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfobj.c index 3f03426064..023cb6990b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfobj.c +++ b/src/add-ons/kernel/bus_managers/acpi/namespace/nsxfobj.c @@ -2,7 +2,6 @@ * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * $Revision: 1.123 $ * ******************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +118,7 @@ #define __NSXFOBJ_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" @@ -209,6 +209,7 @@ AcpiGetParent ( ACPI_HANDLE *RetHandle) { ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; ACPI_STATUS Status; @@ -241,12 +242,12 @@ AcpiGetParent ( /* Get the parent entry */ - *RetHandle = - AcpiNsConvertEntryToHandle (AcpiNsGetParentNode (Node)); + ParentNode = AcpiNsGetParentNode (Node); + *RetHandle = AcpiNsConvertEntryToHandle (ParentNode); /* Return exception if parent is null */ - if (!AcpiNsGetParentNode (Node)) + if (!ParentNode) { Status = AE_NULL_ENTRY; } @@ -333,7 +334,7 @@ AcpiGetNextObject ( /* Internal function does the real work */ - Node = AcpiNsGetNextNode (Type, ParentNode, ChildNode); + Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode); if (!Node) { Status = AE_NOT_FOUND; diff --git a/src/add-ons/kernel/bus_managers/acpi/oshaiku.c b/src/add-ons/kernel/bus_managers/acpi/oshaiku.c index dc5bb80f7a..c1c3bf7062 100644 --- a/src/add-ons/kernel/bus_managers/acpi/oshaiku.c +++ b/src/add-ons/kernel/bus_managers/acpi/oshaiku.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -137,6 +137,7 @@ extern void *gDPCHandle; #endif #include "acpi.h" +#include "accommon.h" #include "amlcode.h" #include "acparser.h" #include "acdebug.h" @@ -934,32 +935,6 @@ AcpiOsValidateInterface(char *Interface) } -/****************************************************************************** - * - * FUNCTION: AcpiOsValidateAddress - * - * PARAMETERS: SpaceId - ACPI space ID - * Address - Physical address - * Length - Address length - * - * RETURN: AE_OK if Address/Length is valid for the SpaceId. Otherwise, - * should return AE_AML_ILLEGAL_ADDRESS. - * - * DESCRIPTION: Validate a system address via the host OS. Used to validate - * the addresses accessed by AML operation regions. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsValidateAddress(UINT8 SpaceId, ACPI_PHYSICAL_ADDRESS Address, - ACPI_SIZE Length) -{ - DEBUG_FUNCTION_F("space: %u; addr: 0x%08lx; length: %lu", - (uint8)SpaceId, (addr_t)Address, (size_t)Length); - return AE_OK; -} - - /****************************************************************************** * * FUNCTION: AcpiOsReadPciConfiguration diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psargs.c b/src/add-ons/kernel/bus_managers/acpi/parser/psargs.c index c32543c1c3..60d4a835b1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psargs.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psargs.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments - * $Revision: 1.95 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __PSARGS_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acnamesp.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psloop.c b/src/add-ons/kernel/bus_managers/acpi/parser/psloop.c index 6760d5c125..fe9b7311a2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psloop.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psloop.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psloop - Main AML parse loop - * $Revision: 1.19 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +123,7 @@ */ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acdispat.h" #include "amlcode.h" @@ -171,6 +171,12 @@ AcpiPsCompleteFinalOp ( ACPI_PARSE_OBJECT *Op, ACPI_STATUS Status); +static void +AcpiPsLinkModuleCode ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId); + /******************************************************************************* * @@ -502,6 +508,7 @@ AcpiPsGetArguments ( { ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); @@ -558,13 +565,11 @@ AcpiPsGetArguments ( } - /* Special processing for certain opcodes */ - - /* TBD (remove): Temporary mechanism to disable this code if needed */ - -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - - if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS1) && + /* + * Handle executable code at "module-level". This refers to + * executable opcodes that appear outside of any control method. + */ + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) && ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) { /* @@ -580,6 +585,19 @@ AcpiPsGetArguments ( case AML_ELSE_OP: case AML_WHILE_OP: + /* + * Currently supported module-level opcodes are: + * IF/ELSE/WHILE. These appear to be the most common, + * and easiest to support since they open an AML + * package. + */ + if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) + { + AcpiPsLinkModuleCode (AmlOpStart, + (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart), + WalkState->OwnerId); + } + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Pass1: Skipping an If/Else/While body\n")); @@ -590,10 +608,33 @@ AcpiPsGetArguments ( break; default: + /* + * Check for an unsupported executable opcode at module + * level. We must be in PASS1, the parent must be a SCOPE, + * The opcode class must be EXECUTE, and the opcode must + * not be an argument to another opcode. + */ + if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) && + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if ((OpInfo->Class == AML_CLASS_EXECUTE) && + (!Arg)) + { + ACPI_WARNING ((AE_INFO, + "Detected an unsupported executable opcode " + "at module-level: [0x%.4X] at table offset 0x%.4X", + Op->Common.AmlOpcode, + (UINT32) (ACPI_PTR_DIFF (AmlOpStart, + WalkState->ParserState.AmlStart) + + sizeof (ACPI_TABLE_HEADER)))); + } + } break; } } -#endif + + /* Special processing for certain opcodes */ switch (Op->Common.AmlOpcode) { @@ -659,6 +700,78 @@ AcpiPsGetArguments ( } +/******************************************************************************* + * + * FUNCTION: AcpiPsLinkModuleCode + * + * PARAMETERS: AmlStart - Pointer to the AML + * AmlLength - Length of executable AML + * OwnerId - OwnerId of module level code + * + * RETURN: None. + * + * DESCRIPTION: Wrap the module-level code with a method object and link the + * object to the global list. Note, the mutex field of the method + * object is used to link multiple module-level code objects. + * + ******************************************************************************/ + +static void +AcpiPsLinkModuleCode ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *MethodObj; + + + /* Get the tail of the list */ + + Prev = Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + } + + /* + * Insert the module level code into the list. Merge it if it is + * adjacent to the previous element. + */ + if (!Prev || + ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart)) + { + /* Create, initialize, and link a new temporary method object */ + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + return; + } + + MethodObj->Method.AmlStart = AmlStart; + MethodObj->Method.AmlLength = AmlLength; + MethodObj->Method.OwnerId = OwnerId; + MethodObj->Method.Flags |= AOPOBJ_MODULE_LEVEL; + + if (!Prev) + { + AcpiGbl_ModuleCodeList = MethodObj; + } + else + { + Prev->Method.Mutex = MethodObj; + } + } + else + { + Prev->Method.AmlLength += AmlLength; + } +} + + /******************************************************************************* * * FUNCTION: AcpiPsCompleteOp diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psopcode.c b/src/add-ons/kernel/bus_managers/acpi/parser/psopcode.c index 0f5086e0f2..d107c52370 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psopcode.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psopcode.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psopcode - Parser/Interpreter opcode information table - * $Revision: 1.103 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acopcode.h" #include "amlcode.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psparse.c b/src/add-ons/kernel/bus_managers/acpi/parser/psparse.c index 135111966d..d9d6a2944b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psparse.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psparse.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psparse - Parser top level AML parse routines - * $Revision: 1.176 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +124,7 @@ */ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acdispat.h" #include "amlcode.h" @@ -222,6 +222,7 @@ AcpiPsCompleteThisOp ( ACPI_PARSE_OBJECT *Next; const ACPI_OPCODE_INFO *ParentInfo; ACPI_PARSE_OBJECT *ReplacementOp = NULL; + ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op); @@ -274,7 +275,7 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - goto AllocateError; + Status = AE_NO_MEMORY; } break; @@ -294,7 +295,7 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - goto AllocateError; + Status = AE_NO_MEMORY; } } else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && @@ -307,11 +308,13 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); if (!ReplacementOp) { - goto AllocateError; + Status = AE_NO_MEMORY; + } + else + { + ReplacementOp->Named.Data = Op->Named.Data; + ReplacementOp->Named.Length = Op->Named.Length; } - - ReplacementOp->Named.Data = Op->Named.Data; - ReplacementOp->Named.Length = Op->Named.Length; } } break; @@ -321,7 +324,7 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - goto AllocateError; + Status = AE_NO_MEMORY; } } @@ -379,15 +382,7 @@ Cleanup: /* Now we can actually delete the subtree rooted at Op */ AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (AE_OK); - - -AllocateError: - - /* Always delete the subtree, even on error */ - - AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS (Status); } @@ -545,12 +540,23 @@ AcpiPsParseAml ( WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize)); + if (!WalkState->ParserState.Aml) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } /* Create and initialize a new thread state */ Thread = AcpiUtCreateThreadState (); if (!Thread) { + if (WalkState->MethodDesc) + { + /* Executing a control method - additional cleanup */ + + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + AcpiDsDeleteWalkState (WalkState); return_ACPI_STATUS (AE_NO_MEMORY); } @@ -731,9 +737,10 @@ AcpiPsParseAml ( } else { - /* On error, delete any return object */ + /* On error, delete any return object or implicit return */ AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + AcpiDsClearImplicitReturn (PreviousWalkState); } } diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psscope.c b/src/add-ons/kernel/bus_managers/acpi/parser/psscope.c index 25ac459e33..979dbb1515 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psscope.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psscope.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psscope - Parser scope stack management routines - * $Revision: 1.48 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #define _COMPONENT ACPI_PARSER diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/pstree.c b/src/add-ons/kernel/bus_managers/acpi/parser/pstree.c index 22a12cb74d..20ac405cac 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/pstree.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/pstree.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: pstree - Parser op tree manipulation/traversal/search - * $Revision: 1.52 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __PSTREE_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psutils.c b/src/add-ons/kernel/bus_managers/acpi/parser/psutils.c index 5c329a2d56..42f2b015d6 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psutils.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psutils - Parser miscellaneous utilities (Parser only) - * $Revision: 1.71 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "amlcode.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/pswalk.c b/src/add-ons/kernel/bus_managers/acpi/parser/pswalk.c index 5944635293..d8d5f5e6f2 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/pswalk.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/pswalk.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: pswalk - Parser routines to walk parsed op tree(s) - * $Revision: 1.79 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +115,7 @@ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #define _COMPONENT ACPI_PARSER diff --git a/src/add-ons/kernel/bus_managers/acpi/parser/psxface.c b/src/add-ons/kernel/bus_managers/acpi/parser/psxface.c index a68171397c..1859b69214 100644 --- a/src/add-ons/kernel/bus_managers/acpi/parser/psxface.c +++ b/src/add-ons/kernel/bus_managers/acpi/parser/psxface.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: psxface - Parser external interfaces - * $Revision: 1.94 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,9 +116,11 @@ #define __PSXFACE_C__ #include "acpi.h" +#include "accommon.h" #include "acparser.h" #include "acdispat.h" #include "acinterp.h" +#include "amlcode.h" #define _COMPONENT ACPI_PARSER @@ -393,6 +394,45 @@ AcpiPsExecuteMethod ( goto Cleanup; } + if (Info->ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; + } + + /* Invoke an internal method if necessary */ + + if (Info->ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = Info->ObjDesc->Method.Implementation (WalkState); + Info->ReturnObject = WalkState->ReturnDesc; + + /* Cleanup states */ + + AcpiDsScopeStackClear (WalkState); + AcpiPsCleanupScope (&WalkState->ParserState); + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* + * Start method evaluation with an implicit return of zero. This is done + * for Windows compatibility. + */ + if (AcpiGbl_EnableInterpreterSlack) + { + WalkState->ImplicitReturnObj = + AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!WalkState->ImplicitReturnObj) + { + Status = AE_NO_MEMORY; + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + WalkState->ImplicitReturnObj->Integer.Value = 0; + } + /* Parse the AML */ Status = AcpiPsParseAml (WalkState); diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsaddr.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsaddr.c index a51156e608..f2f3c4421f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsaddr.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsaddr.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsaddr - Address resource descriptors (16/32/64) - * $Revision: 1.51 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSADDR_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rscalc.c b/src/add-ons/kernel/bus_managers/acpi/resources/rscalc.c index 01242b1937..76aa44ff83 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rscalc.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rscalc.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rscalc - Calculate stream and list lengths - * $Revision: 1.84 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,10 +116,11 @@ #define __RSCALC_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" -#include "amlcode.h" #include "acnamesp.h" + #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rscalc") @@ -656,6 +656,14 @@ AcpiRsGetPciRoutingTableLength ( PackageElement = *TopObjectList; + /* We must have a valid Package object */ + + if (!PackageElement || + (PackageElement->Common.Type != ACPI_TYPE_PACKAGE)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + /* * The SubObjectList will now point to an array of the * four IRQ elements: Address, Pin, Source and SourceIndex @@ -671,13 +679,13 @@ AcpiRsGetPciRoutingTableLength ( if (*SubObjectList && /* Null object allowed */ ((ACPI_TYPE_STRING == - ACPI_GET_OBJECT_TYPE (*SubObjectList)) || + (*SubObjectList)->Common.Type) || ((ACPI_TYPE_LOCAL_REFERENCE == - ACPI_GET_OBJECT_TYPE (*SubObjectList)) && + (*SubObjectList)->Common.Type) && - ((*SubObjectList)->Reference.Opcode == - AML_INT_NAMEPATH_OP)))) + ((*SubObjectList)->Reference.Class == + ACPI_REFCLASS_NAME)))) { NameFound = TRUE; } @@ -695,7 +703,7 @@ AcpiRsGetPciRoutingTableLength ( if (NameFound) { - if (ACPI_GET_OBJECT_TYPE (*SubObjectList) == ACPI_TYPE_STRING) + if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING) { /* * The length String.Length field does not include the diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rscreate.c b/src/add-ons/kernel/bus_managers/acpi/resources/rscreate.c index c6a0830cfa..e9c840b64e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rscreate.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rscreate.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rscreate - Create resource lists/tables - * $Revision: 1.79 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -114,12 +113,11 @@ * *****************************************************************************/ - #define __RSCREATE_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" -#include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_RESOURCES @@ -300,7 +298,7 @@ AcpiRsCreatePciRoutingTable ( /* Each element of the top-level package must also be a package */ - if (ACPI_GET_OBJECT_TYPE (*TopObjectList) != ACPI_TYPE_PACKAGE) + if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) { ACPI_ERROR ((AE_INFO, "(PRT[%X]) Need sub-package, found %s", @@ -328,7 +326,7 @@ AcpiRsCreatePciRoutingTable ( /* 1) First subobject: Dereference the PRT.Address */ ObjDesc = SubObjectList[0]; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); @@ -340,7 +338,7 @@ AcpiRsCreatePciRoutingTable ( /* 2) Second subobject: Dereference the PRT.Pin */ ObjDesc = SubObjectList[1]; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); @@ -356,7 +354,7 @@ AcpiRsCreatePciRoutingTable ( * other ACPI implementations. */ ObjDesc = SubObjectList[3]; - if (!ObjDesc || (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)) + if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) { SubObjectList[3] = SubObjectList[2]; SubObjectList[2] = ObjDesc; @@ -373,15 +371,15 @@ AcpiRsCreatePciRoutingTable ( ObjDesc = SubObjectList[2]; if (ObjDesc) { - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ObjDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: - if (ObjDesc->Reference.Opcode != AML_INT_NAMEPATH_OP) + if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) { ACPI_ERROR ((AE_INFO, - "(PRT[%X].Source) Need name, found reference op %X", - Index, ObjDesc->Reference.Opcode)); + "(PRT[%X].Source) Need name, found Reference Class %X", + Index, ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_BAD_DATA); } @@ -441,7 +439,7 @@ AcpiRsCreatePciRoutingTable ( /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ ObjDesc = SubObjectList[3]; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%X].SourceIndex) Need Integer, found %s", diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsdump.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsdump.c index a6784d2a8d..62db284c6f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsdump.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsdump.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsdump - Functions to display the resource structures. - * $Revision: 1.64 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __RSDUMP_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsinfo.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsinfo.c index 4bab1cde3c..abf79943d9 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsinfo.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsinfo.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsinfo - Dispatch and Info tables - * $Revision: 1.9 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSINFO_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsio.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsio.c index 7c5deea1ef..fb9213dd72 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsio.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsio.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsio - IO and DMA resource descriptors - * $Revision: 1.38 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSIO_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsirq.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsirq.c index d4afc91e56..7eab435139 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsirq.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsirq.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsirq - IRQ resource descriptors - * $Revision: 1.52 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSIRQ_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rslist.c b/src/add-ons/kernel/bus_managers/acpi/resources/rslist.c index 278c38a152..3adce2b393 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rslist.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rslist.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rslist - Linked list utilities - * $Revision: 1.63 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSLIST_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsmemory.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsmemory.c index 08cd4aab10..a3d08c01a1 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsmemory.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsmemory.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsmem24 - Memory resource descriptors - * $Revision: 1.35 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSMEMORY_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsmisc.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsmisc.c index 2b77b91cef..3565334e73 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsmisc.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsmisc.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsmisc - Miscellaneous resource descriptors - * $Revision: 1.48 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __RSMISC_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsutils.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsutils.c index f324a74281..4e0f04ce8e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsutils.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsutils - Utilities for the resource manager - * $Revision: 1.69 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __RSUTILS_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acresrc.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/resources/rsxface.c b/src/add-ons/kernel/bus_managers/acpi/resources/rsxface.c index c98a3b0925..32ed559569 100644 --- a/src/add-ons/kernel/bus_managers/acpi/resources/rsxface.c +++ b/src/add-ons/kernel/bus_managers/acpi/resources/rsxface.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: rsxface - Public interfaces to the resource manager - * $Revision: 1.49 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __RSXFACE_C__ #include "acpi.h" +#include "accommon.h" #include "acresrc.h" #include "acnamesp.h" @@ -460,13 +460,13 @@ AcpiResourceToAddress64 ( { case ACPI_RESOURCE_TYPE_ADDRESS16: - Address16 = (ACPI_RESOURCE_ADDRESS16 *) &Resource->Data; + Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); ACPI_COPY_ADDRESS (Out, Address16); break; case ACPI_RESOURCE_TYPE_ADDRESS32: - Address32 = (ACPI_RESOURCE_ADDRESS32 *) &Resource->Data; + Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); ACPI_COPY_ADDRESS (Out, Address32); break; diff --git a/src/add-ons/kernel/bus_managers/acpi/tables/tbfadt.c b/src/add-ons/kernel/bus_managers/acpi/tables/tbfadt.c index ab911c740f..c657a0b75a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/tables/tbfadt.c +++ b/src/add-ons/kernel/bus_managers/acpi/tables/tbfadt.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: tbfadt - FADT table utilities - * $Revision: 1.8 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __TBFADT_C__ #include "acpi.h" +#include "accommon.h" #include "actables.h" #define _COMPONENT ACPI_TABLES @@ -124,10 +124,11 @@ /* Local prototypes */ -static void inline +static inline void AcpiTbInitGenericAddress ( ACPI_GENERIC_ADDRESS *GenericAddress, - UINT8 BitWidth, + UINT8 SpaceId, + UINT8 ByteWidth, UINT64 Address); static void @@ -138,15 +139,20 @@ static void AcpiTbValidateFadt ( void); +static void +AcpiTbSetupFadtRegisters ( + void); + /* Table for conversion of FADT to common internal format and FADT validation */ typedef struct acpi_fadt_info { char *Name; - UINT8 Target; - UINT8 Source; + UINT8 Address64; + UINT8 Address32; UINT8 Length; + UINT8 DefaultLength; UINT8 Type; } ACPI_FADT_INFO; @@ -156,40 +162,98 @@ typedef struct acpi_fadt_info static ACPI_FADT_INFO FadtInfoTable[] = { - {"Pm1aEventBlock", ACPI_FADT_OFFSET (XPm1aEventBlock), - ACPI_FADT_OFFSET (Pm1aEventBlock), - ACPI_FADT_OFFSET (Pm1EventLength), ACPI_FADT_REQUIRED}, + {"Pm1aEventBlock", + ACPI_FADT_OFFSET (XPm1aEventBlock), + ACPI_FADT_OFFSET (Pm1aEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + ACPI_FADT_REQUIRED}, - {"Pm1bEventBlock", ACPI_FADT_OFFSET (XPm1bEventBlock), - ACPI_FADT_OFFSET (Pm1bEventBlock), - ACPI_FADT_OFFSET (Pm1EventLength), 0}, + {"Pm1bEventBlock", + ACPI_FADT_OFFSET (XPm1bEventBlock), + ACPI_FADT_OFFSET (Pm1bEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + 0}, - {"Pm1aControlBlock", ACPI_FADT_OFFSET (XPm1aControlBlock), - ACPI_FADT_OFFSET (Pm1aControlBlock), - ACPI_FADT_OFFSET (Pm1ControlLength), ACPI_FADT_REQUIRED}, + {"Pm1aControlBlock", + ACPI_FADT_OFFSET (XPm1aControlBlock), + ACPI_FADT_OFFSET (Pm1aControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + ACPI_FADT_REQUIRED}, - {"Pm1bControlBlock", ACPI_FADT_OFFSET (XPm1bControlBlock), - ACPI_FADT_OFFSET (Pm1bControlBlock), - ACPI_FADT_OFFSET (Pm1ControlLength), 0}, + {"Pm1bControlBlock", + ACPI_FADT_OFFSET (XPm1bControlBlock), + ACPI_FADT_OFFSET (Pm1bControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + 0}, - {"Pm2ControlBlock", ACPI_FADT_OFFSET (XPm2ControlBlock), - ACPI_FADT_OFFSET (Pm2ControlBlock), - ACPI_FADT_OFFSET (Pm2ControlLength), ACPI_FADT_SEPARATE_LENGTH}, + {"Pm2ControlBlock", + ACPI_FADT_OFFSET (XPm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlLength), + ACPI_PM2_REGISTER_WIDTH, + ACPI_FADT_SEPARATE_LENGTH}, - {"PmTimerBlock", ACPI_FADT_OFFSET (XPmTimerBlock), - ACPI_FADT_OFFSET (PmTimerBlock), - ACPI_FADT_OFFSET (PmTimerLength), ACPI_FADT_REQUIRED}, + {"PmTimerBlock", + ACPI_FADT_OFFSET (XPmTimerBlock), + ACPI_FADT_OFFSET (PmTimerBlock), + ACPI_FADT_OFFSET (PmTimerLength), + ACPI_PM_TIMER_WIDTH, + ACPI_FADT_REQUIRED}, - {"Gpe0Block", ACPI_FADT_OFFSET (XGpe0Block), - ACPI_FADT_OFFSET (Gpe0Block), - ACPI_FADT_OFFSET (Gpe0BlockLength), ACPI_FADT_SEPARATE_LENGTH}, + {"Gpe0Block", + ACPI_FADT_OFFSET (XGpe0Block), + ACPI_FADT_OFFSET (Gpe0Block), + ACPI_FADT_OFFSET (Gpe0BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH}, - {"Gpe1Block", ACPI_FADT_OFFSET (XGpe1Block), - ACPI_FADT_OFFSET (Gpe1Block), - ACPI_FADT_OFFSET (Gpe1BlockLength), ACPI_FADT_SEPARATE_LENGTH} + {"Gpe1Block", + ACPI_FADT_OFFSET (XGpe1Block), + ACPI_FADT_OFFSET (Gpe1Block), + ACPI_FADT_OFFSET (Gpe1BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH} }; -#define ACPI_FADT_INFO_ENTRIES (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO)) +#define ACPI_FADT_INFO_ENTRIES \ + (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO)) + + +/* Table used to split Event Blocks into separate status/enable registers */ + +typedef struct acpi_fadt_pm_info +{ + ACPI_GENERIC_ADDRESS *Target; + UINT8 Source; + UINT8 RegisterNum; + +} ACPI_FADT_PM_INFO; + +static ACPI_FADT_PM_INFO FadtPmInfoTable[] = +{ + {&AcpiGbl_XPm1aStatus, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 0}, + + {&AcpiGbl_XPm1aEnable, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 1}, + + {&AcpiGbl_XPm1bStatus, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 0}, + + {&AcpiGbl_XPm1bEnable, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 1} +}; + +#define ACPI_FADT_PM_INFO_ENTRIES \ + (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO)) /******************************************************************************* @@ -197,7 +261,8 @@ static ACPI_FADT_INFO FadtInfoTable[] = * FUNCTION: AcpiTbInitGenericAddress * * PARAMETERS: GenericAddress - GAS struct to be initialized - * BitWidth - Width of this register + * SpaceId - ACPI Space ID for this register + * ByteWidth - Width of this register, in bytes * Address - Address of the register * * RETURN: None @@ -208,10 +273,11 @@ static ACPI_FADT_INFO FadtInfoTable[] = * ******************************************************************************/ -static void inline +static inline void AcpiTbInitGenericAddress ( ACPI_GENERIC_ADDRESS *GenericAddress, - UINT8 BitWidth, + UINT8 SpaceId, + UINT8 ByteWidth, UINT64 Address) { @@ -223,10 +289,10 @@ AcpiTbInitGenericAddress ( /* All other fields are byte-wide */ - GenericAddress->SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; - GenericAddress->BitWidth = BitWidth; + GenericAddress->SpaceId = SpaceId; + GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth); GenericAddress->BitOffset = 0; - GenericAddress->AccessWidth = 0; + GenericAddress->AccessWidth = 0; /* Access width ANY */ } @@ -235,7 +301,6 @@ AcpiTbInitGenericAddress ( * FUNCTION: AcpiTbParseFadt * * PARAMETERS: TableIndex - Index for the FADT - * Flags - Flags * * RETURN: None * @@ -246,8 +311,7 @@ AcpiTbInitGenericAddress ( void AcpiTbParseFadt ( - UINT32 TableIndex, - UINT8 Flags) + UINT32 TableIndex) { UINT32 Length; ACPI_TABLE_HEADER *Table; @@ -275,7 +339,7 @@ AcpiTbParseFadt ( */ (void) AcpiTbVerifyChecksum (Table, Length); - /* Obtain a local copy of the FADT in common ACPI 2.0+ format */ + /* Create a local copy of the FADT in common ACPI 2.0+ format */ AcpiTbCreateLocalFadt (Table, Length); @@ -286,10 +350,10 @@ AcpiTbParseFadt ( /* Obtain the DSDT and FACS tables via their addresses within the FADT */ AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, - Flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, - Flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); + ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); } @@ -323,8 +387,9 @@ AcpiTbCreateLocalFadt ( if (Length > sizeof (ACPI_TABLE_FADT)) { ACPI_WARNING ((AE_INFO, - "FADT (revision %u) is longer than ACPI 2.0 version, truncating length 0x%X to 0x%X", - Table->Revision, Length, sizeof (ACPI_TABLE_FADT))); + "FADT (revision %u) is longer than ACPI 2.0 version, " + "truncating length 0x%X to 0x%X", + Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); } /* Clear the entire local FADT */ @@ -336,12 +401,17 @@ AcpiTbCreateLocalFadt ( ACPI_MEMCPY (&AcpiGbl_FADT, Table, ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT))); - /* - * 1) Convert the local copy of the FADT to the common internal format - * 2) Validate some of the important values within the FADT - */ + /* Convert the local copy of the FADT to the common internal format */ + AcpiTbConvertFadt (); + + /* Validate FADT values now, before we make any changes */ + AcpiTbValidateFadt (); + + /* Initialize the global ACPI register structures */ + + AcpiTbSetupFadtRegisters (); } @@ -354,23 +424,28 @@ AcpiTbCreateLocalFadt ( * RETURN: None * * DESCRIPTION: Converts all versions of the FADT to a common internal format. - * Expand all 32-bit addresses to 64-bit. + * Expand 32-bit addresses to 64-bit as necessary. * * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), * and must contain a copy of the actual FADT. * - * ACPICA will use the "X" fields of the FADT for all addresses. + * Notes on 64-bit register addresses: * - * "X" fields are optional extensions to the original V1.0 fields. Even if - * they are present in the structure, they can be optionally not used by - * setting them to zero. Therefore, we must selectively expand V1.0 fields - * if the corresponding X field is zero. + * After this FADT conversion, later ACPICA code will only use the 64-bit "X" + * fields of the FADT for all ACPI register addresses. * - * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding - * "X" fields. + * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * V1.0 fields. Even if they are present in the FADT, they are optional and + * are unused if the BIOS sets them to zero. Therefore, we must copy/expand + * 32-bit V1.0 fields if the corresponding X field is zero. * - * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by - * expanding the corresponding ACPI 1.0 field. + * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the + * corresponding "X" fields in the internal FADT. + * + * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded + * to the corresponding 64-bit X fields. For compatibility with other ACPI + * implementations, we ignore the 64-bit field if the 32-bit field is valid, + * regardless of whether the host OS is 32-bit or 64-bit. * ******************************************************************************/ @@ -378,8 +453,8 @@ static void AcpiTbConvertFadt ( void) { - UINT8 Pm1RegisterLength; - ACPI_GENERIC_ADDRESS *Target; + ACPI_GENERIC_ADDRESS *Address64; + UINT32 Address32; UINT32 i; @@ -387,13 +462,14 @@ AcpiTbConvertFadt ( AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); - /* Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary */ - + /* + * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Later code will always use the X 64-bit field. + */ if (!AcpiGbl_FADT.XFacs) { AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; } - if (!AcpiGbl_FADT.XDsdt) { AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; @@ -404,8 +480,8 @@ AcpiTbConvertFadt ( * should be zero are indeed zero. This will workaround BIOSs that * inadvertently place values in these fields. * - * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at - * offset 45, 55, 95, and the word located at offset 109, 110. + * The ACPI 1.0 reserved fields that will be zeroed are the bytes located + * at offset 45, 55, 95, and the word located at offset 109, 110. */ if (AcpiGbl_FADT.Header.Revision < 3) { @@ -416,51 +492,57 @@ AcpiTbConvertFadt ( } /* - * Expand the ACPI 1.0 32-bit V1.0 addresses to the ACPI 2.0 64-bit "X" - * generic address structures as necessary. + * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" + * generic address structures as necessary. Later code will always use + * the 64-bit address structures. + * + * March 2009: + * We now always use the 32-bit address if it is valid (non-null). This + * is not in accordance with the ACPI specification which states that + * the 64-bit address supersedes the 32-bit version, but we do this for + * compatibility with other ACPI implementations. Most notably, in the + * case where both the 32 and 64 versions are non-null, we use the 32-bit + * version. This is the only address that is guaranteed to have been + * tested by the BIOS manufacturer. */ for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { - Target = ACPI_ADD_PTR ( - ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, FadtInfoTable[i].Target); + Address32 = *ACPI_ADD_PTR (UINT32, + &AcpiGbl_FADT, FadtInfoTable[i].Address32); - /* Expand only if the X target is null */ + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); - if (!Target->Address) + /* + * If both 32- and 64-bit addresses are valid (non-zero), + * they must match. + */ + if (Address64->Address && Address32 && + (Address64->Address != (UINT64) Address32)) { - AcpiTbInitGenericAddress (Target, - *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), - (UINT64) *ACPI_ADD_PTR (UINT32, &AcpiGbl_FADT, FadtInfoTable[i].Source)); + ACPI_ERROR ((AE_INFO, + "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", + FadtInfoTable[i].Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address))); } - } - /* - * Calculate separate GAS structs for the PM1 Enable registers. - * These addresses do not appear (directly) in the FADT, so it is - * useful to calculate them once, here. - * - * The PM event blocks are split into two register blocks, first is the - * PM Status Register block, followed immediately by the PM Enable Register - * block. Each is of length (Pm1EventLength/2) - */ - Pm1RegisterLength = (UINT8) ACPI_DIV_2 (AcpiGbl_FADT.Pm1EventLength); + /* Always use 32-bit address if it is valid (non-null) */ - /* The PM1A register block is required */ - - AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, Pm1RegisterLength, - (AcpiGbl_FADT.XPm1aEventBlock.Address + Pm1RegisterLength)); - - /* The PM1B register block is optional, ignore if not present */ - - if (AcpiGbl_FADT.XPm1bEventBlock.Address) - { - AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, Pm1RegisterLength, - (AcpiGbl_FADT.XPm1bEventBlock.Address + Pm1RegisterLength)); + if (Address32) + { + /* + * Copy the 32-bit address to the 64-bit GAS structure. The + * Space ID is always I/O for 32-bit legacy address fields + */ + AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), + (UINT64) Address32); + } } } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiTbValidateFadt * @@ -484,21 +566,64 @@ static void AcpiTbValidateFadt ( void) { - UINT32 *Address32; + char *Name; ACPI_GENERIC_ADDRESS *Address64; UINT8 Length; UINT32 i; + /* + * Check for FACS and DSDT address mismatches. An address mismatch between + * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and + * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. + */ + if (AcpiGbl_FADT.Facs && + (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs)) + { + ACPI_WARNING ((AE_INFO, + "32/64X FACS address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); + + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + + if (AcpiGbl_FADT.Dsdt && + (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt)) + { + ACPI_WARNING ((AE_INFO, + "32/64X DSDT address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); + + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + /* Examine all of the 64-bit extended address fields (X fields) */ for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { - /* Generate pointers to the 32-bit and 64-bit addresses and get the length */ + /* + * Generate pointer to the 64-bit address, get the register + * length (width) and the register name + */ + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + Length = *ACPI_ADD_PTR (UINT8, + &AcpiGbl_FADT, FadtInfoTable[i].Length); + Name = FadtInfoTable[i].Name; - Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, FadtInfoTable[i].Target); - Address32 = ACPI_ADD_PTR (UINT32, &AcpiGbl_FADT, FadtInfoTable[i].Source); - Length = *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length); + /* + * For each extended field, check for length mismatch between the + * legacy length field and the corresponding 64-bit X length field. + */ + if (Address64->Address && + (Address64->BitWidth != ACPI_MUL_8 (Length))) + { + ACPI_WARNING ((AE_INFO, + "32/64X length mismatch in %s: %d/%d", + Name, ACPI_MUL_8 (Length), Address64->BitWidth)); + } if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED) { @@ -509,33 +634,119 @@ AcpiTbValidateFadt ( if (!Address64->Address || !Length) { ACPI_ERROR ((AE_INFO, - "Required field \"%s\" has zero address and/or length: %8.8X%8.8X/%X", - FadtInfoTable[i].Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + "Required field %s has zero address and/or length:" + " %8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH) { /* * Field is optional (PM2Control, GPE0, GPE1) AND has its own - * length field. If present, both the address and length must be valid. + * length field. If present, both the address and length must + * be valid. */ - if ((Address64->Address && !Length) || (!Address64->Address && Length)) + if ((Address64->Address && !Length) || + (!Address64->Address && Length)) { ACPI_WARNING ((AE_INFO, - "Optional field \"%s\" has zero address or length: %8.8X%8.8X/%X", - FadtInfoTable[i].Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + "Optional field %s has zero address or length: " + "%8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } - - /* If both 32- and 64-bit addresses are valid (non-zero), they must match */ - - if (Address64->Address && *Address32 && - (Address64->Address != (UINT64) *Address32)) - { - ACPI_ERROR ((AE_INFO, - "32/64X address mismatch in \"%s\": [%8.8X] [%8.8X%8.8X], using 64X", - FadtInfoTable[i].Name, *Address32, ACPI_FORMAT_UINT64 (Address64->Address))); - } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetupFadtRegisters + * + * PARAMETERS: None, uses AcpiGbl_FADT. + * + * RETURN: None + * + * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, + * force FADT register definitions to their default lengths. + * + ******************************************************************************/ + +static void +AcpiTbSetupFadtRegisters ( + void) +{ + ACPI_GENERIC_ADDRESS *Target64; + ACPI_GENERIC_ADDRESS *Source64; + UINT8 Pm1RegisterByteWidth; + UINT32 i; + + + /* + * Optionally check all register lengths against the default values and + * update them if they are incorrect. + */ + if (AcpiGbl_UseDefaultRegisterWidths) + { + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtInfoTable[i].Address64); + + /* + * If a valid register (Address != 0) and the (DefaultLength > 0) + * (Not a GPE register), then check the width against the default. + */ + if ((Target64->Address) && + (FadtInfoTable[i].DefaultLength > 0) && + (FadtInfoTable[i].DefaultLength != Target64->BitWidth)) + { + ACPI_WARNING ((AE_INFO, + "Invalid length for %s: %d, using default %d", + FadtInfoTable[i].Name, Target64->BitWidth, + FadtInfoTable[i].DefaultLength)); + + /* Incorrect size, set width to the default */ + + Target64->BitWidth = FadtInfoTable[i].DefaultLength; + } + } + } + + /* + * Get the length of the individual PM1 registers (enable and status). + * Each register is defined to be (event block length / 2). Extra divide + * by 8 converts bits to bytes. + */ + Pm1RegisterByteWidth = (UINT8) + ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth); + + /* + * Calculate separate GAS structs for the PM1x (A/B) Status and Enable + * registers. These addresses do not appear (directly) in the FADT, so it + * is useful to pre-calculate them from the PM1 Event Block definitions. + * + * The PM event blocks are split into two register blocks, first is the + * PM Status Register block, followed immediately by the PM Enable + * Register block. Each is of length (Pm1EventLength/2) + * + * Note: The PM1A event block is required by the ACPI specification. + * However, the PM1B event block is optional and is rarely, if ever, + * used. + */ + + for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) + { + Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtPmInfoTable[i].Source); + + if (Source64->Address) + { + AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target, + Source64->SpaceId, Pm1RegisterByteWidth, + Source64->Address + + (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth)); + } } } diff --git a/src/add-ons/kernel/bus_managers/acpi/tables/tbfind.c b/src/add-ons/kernel/bus_managers/acpi/tables/tbfind.c index 8fb4df1c0d..1838b5eb78 100644 --- a/src/add-ons/kernel/bus_managers/acpi/tables/tbfind.c +++ b/src/add-ons/kernel/bus_managers/acpi/tables/tbfind.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: tbfind - find table - * $Revision: 1.5 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __TBFIND_C__ #include "acpi.h" +#include "accommon.h" #include "actables.h" #define _COMPONENT ACPI_TABLES diff --git a/src/add-ons/kernel/bus_managers/acpi/tables/tbinstal.c b/src/add-ons/kernel/bus_managers/acpi/tables/tbinstal.c index b8325cd4ae..c911f84f68 100644 --- a/src/add-ons/kernel/bus_managers/acpi/tables/tbinstal.c +++ b/src/add-ons/kernel/bus_managers/acpi/tables/tbinstal.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal - * $Revision: 1.94 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __TBINSTAL_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "actables.h" @@ -155,7 +155,8 @@ AcpiTbVerifyTable ( if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == ACPI_TABLE_ORIGIN_MAPPED) { - TableDesc->Pointer = AcpiOsMapMemory (TableDesc->Address, TableDesc->Length); + TableDesc->Pointer = AcpiOsMapMemory ( + TableDesc->Address, TableDesc->Length); } if (!TableDesc->Pointer) @@ -186,7 +187,9 @@ AcpiTbVerifyTable ( * * RETURN: Status * - * DESCRIPTION: This function is called to add the ACPI table + * DESCRIPTION: This function is called to add an ACPI table. It is used to + * dynamically load tables via the Load and LoadTable AML + * operators. * ******************************************************************************/ @@ -197,6 +200,7 @@ AcpiTbAddTable ( { UINT32 i; ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *OverrideTable = NULL; ACPI_FUNCTION_TRACE (TbAddTable); @@ -228,7 +232,8 @@ AcpiTbAddTable ( if (!AcpiGbl_RootTableList.Tables[i].Pointer) { Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); - if (ACPI_FAILURE (Status) || !AcpiGbl_RootTableList.Tables[i].Pointer) + if (ACPI_FAILURE (Status) || + !AcpiGbl_RootTableList.Tables[i].Pointer) { continue; } @@ -290,6 +295,30 @@ AcpiTbAddTable ( } } + /* + * ACPI Table Override: + * Allow the host to override dynamically loaded tables. + */ + Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + TableDesc->Pointer->Signature, + ACPI_CAST_PTR (void, TableDesc->Address))); + + /* We can delete the table that was passed as a parameter */ + + AcpiTbDeleteTable (TableDesc); + + /* Setup descriptor for the new table */ + + TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + TableDesc->Pointer = OverrideTable; + TableDesc->Length = OverrideTable->Length; + TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + /* Add the table to the global root table list */ Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, @@ -341,8 +370,9 @@ AcpiTbResizeRootTableList ( /* Increase the Table Array size */ Tables = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) AcpiGbl_RootTableList.Size + ACPI_ROOT_TABLE_SIZE_INCREMENT) - * sizeof (ACPI_TABLE_DESC)); + ((ACPI_SIZE) AcpiGbl_RootTableList.Size + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC)); if (!Tables) { ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); @@ -522,32 +552,62 @@ AcpiTbTerminate ( * * PARAMETERS: TableIndex - Table index * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Delete all namespace objects created when this table was loaded. * ******************************************************************************/ -void +ACPI_STATUS AcpiTbDeleteNamespaceByOwner ( UINT32 TableIndex) { ACPI_OWNER_ID OwnerId; + ACPI_STATUS Status; - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) { - OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + return_ACPI_STATUS (Status); } - else + + if (TableIndex >= AcpiGbl_RootTableList.Count) { + /* The table index does not exist */ + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return; + return_ACPI_STATUS (AE_NOT_EXIST); } + /* Get the owner ID for this table, used to delete namespace nodes */ + + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); + AcpiNsDeleteNamespaceByOwner (OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + return_ACPI_STATUS (Status); } @@ -610,7 +670,8 @@ AcpiTbReleaseOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); if (TableIndex < AcpiGbl_RootTableList.Count) { - AcpiUtReleaseOwnerId (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + AcpiUtReleaseOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); Status = AE_OK; } @@ -676,7 +737,8 @@ AcpiTbIsTableLoaded ( if (TableIndex < AcpiGbl_RootTableList.Count) { IsLoaded = (BOOLEAN) - (AcpiGbl_RootTableList.Tables[TableIndex].Flags & ACPI_TABLE_IS_LOADED); + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & + ACPI_TABLE_IS_LOADED); } (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); @@ -708,11 +770,13 @@ AcpiTbSetTableLoadedFlag ( { if (IsLoaded) { - AcpiGbl_RootTableList.Tables[TableIndex].Flags |= ACPI_TABLE_IS_LOADED; + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= + ACPI_TABLE_IS_LOADED; } else { - AcpiGbl_RootTableList.Tables[TableIndex].Flags &= ~ACPI_TABLE_IS_LOADED; + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= + ~ACPI_TABLE_IS_LOADED; } } diff --git a/src/add-ons/kernel/bus_managers/acpi/tables/tbutils.c b/src/add-ons/kernel/bus_managers/acpi/tables/tbutils.c index ab21db646e..ec2a88e283 100644 --- a/src/add-ons/kernel/bus_managers/acpi/tables/tbutils.c +++ b/src/add-ons/kernel/bus_managers/acpi/tables/tbutils.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: tbutils - table utilities - * $Revision: 1.91 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __TBUTILS_C__ #include "acpi.h" +#include "accommon.h" #include "actables.h" #define _COMPONENT ACPI_TABLES @@ -124,12 +124,48 @@ /* Local prototypes */ +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length); + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header); + static ACPI_PHYSICAL_ADDRESS AcpiTbGetRootTableEntry ( UINT8 *TableEntry, UINT32 TableEntrySize); +/******************************************************************************* + * + * FUNCTION: AcpiTbInitializeFacs + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global + * for accessing the Global Lock and Firmware Waking Vector + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInitializeFacs ( + void) +{ + ACPI_STATUS Status; + + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS)); + return (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiTbTablesLoaded @@ -157,6 +193,67 @@ AcpiTbTablesLoaded ( } +/******************************************************************************* + * + * FUNCTION: AcpiTbFixString + * + * PARAMETERS: String - String to be repaired + * Length - Maximum length + * + * RETURN: None + * + * DESCRIPTION: Replace every non-printable or non-ascii byte in the string + * with a question mark '?'. + * + ******************************************************************************/ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length) +{ + + while (Length && *String) + { + if (!ACPI_IS_PRINT (*String)) + { + *String = '?'; + } + String++; + Length--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCleanupTableHeader + * + * PARAMETERS: OutHeader - Where the cleaned header is returned + * Header - Input ACPI table header + * + * RETURN: Returns the cleaned header in OutHeader + * + * DESCRIPTION: Copy the table header and ensure that all "string" fields in + * the header consist of printable characters. + * + ******************************************************************************/ + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header) +{ + + ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); + + AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE); + AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE); + AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE); +} + + /******************************************************************************* * * FUNCTION: AcpiTbPrintTableHeader @@ -175,35 +272,48 @@ AcpiTbPrintTableHeader ( ACPI_PHYSICAL_ADDRESS Address, ACPI_TABLE_HEADER *Header) { + ACPI_TABLE_HEADER LocalHeader; + + /* + * The reason that the Address is cast to a void pointer is so that we + * can use %p which will work properly on both 32-bit and 64-bit hosts. + */ if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS)) { - /* FACS only has signature and length fields of common table header */ + /* FACS only has signature and length fields */ - ACPI_INFO ((AE_INFO, "%4.4s @ 0x%p/0x%04X", - Header->Signature, ACPI_CAST_PTR (UINT64, Address), Header->Length)); + ACPI_INFO ((AE_INFO, "%4.4s %p %05X", + Header->Signature, ACPI_CAST_PTR (void, Address), + Header->Length)); } else if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_RSDP)) { /* RSDP has no common fields */ - ACPI_INFO ((AE_INFO, "RSDP @ 0x%p/0x%04X (v%3.3d %6.6s)", + ACPI_MEMCPY (LocalHeader.OemId, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); + + ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", ACPI_CAST_PTR (void, Address), (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, - ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId)); + LocalHeader.OemId)); } else { /* Standard ACPI table with full common header */ + AcpiTbCleanupTableHeader (&LocalHeader, Header); + ACPI_INFO ((AE_INFO, - "%4.4s @ 0x%p/0x%04X (v%3.3d %6.6s %8.8s 0x%08X %4.4s 0x%08X)", - Header->Signature, ACPI_CAST_PTR (void, Address), - Header->Length, Header->Revision, Header->OemId, - Header->OemTableId, Header->OemRevision, Header->AslCompilerId, - Header->AslCompilerRevision)); + "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", + LocalHeader.Signature, ACPI_CAST_PTR (void, Address), + LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId, + LocalHeader.OemTableId, LocalHeader.OemRevision, + LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision)); } } @@ -240,7 +350,8 @@ AcpiTbVerifyChecksum ( { ACPI_WARNING ((AE_INFO, "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", - Table->Signature, Table->Checksum, (UINT8) (Table->Checksum - Checksum))); + Table->Signature, Table->Checksum, + (UINT8) (Table->Checksum - Checksum))); #if (ACPI_CHECKSUM_ABORT) return (AE_BAD_CHECKSUM); @@ -287,25 +398,30 @@ AcpiTbChecksum ( * FUNCTION: AcpiTbInstallTable * * PARAMETERS: Address - Physical address of DSDT or FACS - * Flags - Flags * Signature - Table signature, NULL if no need to * match * TableIndex - Index into root table array * * RETURN: None * - * DESCRIPTION: Install an ACPI table into the global data structure. + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is implemented here to allow the host + * OS to replace any table before it is installed in the root + * table array. * ******************************************************************************/ void AcpiTbInstallTable ( ACPI_PHYSICAL_ADDRESS Address, - UINT8 Flags, char *Signature, UINT32 TableIndex) { - ACPI_TABLE_HEADER *Table; + UINT8 Flags; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TableToInstall; + ACPI_TABLE_HEADER *MappedTable; + ACPI_TABLE_HEADER *OverrideTable = NULL; if (!Address) @@ -317,43 +433,70 @@ AcpiTbInstallTable ( /* Map just the table header */ - Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); - if (!Table) + MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!MappedTable) { return; } - /* If a particular signature is expected, signature must match */ + /* If a particular signature is expected (DSDT/FACS), it must match */ if (Signature && - !ACPI_COMPARE_NAME (Table->Signature, Signature)) + !ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) { - ACPI_ERROR ((AE_INFO, "Invalid signature 0x%X for ACPI table [%s]", - *ACPI_CAST_PTR (UINT32, Table->Signature), Signature)); + ACPI_ERROR ((AE_INFO, + "Invalid signature 0x%X for ACPI table, expected [%s]", + *ACPI_CAST_PTR (UINT32, MappedTable->Signature), Signature)); goto UnmapAndExit; } + /* + * ACPI Table Override: + * + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. + */ + Status = AcpiOsTableOverride (MappedTable, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + MappedTable->Signature, ACPI_CAST_PTR (void, Address))); + + AcpiGbl_RootTableList.Tables[TableIndex].Pointer = OverrideTable; + Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + + TableToInstall = OverrideTable; + Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + else + { + TableToInstall = MappedTable; + Flags = ACPI_TABLE_ORIGIN_MAPPED; + } + /* Initialize the table entry */ AcpiGbl_RootTableList.Tables[TableIndex].Address = Address; - AcpiGbl_RootTableList.Tables[TableIndex].Length = Table->Length; + AcpiGbl_RootTableList.Tables[TableIndex].Length = TableToInstall->Length; AcpiGbl_RootTableList.Tables[TableIndex].Flags = Flags; ACPI_MOVE_32_TO_32 ( &(AcpiGbl_RootTableList.Tables[TableIndex].Signature), - Table->Signature); + TableToInstall->Signature); - AcpiTbPrintTableHeader (Address, Table); + AcpiTbPrintTableHeader (Address, TableToInstall); if (TableIndex == ACPI_TABLE_INDEX_DSDT) { /* Global integer width is based upon revision of the DSDT */ - AcpiUtSetIntegerWidth (Table->Revision); + AcpiUtSetIntegerWidth (TableToInstall->Revision); } UnmapAndExit: - AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); } @@ -398,7 +541,8 @@ AcpiTbGetRootTableEntry ( { /* * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return - * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit + * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, + * return 64-bit */ ACPI_MOVE_64_TO_64 (&Address64, TableEntry); @@ -408,7 +552,8 @@ AcpiTbGetRootTableEntry ( /* Will truncate 64-bit address to 32 bits, issue warning */ ACPI_WARNING ((AE_INFO, - "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating", + "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," + " truncating", ACPI_FORMAT_UINT64 (Address64))); } #endif @@ -422,7 +567,6 @@ AcpiTbGetRootTableEntry ( * FUNCTION: AcpiTbParseRootTable * * PARAMETERS: Rsdp - Pointer to the RSDP - * Flags - Flags * * RETURN: Status * @@ -437,8 +581,7 @@ AcpiTbGetRootTableEntry ( ACPI_STATUS AcpiTbParseRootTable ( - ACPI_PHYSICAL_ADDRESS RsdpAddress, - UINT8 Flags) + ACPI_PHYSICAL_ADDRESS RsdpAddress) { ACPI_TABLE_RSDP *Rsdp; UINT32 TableEntrySize; @@ -463,7 +606,8 @@ AcpiTbParseRootTable ( return_ACPI_STATUS (AE_NO_MEMORY); } - AcpiTbPrintTableHeader (RsdpAddress, ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); + AcpiTbPrintTableHeader (RsdpAddress, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); /* Differentiate between RSDT and XSDT root tables */ @@ -530,11 +674,13 @@ AcpiTbParseRootTable ( /* Calculate the number of tables described in the root table */ - TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / TableEntrySize); + TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / + TableEntrySize); /* - * First two entries in the table array are reserved for the DSDT and FACS, - * which are not actually present in the RSDT/XSDT - they come from the FADT + * First two entries in the table array are reserved for the DSDT + * and FACS, which are not actually present in the RSDT/XSDT - they + * come from the FADT */ TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); AcpiGbl_RootTableList.Count = 2; @@ -552,7 +698,8 @@ AcpiTbParseRootTable ( if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", - (unsigned) (AcpiGbl_RootTableList.Size - AcpiGbl_RootTableList.Count))); + (unsigned) (TableCount - + (AcpiGbl_RootTableList.Count - 2)))); break; } } @@ -579,14 +726,14 @@ AcpiTbParseRootTable ( for (i = 2; i < AcpiGbl_RootTableList.Count; i++) { AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, - Flags, NULL, i); + NULL, i); /* Special case for FADT - get the DSDT and FACS */ if (ACPI_COMPARE_NAME ( &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) { - AcpiTbParseFadt (i, Flags); + AcpiTbParseFadt (i); } } diff --git a/src/add-ons/kernel/bus_managers/acpi/tables/tbxface.c b/src/add-ons/kernel/bus_managers/acpi/tables/tbxface.c index 7e10ac221e..4c12916c5a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/tables/tbxface.c +++ b/src/add-ons/kernel/bus_managers/acpi/tables/tbxface.c @@ -2,7 +2,6 @@ * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces - * $Revision: 1.88 $ * *****************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __TBXFACE_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "actables.h" @@ -237,7 +237,7 @@ AcpiInitializeTables ( * Root Table Array. This array contains the information of the RSDT/XSDT * in a common, more useable format. */ - Status = AcpiTbParseRootTable (RsdpAddress, ACPI_TABLE_ORIGIN_MAPPED); + Status = AcpiTbParseRootTable (RsdpAddress); return_ACPI_STATUS (Status); } @@ -304,7 +304,7 @@ AcpiReallocateRootTable ( ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetTableHeader * @@ -319,7 +319,7 @@ ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) * NOTE: Caller is responsible in unmapping the header with * AcpiOsUnmapMemory * - *****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiGetTableHeader ( @@ -339,9 +339,8 @@ AcpiGetTableHeader ( return (AE_BAD_PARAMETER); } - /* - * Walk the root table list - */ + /* Walk the root table list */ + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) { if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), @@ -357,10 +356,12 @@ AcpiGetTableHeader ( if (!AcpiGbl_RootTableList.Tables[i].Pointer) { - if ((AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_ORIGIN_MASK) == + if ((AcpiGbl_RootTableList.Tables[i].Flags & + ACPI_TABLE_ORIGIN_MASK) == ACPI_TABLE_ORIGIN_MAPPED) { - Header = AcpiOsMapMemory (AcpiGbl_RootTableList.Tables[i].Address, + Header = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[i].Address, sizeof (ACPI_TABLE_HEADER)); if (!Header) { @@ -370,16 +371,15 @@ AcpiGetTableHeader ( ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER)); AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER)); } - else { return AE_NOT_FOUND; } } - else { - ACPI_MEMCPY (OutTableHeader, AcpiGbl_RootTableList.Tables[i].Pointer, + ACPI_MEMCPY (OutTableHeader, + AcpiGbl_RootTableList.Tables[i].Pointer, sizeof(ACPI_TABLE_HEADER)); } @@ -392,7 +392,7 @@ AcpiGetTableHeader ( ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetTable * @@ -404,7 +404,7 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) * * DESCRIPTION: Finds and verifies an ACPI table. * - *****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiGetTable ( @@ -424,9 +424,8 @@ AcpiGetTable ( return (AE_BAD_PARAMETER); } - /* - * Walk the root table list - */ + /* Walk the root table list */ + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) { if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), @@ -534,7 +533,6 @@ AcpiTbLoadNamespace ( void) { ACPI_STATUS Status; - ACPI_TABLE_HEADER *Table; UINT32 i; @@ -548,56 +546,38 @@ AcpiTbLoadNamespace ( * are optional. */ if (!AcpiGbl_RootTableList.Count || - !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), - ACPI_SIG_DSDT) || - ACPI_FAILURE (AcpiTbVerifyTable(&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) + !ACPI_COMPARE_NAME ( + &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), + ACPI_SIG_DSDT) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) { Status = AE_NO_ACPI_TABLES; goto UnlockAndExit; } - /* - * Find DSDT table - */ - Status = AcpiOsTableOverride ( - AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer, &Table); - if (ACPI_SUCCESS (Status) && Table) - { - /* - * DSDT table has been found - */ - AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); - AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer = Table; - AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Length = Table->Length; - AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags = ACPI_TABLE_ORIGIN_UNKNOWN; + /* A valid DSDT is required */ - ACPI_INFO ((AE_INFO, "Table DSDT replaced by host OS")); - AcpiTbPrintTableHeader (0, Table); - } - - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); + Status = AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); if (ACPI_FAILURE (Status)) { - /* A valid DSDT is required */ - Status = AE_NO_ACPI_TABLES; goto UnlockAndExit; } (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - /* - * Load and parse tables. - */ + /* Load and parse tables */ + Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * Load any SSDT or PSDT tables. Note: Loop leaves tables locked - */ + /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) { @@ -605,7 +585,8 @@ AcpiTbLoadNamespace ( ACPI_SIG_SSDT) && !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), ACPI_SIG_PSDT)) || - ACPI_FAILURE (AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]))) + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[i]))) { continue; } @@ -647,13 +628,13 @@ AcpiLoadTables ( ACPI_FUNCTION_TRACE (AcpiLoadTables); - /* - * Load the namespace from the tables - */ + /* Load the namespace from the tables */ + Status = AcpiTbLoadNamespace (); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "While loading namespace from ACPI tables")); + ACPI_EXCEPTION ((AE_INFO, Status, + "While loading namespace from ACPI tables")); } return_ACPI_STATUS (Status); diff --git a/src/add-ons/kernel/bus_managers/acpi/tables/tbxfroot.c b/src/add-ons/kernel/bus_managers/acpi/tables/tbxfroot.c index 0f971496e7..e0a571f36f 100644 --- a/src/add-ons/kernel/bus_managers/acpi/tables/tbxfroot.c +++ b/src/add-ons/kernel/bus_managers/acpi/tables/tbxfroot.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: tbxfroot - Find the root ACPI table (RSDT) - * $Revision: 1.106 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __TBXFROOT_C__ #include "acpi.h" +#include "accommon.h" #include "actables.h" @@ -160,7 +160,8 @@ AcpiTbValidateRsdp ( * Note: Sometimes there exists more than one RSDP in memory; the valid * RSDP has a valid checksum, all others have an invalid checksum. */ - if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, sizeof (ACPI_SIG_RSDP)-1) != 0) + if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, + sizeof (ACPI_SIG_RSDP)-1) != 0) { /* Nope, BAD Signature */ @@ -188,7 +189,7 @@ AcpiTbValidateRsdp ( /******************************************************************************* * - * FUNCTION: AcpiTbFindRsdp + * FUNCTION: AcpiFindRootPointer * * PARAMETERS: TableAddress - Where the table pointer is returned * diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utalloc.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utalloc.c index d251e12a0d..a66b94005c 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utalloc.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utalloc.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utalloc - local memory allocation routines - * $Revision: 1.166 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __UTALLOC_C__ #include "acpi.h" +#include "accommon.h" #include "acdebug.h" #define _COMPONENT ACPI_UTILITIES @@ -318,7 +318,7 @@ AcpiUtValidateBuffer ( * RETURN: Status * * DESCRIPTION: Validate that the buffer is of the required length or - * allocate a new buffer. Returned buffer is always zeroed. + * allocate a new buffer. Returned buffer is always zeroed. * ******************************************************************************/ @@ -327,65 +327,71 @@ AcpiUtInitializeBuffer ( ACPI_BUFFER *Buffer, ACPI_SIZE RequiredLength) { - ACPI_STATUS Status = AE_OK; + ACPI_SIZE InputBufferLength; - switch (Buffer->Length) + /* Parameter validation */ + + if (!Buffer || !RequiredLength) + { + return (AE_BAD_PARAMETER); + } + + /* + * Buffer->Length is used as both an input and output parameter. Get the + * input actual length and set the output required buffer length. + */ + InputBufferLength = Buffer->Length; + Buffer->Length = RequiredLength; + + /* + * The input buffer length contains the actual buffer length, or the type + * of buffer to be allocated by this routine. + */ + switch (InputBufferLength) { case ACPI_NO_BUFFER: - /* Set the exception and returned the required length */ - - Status = AE_BUFFER_OVERFLOW; - break; + /* Return the exception (and the required buffer length) */ + return (AE_BUFFER_OVERFLOW); case ACPI_ALLOCATE_BUFFER: /* Allocate a new buffer */ Buffer->Pointer = AcpiOsAllocate (RequiredLength); - if (!Buffer->Pointer) - { - return (AE_NO_MEMORY); - } - - /* Clear the buffer */ - - ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); break; - case ACPI_ALLOCATE_LOCAL_BUFFER: /* Allocate a new buffer with local interface to allow tracking */ - Buffer->Pointer = ACPI_ALLOCATE_ZEROED (RequiredLength); - if (!Buffer->Pointer) - { - return (AE_NO_MEMORY); - } + Buffer->Pointer = ACPI_ALLOCATE (RequiredLength); break; - default: /* Existing buffer: Validate the size of the buffer */ - if (Buffer->Length < RequiredLength) + if (InputBufferLength < RequiredLength) { - Status = AE_BUFFER_OVERFLOW; - break; + return (AE_BUFFER_OVERFLOW); } - - /* Clear the buffer */ - - ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); break; } - Buffer->Length = RequiredLength; - return (Status); + /* Validate allocation from above or input buffer pointer */ + + if (!Buffer->Pointer) + { + return (AE_NO_MEMORY); + } + + /* Have a valid buffer, clear it */ + + ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); + return (AE_OK); } diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utcache.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utcache.c index fe7fa4ddfe..aabc0a2305 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utcache.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utcache.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utcache - local cache allocation routines - * $Revision: 1.9 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __UTCACHE_C__ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utcache") @@ -194,6 +194,7 @@ AcpiOsPurgeCache ( ACPI_MEMORY_LIST *Cache) { char *Next; + ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); @@ -204,6 +205,12 @@ AcpiOsPurgeCache ( return (AE_BAD_PARAMETER); } + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + /* Walk the list of objects in this cache */ while (Cache->ListHead) @@ -218,6 +225,7 @@ AcpiOsPurgeCache ( Cache->CurrentDepth--; } + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); return (AE_OK); } diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utclib.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utclib.c index f4a9a370c1..a9b8122fab 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utclib.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utclib.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: cmclib - Local implementation of C library functions - * $Revision: 1.61 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __CMCLIB_C__ #include "acpi.h" +#include "accommon.h" /* * These implementations of standard C Library routines can optionally be diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utcopy.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utcopy.c index fb987dceae..20a0e34324 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utcopy.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utcopy.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utcopy - Internal to external object translation utilities - * $Revision: 1.137 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +116,7 @@ #define __UTCOPY_C__ #include "acpi.h" -#include "amlcode.h" +#include "accommon.h" #include "acnamesp.h" @@ -227,11 +226,11 @@ AcpiUtCopyIsimpleToEsimple ( * In general, the external object will be the same type as * the internal object */ - ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); + ExternalObject->Type = InternalObject->Common.Type; /* However, only a limited number of external types are supported */ - switch (ACPI_GET_OBJECT_TYPE (InternalObject)) + switch (InternalObject->Common.Type) { case ACPI_TYPE_STRING: @@ -269,40 +268,47 @@ AcpiUtCopyIsimpleToEsimple ( /* This is an object reference. */ - switch (InternalObject->Reference.Opcode) + switch (InternalObject->Reference.Class) { - case AML_INT_NAMEPATH_OP: - - /* For namepath, return the object handle ("reference") */ - - default: - - /* We are referring to the namespace node */ + case ACPI_REFCLASS_NAME: + /* + * For namepath, return the object handle ("reference") + * We are referring to the namespace node + */ ExternalObject->Reference.Handle = InternalObject->Reference.Node; ExternalObject->Reference.ActualType = AcpiNsGetType (InternalObject->Reference.Node); break; + + default: + + /* All other reference types are unsupported */ + + return_ACPI_STATUS (AE_TYPE); } break; case ACPI_TYPE_PROCESSOR: - ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId; - ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address; - ExternalObject->Processor.PblkLength = InternalObject->Processor.Length; + ExternalObject->Processor.ProcId = + InternalObject->Processor.ProcId; + ExternalObject->Processor.PblkAddress = + InternalObject->Processor.Address; + ExternalObject->Processor.PblkLength = + InternalObject->Processor.Length; break; case ACPI_TYPE_POWER: ExternalObject->PowerResource.SystemLevel = - InternalObject->PowerResource.SystemLevel; + InternalObject->PowerResource.SystemLevel; ExternalObject->PowerResource.ResourceOrder = - InternalObject->PowerResource.ResourceOrder; + InternalObject->PowerResource.ResourceOrder; break; @@ -310,8 +316,9 @@ AcpiUtCopyIsimpleToEsimple ( /* * There is no corresponding external object type */ - ACPI_ERROR ((AE_INFO, "Unsupported object type, cannot convert to external object: %s", - AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (InternalObject)))); + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to external object: %s", + AcpiUtGetTypeName (InternalObject->Common.Type))); return_ACPI_STATUS (AE_SUPPORT); } @@ -451,7 +458,7 @@ AcpiUtCopyIpackageToEpackage ( Info.ObjectSpace = 0; Info.NumPackages = 1; - ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); + ExternalObject->Type = InternalObject->Common.Type; ExternalObject->Package.Count = InternalObject->Package.Count; ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info.FreeSpace); @@ -498,7 +505,7 @@ AcpiUtCopyIobjectToEobject ( ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); - if (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE) + if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE) { /* * Package object: Copy all subobjects (including @@ -581,7 +588,8 @@ AcpiUtCopyEsimpleToIsimple ( default: /* All other types are not supported */ - ACPI_ERROR ((AE_INFO, "Unsupported object type, cannot convert to internal object: %s", + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to internal object: %s", AcpiUtGetTypeName (ExternalObject->Type))); return_ACPI_STATUS (AE_SUPPORT); @@ -595,7 +603,9 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_STRING: InternalObject->String.Pointer = - ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) ExternalObject->String.Length + 1); + ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) + ExternalObject->String.Length + 1); + if (!InternalObject->String.Pointer) { goto ErrorExit; @@ -639,7 +649,7 @@ AcpiUtCopyEsimpleToIsimple ( /* TBD: should validate incoming handle */ - InternalObject->Reference.Opcode = AML_INT_NAMEPATH_OP; + InternalObject->Reference.Class = ACPI_REFCLASS_NAME; InternalObject->Reference.Node = ExternalObject->Reference.Handle; break; @@ -786,6 +796,7 @@ AcpiUtCopySimpleObject ( { UINT16 ReferenceCount; ACPI_OPERAND_OBJECT *NextObject; + ACPI_STATUS Status; /* Save fields from destination that we don't want to overwrite */ @@ -809,7 +820,7 @@ AcpiUtCopySimpleObject ( /* Handle the objects with extra data */ - switch (ACPI_GET_OBJECT_TYPE (DestDesc)) + switch (DestDesc->Common.Type) { case ACPI_TYPE_BUFFER: /* @@ -862,11 +873,11 @@ AcpiUtCopySimpleObject ( * We copied the reference object, so we now must add a reference * to the object pointed to by the reference * - * DDBHandle reference (from Load/LoadTable is a special reference, - * it's Reference.Object is the table index, so does not need to + * DDBHandle reference (from Load/LoadTable) is a special reference, + * it does not have a Reference.Object, so does not need to * increase the reference count */ - if (SourceDesc->Reference.Opcode == AML_LOAD_OP) + if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) { break; } @@ -884,6 +895,29 @@ AcpiUtCopySimpleObject ( } break; + /* + * For Mutex and Event objects, we cannot simply copy the underlying + * OS object. We must create a new one. + */ + case ACPI_TYPE_MUTEX: + + Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_EVENT: + + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &DestDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + default: /* Nothing to do for other simple objects */ break; @@ -937,7 +971,7 @@ AcpiUtCopyIelementToIelement ( * This is a simple object, just copy it */ TargetObject = AcpiUtCreateInternalObject ( - ACPI_GET_OBJECT_TYPE (SourceObject)); + SourceObject->Common.Type); if (!TargetObject) { return (AE_NO_MEMORY); @@ -1022,7 +1056,7 @@ AcpiUtCopyIpackageToIpackage ( ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); - DestObj->Common.Type = ACPI_GET_OBJECT_TYPE (SourceObj); + DestObj->Common.Type = SourceObj->Common.Type; DestObj->Common.Flags = SourceObj->Common.Flags; DestObj->Package.Count = SourceObj->Package.Count; @@ -1083,7 +1117,7 @@ AcpiUtCopyIobjectToIobject ( /* Create the top level object */ - *DestDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceDesc)); + *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); if (!*DestDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -1091,7 +1125,7 @@ AcpiUtCopyIobjectToIobject ( /* Copy the object and possible subobjects */ - if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_PACKAGE) + if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) { Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, WalkState); diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utdebug.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utdebug.c index 70e4db8a2b..3901b07d19 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utdebug.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utdebug.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utdebug - Debug print routines - * $Revision: 1.137 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +116,7 @@ #define __UTDEBUG_C__ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdebug") @@ -124,7 +124,7 @@ #ifdef ACPI_DEBUG_OUTPUT -static ACPI_THREAD_ID AcpiGbl_PrevThreadId = 0xFFFFFFFF; +static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; static char *AcpiGbl_FnEntryStr = "----Entry"; static char *AcpiGbl_FnExitStr = "----Exit-"; @@ -230,7 +230,7 @@ AcpiUtTrimFunctionName ( /******************************************************************************* * - * FUNCTION: AcpiUtDebugPrint + * FUNCTION: AcpiDebugPrint * * PARAMETERS: RequestedDebugLevel - Requested debug print level * LineNumber - Caller's line number (for error output) @@ -248,7 +248,7 @@ AcpiUtTrimFunctionName ( ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE -AcpiUtDebugPrint ( +AcpiDebugPrint ( UINT32 RequestedDebugLevel, UINT32 LineNumber, const char *FunctionName, @@ -279,8 +279,9 @@ AcpiUtDebugPrint ( if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ( - "\n**** Context Switch from TID %X to TID %X ****\n\n", - AcpiGbl_PrevThreadId, ThreadId); + "\n**** Context Switch from TID %p to TID %p ****\n\n", + ACPI_CAST_PTR (void, AcpiGbl_PrevThreadId), + ACPI_CAST_PTR (void, ThreadId)); } AcpiGbl_PrevThreadId = ThreadId; @@ -294,7 +295,7 @@ AcpiUtDebugPrint ( if (ACPI_LV_THREADS & AcpiDbgLevel) { - AcpiOsPrintf ("[%04lX] ", ThreadId); + AcpiOsPrintf ("[%p] ", ACPI_CAST_PTR (void, ThreadId)); } AcpiOsPrintf ("[%02ld] %-22.22s: ", @@ -305,12 +306,12 @@ AcpiUtDebugPrint ( va_end (args); } -ACPI_EXPORT_SYMBOL (AcpiUtDebugPrint) +ACPI_EXPORT_SYMBOL (AcpiDebugPrint) /******************************************************************************* * - * FUNCTION: AcpiUtDebugPrintRaw + * FUNCTION: AcpiDebugPrintRaw * * PARAMETERS: RequestedDebugLevel - Requested debug print level * LineNumber - Caller's line number @@ -328,7 +329,7 @@ ACPI_EXPORT_SYMBOL (AcpiUtDebugPrint) ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE -AcpiUtDebugPrintRaw ( +AcpiDebugPrintRaw ( UINT32 RequestedDebugLevel, UINT32 LineNumber, const char *FunctionName, @@ -351,7 +352,7 @@ AcpiUtDebugPrintRaw ( va_end (args); } -ACPI_EXPORT_SYMBOL (AcpiUtDebugPrintRaw) +ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw) /******************************************************************************* @@ -381,7 +382,7 @@ AcpiUtTrace ( AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s\n", AcpiGbl_FnEntryStr); } @@ -417,7 +418,7 @@ AcpiUtTracePtr ( AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s %p\n", AcpiGbl_FnEntryStr, Pointer); } @@ -452,7 +453,7 @@ AcpiUtTraceStr ( AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s %s\n", AcpiGbl_FnEntryStr, String); } @@ -487,7 +488,7 @@ AcpiUtTraceU32 ( AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s %08X\n", AcpiGbl_FnEntryStr, Integer); } @@ -517,7 +518,7 @@ AcpiUtExit ( UINT32 ComponentId) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s\n", AcpiGbl_FnExitStr); @@ -555,14 +556,14 @@ AcpiUtStatusExit ( if (ACPI_SUCCESS (Status)) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s %s\n", AcpiGbl_FnExitStr, AcpiFormatException (Status)); } else { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, AcpiFormatException (Status)); @@ -600,7 +601,7 @@ AcpiUtValueExit ( ACPI_INTEGER Value) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, ACPI_FORMAT_UINT64 (Value)); @@ -637,7 +638,7 @@ AcpiUtPtrExit ( UINT8 *Ptr) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, "%s %p\n", AcpiGbl_FnExitStr, Ptr); diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utdelete.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utdelete.c index 5afd8d4108..bf30aee74e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utdelete.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utdelete.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: utdelete - object deletion and reference count utilities - * $Revision: 1.126 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,10 +116,11 @@ #define __UTDELETE_C__ #include "acpi.h" +#include "accommon.h" #include "acinterp.h" #include "acnamesp.h" #include "acevents.h" -#include "amlcode.h" + #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdelete") @@ -158,6 +158,7 @@ AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT *HandlerDesc; ACPI_OPERAND_OBJECT *SecondDesc; ACPI_OPERAND_OBJECT *NextDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); @@ -172,7 +173,7 @@ AcpiUtDeleteInternalObj ( * Must delete or free any pointers within the object that are not * actual ACPI objects (for example, a raw buffer pointer). */ - switch (ACPI_GET_OBJECT_TYPE (Object)) + switch (Object->Common.Type) { case ACPI_TYPE_STRING: @@ -317,6 +318,25 @@ AcpiUtDeleteInternalObj ( HandlerDesc = Object->Region.Handler; if (HandlerDesc) { + NextDesc = HandlerDesc->AddressSpace.RegionList; + LastObjPtr = &HandlerDesc->AddressSpace.RegionList; + + /* Remove the region object from the handler's list */ + + while (NextDesc) + { + if (NextDesc == Object) + { + *LastObjPtr = NextDesc->Region.Next; + break; + } + + /* Walk the linked list of handler */ + + LastObjPtr = &NextDesc->Region.Next; + NextDesc = NextDesc->Region.Next; + } + if (HandlerDesc->AddressSpace.HandlerFlags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { @@ -494,7 +514,7 @@ AcpiUtUpdateRefCount ( Object, NewCount)); } - if (ACPI_GET_OBJECT_TYPE (Object) == ACPI_TYPE_METHOD) + if (Object->Common.Type == ACPI_TYPE_METHOD) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); @@ -587,7 +607,7 @@ AcpiUtUpdateObjectReference ( * All sub-objects must have their reference count incremented also. * Different object types have different subobjects. */ - switch (ACPI_GET_OBJECT_TYPE (Object)) + switch (Object->Common.Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: @@ -659,8 +679,8 @@ AcpiUtUpdateObjectReference ( * reference must track changes to the ref count of the index or * target object. */ - if ((Object->Reference.Opcode == AML_INDEX_OP) || - (Object->Reference.Opcode == AML_INT_NAMEPATH_OP)) + if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) || + (Object->Reference.Class== ACPI_REFCLASS_NAME)) { NextObject = Object->Reference.Object; } @@ -696,11 +716,20 @@ AcpiUtUpdateObjectReference ( return_ACPI_STATUS (AE_OK); + ErrorExit: ACPI_EXCEPTION ((AE_INFO, Status, "Could not update object reference count")); + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + return_ACPI_STATUS (Status); } diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/uteval.c b/src/add-ons/kernel/bus_managers/acpi/utilities/uteval.c index ce81314520..ecb0cf19a7 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/uteval.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/uteval.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: uteval - Object evaluation - * $Revision: 1.73 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,46 +116,43 @@ #define __UTEVAL_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" -#include "acinterp.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("uteval") -/* Local prototypes */ - -static void -AcpiUtCopyIdString ( - char *Destination, - char *Source, - ACPI_SIZE MaxLength); - -static ACPI_STATUS -AcpiUtTranslateOneCid ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_COMPATIBLE_ID *OneCid); - /* * Strings supported by the _OSI predefined (internal) method. + * + * March 2009: Removed "Linux" as this host no longer wants to respond true + * for this string. Basically, the only safe OS strings are windows-related + * and in many or most cases represent the only test path within the + * BIOS-provided ASL code. + * + * The second element of each entry is used to track the newest version of + * Windows that the BIOS has requested. */ -static const char *AcpiInterfacesSupported[] = +static const ACPI_INTERFACE_INFO AcpiInterfacesSupported[] = { /* Operating System Vendor Strings */ - "Linux", - "Windows 2000", /* Windows 2000 */ - "Windows 2001", /* Windows XP */ - "Windows 2001 SP1", /* Windows XP SP1 */ - "Windows 2001 SP2", /* Windows XP SP2 */ - "Windows 2001.1", /* Windows Server 2003 */ - "Windows 2001.1 SP1", /* Windows Server 2003 SP1 - Added 03/2006 */ - "Windows 2006", /* Windows Vista - Added 03/2006 */ + {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ + {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ + {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ + {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ + {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ + {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ + {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ + {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ + {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ + {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ /* Feature Group Strings */ - "Extended Address Space Descriptor" + {"Extended Address Space Descriptor", 0} /* * All "optional" feature group strings (features that are implemented @@ -185,6 +181,7 @@ AcpiUtOsiImplementation ( ACPI_STATUS Status; ACPI_OPERAND_OBJECT *StringDesc; ACPI_OPERAND_OBJECT *ReturnDesc; + UINT32 ReturnValue; UINT32 i; @@ -207,20 +204,29 @@ AcpiUtOsiImplementation ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* Default return value is SUPPORTED */ + /* Default return value is 0, NOT SUPPORTED */ - ReturnDesc->Integer.Value = ACPI_UINT32_MAX; - WalkState->ReturnDesc = ReturnDesc; + ReturnValue = 0; /* Compare input string to static table of supported interfaces */ for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++) { - if (!ACPI_STRCMP (StringDesc->String.Pointer, AcpiInterfacesSupported[i])) + if (!ACPI_STRCMP (StringDesc->String.Pointer, + AcpiInterfacesSupported[i].Name)) { - /* The interface is supported */ + /* + * The interface is supported. + * Update the OsiData if necessary. We keep track of the latest + * version of Windows that has been requested by the BIOS. + */ + if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData) + { + AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value; + } - return_ACPI_STATUS (AE_CTRL_TERMINATE); + ReturnValue = ACPI_UINT32_MAX; + goto Exit; } } @@ -234,13 +240,20 @@ AcpiUtOsiImplementation ( { /* The interface is supported */ - return_ACPI_STATUS (AE_CTRL_TERMINATE); + ReturnValue = ACPI_UINT32_MAX; } - /* The interface is not supported */ - ReturnDesc->Integer.Value = 0; - return_ACPI_STATUS (AE_CTRL_TERMINATE); +Exit: + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, + "ACPI: BIOS _OSI(%s) is %ssupported\n", + StringDesc->String.Pointer, ReturnValue == 0 ? "not " : "")); + + /* Complete the return value */ + + ReturnDesc->Integer.Value = ReturnValue; + WalkState->ReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); } @@ -256,7 +269,7 @@ AcpiUtOsiImplementation ( * RETURN: Status * * DESCRIPTION: Evaluates a namespace object and verifies the type of the - * return object. Common code that simplifies accessing objects + * return object. Common code that simplifies accessing objects * that have required return objects of fixed types. * * NOTE: Internal function, no parameter validation @@ -325,7 +338,7 @@ AcpiUtEvaluateObject ( /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE (Info->ReturnObject)) + switch ((Info->ReturnObject)->Common.Type) { case ACPI_TYPE_INTEGER: ReturnBtype = ACPI_BTYPE_INTEGER; @@ -352,7 +365,7 @@ AcpiUtEvaluateObject ( (!ExpectedReturnBtypes)) { /* - * We received a return object, but one was not expected. This can + * We received a return object, but one was not expected. This can * happen frequently if the "implicit return" feature is enabled. * Just delete the return object and return AE_OK. */ @@ -395,12 +408,12 @@ Cleanup: * * PARAMETERS: ObjectName - Object name to be evaluated * DeviceNode - Node for the device - * Address - Where the value is returned + * Value - Where the value is returned * * RETURN: Status * * DESCRIPTION: Evaluates a numeric namespace object for a selected device - * and stores result in *Address. + * and stores result in *Value. * * NOTE: Internal function, no parameter validation * @@ -410,7 +423,7 @@ ACPI_STATUS AcpiUtEvaluateNumericObject ( char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_INTEGER *Address) + ACPI_INTEGER *Value) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; @@ -428,326 +441,7 @@ AcpiUtEvaluateNumericObject ( /* Get the returned Integer */ - *Address = ObjDesc->Integer.Value; - - /* On exit, we must delete the return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCopyIdString - * - * PARAMETERS: Destination - Where to copy the string - * Source - Source string - * MaxLength - Length of the destination buffer - * - * RETURN: None - * - * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. - * Performs removal of a leading asterisk if present -- workaround - * for a known issue on a bunch of machines. - * - ******************************************************************************/ - -static void -AcpiUtCopyIdString ( - char *Destination, - char *Source, - ACPI_SIZE MaxLength) -{ - - /* - * Workaround for ID strings that have a leading asterisk. This construct - * is not allowed by the ACPI specification (ID strings must be - * alphanumeric), but enough existing machines have this embedded in their - * ID strings that the following code is useful. - */ - if (*Source == '*') - { - Source++; - } - - /* Do the actual copy */ - - ACPI_STRNCPY (Destination, Source, MaxLength); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtExecute_HID - * - * PARAMETERS: DeviceNode - Node for the device - * Hid - Where the HID is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _HID control method that returns the hardware - * ID of the device. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_HID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Hid) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (UtExecute_HID); - - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) - { - /* Convert the Numeric HID to string */ - - AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value); - } - else - { - /* Copy the String HID from the returned object */ - - AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer, - sizeof (Hid->Value)); - } - - /* On exit, we must delete the return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtTranslateOneCid - * - * PARAMETERS: ObjDesc - _CID object, must be integer or string - * OneCid - Where the CID string is returned - * - * RETURN: Status - * - * DESCRIPTION: Return a numeric or string _CID value as a string. - * (Compatible ID) - * - * NOTE: Assumes a maximum _CID string length of - * ACPI_MAX_CID_LENGTH. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtTranslateOneCid ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_COMPATIBLE_ID *OneCid) -{ - - - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) - { - case ACPI_TYPE_INTEGER: - - /* Convert the Numeric CID to string */ - - AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value); - return (AE_OK); - - case ACPI_TYPE_STRING: - - if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH) - { - return (AE_AML_STRING_LIMIT); - } - - /* Copy the String CID from the returned object */ - - AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer, - ACPI_MAX_CID_LENGTH); - return (AE_OK); - - default: - - return (AE_TYPE); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtExecute_CID - * - * PARAMETERS: DeviceNode - Node for the device - * ReturnCidList - Where the CID list is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _CID control method that returns one or more - * compatible hardware IDs for the device. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_CID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_COMPATIBLE_ID_LIST **ReturnCidList) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - UINT32 Count; - UINT32 Size; - ACPI_COMPATIBLE_ID_LIST *CidList; - UINT32 i; - - - ACPI_FUNCTION_TRACE (UtExecute_CID); - - - /* Evaluate the _CID method for this device */ - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, - &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the number of _CIDs returned */ - - Count = 1; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE) - { - Count = ObjDesc->Package.Count; - } - - /* Allocate a worst-case buffer for the _CIDs */ - - Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) + - sizeof (ACPI_COMPATIBLE_ID_LIST)); - - CidList = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Size); - if (!CidList) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Init CID list */ - - CidList->Count = Count; - CidList->Size = Size; - - /* - * A _CID can return either a single compatible ID or a package of - * compatible IDs. Each compatible ID can be one of the following: - * 1) Integer (32 bit compressed EISA ID) or - * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") - */ - - /* The _CID object can be either a single CID or a package (list) of CIDs */ - - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE) - { - /* Translate each package element */ - - for (i = 0; i < Count; i++) - { - Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i], - &CidList->Id[i]); - if (ACPI_FAILURE (Status)) - { - break; - } - } - } - else - { - /* Only one CID, translate to a string */ - - Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id); - } - - /* Cleanup on error */ - - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (CidList); - } - else - { - *ReturnCidList = CidList; - } - - /* On exit, we must delete the _CID return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtExecute_UID - * - * PARAMETERS: DeviceNode - Node for the device - * Uid - Where the UID is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _UID control method that returns the hardware - * ID of the device. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_UID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Uid) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (UtExecute_UID); - - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) - { - /* Convert the Numeric UID to string */ - - AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value); - } - else - { - /* Copy the String UID from the returned object */ - - AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer, - sizeof (Uid->Value)); - } + *Value = ObjDesc->Integer.Value; /* On exit, we must delete the return object */ @@ -814,63 +508,68 @@ AcpiUtExecute_STA ( /******************************************************************************* * - * FUNCTION: AcpiUtExecute_Sxds + * FUNCTION: AcpiUtExecutePowerMethods * * PARAMETERS: DeviceNode - Node for the device - * Flags - Where the status flags are returned + * MethodNames - Array of power method names + * MethodCount - Number of methods to execute + * OutValues - Where the power method values are returned * - * RETURN: Status + * RETURN: Status, OutValues * - * DESCRIPTION: Executes _STA for selected device and stores results in - * *Flags. + * DESCRIPTION: Executes the specified power methods for the device and returns + * the result(s). * * NOTE: Internal function, no parameter validation * ******************************************************************************/ ACPI_STATUS -AcpiUtExecute_Sxds ( +AcpiUtExecutePowerMethods ( ACPI_NAMESPACE_NODE *DeviceNode, - UINT8 *Highest) + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + ACPI_STATUS FinalStatus = AE_NOT_FOUND; UINT32 i; - ACPI_FUNCTION_TRACE (UtExecute_Sxds); + ACPI_FUNCTION_TRACE (UtExecutePowerMethods); - for (i = 0; i < 4; i++) + for (i = 0; i < MethodCount; i++) { - Highest[i] = 0xFF; + /* + * Execute the power method (_SxD or _SxW). The only allowable + * return type is an Integer. + */ Status = AcpiUtEvaluateObject (DeviceNode, - ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]), + ACPI_CAST_PTR (char, MethodNames[i]), ACPI_BTYPE_INTEGER, &ObjDesc); - if (ACPI_FAILURE (Status)) + if (ACPI_SUCCESS (Status)) { - if (Status != AE_NOT_FOUND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%s on Device %4.4s, %s\n", - ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]), - AcpiUtGetNodeName (DeviceNode), - AcpiFormatException (Status))); - - return_ACPI_STATUS (Status); - } - } - else - { - /* Extract the Dstate value */ - - Highest[i] = (UINT8) ObjDesc->Integer.Value; + OutValues[i] = (UINT8) ObjDesc->Integer.Value; /* Delete the return object */ AcpiUtRemoveReference (ObjDesc); + FinalStatus = AE_OK; /* At least one value is valid */ + continue; } + + OutValues[i] = ACPI_UINT8_MAX; + if (Status == AE_NOT_FOUND) + { + continue; /* Ignore if not found */ + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n", + ACPI_CAST_PTR (char, MethodNames[i]), + AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status))); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (FinalStatus); } diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utglobal.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utglobal.c index 22129b604a..b61b3fb5ba 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utglobal.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utglobal.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utglobal - Global variables for the ACPI subsystem - * $Revision: 1.256 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,10 +117,9 @@ #define DEFINE_ACPI_GLOBALS #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" -ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) - #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utglobal") @@ -174,7 +172,16 @@ const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = "\\_S5_" }; -const char *AcpiGbl_HighestDstateNames[4] = +const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] = +{ + "_S0W", + "_S1W", + "_S2W", + "_S3W", + "_S4W" +}; + +const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = { "_S1D", "_S2D", @@ -356,14 +363,12 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, - /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, - /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, - /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, + /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} @@ -400,8 +405,9 @@ const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = "PCI_Config", "EmbeddedControl", "SMBus", - "CMOS", + "SystemCMOS", "PCIBARTarget", + "IPMI", "DataTable" }; @@ -546,7 +552,7 @@ AcpiUtGetObjectTypeName ( return ("[NULL Object Descriptor]"); } - return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc))); + return (AcpiUtGetTypeName (ObjDesc->Common.Type)); } @@ -659,6 +665,60 @@ AcpiUtGetDescriptorName ( } +/******************************************************************************* + * + * FUNCTION: AcpiUtGetReferenceName + * + * PARAMETERS: Object - An ACPI reference object + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Decode a reference object sub-type to a string. + * + ******************************************************************************/ + +/* Printable names of reference object sub-types */ + +static const char *AcpiGbl_RefClassNames[] = +{ + /* 00 */ "Local", + /* 01 */ "Argument", + /* 02 */ "RefOf", + /* 03 */ "Index", + /* 04 */ "DdbHandle", + /* 05 */ "Named Object", + /* 06 */ "Debug" +}; + +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object) +{ + + if (!Object) + { + return ("NULL Object"); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + return ("Not an Operand object"); + } + + if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return ("Not a Reference object"); + } + + if (Object->Reference.Class > ACPI_REFCLASS_MAX) + { + return ("Unknown Reference class"); + } + + return (AcpiGbl_RefClassNames[Object->Reference.Class]); +} + + #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* * Strings and procedures used for debug only @@ -776,14 +836,14 @@ AcpiUtValidObjectType ( * * PARAMETERS: None * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Init library globals. All globals that require specific * initialization should be initialized here! * ******************************************************************************/ -void +ACPI_STATUS AcpiUtInitGlobals ( void) { @@ -799,7 +859,7 @@ AcpiUtInitGlobals ( Status = AcpiUtCreateCaches (); if (ACPI_FAILURE (Status)) { - return; + return_ACPI_STATUS (Status); } /* Mutex locked flags */ @@ -815,7 +875,10 @@ AcpiUtInitGlobals ( { AcpiGbl_OwnerIdMask[i] = 0; } - AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */ + + /* Last OwnerID is never valid */ + + AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Event counters */ @@ -833,6 +896,7 @@ AcpiUtInitGlobals ( AcpiGbl_GpeXruptListHead = NULL; AcpiGbl_GpeFadtBlocks[0] = NULL; AcpiGbl_GpeFadtBlocks[1] = NULL; + AcpiCurrentGpeCount = 0; /* Global handlers */ @@ -848,6 +912,7 @@ AcpiUtInitGlobals ( AcpiGbl_GlobalLockMutex = NULL; AcpiGbl_GlobalLockAcquired = FALSE; AcpiGbl_GlobalLockHandle = 0; + AcpiGbl_GlobalLockPresent = FALSE; /* Miscellaneous variables */ @@ -864,6 +929,7 @@ AcpiUtInitGlobals ( AcpiGbl_TraceDbgLayer = 0; AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; + AcpiGbl_OsiData = 0; /* Hardware oriented */ @@ -872,6 +938,7 @@ AcpiUtInitGlobals ( /* Namespace */ + AcpiGbl_ModuleCodeList = NULL; AcpiGbl_RootNode = NULL; AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; @@ -890,13 +957,15 @@ AcpiUtInitGlobals ( AcpiGbl_DisplayFinalMemStats = FALSE; #endif - return_VOID; + return_ACPI_STATUS (AE_OK); } /* Public globals */ +ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) ACPI_EXPORT_SYMBOL (AcpiDbgLevel) ACPI_EXPORT_SYMBOL (AcpiDbgLayer) ACPI_EXPORT_SYMBOL (AcpiGpeCount) +ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utids.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utids.c new file mode 100644 index 0000000000..7669330500 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utids.c @@ -0,0 +1,497 @@ +/****************************************************************************** + * + * Module Name: utids - support for device IDs - HID, UID, CID + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTIDS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utids") + +/* Local prototypes */ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIdString + * + * PARAMETERS: Destination - Where to copy the string + * Source - Source string + * + * RETURN: None + * + * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. + * Performs removal of a leading asterisk if present -- workaround + * for a known issue on a bunch of machines. + * + ******************************************************************************/ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source) +{ + + /* + * Workaround for ID strings that have a leading asterisk. This construct + * is not allowed by the ACPI specification (ID strings must be + * alphanumeric), but enough existing machines have this embedded in their + * ID strings that the following code is useful. + */ + if (*Source == '*') + { + Source++; + } + + /* Do the actual copy */ + + ACPI_STRCPY (Destination, Source); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_HID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string HID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _HID control method that returns the hardware + * ID of the device. The HID is either an 32-bit encoded EISAID + * Integer or a String. A string is always returned. An EISAID + * is converted to a string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Hid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_HID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_EISAID_STRING_SIZE; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the HID */ + + Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Hid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID)); + + /* Convert EISAID to a string or simply copy existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value); + } + else + { + AcpiUtCopyIdString (Hid->String, ObjDesc->String.Pointer); + } + + Hid->Length = Length; + *ReturnId = Hid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_UID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _UID control method that returns the unique + * ID of the device. The UID is either a 64-bit Integer (NOT an + * EISAID) or a string. Always returns a string. A 64-bit integer + * is converted to a decimal string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Uid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_UID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_MAX64_DECIMAL_DIGITS + 1; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the UID */ + + Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Uid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID)); + + /* Convert an Integer to string, or just copy an existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value); + } + else + { + AcpiUtCopyIdString (Uid->String, ObjDesc->String.Pointer); + } + + Uid->Length = Length; + *ReturnId = Uid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_CID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnCidList - Where the CID list is returned + * + * RETURN: Status, list of CID strings + * + * DESCRIPTION: Executes the _CID control method that returns one or more + * compatible hardware IDs for the device. + * + * NOTE: Internal function, no parameter validation + * + * A _CID method can return either a single compatible ID or a package of + * compatible IDs. Each compatible ID can be one of the following: + * 1) Integer (32 bit compressed EISA ID) or + * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") + * + * The Integer CIDs are converted to string format by this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList) +{ + ACPI_OPERAND_OBJECT **CidObjects; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID_LIST *CidList; + char *NextIdString; + UINT32 StringAreaSize; + UINT32 Length; + UINT32 CidListSize; + ACPI_STATUS Status; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecute_CID); + + + /* Evaluate the _CID method for this device */ + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Get the count and size of the returned _CIDs. _CID can return either + * a Package of Integers/Strings or a single Integer or String. + * Note: This section also validates that all CID elements are of the + * correct type (Integer or String). + */ + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Count = ObjDesc->Package.Count; + CidObjects = ObjDesc->Package.Elements; + } + else /* Single Integer or String CID */ + { + Count = 1; + CidObjects = &ObjDesc; + } + + StringAreaSize = 0; + for (i = 0; i < Count; i++) + { + /* String lengths include null terminator */ + + switch (CidObjects[i]->Common.Type) + { + case ACPI_TYPE_INTEGER: + StringAreaSize += ACPI_EISAID_STRING_SIZE; + break; + + case ACPI_TYPE_STRING: + StringAreaSize += CidObjects[i]->String.Length + 1; + break; + + default: + Status = AE_TYPE; + goto Cleanup; + } + } + + /* + * Now that we know the length of the CIDs, allocate return buffer: + * 1) Size of the base structure + + * 2) Size of the CID DEVICE_ID array + + * 3) Size of the actual CID strings + */ + CidListSize = sizeof (ACPI_DEVICE_ID_LIST) + + ((Count - 1) * sizeof (ACPI_DEVICE_ID)) + + StringAreaSize; + + CidList = ACPI_ALLOCATE_ZEROED (CidListSize); + if (!CidList) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for CID strings starts after the CID DEVICE_ID array */ + + NextIdString = ACPI_CAST_PTR (char, CidList->Ids) + + ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID)); + + /* Copy/convert the CIDs to the return buffer */ + + for (i = 0; i < Count; i++) + { + if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER) + { + /* Convert the Integer (EISAID) CID to a string */ + + AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value); + Length = ACPI_EISAID_STRING_SIZE; + } + else /* ACPI_TYPE_STRING */ + { + /* Copy the String CID from the returned object */ + + AcpiUtCopyIdString (NextIdString, CidObjects[i]->String.Pointer); + Length = CidObjects[i]->String.Length + 1; + } + + CidList->Ids[i].String = NextIdString; + CidList->Ids[i].Length = Length; + NextIdString += Length; + } + + /* Finish the CID list */ + + CidList->Count = Count; + CidList->ListSize = CidListSize; + *ReturnCidList = CidList; + + +Cleanup: + + /* On exit, we must delete the _CID return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utinit.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utinit.c index 1fcc5bcaab..d59904b46a 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utinit.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utinit.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utinit - Common ACPI subsystem initialization - * $Revision: 1.137 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __UTINIT_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #include "acevents.h" #include "actables.h" @@ -184,12 +184,12 @@ AcpiUtTerminate ( * * FUNCTION: AcpiUtSubsystemShutdown * - * PARAMETERS: none + * PARAMETERS: None * - * RETURN: none + * RETURN: None * - * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex - * objects here -- because the AML debugger may be still running. + * DESCRIPTION: Shutdown the various components. Do not delete the mutex + * objects here, because the AML debugger may be still running. * ******************************************************************************/ @@ -197,24 +197,8 @@ void AcpiUtSubsystemShutdown ( void) { - ACPI_FUNCTION_TRACE (UtSubsystemShutdown); - /* Just exit if subsystem is already shutdown */ - - if (AcpiGbl_Shutdown) - { - ACPI_ERROR ((AE_INFO, - "ACPI Subsystem is already terminated")); - return_VOID; - } - - /* Subsystem appears active, go ahead and shut it down */ - - AcpiGbl_Shutdown = TRUE; - AcpiGbl_StartupFlags = 0; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Shutting down ACPI Subsystem\n")); #ifndef ACPI_ASL_COMPILER diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utlock.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utlock.c new file mode 100644 index 0000000000..dd4e100001 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utlock.c @@ -0,0 +1,277 @@ +/****************************************************************************** + * + * Module Name: utlock - Reader/Writer lock interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTLOCK_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utlock") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateRwLock + * AcpiUtDeleteRwLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader/writer lock creation and deletion interfaces. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Lock->NumReaders = 0; + Status = AcpiOsCreateMutex (&Lock->ReaderMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateMutex (&Lock->WriterMutex); + return (Status); +} + + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsDeleteMutex (Lock->ReaderMutex); + AcpiOsDeleteMutex (Lock->WriterMutex); + + Lock->NumReaders = 0; + Lock->ReaderMutex = NULL; + Lock->WriterMutex = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireReadLock + * AcpiUtReleaseReadLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition, + * only the first reader acquires the write mutex. On release, + * only the last reader releases the write mutex. Although this + * algorithm can in theory starve writers, this should not be a + * problem with ACPICA since the subsystem is infrequently used + * in comparison to (for example) an I/O system. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Acquire the write lock only for the first reader */ + + Lock->NumReaders++; + if (Lock->NumReaders == 1) + { + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Release the write lock only for the very last reader */ + + Lock->NumReaders--; + if (Lock->NumReaders == 0) + { + AcpiOsReleaseMutex (Lock->WriterMutex); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireWriteLock + * AcpiUtReleaseWriteLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or + * release the writer mutex associated with the lock. Acquisition + * of the lock is fully exclusive and will block all readers and + * writers until it is released. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + return (Status); +} + + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsReleaseMutex (Lock->WriterMutex); +} + diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utmath.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utmath.c index c0b37228eb..b0a40ff2bc 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utmath.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utmath.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: utmath - Integer math support routines - * $Revision: 1.24 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __UTMATH_C__ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_UTILITIES diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utmisc.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utmisc.c index 64c2389908..89e1addba6 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utmisc.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utmisc.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: utmisc - common utility procedures - * $Revision: 1.154 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,12 +117,19 @@ #define __UTMISC_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmisc") +/* + * Common suffix for messages + */ +#define ACPI_COMMON_MSG_SUFFIX \ + AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber) + /******************************************************************************* * @@ -205,6 +211,40 @@ AcpiUtValidateException ( } +/******************************************************************************* + * + * FUNCTION: AcpiUtIsPciRootBridge + * + * PARAMETERS: Id - The HID/CID in string format + * + * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id) +{ + + /* + * Check if this is a PCI root bridge. + * ACPI 3.0+: check for a PCI Express root also. + */ + if (!(ACPI_STRCMP (Id, + PCI_ROOT_HID_STRING)) || + + !(ACPI_STRCMP (Id, + PCI_EXPRESS_ROOT_HID_STRING))) + { + return (TRUE); + } + + return (FALSE); +} + + /******************************************************************************* * * FUNCTION: AcpiUtIsAmlTable @@ -860,7 +900,7 @@ AcpiUtRepairName ( } else { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); } } @@ -1176,7 +1216,7 @@ AcpiUtWalkPackageTree ( */ if ((!ThisSourceObj) || (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (ThisSourceObj) != ACPI_TYPE_PACKAGE)) + (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE)) { Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, State, Context); @@ -1237,6 +1277,13 @@ AcpiUtWalkPackageTree ( State->Pkg.ThisTargetObj, 0); if (!State) { + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } return_ACPI_STATUS (AE_NO_MEMORY); } } @@ -1250,7 +1297,7 @@ AcpiUtWalkPackageTree ( /******************************************************************************* * - * FUNCTION: AcpiUtError, AcpiUtWarning, AcpiUtInfo + * FUNCTION: AcpiError, AcpiException, AcpiWarning, AcpiInfo * * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) @@ -1263,7 +1310,7 @@ AcpiUtWalkPackageTree ( ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE -AcpiUtError ( +AcpiError ( const char *ModuleName, UINT32 LineNumber, const char *Format, @@ -1272,16 +1319,16 @@ AcpiUtError ( va_list args; - AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); + AcpiOsPrintf ("ACPI Error: "); va_start (args, Format); AcpiOsVprintf (Format, args); - AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); + ACPI_COMMON_MSG_SUFFIX; va_end (args); } void ACPI_INTERNAL_VAR_XFACE -AcpiUtException ( +AcpiException ( const char *ModuleName, UINT32 LineNumber, ACPI_STATUS Status, @@ -1291,17 +1338,16 @@ AcpiUtException ( va_list args; - AcpiOsPrintf ("ACPI Exception (%s-%04d): %s, ", ModuleName, LineNumber, - AcpiFormatException (Status)); + AcpiOsPrintf ("ACPI Exception: %s, ", AcpiFormatException (Status)); va_start (args, Format); AcpiOsVprintf (Format, args); - AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); + ACPI_COMMON_MSG_SUFFIX; va_end (args); } void ACPI_INTERNAL_VAR_XFACE -AcpiUtWarning ( +AcpiWarning ( const char *ModuleName, UINT32 LineNumber, const char *Format, @@ -1310,16 +1356,16 @@ AcpiUtWarning ( va_list args; - AcpiOsPrintf ("ACPI Warning (%s-%04d): ", ModuleName, LineNumber); + AcpiOsPrintf ("ACPI Warning: "); va_start (args, Format); AcpiOsVprintf (Format, args); - AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); + ACPI_COMMON_MSG_SUFFIX; va_end (args); } void ACPI_INTERNAL_VAR_XFACE -AcpiUtInfo ( +AcpiInfo ( const char *ModuleName, UINT32 LineNumber, const char *Format, @@ -1328,10 +1374,6 @@ AcpiUtInfo ( va_list args; - /* - * Removed ModuleName, LineNumber, and acpica version, not needed - * for info output - */ AcpiOsPrintf ("ACPI: "); va_start (args, Format); @@ -1340,3 +1382,56 @@ AcpiUtInfo ( va_end (args); } +ACPI_EXPORT_SYMBOL (AcpiError) +ACPI_EXPORT_SYMBOL (AcpiException) +ACPI_EXPORT_SYMBOL (AcpiWarning) +ACPI_EXPORT_SYMBOL (AcpiInfo) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Warnings for the predefined validation module. Messages are + * only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of error + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list args; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf ("ACPI Warning for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utmutex.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utmutex.c index 0abc24cf1a..f6e7cc3652 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utmutex.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utmutex.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: utmutex - local mutex support - * $Revision: 1.13 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __UTMUTEX_C__ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmutex") @@ -141,7 +141,8 @@ AcpiUtDeleteMutex ( * * RETURN: Status * - * DESCRIPTION: Create the system mutex objects. + * DESCRIPTION: Create the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. * ******************************************************************************/ @@ -156,9 +157,8 @@ AcpiUtMutexInitialize ( ACPI_FUNCTION_TRACE (UtMutexInitialize); - /* - * Create each of the predefined mutex objects - */ + /* Create each of the predefined mutex objects */ + for (i = 0; i < ACPI_NUM_MUTEX; i++) { Status = AcpiUtCreateMutex (i); @@ -177,6 +177,14 @@ AcpiUtMutexInitialize ( } Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create the reader/writer lock for namespace access */ + + Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); return_ACPI_STATUS (Status); } @@ -189,7 +197,8 @@ AcpiUtMutexInitialize ( * * RETURN: None. * - * DESCRIPTION: Delete all of the system mutex objects. + * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. * ******************************************************************************/ @@ -203,9 +212,8 @@ AcpiUtMutexTerminate ( ACPI_FUNCTION_TRACE (UtMutexTerminate); - /* - * Delete each predefined mutex object - */ + /* Delete each predefined mutex object */ + for (i = 0; i < ACPI_NUM_MUTEX; i++) { (void) AcpiUtDeleteMutex (i); @@ -215,6 +223,10 @@ AcpiUtMutexTerminate ( AcpiOsDeleteLock (AcpiGbl_GpeLock); AcpiOsDeleteLock (AcpiGbl_HardwareLock); + + /* Delete the reader/writer lock */ + + AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); return_VOID; } @@ -339,15 +351,16 @@ AcpiUtAcquireMutex ( if (i == MutexId) { ACPI_ERROR ((AE_INFO, - "Mutex [%s] already acquired by this thread [%X]", - AcpiUtGetMutexName (MutexId), ThisThreadId)); + "Mutex [%s] already acquired by this thread [%p]", + AcpiUtGetMutexName (MutexId), + ACPI_CAST_PTR (void, ThisThreadId))); return (AE_ALREADY_ACQUIRED); } ACPI_ERROR ((AE_INFO, - "Invalid acquire order: Thread %X owns [%s], wants [%s]", - ThisThreadId, AcpiUtGetMutexName (i), + "Invalid acquire order: Thread %p owns [%s], wants [%s]", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); return (AE_ACQUIRE_DEADLOCK); @@ -357,15 +370,15 @@ AcpiUtAcquireMutex ( #endif ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + "Thread %p attempting to acquire Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); AcpiGbl_MutexInfo[MutexId].UseCount++; AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; @@ -373,7 +386,8 @@ AcpiUtAcquireMutex ( else { ACPI_EXCEPTION ((AE_INFO, Status, - "Thread %X could not acquire Mutex [%X]", ThisThreadId, MutexId)); + "Thread %p could not acquire Mutex [%X]", + ACPI_CAST_PTR (void, ThisThreadId), MutexId)); } return (Status); @@ -403,9 +417,8 @@ AcpiUtReleaseMutex ( ThisThreadId = AcpiOsGetThreadId (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X releasing Mutex [%s]\n", ThisThreadId, - AcpiUtGetMutexName (MutexId))); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); if (MutexId > ACPI_MAX_MUTEX) { diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utobject.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utobject.c index f49da2d3bf..e38d2b2879 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utobject.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utobject.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utobject - ACPI object create/delete/size/cache routines - * $Revision: 1.108 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -117,8 +116,8 @@ #define __UTOBJECT_C__ #include "acpi.h" +#include "accommon.h" #include "acnamesp.h" -#include "amlcode.h" #define _COMPONENT ACPI_UTILITIES @@ -420,7 +419,7 @@ AcpiUtValidInternalObject ( if (!Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n")); return (FALSE); } @@ -435,7 +434,7 @@ AcpiUtValidInternalObject ( return (TRUE); default: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is not not an ACPI operand obj [%s]\n", Object, AcpiUtGetDescriptorName (Object))); break; @@ -549,6 +548,7 @@ AcpiUtGetSimpleObjectSize ( ACPI_SIZE *ObjLength) { ACPI_SIZE Length; + ACPI_SIZE Size; ACPI_STATUS Status = AE_OK; @@ -586,7 +586,7 @@ AcpiUtGetSimpleObjectSize ( * must be accessed bytewise or there may be alignment problems on * certain processors */ - switch (ACPI_GET_OBJECT_TYPE (InternalObject)) + switch (InternalObject->Common.Type) { case ACPI_TYPE_STRING: @@ -611,16 +611,21 @@ AcpiUtGetSimpleObjectSize ( case ACPI_TYPE_LOCAL_REFERENCE: - switch (InternalObject->Reference.Opcode) + switch (InternalObject->Reference.Class) { - case AML_INT_NAMEPATH_OP: + case ACPI_REFCLASS_NAME: /* * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ - Length += ACPI_ROUND_UP_TO_NATIVE_WORD ( - AcpiNsGetPathnameLength (InternalObject->Reference.Node)); + Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node); + if (!Size) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size); break; default: @@ -630,9 +635,10 @@ AcpiUtGetSimpleObjectSize ( * Notably, Locals and Args are not supported, but this may be * required eventually. */ - ACPI_ERROR ((AE_INFO, - "Unsupported Reference opcode=%X in object %p", - InternalObject->Reference.Opcode, InternalObject)); + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported Reference Class [%s] %X in object %p", + AcpiUtGetReferenceName (InternalObject), + InternalObject->Reference.Class, InternalObject)); Status = AE_TYPE; break; } @@ -641,8 +647,10 @@ AcpiUtGetSimpleObjectSize ( default: - ACPI_ERROR ((AE_INFO, "Unsupported type=%X in object %p", - ACPI_GET_OBJECT_TYPE (InternalObject), InternalObject)); + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported type [%s] %X in object %p", + AcpiUtGetObjectTypeName (InternalObject), + InternalObject->Common.Type, InternalObject)); Status = AE_TYPE; break; } @@ -801,7 +809,7 @@ AcpiUtGetObjectSize ( if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE)) + (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)) { Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); } diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utresrc.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utresrc.c index d62e8ba89a..2f19d63986 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utresrc.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utresrc.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: utresrc - Resource managment utilities - * $Revision: 1.15 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __UTRESRC_C__ #include "acpi.h" +#include "accommon.h" #include "amlresrc.h" diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utstate.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utstate.c index 1da17203d0..245ca02bfc 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utstate.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utstate.c @@ -1,7 +1,6 @@ /******************************************************************************* * * Module Name: utstate - state object support procedures - * $Revision: 1.9 $ * ******************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +117,7 @@ #define __UTSTATE_C__ #include "acpi.h" +#include "accommon.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utstate") @@ -302,7 +302,7 @@ AcpiUtCreateThreadState ( if (!State->Thread.ThreadId) { ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); - State->Thread.ThreadId = 1; + State->Thread.ThreadId = (ACPI_THREAD_ID) 1; } return_PTR ((ACPI_THREAD_STATE *) State); diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/uttrack.c b/src/add-ons/kernel/bus_managers/acpi/utilities/uttrack.c index 5a0a22185d..d712c1a3e5 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/uttrack.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/uttrack.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: uttrack - Memory allocation tracking routines (debug only) - * $Revision: 1.6 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -128,6 +127,7 @@ #define __UTTRACK_C__ #include "acpi.h" +#include "accommon.h" #ifdef ACPI_DBG_TRACK_ALLOCATIONS diff --git a/src/add-ons/kernel/bus_managers/acpi/utilities/utxface.c b/src/add-ons/kernel/bus_managers/acpi/utilities/utxface.c index 0d1c4d2d82..ba57f4922b 100644 --- a/src/add-ons/kernel/bus_managers/acpi/utilities/utxface.c +++ b/src/add-ons/kernel/bus_managers/acpi/utilities/utxface.c @@ -1,7 +1,6 @@ /****************************************************************************** * * Module Name: utxface - External interfaces for "global" ACPI functions - * $Revision: 1.128 $ * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. * All rights reserved. * * 2. License @@ -118,9 +117,11 @@ #define __UTXFACE_C__ #include "acpi.h" +#include "accommon.h" #include "acevents.h" #include "acnamesp.h" #include "acdebug.h" +#include "actables.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utxface") @@ -165,7 +166,12 @@ AcpiInitializeSubsystem ( /* Initialize all globals used by the subsystem */ - AcpiUtInitGlobals (); + Status = AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals")); + return_ACPI_STATUS (Status); + } /* Create the default mutex objects */ @@ -235,6 +241,17 @@ AcpiEnableSubsystem ( } } + /* + * Obtain a permanent mapping for the FACS. This is required for the + * Global Lock and the Firmware Waking Vector + */ + Status = AcpiTbInitializeFacs (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); + return_ACPI_STATUS (Status); + } + /* * Install the default OpRegion handlers. These are installed unless * other handlers have already been installed via the @@ -342,6 +359,16 @@ AcpiInitializeObjects ( } } + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + */ + AcpiNsExecModuleCodeList (); + /* * Initialize the objects that remain uninitialized. This runs the * executable AML that may be part of the declaration of these objects: @@ -420,7 +447,7 @@ ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) * * RETURN: Status * - * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. + * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. * ******************************************************************************/ @@ -434,15 +461,28 @@ AcpiTerminate ( ACPI_FUNCTION_TRACE (AcpiTerminate); + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); + /* Terminate the AML Debugger if present */ - ACPI_DEBUGGER_EXEC(AcpiGbl_DbTerminateThreads = TRUE); + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); /* Shutdown and free all resources */ AcpiUtSubsystemShutdown (); - /* Free the mutex objects */ AcpiUtMutexTerminate (); @@ -463,8 +503,8 @@ AcpiTerminate ( ACPI_EXPORT_SYMBOL (AcpiTerminate) -#ifndef ACPI_ASL_COMPILER +#ifndef ACPI_ASL_COMPILER /******************************************************************************* * * FUNCTION: AcpiSubsystemStatus @@ -690,4 +730,5 @@ AcpiPurgeCachedObjects ( ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) -#endif +#endif /* ACPI_ASL_COMPILER */ +