diff options
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Parser')
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psargs.c | 950 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psfind.c | 459 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c | 704 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psparse.c | 1506 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psscope.c | 375 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/pstree.c | 518 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psutils.c | 683 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c | 727 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Parser/psxface.c | 270 |
9 files changed, 6192 insertions, 0 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psargs.c b/sys/contrib/dev/acpica/Subsystem/Parser/psargs.c new file mode 100644 index 0000000..6b203ff --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psargs.c @@ -0,0 +1,950 @@ +/****************************************************************************** + * + * Module Name: psargs - Parse AML opcode arguments + * $Revision: 35 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 __PSARGS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psargs") + + +UINT32 +AcpiPsPkgLengthEncodingSize ( + UINT32 FirstByte) +{ + + /* + * Bits 6-7 contain the number of bytes + * in the encoded package length (-1) + */ + + return ((FirstByte >> 6) + 1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageLength + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Decoded package length. On completion, the AML pointer points + * past the length byte or bytes. + * + * DESCRIPTION: Decode and return a package length field + * + ******************************************************************************/ + +UINT32 +xxxAcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 EncodingLength; + UINT32 PackageLength = 0; + UINT8 *AmlPtr = ParserState->Aml; + + + FUNCTION_TRACE ("PsGetNextPackageLength"); + + + EncodingLength = AcpiPsPkgLengthEncodingSize ((UINT32) GET8 (AmlPtr)); + + + switch (EncodingLength) + { + case 1: /* 1-byte encoding (bits 0-5) */ + + PackageLength = ((UINT32) GET8 (AmlPtr) & 0x3f); + break; + + + case 2: /* 2-byte encoding (next byte + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + + + case 3: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 2)) << 12) | + (((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + + + case 4: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 3)) << 20) | + (((UINT32) GET8 (AmlPtr + 2)) << 12) | + (((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + } + + ParserState->Aml += EncodingLength; + + return_VALUE (PackageLength); +} + +UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 EncodedLength; + UINT32 Length = 0; + + + FUNCTION_TRACE ("PsGetNextPackageLength"); + + + EncodedLength = (UINT32) GET8 (ParserState->Aml); + ParserState->Aml++; + + + switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */ + { + case 0: /* 1-byte encoding (bits 0-5) */ + + Length = (EncodedLength & 0x3f); + break; + + + case 1: /* 2-byte encoding (next byte + bits 0-3) */ + + Length = (GET8 (ParserState->Aml) << 4) | (EncodedLength & 0xf); + ParserState->Aml++; + break; + + + case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + Length = ( (GET8 (ParserState->Aml + 1) << 12) + | (GET8 (ParserState->Aml) << 4) + | (EncodedLength & 0xf)); + ParserState->Aml += 2; + break; + + + case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + Length = ( (GET8 (ParserState->Aml + 2) << 20) + | (GET8 (ParserState->Aml + 1) << 12) + | (GET8 (ParserState->Aml) << 4) + | (EncodedLength & 0xf)); + ParserState->Aml += 3; + break; + } + + return_VALUE (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageEnd + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to end-of-package +1 + * + * DESCRIPTION: Get next package length and return a pointer past the end of + * the package. Consumes the package length field + * + ******************************************************************************/ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + NATIVE_UINT Length; + + + FUNCTION_TRACE ("PsGetNextPackageEnd"); + + + Length = (NATIVE_UINT) AcpiPsGetNextPackageLength (ParserState); + + return_PTR (Start + Length); /* end of package */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamestring + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to the start of the name string (pointer points into + * the AML. + * + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name + * prefix characters. Set parser state to point past the string. + * (Name is consumed from the AML.) + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT8 *End = ParserState->Aml; + UINT32 Length; + + + FUNCTION_TRACE ("PsGetNextNamestring"); + + + /* Handle multiple prefix characters */ + + while (AcpiPsIsPrefixChar (GET8 (End))) + { + /* include prefix '\\' or '^' */ + + End++; + } + + /* Decode the path */ + + switch (GET8 (End)) + { + case 0: + + /* NullName */ + + if (End == Start) + { + Start = NULL; + } + End++; + break; + + + case AML_DUAL_NAME_PREFIX: + + /* two name segments */ + + End += 9; + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + /* multiple name segments */ + + Length = (UINT32) GET8 (End + 1) * 4; + End += 2 + Length; + break; + + + default: + + /* single name segment */ + /* assert (AcpiPsIsLead (GET8 (End))); */ + + End += 4; + break; + } + + ParserState->Aml = (UINT8*) End; + + return_PTR ((NATIVE_CHAR *) Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamepath + * + * PARAMETERS: ParserState - Current parser state object + * Arg - Where the namepath will be stored + * ArgCount - If the namepath points to a control method + * the method's argument is returned here. + * MethodCall - Whether the namepath can be the start + * of a method call + * + * RETURN: None + * + * DESCRIPTION: Get next name (if method call, push appropriate # args). Names + * are looked up in either the parsed or internal namespace to + * determine if the name represents a control method. If a method + * is found, the number of arguments to the method is returned. + * This information is critical for parsing to continue correctly. + * + ******************************************************************************/ + + +#ifdef PARSER_ONLY + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall) +{ + NATIVE_CHAR *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Count; + + + FUNCTION_TRACE ("PsGetNextNamepath"); + + + Path = AcpiPsGetNextNamestring (ParserState); + if (!Path || !MethodCall) + { + /* Null name case, create a null namepath object */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + return_VOID; + } + + + if (AcpiGbl_ParsedNamespaceRoot) + { + /* + * Lookup the name in the parsed namespace + */ + + Op = NULL; + if (MethodCall) + { + Op = AcpiPsFind (AcpiPsGetParentScope (ParserState), + Path, AML_METHOD_OP, 0); + } + + if (Op) + { + if (Op->Opcode == AML_METHOD_OP) + { + /* + * The name refers to a control method, so this namepath is a + * method invocation. We need to 1) Get the number of arguments + * associated with this method, and 2) Change the NAMEPATH + * object into a METHODCALL object. + */ + + Count = AcpiPsGetArg (Op, 0); + if (Count && Count->Opcode == AML_BYTE_OP) + { + NameOp = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (NameOp) + { + /* Change arg into a METHOD CALL and attach the name */ + + AcpiPsInitOp (Arg, AML_METHODCALL_OP); + + NameOp->Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Node = (ACPI_NAMESPACE_NODE *) Op; + AcpiPsAppendArg (Arg, NameOp); + + *ArgCount = Count->Value.Integer & + METHOD_FLAGS_ARG_COUNT; + } + } + + return_VOID; + } + + /* + * Else this is normal named object reference. + * Just init the NAMEPATH object with the pathname. + * (See code below) + */ + } + } + + + /* + * Either we didn't find the object in the namespace, or the object is + * something other than a control method. Just initialize the Op with the + * pathname + */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + + + return_VOID; +} + + +#else + + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall) +{ + NATIVE_CHAR *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; + + + FUNCTION_TRACE ("PsGetNextNamepath"); + + + Path = AcpiPsGetNextNamestring (ParserState); + if (!Path || !MethodCall) + { + /* Null name case, create a null namepath object */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + return_VOID; + } + + + if (MethodCall) + { + /* + * Lookup the name in the internal namespace + */ + ScopeInfo.Scope.Node = NULL; + Node = ParserState->StartNode; + if (Node) + { + ScopeInfo.Scope.Node = Node; + } + + /* + * Lookup object. We don't want to add anything new to the namespace + * here, however. So we use MODE_EXECUTE. Allow searching of the + * parent tree, but don't open a new scope -- we just want to lookup the + * object (MUST BE mode EXECUTE to perform upsearch) + */ + + Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, + &Node); + if (ACPI_SUCCESS (Status)) + { + if (Node->Type == ACPI_TYPE_METHOD) + { + MethodNode = Node; + DEBUG_PRINT (TRACE_PARSE, + ("PsGetNextNamepath: method - %p Path=%p\n", + MethodNode, Path)); + + NameOp = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (NameOp) + { + /* Change arg into a METHOD CALL and attach name to it */ + + AcpiPsInitOp (Arg, AML_METHODCALL_OP); + + NameOp->Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Node = MethodNode; + AcpiPsAppendArg (Arg, NameOp); + + *ArgCount = ((ACPI_OPERAND_OBJECT *) MethodNode->Object)->Method.ParamCount; + } + + return_VOID; + } + + /* + * Else this is normal named object reference. + * Just init the NAMEPATH object with the pathname. + * (See code below) + */ + } + } + + /* + * Either we didn't find the object in the namespace, or the object is + * something other than a control method. Just initialize the Op with the + * pathname + */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + + + return_VOID; +} + +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextSimpleArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * Arg - Where the argument is returned + * + * RETURN: None + * + * DESCRIPTION: Get the next simple argument (constant, string, or namestring) + * + ******************************************************************************/ + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg) +{ + + + FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); + + + switch (ArgType) + { + + case ARGP_BYTEDATA: + + AcpiPsInitOp (Arg, AML_BYTE_OP); + Arg->Value.Integer = (UINT32) GET8 (ParserState->Aml); + ParserState->Aml++; + break; + + + case ARGP_WORDDATA: + + AcpiPsInitOp (Arg, AML_WORD_OP); + + /* Get 2 bytes from the AML stream */ + + MOVE_UNALIGNED16_TO_32 (&Arg->Value.Integer, ParserState->Aml); + ParserState->Aml += 2; + break; + + + case ARGP_DWORDDATA: + + AcpiPsInitOp (Arg, AML_DWORD_OP); + + /* Get 4 bytes from the AML stream */ + + MOVE_UNALIGNED32_TO_32 (&Arg->Value.Integer, ParserState->Aml); + ParserState->Aml += 4; + break; + + + case ARGP_CHARLIST: + + AcpiPsInitOp (Arg, AML_STRING_OP); + Arg->Value.String = (char*) ParserState->Aml; + + while (GET8 (ParserState->Aml) != '\0') + { + ParserState->Aml++; + } + ParserState->Aml++; + break; + + + case ARGP_NAME: + case ARGP_NAMESTRING: + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = AcpiPsGetNextNamestring (ParserState); + break; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextField + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: A newly allocated FIELD op + * + * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_PTRDIFF AmlOffset = ParserState->Aml - + ParserState->AmlStart; + ACPI_PARSE_OBJECT *Field; + UINT16 Opcode; + UINT32 Name; + + + FUNCTION_TRACE ("PsGetNextField"); + + + /* determine field type */ + + switch (GET8 (ParserState->Aml)) + { + + default: + + Opcode = AML_NAMEDFIELD_OP; + break; + + + case 0x00: + + Opcode = AML_RESERVEDFIELD_OP; + ParserState->Aml++; + break; + + + case 0x01: + + Opcode = AML_ACCESSFIELD_OP; + ParserState->Aml++; + break; + } + + + /* Allocate a new field op */ + + Field = AcpiPsAllocOp (Opcode); + if (Field) + { + Field->AmlOffset = AmlOffset; + + /* Decode the field type */ + + switch (Opcode) + { + case AML_NAMEDFIELD_OP: + + /* Get the 4-character name */ + + MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml); + AcpiPsSetName (Field, Name); + ParserState->Aml += 4; + + /* Get the length which is encoded as a package length */ + + Field->Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_RESERVEDFIELD_OP: + + /* Get the length which is encoded as a package length */ + + Field->Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_ACCESSFIELD_OP: + + /* Get AccessType and AccessAtrib and merge into the field Op */ + + Field->Value.Integer = ((GET8 (ParserState->Aml) << 8) | + GET8 (ParserState->Aml)); + ParserState->Aml += 2; + break; + } + } + + return_PTR (Field); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * ArgCount - If the argument points to a control method + * the method's argument is returned here. + * + * RETURN: An op object containing the next argument. + * + * DESCRIPTION: Get next argument (including complex list arguments that require + * pushing the parser stack) + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetNextArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + UINT32 *ArgCount) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *Prev = NULL; + ACPI_PARSE_OBJECT *Field; + UINT32 Subop; + + + FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + case ARGP_WORDDATA: + case ARGP_DWORDDATA: + case ARGP_CHARLIST: + case ARGP_NAME: + case ARGP_NAMESTRING: + + /* constants, strings, and namestrings are all the same size */ + + Arg = AcpiPsAllocOp (AML_BYTE_OP); + if (Arg) + { + AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); + } + break; + + + case ARGP_PKGLENGTH: + + /* package length, nothing returned */ + + ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); + break; + + + case ARGP_FIELDLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* non-empty list */ + + while (ParserState->Aml < ParserState->PkgEnd) + { + Field = AcpiPsGetNextField (ParserState); + if (!Field) + { + break; + } + + if (Prev) + { + Prev->Next = Field; + } + + else + { + Arg = Field; + } + + Prev = Field; + } + + /* skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_BYTELIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* non-empty list */ + + Arg = AcpiPsAllocOp (AML_BYTELIST_OP); + if (Arg) + { + /* fill in bytelist data */ + + Arg->Value.Size = (ParserState->PkgEnd - ParserState->Aml); + ((ACPI_PARSE2_OBJECT *) Arg)->Data = ParserState->Aml; + } + + /* skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_TARGET: + case ARGP_SUPERNAME: + { + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) + { + /* NullName or NameString */ + + Arg = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (Arg) + { + AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0); + } + } + + else + { + /* single complex argument, nothing returned */ + + *ArgCount = 1; + } + } + break; + + + case ARGP_DATAOBJ: + case ARGP_TERMARG: + + /* single complex argument, nothing returned */ + + *ArgCount = 1; + break; + + + case ARGP_DATAOBJLIST: + case ARGP_TERMLIST: + case ARGP_OBJLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* non-empty list of variable arguments, nothing returned */ + + *ArgCount = ACPI_VAR_ARGS; + } + break; + } + + return_PTR (Arg); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psfind.c b/sys/contrib/dev/acpica/Subsystem/Parser/psfind.c new file mode 100644 index 0000000..a0a9236 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psfind.c @@ -0,0 +1,459 @@ + +/****************************************************************************** + * + * Module Name: psfind - Parse tree search routine + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 __PSFIND_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParent + * + * PARAMETERS: Op - Get the parent of this Op + * + * RETURN: The Parent op. + * + * DESCRIPTION: Get op's parent + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsGetParent ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent = Op; + + + /* Traverse the tree upward (to root if necessary) */ + + while (Parent) + { + switch (Parent->Opcode) + { + case AML_SCOPE_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_DEVICE_OP: + case AML_POWER_RES_OP: + case AML_THERMAL_ZONE_OP: + + return (Parent->Parent); + } + + Parent = Parent->Parent; + } + + return (Parent); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFindName + * + * PARAMETERS: Scope - Scope to search + * Name - ACPI name to search for + * Opcode - Opcode to search for + * + * RETURN: Op containing the name + * + * DESCRIPTION: Find name segment from a list of acpi_ops. Searches a single + * scope, no more. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsFindName ( + ACPI_PARSE_OBJECT *Scope, + UINT32 Name, + UINT32 Opcode) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Field; + + + /* search scope level for matching name segment */ + + Op = AcpiPsGetChild (Scope); + + while (Op) + { + + if (AcpiPsIsFieldOp (Op->Opcode)) + { + /* Field, search named fields */ + + Field = AcpiPsGetChild (Op); + while (Field) + { + if (AcpiPsIsNamedOp (Field->Opcode) && + AcpiPsGetName (Field) == Name && + (!Opcode || Field->Opcode == Opcode)) + { + return (Field); + } + + Field = Field->Next; + } + } + + else if (AcpiPsIsCreateFieldOp (Op->Opcode)) + { + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + Field = AcpiPsGetArg (Op, 3); + } + + else + { + /* CreateXXXField, check name */ + + Field = AcpiPsGetArg (Op, 2); + } + + if ((Field) && + (Field->Value.String) && + (!STRNCMP (Field->Value.String, (char *) &Name, ACPI_NAME_SIZE))) + { + return (Op); + } + } + + else if ((AcpiPsIsNamedOp (Op->Opcode)) && + (AcpiPsGetName (Op) == Name) && + (!Opcode || Op->Opcode == Opcode || Opcode == AML_SCOPE_OP)) + { + break; + } + + Op = Op->Next; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFind + * + * PARAMETERS: Scope - Where to begin the search + * Path - ACPI Path to the named object + * Opcode - Opcode associated with the object + * Create - if TRUE, create the object if not found. + * + * RETURN: Op if found, NULL otherwise. + * + * DESCRIPTION: Find object within scope + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR *Path, + UINT16 Opcode, + UINT32 Create) +{ + UINT32 SegCount; + UINT32 Name; + UINT32 NameOp; + ACPI_PARSE_OBJECT *Op = NULL; + BOOLEAN Unprefixed = TRUE; + + + FUNCTION_TRACE_PTR ("PsFind", Scope); + + + if (!Scope || !Path) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Null path (%p) or scope (%p)!\n", Path, Scope)); + return_VALUE (NULL); + } + + + AcpiGbl_PsFindCount++; + + + /* Handle all prefixes in the name path */ + + while (AcpiPsIsPrefixChar (GET8 (Path))) + { + switch (GET8 (Path)) + { + + case '\\': + + /* Could just use a global for "root scope" here */ + + while (Scope->Parent) + { + Scope = Scope->Parent; + } + + /* get first object within the scope */ + /* TBD: [Investigate] OR - set next in root scope to point to the same value as arg */ + + /* Scope = Scope->Value.Arg; */ + + break; + + + case '^': + + /* Go up to the next valid scoping Op (method, scope, etc.) */ + + if (AcpiPsGetParent (Scope)) + { + Scope = AcpiPsGetParent (Scope); + } + + break; + } + + Unprefixed = FALSE; + Path++; + } + + /* get name segment count */ + + switch (GET8 (Path)) + { + case '\0': + SegCount = 0; + + /* Null name case */ + + if (Unprefixed) + { + Op = NULL; + } + else + { + Op = Scope; + } + + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Null path, returning current root scope Op=%p\n", Op)); + return_PTR (Op); + break; + + case AML_DUAL_NAME_PREFIX: + SegCount = 2; + Path++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + SegCount = GET8 (Path + 1); + Path += 2; + break; + + default: + SegCount = 1; + break; + } + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Search scope %p Segs=%d Opcode=%4.4X Create=%d\n", Scope, SegCount, Opcode, Create)); + + /* match each name segment */ + + while (Scope && SegCount) + { + MOVE_UNALIGNED32_TO_32 (&Name, Path); + Path += 4; + SegCount --; + + if (SegCount) + { + NameOp = 0; + } + else + { + NameOp = Opcode; + } + + Op = AcpiPsFindName (Scope, Name, NameOp); + if (Op) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Found! Op=%p Opcode=%4.4X\n", &Name, Op, Op->Opcode)); + } + + if (!Op) + { + if (Create) + { + /* Create a new Scope level */ + + if (SegCount) + { + Op = AcpiPsAllocOp (AML_SCOPE_OP); + } + else + { + Op = AcpiPsAllocOp (Opcode); + } + + if (Op) + { + AcpiPsSetName (Op, Name); + AcpiPsAppendArg (Scope, Op); + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Not found, created Op=%p Opcode=%4.4X\n", &Name, Op, Opcode)); + } + } + + else if (Unprefixed) + { + /* Search higher scopes for unprefixed name */ + + while (!Op && Scope->Parent) + { + Scope = Scope->Parent; + Op = AcpiPsFindName (Scope, Name, Opcode); + if (Op) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Found in parent tree! Op=%p Opcode=%4.4X\n", &Name, Op, Op->Opcode)); + } + + else + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Not found in parent=%p\n", &Name, Scope)); + } + } + } + + else + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Segment [%4.4s] Not Found in scope %p!\n", &Name, Scope)); + } + } + + Unprefixed = FALSE; + Scope = Op; + } + + return_PTR (Op); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c b/sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c new file mode 100644 index 0000000..8035f6a --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c @@ -0,0 +1,704 @@ +/****************************************************************************** + * + * Module Name: psopcode - Parser opcode information table + * $Revision: 20 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT PARSER + MODULE_NAME ("psopcode") + + +UINT8 AcpiGbl_AmlShortOpInfoIndex[]; +UINT8 AcpiGbl_AmlLongOpInfoIndex[]; + +#define _UNK 0x6B +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D +#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ + +#define MAX_EXTENDED_OPCODE 0x87 +#define NUM_EXTENDED_OPCODE MAX_EXTENDED_OPCODE + 1 +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE MAX_INTERNAL_OPCODE + 1 + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeInfo + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the info about the opcode. NULL if the opcode was + * not found in the table. + * + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! + * + ******************************************************************************/ + +ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *OpInfo; + UINT8 UpperOpcode; + UINT8 LowerOpcode; + + + /* Split the 16-bit opcode into separate bytes */ + + UpperOpcode = (UINT8) (Opcode >> 8); + LowerOpcode = (UINT8) Opcode; + + /* Default is "unknown opcode" */ + + OpInfo = &AcpiGbl_AmlOpInfo [_UNK]; + + + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + + switch (UpperOpcode) + { + case 0: + + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ + + OpInfo = &AcpiGbl_AmlOpInfo [AcpiGbl_AmlShortOpInfoIndex [LowerOpcode]]; + break; + + + case AML_EXTOP: + + /* Extended (16-bit, prefix+opcode) opcode */ + + if (LowerOpcode <= MAX_EXTENDED_OPCODE) + { + OpInfo = &AcpiGbl_AmlOpInfo [AcpiGbl_AmlLongOpInfoIndex [LowerOpcode]]; + } + break; + + + case AML_LNOT_OP: + + /* This case is for the bogus opcodes LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL */ + /* TBD: [Investigate] remove this case? */ + + DEBUG_PRINT (ACPI_ERROR, ("PsGetOpcodeInfo: Bad multi-byte opcode=%X\n", + Opcode)); + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ("PsGetOpcodeInfo: Unknown extended opcode=%X\n", + Opcode)); + + break; + } + + + /* Get the Op info pointer for this opcode */ + + return (OpInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeName + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the name of the opcode (ASCII String) + * Note: Never returns NULL. + * + * DESCRIPTION: Translate an opcode into a human-readable string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiPsGetOpcodeName ( + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *Op; + + + Op = AcpiPsGetOpcodeInfo (Opcode); + + /* Always guaranteed to return a valid pointer */ + + DEBUG_ONLY_MEMBERS (return Op->Name); + return ("AE_NOT_CONFIGURED"); +} + + +/******************************************************************************* + * + * NAME: AcpiGbl_AmlOpInfo + * + * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands> + * The name is a simple ascii string, the operand specifier is an + * ascii string with one letter per operand. The letter specifies + * the operand type. + * + ******************************************************************************/ + + +/* + * Flags byte: 0-4 (5 bits) = Opcode Type + * 5 (1 bit) = Has arguments flag + * 6-7 (2 bits) = Reserved + */ +#define AML_NO_ARGS 0 +#define AML_HAS_ARGS ACPI_OP_ARGS_MASK + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed + * into a 32-bit number and stored in the master opcode table at the end of this file. + */ + +#define ARGP_ZERO_OP ARG_NONE +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEF_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed + * into a 32-bit number and stored in the master opcode table at the end of this file. + * + * (Used by AcpiAmlPrepOperands procedure) + */ + +#define ARGI_ZERO_OP ARG_NONE +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_STRING_OP ARGI_INVALID_OPCODE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#define ARGI_BUFFER_OP ARGI_INVALID_OPCODE +#define ARGI_PACKAGE_OP ARGI_INVALID_OPCODE +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_TARGETREF) +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_TARGETREF) +#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_REFERENCE, ARGI_NUMBER) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_LAND_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_REFERENCE, ARGI_TARGETREF) +#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_NUMBER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION, ARGI_TARGETREF) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_NUMBER) +#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_NUMBER) +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_DEBUG_OP ARG_NONE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_REGION_OP ARGI_INVALID_OPCODE +#define ARGI_DEF_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE + + +/* + * Master Opcode information table. A summary of everything we know about each opcode, all in one place. + */ + + +ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[] = +{ +/* Index Opcode Type Class Has Arguments? Name Parser Args Interpreter Args */ + +/* 00 */ /* AML_ZERO_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "ZeroOp", ARGP_ZERO_OP, ARGI_ZERO_OP), +/* 01 */ /* AML_ONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "OneOp", ARGP_ONE_OP, ARGI_ONE_OP), +/* 02 */ /* AML_ALIAS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP), +/* 03 */ /* AML_NAME_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Name", ARGP_NAME_OP, ARGI_NAME_OP), +/* 04 */ /* AML_BYTE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP), +/* 05 */ /* AML_WORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "WordConst", ARGP_WORD_OP, ARGI_WORD_OP), +/* 06 */ /* AML_DWORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP), +/* 07 */ /* AML_STRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "String", ARGP_STRING_OP, ARGI_STRING_OP), +/* 08 */ /* AML_SCOPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP), +/* 09 */ /* AML_BUFFER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP), +/* 0A */ /* AML_PACKAGE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP), +/* 0B */ /* AML_METHOD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Method", ARGP_METHOD_OP, ARGI_METHOD_OP), +/* 0C */ /* AML_LOCAL0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local0", ARGP_LOCAL0, ARGI_LOCAL0), +/* 0D */ /* AML_LOCAL1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local1", ARGP_LOCAL1, ARGI_LOCAL1), +/* 0E */ /* AML_LOCAL2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local2", ARGP_LOCAL2, ARGI_LOCAL2), +/* 0F */ /* AML_LOCAL3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local3", ARGP_LOCAL3, ARGI_LOCAL3), +/* 10 */ /* AML_LOCAL4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local4", ARGP_LOCAL4, ARGI_LOCAL4), +/* 11 */ /* AML_LOCAL5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local5", ARGP_LOCAL5, ARGI_LOCAL5), +/* 12 */ /* AML_LOCAL6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local6", ARGP_LOCAL6, ARGI_LOCAL6), +/* 13 */ /* AML_LOCAL7 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local7", ARGP_LOCAL7, ARGI_LOCAL7), +/* 14 */ /* AML_ARG0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg0", ARGP_ARG0, ARGI_ARG0), +/* 15 */ /* AML_ARG1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg1", ARGP_ARG1, ARGI_ARG1), +/* 16 */ /* AML_ARG2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg2", ARGP_ARG2, ARGI_ARG2), +/* 17 */ /* AML_ARG3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg3", ARGP_ARG3, ARGI_ARG3), +/* 18 */ /* AML_ARG4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg4", ARGP_ARG4, ARGI_ARG4), +/* 19 */ /* AML_ARG5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg5", ARGP_ARG5, ARGI_ARG5), +/* 1A */ /* AML_ARG6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg6", ARGP_ARG6, ARGI_ARG6), +/* 1B */ /* AML_STORE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "Store", ARGP_STORE_OP, ARGI_STORE_OP), +/* 1C */ /* AML_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP), +/* 1D */ /* AML_ADD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Add", ARGP_ADD_OP, ARGI_ADD_OP), +/* 1E */ /* AML_CONCAT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Concat", ARGP_CONCAT_OP, ARGI_CONCAT_OP), +/* 1F */ /* AML_SUBTRACT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP), +/* 20 */ /* AML_INCREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP), +/* 21 */ /* AML_DECREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP), +/* 22 */ /* AML_MULTIPLY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP), +/* 23 */ /* AML_DIVIDE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP), +/* 24 */ /* AML_SHIFT_LEFT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP), +/* 25 */ /* AML_SHIFT_RIGHT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP), +/* 26 */ /* AML_BIT_AND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP), +/* 27 */ /* AML_BIT_NAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP), +/* 28 */ /* AML_BIT_OR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP), +/* 29 */ /* AML_BIT_NOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP), +/* 2A */ /* AML_BIT_XOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP), +/* 2B */ /* AML_BIT_NOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP), +/* 2C */ /* AML_FIND_SET_LEFT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP), +/* 2D */ /* AML_FIND_SET_RIGHT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, ARGI_FIND_SET_RIGHT_BIT_OP), +/* 2E */ /* AML_DEREF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP), +/* 2F */ /* AML_NOTIFY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC1| AML_HAS_ARGS, "Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP), +/* 30 */ /* AML_SIZE_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP), +/* 31 */ /* AML_INDEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_INDEX| AML_HAS_ARGS, "Index", ARGP_INDEX_OP, ARGI_INDEX_OP), +/* 32 */ /* AML_MATCH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MATCH| AML_HAS_ARGS, "Match", ARGP_MATCH_OP, ARGI_MATCH_OP), +/* 33 */ /* AML_DWORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateDWordField", ARGP_DWORD_FIELD_OP, ARGI_DWORD_FIELD_OP), +/* 34 */ /* AML_WORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateWordField", ARGP_WORD_FIELD_OP, ARGI_WORD_FIELD_OP), +/* 35 */ /* AML_BYTE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateByteField", ARGP_BYTE_FIELD_OP, ARGI_BYTE_FIELD_OP), +/* 36 */ /* AML_BIT_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateBitField", ARGP_BIT_FIELD_OP, ARGI_BIT_FIELD_OP), +/* 37 */ /* AML_TYPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP), +/* 38 */ /* AML_LAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LAnd", ARGP_LAND_OP, ARGI_LAND_OP), +/* 39 */ /* AML_LOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LOr", ARGP_LOR_OP, ARGI_LOR_OP), +/* 3A */ /* AML_LNOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "LNot", ARGP_LNOT_OP, ARGI_LNOT_OP), +/* 3B */ /* AML_LEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP), +/* 3C */ /* AML_LGREATER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP), +/* 3D */ /* AML_LLESS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LLess", ARGP_LLESS_OP, ARGI_LLESS_OP), +/* 3E */ /* AML_IF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "If", ARGP_IF_OP, ARGI_IF_OP), +/* 3F */ /* AML_ELSE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Else", ARGP_ELSE_OP, ARGI_ELSE_OP), +/* 40 */ /* AML_WHILE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "While", ARGP_WHILE_OP, ARGI_WHILE_OP), +/* 41 */ /* AML_NOOP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Noop", ARGP_NOOP_OP, ARGI_NOOP_OP), +/* 42 */ /* AML_RETURN_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Return", ARGP_RETURN_OP, ARGI_RETURN_OP), +/* 43 */ /* AML_BREAK_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break", ARGP_BREAK_OP, ARGI_BREAK_OP), +/* 44 */ /* AML_BREAK_POINT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP), +/* 45 */ /* AML_ONES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "OnesOp", ARGP_ONES_OP, ARGI_ONES_OP), + +/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ + +/* 46 */ /* AML_MUTEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP), +/* 47 */ /* AML_EVENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_NO_ARGS, "Event", ARGP_EVENT_OP, ARGI_EVENT_OP), +/* 48 */ /* AML_COND_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP), +/* 49 */ /* AML_CREATE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP), +/* 4A */ /* AML_LOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Load", ARGP_LOAD_OP, ARGI_LOAD_OP), +/* 4B */ /* AML_STALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Stall", ARGP_STALL_OP, ARGI_STALL_OP), +/* 4C */ /* AML_SLEEP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP), +/* 4D */ /* AML_ACQUIRE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2S| AML_HAS_ARGS, "Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP), +/* 4E */ /* AML_SIGNAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP), +/* 4F */ /* AML_WAIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2S| AML_HAS_ARGS, "Wait", ARGP_WAIT_OP, ARGI_WAIT_OP), +/* 50 */ /* AML_RESET_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Reset", ARGP_RESET_OP, ARGI_RESET_OP), +/* 51 */ /* AML_RELEASE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP), +/* 52 */ /* AML_FROM_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP), +/* 53 */ /* AML_TO_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP), +/* 54 */ /* AML_UNLOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP), +/* 55 */ /* AML_REVISION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Revision", ARGP_REVISION_OP, ARGI_REVISION_OP), +/* 56 */ /* AML_DEBUG_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP), +/* 57 */ /* AML_FATAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_FATAL| AML_HAS_ARGS, "Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP), +/* 58 */ /* AML_REGION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "OpRegion", ARGP_REGION_OP, ARGI_REGION_OP), +/* 59 */ /* AML_DEF_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Field", ARGP_DEF_FIELD_OP, ARGI_DEF_FIELD_OP), +/* 5A */ /* AML_DEVICE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP), +/* 5B */ /* AML_PROCESSOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP), +/* 5C */ /* AML_POWER_RES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "PowerRes", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP), +/* 5D */ /* AML_THERMAL_ZONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP), +/* 5E */ /* AML_INDEX_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP), +/* 5F */ /* AML_BANK_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP), + +/* Internal opcodes that map to invalid AML opcodes */ + +/* 60 */ /* AML_LNOTEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP), +/* 61 */ /* AML_LLESSEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP), +/* 62 */ /* AML_LGREATEREQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP), +/* 63 */ /* AML_NAMEPATH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "NamePath", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP), +/* 64 */ /* AML_METHODCALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_CALL| AML_HAS_ARGS, "MethodCall", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP), +/* 65 */ /* AML_BYTELIST_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "ByteList", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP), +/* 66 */ /* AML_RESERVEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "ReservedField", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP), +/* 67 */ /* AML_NAMEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "NamedField", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP), +/* 68 */ /* AML_ACCESSFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "AccessField", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP), +/* 69 */ /* AML_STATICSTRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP), +/* 6A */ /* AML_RETURN_VALUE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RETURN| AML_HAS_ARGS, "[Return Value]", ARG_NONE, ARG_NONE), +/* 6B */ /* UNKNOWN OPCODES */ OP_INFO_ENTRY (ACPI_OP_TYPE_UNKNOWN | OPTYPE_BOGUS| AML_HAS_ARGS, "UNKNOWN_OP!", ARG_NONE, ARG_NONE), +/* 6C */ /* ASCII CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_ASCII | OPTYPE_BOGUS| AML_HAS_ARGS, "ASCII_ONLY!", ARG_NONE, ARG_NONE), +/* 6D */ /* PREFIX CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_PREFIX | OPTYPE_BOGUS| AML_HAS_ARGS, "PREFIX_ONLY!", ARG_NONE, ARG_NONE), +}; + +/* + * This table is directly indexed by the opcodes, and returns an + * index into the table above + */ + +UINT8 AcpiGbl_AmlShortOpInfoIndex[256] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, _UNK, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, _UNK, 0x0b, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, +/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, _UNK, _UNK, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, _UNK, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, _UNK, _UNK, +/* 0x98 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, +/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, +/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, +}; + + +UINT8 AcpiGbl_AmlLongOpInfoIndex[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +}; + + +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psparse.c b/sys/contrib/dev/acpica/Subsystem/Parser/psparse.c new file mode 100644 index 0000000..4951b7a --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psparse.c @@ -0,0 +1,1506 @@ +/****************************************************************************** + * + * Module Name: psparse - Parser top level AML parse routines + * $Revision: 60 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AcpiGbl_AmlOpInfo[] + */ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psparse") + + +UINT32 AcpiGbl_Depth = 0; +extern UINT32 AcpiGbl_ScopeDepth; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteCompletedOp + * + * PARAMETERS: State - Walk state + * Op - Completed op + * + * RETURN: AE_OK + * + * DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during + * AcpiPsDeleteParse tree to delete Op objects when all sub-objects + * have been visited (and deleted.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsDeleteCompletedOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op) +{ + + AcpiPsFreeOp (Op); + return (AE_OK); +} + + +#ifndef PARSER_ONLY +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseTree + * + * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete + * + * RETURN: None + * + * DESCRIPTION: Delete a portion of or an entire parse tree. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *SubtreeRoot) +{ + ACPI_WALK_STATE *WalkState; + ACPI_WALK_LIST WalkList; + + + FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot); + + + if (!SubtreeRoot) + { + return_VOID; + } + + /* Create and initialize a new walk list */ + + WalkList.WalkState = NULL; + WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, &WalkList); + if (!WalkState) + { + return_VOID; + } + + WalkState->ParserState = NULL; + WalkState->ParseFlags = 0; + WalkState->DescendingCallback = NULL; + WalkState->AscendingCallback = NULL; + + + WalkState->Origin = SubtreeRoot; + WalkState->NextOp = SubtreeRoot; + + + /* Head downward in the tree */ + + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Visit all nodes in the subtree */ + + while (WalkState->NextOp) + { + AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp, + AcpiPsDeleteCompletedOp); + } + + /* We are done with this walk */ + + AcpiDsDeleteWalkState (WalkState); + + return_VOID; +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode) +{ + + /* Extended (2-byte) opcode if > 255 */ + + if (Opcode > 0x00FF) + { + return (2); + } + + /* Otherwise, just a single byte opcode */ + + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: ParserState - A parser state object + * + * RETURN: Status + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml; + UINT16 Opcode; + + + Aml = ParserState->Aml; + Opcode = (UINT16) GET8 (Aml); + + Aml++; + + + /* + * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL. + * These opcodes are no longer recognized. Instead, they are broken into + * two opcodes. + * + * + * if (Opcode == AML_EXTOP + * || (Opcode == AML_LNOT + * && (GET8 (AcpiAml) == AML_LEQUAL + * || GET8 (AcpiAml) == AML_LGREATER + * || GET8 (AcpiAml) == AML_LLESS))) + * + * extended Opcode, !=, <=, or >= + */ + + if (Opcode == AML_EXTOP) + { + /* Extended opcode */ + + Opcode = (UINT16) ((Opcode << 8) | GET8 (Aml)); + Aml++; + } + + /* don't convert bare name to a namepath */ + + return (Opcode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateState + * + * PARAMETERS: AcpiAml - AcpiAml code pointer + * AcpiAmlSize - Length of AML code + * + * RETURN: A new parser state object + * + * DESCRIPTION: Create and initialize a new parser state object + * + ******************************************************************************/ + +ACPI_PARSE_STATE * +AcpiPsCreateState ( + UINT8 *Aml, + UINT32 AmlSize) +{ + ACPI_PARSE_STATE *ParserState; + + + FUNCTION_TRACE ("PsCreateState"); + + + ParserState = AcpiCmCallocate (sizeof (ACPI_PARSE_STATE)); + if (!ParserState) + { + return_VALUE (NULL); + } + + ParserState->Aml = Aml; + ParserState->AmlEnd = Aml + AmlSize; + ParserState->PkgEnd = ParserState->AmlEnd; + ParserState->AmlStart = Aml; + + + return_PTR (ParserState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFindObject + * + * PARAMETERS: Opcode - Current opcode + * ParserState - Current state + * WalkState - Current state + * *Op - Where found/new op is returned + * + * RETURN: Status + * + * DESCRIPTION: Find a named object. Two versions - one to search the parse + * tree (for parser-only applications such as acpidump), another + * to search the ACPI internal namespace (the parse tree may no + * longer exist) + * + ******************************************************************************/ + +#ifdef PARSER_ONLY + +ACPI_STATUS +AcpiPsFindObject ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + NATIVE_CHAR *Path; + + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + *OutOp = Op; + return (AE_OK); + } + + /* Find the name in the parse tree */ + + Path = AcpiPsGetNextNamestring (WalkState->ParserState); + + *OutOp = AcpiPsFind (AcpiPsGetParentScope (WalkState->ParserState), + Path, Opcode, 1); + + if (!(*OutOp)) + { + return (AE_NOT_FOUND); + } + + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteThisOp + * + * PARAMETERS: WalkState - Current State + * Op - Op to complete + * + * RETURN: TRUE if Op and subtree was deleted + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ +#ifndef PARSER_ONLY + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_OPCODE_INFO *OpInfo; + ACPI_OPCODE_INFO *ParentInfo; + UINT32 OpcodeClass; + ACPI_PARSE_OBJECT *ReplacementOp = NULL; + + + FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op); + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + OpcodeClass = ACPI_GET_OP_CLASS (OpInfo); + + + /* Delete this op and the subtree below it if asked to */ + + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && + (OpcodeClass != OPTYPE_CONSTANT) && + (OpcodeClass != OPTYPE_LITERAL) && + (OpcodeClass != OPTYPE_LOCAL_VARIABLE) && + (OpcodeClass != OPTYPE_METHOD_ARGUMENT) && + (OpcodeClass != OPTYPE_DATA_TERM) && + (Op->Opcode != AML_NAMEPATH_OP)) + { + /* Make sure that we only delete this subtree */ + + if (Op->Parent) + { + /* + * Check if we need to replace the operator and its subtree + * with a return value op + */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode); + + switch (ACPI_GET_OP_CLASS (ParentInfo)) + { + case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ + case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ + break; + + default: + ReplacementOp = AcpiPsAllocOp (AML_RETURN_VALUE_OP); + if (!ReplacementOp) + { + return_VALUE (FALSE); + } + } + + /* We must unlink this op from the parent tree */ + + Prev = Op->Parent->Value.Arg; + if (Prev == Op) + { + /* This op is the first in the list */ + + if (ReplacementOp) + { + ReplacementOp->Parent = Op->Parent; + ReplacementOp->Value.Arg = NULL; + Op->Parent->Value.Arg = ReplacementOp; + ReplacementOp->Next = Op->Next; + } + else + { + Op->Parent->Value.Arg = Op->Next; + } + } + + /* Search the parent list */ + + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + + Next = Prev->Next; + if (Next == Op) + { + if (ReplacementOp) + { + ReplacementOp->Parent = Op->Parent; + ReplacementOp->Value.Arg = NULL; + Prev->Next = ReplacementOp; + ReplacementOp->Next = Op->Next; + Next = NULL; + } + else + { + Prev->Next = Op->Next; + Next = NULL; + } + } + + Prev = Next; + } + + } + + /* Now we can actually delete the subtree rooted at op */ + + AcpiPsDeleteParseTree (Op); + + return_VALUE (TRUE); + } + + return_VALUE (FALSE); + +#else + return (FALSE); +#endif +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsNextParseState + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus) +{ + ACPI_PARSE_STATE *ParserState = WalkState->ParserState; + ACPI_STATUS Status = AE_CTRL_PENDING; + UINT8 *Start; + UINT32 PackageLength; + + + FUNCTION_TRACE_PTR ("PsNextParseState", Op); + + + switch (CallbackStatus) + { + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + + ParserState->Aml = ParserState->AmlEnd; + Status = AE_CTRL_TERMINATE; + break; + + + case AE_CTRL_PENDING: + + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ +/* WalkState->ControlState->Common.State = + CONTROL_PREDICATE_EXECUTING;*/ + + /* TBD: How to handle a break within a while. */ + /* This code attempts it */ + + ParserState->Aml = WalkState->AmlLastWhile; + break; + + + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + * + * Note: ParserState->Aml is modified by the package length procedure + * TBD: [Investigate] perhaps it shouldn't, too much trouble + */ + Start = ParserState->Aml; + PackageLength = AcpiPsGetNextPackageLength (ParserState); + ParserState->Aml = Start + PackageLength; + break; + + + case AE_CTRL_FALSE: + + /* + * Either an IF/WHILE Predicate was false or we encountered a BREAK + * opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ + + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + + /* In the case of a BREAK, just force a predicate (if any) to FALSE */ + + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_END; + break; + + + case AE_CTRL_TRANSFER: + + /* + * A method call (invocation) -- transfer control + */ + Status = AE_CTRL_TRANSFER; + WalkState->PrevOp = Op; + WalkState->MethodCallOp = Op; + WalkState->MethodCallNode = (Op->Value.Arg)->Node; + + /* Will return value (if any) be used by the caller? */ + + WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState); + break; + + + default: + Status = CallbackStatus; + if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) + { + Status = AE_OK; + } + break; + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_OPCODE_INFO *OpInfo; + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE2_OBJECT *DeferredOp; + UINT32 ArgCount; /* push for fixed or var args */ + UINT32 ArgTypes = 0; + ACPI_PTRDIFF AmlOffset; + UINT16 Opcode; + ACPI_PARSE_OBJECT PreOp; + ACPI_PARSE_STATE *ParserState; + + + + FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); + + + ParserState = WalkState->ParserState; + + if (WalkState->WalkType & WALK_METHOD_RESTART) + { + /* We are restarting a preempted control method */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((ParserState->Scope->ParseScope.Op) && + ((ParserState->Scope->ParseScope.Op->Opcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Opcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + CONTROL_PREDICATE_EXECUTING)) + { + + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + + Status = AcpiDsGetPredicateValue (WalkState, NULL, TRUE); + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op)); + } + + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + ArgTypes = WalkState->PrevArgTypes; + } + } + + /* + * Iterative parsing loop, while there is more aml to process: + */ + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + if (!Op) + { + /* Get the next opcode from the AML stream */ + + AmlOffset = ParserState->Aml - ParserState->AmlStart; + Opcode = AcpiPsPeekOpcode (ParserState); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + switch (ACPI_GET_OP_TYPE (OpInfo)) + { + case ACPI_OP_TYPE_OPCODE: + + /* Found opcode info, this is a normal opcode */ + + ParserState->Aml += AcpiPsGetOpcodeSize (Opcode); + ArgTypes = OpInfo->ParseArgs; + break; + + case ACPI_OP_TYPE_ASCII: + case ACPI_OP_TYPE_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + + Opcode = AML_NAMEPATH_OP; + ArgTypes = ARGP_NAMESTRING; + break; + + case ACPI_OP_TYPE_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + DEBUG_PRINT (ACPI_ERROR, + ("ParseLoop: Found unknown opcode 0x%lX at AML offset 0x%X, ignoring\n", + Opcode, AmlOffset)); + + DUMP_BUFFER (ParserState->Aml, 128); + + /* Assume one-byte bad opcode */ + + ParserState->Aml++; + continue; + } + + + /* Create Op structure and append to parent's argument list */ + + if (AcpiPsIsNamedOp (Opcode)) + { + PreOp.Value.Arg = NULL; + PreOp.Opcode = Opcode; + + while (GET_CURRENT_ARG_TYPE (ArgTypes) != ARGP_NAME) + { + Arg = AcpiPsGetNextArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), + &ArgCount); + AcpiPsAppendArg (&PreOp, Arg); + INCREMENT_ARG_LIST (ArgTypes); + } + + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (ArgTypes); + + if (WalkState->DescendingCallback != NULL) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + Status = WalkState->DescendingCallback (Opcode, NULL, WalkState, &Op); + if (Op == NULL) + { + continue; + } + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + + AcpiPsAppendArg (Op, PreOp.Value.Arg); + AcpiGbl_Depth++; + + + if (Op->Opcode == AML_REGION_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Backup to beginning of OpRegion declaration (2 for + * Opcode, 4 for name) + * + * BodyLength is unknown until we parse the body + */ + + DeferredOp->Data = ParserState->Aml - 6; + DeferredOp->Length = 0; + } + } + } + + + else + { + /* Not a named opcode, just allocate Op and append to parent */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + if ((Op->Opcode == AML_CREATE_FIELD_OP) || + (Op->Opcode == AML_BIT_FIELD_OP) || + (Op->Opcode == AML_BYTE_FIELD_OP) || + (Op->Opcode == AML_WORD_FIELD_OP) || + (Op->Opcode == AML_DWORD_FIELD_OP)) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + DeferredOp = (ACPI_PARSE2_OBJECT *) Op; + + DeferredOp->Data = ParserState->Aml -1; + DeferredOp->Length = 0; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op); + + if ((WalkState->DescendingCallback != NULL)) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + Status = WalkState->DescendingCallback (Opcode, Op, WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + } + + Op->AmlOffset = AmlOffset; + + if (OpInfo) + { + DEBUG_PRINT (TRACE_PARSE, + ("ParseLoop: Op=%p Opcode=%4.4lX Aml %p Oft=%5.5lX\n", + Op, Op->Opcode, ParserState->Aml, Op->AmlOffset)); + } + } + + + /* Start ArgCount at zero because we don't know if there are any args yet */ + + ArgCount = 0; + + + if (ArgTypes) /* Are there any arguments that must be processed? */ + { + /* get arguments */ + + switch (Op->Opcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), Op); + break; + + case AML_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + AcpiPsGetNextNamepath (ParserState, Op, &ArgCount, 1); + ArgTypes = 0; + break; + + + default: + + /* Op is not a constant or string, append each argument */ + + while (GET_CURRENT_ARG_TYPE (ArgTypes) && !ArgCount) + { + AmlOffset = ParserState->Aml - ParserState->AmlStart; + Arg = AcpiPsGetNextArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), + &ArgCount); + if (Arg) + { + Arg->AmlOffset = AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + + INCREMENT_ARG_LIST (ArgTypes); + } + + + /* For a method, save the length and address of the body */ + + if (Op->Opcode == AML_METHOD_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + */ + + DeferredOp->Data = ParserState->Aml; + DeferredOp->Length = ParserState->PkgEnd - + ParserState->Aml; + + /* + * Skip body of method. For OpRegions, we must continue + * parsing because the opregion is not a standalone + * package (We don't know where the end is). + */ + ParserState->Aml = ParserState->PkgEnd; + ArgCount = 0; + } + } + + break; + } + } + + + /* + * Zero ArgCount means that all arguments for this op have been processed + */ + if (!ArgCount) + { + /* completed Op, prepare for next */ + + if (AcpiPsIsNamedOp (Op->Opcode)) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Opcode == AML_REGION_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an OpRegion declaration, we now + * know the length. + */ + + DeferredOp->Length = ParserState->Aml - + DeferredOp->Data; + } + } + } + + if ((Op->Opcode == AML_CREATE_FIELD_OP) || + (Op->Opcode == AML_BIT_FIELD_OP) || + (Op->Opcode == AML_BYTE_FIELD_OP) || + (Op->Opcode == AML_WORD_FIELD_OP) || + (Op->Opcode == AML_DWORD_FIELD_OP)) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + * -4 for the name (last) -- TBD: namestring: may be longer + * than 4? + */ + DeferredOp = (ACPI_PARSE2_OBJECT *) Op; + + DeferredOp->Length = ParserState->Aml - DeferredOp->Data; + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + } + + +CloseThisOp: + + /* + * Finished one argument of the containing scope + */ + ParserState->Scope->ParseScope.ArgCount--; + + /* Close this Op (may result in parse subtree deletion) */ + + if (AcpiPsCompleteThisOp (WalkState, Op)) + { + Op = NULL; + } + + + if (Status == AE_CTRL_TRANSFER) + { + /* + * We are about to transfer to a called method. + */ + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = ArgTypes; + return_ACPI_STATUS (Status); + } + + else if (Status == AE_CTRL_END) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + AcpiPsCompleteThisOp (WalkState, Op); + Op = NULL; + Status = AE_OK; + } + + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + if (Op == NULL) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + } + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = ArgTypes; + + /* + * TEMP: + */ + + return_ACPI_STATUS (Status); + } + + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op)); + } + + else + { + Op = NULL; + } + + } + + + /* ArgCount is non-zero */ + + else + { + /* complex argument, push Op and prepare for argument */ + + AcpiPsPushScope (ParserState, Op, ArgTypes, ArgCount); + Op = NULL; + } + + } /* while ParserState->Aml */ + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several AML blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsParseLoop: Package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseAml + * + * PARAMETERS: StartScope - The starting point of the parse. Becomes the + * root of the parsed op tree. + * Aml - Pointer to the raw AML code to parse + * AmlSize - Length of the AML to parse + * + * RETURN: Status + * + * DESCRIPTION: Parse raw AML and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_PARSE_OBJECT *StartScope, + UINT8 *Aml, + UINT32 AmlSize, + UINT32 ParseFlags, + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_STATUS Status; + ACPI_PARSE_STATE *ParserState; + ACPI_WALK_STATE *WalkState; + ACPI_WALK_LIST WalkList; + ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_WALK_LIST *PrevWalkList = AcpiGbl_CurrentWalkList; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_OPERAND_OBJECT *MthDesc = NULL; + ACPI_NAMESPACE_NODE *StartNode; + + + FUNCTION_TRACE ("PsParseAml"); + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: Entered with Scope=%p Aml=%p size=%lX\n", + StartScope, Aml, AmlSize)); + + + /* Create and initialize a new parser state */ + + ParserState = AcpiPsCreateState (Aml, AmlSize); + if (!ParserState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiPsInitScope (ParserState, StartScope); + + if (MethodNode) + { + MthDesc = AcpiNsGetAttachedObject (MethodNode); + } + + /* Create and initialize a new walk list */ + + WalkList.WalkState = NULL; + + WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, ParserState->StartOp, MthDesc, &WalkList); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + WalkState->MethodNode = MethodNode; + WalkState->ParserState = ParserState; + WalkState->ParseFlags = ParseFlags; + WalkState->DescendingCallback = DescendingCallback; + WalkState->AscendingCallback = AscendingCallback; + + /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + */ + AcpiGbl_CurrentWalkList = &WalkList; + + + if (MethodNode) + { + StartNode = MethodNode; + ParserState->StartNode = MethodNode; + WalkState->WalkType = WALK_METHOD; + + if (StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + + AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); + } + + else + { + /* Setup the current scope */ + + Node = ParserState->StartOp->Node; + if (Node) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (Node, Node->Type, + WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + } + } + + + Status = AE_OK; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsParseAml: State=%p\n", + WalkState)); + + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + Status = AcpiPsParseLoop (WalkState); + } + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: Completed one call to walk loop, State=%p\n", + WalkState)); + + if (Status == AE_CTRL_TRANSFER) + { + /* + * A method call was detected. + * Transfer control to the called control method + */ + + Status = AcpiDsCallControlMethod (&WalkList, WalkState, NULL); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + continue; + } + + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + + /* We are done with this walk, move on to the parent if any */ + + + WalkState = AcpiDsPopWalkState (&WalkList); + + /* Extract return value before we delete WalkState */ + + ReturnDesc = WalkState->ReturnDesc; + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: ReturnValue=%p, State=%p\n", + WalkState->ReturnDesc, WalkState)); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) + { + AcpiDsTerminateControlMethod (WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiPsCleanupScope (WalkState->ParserState); + AcpiCmFree (WalkState->ParserState); + AcpiDsDeleteWalkState (WalkState); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + if (WalkState && + ACPI_SUCCESS (Status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + AcpiDsRestartControlMethod (WalkState, ReturnDesc); + WalkState->WalkType |= WALK_METHOD_RESTART; + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (CallerReturnDesc) + { + *CallerReturnDesc = ReturnDesc; /* NULL if no return value */ + } + + else if (ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiCmRemoveReference (ReturnDesc); + } + } + + + /* Normal exit */ + + AcpiGbl_CurrentWalkList = PrevWalkList; + return_ACPI_STATUS (Status); + + +Cleanup: + + /* Cleanup */ + + AcpiDsDeleteWalkState (WalkState); + AcpiPsCleanupScope (ParserState); + AcpiCmFree (ParserState); + + AcpiGbl_CurrentWalkList = PrevWalkList; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psscope.c b/sys/contrib/dev/acpica/Subsystem/Parser/psscope.c new file mode 100644 index 0000000..47b61dc --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psscope.c @@ -0,0 +1,375 @@ +/****************************************************************************** + * + * Module Name: psscope - Parser scope stack management routines + * $Revision: 21 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psscope") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParentScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to an Op object + * + * DESCRIPTION: Get parent of current op being parsed + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *ParserState) +{ + return (ParserState->Scope->ParseScope.Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsHasCompletedScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Boolean, TRUE = scope completed. + * + * DESCRIPTION: Is parsing of current argument complete? Determined by + * 1) AML pointer is at or beyond the end of the scope + * 2) The scope argument count has reached zero. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState) +{ + return ((BOOLEAN) ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || + !ParserState->Scope->ParseScope.ArgCount))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitScope + * + * PARAMETERS: ParserState - Current parser state object + * Root - the Root Node of this new scope + * + * RETURN: Status + * + * DESCRIPTION: Allocate and init a new scope object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *RootOp) +{ + ACPI_GENERIC_STATE *Scope; + + + FUNCTION_TRACE_PTR ("PsInitScope", RootOp); + + + Scope = AcpiCmCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->ParseScope.Op = RootOp; + Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; + Scope->ParseScope.ArgEnd = ParserState->AmlEnd; + Scope->ParseScope.PkgEnd = ParserState->AmlEnd; + + ParserState->Scope = Scope; + ParserState->StartOp = RootOp; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPushScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Current op to be pushed + * RemainingArgs - List of args remaining + * ArgCount - Fixed or variable number of args + * + * RETURN: Status + * + * DESCRIPTION: Push current op to begin parsing its argument + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount) +{ + ACPI_GENERIC_STATE *Scope; + + + FUNCTION_TRACE_PTR ("PsPushScope", Op); + + + Scope = AcpiCmCreateGenericState (); + if (!Scope) + { + return (AE_NO_MEMORY); + } + + + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + + /* Push onto scope stack */ + + AcpiCmPushGenericState (&ParserState->Scope, Scope); + + + if (ArgCount == ACPI_VAR_ARGS) + { + /* multiple arguments */ + + Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + } + + else + { + /* single argument */ + + Scope->ParseScope.ArgEnd = ACPI_MAX_AML; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPopScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Where the popped op is returned + * ArgList - Where the popped "next argument" is + * returned + * ArgCount - Count of objects in ArgList + * + * RETURN: Status + * + * DESCRIPTION: Return to parsing a previous op + * + ******************************************************************************/ + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount) +{ + ACPI_GENERIC_STATE *Scope = ParserState->Scope; + + + FUNCTION_TRACE ("PsPopScope"); + + /* + * Only pop the scope if there is in fact a next scope + */ + if (Scope->Common.Next) + { + Scope = AcpiCmPopGenericState (&ParserState->Scope); + + + /* return to parsing previous op */ + + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; + ParserState->PkgEnd = Scope->ParseScope.PkgEnd; + + /* All done with this scope state structure */ + + AcpiCmDeleteGenericState (Scope); + } + + else + { + /* empty parse stack, prepare to fetch next opcode */ + + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; + } + + + DEBUG_PRINT (TRACE_PARSE, + ("PsPopScope: Popped Op %p Args %d\n", *Op, *ArgCount)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCleanupScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Status + * + * DESCRIPTION: Destroy available list, remaining stack levels, and return + * root scope + * + ******************************************************************************/ + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_GENERIC_STATE *Scope; + + FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState); + + + if (!ParserState) + { + return; + } + + + /* Delete anything on the scope stack */ + + while (ParserState->Scope) + { + Scope = AcpiCmPopGenericState (&ParserState->Scope); + AcpiCmDeleteGenericState (Scope); + } + + return_VOID; +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/pstree.c b/sys/contrib/dev/acpica/Subsystem/Parser/pstree.c new file mode 100644 index 0000000..adb5c62 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/pstree.c @@ -0,0 +1,518 @@ +/****************************************************************************** + * + * Module Name: pstree - Parser op tree manipulation/traversal/search + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 __PSTREE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("pstree") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArg + * + * PARAMETERS: Op - Get an argument for this op + * Argn - Nth argument to get + * + * RETURN: The argument (as an Op object). NULL if argument does not exist + * + * DESCRIPTION: Get the specified op's argument. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_OPCODE_INFO *OpInfo; + + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Invalid opcode or ASCII character */ + + return (NULL); + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(ACPI_GET_OP_ARGS (OpInfo))) + { + /* Has no linked argument objects */ + + return (NULL); + } + + /* Get the requested argument object */ + + Arg = Op->Value.Arg; + while (Arg && Argn) + { + Argn--; + Arg = Arg->Next; + } + + return (Arg); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAppendArg + * + * PARAMETERS: Op - Append an argument to this Op. + * Arg - Argument Op to append + * + * RETURN: None. + * + * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK) + * + ******************************************************************************/ + +void +AcpiPsAppendArg ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_PARSE_OBJECT *PrevArg; + ACPI_OPCODE_INFO *OpInfo; + + + if (!Op) + { + return; + } + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Invalid opcode */ + + return; + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(ACPI_GET_OP_ARGS (OpInfo))) + { + /* Has no linked argument objects */ + + return; + } + + + /* Append the argument to the linked argument list */ + + if (Op->Value.Arg) + { + /* Append to existing argument list */ + + PrevArg = Op->Value.Arg; + while (PrevArg->Next) + { + PrevArg = PrevArg->Next; + } + PrevArg->Next = Arg; + } + + else + { + /* No argument list, this will be the first argument */ + + Op->Value.Arg = Arg; + } + + + /* Set the parent in this arg and any args linked after it */ + + while (Arg) + { + Arg->Parent = Op; + Arg = Arg->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + switch (Op->Opcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_METHODCALL_OP: + + Child = AcpiPsGetArg (Op, 0); + break; + + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_IF_OP: + case AML_WHILE_OP: + case AML_DEF_FIELD_OP: + + Child = AcpiPsGetArg (Op, 1); + break; + + + case AML_POWER_RES_OP: + case AML_INDEX_FIELD_OP: + + Child = AcpiPsGetArg (Op, 2); + break; + + + case AML_PROCESSOR_OP: + case AML_BANK_FIELD_OP: + + Child = AcpiPsGetArg (Op, 3); + break; + + } + + return (Child); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetDepthNext + * + * PARAMETERS: Origin - Root of subtree to search + * Op - Last (previous) Op that was found + * + * RETURN: Next Op found in the search. + * + * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) + * Return NULL when reaching "origin" or when walking up from root + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Arg; + + + if (!Op) + { + return (NULL); + } + + /* look for an argument or child */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + return (Next); + } + + /* look for a sibling */ + + Next = Op->Next; + if (Next) + { + return (Next); + } + + /* look for a sibling of parent */ + + Parent = Op->Parent; + + while (Parent) + { + Arg = AcpiPsGetArg (Parent, 0); + while (Arg && (Arg != Origin) && (Arg != Op)) + { + Arg = Arg->Next; + } + + if (Arg == Origin) + { + /* reached parent of origin, end search */ + + return (NULL); + } + + if (Parent->Next) + { + /* found sibling of parent */ + return (Parent->Next); + } + + Op = Parent; + Parent = Parent->Parent; + } + + return (Next); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFetchPrefix + * + * PARAMETERS: Scope - Op to fetch prefix for + * Path - A namestring containing the prefix + * io - Direction flag + * + * RETURN: Op referenced by the prefix + * + * DESCRIPTION: Fetch and handle path prefix ('\\' or '^') + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsFetchPrefix ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR **Path, + UINT32 io) +{ + UINT32 prefix = io ? GET8 (*Path):**Path; + + + switch (prefix) + { + case '\\': + case '/': + + /* go to the root */ + + *Path += 1; + while (Scope->Parent) + { + Scope = Scope->Parent; + } + break; + + + case '^': + + /* go up one level */ + + *Path += 1; + Scope = Scope->Parent; + break; + } + + if (Scope && !Scope->Parent) + { + /* searching from the root, start with its children */ + + Scope = AcpiPsGetChild (Scope); + } + + return (Scope); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFetchName + * + * PARAMETERS: Path - A string containing the name segment + * io - Direction flag + * + * RETURN: The 4-INT8 ASCII ACPI Name as a UINT32 + * + * DESCRIPTION: Fetch ACPI name segment (dot-delimited) + * + ******************************************************************************/ + +UINT32 +AcpiPsFetchName ( + NATIVE_CHAR **Path, + UINT32 io) +{ + UINT32 Name = 0; + NATIVE_CHAR *nm; + UINT32 i; + NATIVE_CHAR ch; + + + if (io) + { + /* Get the name from the path pointer */ + + MOVE_UNALIGNED32_TO_32 (&Name, *Path); + *Path += 4; + } + + else + { + if (**Path == '.') + { + *Path += 1; + } + + nm = (NATIVE_CHAR *) &Name; + for (i = 0; i < 4; i++) + { + ch = **Path; + if (ch && ch != '.') + { + *nm = ch; + *Path += 1; + } + + else + { + *nm = '_'; + } + nm++; + } + } + + return (Name); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psutils.c b/sys/contrib/dev/acpica/Subsystem/Parser/psutils.c new file mode 100644 index 0000000..0467ff8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psutils.c @@ -0,0 +1,683 @@ +/****************************************************************************** + * + * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * $Revision: 30 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psutils") + + +#define PARSEOP_GENERIC 0x01 +#define PARSEOP_NAMED 0x02 +#define PARSEOP_DEFERRED 0x03 +#define PARSEOP_BYTELIST 0x04 +#define PARSEOP_IN_CACHE 0x80 + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitOp + * + * PARAMETERS: Op - A newly allocated Op object + * Opcode - Opcode to store in the Op + * + * RETURN: Status + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode + * + ******************************************************************************/ + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *AmlOp; + + + Op->DataType = ACPI_DESC_TYPE_PARSER; + Op->Opcode = Opcode; + + AmlOp = AcpiPsGetOpcodeInfo (Opcode); + + DEBUG_ONLY_MEMBERS (STRNCPY (Op->OpName, AmlOp->Name, + sizeof (Op->OpName))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAllocOp + * + * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * + * RETURN: Pointer to the new Op. + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode. A cache of opcodes is available for the pure + * GENERIC_OP, since this is by far the most commonly used. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsAllocOp ( + UINT16 Opcode) +{ + ACPI_PARSE_OBJECT *Op = NULL; + UINT32 Size; + UINT8 Flags; + + + /* Allocate the minimum required size object */ + + if (AcpiPsIsDeferredOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_DEFERRED; + } + + else if (AcpiPsIsNamedOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_NAMED; + } + + else if (AcpiPsIsBytelistOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_BYTELIST; + } + + else + { + Size = sizeof (ACPI_PARSE_OBJECT); + Flags = PARSEOP_GENERIC; + } + + + if (Size == sizeof (ACPI_PARSE_OBJECT)) + { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ParseCacheRequests++; + if (AcpiGbl_ParseCache) + { + /* Extract an op from the front of the cache list */ + + AcpiGbl_ParseCacheDepth--; + AcpiGbl_ParseCacheHits++; + + Op = AcpiGbl_ParseCache; + AcpiGbl_ParseCache = Op->Next; + + if (Op->DataType == 0xFF) + { + DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op)); + } + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT)); + + DEBUG_PRINT (TRACE_PARSE, + ("PsAllocOp: Op %p from Parse Cache\n", Op)); + } + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ExtParseCacheRequests++; + if (AcpiGbl_ExtParseCache) + { + /* Extract an op from the front of the cache list */ + + AcpiGbl_ExtParseCacheDepth--; + AcpiGbl_ExtParseCacheHits++; + + Op = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache; + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op->Next; + + if (Op->DataType == 0xFF) + { + DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op)); + } + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT)); + + DEBUG_PRINT (TRACE_PARSE, + ("PsAllocOp: Op %p from ExtParse Cache\n", Op)); + } + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + + /* Allocate a new Op if necessary */ + + if (!Op) + { + Op = AcpiCmCallocate (Size); + } + + /* Initialize the Op */ + if (Op) + { + AcpiPsInitOp (Op, Opcode); + Op->Flags = Flags; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFreeOp + * + * PARAMETERS: Op - Op to be freed + * + * RETURN: None. + * + * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list + * or actually free it. + * + ******************************************************************************/ + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op) +{ + + + if (Op->Opcode == AML_RETURN_VALUE_OP) + { + DEBUG_PRINT (ACPI_INFO, ("Free retval op: %p\n", Op)); + } + + if (Op->Flags == PARSEOP_GENERIC) + { + /* Is the cache full? */ + + if (AcpiGbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH) + { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT)); + Op->Flags = PARSEOP_IN_CACHE; + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ParseCacheDepth++; + + Op->Next = AcpiGbl_ParseCache; + AcpiGbl_ParseCache = Op; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return; + } + } + + else + { + /* Is the cache full? */ + + if (AcpiGbl_ExtParseCacheDepth < MAX_EXTPARSE_CACHE_DEPTH) + { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT)); + Op->Flags = PARSEOP_IN_CACHE; + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ExtParseCacheDepth++; + + Op->Next = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache; + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return; + } + } + + + /* + * Not a GENERIC OP, or the cache is full, just free the Op + */ + + AcpiCmFree (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseCache + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all objects that are on the parse cache list. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseCache ( + void) +{ + ACPI_PARSE_OBJECT *Next; + + + FUNCTION_TRACE ("PsDeleteParseCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_ParseCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ParseCache->Next; + AcpiCmFree (AcpiGbl_ParseCache); + AcpiGbl_ParseCache = Next; + AcpiGbl_ParseCacheDepth--; + } + + /* Traverse the global cache list */ + + while (AcpiGbl_ExtParseCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ExtParseCache->Next; + AcpiCmFree (AcpiGbl_ExtParseCache); + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Next; + AcpiGbl_ExtParseCacheDepth--; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: Utility functions + * + * DESCRIPTION: Low level functions + * + * TBD: [Restructure] + * 1) Some of these functions should be macros + * 2) Some can be simplified + * + ******************************************************************************/ + + +/* + * Is "c" a namestring lead character? + */ + + +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z'))); +} + + +/* + * Is "c" a namestring prefix character? + */ +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '\\' || c == '^')); +} + + +BOOLEAN +AcpiPsIsNamespaceObjectOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_DEF_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_NAMEDFIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_METHODCALL_OP || + Opcode == AML_NAMEPATH_OP)); +} + +BOOLEAN +AcpiPsIsNamespaceOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_DEF_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_NAMEDFIELD_OP)); +} + + +/* + * Is opcode for a named object Op? + * (Includes all named object opcodes) + * + * TBD: [Restructure] Need a better way than this brute force approach! + */ +BOOLEAN +AcpiPsIsNodeOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_NAMEDFIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + + + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_METHODCALL_OP || + Opcode == AML_NAMEPATH_OP)); +} + + +/* + * Is opcode for a named Op? + */ +BOOLEAN +AcpiPsIsNamedOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_NAMEDFIELD_OP)); +} + + +BOOLEAN +AcpiPsIsDeferredOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_METHOD_OP || + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_REGION_OP)); +} + + +/* + * Is opcode for a bytelist? + */ +BOOLEAN +AcpiPsIsBytelistOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) (Opcode == AML_BYTELIST_OP)); +} + + +/* + * Is opcode for a Field, IndexField, or BankField + */ +BOOLEAN +AcpiPsIsFieldOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_CREATE_FIELD_OP + || Opcode == AML_DEF_FIELD_OP + || Opcode == AML_INDEX_FIELD_OP + || Opcode == AML_BANK_FIELD_OP)); +} + + +/* + * Is field creation op + */ +BOOLEAN +AcpiPsIsCreateFieldOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP)); +} + + +/* + * Cast an acpi_op to an acpi_extended_op if possible + */ + +/* TBD: This is very inefficient, fix */ +ACPI_PARSE2_OBJECT * +AcpiPsToExtendedOp ( + ACPI_PARSE_OBJECT *Op) +{ + return ((AcpiPsIsDeferredOp (Op->Opcode) || AcpiPsIsNamedOp (Op->Opcode) || AcpiPsIsBytelistOp (Op->Opcode)) + ? ( (ACPI_PARSE2_OBJECT *) Op) : NULL); +} + + +/* + * Get op's name (4-byte name segment) or 0 if unnamed + */ +UINT32 +AcpiPsGetName ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op); + + return (Named ? Named->Name : 0); +} + + +/* + * Set op's name + */ +void +AcpiPsSetName ( + ACPI_PARSE_OBJECT *Op, + UINT32 name) +{ + ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op); + + if (Named) + { + Named->Name = name; + } +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c b/sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c new file mode 100644 index 0000000..176a54d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c @@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * $Revision: 47 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT PARSER + MODULE_NAME ("pswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextWalkOp + * + * PARAMETERS: WalkState - Current state of the walk + * Op - Current Op to be walked + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Get the next Op in a walk of the parse tree. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *GrandParent; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op); + + + /* Check for a argument only if we are descending in the tree */ + + if (WalkState->NextOpInfo != NEXT_OP_UPWARD) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * No more children, this Op is complete. Save Next and Parent + * in case the Op object gets deleted by the callback routine + */ + + Next = Op->Next; + Parent = Op->Parent; + + Status = AscendingCallback (WalkState, Op); + + switch (Status) + { + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + WalkState->PrevOp = WalkState->Origin; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); + break; + + + case AE_CTRL_FALSE: + + /* + * Either an IF/WHILE Predicate was false or we encountered a BREAK + * opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ + + Next = Parent->Next; + Status = AE_OK; + + /* + * If there is a sibling to the parent, we must close out the + * parent now, because we are going to continue to go downward (to + * the sibling) in the parse tree. + */ + if (Next) + { + Status = AscendingCallback (WalkState, Parent); + + /* The parent sibling will be next */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Continue downward */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Drop into the loop below because we are moving upwards in + * the tree + */ + + break; + + + default: + /* + * If we are back to the starting point, the walk is complete. + */ + if (Op == WalkState->Origin) + { + /* Reached the point of origin, the walk is complete */ + + WalkState->PrevOp = Op; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (Status); + } + + /* + * Check for a sibling to the current op. A sibling means + * we are still going "downward" in the tree. + */ + + if (Next) + { + /* There is a sibling, it will be next */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Continue downward */ + + return_ACPI_STATUS (Status); + } + + /* + * No sibling, but check status. + * Abort on error from callback routine + */ + if (ACPI_FAILURE (Status)) + { + /* Next op will be the parent */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Parent; + WalkState->NextOpInfo = NEXT_OP_UPWARD; + + return_ACPI_STATUS (Status); + } + + /* + * Drop into the loop below because we are moving upwards in + * the tree + */ + + break; + } + } + + else + { + /* + * We are resuming a walk, and we were (are) going upward in the tree. + * So, we want to drop into the parent loop below. + */ + + Parent = Op; + } + + + /* + * Look for a sibling of the current Op's parent + * Continue moving up the tree until we find a node that has not been + * visited, or we get back to where we started. + */ + while (Parent) + { + /* We are moving up the tree, therefore this parent Op is complete */ + + GrandParent = Parent->Parent; + Next = Parent->Next; + + Status = AscendingCallback (WalkState, Parent); + + + switch (Status) + { + case AE_CTRL_FALSE: + + /* + * Either an IF/WHILE Predicate was false or we encountered a + * BREAK opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ + + Parent = GrandParent; + Next = GrandParent->Next; + GrandParent = GrandParent->Parent; + + Status = AscendingCallback (WalkState, Parent); + + /* Now continue to the next node in the tree */ + + break; + + + case AE_CTRL_TRUE: + + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ + + Op = WalkState->ControlState->Control.PredicateOp; + + WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING; + + /* + * AcpiEvaluate the predicate again (next) + * Because we will traverse WHILE tree again + */ + + WalkState->PrevOp = Op->Parent; + WalkState->NextOp = Op; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (AE_OK); + break; + + + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + WalkState->PrevOp = WalkState->Origin; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); + break; + } + + + /* + * If we are back to the starting point, the walk is complete. + */ + if (Parent == WalkState->Origin) + { + /* Reached the point of origin, the walk is complete */ + + WalkState->PrevOp = Parent; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (Status); + } + + + /* + * If there is a sibling to this parent (it is not the starting point + * Op), then we will visit it. + */ + if (Next) + { + /* found sibling of parent */ + + WalkState->PrevOp = Parent; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (Status); + } + + /* + * No sibling, check for an error from closing the parent + * (Also, AE_PENDING if a method call was encountered) + */ + if (ACPI_FAILURE (Status)) + { + WalkState->PrevOp = Parent; + WalkState->NextOp = GrandParent; + WalkState->NextOpInfo = NEXT_OP_UPWARD; + + return_ACPI_STATUS (Status); + } + + /* No siblings, no errors, just move up one more level in the tree */ + + Op = Parent; + Parent = GrandParent; + WalkState->PrevOp = Op; + } + + + /* Got all the way to the top of the tree, we must be done! */ + /* However, the code should have terminated in the loop above */ + + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsWalkLoop + * + * PARAMETERS: WalkList - State of the walk + * StartOp - Starting Op of the subtree to be walked + * DescendingCallback - Procedure called when a new Op is + * encountered + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Perform a walk of the parsed AML tree. Begins and terminates at + * the StartOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsWalkLoop ( + ACPI_WALK_LIST *WalkList, + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_STATUS Status = AE_OK; + ACPI_WALK_STATE *WalkState; + ACPI_PARSE_OBJECT *Op = StartOp; + + + FUNCTION_TRACE_PTR ("PsWalkLoop", StartOp); + + + WalkState = AcpiDsGetCurrentWalkState (WalkList); + + + /* Walk entire subtree, visiting all nodes depth-first */ + + while (Op) + { + if (WalkState->NextOpInfo != NEXT_OP_UPWARD) + { + Status = DescendingCallback (Op->Opcode, Op, WalkState, NULL); + } + + /* + * A TRUE exception means that an ELSE was detected, but the IF + * predicate evaluated TRUE. + */ + if (Status == AE_CTRL_TRUE) + { + /* + * Ignore the entire ELSE block by moving on to the the next opcode. + * And we do that by simply going up in the tree (either to the next + * sibling or to the parent) from here. + */ + + WalkState->NextOpInfo = NEXT_OP_UPWARD; + } + + /* Get the next node (op) in the depth-first walk */ + + Status = AcpiPsGetNextWalkOp (WalkState, Op, AscendingCallback); + + /* + * A PENDING exception means that a control method invocation has been + * detected + */ + + if (Status == AE_CTRL_PENDING) + { + /* Transfer control to the called control method */ + + Status = AcpiDsCallControlMethod (WalkList, WalkState, Op); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + WalkState = AcpiDsGetCurrentWalkState (WalkList); + } + + /* Abort the walk on any exception */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Op = WalkState->NextOp; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsWalkParsedAml + * + * PARAMETERS: StartOp - Starting Op of the subtree to be walked + * EndOp - Where to terminate the walk + * DescendingCallback - Procedure called when a new Op is + * encountered + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Top level interface to walk the parsed AML tree. Handles + * preemption of executing control methods. + * + * NOTE: The EndOp is usually only different from the StartOp if + * we don't want to visit the StartOp during the tree descent. + * + ******************************************************************************/ + +ACPI_STATUS +mmmmAcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_STATUS Status; + ACPI_WALK_LIST WalkList; + ACPI_WALK_LIST *PrevWalkList; + + + FUNCTION_TRACE_PTR ("PsWalkParsedAml", StartOp); + + + /* Parameter Validation */ + + if (!StartOp || !EndOp) + { + return (AE_BAD_PARAMETER); + } + + /* Initialize a new walk list */ + + WalkList.WalkState = NULL; + + WalkState = AcpiDsCreateWalkState (OwnerId, EndOp, MthDesc, &WalkList); + if (!WalkState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + */ + PrevWalkList = AcpiGbl_CurrentWalkList; + AcpiGbl_CurrentWalkList = &WalkList; + + if (StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + + if (MthDesc) + { + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + + AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); + } + + Op = StartOp; + Status = AE_OK; + + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsWalkParsedAml: Op=%p EndOp=%p State=%p\n", + Op, EndOp, WalkState)); + + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + Status = AcpiPsWalkLoop (&WalkList, Op, DescendingCallback, + AscendingCallback); + } + + DEBUG_PRINT (TRACE_PARSE, + ("PsWalkParsedAml: Completed one call to walk loop, State=%p\n", + WalkState)); + + /* We are done with this walk, move on to the parent if any */ + + BREAKPOINT3; + + WalkState = AcpiDsPopWalkState (&WalkList); + + /* Extract return value before we delete WalkState */ + + ReturnDesc = WalkState->ReturnDesc; + + DEBUG_PRINT (TRACE_PARSE, + ("PsWalkParsedAml: ReturnValue=%p, State=%p\n", + WalkState->ReturnDesc, WalkState)); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if (WalkState->MethodDesc) + { + AcpiDsTerminateControlMethod (WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiDsDeleteWalkState (WalkState); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + if (WalkState && + ACPI_SUCCESS (Status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + AcpiDsRestartControlMethod (WalkState, ReturnDesc); + + /* Get the next Op to process */ + + Op = WalkState->NextOp; + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (CallerReturnDesc) + { + *CallerReturnDesc = ReturnDesc; /* NULL if no return value */ + } + + else if (ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiCmRemoveReference (ReturnDesc); + } + } + + + AcpiGbl_CurrentWalkList = PrevWalkList; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psxface.c b/sys/contrib/dev/acpica/Subsystem/Parser/psxface.c new file mode 100644 index 0000000..2f65a41 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psxface.c @@ -0,0 +1,270 @@ +/****************************************************************************** + * + * Module Name: psxface - Parser external interfaces + * $Revision: 37 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 __PSXFACE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT PARSER + MODULE_NAME ("psxface") + + +/***************************************************************************** + * + * FUNCTION: AcpiPsxExecute + * + * PARAMETERS: MethodNode - A method object containing both the AML + * address and length. + * **Params - List of parameters to pass to method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * **ReturnObjDesc - Return object from execution of the + * method. + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ****************************************************************************/ + +ACPI_STATUS +AcpiPsxExecute ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; + ACPI_PARSE_OBJECT *Op; + + + FUNCTION_TRACE ("PsxExecute"); + + + /* Validate the Node and get the attached object */ + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Params) + { + /* + * The caller "owns" the parameters, so give each one an extra + * reference + */ + + for (i = 0; Params[i]; i++) + { + AcpiCmAddReference (Params[i]); + } + } + + /* + * Perform the first pass parse of the method to enter any + * named objects that it creates into the namespace + */ + + DEBUG_PRINT (ACPI_INFO, + ("PsxExecute: **** Begin Method Execution **** Entry=%p obj=%p\n", + MethodNode, ObjDesc)); + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + MethodNode, Params, ReturnObjDesc, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + AcpiPsDeleteParseTree (Op); + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * The walk of the parse tree is where we actually execute the method + */ + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + MethodNode, Params, ReturnObjDesc, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + AcpiPsDeleteParseTree (Op); + + if (Params) + { + /* Take away the extra reference that we gave the parameters above */ + + for (i = 0; Params[i]; i++) + { + AcpiCmUpdateObjectReference (Params[i], REF_DECREMENT); + } + } + + + /* + * Normal exit is with Status == AE_RETURN_VALUE when a ReturnOp has been + * executed, or with Status == AE_PENDING at end of AML block (end of + * Method code) + */ + + if (*ReturnObjDesc) + { + DEBUG_PRINT (ACPI_INFO, ("Method returned ObjDesc=%X\n", + *ReturnObjDesc)); + DUMP_STACK_ENTRY (*ReturnObjDesc); + + Status = AE_CTRL_RETURN_VALUE; + } + + + return_ACPI_STATUS (Status); +} + + |