summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2003-08-07 16:38:31 +0000
committernjl <njl@FreeBSD.org>2003-08-07 16:38:31 +0000
commit8e8fea90a8152fdd7d406e50c07a1a03c0a6f260 (patch)
tree94d147aac2834f790fce19e3eea4af198e5c515d /sys
parent05f7e6fdf1697c5053de4ad692dfec98ef98d567 (diff)
parent80af1416fc76b2bf98a3053c521dd9dfbe00fef2 (diff)
downloadFreeBSD-src-8e8fea90a8152fdd7d406e50c07a1a03c0a6f260.zip
FreeBSD-src-8e8fea90a8152fdd7d406e50c07a1a03c0a6f260.tar.gz
This commit was generated by cvs2svn to compensate for changes in r118611,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'sys')
-rw-r--r--sys/contrib/dev/acpica/compiler/aslanalyze.c1697
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcodegen.c608
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompile.c615
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.h1120
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.l1153
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.y2902
-rw-r--r--sys/contrib/dev/acpica/compiler/aslerror.c621
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfiles.c839
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfold.c532
-rw-r--r--sys/contrib/dev/acpica/compiler/aslglobal.h267
-rw-r--r--sys/contrib/dev/acpica/compiler/asllength.c504
-rw-r--r--sys/contrib/dev/acpica/compiler/asllisting.c1319
-rw-r--r--sys/contrib/dev/acpica/compiler/aslload.c691
-rw-r--r--sys/contrib/dev/acpica/compiler/asllookup.c974
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmain.c794
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmap.c687
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopcodes.c620
-rw-r--r--sys/contrib/dev/acpica/compiler/asloperands.c1112
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopt.c800
-rw-r--r--sys/contrib/dev/acpica/compiler/aslresource.c632
-rw-r--r--sys/contrib/dev/acpica/compiler/aslrestype1.c1041
-rw-r--r--sys/contrib/dev/acpica/compiler/aslrestype2.c1536
-rw-r--r--sys/contrib/dev/acpica/compiler/aslstubs.c266
-rw-r--r--sys/contrib/dev/acpica/compiler/asltransform.c623
-rw-r--r--sys/contrib/dev/acpica/compiler/asltree.c1182
-rw-r--r--sys/contrib/dev/acpica/compiler/asltypes.h496
-rw-r--r--sys/contrib/dev/acpica/compiler/aslutils.c1015
27 files changed, 24646 insertions, 0 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c
new file mode 100644
index 0000000..a843f17
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c
@@ -0,0 +1,1697 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslanalyze.c - check for semantic errors
+ * $Revision: 77 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "acparser.h"
+#include "amlcode.h"
+
+#include <ctype.h>
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslanalyze")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMapArgTypeToBtype
+ *
+ * PARAMETERS: ArgType - The ARGI required type(s) for this argument,
+ * from the opcode info table
+ *
+ * RETURN: The corresponding Bit-encoded types
+ *
+ * DESCRIPTION: Convert an encoded ARGI required argument type code into a
+ * bitfield type code. Implements the implicit source conversion
+ * rules.
+ *
+ ******************************************************************************/
+
+UINT32
+AnMapArgTypeToBtype (
+ UINT32 ArgType)
+{
+
+ switch (ArgType)
+ {
+
+ /* Simple types */
+
+ case ARGI_ANYTYPE:
+ return (ACPI_BTYPE_OBJECTS_AND_REFS);
+
+ case ARGI_PACKAGE:
+ return (ACPI_BTYPE_PACKAGE);
+
+ case ARGI_EVENT:
+ return (ACPI_BTYPE_EVENT);
+
+ case ARGI_MUTEX:
+ return (ACPI_BTYPE_MUTEX);
+
+ case ARGI_DDBHANDLE:
+ return (ACPI_BTYPE_DDB_HANDLE);
+
+ /* Interchangeable types */
+ /*
+ * Source conversion rules:
+ * Integer, String, and Buffer are all interchangeable
+ */
+ case ARGI_INTEGER:
+ case ARGI_STRING:
+ case ARGI_BUFFER:
+ case ARGI_BUFFER_OR_STRING:
+ case ARGI_COMPUTEDATA:
+ return (ACPI_BTYPE_COMPUTE_DATA);
+
+ /* References */
+
+ case ARGI_INTEGER_REF:
+ return (ACPI_BTYPE_INTEGER);
+
+ case ARGI_OBJECT_REF:
+ return (ACPI_BTYPE_ALL_OBJECTS);
+
+ case ARGI_DEVICE_REF:
+ return (ACPI_BTYPE_DEVICE_OBJECTS);
+
+ case ARGI_REFERENCE:
+ return (ACPI_BTYPE_REFERENCE);
+
+ case ARGI_TARGETREF:
+ case ARGI_FIXED_TARGET:
+ case ARGI_SIMPLE_TARGET:
+ return (ACPI_BTYPE_OBJECTS_AND_REFS);
+
+ /* Complex types */
+
+ case ARGI_DATAOBJECT:
+
+ /* Buffer, string, package or reference to a Op - Used only by SizeOf operator*/
+
+ return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE);
+
+ case ARGI_COMPLEXOBJ:
+
+ /* Buffer, String, or package */
+
+ return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE);
+
+ case ARGI_REF_OR_STRING:
+ return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE);
+
+ case ARGI_REGION_OR_FIELD:
+ return (ACPI_BTYPE_REGION | ACPI_BTYPE_FIELD_UNIT);
+
+ default:
+ break;
+ }
+
+ return (ACPI_BTYPE_OBJECTS_AND_REFS);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMapEtypeToBtype
+ *
+ * PARAMETERS: Etype - Encoded ACPI Type
+ *
+ * RETURN: Btype corresponding to the Etype
+ *
+ * DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the
+ * operand conversion rules. In other words, returns the type(s)
+ * this Etype is implicitly converted to during interpretation.
+ *
+ ******************************************************************************/
+
+UINT32
+AnMapEtypeToBtype (
+ UINT32 Etype)
+{
+
+
+ if (Etype == ACPI_TYPE_ANY)
+ {
+ return ACPI_BTYPE_OBJECTS_AND_REFS;
+ }
+
+ /* Try the standard ACPI data types */
+
+ if (Etype <= ACPI_TYPE_EXTERNAL_MAX)
+ {
+ /*
+ * This switch statement implements the allowed operand conversion
+ * rules as per the "ASL Data Types" section of the ACPI
+ * specification.
+ */
+ switch (Etype)
+ {
+ case ACPI_TYPE_INTEGER:
+ return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE);
+
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ return (ACPI_BTYPE_COMPUTE_DATA);
+
+ case ACPI_TYPE_PACKAGE:
+ return (ACPI_BTYPE_PACKAGE);
+
+ case ACPI_TYPE_FIELD_UNIT:
+ return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD);
+
+ case ACPI_TYPE_DDB_HANDLE:
+ return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE);
+
+ case ACPI_BTYPE_DEBUG_OBJECT:
+
+ /* Cannot be used as a source operand */
+
+ return (0);
+
+ default:
+ return (1 << (Etype - 1));
+ }
+ }
+
+ /* Try the internal data types */
+
+ switch (Etype)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ /* Named fields can be either Integer/Buffer/String */
+
+ return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
+
+ case ACPI_TYPE_LOCAL_ALIAS:
+
+ return (ACPI_BTYPE_INTEGER);
+
+
+ case ACPI_TYPE_LOCAL_RESOURCE:
+ case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
+
+ return (ACPI_BTYPE_REFERENCE);
+
+ default:
+ printf ("Unhandled encoded type: %X\n", Etype);
+ return (0);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMapBtypeToEtype
+ *
+ * PARAMETERS: Btype - Bitfield of ACPI types
+ *
+ * RETURN: The Etype corresponding the the Btype
+ *
+ * DESCRIPTION: Convert a bitfield type to an encoded type
+ *
+ ******************************************************************************/
+
+UINT32
+AnMapBtypeToEtype (
+ UINT32 Btype)
+{
+ UINT32 i;
+ UINT32 Etype;
+
+
+ if (Btype == 0)
+ {
+ return 0;
+ }
+
+ Etype = 1;
+ for (i = 1; i < Btype; i *= 2)
+ {
+ Etype++;
+ }
+
+ return (Etype);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnFormatBtype
+ *
+ * PARAMETERS: Btype - Bitfield of ACPI types
+ * Buffer - Where to put the ascii string
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Convert a Btype to a string of ACPI types
+ *
+ ******************************************************************************/
+
+void
+AnFormatBtype (
+ char *Buffer,
+ UINT32 Btype)
+{
+ UINT32 Type;
+ BOOLEAN First = TRUE;
+
+
+ *Buffer = 0;
+
+ if (Btype == 0)
+ {
+ strcat (Buffer, "NoReturnValue");
+ return;
+ }
+
+ for (Type = 1; Type < ACPI_TYPE_EXTERNAL_MAX; Type++)
+ {
+ if (Btype & 0x00000001)
+ {
+ if (!First)
+ {
+ strcat (Buffer, "|");
+ }
+ First = FALSE;
+ strcat (Buffer, AcpiUtGetTypeName (Type));
+ }
+ Btype >>= 1;
+ }
+
+ if (Btype & 0x00000001)
+ {
+ if (!First)
+ {
+ strcat (Buffer, "|");
+ }
+ First = FALSE;
+ strcat (Buffer, "Reference");
+ }
+
+ Btype >>= 1;
+ if (Btype & 0x00000001)
+ {
+ if (!First)
+ {
+ strcat (Buffer, "|");
+ }
+ First = FALSE;
+ strcat (Buffer, "Resource");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnGetBtype
+ *
+ * PARAMETERS: Op - Parse node whose type will be returned.
+ *
+ * RETURN: The Btype associated with the Op.
+ *
+ * DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node.
+ * Handles the case where the node is a name or method call and
+ * the actual type must be obtained from the namespace node.
+ *
+ ******************************************************************************/
+
+UINT32
+AnGetBtype (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_PARSE_OBJECT *ReferencedNode;
+ UINT32 ThisNodeBtype = 0;
+
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
+ (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+ {
+ Node = Op->Asl.Node;
+ if (!Node)
+ {
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "Null attached Nsnode: [%s] at line %d\n",
+ Op->Asl.ParseOpName, Op->Asl.LineNumber);
+ return ACPI_UINT32_MAX;
+ }
+
+ ThisNodeBtype = AnMapEtypeToBtype (Node->Type);
+
+ /*
+ * Since it was a named reference, enable the
+ * reference bit also
+ */
+ ThisNodeBtype |= ACPI_BTYPE_REFERENCE;
+
+ if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
+ {
+ ReferencedNode = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+ if (!ReferencedNode)
+ {
+ printf ("No back ptr to Op: type %X\n", Node->Type);
+ return ACPI_UINT32_MAX;
+ }
+
+ if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED)
+ {
+ ThisNodeBtype = ReferencedNode->Asl.AcpiBtype;
+ }
+ else
+ {
+ return (ACPI_UINT32_MAX -1);
+ }
+ }
+ }
+ else
+ {
+ ThisNodeBtype = Op->Asl.AcpiBtype;
+ }
+
+ return (ThisNodeBtype);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnCheckForReservedName
+ *
+ * PARAMETERS: Op - A parse node
+ * Name - NameSeg to check
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Check a NameSeg against the reserved list.
+ *
+ ******************************************************************************/
+
+#define ACPI_VALID_RESERVED_NAME_MAX 0x80000000
+#define ACPI_NOT_RESERVED_NAME ACPI_UINT32_MAX
+#define ACPI_PREDEFINED_NAME (ACPI_UINT32_MAX - 1)
+#define ACPI_EVENT_RESERVED_NAME (ACPI_UINT32_MAX - 2)
+#define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3)
+
+UINT32
+AnCheckForReservedName (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name)
+{
+ UINT32 i;
+
+
+ if (Name[0] == 0)
+ {
+ AcpiOsPrintf ("Found a null name, external = %s\n", Op->Asl.ExternalName);
+ }
+
+ /* All reserved names are prefixed with a single underscore */
+
+ if (Name[0] != '_')
+ {
+ return (ACPI_NOT_RESERVED_NAME);
+ }
+
+ /* Check for a standard reserved method name */
+
+ for (i = 0; ReservedMethods[i].Name; i++)
+ {
+ if (!ACPI_STRNCMP (Name, ReservedMethods[i].Name, ACPI_NAME_SIZE))
+ {
+ if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE)
+ {
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName);
+ return (ACPI_PREDEFINED_NAME);
+ }
+ else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME)
+ {
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName);
+ return (ACPI_PREDEFINED_NAME);
+ }
+
+ /* Return index into reserved array */
+
+ return i;
+ }
+ }
+
+ /*
+ * Now check for the "special" reserved names --
+ * GPE: _Lxx
+ * GPE: _Exx
+ * EC: _Qxx
+ */
+ if ((Name[1] == 'L') ||
+ (Name[1] == 'E') ||
+ (Name[1] == 'Q'))
+ {
+ /* The next two characters must be hex digits */
+
+ if ((isxdigit (Name[2])) &&
+ (isxdigit (Name[3])))
+ {
+ return (ACPI_EVENT_RESERVED_NAME);
+ }
+ }
+
+
+ /* Check for the names reserved for the compiler itself: _T_x */
+
+ else if ((Op->Asl.ExternalName[1] == 'T') &&
+ (Op->Asl.ExternalName[2] == '_'))
+ {
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName);
+ return (ACPI_COMPILER_RESERVED_NAME);
+ }
+
+ /*
+ * The name didn't match any of the known reserved names. Flag it as a
+ * warning, since the entire namespace starting with an underscore is
+ * reserved by the ACPI spec.
+ */
+ AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, Op->Asl.ExternalName);
+
+ return (ACPI_NOT_RESERVED_NAME);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnCheckForReservedMethod
+ *
+ * PARAMETERS: Op - A parse node of type "METHOD".
+ * MethodInfo - Saved info about this method
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: If method is a reserved name, check that the number of arguments
+ * and the return type (returns a value or not) is correct.
+ *
+ ******************************************************************************/
+
+void
+AnCheckForReservedMethod (
+ ACPI_PARSE_OBJECT *Op,
+ ASL_METHOD_INFO *MethodInfo)
+{
+ UINT32 Index;
+
+
+ /* Check for a match against the reserved name list */
+
+ Index = AnCheckForReservedName (Op, Op->Asl.NameSeg);
+
+ switch (Index)
+ {
+ case ACPI_NOT_RESERVED_NAME:
+ case ACPI_PREDEFINED_NAME:
+ case ACPI_COMPILER_RESERVED_NAME:
+
+ /* Just return, nothing to do */
+ break;
+
+
+ case ACPI_EVENT_RESERVED_NAME:
+
+ Gbl_ReservedMethods++;
+
+ /* NumArguments must be zero for all _Lxx, _Exx, and _Qxx methods */
+
+ if (MethodInfo->NumArguments != 0)
+ {
+ sprintf (MsgBuffer, " %s requires %d",
+ Op->Asl.ExternalName, 0);
+
+ AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer);
+ }
+ break;
+
+
+ default:
+
+ Gbl_ReservedMethods++;
+
+ /* Matched a reserved method name */
+
+ if (MethodInfo->NumArguments != ReservedMethods[Index].NumArguments)
+ {
+ sprintf (MsgBuffer, " %s requires %d",
+ ReservedMethods[Index].Name,
+ ReservedMethods[Index].NumArguments);
+
+ if (MethodInfo->NumArguments > ReservedMethods[Index].NumArguments)
+ {
+ AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer);
+ }
+ else
+ {
+ AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, MsgBuffer);
+ }
+ }
+
+ if (MethodInfo->NumReturnNoValue &&
+ ReservedMethods[Index].Flags & ASL_RSVD_RETURN_VALUE)
+ {
+ sprintf (MsgBuffer, "%s", ReservedMethods[Index].Name);
+
+ AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, MsgBuffer);
+ }
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMethodAnalysisWalkBegin
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback for the analysis walk. Check methods for :
+ * 1) Initialized local variables
+ * 2) Valid arguments
+ * 3) Return types
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnMethodAnalysisWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
+ ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
+ ACPI_PARSE_OBJECT *Next;
+ UINT32 RegisterNumber;
+ UINT32 i;
+ char LocalName[] = "Local0";
+ char ArgName[] = "Arg0";
+
+
+ ACPI_FUNCTION_NAME ("AnMethodAnalysisWalkBegin");
+
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_METHOD:
+
+ TotalMethods++;
+
+ /*
+ * Create and init method info
+ */
+ MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
+ MethodInfo->Next = WalkInfo->MethodStack;
+ MethodInfo->Op = Op;
+
+ WalkInfo->MethodStack = MethodInfo;
+
+ /* Get the NumArguments node */
+
+ Next = Op->Asl.Child;
+ Next = Next->Asl.Next;
+ MethodInfo->NumArguments = (UINT8) (((UINT8) Next->Asl.Value.Integer) & 0x07);
+
+ /*
+ * Actual arguments are initialized at method entry.
+ * All other ArgX "registers" can be used as locals, so we
+ * track their initialization.
+ */
+ for (i = 0; i < MethodInfo->NumArguments; i++)
+ {
+ MethodInfo->ArgInitialized[i] = TRUE;
+ }
+
+ break;
+
+
+ case PARSEOP_METHODCALL:
+
+ if (MethodInfo &&
+ (Op->Asl.Node == MethodInfo->Op->Asl.Node))
+ {
+ AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName);
+ }
+ break;
+
+
+ case PARSEOP_LOCAL0:
+ case PARSEOP_LOCAL1:
+ case PARSEOP_LOCAL2:
+ case PARSEOP_LOCAL3:
+ case PARSEOP_LOCAL4:
+ case PARSEOP_LOCAL5:
+ case PARSEOP_LOCAL6:
+ case PARSEOP_LOCAL7:
+
+ if (!MethodInfo)
+ {
+ /* Probably was an error in the method declaration, no additional error here */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op));
+ return (AE_ERROR);
+ }
+
+ RegisterNumber = (Op->Asl.AmlOpcode & 0x000F);
+
+ /*
+ * If the local is being used as a target, mark the local
+ * initialized
+ */
+ if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ {
+ MethodInfo->LocalInitialized[RegisterNumber] = TRUE;
+ }
+
+ /*
+ * Otherwise, this is a reference, check if the local
+ * has been previously initialized.
+ */
+ else if (!MethodInfo->LocalInitialized[RegisterNumber])
+ {
+ LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30);
+ AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName);
+ }
+ break;
+
+
+ case PARSEOP_ARG0:
+ case PARSEOP_ARG1:
+ case PARSEOP_ARG2:
+ case PARSEOP_ARG3:
+ case PARSEOP_ARG4:
+ case PARSEOP_ARG5:
+ case PARSEOP_ARG6:
+
+ if (!MethodInfo)
+ {
+ /* Probably was an error in the method declaration, no additional error here */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op));
+ return (AE_ERROR);
+ }
+
+ RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8;
+ ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30);
+
+ /*
+ * If the Arg is being used as a target, mark the local
+ * initialized
+ */
+ if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ {
+ MethodInfo->ArgInitialized[RegisterNumber] = TRUE;
+ }
+
+ /*
+ * Otherwise, this is a reference, check if the Arg
+ * has been previously initialized.
+ */
+ else if (!MethodInfo->ArgInitialized[RegisterNumber])
+ {
+ AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName);
+ }
+
+ /* Flag this arg if it is not a "real" argument to the method */
+
+ if (RegisterNumber >= MethodInfo->NumArguments)
+ {
+ AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName);
+ }
+ break;
+
+
+ case PARSEOP_RETURN:
+
+ if (!MethodInfo)
+ {
+ /* Probably was an error in the method declaration, no additional error here */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op));
+ return (AE_ERROR);
+ }
+
+ /* Child indicates a return value */
+
+ if ((Op->Asl.Child) &&
+ (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
+ {
+ MethodInfo->NumReturnWithValue++;
+ }
+ else
+ {
+ MethodInfo->NumReturnNoValue++;
+ }
+ break;
+
+
+ case PARSEOP_BREAK:
+ case PARSEOP_CONTINUE:
+
+ Next = Op->Asl.Parent;
+ while (Next)
+ {
+ if (Next->Asl.ParseOpcode == PARSEOP_WHILE)
+ {
+ break;
+ }
+ Next = Next->Asl.Parent;
+ }
+
+ if (!Next)
+ {
+ AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL);
+ }
+ break;
+
+
+ case PARSEOP_DEVICE:
+ case PARSEOP_EVENT:
+ case PARSEOP_MUTEX:
+ case PARSEOP_OPERATIONREGION:
+ case PARSEOP_POWERRESOURCE:
+ case PARSEOP_PROCESSOR:
+ case PARSEOP_THERMALZONE:
+
+ /*
+ * The first operand is a name to be created in the namespace.
+ * Check against the reserved list.
+ */
+ i = AnCheckForReservedName (Op, Op->Asl.NameSeg);
+ if (i < ACPI_VALID_RESERVED_NAME_MAX)
+ {
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName);
+ }
+ break;
+
+
+ case PARSEOP_NAME:
+
+ i = AnCheckForReservedName (Op, Op->Asl.NameSeg);
+ if (i < ACPI_VALID_RESERVED_NAME_MAX)
+ {
+ if (ReservedMethods[i].NumArguments > 0)
+ {
+ /*
+ * This reserved name must be a control method because
+ * it must have arguments
+ */
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, "with arguments");
+ }
+
+ /*
+ * Typechecking for _HID
+ */
+ else if (!ACPI_STRCMP (METHOD_NAME__HID, ReservedMethods[i].Name))
+ {
+ /* Examine the second operand to typecheck it */
+
+ Next = Op->Asl.Child->Asl.Next;
+
+ if ((Next->Asl.ParseOpcode != PARSEOP_INTEGER) &&
+ (Next->Asl.ParseOpcode != PARSEOP_STRING_LITERAL))
+ {
+ /* _HID must be a string or an integer */
+
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next, "String or Integer");
+ }
+
+ if (Next->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
+ {
+ /*
+ * _HID is a string, all characters must be alphanumeric.
+ * One of the things we want to catch here is the use of
+ * a leading asterisk in the string.
+ */
+ for (i = 0; Next->Asl.Value.String[i]; i++)
+ {
+ if (!isalnum (Next->Asl.Value.String[i]))
+ {
+ AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, Next, Next->Asl.Value.String);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ break;
+
+
+ default:
+ break;
+ }
+
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnLastStatementIsReturn
+ *
+ * PARAMETERS: Op - A method parse node
+ *
+ * RETURN: TRUE if last statement is an ASL RETURN. False otherwise
+ *
+ * DESCRIPTION: Walk down the list of top level statements within a method
+ * to find the last one. Check if that last statement is in
+ * fact a RETURN statement.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AnLastStatementIsReturn (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ /*
+ * Check if last statement is a return
+ */
+ Next = ASL_GET_CHILD_NODE (Op);
+ while (Next)
+ {
+ if ((!Next->Asl.Next) &&
+ (Next->Asl.ParseOpcode == PARSEOP_RETURN))
+ {
+ return TRUE;
+ }
+
+ Next = ASL_GET_PEER_NODE (Next);
+ }
+
+ return FALSE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMethodAnalysisWalkEnd
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback for analysis walk. Complete method
+ * return analysis.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnMethodAnalysisWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
+ ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
+
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_METHOD:
+ case PARSEOP_RETURN:
+ if (!MethodInfo)
+ {
+ printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
+ AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "No method info for this method");
+ CmCleanupAndExit ();
+ return (AE_AML_INTERNAL);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_METHOD:
+
+ WalkInfo->MethodStack = MethodInfo->Next;
+
+ /*
+ * Check if there is no return statement at the end of the
+ * method AND we can actually get there -- i.e., the execution
+ * of the method can possibly terminate without a return statement.
+ */
+ if ((!AnLastStatementIsReturn (Op)) &&
+ (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT)))
+ {
+ /*
+ * No return statement, and execution can possibly exit
+ * via this path. This is equivalent to Return ()
+ */
+ MethodInfo->NumReturnNoValue++;
+ }
+
+ /*
+ * Check for case where some return statements have a return value
+ * and some do not. Exit without a return statement is a return with
+ * no value
+ */
+ if (MethodInfo->NumReturnNoValue &&
+ MethodInfo->NumReturnWithValue)
+ {
+ AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, Op->Asl.ExternalName);
+ }
+
+ /*
+ * If there are any RETURN() statements with no value, or there is a
+ * control path that allows the method to exit without a return value,
+ * we mark the method as a method that does not return a value. This
+ * knowledge can be used to check method invocations that expect a
+ * returned value.
+ */
+ if (MethodInfo->NumReturnNoValue)
+ {
+ if (MethodInfo->NumReturnWithValue)
+ {
+ Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL;
+ }
+ else
+ {
+ Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL;
+ }
+ }
+
+ /*
+ * Check predefined method names for correct return behavior
+ * and correct number of arguments
+ */
+ AnCheckForReservedMethod (Op, MethodInfo);
+ ACPI_MEM_FREE (MethodInfo);
+ break;
+
+
+ case PARSEOP_RETURN:
+
+ /*
+ * The parent block does not "exit" and continue execution -- the
+ * method is terminated here with the Return() statement.
+ */
+ Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
+ Op->Asl.ParentMethod = MethodInfo->Op; /* Used in the "typing" pass later */
+
+ /*
+ * If there is a peer node after the return statement, then this
+ * node is unreachable code -- i.e., it won't be executed because of the
+ * preceeding Return() statement.
+ */
+ if (Op->Asl.Next)
+ {
+ AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL);
+ }
+ break;
+
+
+ case PARSEOP_IF:
+
+ if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
+ (Op->Asl.Next) &&
+ (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE))
+ {
+ /*
+ * This IF has a corresponding ELSE. The IF block has no exit,
+ * (it contains an unconditional Return)
+ * mark the ELSE block to remember this fact.
+ */
+ Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT;
+ }
+ break;
+
+
+ case PARSEOP_ELSE:
+
+ if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
+ (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT))
+ {
+ /*
+ * This ELSE block has no exit and the corresponding IF block
+ * has no exit either. Therefore, the parent node has no exit.
+ */
+ Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
+ }
+ break;
+
+
+ default:
+
+ if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
+ (Op->Asl.Parent))
+ {
+ /* If this node has no exit, then the parent has no exit either */
+
+ Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
+ }
+ break;
+ }
+
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMethodTypingWalkBegin
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback for the typing walk.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnMethodTypingWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnMethodTypingWalkEnd
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback for typing walk. Complete method
+ * return analysis. Check methods for :
+ * 1) Initialized local variables
+ * 2) Valid arguments
+ * 3) Return types
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnMethodTypingWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ UINT32 ThisNodeBtype;
+
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_METHOD:
+
+ Op->Asl.CompileFlags |= NODE_METHOD_TYPED;
+ break;
+
+ case PARSEOP_RETURN:
+
+ if ((Op->Asl.Child) &&
+ (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
+ {
+ ThisNodeBtype = AnGetBtype (Op->Asl.Child);
+
+ if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) &&
+ (ThisNodeBtype == (ACPI_UINT32_MAX -1)))
+ {
+ /*
+ * The method is untyped at this time (typically a forward reference).
+ * We must recursively type the method here
+ */
+ TrWalkParseTree (ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Op->Asl.Child->Asl.Node->Object),
+ ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
+ AnMethodTypingWalkEnd, NULL);
+
+ ThisNodeBtype = AnGetBtype (Op->Asl.Child);
+ }
+
+ /* Returns a value, get it's type */
+
+ if (Op->Asl.ParentMethod)
+ {
+ Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnCheckMethodReturnValue
+ *
+ * PARAMETERS: Op - Parent
+ * OpInfo - Parent info
+ * ArgOp - Method invocation op
+ * RequiredBtypes - What caller requires
+ * ThisNodeBtype - What this node returns (if anything)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Check a method invocation for 1) A return value and if it does
+ * in fact return a value, 2) check the type of the return value.
+ *
+ ******************************************************************************/
+
+void
+AnCheckMethodReturnValue (
+ ACPI_PARSE_OBJECT *Op,
+ const ACPI_OPCODE_INFO *OpInfo,
+ ACPI_PARSE_OBJECT *ArgOp,
+ UINT32 RequiredBtypes,
+ UINT32 ThisNodeBtype)
+{
+ ACPI_PARSE_OBJECT *OwningOp;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ Node = ArgOp->Asl.Node;
+
+
+ /* Examine the parent op of this method */
+
+ OwningOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+ if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL)
+ {
+ /*
+ * Method NEVER returns a value
+ */
+ AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName);
+ }
+ else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL)
+ {
+ /*
+ * Method SOMETIMES returns a value, SOMETIMES not
+ */
+ AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName);
+ }
+ else if (!(ThisNodeBtype & RequiredBtypes))
+ {
+ /*
+ * Method returns a value, but the type is wrong
+ */
+ AnFormatBtype (StringBuffer, ThisNodeBtype);
+ AnFormatBtype (StringBuffer2, RequiredBtypes);
+
+
+ /*
+ * The case where the method does not return any value at all
+ * was already handled in the namespace cross reference
+ * -- Only issue an error if the method in fact returns a value,
+ * but it is of the wrong type
+ */
+ if (ThisNodeBtype != 0)
+ {
+ sprintf (MsgBuffer, "Method returns [%s], %s operator requires [%s]",
+ StringBuffer, OpInfo->Name, StringBuffer2);
+
+ AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnOperandTypecheckWalkBegin
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback for the analysis walk. Check methods for :
+ * 1) Initialized local variables
+ * 2) Valid arguments
+ * 3) Return types
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnOperandTypecheckWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnOperandTypecheckWalkEnd
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback for analysis walk. Complete method
+ * return analysis.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnOperandTypecheckWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT32 RuntimeArgTypes;
+ UINT32 RuntimeArgTypes2;
+ UINT32 RequiredBtypes;
+ UINT32 ThisNodeBtype;
+ UINT32 CommonBtypes;
+ UINT32 OpcodeClass;
+ ACPI_PARSE_OBJECT *ArgOp;
+ UINT32 ArgType;
+
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_RAW_DATA_BYTE:
+ case AML_RAW_DATA_WORD:
+ case AML_RAW_DATA_DWORD:
+ case AML_RAW_DATA_QWORD:
+ case AML_RAW_DATA_BUFFER:
+ case AML_RAW_DATA_CHAIN:
+ case AML_PACKAGE_LENGTH:
+ case AML_UNASSIGNED_OPCODE:
+ case AML_DEFAULT_ARG_OP:
+
+ /* Ignore the internal (compiler-only) AML opcodes */
+
+ return (AE_OK);
+
+ default:
+ break;
+ }
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
+ if (!OpInfo)
+ {
+ return (AE_OK);
+ }
+
+ ArgOp = Op->Asl.Child;
+ RuntimeArgTypes = OpInfo->RuntimeArgs;
+ OpcodeClass = OpInfo->Class;
+
+
+ /*
+ * Special case for control opcodes IF/RETURN/WHILE since they
+ * have no runtime arg list (at this time)
+ */
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+ case AML_RETURN_OP:
+
+ if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
+ {
+ /* The lone arg is a method call, check it */
+
+ RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
+ if (Op->Asl.AmlOpcode == AML_RETURN_OP)
+ {
+ RequiredBtypes = 0xFFFFFFFF;
+ }
+
+ ThisNodeBtype = AnGetBtype (ArgOp);
+ if (ThisNodeBtype == ACPI_UINT32_MAX)
+ {
+ return (AE_OK);
+ }
+ AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype);
+ }
+ return (AE_OK);
+
+ default:
+ break;
+ }
+
+ /* Ignore the non-executable opcodes */
+
+ if (RuntimeArgTypes == ARGI_INVALID_OPCODE)
+ {
+ return (AE_OK);
+ }
+
+ switch (OpcodeClass)
+ {
+ case AML_CLASS_EXECUTE:
+ case AML_CLASS_CREATE:
+ case AML_CLASS_CONTROL:
+ case AML_CLASS_RETURN_VALUE:
+
+ /* TBD: Change class or fix typechecking for these */
+
+ if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) ||
+ (Op->Asl.AmlOpcode == AML_PACKAGE_OP) ||
+ (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))
+ {
+ break;
+ }
+
+ /* Reverse the runtime argument list */
+
+ RuntimeArgTypes2 = 0;
+ while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes)))
+ {
+ RuntimeArgTypes2 <<= ARG_TYPE_WIDTH;
+ RuntimeArgTypes2 |= ArgType;
+ INCREMENT_ARG_LIST (RuntimeArgTypes);
+ }
+
+ while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2)))
+ {
+ RequiredBtypes = AnMapArgTypeToBtype (ArgType);
+
+ ThisNodeBtype = AnGetBtype (ArgOp);
+ if (ThisNodeBtype == ACPI_UINT32_MAX)
+ {
+ goto NextArgument;
+ }
+
+ /* Examine the arg based on the required type of the arg */
+
+ switch (ArgType)
+ {
+ case ARGI_TARGETREF:
+
+ if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
+ {
+ /* ZERO is the placeholder for "don't store result" */
+
+ ThisNodeBtype = RequiredBtypes;
+ break;
+ }
+
+ if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)
+ {
+ /*
+ * This is the case where an original reference to a resource
+ * descriptor field has been replaced by an (Integer) offset.
+ * These named fields are supported at compile-time only;
+ * the names are not passed to the interpreter (via the AML).
+ */
+ if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
+ (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
+ {
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL);
+ }
+ else
+ {
+ AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL);
+ }
+ break;
+ }
+
+ if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
+ (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF))
+ {
+ break;
+ }
+
+ ThisNodeBtype = RequiredBtypes;
+ break;
+
+
+ case ARGI_REFERENCE: /* References */
+ case ARGI_INTEGER_REF:
+ case ARGI_OBJECT_REF:
+ case ARGI_DEVICE_REF:
+
+ switch (ArgOp->Asl.ParseOpcode)
+ {
+ case PARSEOP_LOCAL0:
+ case PARSEOP_LOCAL1:
+ case PARSEOP_LOCAL2:
+ case PARSEOP_LOCAL3:
+ case PARSEOP_LOCAL4:
+ case PARSEOP_LOCAL5:
+ case PARSEOP_LOCAL6:
+ case PARSEOP_LOCAL7:
+
+ /* TBD: implement analysis of current value (type) of the local */
+ /* For now, just treat any local as a typematch */
+
+ /*ThisNodeBtype = RequiredBtypes;*/
+ break;
+
+ case PARSEOP_ARG0:
+ case PARSEOP_ARG1:
+ case PARSEOP_ARG2:
+ case PARSEOP_ARG3:
+ case PARSEOP_ARG4:
+ case PARSEOP_ARG5:
+ case PARSEOP_ARG6:
+
+ /* Hard to analyze argument types, sow we won't */
+ /* For now, just treat any arg as a typematch */
+
+ /* ThisNodeBtype = RequiredBtypes; */
+ break;
+
+ case PARSEOP_DEBUG:
+ break;
+
+ case PARSEOP_REFOF:
+ case PARSEOP_INDEX:
+ default:
+ break;
+
+ }
+ break;
+
+ case ARGI_INTEGER:
+ default:
+ break;
+ }
+
+
+ CommonBtypes = ThisNodeBtype & RequiredBtypes;
+
+ if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
+ {
+ /* Check a method call for a valid return value */
+
+ AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype);
+ }
+
+ /*
+ * Now check if the actual type(s) match at least one
+ * bit to the required type
+ */
+ else if (!CommonBtypes)
+ {
+ /* No match -- this is a type mismatch error */
+
+ AnFormatBtype (StringBuffer, ThisNodeBtype);
+ AnFormatBtype (StringBuffer2, RequiredBtypes);
+
+ sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]",
+ StringBuffer, OpInfo->Name, StringBuffer2);
+
+ AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
+ }
+
+ NextArgument:
+ ArgOp = ArgOp->Asl.Next;
+ INCREMENT_ARG_LIST (RuntimeArgTypes2);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnOtherSemanticAnalysisWalkBegin
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback for the analysis walk. Check methods for :
+ * 1) Initialized local variables
+ * 2) Valid arguments
+ * 3) Return types
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnOtherSemanticAnalysisWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AnOtherSemanticAnalysisWalkEnd
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback for analysis walk. Complete method
+ * return analysis.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AnOtherSemanticAnalysisWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ return AE_OK;
+
+}
diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c
new file mode 100644
index 0000000..2b3c570
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c
@@ -0,0 +1,608 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslcodegen - AML code generation
+ * $Revision: 49 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslcodegen")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgGenerateAmlOutput
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generate AML code. Currently generates the listing file
+ * simultaneously.
+ *
+ ******************************************************************************/
+
+void
+CgGenerateAmlOutput (void)
+{
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n");
+
+ /* Generate the AML output file */
+
+ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
+ Gbl_SourceLine = 0;
+ Gbl_NextError = Gbl_ErrorLog;
+
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL);
+ CgCloseTable ();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgAmlWriteWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse tree walk to generate the AML code.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+CgAmlWriteWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ /*
+ * Debug output
+ */
+ DbgPrint (ASL_TREE_OUTPUT,
+ "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
+ UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
+
+ if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG ||
+ Op->Asl.ParseOpcode == PARSEOP_NAMESTRING ||
+ Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
+ {
+ DbgPrint (ASL_TREE_OUTPUT,
+ "%10.32s ", Op->Asl.ExternalName);
+ }
+ else
+ {
+ DbgPrint (ASL_TREE_OUTPUT, " ");
+ }
+
+ DbgPrint (ASL_TREE_OUTPUT,
+ "Val-%08X POp-%04X AOp-%04X OpLen-%01X PByts-%01X Len-%04X SubLen-%04X PSubLen-%04X Op-%08X Chld-%08X Paren-%08X Flags-%04X AcTyp-%08X C-%2d L-%d\n",
+ (UINT32) Op->Asl.Value.Integer,
+ Op->Asl.ParseOpcode,
+ Op->Asl.AmlOpcode,
+ Op->Asl.AmlOpcodeLength,
+ Op->Asl.AmlPkgLenBytes,
+ Op->Asl.AmlLength,
+ Op->Asl.AmlSubtreeLength,
+ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
+ Op,
+ Op->Asl.Child,
+ Op->Asl.Parent,
+ Op->Asl.CompileFlags,
+ Op->Asl.AcpiBtype,
+ Op->Asl.Column,
+ Op->Asl.LineNumber);
+
+ /*
+ * Generate the AML for this node
+ */
+ CgWriteNode (Op);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgLocalWriteAmlData
+ *
+ * PARAMETERS: Buffer - Buffer to write
+ * Length - Size of data in buffer
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write a buffer of AML data to the AML output file.
+ *
+ ******************************************************************************/
+
+void
+CgLocalWriteAmlData (
+ ACPI_PARSE_OBJECT *Op,
+ void *Buffer,
+ UINT32 Length)
+{
+
+
+ /* Write the raw data to the AML file */
+
+ FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length);
+
+ /* Update the final AML length for this node (used for listings) */
+
+ if (Op)
+ {
+ Op->Asl.FinalAmlLength += Length;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgWriteAmlOpcode
+ *
+ * PARAMETERS: Op - Parse node with an AML opcode
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Write the AML opcode corresponding to a parse node.
+ *
+ ******************************************************************************/
+
+void
+CgWriteAmlOpcode (
+ ACPI_PARSE_OBJECT *Op)
+{
+ union {
+ UINT16 Opcode;
+ UINT8 OpcodeBytes[2];
+ } Aml;
+ union {
+ UINT32 Len;
+ UINT8 LenBytes[4];
+ } PkgLen;
+
+ UINT8 PkgLenFirstByte;
+ UINT32 i;
+
+
+ /* We expect some DEFAULT_ARGs, just ignore them */
+
+ if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
+ {
+ return;
+ }
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_UNASSIGNED_OPCODE:
+
+ /* These opcodes should not get here */
+
+ printf ("Found a node with an unassigned AML opcode\n");
+ fprintf (stderr, "Found a node with an unassigned AML opcode\n");
+ return;
+
+ case AML_INT_RESERVEDFIELD_OP:
+
+ /* Special opcodes for within a field definition */
+
+ Aml.Opcode = 0x00;
+ break;
+
+ case AML_INT_ACCESSFIELD_OP:
+
+ Aml.Opcode = 0x01;
+ break;
+
+ default:
+ Aml.Opcode = Op->Asl.AmlOpcode;
+ break;
+ }
+
+
+ switch (Aml.Opcode)
+ {
+ case AML_PACKAGE_LENGTH:
+
+ /* Value is the length to be encoded (Used in field definitions) */
+
+ PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
+ break;
+
+ default:
+
+ /* Check for two-byte opcode */
+
+ if (Aml.Opcode > 0x00FF)
+ {
+ /* Write the high byte first */
+
+ CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
+ }
+
+ CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
+
+ /* Subtreelength doesn't include length of package length bytes */
+
+ PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
+ break;
+ }
+
+ /* Does this opcode have an associated "PackageLength" field? */
+
+ if (Op->Asl.CompileFlags & NODE_AML_PACKAGE)
+ {
+ if (Op->Asl.AmlPkgLenBytes == 1)
+ {
+ /* Simplest case -- no bytes to follow, just write the count */
+
+ CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
+ }
+ else
+ {
+ /*
+ * Encode the "bytes to follow" in the first byte, top two bits.
+ * The low-order nybble of the length is in the bottom 4 bits
+ */
+ PkgLenFirstByte = (UINT8) (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
+ (PkgLen.LenBytes[0] & 0x0F));
+
+ CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
+
+ /* Shift the length over by the 4 bits we just stuffed in the first byte */
+
+ PkgLen.Len >>= 4;
+
+ /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */
+
+ for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
+ {
+ CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
+ }
+ }
+ }
+
+ switch (Aml.Opcode)
+ {
+ case AML_BYTE_OP:
+
+ CgLocalWriteAmlData (Op, (UINT8 *) &Op->Asl.Value.Integer, 1);
+ break;
+
+ case AML_WORD_OP:
+
+ CgLocalWriteAmlData (Op, (UINT16 *) &Op->Asl.Value.Integer, 2);
+ break;
+
+ case AML_DWORD_OP:
+
+ CgLocalWriteAmlData (Op, (UINT32 *) &Op->Asl.Value.Integer, 4);
+ break;
+
+ case AML_QWORD_OP:
+
+ CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
+ break;
+
+ case AML_STRING_OP:
+
+ CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
+ break;
+
+ default:
+ /* All data opcodes must appear above */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgWriteTableHeader
+ *
+ * PARAMETERS: Op - The DEFINITIONBLOCK node
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
+ *
+ ******************************************************************************/
+
+void
+CgWriteTableHeader (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Child;
+
+
+ /* AML filename */
+
+ Child = Op->Asl.Child;
+
+ /* Signature */
+
+ Child = Child->Asl.Next;
+ strncpy (TableHeader.Signature, Child->Asl.Value.String, 4);
+
+ /* Revision */
+
+ Child = Child->Asl.Next;
+ TableHeader.Revision = (UINT8) Child->Asl.Value.Integer;
+
+ /* OEMID */
+
+ Child = Child->Asl.Next;
+ strncpy (TableHeader.OemId, Child->Asl.Value.String, 6);
+
+ /* OEM TableID */
+
+ Child = Child->Asl.Next;
+ strncpy (TableHeader.OemTableId, Child->Asl.Value.String, 8);
+
+ /* OEM Revision */
+
+ Child = Child->Asl.Next;
+ TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
+
+ /* Compiler ID */
+
+ strncpy (TableHeader.AslCompilerId, CompilerCreatorId, 4);
+
+ /* Compiler version */
+
+ TableHeader.AslCompilerRevision = CompilerCreatorRevision;
+
+ /* Table length. Checksum zero for now, will rewrite later */
+
+ TableHeader.Length = Gbl_TableLength;
+ TableHeader.Checksum = 0;
+
+ CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgCloseTable
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Complete the ACPI table by calculating the checksum and
+ * re-writing the header.
+ *
+ ******************************************************************************/
+
+void
+CgCloseTable (void)
+{
+ signed char Sum;
+ UINT8 FileByte;
+
+
+ FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+ Sum = 0;
+
+ /* Calculate the checksum over the entire file */
+
+ while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
+ {
+ Sum = (signed char) (Sum + FileByte);
+ }
+
+ /* Re-write the table header with the checksum */
+
+ TableHeader.Checksum = (UINT8) (0 - Sum);
+
+ FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+ CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgWriteNode
+ *
+ * PARAMETERS: Op - Parse node to write.
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Write the AML that corresponds to a parse node.
+ *
+ ******************************************************************************/
+
+void
+CgWriteNode (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ASL_RESOURCE_NODE *Rnode;
+
+
+ Op->Asl.FinalAmlLength = 0;
+
+ /* Always check for DEFAULT_ARG and other "Noop" nodes */
+ /* TBD: this may not be the best place for this check */
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) ||
+ (Op->Asl.ParseOpcode == PARSEOP_INCLUDE) ||
+ (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END))
+ {
+ return;
+ }
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_RAW_DATA_BYTE:
+ case AML_RAW_DATA_WORD:
+ case AML_RAW_DATA_DWORD:
+ case AML_RAW_DATA_QWORD:
+
+ CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
+ return;
+
+
+ case AML_RAW_DATA_BUFFER:
+
+ CgLocalWriteAmlData (Op, Op->Asl.Value.Buffer, Op->Asl.AmlLength);
+ return;
+
+
+ case AML_RAW_DATA_CHAIN:
+
+ Rnode = ACPI_CAST_PTR (ASL_RESOURCE_NODE, Op->Asl.Value.Buffer);
+ while (Rnode)
+ {
+ CgLocalWriteAmlData (Op, Rnode->Buffer, Rnode->BufferLength);
+ Rnode = Rnode->Next;
+ }
+ return;
+
+ default:
+ /* Internal data opcodes must all appear above */
+ break;
+ }
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFAULT_ARG:
+
+ break;
+
+ case PARSEOP_DEFINITIONBLOCK:
+
+ CgWriteTableHeader (Op);
+ break;
+
+ case PARSEOP_NAMESEG:
+ case PARSEOP_NAMESTRING:
+ case PARSEOP_METHODCALL:
+
+ CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
+ break;
+
+ default:
+
+ CgWriteAmlOpcode (Op);
+ break;
+ }
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c
new file mode 100644
index 0000000..fa3d45e
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslcompile.c
@@ -0,0 +1,615 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslcompile - top level compile module
+ * $Revision: 69 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 <stdio.h>
+#include "aslcompiler.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslcompile")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslCompilerSignon
+ *
+ * PARAMETERS: FileId - ID of the output file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display compiler signon
+ *
+ ******************************************************************************/
+
+void
+AslCompilerSignon (
+ UINT32 FileId)
+{
+ char *Prefix = "";
+
+
+ /*
+ * Set line prefix depending on the destination file type
+ */
+ switch (FileId)
+ {
+ case ASL_FILE_ASM_SOURCE_OUTPUT:
+ case ASL_FILE_ASM_INCLUDE_OUTPUT:
+
+ Prefix = "; ";
+ break;
+
+ case ASL_FILE_HEX_OUTPUT:
+
+ if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
+ {
+ Prefix = "; ";
+ }
+ else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
+ Prefix = " * ";
+ }
+ break;
+
+ case ASL_FILE_C_SOURCE_OUTPUT:
+ case ASL_FILE_C_INCLUDE_OUTPUT:
+
+ Prefix = " * ";
+ break;
+
+ default:
+ /* No other output types supported */
+ break;
+ }
+
+ /* Compiler signon with copyright */
+
+ FlPrintFile (FileId,
+ "%s\n%s%s\n%s%s version %X [%s]\n%s%s\n%sSupports ACPI Specification Revision 2.0b\n%s\n",
+ Prefix,
+ Prefix, IntelAcpiCA,
+ Prefix, CompilerId, ACPI_CA_VERSION, __DATE__,
+ Prefix, CompilerCopyright,
+ Prefix,
+ Prefix);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslCompilerFileHeader
+ *
+ * PARAMETERS: FileId - ID of the output file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Header used at the beginning of output files
+ *
+ ******************************************************************************/
+
+void
+AslCompilerFileHeader (
+ UINT32 FileId)
+{
+ struct tm *NewTime;
+ time_t Aclock;
+ char *Prefix = "";
+
+
+ /*
+ * Set line prefix depending on the destination file type
+ */
+ switch (FileId)
+ {
+ case ASL_FILE_ASM_SOURCE_OUTPUT:
+ case ASL_FILE_ASM_INCLUDE_OUTPUT:
+
+ Prefix = "; ";
+ break;
+
+ case ASL_FILE_HEX_OUTPUT:
+
+ if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
+ {
+ Prefix = "; ";
+ }
+ else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
+ {
+ Prefix = " * ";
+ }
+ break;
+
+ case ASL_FILE_C_SOURCE_OUTPUT:
+ case ASL_FILE_C_INCLUDE_OUTPUT:
+
+ Prefix = " * ";
+ break;
+
+ default:
+ /* No other output types supported */
+ break;
+ }
+
+ /* Compilation header with timestamp */
+
+ (void) time (&Aclock);
+ NewTime = localtime (&Aclock);
+
+ FlPrintFile (FileId,
+ "%sCompilation of \"%s\" - %s%s\n",
+ Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
+ Prefix);
+
+ switch (FileId)
+ {
+ case ASL_FILE_C_SOURCE_OUTPUT:
+ case ASL_FILE_C_INCLUDE_OUTPUT:
+ FlPrintFile (FileId, " */\n");
+ break;
+
+ default:
+ /* Nothing to do for other output types */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CmFlushSourceCode
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Read in any remaining source code after the parse tree
+ * has been constructed.
+ *
+ ******************************************************************************/
+
+void
+CmFlushSourceCode (void)
+{
+ char Buffer;
+
+
+ while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
+ {
+ InsertLineBuffer ((int) Buffer);
+ }
+
+ ResetCurrentLineBuffer ();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CmDoCompile
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status (0 = OK)
+ *
+ * DESCRIPTION: This procedure performs the entire compile
+ *
+ ******************************************************************************/
+
+int
+CmDoCompile (void)
+{
+ ACPI_STATUS Status;
+ UINT32 i = 0;
+
+
+ UtBeginEvent (12, "Total Compile time");
+ UtBeginEvent (i, "Initialize");
+
+ /* Open the required input and output files */
+
+ Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename);
+ if (ACPI_FAILURE (Status))
+ {
+ AePrintErrorLog (ASL_FILE_STDERR);
+ return -1;
+ }
+
+ Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
+ if (ACPI_FAILURE (Status))
+ {
+ AePrintErrorLog (ASL_FILE_STDERR);
+ return -1;
+ }
+
+ UtEndEvent (i++);
+
+ /* Build the parse tree */
+
+ UtBeginEvent (i, "Parse source code and build parse tree");
+ AslCompilerparse();
+ UtEndEvent (i++);
+
+ /* Flush out any remaining source after parse tree is complete */
+
+ CmFlushSourceCode ();
+
+ /* Did the parse tree get successfully constructed? */
+
+ if (!RootNode)
+ {
+ CmCleanupAndExit ();
+ return -1;
+ }
+
+ OpcGetIntegerWidth (RootNode);
+
+ /* Pre-process parse tree for any operator transforms */
+
+ UtBeginEvent (i, "Generate AML opcodes");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, TrAmlTransformWalk, NULL, NULL);
+
+ /* Generate AML opcodes corresponding to the parse tokens */
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL);
+ UtEndEvent (i++);
+
+ /*
+ * Now that the input is parsed, we can open the AML output file.
+ * Note: by default, the name of this file comes from the table descriptor
+ * within the input file.
+ */
+ Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
+ if (ACPI_FAILURE (Status))
+ {
+ AePrintErrorLog (ASL_FILE_STDERR);
+ return -1;
+ }
+
+ /* Interpret and generate all compile-time constants */
+
+ UtBeginEvent (i, "Constant folding via AML interpreter");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nInterpreting compile-time constant expressions\n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, OpcAmlConstantWalk, NULL, NULL);
+ UtEndEvent (i++);
+
+ /* Calculate all AML package lengths */
+
+ UtBeginEvent (i, "Generate AML package lengths");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
+ UtEndEvent (i++);
+
+ if (Gbl_ParseOnlyFlag)
+ {
+ AePrintErrorLog (ASL_FILE_STDOUT);
+ UtDisplaySummary (ASL_FILE_STDOUT);
+ if (Gbl_DebugFlag)
+ {
+ /* Print error summary to the debug file */
+
+ AePrintErrorLog (ASL_FILE_STDERR);
+ UtDisplaySummary (ASL_FILE_STDERR);
+ }
+ return 0;
+ }
+
+ /*
+ * Create an internal namespace and use it as a symbol table
+ */
+
+ /* Namespace loading */
+
+ UtBeginEvent (i, "Create ACPI Namespace");
+ Status = LdLoadNamespace (RootNode);
+ UtEndEvent (i++);
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+
+ /* Namespace lookup */
+
+ UtBeginEvent (i, "Cross reference parse tree and Namespace");
+ Status = LkCrossReferenceNamespace ();
+ UtEndEvent (i++);
+ UtEndEvent (i++);
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+
+ /*
+ * Semantic analysis. This can happen only after the
+ * namespace has been loaded and cross-referenced.
+ *
+ * part one - check control methods
+ */
+ UtBeginEvent (i, "Analyze control method return types");
+ AnalysisWalkInfo.MethodStack = NULL;
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodAnalysisWalkBegin,
+ AnMethodAnalysisWalkEnd, &AnalysisWalkInfo);
+ UtEndEvent (i++);
+
+ /* Semantic error checking part two - typing of method returns */
+
+ UtBeginEvent (i, "Determine object types returned by methods");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing \n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
+ AnMethodTypingWalkEnd, NULL);
+ UtEndEvent (i++);
+
+ /* Semantic error checking part three - operand type checking */
+
+ UtBeginEvent (i, "Analyze AML operand types");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking \n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOperandTypecheckWalkBegin,
+ AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
+ UtEndEvent (i++);
+
+ /* Semantic error checking part four - other miscellaneous checks */
+
+ UtBeginEvent (i, "Miscellaneous analysis");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous \n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOtherSemanticAnalysisWalkBegin,
+ AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo);
+ UtEndEvent (i++);
+
+ /* Calculate all AML package lengths */
+
+ UtBeginEvent (i, "Finish AML package length generation");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL);
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
+ UtEndEvent (i++);
+
+
+ /* Code generation - emit the AML */
+
+ UtBeginEvent (i, "Generate AML code and write output files");
+ CgGenerateAmlOutput ();
+ UtEndEvent (i++);
+
+ UtBeginEvent (i, "Write optional output files");
+ CmDoOutputFiles ();
+ UtEndEvent (i++);
+
+ UtEndEvent (13);
+ CmCleanupAndExit ();
+ return 0;
+}
+
+void
+CmDoOutputFiles (void)
+{
+
+ /* Create listings and hex files */
+
+ LsDoListings ();
+ LsDoHexOutput ();
+
+ /* Dump the namespace to the .nsp file if requested */
+
+ LsDisplayNamespace ();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CmCleanupAndExit
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Close all open files and exit the compiler
+ *
+ ******************************************************************************/
+
+void
+CmCleanupAndExit (void)
+{
+ UINT32 i;
+
+
+ AePrintErrorLog (ASL_FILE_STDOUT);
+ if (Gbl_DebugFlag)
+ {
+ /* Print error summary to the debug file */
+
+ AePrintErrorLog (ASL_FILE_STDERR);
+ }
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
+ for (i = 0; i < 13; i++)
+ {
+ if (AslGbl_Events[i].Valid)
+ {
+ DbgPrint (ASL_DEBUG_OUTPUT, "%8lu ms - %s\n",
+ AslGbl_Events[i].EndTime -
+ AslGbl_Events[i].StartTime,
+ AslGbl_Events[i].EventName);
+ }
+ }
+
+ if (Gbl_CompileTimesFlag)
+ {
+ printf ("\nElapsed time for major events\n\n");
+ for (i = 0; i < 13; i++)
+ {
+ if (AslGbl_Events[i].Valid)
+ {
+ printf ("%8lu ms : %s\n",
+ AslGbl_Events[i].EndTime -
+ AslGbl_Events[i].StartTime,
+ AslGbl_Events[i].EventName);
+ }
+ }
+ printf ("\nMiscellaneous compile statistics\n\n");
+ printf ("%11u : %s\n", TotalParseNodes, "Parse nodes");
+ printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches");
+ printf ("%11u : %s\n", TotalNamedObjects, "Named objects");
+ printf ("%11u : %s\n", TotalMethods, "Control methods");
+ printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
+ printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
+ printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
+ printf ("\n");
+ }
+
+ if (Gbl_NsLookupCount)
+ {
+ DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n");
+ DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", Gbl_NsLookupCount);
+ DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Time per search",
+ ((UINT32) (AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) /
+ Gbl_NsLookupCount);
+ }
+
+ /* Close all open files */
+
+ for (i = 2; i < ASL_MAX_FILE_TYPE; i++)
+ {
+ FlCloseFile (i);
+ }
+
+ /*
+ * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
+ */
+ if (!Gbl_SourceOutputFlag)
+ {
+ unlink (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
+ }
+
+ /* Delete AML file if there are errors */
+
+ if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors))
+ {
+ unlink (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename);
+ }
+
+ if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
+ {
+ printf ("\nMaximum error count (%d) exceeded.\n", ASL_MAX_ERROR_COUNT);
+ }
+
+ UtDisplaySummary (ASL_FILE_STDOUT);
+ exit (0);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h
new file mode 100644
index 0000000..5e6724b
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h
@@ -0,0 +1,1120 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslcompiler.h - common include file
+ * $Revision: 127 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#ifndef __ASLCOMPILER_H
+#define __ASLCOMPILER_H
+
+
+/* Microsoft-specific */
+
+#if (defined WIN32 || defined WIN64)
+
+/* warn : used #pragma pack */
+#pragma warning(disable:4103)
+
+/* warn : named type definition in parentheses */
+#pragma warning(disable:4115)
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+
+
+#include "acpi.h"
+#include "amlresrc.h"
+#include "acdebug.h"
+#include "asltypes.h"
+#include "aslglobal.h"
+
+
+/*
+ * Compiler versions and names
+ */
+
+#define CompilerCreatorRevision ACPI_CA_VERSION
+
+#define IntelAcpiCA "Intel ACPI Component Architecture"
+#define CompilerId "ASL Optimizing Compiler / AML Disassembler"
+#define CompilerCopyright "Copyright (C) 2000 - 2003 Intel Corporation"
+#define CompilerCompliance "ACPI 2.0b"
+#define CompilerName "iasl"
+#define CompilerCreatorId "INTL"
+
+
+/* Configuration constants */
+
+#define ASL_MAX_ERROR_COUNT 200
+#define ASL_NODE_CACHE_SIZE 1024
+#define ASL_STRING_CACHE_SIZE 32768
+
+#define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS
+#define ASL_YYTNAME_START 3
+
+/*
+ * Macros
+ */
+
+#define ASL_RESDESC_OFFSET(m) ACPI_OFFSET (ASL_RESOURCE_DESC, m)
+#define ASL_PTR_DIFF(a,b) ((UINT8 *)(b) - (UINT8 *)(a))
+#define ASL_PTR_ADD(a,b) ((UINT8 *)(a) = ((UINT8 *)(a) + (b)))
+#define ASL_GET_CHILD_NODE(a) (a)->Asl.Child
+#define ASL_GET_PEER_NODE(a) (a)->Asl.Next
+#define OP_TABLE_ENTRY(a,b,c,d) {b,d,a,c}
+
+
+#define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */
+
+
+/* Internal AML opcodes */
+
+#define AML_RAW_DATA_BYTE (UINT16) 0xAA01 /* write one raw byte */
+#define AML_RAW_DATA_WORD (UINT16) 0xAA02 /* write 2 raw bytes */
+#define AML_RAW_DATA_DWORD (UINT16) 0xAA04 /* write 4 raw bytes */
+#define AML_RAW_DATA_QWORD (UINT16) 0xAA08 /* write 8 raw bytes */
+#define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B /* raw buffer with length */
+#define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C /* chain of raw buffers */
+#define AML_PACKAGE_LENGTH (UINT16) 0xAA10
+#define AML_UNASSIGNED_OPCODE (UINT16) 0xEEEE
+#define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD
+
+
+/* filename suffixes for output files */
+
+#define FILE_SUFFIX_AML_CODE "aml"
+#define FILE_SUFFIX_LISTING "lst"
+#define FILE_SUFFIX_HEX_DUMP "hex"
+#define FILE_SUFFIX_DEBUG "txt"
+#define FILE_SUFFIX_SOURCE "src"
+#define FILE_SUFFIX_NAMESPACE "nsp"
+#define FILE_SUFFIX_ASM_SOURCE "asm"
+#define FILE_SUFFIX_C_SOURCE "c"
+#define FILE_SUFFIX_DISASSEMBLY "dsl"
+#define FILE_SUFFIX_ASM_INCLUDE "inc"
+#define FILE_SUFFIX_C_INCLUDE "h"
+
+
+/* Misc */
+
+#define ASL_EXTERNAL_METHOD 255
+#define ASL_ABORT TRUE
+#define ASL_NO_ABORT FALSE
+
+
+/*******************************************************************************
+ *
+ * Compiler prototypes
+ *
+ ******************************************************************************/
+
+
+void
+end_stmt (void);
+
+
+/* parser */
+
+int
+AslCompilerparse(
+ void);
+
+ACPI_PARSE_OBJECT *
+AslDoError (
+ void);
+
+int
+AslCompilererror(
+ char *s);
+
+int
+AslCompilerlex(
+ void);
+
+void
+ResetCurrentLineBuffer (
+ void);
+
+void
+InsertLineBuffer (
+ int SourceChar);
+
+int
+AslPopInputFileStack (
+ void);
+
+void
+AslPushInputFileStack (
+ FILE *InputFile,
+ char *Filename);
+
+/* aslmain */
+
+void
+AslCompilerSignon (
+ UINT32 FileId);
+
+void
+AslCompilerFileHeader (
+ UINT32 FileId);
+
+void
+AslDoSourceOutputFile (
+ char *Buffer);
+
+#define ASL_DEBUG_OUTPUT 0
+#define ASL_PARSE_OUTPUT 1
+#define ASL_TREE_OUTPUT 2
+
+
+void
+DbgPrint (
+ UINT32 Type,
+ char *Format,
+ ...);
+
+void
+ErrorContext (void);
+
+/* aslcompile */
+
+int
+CmDoCompile (void);
+
+void
+CmDoOutputFiles (void);
+
+void
+CmCleanupAndExit (void);
+
+
+/* aslerror */
+
+void
+AslError (
+ UINT8 Level,
+ UINT8 MessageId,
+ ACPI_PARSE_OBJECT *Op,
+ char *ExtraMessage);
+
+void
+AslCoreSubsystemError (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_STATUS Status,
+ char *ExtraMessage,
+ BOOLEAN Abort);
+
+void
+AslCommonError (
+ UINT8 Level,
+ UINT8 MessageId,
+ UINT32 CurrentLineNumber,
+ UINT32 LogicalLineNumber,
+ UINT32 LogicalByteOffset,
+ UINT32 Column,
+ char *Filename,
+ char *ExtraMessage);
+
+void
+AePrintException (
+ UINT32 FileId,
+ ASL_ERROR_MSG *Enode,
+ char *Header);
+
+void
+AePrintErrorLog (
+ UINT32 FileId);
+
+ACPI_STATUS
+AeLocalGetRootPointer (
+ UINT32 Flags,
+ ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress);
+
+
+/* asllisting */
+
+void
+LsWriteListingHexBytes (
+ UINT8 *Buffer,
+ UINT32 Length,
+ UINT32 FileId);
+
+void
+LsWriteNodeToListing (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 FileId);
+
+void
+LsWriteNodeToAsmListing (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+LsWriteNode (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 FileId);
+
+void
+LsFinishSourceListing (
+ UINT32 FileId);
+
+void
+LsFlushListingBuffer (
+ UINT32 FileId);
+
+void
+LsDoHexOutput (
+ void);
+
+void
+LsDoHexOutputC (
+ void);
+
+void
+LsDoHexOutputAsm (
+ void);
+
+void
+LsPushNode (
+ char *Filename);
+
+ASL_LISTING_NODE *
+LsPopNode (
+ void);
+
+
+/*
+ * aslopcodes - generate AML opcodes
+ */
+
+ACPI_STATUS
+OpcAmlOpcodeWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+OpcAmlConstantWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+void
+OpcGenerateAmlOpcode (
+ ACPI_PARSE_OBJECT *Op);
+
+UINT32
+OpcSetOptimalIntegerSize (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpcGetIntegerWidth (
+ ACPI_PARSE_OBJECT *Op);
+
+/*
+ * asloperands - generate AML operands for the AML opcodes
+ */
+
+void
+OpnGenerateAmlOperands (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoField (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoBankField (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoBuffer (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoDefinitionBlock (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoFieldCommon (
+ ACPI_PARSE_OBJECT *FieldOp,
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoIndexField (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoLoadTable (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoMethod (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoPackage (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+OpnDoRegion (
+ ACPI_PARSE_OBJECT *Op);
+
+/*
+ * aslopt - optmization
+ */
+
+void
+OptOptimizeNamePath (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Flags,
+ ACPI_WALK_STATE *WalkState,
+ char *AmlNameString,
+ ACPI_NAMESPACE_NODE *TargetNode);
+
+
+/*
+ * aslresource - resource template generation
+ */
+
+void
+RsDoResourceTemplate (
+ ACPI_PARSE_OBJECT *Op);
+
+
+void
+CgGenerateAmlOutput (void);
+
+void
+CgGenerateListing (
+ UINT32 FileId);
+
+void
+LsDoListings (void);
+
+void
+CgGenerateAmlLengths (
+ ACPI_PARSE_OBJECT *Op);
+
+ACPI_STATUS
+CgOpenOutputFile (
+ char *InputFilename);
+
+
+/* asllength */
+
+ACPI_STATUS
+LnPackageLengthWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+LnInitLengthsWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+
+ACPI_STATUS
+CgAmlWriteWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+void
+CgGenerateOutput(
+ void);
+
+void
+CgCloseTable (void);
+
+
+void
+CgWriteNode (
+ ACPI_PARSE_OBJECT *Op);
+
+/*
+ * aslmap
+ */
+
+ACPI_OBJECT_TYPE
+AslMapNamedOpcodeToDataType (
+ UINT16 Opcode);
+
+/*
+ * asltransform - parse tree transformations
+ */
+
+ACPI_STATUS
+TrAmlTransformWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+
+void
+TrTransformSubtree (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+TrDoSwitch (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+TrDoDefinitionBlock (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+TrDoElseif (
+ ACPI_PARSE_OBJECT *Op);
+
+
+/*
+ * asltree - parse tree support
+ */
+
+ACPI_STATUS
+TrWalkParseTree (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Visitation,
+ ASL_WALK_CALLBACK DescendingCallback,
+ ASL_WALK_CALLBACK AscendingCallback,
+ void *Context);
+
+ACPI_PARSE_OBJECT *
+TrAllocateNode (
+ UINT32 ParseOpcode);
+
+
+/* Values for "Visitation" parameter above */
+
+#define ASL_WALK_VISIT_DOWNWARD 0x01
+#define ASL_WALK_VISIT_UPWARD 0x02
+#define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
+
+
+char *
+TrAddNode (
+ void *Thing);
+
+ACPI_PARSE_OBJECT *
+TrUpdateNode (
+ UINT32 ParseOpcode,
+ ACPI_PARSE_OBJECT *Op);
+
+ACPI_PARSE_OBJECT *
+TrCreateNode (
+ UINT32 ParseOpcode,
+ UINT32 NumChildren,
+ ...);
+
+ACPI_PARSE_OBJECT *
+TrCreateLeafNode (
+ UINT32 ParseOpcode);
+
+ACPI_PARSE_OBJECT *
+TrCreateValuedLeafNode (
+ UINT32 ParseOpcode,
+ ACPI_INTEGER Value);
+
+ACPI_PARSE_OBJECT *
+TrLinkChildren (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 NumChildren,
+ ...);
+
+void
+TrSetEndLineNumber (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+TrWalkTree (void);
+
+ACPI_PARSE_OBJECT *
+TrLinkPeerNode (
+ ACPI_PARSE_OBJECT *Op1,
+ ACPI_PARSE_OBJECT *Op2);
+
+ACPI_PARSE_OBJECT *
+TrLinkChildNode (
+ ACPI_PARSE_OBJECT *Op1,
+ ACPI_PARSE_OBJECT *Op2);
+
+ACPI_PARSE_OBJECT *
+TrSetNodeFlags (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Flags);
+
+ACPI_PARSE_OBJECT *
+TrLinkPeerNodes (
+ UINT32 NumPeers,
+ ...);
+
+void
+TrReleaseNode (
+ ACPI_PARSE_OBJECT *Op);
+
+/* Analyze */
+
+ACPI_STATUS
+AnOtherSemanticAnalysisWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnOtherSemanticAnalysisWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnOperandTypecheckWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnOperandTypecheckWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnMethodAnalysisWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnMethodAnalysisWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnMethodTypingWalkBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+AnMethodTypingWalkEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+
+/*
+ * aslfiles - File I/O support
+ */
+
+void
+AslAbort (void);
+
+FILE *
+FlOpenLocalFile (
+ char *LocalName,
+ char *Mode);
+
+void
+FlOpenIncludeFile (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+FlFileError (
+ UINT32 FileId,
+ UINT8 ErrorId);
+
+void
+FlOpenFile (
+ UINT32 FileId,
+ char *Filename,
+ char *Mode);
+
+ACPI_STATUS
+FlReadFile (
+ UINT32 FileId,
+ void *Buffer,
+ UINT32 Length);
+
+void
+FlWriteFile (
+ UINT32 FileId,
+ void *Buffer,
+ UINT32 Length);
+
+void
+FlSeekFile (
+ UINT32 FileId,
+ long Offset);
+
+void
+FlCloseFile (
+ UINT32 FileId);
+
+void
+FlPrintFile (
+ UINT32 FileId,
+ char *Format,
+ ...);
+
+void
+FlSetLineNumber (
+ ACPI_PARSE_OBJECT *Op);
+
+ACPI_STATUS
+FlParseInputPathname (
+ char *InputFilename);
+
+ACPI_STATUS
+FlOpenInputFile (
+ char *InputFilename);
+
+ACPI_STATUS
+FlOpenAmlOutputFile (
+ char *InputFilename);
+
+ACPI_STATUS
+FlOpenMiscOutputFiles (
+ char *InputFilename);
+
+void
+MpDisplayReservedNames (
+ void);
+
+
+/* Load */
+
+ACPI_STATUS
+LdLoadNamespace (
+ ACPI_PARSE_OBJECT *RootOp);
+
+
+ACPI_STATUS
+LdNamespace1Begin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+LdNamespace1End (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+
+/* Lookup */
+
+ACPI_STATUS
+LkCrossReferenceNamespace (void);
+
+ACPI_STATUS
+LkNamespaceLocateBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+LkNamespaceLocateEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+ACPI_STATUS
+LsDisplayNamespace (
+ void);
+
+ACPI_STATUS
+LsCompareOneNamespaceObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue);
+
+
+/* Utils */
+
+void
+UtDisplayConstantOpcodes (
+ void);
+
+void
+UtBeginEvent (
+ UINT32 Event,
+ char *Name);
+
+void
+UtEndEvent (
+ UINT32 Event);
+
+void *
+UtLocalCalloc (
+ UINT32 Size);
+
+void
+UtPrintFormattedName (
+ UINT16 ParseOpcode,
+ UINT32 Level);
+
+void
+UtDisplaySummary (
+ UINT32 FileId);
+
+UINT8
+UtHexCharToValue (
+ int hc);
+
+void
+UtConvertByteToHex (
+ UINT8 RawByte,
+ UINT8 *Buffer);
+
+void
+UtConvertByteToAsmHex (
+ UINT8 RawByte,
+ UINT8 *Buffer);
+
+char *
+UtGetOpName (
+ UINT32 ParseOpcode);
+
+void
+UtSetParseOpName (
+ ACPI_PARSE_OBJECT *Op);
+
+ACPI_PARSE_OBJECT *
+UtGetArg (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Argn);
+
+char *
+UtGetStringBuffer (
+ UINT32 Length);
+
+ACPI_STATUS
+UtInternalizeName (
+ char *ExternalName,
+ char **ConvertedName);
+
+void
+UtAttachNamepathToOwner (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *NameNode);
+
+ACPI_PARSE_OBJECT *
+UtCheckIntegerRange (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 LowValue,
+ UINT32 HighValue);
+
+ACPI_STATUS
+UtStrtoul64 (
+ char *String,
+ UINT32 Base,
+ ACPI_INTEGER *RetInteger);
+
+ACPI_INTEGER
+UtDoConstant (
+ char *String);
+
+
+/* Find */
+
+void
+LnAdjustLengthToRoot (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 LengthDelta);
+
+
+#define NEXT_RESOURCE_DESC(a,b) (ASL_RESOURCE_DESC *) (((char *) (a)) + sizeof(b))
+
+#define DEFAULT_RESOURCE_DESC_SIZE (sizeof (ASL_RESOURCE_DESC) + sizeof (ASL_END_TAG_DESC))
+
+
+/*
+ * Resource utilities
+ */
+
+ASL_RESOURCE_NODE *
+RsAllocateResourceNode (
+ UINT32 Size);
+
+ void
+RsCreateBitField (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name,
+ UINT32 ByteOffset,
+ UINT32 BitOffset);
+
+void
+RsCreateByteField (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name,
+ UINT32 ByteOffset);
+
+void
+RsSetFlagBits (
+ UINT8 *Flags,
+ ACPI_PARSE_OBJECT *Op,
+ UINT8 Position,
+ UINT8 DefaultBit);
+
+ACPI_PARSE_OBJECT *
+RsCompleteNodeAndGetNext (
+ ACPI_PARSE_OBJECT *Op);
+
+ASL_RESOURCE_NODE *
+RsDoOneResourceDescriptor (
+ ACPI_PARSE_OBJECT *DescriptorTypeOp,
+ UINT32 CurrentByteOffset,
+ UINT8 *State);
+
+#define ACPI_RSTATE_NORMAL 0
+#define ACPI_RSTATE_START_DEPENDENT 1
+#define ACPI_RSTATE_DEPENDENT_LIST 2
+
+UINT32
+RsLinkDescriptorChain (
+ ASL_RESOURCE_NODE **PreviousRnode,
+ ASL_RESOURCE_NODE *Rnode);
+
+
+/*
+ * Small descriptors
+ */
+
+ASL_RESOURCE_NODE *
+RsDoDmaDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoEndDependentDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoFixedIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoInterruptDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoIrqDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoIrqNoFlagsDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoMemory24Descriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoMemory32Descriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoMemory32FixedDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoStartDependentDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoStartDependentNoPriDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoVendorSmallDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+
+/*
+ * Large descriptors
+ */
+
+UINT32
+RsGetStringDataLength (
+ ACPI_PARSE_OBJECT *InitializerOp);
+
+ASL_RESOURCE_NODE *
+RsDoDwordIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoDwordMemoryDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoQwordIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoQwordMemoryDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoWordIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoWordBusNumberDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoVendorLargeDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+ASL_RESOURCE_NODE *
+RsDoGeneralRegisterDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset);
+
+
+#endif /* __ASLCOMPILER_H */
+
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l
new file mode 100644
index 0000000..a7598e6
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l
@@ -0,0 +1,1153 @@
+
+%{
+/******************************************************************************
+ *
+ * Module Name: aslcompiler.l - Flex input file
+ * $Revision: $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 <stdlib.h>
+#include <string.h>
+#include "aslcompiler.h"
+#include "aslcompiler.y.h"
+YYSTYPE AslCompilerlval;
+
+/*
+ * Generation: Use the following command line:
+ *
+ * flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath)
+ *
+ * -i: Scanner must be case-insensitive
+ */
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslscan")
+char
+comment (void);
+char
+comment2 (void);
+void
+count (int type);
+char
+literal (void);
+void
+copy (void);
+
+/*! [Begin] no source code translation */
+
+%}
+
+
+LeadNameChar [A-Za-z_]
+DigitChar [0-9]
+HexDigitChar [A-Fa-f0-9]
+RootChar [\\]
+Nothing []
+
+NameChar [A-Za-z_0-9]
+NameSeg1 {LeadNameChar}{NameChar}
+NameSeg2 {LeadNameChar}{NameChar}{NameChar}
+NameSeg3 {LeadNameChar}{NameChar}{NameChar}{NameChar}
+NameSeg {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3}
+
+NameString {RootChar}|{RootChar}{NamePath}|[\^]+{NamePath}|{NonEmptyNamePath}
+NamePath {NonEmptyNamePath}?
+NonEmptyNamePath {NameSeg}{NamePathTail}*
+NamePathTail [.]{NameSeg}
+
+%%
+
+[ ] { count (0); }
+[\n] { count (0); }
+[ \t] { count (0); }
+
+
+"/*" { if (!comment ()) yyterminate (); }
+"//" { if (!comment2 ()) yyterminate (); }
+
+"\"" { if (literal ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); }
+
+
+0[xX]{HexDigitChar}+ |
+{DigitChar}+ { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
+ count (1); return (PARSEOP_INTEGER); }
+
+"Include" { count (1); return (PARSEOP_INCLUDE); }
+"#include" { count (1); return (PARSEOP_INCLUDE_CSTYLE); }
+"#line" { count (1); return (PARSEOP_LINE_CSTYLE); }
+"External" { count (1); return (PARSEOP_EXTERNAL); }
+
+
+"Ones" { count (1); return (PARSEOP_ONES); }
+"One" { count (1); return (PARSEOP_ONE); }
+"Zero" { count (1); return (PARSEOP_ZERO); }
+"Revision" { count (1); return (PARSEOP_REVISION); }
+
+"Offset" { count (1); return (PARSEOP_OFFSET); }
+"AccessAs" { count (1); return (PARSEOP_ACCESSAS); }
+"BankField" { count (2); return (PARSEOP_BANKFIELD); }
+"CreateBitField" { count (2); return (PARSEOP_CREATEBITFIELD); }
+"CreateByteField" { count (2); return (PARSEOP_CREATEBYTEFIELD); }
+"CreateDWordField" { count (2); return (PARSEOP_CREATEDWORDFIELD); }
+"CreateField" { count (2); return (PARSEOP_CREATEFIELD); }
+"CreateQWordField" { count (2); return (PARSEOP_CREATEQWORDFIELD); }
+"CreateWordField" { count (2); return (PARSEOP_CREATEWORDFIELD); }
+"DataTableRegion" { count (2); return (PARSEOP_DATATABLEREGION); }
+"Device" { count (2); return (PARSEOP_DEVICE); }
+"Event" { count (2); return (PARSEOP_EVENT); }
+"Field" { count (2); return (PARSEOP_FIELD); }
+"IndexField" { count (2); return (PARSEOP_INDEXFIELD); }
+"Method" { count (2); return (PARSEOP_METHOD); }
+"Mutex" { count (2); return (PARSEOP_MUTEX); }
+"OperationRegion" { count (2); return (PARSEOP_OPERATIONREGION); }
+"PowerResource" { count (2); return (PARSEOP_POWERRESOURCE); }
+"Processor" { count (2); return (PARSEOP_PROCESSOR); }
+"ThermalZone" { count (2); return (PARSEOP_THERMALZONE); }
+"Alias" { count (2); return (PARSEOP_ALIAS); }
+"Name" { count (2); return (PARSEOP_NAME); }
+"Scope" { count (2); return (PARSEOP_SCOPE); }
+"Break" { count (3); return (PARSEOP_BREAK); }
+"BreakPoint" { count (3); return (PARSEOP_BREAKPOINT); }
+"Continue" { count (3); return (PARSEOP_CONTINUE); }
+"Fatal" { count (3); return (PARSEOP_FATAL); }
+"If" { count (3); return (PARSEOP_IF); }
+"Else" { count (3); return (PARSEOP_ELSE); }
+"ElseIf" { count (3); return (PARSEOP_ELSEIF); }
+"Load" { count (3); return (PARSEOP_LOAD); }
+"Noop" { count (3); return (PARSEOP_NOOP); }
+"Notify" { count (3); return (PARSEOP_NOTIFY); }
+"Release" { count (3); return (PARSEOP_RELEASE); }
+"Reset" { count (3); return (PARSEOP_RESET); }
+"Return" { count (3); return (PARSEOP_RETURN); }
+"Signal" { count (3); return (PARSEOP_SIGNAL); }
+"Sleep" { count (3); return (PARSEOP_SLEEP); }
+"Stall" { count (3); return (PARSEOP_STALL); }
+"Switch" { count (3); return (PARSEOP_SWITCH); }
+"Case" { count (3); return (PARSEOP_CASE); }
+"Default" { count (3); return (PARSEOP_DEFAULT); }
+"Unload" { count (3); return (PARSEOP_UNLOAD); }
+"While" { count (3); return (PARSEOP_WHILE); }
+
+"Acquire" { count (3); return (PARSEOP_ACQUIRE); }
+"Add" { count (3); return (PARSEOP_ADD); }
+"And" { count (3); return (PARSEOP_AND); }
+"Concatenate" { count (3); return (PARSEOP_CONCATENATE); }
+"ConcatenateResTemplate" { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); }
+"CondRefOf" { count (3); return (PARSEOP_CONDREFOF); }
+"CopyObject" { count (3); return (PARSEOP_COPYOBJECT); }
+"Decrement" { count (3); return (PARSEOP_DECREMENT); }
+"DeRefOf" { count (3); return (PARSEOP_DEREFOF); }
+"Divide" { count (3); return (PARSEOP_DIVIDE); }
+"FindSetLeftBit" { count (3); return (PARSEOP_FINDSETLEFTBIT); }
+"FindSetRightBit" { count (3); return (PARSEOP_FINDSETRIGHTBIT); }
+"FromBCD" { count (3); return (PARSEOP_FROMBCD); }
+"Increment" { count (3); return (PARSEOP_INCREMENT); }
+"Index" { count (3); return (PARSEOP_INDEX); }
+"LAnd" { count (3); return (PARSEOP_LAND); }
+"LEqual" { count (3); return (PARSEOP_LEQUAL); }
+"LGreater" { count (3); return (PARSEOP_LGREATER); }
+"LGreaterEqual" { count (3); return (PARSEOP_LGREATEREQUAL); }
+"LLess" { count (3); return (PARSEOP_LLESS); }
+"LLessEqual" { count (3); return (PARSEOP_LLESSEQUAL); }
+"LNot" { count (3); return (PARSEOP_LNOT); }
+"LNotEqual" { count (3); return (PARSEOP_LNOTEQUAL); }
+"LoadTable" { count (3); return (PARSEOP_LOADTABLE); }
+"LOr" { count (3); return (PARSEOP_LOR); }
+"Match" { count (3); return (PARSEOP_MATCH); }
+"Mid" { count (3); return (PARSEOP_MID); }
+"Mod" { count (3); return (PARSEOP_MOD); }
+"Multiply" { count (3); return (PARSEOP_MULTIPLY); }
+"NAnd" { count (3); return (PARSEOP_NAND); }
+"NOr" { count (3); return (PARSEOP_NOR); }
+"Not" { count (3); return (PARSEOP_NOT); }
+"ObjectType" { count (3); return (PARSEOP_OBJECTTYPE); }
+"Or" { count (3); return (PARSEOP_OR); }
+"RefOf" { count (3); return (PARSEOP_REFOF); }
+"ShiftLeft" { count (3); return (PARSEOP_SHIFTLEFT); }
+"ShiftRight" { count (3); return (PARSEOP_SHIFTRIGHT); }
+"SizeOf" { count (3); return (PARSEOP_SIZEOF); }
+"Store" { count (3); return (PARSEOP_STORE); }
+"Subtract" { count (3); return (PARSEOP_SUBTRACT); }
+"ToBCD" { count (3); return (PARSEOP_TOBCD); }
+"ToBuffer" { count (3); return (PARSEOP_TOBUFFER); }
+"ToDecimalString" { count (3); return (PARSEOP_TODECIMALSTRING); }
+"ToHexString" { count (3); return (PARSEOP_TOHEXSTRING); }
+"ToInteger" { count (3); return (PARSEOP_TOINTEGER); }
+"ToString" { count (3); return (PARSEOP_TOSTRING); }
+"Wait" { count (3); return (PARSEOP_WAIT); }
+"XOr" { count (3); return (PARSEOP_XOR); }
+
+"Arg0" { count (1); return (PARSEOP_ARG0); }
+"Arg1" { count (1); return (PARSEOP_ARG1); }
+"Arg2" { count (1); return (PARSEOP_ARG2); }
+"Arg3" { count (1); return (PARSEOP_ARG3); }
+"Arg4" { count (1); return (PARSEOP_ARG4); }
+"Arg5" { count (1); return (PARSEOP_ARG5); }
+"Arg6" { count (1); return (PARSEOP_ARG6); }
+
+"Local0" { count (1); return (PARSEOP_LOCAL0); }
+"Local1" { count (1); return (PARSEOP_LOCAL1); }
+"Local2" { count (1); return (PARSEOP_LOCAL2); }
+"Local3" { count (1); return (PARSEOP_LOCAL3); }
+"Local4" { count (1); return (PARSEOP_LOCAL4); }
+"Local5" { count (1); return (PARSEOP_LOCAL5); }
+"Local6" { count (1); return (PARSEOP_LOCAL6); }
+"Local7" { count (1); return (PARSEOP_LOCAL7); }
+
+"Debug" { count (1); return (PARSEOP_DEBUG); }
+
+"DefinitionBlock" { count (1); return (PARSEOP_DEFINITIONBLOCK); }
+"Buffer" { count (1); return (PARSEOP_BUFFER); }
+"Package" { count (1); return (PARSEOP_PACKAGE); }
+
+"EISAID" { count (1); return (PARSEOP_EISAID); }
+"ResourceTemplate" { count (1); return (PARSEOP_RESOURCETEMPLATE); }
+"Unicode" { count (1); return (PARSEOP_UNICODE); }
+"DMA" { count (1); return (PARSEOP_DMA); }
+"DWordIO" { count (1); return (PARSEOP_DWORDIO); }
+"DWordMemory" { count (1); return (PARSEOP_DWORDMEMORY); }
+"EndDependentFn" { count (1); return (PARSEOP_ENDDEPENDENTFN); }
+"FixedIO" { count (1); return (PARSEOP_FIXEDIO); }
+"Interrupt" { count (1); return (PARSEOP_INTERRUPT); }
+"IO" { count (1); return (PARSEOP_IO); }
+"IRQNoFlags" { count (1); return (PARSEOP_IRQNOFLAGS); }
+"IRQ" { count (1); return (PARSEOP_IRQ); }
+"Memory24" { count (1); return (PARSEOP_MEMORY24); }
+"Memory32Fixed" { count (1); return (PARSEOP_MEMORY32FIXED); }
+"Memory32" { count (1); return (PARSEOP_MEMORY32); }
+"QWordIO" { count (1); return (PARSEOP_QWORDIO); }
+"QWordMemory" { count (1); return (PARSEOP_QWORDMEMORY); }
+"Register" { count (1); return (PARSEOP_REGISTER); }
+"StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); }
+"StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); }
+"VendorLong" { count (1); return (PARSEOP_VENDORLONG); }
+"VendorShort" { count (1); return (PARSEOP_VENDORSHORT); }
+"WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); }
+"WordIO" { count (1); return (PARSEOP_WORDIO); }
+
+"UnknownObj" { count (0); return (PARSEOP_OBJECTTYPE_UNK); }
+"IntObj" { count (0); return (PARSEOP_OBJECTTYPE_INT); }
+"StrObj" { count (0); return (PARSEOP_OBJECTTYPE_STR); }
+"BuffObj" { count (0); return (PARSEOP_OBJECTTYPE_BUF); }
+"PkgObj" { count (0); return (PARSEOP_OBJECTTYPE_PKG); }
+"FieldUnitObj" { count (0); return (PARSEOP_OBJECTTYPE_FLD); }
+"DeviceObj" { count (0); return (PARSEOP_OBJECTTYPE_DEV); }
+"EventObj" { count (0); return (PARSEOP_OBJECTTYPE_EVT); }
+"MethodObj" { count (0); return (PARSEOP_OBJECTTYPE_MTH); }
+"MutexObj" { count (0); return (PARSEOP_OBJECTTYPE_MTX); }
+"OpRegionObj" { count (0); return (PARSEOP_OBJECTTYPE_OPR); }
+"PowerResObj" { count (0); return (PARSEOP_OBJECTTYPE_POW); }
+"ThermalZoneObj" { count (0); return (PARSEOP_OBJECTTYPE_THZ); }
+"BuffFieldObj" { count (0); return (PARSEOP_OBJECTTYPE_BFF); }
+"DDBHandleObj" { count (0); return (PARSEOP_OBJECTTYPE_DDB); }
+
+"AnyAcc" { count (0); return (PARSEOP_ACCESSTYPE_ANY); }
+"ByteAcc" { count (0); return (PARSEOP_ACCESSTYPE_BYTE); }
+"WordAcc" { count (0); return (PARSEOP_ACCESSTYPE_WORD); }
+"DWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_DWORD); }
+"QWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_QWORD); }
+"BufferAcc" { count (0); return (PARSEOP_ACCESSTYPE_BUF); }
+
+"Lock" { count (0); return (PARSEOP_LOCKRULE_LOCK); }
+"NoLock" { count (0); return (PARSEOP_LOCKRULE_NOLOCK); }
+
+"Preserve" { count (0); return (PARSEOP_UPDATERULE_PRESERVE); }
+"WriteAsOnes" { count (0); return (PARSEOP_UPDATERULE_ONES); }
+"WriteAsZeros" { count (0); return (PARSEOP_UPDATERULE_ZEROS); }
+
+"Serialized" { count (0); return (PARSEOP_SERIALIZERULE_SERIAL); }
+"NotSerialized" { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); }
+
+"SystemIO" { count (0); return (PARSEOP_REGIONSPACE_IO); }
+"SystemMemory" { count (0); return (PARSEOP_REGIONSPACE_MEM); }
+"PCI_Config" { count (0); return (PARSEOP_REGIONSPACE_PCI); }
+"EmbeddedControl" { count (0); return (PARSEOP_REGIONSPACE_EC); }
+"SMBus" { count (0); return (PARSEOP_REGIONSPACE_SMBUS); }
+"SystemCMOS" { count (0); return (PARSEOP_REGIONSPACE_CMOS); }
+"PciBarTarget" { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); }
+
+"FFixedHW" { count (0); return (PARSEOP_ADDRESSSPACE_FFIXEDHW); }
+
+"SMBQuick" { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); }
+"SMBSendReceive" { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
+"SMBByte" { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
+"SMBWord" { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
+"SMBBlock" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
+"SMBProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
+"SMBBlockProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
+
+"MTR" { count (0); return (PARSEOP_MATCHTYPE_MTR); }
+"MEQ" { count (0); return (PARSEOP_MATCHTYPE_MEQ); }
+"MLE" { count (0); return (PARSEOP_MATCHTYPE_MLE); }
+"MLT" { count (0); return (PARSEOP_MATCHTYPE_MLT); }
+"MGE" { count (0); return (PARSEOP_MATCHTYPE_MGE); }
+"MGT" { count (0); return (PARSEOP_MATCHTYPE_MGT); }
+
+"Compatibility" { count (0); return (PARSEOP_DMATYPE_COMPATIBILITY); }
+"TypeA" { count (0); return (PARSEOP_DMATYPE_A); }
+"TypeB" { count (0); return (PARSEOP_DMATYPE_B); }
+"TypeF" { count (0); return (PARSEOP_DMATYPE_F); }
+
+"BusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_MASTER); }
+"NotBusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); }
+
+"Transfer8" { count (0); return (PARSEOP_XFERTYPE_8); }
+"Transfer8_16" { count (0); return (PARSEOP_XFERTYPE_8_16); }
+"Transfer16" { count (0); return (PARSEOP_XFERTYPE_16); }
+
+"ResourceConsumer" { count (0); return (PARSEOP_RESOURCETYPE_CONSUMER); }
+"ResourceProducer" { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); }
+
+"MinFixed" { count (0); return (PARSEOP_MINTYPE_FIXED); }
+"MinNotFixed" { count (0); return (PARSEOP_MINTYPE_NOTFIXED); }
+
+"MaxFixed" { count (0); return (PARSEOP_MAXTYPE_FIXED); }
+"MaxNotFixed" { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); }
+
+"PosDecode" { count (0); return (PARSEOP_DECODETYPE_POS); }
+"SubDecode" { count (0); return (PARSEOP_DECODETYPE_SUB); }
+
+"ISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_ISAONLY); }
+"NonISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); }
+"EntireRange" { count (0); return (PARSEOP_RANGETYPE_ENTIRE); }
+
+"Cacheable" { count (0); return (PARSEOP_MEMTYPE_CACHEABLE); }
+"WriteCombining" { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); }
+"Prefetchable" { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); }
+"NonCacheable" { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); }
+
+"ReadWrite" { count (0); return (PARSEOP_READWRITETYPE_BOTH); }
+"ReadOnly" { count (0); return (PARSEOP_READWRITETYPE_READONLY); }
+
+"Edge" { count (0); return (PARSEOP_INTTYPE_EDGE); }
+"Level" { count (0); return (PARSEOP_INTTYPE_LEVEL); }
+
+"ActiveHigh" { count (0); return (PARSEOP_INTLEVEL_ACTIVEHIGH); }
+"ActiveLow" { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); }
+
+"Shared" { count (0); return (PARSEOP_SHARETYPE_SHARED); }
+"Exclusive" { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); }
+
+"Decode10" { count (0); return (PARSEOP_IODECODETYPE_10); }
+"Decode16" { count (0); return (PARSEOP_IODECODETYPE_16); }
+
+"TypeTranslation" { count (0); return (PARSEOP_TYPE_TRANSLATION); }
+"TypeStatic" { count (0); return (PARSEOP_TYPE_STATIC); }
+
+"SparseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_SPARSE); }
+"DenseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); }
+
+"AddressRangeMemory" { count (0); return (PARSEOP_ADDRESSTYPE_MEMORY); }
+"AddressRangeReserved" { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); }
+"AddressRangeNVS" { count (0); return (PARSEOP_ADDRESSTYPE_NVS); }
+"AddressRangeACPI" { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); }
+
+
+"{" { count (0); return('{'); }
+"}" { count (0); return('}'); }
+"," { count (0); return(','); }
+"(" { count (0); return('('); }
+")" { count (0); return(')'); }
+
+
+{NameSeg} { char *s;
+ count (0);
+ s=malloc (ACPI_NAME_SIZE + 1);
+ if (strcmp (AslCompilertext, "\\"))
+ {
+ strcpy (s, "____");
+ ACPI_STRUPR (AslCompilertext);
+ }
+ memcpy (s, AslCompilertext, strlen (AslCompilertext));
+ AslCompilerlval.s = s;
+ DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s);
+ return (PARSEOP_NAMESEG); }
+
+{NameString} { char *s;
+ count (0);
+ s=malloc (strlen (AslCompilertext)+1);
+ ACPI_STRUPR (AslCompilertext);
+ strcpy (s, AslCompilertext);
+ s[strlen (AslCompilertext)] = 0;
+ AslCompilerlval.s = s;
+ DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s);
+ return (PARSEOP_NAMESTRING); }
+
+"*" |
+"/" { count (1);
+ AslCompilererror ("Parse error, expecting ASL keyword or name");}
+
+. { count (1);
+ sprintf (MsgBuffer,
+ "Invalid character (0x%2.2X), expecting ASL keyword or name",
+ *AslCompilertext);
+ AslCompilererror (MsgBuffer);}
+
+<<EOF>> { if (AslPopInputFileStack ())
+ yyterminate();
+ else
+ return (PARSEOP_INCLUDE_END);};
+
+%%
+
+/*! [End] no source code translation !*/
+
+typedef struct asl_file_node
+{
+ FILE *File;
+ UINT32 CurrentLineNumber;
+ YY_BUFFER_STATE State;
+ char *Filename;
+ struct asl_file_node *Next;
+
+} ASL_FILE_NODE;
+
+ASL_FILE_NODE *InputStack = NULL;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslPopInputFileStack
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: 0 if a node was popped, -1 otherwise
+ *
+ * DESCRIPTION: Pop the top of the input file stack and point the parser to
+ * the saved parse buffer contained in the fnode. Also, set the
+ * global line counters to the saved values. This function is
+ * called when an include file reaches EOF.
+ *
+ ******************************************************************************/
+
+int
+AslPopInputFileStack (
+ void)
+{
+ ASL_FILE_NODE *Fnode;
+ FILE *InputFile = NULL;
+
+
+ Fnode = InputStack;
+ DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode);
+
+
+ if (!Fnode)
+ {
+ return -1;
+ }
+
+ /* Close the current include file */
+
+ fclose (yyin);
+
+ /* Update the top-of-stack */
+
+ InputStack = Fnode->Next;
+ InputFile = Fnode->File;
+
+ /* Reset global line counter and filename */
+
+ Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename;
+ Gbl_CurrentLineNumber = Fnode->CurrentLineNumber;
+
+ /* Point the parser to the popped file */
+
+ yy_delete_buffer (YY_CURRENT_BUFFER);
+ yy_switch_to_buffer (Fnode->State);
+
+ /* All done with this node */
+
+ ACPI_MEM_FREE (Fnode);
+ return 0;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslPushInputFileStack
+ *
+ * PARAMETERS: InputFile - Open file pointer
+ * Filename - Name of the file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Push the InputFile onto the file stack, and point the parser
+ * to this file. Called when an include file is successfully
+ * opened.
+ *
+ ******************************************************************************/
+
+void
+AslPushInputFileStack (
+ FILE *InputFile,
+ char *Filename)
+{
+ ASL_FILE_NODE *Fnode;
+ YY_BUFFER_STATE State;
+
+
+ /* Save the current state in an Fnode */
+
+ Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE));
+
+ Fnode->File = yyin;
+ Fnode->Next = InputStack;
+ Fnode->State = YY_CURRENT_BUFFER;
+ Fnode->CurrentLineNumber = Gbl_CurrentLineNumber;
+ Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename;
+
+ /* Push it on the stack */
+
+ InputStack = Fnode;
+
+ /* Point the parser to this file */
+
+ State = yy_create_buffer (InputFile, YY_BUF_SIZE);
+ yy_switch_to_buffer (State);
+
+ DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile);
+
+ /* Reset the global line count and filename */
+
+ Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
+ Gbl_CurrentLineNumber = 1;
+ yyin = InputFile;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: ResetCurrentLineBuffer
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers.
+ *
+ ******************************************************************************/
+
+void
+ResetCurrentLineBuffer (
+ void)
+{
+
+ if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle)
+ {
+ FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer,
+ Gbl_LineBufPtr - Gbl_CurrentLineBuffer);
+ }
+
+ Gbl_CurrentLineOffset += Gbl_CurrentColumn;
+ Gbl_CurrentColumn = 0;
+
+ Gbl_CurrentLineNumber++;
+ Gbl_LogicalLineNumber++;
+ Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: InsertLineBuffer
+ *
+ * PARAMETERS: SourceChar - One char from the input ASL source file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Put one character of the source file into the temp line buffer
+ *
+ ******************************************************************************/
+
+#define ASL_SPACES_PER_TAB 4
+
+void
+InsertLineBuffer (
+ int SourceChar)
+{
+ UINT32 i;
+ UINT32 Count = 1;
+
+
+ if (SourceChar == EOF)
+ {
+ return;
+ }
+
+ Gbl_InputByteCount++;
+
+ /* Handle tabs. Convert to spaces */
+
+ if (SourceChar == '\t')
+ {
+ SourceChar = ' ';
+ Count = ASL_SPACES_PER_TAB -
+ (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1));
+ }
+
+
+ for (i = 0; i < Count; i++)
+ {
+ Gbl_CurrentColumn++;
+
+ /* Insert the character into the line buffer */
+
+ *Gbl_LineBufPtr = (UINT8) SourceChar;
+ Gbl_LineBufPtr++;
+
+ if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1)))
+ {
+#if 0
+ /*
+ * Warning if we have split a long source line.
+ * <Probably overkill>
+ */
+ sprintf (MsgBuffer, "Max %d", ASL_LINE_BUFFER_SIZE);
+ AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer);
+#endif
+
+ ResetCurrentLineBuffer ();
+ }
+ else if (SourceChar == '\n')
+ {
+ /* End of line */
+
+ ResetCurrentLineBuffer ();
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: count
+ *
+ * PARAMETERS: yytext - Contains the matched keyword.
+ * Type - Keyword/Character type:
+ * 0 = anything except a keyword
+ * 1 = pseudo-keywords
+ * 2 = non-executable ASL keywords
+ * 3 = executable ASL keywords
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Count keywords and put them into the line buffer
+ *
+ ******************************************************************************/
+
+void
+count (
+ int Type)
+{
+ int i;
+
+
+ switch (Type)
+ {
+ case 2:
+ TotalKeywords++;
+ TotalNamedObjects++;
+ break;
+
+ case 3:
+ TotalKeywords++;
+ TotalExecutableOpcodes++;
+ break;
+ }
+
+ for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++)
+ {
+ InsertLineBuffer (yytext[i]);
+ *Gbl_LineBufPtr = 0;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: comment
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Process a standard comment.
+ *
+ ******************************************************************************/
+
+char
+comment (void)
+{
+ char c;
+ char c1 = 0;
+
+
+ InsertLineBuffer ('/');
+ InsertLineBuffer ('*');
+
+loop:
+
+ /* Eat chars until end-of-comment */
+
+ while ((c = (char) input()) != '*' && c != EOF)
+ {
+ InsertLineBuffer (c);
+ c1 = c;
+ }
+
+ if (c == EOF)
+ {
+ goto EarlyEOF;
+ }
+
+ /*
+ * Check for nested comment -- can help catch cases where a previous
+ * comment was accidently left unterminated
+ */
+ if ((c1 == '/') && (c == '*'))
+ {
+ AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_InputByteCount, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ }
+
+ /* Comment is closed only if the NEXT character is a slash */
+
+ InsertLineBuffer (c);
+
+ if ((c1 = (char) input()) != '/' && c1 != EOF)
+ {
+ unput(c1);
+ goto loop;
+ }
+
+ if (c1 == EOF)
+ {
+ goto EarlyEOF;
+ }
+
+ InsertLineBuffer (c1);
+ return TRUE;
+
+
+EarlyEOF:
+ /*
+ * Premature End-Of-File
+ */
+ AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: comment
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Process a new "//" comment.
+ *
+ ******************************************************************************/
+
+char
+comment2 (void)
+{
+ char c;
+
+
+ InsertLineBuffer ('/');
+ InsertLineBuffer ('/');
+
+ while ((c = (char) input()) != '\n' && c != EOF)
+ {
+ InsertLineBuffer (c);
+ }
+
+ if (c == EOF)
+ {
+ /*
+ * Premature End-Of-File
+ */
+ AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ return (FALSE);
+ }
+
+ InsertLineBuffer (c);
+ return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: literal
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Process a string literal (surrounded by quotes)
+ *
+ ******************************************************************************/
+
+#define ASL_NORMAL_CHAR 0
+#define ASL_ESCAPE_SEQUENCE 1
+#define ASL_OCTAL_CONSTANT 2
+#define ASL_HEX_CONSTANT 3
+
+char
+literal (void)
+{
+ char *s = MsgBuffer;
+ char *CleanString;
+ char StringChar;
+ UINT32 State = ASL_NORMAL_CHAR;
+ UINT32 i = 0;
+ UINT8 Digit;
+ char ConvertBuffer[4];
+
+
+ /*
+ * Eat chars until end-of-literal.
+ * NOTE: Put back the original surrounding quotes into the
+ * source line buffer.
+ */
+ InsertLineBuffer ('\"');
+ while ((StringChar = (char) input()) != EOF)
+ {
+ InsertLineBuffer (StringChar);
+
+DoCharacter:
+
+ switch (State)
+ {
+ case ASL_NORMAL_CHAR:
+
+ switch (StringChar)
+ {
+ case '\\':
+ /*
+ * Special handling for backslash-escape sequence. We will
+ * toss the backslash and translate the escape char(s).
+ */
+ State = ASL_ESCAPE_SEQUENCE;
+ continue;
+
+ case '\"':
+
+ /* String terminator */
+
+ goto CompletedString;
+ }
+ break;
+
+
+ case ASL_ESCAPE_SEQUENCE:
+
+ State = ASL_NORMAL_CHAR;
+ switch (StringChar)
+ {
+ case 'a':
+ StringChar = 0x07; /* BELL */
+ break;
+
+ case 'b':
+ StringChar = 0x08; /* BACKSPACE */
+ break;
+
+ case 'f':
+ StringChar = 0x0C; /* FORMFEED */
+ break;
+
+ case 'n':
+ StringChar = 0x0A; /* LINEFEED */
+ break;
+
+ case 'r':
+ StringChar = 0x0D; /* CARRIAGE RETURN*/
+ break;
+
+ case 't':
+ StringChar = 0x09; /* HORIZONTAL TAB */
+ break;
+
+ case 'v':
+ StringChar = 0x0B; /* VERTICAL TAB */
+ break;
+
+ case 'x':
+ State = ASL_HEX_CONSTANT;
+ i = 0;
+ continue;
+
+ case '\'': /* Single Quote */
+ case '\"': /* Double Quote */
+ case '\\': /* Backslash */
+ break;
+
+ default:
+
+ /* Check for an octal digit (0-7) */
+
+ if (ACPI_IS_OCTAL_DIGIT (StringChar))
+ {
+ State = ASL_OCTAL_CONSTANT;
+ ConvertBuffer[0] = StringChar;
+ i = 1;
+ continue;
+ }
+
+ /* Unknown escape sequence issue warning, but use the character */
+
+ AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ break;
+ }
+ break;
+
+
+ case ASL_OCTAL_CONSTANT:
+
+ /* Up to three octal digits allowed */
+
+ if (!ACPI_IS_OCTAL_DIGIT (StringChar) ||
+ (i > 2))
+ {
+ /*
+ * Reached end of the constant. Convert the assembled ASCII
+ * string and resume processing of the next character
+ */
+ ConvertBuffer[i] = 0;
+ Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8);
+
+ /* Check for NULL or non-ascii character (ignore if so) */
+
+ if ((Digit == 0) || (Digit > ACPI_ASCII_MAX))
+ {
+ AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ }
+ else
+ {
+ *s = (char) Digit;
+ s++;
+ }
+
+ State = ASL_NORMAL_CHAR;
+ goto DoCharacter;
+ break;
+ }
+
+ /* Append another digit of the constant */
+
+ ConvertBuffer[i] = StringChar;
+ i++;
+ continue;
+
+
+ case ASL_HEX_CONSTANT:
+
+ /* Up to two hex digits allowed */
+
+ if (!ACPI_IS_XDIGIT (StringChar) ||
+ (i > 1))
+ {
+ /*
+ * Reached end of the constant. Convert the assembled ASCII
+ * string and resume processing of the next character
+ */
+ ConvertBuffer[i] = 0;
+ Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16);
+
+ /* Check for NULL or non-ascii character (ignore if so) */
+
+ if ((Digit == 0) || (Digit > ACPI_ASCII_MAX))
+ {
+ AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ }
+ else
+ {
+ *s = (char) Digit;
+ s++;
+ }
+
+ State = ASL_NORMAL_CHAR;
+ goto DoCharacter;
+ break;
+ }
+
+ /* Append another digit of the constant */
+
+ ConvertBuffer[i] = StringChar;
+ i++;
+ continue;
+ }
+
+ /* Save the finished character */
+
+ *s = StringChar;
+ s++;
+ }
+
+ /*
+ * Premature End-Of-File
+ */
+ AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ return (FALSE);
+
+
+CompletedString:
+ /*
+ * Null terminate the input string and copy string to a new buffer
+ */
+ *s = 0;
+
+ CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1);
+ if (!CleanString)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ return (FALSE);
+ }
+
+ ACPI_STRCPY (CleanString, MsgBuffer);
+ AslCompilerlval.s = CleanString;
+ return (TRUE);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.y b/sys/contrib/dev/acpica/compiler/aslcompiler.y
new file mode 100644
index 0000000..307e876
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.y
@@ -0,0 +1,2902 @@
+
+%{
+/******************************************************************************
+ *
+ * Module Name: aslcompiler.y - Bison input file (ASL grammar and actions)
+ * $Revision: $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 YYDEBUG 1
+#define YYERROR_VERBOSE 1
+
+/*
+ * State stack - compiler will fault if it overflows. (Default was 200)
+ */
+#define YYINITDEPTH 600
+
+#include "aslcompiler.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "acpi.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslparse")
+
+
+/*
+ * Next statement is important - this makes everything public so that
+ * we can access some of the parser tables from other modules
+ */
+#define static
+#undef alloca
+#define alloca AslLocalAllocate
+#define YYERROR_VERBOSE 1
+
+void *
+AslLocalAllocate (unsigned int Size);
+
+/*
+ * The windows version of bison defines this incorrectly as "32768" (Not negative).
+ * Using a custom (edited binary) version of bison that defines YYFLAG as YYFBAD
+ * instead (#define YYFBAD 32768), so we can define it correctly here.
+ *
+ * The problem is that if YYFLAG is positive, the extended syntax error messages
+ * are disabled.
+ */
+
+#define YYFLAG -32768
+
+
+%}
+
+
+/*
+ * Declare the type of values in the grammar
+ */
+
+%union {
+ UINT64 i;
+ char *s;
+ ACPI_PARSE_OBJECT *n;
+}
+
+
+/*! [Begin] no source code translation */
+
+
+/*
+ * Token types: These are returned by the lexer
+ */
+
+%token <i> PARSEOP_ACCESSAS
+%token <i> PARSEOP_ACCESSATTRIB_BLOCK
+%token <i> PARSEOP_ACCESSATTRIB_BLOCK_CALL
+%token <i> PARSEOP_ACCESSATTRIB_BYTE
+%token <i> PARSEOP_ACCESSATTRIB_WORD_CALL
+%token <i> PARSEOP_ACCESSATTRIB_QUICK
+%token <i> PARSEOP_ACCESSATTRIB_SND_RCV
+%token <i> PARSEOP_ACCESSATTRIB_WORD
+%token <i> PARSEOP_ACCESSATTRIB_WORD_CALL
+%token <i> PARSEOP_ACCESSTYPE_ANY
+%token <i> PARSEOP_ACCESSTYPE_BUF
+%token <i> PARSEOP_ACCESSTYPE_BYTE
+%token <i> PARSEOP_ACCESSTYPE_DWORD
+%token <i> PARSEOP_ACCESSTYPE_QWORD
+%token <i> PARSEOP_ACCESSTYPE_WORD
+%token <i> PARSEOP_ACQUIRE
+%token <i> PARSEOP_ADD
+%token <i> PARSEOP_ADDRESSSPACE_FFIXEDHW
+%token <i> PARSEOP_ADDRESSTYPE_ACPI
+%token <i> PARSEOP_ADDRESSTYPE_MEMORY
+%token <i> PARSEOP_ADDRESSTYPE_NVS
+%token <i> PARSEOP_ADDRESSTYPE_RESERVED
+%token <i> PARSEOP_ALIAS
+%token <i> PARSEOP_AND
+%token <i> PARSEOP_ARG0
+%token <i> PARSEOP_ARG1
+%token <i> PARSEOP_ARG2
+%token <i> PARSEOP_ARG3
+%token <i> PARSEOP_ARG4
+%token <i> PARSEOP_ARG5
+%token <i> PARSEOP_ARG6
+%token <i> PARSEOP_BANKFIELD
+%token <i> PARSEOP_BREAK
+%token <i> PARSEOP_BREAKPOINT
+%token <i> PARSEOP_BUFFER
+%token <i> PARSEOP_BUSMASTERTYPE_MASTER
+%token <i> PARSEOP_BUSMASTERTYPE_NOTMASTER
+%token <i> PARSEOP_BYTECONST
+%token <i> PARSEOP_CASE
+%token <i> PARSEOP_CONCATENATE
+%token <i> PARSEOP_CONCATENATERESTEMPLATE
+%token <i> PARSEOP_CONDREFOF
+%token <i> PARSEOP_CONTINUE
+%token <i> PARSEOP_COPYOBJECT
+%token <i> PARSEOP_CREATEBITFIELD
+%token <i> PARSEOP_CREATEBYTEFIELD
+%token <i> PARSEOP_CREATEDWORDFIELD
+%token <i> PARSEOP_CREATEFIELD
+%token <i> PARSEOP_CREATEQWORDFIELD
+%token <i> PARSEOP_CREATEWORDFIELD
+%token <i> PARSEOP_DATATABLEREGION
+%token <i> PARSEOP_DEBUG
+%token <i> PARSEOP_DECODETYPE_POS
+%token <i> PARSEOP_DECODETYPE_SUB
+%token <i> PARSEOP_DECREMENT
+%token <i> PARSEOP_DEFAULT
+%token <i> PARSEOP_DEFAULT_ARG
+%token <i> PARSEOP_DEFINITIONBLOCK
+%token <i> PARSEOP_DEREFOF
+%token <i> PARSEOP_DEVICE
+%token <i> PARSEOP_DIVIDE
+%token <i> PARSEOP_DMA
+%token <i> PARSEOP_DMATYPE_A
+%token <i> PARSEOP_DMATYPE_COMPATIBILITY
+%token <i> PARSEOP_DMATYPE_B
+%token <i> PARSEOP_DMATYPE_F
+%token <i> PARSEOP_DWORDCONST
+%token <i> PARSEOP_DWORDIO
+%token <i> PARSEOP_DWORDMEMORY
+%token <i> PARSEOP_EISAID
+%token <i> PARSEOP_ELSE
+%token <i> PARSEOP_ELSEIF
+%token <i> PARSEOP_ENDDEPENDENTFN
+%token <i> PARSEOP_ERRORNODE
+%token <i> PARSEOP_EVENT
+%token <i> PARSEOP_EXTERNAL
+%token <i> PARSEOP_FATAL
+%token <i> PARSEOP_FIELD
+%token <i> PARSEOP_FINDSETLEFTBIT
+%token <i> PARSEOP_FINDSETRIGHTBIT
+%token <i> PARSEOP_FIXEDIO
+%token <i> PARSEOP_FROMBCD
+%token <i> PARSEOP_IF
+%token <i> PARSEOP_INCLUDE
+%token <i> PARSEOP_INCLUDE_CSTYLE
+%token <i> PARSEOP_INCLUDE_END
+%token <i> PARSEOP_INCREMENT
+%token <i> PARSEOP_INDEX
+%token <i> PARSEOP_INDEXFIELD
+%token <i> PARSEOP_INTEGER
+%token <i> PARSEOP_INTERRUPT
+%token <i> PARSEOP_INTLEVEL_ACTIVEHIGH
+%token <i> PARSEOP_INTLEVEL_ACTIVELOW
+%token <i> PARSEOP_INTTYPE_EDGE
+%token <i> PARSEOP_INTTYPE_LEVEL
+%token <i> PARSEOP_IO
+%token <i> PARSEOP_IODECODETYPE_10
+%token <i> PARSEOP_IODECODETYPE_16
+%token <i> PARSEOP_IRQ
+%token <i> PARSEOP_IRQNOFLAGS
+%token <i> PARSEOP_LAND
+%token <i> PARSEOP_LEQUAL
+%token <i> PARSEOP_LGREATER
+%token <i> PARSEOP_LGREATEREQUAL
+%token <i> PARSEOP_LINE_CSTYLE
+%token <i> PARSEOP_LLESS
+%token <i> PARSEOP_LLESSEQUAL
+%token <i> PARSEOP_LNOT
+%token <i> PARSEOP_LNOTEQUAL
+%token <i> PARSEOP_LOAD
+%token <i> PARSEOP_LOADTABLE
+%token <i> PARSEOP_LOCAL0
+%token <i> PARSEOP_LOCAL1
+%token <i> PARSEOP_LOCAL2
+%token <i> PARSEOP_LOCAL3
+%token <i> PARSEOP_LOCAL4
+%token <i> PARSEOP_LOCAL5
+%token <i> PARSEOP_LOCAL6
+%token <i> PARSEOP_LOCAL7
+%token <i> PARSEOP_LOCKRULE_LOCK
+%token <i> PARSEOP_LOCKRULE_NOLOCK
+%token <i> PARSEOP_LOR
+%token <i> PARSEOP_MATCH
+%token <i> PARSEOP_MATCHTYPE_MEQ
+%token <i> PARSEOP_MATCHTYPE_MGE
+%token <i> PARSEOP_MATCHTYPE_MGT
+%token <i> PARSEOP_MATCHTYPE_MLE
+%token <i> PARSEOP_MATCHTYPE_MLT
+%token <i> PARSEOP_MATCHTYPE_MTR
+%token <i> PARSEOP_MAXTYPE_FIXED
+%token <i> PARSEOP_MAXTYPE_NOTFIXED
+%token <i> PARSEOP_MEMORY24
+%token <i> PARSEOP_MEMORY32
+%token <i> PARSEOP_MEMORY32FIXED
+%token <i> PARSEOP_MEMTYPE_CACHEABLE
+%token <i> PARSEOP_MEMTYPE_NONCACHEABLE
+%token <i> PARSEOP_MEMTYPE_PREFETCHABLE
+%token <i> PARSEOP_MEMTYPE_WRITECOMBINING
+%token <i> PARSEOP_METHOD
+%token <i> PARSEOP_METHODCALL
+%token <i> PARSEOP_MID
+%token <i> PARSEOP_MINTYPE_FIXED
+%token <i> PARSEOP_MINTYPE_NOTFIXED
+%token <i> PARSEOP_MOD
+%token <i> PARSEOP_MULTIPLY
+%token <i> PARSEOP_MUTEX
+%token <i> PARSEOP_NAME
+%token <s> PARSEOP_NAMESEG
+%token <s> PARSEOP_NAMESTRING
+%token <i> PARSEOP_NAND
+%token <i> PARSEOP_NOOP
+%token <i> PARSEOP_NOR
+%token <i> PARSEOP_NOT
+%token <i> PARSEOP_NOTIFY
+%token <i> PARSEOP_OBJECTTYPE
+%token <i> PARSEOP_OBJECTTYPE_BFF
+%token <i> PARSEOP_OBJECTTYPE_BUF
+%token <i> PARSEOP_OBJECTTYPE_DDB
+%token <i> PARSEOP_OBJECTTYPE_DEV
+%token <i> PARSEOP_OBJECTTYPE_EVT
+%token <i> PARSEOP_OBJECTTYPE_FLD
+%token <i> PARSEOP_OBJECTTYPE_INT
+%token <i> PARSEOP_OBJECTTYPE_MTH
+%token <i> PARSEOP_OBJECTTYPE_MTX
+%token <i> PARSEOP_OBJECTTYPE_OPR
+%token <i> PARSEOP_OBJECTTYPE_PKG
+%token <i> PARSEOP_OBJECTTYPE_POW
+%token <i> PARSEOP_OBJECTTYPE_STR
+%token <i> PARSEOP_OBJECTTYPE_THZ
+%token <i> PARSEOP_OBJECTTYPE_UNK
+%token <i> PARSEOP_OFFSET
+%token <i> PARSEOP_ONE
+%token <i> PARSEOP_ONES
+%token <i> PARSEOP_OPERATIONREGION
+%token <i> PARSEOP_OR
+%token <i> PARSEOP_PACKAGE
+%token <i> PARSEOP_PACKAGE_LENGTH
+%token <i> PARSEOP_POWERRESOURCE
+%token <i> PARSEOP_PROCESSOR
+%token <i> PARSEOP_QWORDCONST
+%token <i> PARSEOP_QWORDIO
+%token <i> PARSEOP_QWORDMEMORY
+%token <i> PARSEOP_RANGETYPE_ENTIRE
+%token <i> PARSEOP_RANGETYPE_ISAONLY
+%token <i> PARSEOP_RANGETYPE_NONISAONLY
+%token <i> PARSEOP_RAW_DATA
+%token <i> PARSEOP_READWRITETYPE_BOTH
+%token <i> PARSEOP_READWRITETYPE_READONLY
+%token <i> PARSEOP_REFOF
+%token <i> PARSEOP_REGIONSPACE_CMOS
+%token <i> PARSEOP_REGIONSPACE_EC
+%token <i> PARSEOP_REGIONSPACE_IO
+%token <i> PARSEOP_REGIONSPACE_MEM
+%token <i> PARSEOP_REGIONSPACE_PCI
+%token <i> PARSEOP_REGIONSPACE_PCIBAR
+%token <i> PARSEOP_REGIONSPACE_SMBUS
+%token <i> PARSEOP_REGISTER
+%token <i> PARSEOP_RELEASE
+%token <i> PARSEOP_RESERVED_BYTES
+%token <i> PARSEOP_RESET
+%token <i> PARSEOP_RESOURCETEMPLATE
+%token <i> PARSEOP_RESOURCETYPE_CONSUMER
+%token <i> PARSEOP_RESOURCETYPE_PRODUCER
+%token <i> PARSEOP_RETURN
+%token <i> PARSEOP_REVISION
+%token <i> PARSEOP_SCOPE
+%token <i> PARSEOP_SERIALIZERULE_NOTSERIAL
+%token <i> PARSEOP_SERIALIZERULE_SERIAL
+%token <i> PARSEOP_SHARETYPE_EXCLUSIVE
+%token <i> PARSEOP_SHARETYPE_SHARED
+%token <i> PARSEOP_SHIFTLEFT
+%token <i> PARSEOP_SHIFTRIGHT
+%token <i> PARSEOP_SIGNAL
+%token <i> PARSEOP_SIZEOF
+%token <i> PARSEOP_SLEEP
+%token <i> PARSEOP_STALL
+%token <i> PARSEOP_STARTDEPENDENTFN
+%token <i> PARSEOP_STARTDEPENDENTFN_NOPRI
+%token <i> PARSEOP_STORE
+%token <s> PARSEOP_STRING_LITERAL
+%token <i> PARSEOP_SUBTRACT
+%token <i> PARSEOP_SWITCH
+%token <i> PARSEOP_THERMALZONE
+%token <i> PARSEOP_TOBCD
+%token <i> PARSEOP_TOBUFFER
+%token <i> PARSEOP_TODECIMALSTRING
+%token <i> PARSEOP_TOHEXSTRING
+%token <i> PARSEOP_TOINTEGER
+%token <i> PARSEOP_TOSTRING
+%token <i> PARSEOP_TRANSLATIONTYPE_DENSE
+%token <i> PARSEOP_TRANSLATIONTYPE_SPARSE
+%token <i> PARSEOP_TYPE_STATIC
+%token <i> PARSEOP_TYPE_TRANSLATION
+%token <i> PARSEOP_UNICODE
+%token <i> PARSEOP_UNLOAD
+%token <i> PARSEOP_UPDATERULE_ONES
+%token <i> PARSEOP_UPDATERULE_PRESERVE
+%token <i> PARSEOP_UPDATERULE_ZEROS
+%token <i> PARSEOP_VAR_PACKAGE
+%token <i> PARSEOP_VENDORLONG
+%token <i> PARSEOP_VENDORSHORT
+%token <i> PARSEOP_WAIT
+%token <i> PARSEOP_WHILE
+%token <i> PARSEOP_WORDBUSNUMBER
+%token <i> PARSEOP_WORDCONST
+%token <i> PARSEOP_WORDIO
+%token <i> PARSEOP_XFERTYPE_8
+%token <i> PARSEOP_XFERTYPE_8_16
+%token <i> PARSEOP_XFERTYPE_16
+%token <i> PARSEOP_XOR
+%token <i> PARSEOP_ZERO
+
+
+/*
+ * Production names
+ */
+
+%type <n> ASLCode
+%type <n> DefinitionBlockTerm
+%type <n> TermList
+%type <n> Term
+%type <n> CompilerDirective
+%type <n> ObjectList
+%type <n> Object
+%type <n> DataObject
+%type <n> BufferData
+%type <n> PackageData
+%type <n> IntegerData
+%type <n> StringData
+%type <n> NamedObject
+%type <n> NameSpaceModifier
+%type <n> UserTerm
+%type <n> ArgList
+%type <n> ArgListTail
+%type <n> TermArg
+%type <n> Target
+%type <n> RequiredTarget
+%type <n> SimpleTarget
+%type <n> BufferTermData
+
+%type <n> Type1Opcode
+%type <n> Type2Opcode
+%type <n> Type2IntegerOpcode
+%type <n> Type2StringOpcode
+%type <n> Type2BufferOpcode
+%type <n> Type2BufferOrStringOpcode
+%type <n> Type3Opcode
+
+/* Obsolete %type <n> Type4Opcode */
+
+%type <n> Type5Opcode
+%type <n> Type6Opcode
+
+%type <n> LineTerm
+%type <n> IncludeTerm
+%type <n> IncludeCStyleTerm
+%type <n> ExternalTerm
+
+%type <n> FieldUnitList
+%type <n> FieldUnitListTail
+%type <n> FieldUnit
+%type <n> FieldUnitEntry
+
+%type <n> OffsetTerm
+%type <n> AccessAsTerm
+%type <n> OptionalAccessAttribTerm
+
+
+/* Named Objects */
+
+%type <n> BankFieldTerm
+%type <n> CreateBitFieldTerm
+%type <n> CreateByteFieldTerm
+%type <n> CreateDWordFieldTerm
+%type <n> CreateFieldTerm
+%type <n> CreateQWordFieldTerm
+%type <n> CreateWordFieldTerm
+%type <n> DataRegionTerm
+%type <n> DeviceTerm
+%type <n> EventTerm
+%type <n> FieldTerm
+%type <n> IndexFieldTerm
+%type <n> MethodTerm
+%type <n> MutexTerm
+%type <n> OpRegionTerm
+%type <n> OpRegionSpaceIdTerm
+%type <n> PowerResTerm
+%type <n> ProcessorTerm
+%type <n> ThermalZoneTerm
+
+
+/* Namespace modifiers */
+
+%type <n> AliasTerm
+%type <n> NameTerm
+%type <n> ScopeTerm
+
+/* Type 1 opcodes */
+
+%type <n> BreakTerm
+%type <n> BreakPointTerm
+%type <n> ContinueTerm
+%type <n> FatalTerm
+%type <n> IfElseTerm
+%type <n> IfTerm
+%type <n> ElseTerm
+%type <n> LoadTerm
+%type <n> NoOpTerm
+%type <n> NotifyTerm
+%type <n> ReleaseTerm
+%type <n> ResetTerm
+%type <n> ReturnTerm
+%type <n> SignalTerm
+%type <n> SleepTerm
+%type <n> StallTerm
+%type <n> SwitchTerm
+%type <n> CaseTermList
+%type <n> DefaultTermList
+%type <n> CaseTerm
+%type <n> DefaultTerm
+%type <n> UnloadTerm
+%type <n> WhileTerm
+
+/* Type 2 opcodes */
+
+%type <n> AcquireTerm
+%type <n> AddTerm
+%type <n> AndTerm
+%type <n> ConcatTerm
+%type <n> ConcatResTerm
+%type <n> CondRefOfTerm
+%type <n> CopyObjectTerm
+%type <n> DecTerm
+%type <n> DerefOfTerm
+%type <n> DivideTerm
+%type <n> FindSetLeftBitTerm
+%type <n> FindSetRightBitTerm
+%type <n> FromBCDTerm
+%type <n> IncTerm
+%type <n> IndexTerm
+%type <n> LAndTerm
+%type <n> LEqualTerm
+%type <n> LGreaterTerm
+%type <n> LGreaterEqualTerm
+%type <n> LLessTerm
+%type <n> LLessEqualTerm
+%type <n> LNotTerm
+%type <n> LNotEqualTerm
+%type <n> LoadTableTerm
+%type <n> LOrTerm
+%type <n> MatchTerm
+%type <n> MidTerm
+%type <n> ModTerm
+%type <n> MultiplyTerm
+%type <n> NAndTerm
+%type <n> NOrTerm
+%type <n> NotTerm
+%type <n> ObjectTypeTerm
+%type <n> OrTerm
+%type <n> RefOfTerm
+%type <n> ShiftLeftTerm
+%type <n> ShiftRightTerm
+%type <n> SizeOfTerm
+%type <n> StoreTerm
+%type <n> SubtractTerm
+%type <n> ToBCDTerm
+%type <n> ToBufferTerm
+%type <n> ToDecimalStringTerm
+%type <n> ToHexStringTerm
+%type <n> ToIntegerTerm
+%type <n> ToStringTerm
+%type <n> WaitTerm
+%type <n> XOrTerm
+
+%type <n> OptionalTermArg
+%type <n> OptionalListString
+
+
+/* Keywords */
+
+%type <n> ObjectTypeKeyword
+%type <n> AccessTypeKeyword
+%type <n> AccessAttribKeyword
+%type <n> LockRuleKeyword
+%type <n> UpdateRuleKeyword
+%type <n> RegionSpaceKeyword
+%type <n> AddressSpaceKeyword
+%type <n> MatchOpKeyword
+%type <n> SerializeRuleKeyword
+%type <n> DMATypeKeyword
+%type <n> BusMasterKeyword
+%type <n> XferTypeKeyword
+%type <n> ResourceTypeKeyword
+%type <n> MinKeyword
+%type <n> MaxKeyword
+%type <n> DecodeKeyword
+%type <n> RangeTypeKeyword
+%type <n> MemTypeKeyword
+%type <n> ReadWriteKeyword
+%type <n> InterruptTypeKeyword
+%type <n> InterruptLevel
+%type <n> ShareTypeKeyword
+%type <n> IODecodeKeyword
+%type <n> TypeKeyword
+%type <n> TranslationKeyword
+%type <n> AddressKeyword
+
+/* Types */
+
+%type <n> SuperName
+%type <n> ArgTerm
+%type <n> LocalTerm
+%type <n> DebugTerm
+
+
+%type <n> Integer
+
+%type <n> ByteConst
+%type <n> WordConst
+%type <n> DWordConst
+%type <n> QWordConst
+
+/* Useless
+%type <n> WordConst
+%type <n> QWordConst
+*/
+
+%type <n> String
+
+%type <n> ConstTerm
+%type <n> ByteConstExpr
+%type <n> WordConstExpr
+%type <n> DWordConstExpr
+%type <n> QWordConstExpr
+%type <n> ConstExprTerm
+
+%type <n> BufferTerm
+%type <n> ByteList
+%type <n> ByteListTail
+%type <n> DWordList
+%type <n> DWordListTail
+
+%type <n> PackageTerm
+%type <n> PackageLengthTerm
+%type <n> PackageList
+%type <n> PackageListTail
+%type <n> PackageElement
+
+%type <n> VarPackageLengthTerm
+
+
+%type <n> EISAIDTerm
+%type <n> ResourceTemplateTerm
+%type <n> UnicodeTerm
+%type <n> ResourceMacroList
+%type <n> ResourceMacroTerm
+
+%type <n> DMATerm
+%type <n> DWordIOTerm
+%type <n> DWordMemoryTerm
+%type <n> EndDependentFnTerm
+%type <n> FixedIOTerm
+%type <n> InterruptTerm
+%type <n> IOTerm
+%type <n> IRQNoFlagsTerm
+%type <n> IRQTerm
+%type <n> Memory24Term
+%type <n> Memory32FixedTerm
+%type <n> Memory32Term
+%type <n> QWordIOTerm
+%type <n> QWordMemoryTerm
+%type <n> RegisterTerm
+%type <n> StartDependentFnTerm
+%type <n> StartDependentFnNoPriTerm
+%type <n> VendorLongTerm
+%type <n> VendorShortTerm
+%type <n> WordBusNumberTerm
+%type <n> WordIOTerm
+
+%type <n> NameString
+%type <n> NameSeg
+
+
+/* Local types that help construct the AML, not in ACPI spec */
+
+%type <n> IncludeEndTerm
+%type <n> AmlPackageLengthTerm
+%type <n> OptionalByteConstExpr
+%type <n> OptionalDWordConstExpr
+%type <n> OptionalSerializeRuleKeyword
+%type <n> OptionalResourceType_First
+%type <n> OptionalMinType
+%type <n> OptionalMaxType
+%type <n> OptionalMemType
+%type <n> OptionalCount
+%type <n> OptionalDecodeType
+%type <n> OptionalRangeType
+%type <n> OptionalShareType
+%type <n> OptionalType
+%type <n> OptionalType_Last
+%type <n> OptionalTranslationType_Last
+%type <n> OptionalStringData
+%type <n> OptionalNameString
+%type <n> OptionalNameString_First
+%type <n> OptionalNameString_Last
+%type <n> OptionalAddressRange
+%type <n> OptionalObjectTypeKeyword
+%type <n> OptionalReference
+
+
+%type <n> TermArgItem
+%type <n> NameStringItem
+
+%%
+
+
+/*******************************************************************************
+ *
+ * Production rules start here
+ *
+ ******************************************************************************/
+
+/*
+ * ASL Names
+ */
+
+
+/*
+ * Blocks, Data, and Opcodes
+ */
+
+ASLCode
+ : DefinitionBlockTerm
+ | error {YYABORT; $$ = NULL;}
+ ;
+
+DefinitionBlockTerm
+ : PARSEOP_DEFINITIONBLOCK '(' {$$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);}
+ String ','
+ String ','
+ ByteConst ','
+ String ','
+ String ','
+ DWordConst
+ ')' {TrSetEndLineNumber ($<n>3);}
+ '{' ObjectList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);}
+ ;
+
+TermList
+ : {$$ = NULL;}
+ | Term TermList {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);}
+ ;
+
+Term
+ : Object {}
+ | Type1Opcode {}
+ | Type2Opcode {}
+ | Type2IntegerOpcode {}
+ | Type2StringOpcode {}
+ | Type2BufferOpcode {}
+ | Type2BufferOrStringOpcode {}
+ | error {$$ = AslDoError(); yyclearin;}
+ ;
+
+CompilerDirective
+ : IncludeTerm {}
+ | IncludeCStyleTerm {$$ = NULL;}
+ | LineTerm {$$ = NULL;}
+ | ExternalTerm {}
+ ;
+
+ObjectList
+ : {$$ = NULL;}
+ | Object ObjectList {$$ = TrLinkPeerNode ($1,$2);}
+ | error {$$ = AslDoError(); yyclearin;}
+ ;
+
+Object
+ : CompilerDirective {}
+ | NamedObject {}
+ | NameSpaceModifier {}
+ ;
+
+DataObject
+ : BufferData {}
+ | PackageData {}
+ | IntegerData {}
+ | StringData {}
+ ;
+
+BufferData
+ : Type5Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
+ | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
+ | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
+ | BufferTerm {}
+ ;
+
+PackageData
+ : PackageTerm {}
+ ;
+
+IntegerData
+ : Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
+ | Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
+ | Integer {}
+ | ConstTerm {}
+ ;
+
+StringData
+ : Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
+ | String {}
+ ;
+
+NamedObject
+ : BankFieldTerm {}
+ | CreateBitFieldTerm {}
+ | CreateByteFieldTerm {}
+ | CreateDWordFieldTerm {}
+ | CreateFieldTerm {}
+ | CreateQWordFieldTerm {}
+ | CreateWordFieldTerm {}
+ | DataRegionTerm {}
+ | DeviceTerm {}
+ | EventTerm {}
+ | FieldTerm {}
+ | IndexFieldTerm {}
+ | MethodTerm {}
+ | MutexTerm {}
+ | OpRegionTerm {}
+ | PowerResTerm {}
+ | ProcessorTerm {}
+ | ThermalZoneTerm {}
+ ;
+
+NameSpaceModifier
+ : AliasTerm {}
+ | NameTerm {}
+ | ScopeTerm {}
+ ;
+
+UserTerm
+ : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);}
+ ArgList ')' {$$ = TrLinkChildNode ($1,$4);}
+ ;
+
+ArgList
+ : {$$ = NULL;}
+ | TermArg ArgListTail {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+ArgListTail
+ : {$$ = NULL;}
+ | ',' TermArg ArgListTail {$$ = TrLinkPeerNode ($2,$3);}
+ | ',' {$$ = NULL;} /* Allows a trailing comma at list end */
+ ;
+
+TermArg
+ : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
+ ;
+
+Target
+ : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */
+ | ',' {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */
+ | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);}
+ ;
+
+RequiredTarget
+ : ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);}
+ ;
+
+SimpleTarget
+ : NameString {}
+ | LocalTerm {}
+ | ArgTerm {}
+ ;
+
+
+/* Opcode types */
+
+Type1Opcode
+ : BreakTerm {}
+ | BreakPointTerm {}
+ | ContinueTerm {}
+ | FatalTerm {}
+ | IfElseTerm {}
+ | LoadTerm {}
+ | NoOpTerm {}
+ | NotifyTerm {}
+ | ReleaseTerm {}
+ | ResetTerm {}
+ | ReturnTerm {}
+ | SignalTerm {}
+ | SleepTerm {}
+ | StallTerm {}
+ | SwitchTerm {}
+ | UnloadTerm {}
+ | WhileTerm {}
+ ;
+
+Type2Opcode
+ : AcquireTerm {}
+ | CondRefOfTerm {}
+ | CopyObjectTerm {}
+ | DerefOfTerm {}
+ | ObjectTypeTerm {}
+ | RefOfTerm {}
+ | SizeOfTerm {}
+ | StoreTerm {}
+ | WaitTerm {}
+ | UserTerm {}
+ ;
+
+/*
+ * A type 2 opcode evaluates to an Integer and cannot have a destination operand
+ */
+
+Type2IntegerOpcode /* "Type3" opcodes */
+ : AddTerm {}
+ | AndTerm {}
+ | DecTerm {}
+ | DivideTerm {}
+ | FindSetLeftBitTerm {}
+ | FindSetRightBitTerm {}
+ | FromBCDTerm {}
+ | IncTerm {}
+ | IndexTerm {}
+ | LAndTerm {}
+ | LEqualTerm {}
+ | LGreaterTerm {}
+ | LGreaterEqualTerm {}
+ | LLessTerm {}
+ | LLessEqualTerm {}
+ | LNotTerm {}
+ | LNotEqualTerm {}
+ | LoadTableTerm {}
+ | LOrTerm {}
+ | MatchTerm {}
+ | ModTerm {}
+ | MultiplyTerm {}
+ | NAndTerm {}
+ | NOrTerm {}
+ | NotTerm {}
+ | OrTerm {}
+ | ShiftLeftTerm {}
+ | ShiftRightTerm {}
+ | SubtractTerm {}
+ | ToBCDTerm {}
+ | ToIntegerTerm {}
+ | XOrTerm {}
+ ;
+
+
+Type2StringOpcode /* "Type4" Opcodes */
+ : ToDecimalStringTerm {}
+ | ToHexStringTerm {}
+ | ToStringTerm {}
+ ;
+
+Type2BufferOpcode /* "Type5" Opcodes */
+ : ToBufferTerm {}
+ | ConcatResTerm {}
+ ;
+
+Type2BufferOrStringOpcode
+ : ConcatTerm {}
+ | MidTerm {}
+ ;
+
+/*
+ * A type 3 opcode evaluates to an Integer and cannot have a destination operand
+ */
+
+Type3Opcode
+ : EISAIDTerm {}
+ ;
+
+/* Obsolete
+Type4Opcode
+ : ConcatTerm {}
+ | ToDecimalStringTerm {}
+ | ToHexStringTerm {}
+ | MidTerm {}
+ | ToStringTerm {}
+ ;
+*/
+
+
+Type5Opcode
+ : ResourceTemplateTerm {}
+ | UnicodeTerm {}
+ ;
+
+Type6Opcode
+ : RefOfTerm {}
+ | DerefOfTerm {}
+ | IndexTerm {}
+ | UserTerm {}
+ ;
+
+IncludeTerm
+ : PARSEOP_INCLUDE '(' {$$ = TrCreateLeafNode (PARSEOP_INCLUDE);}
+ String ')' {$$ = TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);}
+ TermList
+ IncludeEndTerm {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);}
+ ;
+
+IncludeEndTerm
+ : PARSEOP_INCLUDE_END {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);}
+ ;
+
+IncludeCStyleTerm
+ : PARSEOP_INCLUDE_CSTYLE
+ String {FlOpenIncludeFile ($2);}
+ ;
+
+LineTerm
+ : PARSEOP_LINE_CSTYLE
+ Integer {FlSetLineNumber ($2);}
+ ;
+
+ExternalTerm
+ : PARSEOP_EXTERNAL '('
+ NameString
+ OptionalObjectTypeKeyword
+ ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,2,$3,$4);}
+ | PARSEOP_EXTERNAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Named Objects *******************************************************/
+
+
+BankFieldTerm
+ : PARSEOP_BANKFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_BANKFIELD);}
+ NameString
+ NameStringItem
+ TermArgItem
+ ',' AccessTypeKeyword
+ ',' LockRuleKeyword
+ ',' UpdateRuleKeyword
+ ')' '{'
+ FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$5,$6,$8,$10,$12,$15);}
+ | PARSEOP_BANKFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+FieldUnitList
+ : {$$ = NULL;}
+ | FieldUnit
+ FieldUnitListTail {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+FieldUnitListTail
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;} /* Allows a trailing comma at list end */
+ | ',' FieldUnit
+ FieldUnitListTail {$$ = TrLinkPeerNode ($2,$3);}
+ ;
+
+FieldUnit
+ : FieldUnitEntry {}
+ | OffsetTerm {}
+ | AccessAsTerm {}
+ ;
+
+FieldUnitEntry
+ : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);}
+ | NameSeg ','
+ AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);}
+ ;
+
+OffsetTerm
+ : PARSEOP_OFFSET '('
+ AmlPackageLengthTerm
+ ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);}
+ | PARSEOP_OFFSET '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+AccessAsTerm
+ : PARSEOP_ACCESSAS '('
+ AccessTypeKeyword
+ OptionalAccessAttribTerm
+ ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);}
+ | PARSEOP_ACCESSAS '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CreateBitFieldTerm
+ : PARSEOP_CREATEBITFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);}
+ TermArg
+ TermArgItem
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_CREATEBITFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CreateByteFieldTerm
+ : PARSEOP_CREATEBYTEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);}
+ TermArg
+ TermArgItem
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_CREATEBYTEFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CreateDWordFieldTerm
+ : PARSEOP_CREATEDWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);}
+ TermArg
+ TermArgItem
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_CREATEDWORDFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CreateFieldTerm
+ : PARSEOP_CREATEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);}
+ TermArg
+ TermArgItem
+ TermArgItem
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,TrSetNodeFlags ($7, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_CREATEFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CreateQWordFieldTerm
+ : PARSEOP_CREATEQWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);}
+ TermArg
+ TermArgItem
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_CREATEQWORDFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CreateWordFieldTerm
+ : PARSEOP_CREATEWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);}
+ TermArg
+ TermArgItem
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_CREATEWORDFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DataRegionTerm
+ : PARSEOP_DATATABLEREGION '(' {$$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);}
+ NameString
+ TermArgItem
+ TermArgItem
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$6,$7);}
+ | PARSEOP_DATATABLEREGION '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DeviceTerm
+ : PARSEOP_DEVICE '(' {$$ = TrCreateLeafNode (PARSEOP_DEVICE);}
+ NameString
+ ')' '{'
+ ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
+ | PARSEOP_DEVICE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+EventTerm
+ : PARSEOP_EVENT '(' {$$ = TrCreateLeafNode (PARSEOP_EVENT);}
+ NameString
+ ')' {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_EVENT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+FieldTerm
+ : PARSEOP_FIELD '(' {$$ = TrCreateLeafNode (PARSEOP_FIELD);}
+ NameString
+ ',' AccessTypeKeyword
+ ',' LockRuleKeyword
+ ',' UpdateRuleKeyword
+ ')' '{'
+ FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);}
+ | PARSEOP_FIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IndexFieldTerm
+ : PARSEOP_INDEXFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);}
+ NameString
+ NameStringItem
+ ',' AccessTypeKeyword
+ ',' LockRuleKeyword
+ ',' UpdateRuleKeyword
+ ')' '{'
+ FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);}
+ | PARSEOP_INDEXFIELD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+MethodTerm
+ : PARSEOP_METHOD '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);}
+ NameString
+ OptionalByteConstExpr {$$ = UtCheckIntegerRange ($5, 0, 7);}
+ OptionalSerializeRuleKeyword
+ OptionalByteConstExpr
+ ')' '{'
+ TermList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$11);}
+ | PARSEOP_METHOD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+MutexTerm
+ : PARSEOP_MUTEX '(' {$$ = TrCreateLeafNode (PARSEOP_MUTEX);}
+ NameString
+ ',' ByteConstExpr
+ ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);}
+ | PARSEOP_MUTEX '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+OpRegionTerm
+ : PARSEOP_OPERATIONREGION '(' {$$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);}
+ NameString
+ ',' OpRegionSpaceIdTerm
+ TermArgItem
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);}
+ | PARSEOP_OPERATIONREGION '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+OpRegionSpaceIdTerm
+ : RegionSpaceKeyword {}
+ | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);}
+ ;
+
+PowerResTerm
+ : PARSEOP_POWERRESOURCE '(' {$$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);}
+ NameString
+ ',' ByteConstExpr
+ ',' WordConstExpr
+ ')' '{'
+ ObjectList '}' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);}
+ | PARSEOP_POWERRESOURCE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ProcessorTerm
+ : PARSEOP_PROCESSOR '(' {$$ = TrCreateLeafNode (PARSEOP_PROCESSOR);}
+ NameString
+ ',' ByteConstExpr
+ OptionalDWordConstExpr
+ OptionalByteConstExpr
+ ')' '{'
+ ObjectList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);}
+ | PARSEOP_PROCESSOR '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ThermalZoneTerm
+ : PARSEOP_THERMALZONE '(' {$$ = TrCreateLeafNode (PARSEOP_THERMALZONE);}
+ NameString
+ ')' '{'
+ ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
+ | PARSEOP_THERMALZONE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Namespace modifiers *************************************************/
+
+
+AliasTerm
+ : PARSEOP_ALIAS '(' {$$ = TrCreateLeafNode (PARSEOP_ALIAS);}
+ NameString
+ NameStringItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));}
+ | PARSEOP_ALIAS '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+NameTerm
+ : PARSEOP_NAME '(' {$$ = TrCreateLeafNode (PARSEOP_NAME);}
+ NameString
+ ',' DataObject
+ ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);}
+ | PARSEOP_NAME '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ScopeTerm
+ : PARSEOP_SCOPE '(' {$$ = TrCreateLeafNode (PARSEOP_SCOPE);}
+ NameString
+ ')' '{'
+ ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
+ | PARSEOP_SCOPE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Type 1 opcodes *******************************************************/
+
+
+BreakTerm
+ : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);}
+ ;
+
+BreakPointTerm
+ : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);}
+ ;
+
+ContinueTerm
+ : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);}
+ ;
+
+FatalTerm
+ : PARSEOP_FATAL '(' {$$ = TrCreateLeafNode (PARSEOP_FATAL);}
+ ByteConstExpr
+ ',' DWordConstExpr
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);}
+ | PARSEOP_FATAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IfElseTerm
+ : IfTerm ElseTerm {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+IfTerm
+ : PARSEOP_IF '(' {$$ = TrCreateLeafNode (PARSEOP_IF);}
+ TermArg
+ ')' '{'
+ TermList '}'
+ {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_IF '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ElseTerm
+ : {$$ = NULL;}
+ | PARSEOP_ELSE '{' {$$ = TrCreateLeafNode (PARSEOP_ELSE);}
+ TermList '}'
+ {$$ = TrLinkChildren ($<n>3,1,$4);}
+
+ | PARSEOP_ELSEIF '(' {$$ = TrCreateLeafNode (PARSEOP_ELSEIF);}
+ TermArg
+ ')' '{'
+ TermList '}'
+ ElseTerm {$$ = TrLinkChildren ($<n>3,3,$4,$7,$9);}
+
+ | PARSEOP_ELSEIF '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LoadTerm
+ : PARSEOP_LOAD '(' {$$ = TrCreateLeafNode (PARSEOP_LOAD);}
+ NameString
+ RequiredTarget
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_LOAD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+NoOpTerm
+ : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);}
+ ;
+
+NotifyTerm
+ : PARSEOP_NOTIFY '(' {$$ = TrCreateLeafNode (PARSEOP_NOTIFY);}
+ SuperName
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_NOTIFY '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ReleaseTerm
+ : PARSEOP_RELEASE '(' {$$ = TrCreateLeafNode (PARSEOP_RELEASE);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_RELEASE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ResetTerm
+ : PARSEOP_RESET '(' {$$ = TrCreateLeafNode (PARSEOP_RESET);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_RESET '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ReturnTerm
+ : PARSEOP_RETURN '(' {$$ = TrCreateLeafNode (PARSEOP_RETURN);}
+ OptionalTermArg
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_RETURN '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+SignalTerm
+ : PARSEOP_SIGNAL '(' {$$ = TrCreateLeafNode (PARSEOP_SIGNAL);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_SIGNAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+SleepTerm
+ : PARSEOP_SLEEP '(' {$$ = TrCreateLeafNode (PARSEOP_SLEEP);}
+ TermArg
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_SLEEP '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+StallTerm
+ : PARSEOP_STALL '(' {$$ = TrCreateLeafNode (PARSEOP_STALL);}
+ TermArg
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_STALL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+SwitchTerm
+ : PARSEOP_SWITCH '(' {$$ = TrCreateLeafNode (PARSEOP_SWITCH);}
+ TermArg
+ ')' '{'
+ CaseTermList '}'
+ {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_SWITCH '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CaseTermList
+ : {$$ = NULL;}
+ | CaseTerm {}
+ | DefaultTerm
+ DefaultTermList {$$ = TrLinkPeerNode ($1,$2);}
+ | CaseTerm
+ CaseTermList {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+DefaultTermList
+ : {$$ = NULL;}
+ | CaseTerm {}
+ | CaseTerm
+ DefaultTermList {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+CaseTerm
+ : PARSEOP_CASE '(' {$$ = TrCreateLeafNode (PARSEOP_CASE);}
+ DataObject
+ ')' '{'
+ TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_CASE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DefaultTerm
+ : PARSEOP_DEFAULT '{' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT);}
+ TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_DEFAULT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+UnloadTerm
+ : PARSEOP_UNLOAD '(' {$$ = TrCreateLeafNode (PARSEOP_UNLOAD);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_UNLOAD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+WhileTerm
+ : PARSEOP_WHILE '(' {$$ = TrCreateLeafNode (PARSEOP_WHILE);}
+ TermArg
+ ')' '{' TermList '}'
+ {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_WHILE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Type 2 opcodes *******************************************************/
+
+AcquireTerm
+ : PARSEOP_ACQUIRE '(' {$$ = TrCreateLeafNode (PARSEOP_ACQUIRE);}
+ SuperName
+ ',' WordConstExpr
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$6);}
+ | PARSEOP_ACQUIRE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+AddTerm
+ : PARSEOP_ADD '(' {$$ = TrCreateLeafNode (PARSEOP_ADD);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_ADD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+AndTerm
+ : PARSEOP_AND '(' {$$ = TrCreateLeafNode (PARSEOP_AND);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_AND '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ConcatTerm
+ : PARSEOP_CONCATENATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATE);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_CONCATENATE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ConcatResTerm
+ : PARSEOP_CONCATENATERESTEMPLATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_CONCATENATERESTEMPLATE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CondRefOfTerm
+ : PARSEOP_CONDREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_CONDREFOF);}
+ SuperName
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_CONDREFOF '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+CopyObjectTerm
+ : PARSEOP_COPYOBJECT '(' {$$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);}
+ TermArg
+ ',' SimpleTarget
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));}
+ | PARSEOP_COPYOBJECT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DecTerm
+ : PARSEOP_DECREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_DECREMENT);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_DECREMENT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DerefOfTerm
+ : PARSEOP_DEREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_DEREFOF);}
+ TermArg
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_DEREFOF '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DivideTerm
+ : PARSEOP_DIVIDE '(' {$$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
+ TermArg
+ TermArgItem
+ Target
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);}
+ | PARSEOP_DIVIDE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+FindSetLeftBitTerm
+ : PARSEOP_FINDSETLEFTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_FINDSETLEFTBIT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+FindSetRightBitTerm
+ : PARSEOP_FINDSETRIGHTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_FINDSETRIGHTBIT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+FromBCDTerm
+ : PARSEOP_FROMBCD '(' {$$ = TrCreateLeafNode (PARSEOP_FROMBCD);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_FROMBCD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IncTerm
+ : PARSEOP_INCREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_INCREMENT);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_INCREMENT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IndexTerm
+ : PARSEOP_INDEX '(' {$$ = TrCreateLeafNode (PARSEOP_INDEX);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_INDEX '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LAndTerm
+ : PARSEOP_LAND '(' {$$ = TrCreateLeafNode (PARSEOP_LAND);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_LAND '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LEqualTerm
+ : PARSEOP_LEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_LEQUAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LGreaterTerm
+ : PARSEOP_LGREATER '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_LGREATER '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LGreaterEqualTerm
+ : PARSEOP_LGREATEREQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
+ | PARSEOP_LGREATEREQUAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LLessTerm
+ : PARSEOP_LLESS '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_LLESS '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LLessEqualTerm
+ : PARSEOP_LLESSEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
+ | PARSEOP_LLESSEQUAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LNotTerm
+ : PARSEOP_LNOT '(' {$$ = TrCreateLeafNode (PARSEOP_LNOT);}
+ TermArg
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_LNOT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LNotEqualTerm
+ : PARSEOP_LNOTEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
+ | PARSEOP_LNOTEQUAL '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LoadTableTerm
+ : PARSEOP_LOADTABLE '(' {$$ = TrCreateLeafNode (PARSEOP_LOADTABLE);}
+ TermArg
+ TermArgItem
+ TermArgItem
+ OptionalListString
+ OptionalListString
+ OptionalReference
+ ')' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$6,$7,$8,$9);}
+ | PARSEOP_LOADTABLE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+LOrTerm
+ : PARSEOP_LOR '(' {$$ = TrCreateLeafNode (PARSEOP_LOR);}
+ TermArg
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_LOR '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+MatchTerm
+ : PARSEOP_MATCH '(' {$$ = TrCreateLeafNode (PARSEOP_MATCH);}
+ TermArg
+ ',' MatchOpKeyword
+ TermArgItem
+ ',' MatchOpKeyword
+ TermArgItem
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$7,$9,$10,$11);}
+ | PARSEOP_MATCH '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+MidTerm
+ : PARSEOP_MID '(' {$$ = TrCreateLeafNode (PARSEOP_MID);}
+ TermArg
+ TermArgItem
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);}
+ | PARSEOP_MID '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ModTerm
+ : PARSEOP_MOD '(' {$$ = TrCreateLeafNode (PARSEOP_MOD);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_MOD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+MultiplyTerm
+ : PARSEOP_MULTIPLY '(' {$$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_MULTIPLY '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+NAndTerm
+ : PARSEOP_NAND '(' {$$ = TrCreateLeafNode (PARSEOP_NAND);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_NAND '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+NOrTerm
+ : PARSEOP_NOR '(' {$$ = TrCreateLeafNode (PARSEOP_NOR);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_NOR '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+NotTerm
+ : PARSEOP_NOT '(' {$$ = TrCreateLeafNode (PARSEOP_NOT);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_NOT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ObjectTypeTerm
+ : PARSEOP_OBJECTTYPE '(' {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_OBJECTTYPE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+OrTerm
+ : PARSEOP_OR '(' {$$ = TrCreateLeafNode (PARSEOP_OR);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_OR '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+/*
+ * In RefOf, the node isn't really a target, but we can't keep track of it after
+ * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.)
+ */
+RefOfTerm
+ : PARSEOP_REFOF '(' {$$ = TrCreateLeafNode (PARSEOP_REFOF);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_TARGET));}
+ | PARSEOP_REFOF '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ShiftLeftTerm
+ : PARSEOP_SHIFTLEFT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_SHIFTLEFT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ShiftRightTerm
+ : PARSEOP_SHIFTRIGHT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_SHIFTRIGHT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+SizeOfTerm
+ : PARSEOP_SIZEOF '(' {$$ = TrCreateLeafNode (PARSEOP_SIZEOF);}
+ SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_SIZEOF '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+StoreTerm
+ : PARSEOP_STORE '(' {$$ = TrCreateLeafNode (PARSEOP_STORE);}
+ TermArg
+ ',' SuperName
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));}
+ | PARSEOP_STORE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+SubtractTerm
+ : PARSEOP_SUBTRACT '(' {$$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_SUBTRACT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ToBCDTerm
+ : PARSEOP_TOBCD '(' {$$ = TrCreateLeafNode (PARSEOP_TOBCD);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_TOBCD '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ToBufferTerm
+ : PARSEOP_TOBUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_TOBUFFER);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_TOBUFFER '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ToDecimalStringTerm
+ : PARSEOP_TODECIMALSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_TODECIMALSTRING '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ToHexStringTerm
+ : PARSEOP_TOHEXSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_TOHEXSTRING '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ToIntegerTerm
+ : PARSEOP_TOINTEGER '(' {$$ = TrCreateLeafNode (PARSEOP_TOINTEGER);}
+ TermArg
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_TOINTEGER '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ToStringTerm
+ : PARSEOP_TOSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOSTRING);}
+ TermArg
+ OptionalCount
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_TOSTRING '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+WaitTerm
+ : PARSEOP_WAIT '(' {$$ = TrCreateLeafNode (PARSEOP_WAIT);}
+ SuperName
+ TermArgItem
+ ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
+ | PARSEOP_WAIT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+XOrTerm
+ : PARSEOP_XOR '(' {$$ = TrCreateLeafNode (PARSEOP_XOR);}
+ TermArg
+ TermArgItem
+ Target
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
+ | PARSEOP_XOR '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Keywords *************************************************************/
+
+
+ObjectTypeKeyword
+ : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);}
+ | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);}
+ | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);}
+ | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);}
+ | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);}
+ | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);}
+ | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);}
+ | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);}
+ | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);}
+ | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);}
+ | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);}
+ | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);}
+ | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);}
+ | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);}
+ | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);}
+ ;
+
+AccessTypeKeyword
+ : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);}
+ | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);}
+ | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);}
+ | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);}
+ | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);}
+ | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);}
+ ;
+
+AccessAttribKeyword
+ : PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );}
+ | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);}
+ | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);}
+ | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);}
+ | PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);}
+ | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);}
+ | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);}
+ ;
+
+LockRuleKeyword
+ : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);}
+ | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);}
+ ;
+
+UpdateRuleKeyword
+ : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);}
+ | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);}
+ | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);}
+ ;
+
+
+RegionSpaceKeyword
+ : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);}
+ | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);}
+ | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);}
+ | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);}
+ | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);}
+ | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);}
+ | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);}
+ ;
+
+AddressSpaceKeyword
+ : ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);}
+ | RegionSpaceKeyword {}
+ | PARSEOP_ADDRESSSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_ADDRESSSPACE_FFIXEDHW);}
+ ;
+
+
+SerializeRuleKeyword
+ : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);}
+ | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);}
+ ;
+
+MatchOpKeyword
+ : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);}
+ | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);}
+ | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);}
+ | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);}
+ | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);}
+ | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);}
+ ;
+
+DMATypeKeyword
+ : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);}
+ | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);}
+ | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);}
+ | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);}
+ ;
+
+BusMasterKeyword
+ : PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);}
+ | PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);}
+ ;
+
+XferTypeKeyword
+ : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);}
+ | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);}
+ | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);}
+ ;
+
+ResourceTypeKeyword
+ : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);}
+ | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);}
+ ;
+
+MinKeyword
+ : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);}
+ | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);}
+ ;
+
+MaxKeyword
+ : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);}
+ | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);}
+ ;
+
+DecodeKeyword
+ : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);}
+ | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);}
+ ;
+
+RangeTypeKeyword
+ : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);}
+ | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);}
+ | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);}
+ ;
+
+MemTypeKeyword
+ : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);}
+ | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);}
+ | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);}
+ | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);}
+ ;
+
+ReadWriteKeyword
+ : PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);}
+ | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);}
+ ;
+
+InterruptTypeKeyword
+ : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);}
+ | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);}
+ ;
+
+InterruptLevel
+ : PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);}
+ | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);}
+ ;
+
+ShareTypeKeyword
+ : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);}
+ | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);}
+ ;
+
+IODecodeKeyword
+ : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);}
+ | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);}
+ ;
+
+TypeKeyword
+ : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);}
+ | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);}
+ ;
+
+TranslationKeyword
+ : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);}
+ | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);}
+ ;
+
+AddressKeyword
+ : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);}
+ | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);}
+ | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);}
+ | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);}
+ ;
+
+
+/******* Miscellaneous Types **************************************************/
+
+
+SuperName
+ : NameString {}
+ | ArgTerm {}
+ | LocalTerm {}
+ | DebugTerm {}
+ | Type6Opcode {}
+/* | UserTerm {} */ /* Caused reduce/reduce with Type6Opcode->UserTerm */
+ ;
+
+ArgTerm
+ : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);}
+ | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);}
+ | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);}
+ | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);}
+ | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);}
+ | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);}
+ | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);}
+ ;
+
+LocalTerm
+ : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);}
+ | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);}
+ | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);}
+ | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);}
+ | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);}
+ | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);}
+ | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);}
+ | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);}
+ ;
+
+DebugTerm
+ : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);}
+ ;
+
+
+ByteConst
+ : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
+ ;
+
+WordConst
+ : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
+ ;
+
+DWordConst
+ : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
+ ;
+
+QWordConst
+ : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
+ ;
+
+Integer
+ : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);}
+ ;
+
+String
+ : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);}
+ ;
+
+ConstTerm
+ : ConstExprTerm {}
+ | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);}
+ ;
+
+ByteConstExpr
+ : Type3Opcode {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
+ | Type2IntegerOpcode {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
+ | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
+ | ByteConst {}
+ ;
+
+WordConstExpr
+ : Type3Opcode {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
+ | Type2IntegerOpcode {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
+ | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
+ | WordConst {}
+ ;
+
+DWordConstExpr
+ : Type3Opcode {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
+ | Type2IntegerOpcode {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
+ | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
+ | DWordConst {}
+ ;
+
+QWordConstExpr
+ : Type3Opcode {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
+ | Type2IntegerOpcode {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
+ | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
+ | QWordConst {}
+ ;
+
+ConstExprTerm
+ : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);}
+ | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);}
+ | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, 0xFFFFFFFFFFFFFFFF);}
+ ;
+
+/* OptionalCount must appear before ByteList or an incorrect reduction will result */
+
+OptionalCount
+ : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */
+ | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */
+ | ',' TermArg {$$ = $2;}
+ ;
+
+
+BufferTerm
+ : PARSEOP_BUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_BUFFER);}
+ OptionalTermArg
+ ')' '{'
+ BufferTermData '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_BUFFER '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+BufferTermData
+ : ByteList {}
+ | StringData {}
+ ;
+
+ByteList
+ : {$$ = NULL;}
+ | ByteConstExpr
+ ByteListTail {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+ByteListTail
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;} /* Allows a trailing comma at list end */
+ | ',' ByteConstExpr
+ ByteListTail {$$ = TrLinkPeerNode ($2,$3);}
+ ;
+
+DWordList
+ : {$$ = NULL;}
+ | DWordConstExpr
+ DWordListTail {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+DWordListTail
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;} /* Allows a trailing comma at list end */
+ | ',' DWordConstExpr
+ DWordListTail {$$ = TrLinkPeerNode ($2,$3);}
+ ;
+
+PackageTerm
+ : PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_PACKAGE);}
+ PackageLengthTerm
+ ')' '{'
+ PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);}
+ VarPackageLengthTerm
+ ')' '{'
+ PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_PACKAGE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+PackageLengthTerm
+ : {$$ = NULL;}
+ | ByteConstExpr {}
+ ;
+
+VarPackageLengthTerm
+ : TermArg {}
+ ;
+
+PackageList
+ : {$$ = NULL;}
+ | PackageElement
+ PackageListTail {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+PackageListTail
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;} /* Allows a trailing comma at list end */
+ | ',' PackageElement
+ PackageListTail {$$ = TrLinkPeerNode ($2,$3);}
+ ;
+
+PackageElement
+ : DataObject {}
+ | NameString {}
+ ;
+
+EISAIDTerm
+ : PARSEOP_EISAID '('
+ StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);}
+ | PARSEOP_EISAID '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Resources and Memory ***********************************************/
+
+
+ResourceTemplateTerm
+ : PARSEOP_RESOURCETEMPLATE '(' ')'
+ '{'
+ ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,3,
+ TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
+ TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$5);}
+ ;
+
+UnicodeTerm
+ : PARSEOP_UNICODE '(' {$$ = TrCreateLeafNode (PARSEOP_UNICODE);}
+ StringData
+ ')' {$$ = TrLinkChildren ($<n>3,2,0,$4);}
+ | PARSEOP_UNICODE '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+ResourceMacroList
+ : {$$ = NULL;}
+ | ResourceMacroTerm
+ ResourceMacroList {$$ = TrLinkPeerNode ($1,$2);}
+ ;
+
+ResourceMacroTerm
+ : DMATerm {}
+ | DWordIOTerm {}
+ | DWordMemoryTerm {}
+ | EndDependentFnTerm {}
+ | FixedIOTerm {}
+ | InterruptTerm {}
+ | IOTerm {}
+ | IRQNoFlagsTerm {}
+ | IRQTerm {}
+ | Memory24Term {}
+ | Memory32FixedTerm {}
+ | Memory32Term {}
+ | QWordIOTerm {}
+ | QWordMemoryTerm {}
+ | RegisterTerm {}
+ | StartDependentFnTerm {}
+ | StartDependentFnNoPriTerm {}
+ | VendorLongTerm {}
+ | VendorShortTerm {}
+ | WordBusNumberTerm {}
+ | WordIOTerm {}
+ ;
+
+DMATerm
+ : PARSEOP_DMA '(' {$$ = TrCreateLeafNode (PARSEOP_DMA);}
+ DMATypeKeyword
+ ',' BusMasterKeyword
+ ',' XferTypeKeyword
+ OptionalNameString_Last
+ ')' '{'
+ ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$9,$12);}
+ | PARSEOP_DMA '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DWordIOTerm
+ : PARSEOP_DWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDIO);}
+ OptionalResourceType_First
+ OptionalMinType
+ OptionalMaxType
+ OptionalDecodeType
+ OptionalRangeType
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString
+ OptionalType
+ OptionalTranslationType_Last
+ ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);}
+ | PARSEOP_DWORDIO '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+DWordMemoryTerm
+ : PARSEOP_DWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);}
+ OptionalResourceType_First
+ OptionalDecodeType
+ OptionalMinType
+ OptionalMaxType
+ OptionalMemType
+ ',' ReadWriteKeyword
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString
+ OptionalAddressRange
+ OptionalType_Last
+ ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);}
+ | PARSEOP_DWORDMEMORY '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+EndDependentFnTerm
+ : PARSEOP_ENDDEPENDENTFN '('
+ ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);}
+ | PARSEOP_ENDDEPENDENTFN '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+FixedIOTerm
+ : PARSEOP_FIXEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDIO);}
+ WordConstExpr
+ ',' ByteConstExpr
+ OptionalNameString_Last
+ ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);}
+ | PARSEOP_FIXEDIO '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+InterruptTerm
+ : PARSEOP_INTERRUPT '(' {$$ = TrCreateLeafNode (PARSEOP_INTERRUPT);}
+ OptionalResourceType_First
+ ',' InterruptTypeKeyword
+ ',' InterruptLevel
+ OptionalShareType
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString_Last
+ ')' '{'
+ DWordList '}' {$$ = TrLinkChildren ($<n>3,8,$4,$6,$8,$9,$10,$11,$12,$15);}
+ | PARSEOP_INTERRUPT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IOTerm
+ : PARSEOP_IO '(' {$$ = TrCreateLeafNode (PARSEOP_IO);}
+ IODecodeKeyword
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' ByteConstExpr
+ ',' ByteConstExpr
+ OptionalNameString_Last
+ ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);}
+ | PARSEOP_IO '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IRQNoFlagsTerm
+ : PARSEOP_IRQNOFLAGS '(' {$$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);}
+ OptionalNameString_First
+ ')' '{'
+ ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_IRQNOFLAGS '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+IRQTerm
+ : PARSEOP_IRQ '(' {$$ = TrCreateLeafNode (PARSEOP_IRQ);}
+ InterruptTypeKeyword
+ ',' InterruptLevel
+ OptionalShareType
+ OptionalNameString_Last
+ ')' '{'
+ ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$7,$8,$11);}
+ | PARSEOP_IRQ '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+Memory24Term
+ : PARSEOP_MEMORY24 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY24);}
+ ReadWriteKeyword
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ OptionalNameString_Last
+ ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);}
+ | PARSEOP_MEMORY24 '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+Memory32FixedTerm
+ : PARSEOP_MEMORY32FIXED '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);}
+ ReadWriteKeyword
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ OptionalNameString_Last
+ ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$9);}
+ | PARSEOP_MEMORY32FIXED '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+Memory32Term
+ : PARSEOP_MEMORY32 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32);}
+ ReadWriteKeyword
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ ',' DWordConstExpr
+ OptionalNameString_Last
+ ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);}
+ | PARSEOP_MEMORY32 '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+QWordIOTerm
+ : PARSEOP_QWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDIO);}
+ OptionalResourceType_First
+ OptionalMinType
+ OptionalMaxType
+ OptionalDecodeType
+ OptionalRangeType
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString
+ OptionalType
+ OptionalTranslationType_Last
+ ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);}
+ | PARSEOP_QWORDIO '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+QWordMemoryTerm
+ : PARSEOP_QWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);}
+ OptionalResourceType_First
+ OptionalDecodeType
+ OptionalMinType
+ OptionalMaxType
+ OptionalMemType
+ ',' ReadWriteKeyword
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ ',' QWordConstExpr
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString
+ OptionalAddressRange
+ OptionalType_Last
+ ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);}
+ | PARSEOP_QWORDMEMORY '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+RegisterTerm
+ : PARSEOP_REGISTER '(' {$$ = TrCreateLeafNode (PARSEOP_REGISTER);}
+ AddressSpaceKeyword
+ ',' ByteConstExpr
+ ',' ByteConstExpr
+ ',' QWordConstExpr
+ ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$10);}
+ | PARSEOP_REGISTER '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+StartDependentFnTerm
+ : PARSEOP_STARTDEPENDENTFN '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);}
+ ByteConstExpr
+ ',' ByteConstExpr
+ ')' '{'
+ ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$9);}
+ | PARSEOP_STARTDEPENDENTFN '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+StartDependentFnNoPriTerm
+ : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);}
+ ')' '{'
+ ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,1,$6);}
+ | PARSEOP_STARTDEPENDENTFN_NOPRI '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+VendorLongTerm
+ : PARSEOP_VENDORLONG '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORLONG);}
+ OptionalNameString_First
+ ')' '{'
+ ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_VENDORLONG '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+VendorShortTerm
+ : PARSEOP_VENDORSHORT '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);}
+ OptionalNameString_First
+ ')' '{'
+ ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
+ | PARSEOP_VENDORSHORT '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+WordBusNumberTerm
+ : PARSEOP_WORDBUSNUMBER '(' {$$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);}
+ OptionalResourceType_First
+ OptionalMinType
+ OptionalMaxType
+ OptionalDecodeType
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString_Last
+ ')' {$$ = TrLinkChildren ($<n>3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);}
+ | PARSEOP_WORDBUSNUMBER '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+WordIOTerm
+ : PARSEOP_WORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_WORDIO);}
+ OptionalResourceType_First
+ OptionalMinType
+ OptionalMaxType
+ OptionalDecodeType
+ OptionalRangeType
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ ',' WordConstExpr
+ OptionalByteConstExpr
+ OptionalStringData
+ OptionalNameString
+ OptionalType
+ OptionalTranslationType_Last
+ ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);}
+ | PARSEOP_WORDIO '('
+ error ')' {$$ = AslDoError(); yyclearin;}
+ ;
+
+
+/******* Object References ***********************************************/
+
+
+NameString
+ : NameSeg {}
+ | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);}
+ ;
+
+NameSeg
+ : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);}
+ ;
+
+
+/******* Helper rules ****************************************************/
+
+
+AmlPackageLengthTerm
+ : Integer {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);}
+ ;
+
+OptionalAccessAttribTerm
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' ByteConstExpr {$$ = $2;}
+ | ',' AccessAttribKeyword {$$ = $2;}
+ ;
+
+OptionalAddressRange
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' AddressKeyword {$$ = $2;}
+ ;
+
+OptionalByteConstExpr
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' ByteConstExpr {$$ = $2;}
+ ;
+
+OptionalDecodeType
+ : ',' {$$ = NULL;}
+ | ',' DecodeKeyword {$$ = $2;}
+ ;
+
+OptionalDWordConstExpr
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' DWordConstExpr {$$ = $2;}
+ ;
+
+OptionalListString
+ : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */
+ | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */
+ | ',' TermArg {$$ = $2;}
+ ;
+
+OptionalMaxType
+ : ',' {$$ = NULL;}
+ | ',' MaxKeyword {$$ = $2;}
+ ;
+
+OptionalMemType
+ : ',' {$$ = NULL;}
+ | ',' MemTypeKeyword {$$ = $2;}
+ ;
+
+OptionalMinType
+ : ',' {$$ = NULL;}
+ | ',' MinKeyword {$$ = $2;}
+ ;
+
+OptionalNameString
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' NameString {$$ = $2;}
+ ;
+
+OptionalNameString_Last
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' NameString {$$ = $2;}
+ ;
+
+OptionalNameString_First
+ : {$$ = TrCreateLeafNode (PARSEOP_ZERO);}
+ | NameString {$$ = $1;}
+ ;
+
+OptionalObjectTypeKeyword
+ : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);}
+ | ',' ObjectTypeKeyword {$$ = $2;}
+ ;
+
+OptionalRangeType
+ : ',' {$$ = NULL;}
+ | ',' RangeTypeKeyword {$$ = $2;}
+ ;
+
+OptionalReference
+ : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */
+ | ',' {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */
+ | ',' DataObject {$$ = $2;}
+ | ',' NameString {$$ = $2;}
+ ;
+
+OptionalResourceType_First
+ : {$$ = NULL;}
+ | ResourceTypeKeyword {$$ = $1;}
+ ;
+
+OptionalSerializeRuleKeyword
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' SerializeRuleKeyword {$$ = $2;}
+ ;
+
+OptionalShareType
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' ShareTypeKeyword {$$ = $2;}
+ ;
+
+OptionalStringData
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' StringData {$$ = $2;}
+ ;
+
+OptionalTermArg
+ : {$$ = NULL;}
+ | TermArg {$$ = $1;}
+ ;
+
+OptionalType
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' TypeKeyword {$$ = $2;}
+ ;
+
+OptionalType_Last
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' TypeKeyword {$$ = $2;}
+ ;
+
+OptionalTranslationType_Last
+ : {$$ = NULL;}
+ | ',' {$$ = NULL;}
+ | ',' TranslationKeyword {$$ = $2;}
+ ;
+
+
+TermArgItem
+ : ',' TermArg {$$ = $2;}
+ | ',' error {$$ = AslDoError (); yyclearin;}
+ ;
+
+NameStringItem
+ : ',' NameString {$$ = $2;}
+ | ',' error {$$ = AslDoError (); yyclearin;}
+ ;
+
+
+%%
+
+
+/*
+ * Local support functions
+ */
+
+int
+AslCompilerwrap(void)
+{
+ return 1;
+}
+
+/*! [End] no source code translation !*/
+
+void *
+AslLocalAllocate (unsigned int Size)
+{
+ void *Mem;
+
+
+ DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %d\n\n", Size);
+
+ Mem = ACPI_MEM_CALLOCATE (Size);
+ if (!Mem)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_InputByteCount, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ exit (1);
+ }
+
+ return (Mem);
+}
+
+ACPI_PARSE_OBJECT *
+AslDoError (void)
+{
+
+
+ return (TrCreateLeafNode (PARSEOP_ERRORNODE));
+
+}
diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c
new file mode 100644
index 0000000..6ab54ff
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslerror.c
@@ -0,0 +1,621 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslerror - Error handling and statistics
+ * $Revision: 82 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ASL_EXCEPTIONS
+#include "aslcompiler.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslerror")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AeAddToErrorLog
+ *
+ * PARAMETERS: Enode - An error node to add to the log
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Add a new error node to the error log. The error log is
+ * ordered by the "logical" line number (cumulative line number
+ * including all include files.)
+ *
+ ******************************************************************************/
+
+void
+AeAddToErrorLog (
+ ASL_ERROR_MSG *Enode)
+{
+ ASL_ERROR_MSG *Next;
+ ASL_ERROR_MSG *Prev;
+
+
+ if (!Gbl_ErrorLog)
+ {
+ Gbl_ErrorLog = Enode;
+ return;
+ }
+
+ /* List is sorted according to line number */
+
+ if (!Gbl_ErrorLog)
+ {
+ Gbl_ErrorLog = Enode;
+ return;
+ }
+
+ /* Walk error list until we find a line number greater than ours */
+
+ Prev = NULL;
+ Next = Gbl_ErrorLog;
+
+ while ((Next) &&
+ (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
+ {
+ Prev = Next;
+ Next = Next->Next;
+ }
+
+ /* Found our place in the list */
+
+ Enode->Next = Next;
+
+ if (Prev)
+ {
+ Prev->Next = Enode;
+ }
+ else
+ {
+ Gbl_ErrorLog = Enode;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AePrintException
+ *
+ * PARAMETERS: Where - Where to send the message
+ * Enode - Error node to print
+ * Header - Additional text before each message
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print the contents of an error node.
+ *
+ * NOTE: We don't use the FlxxxFile I/O functions here because on error
+ * they abort the compiler and call this function! Since we
+ * are reporting errors here, we ignore most output errors and
+ * just try to get out as much as we can.
+ *
+ ******************************************************************************/
+
+void
+AePrintException (
+ UINT32 FileId,
+ ASL_ERROR_MSG *Enode,
+ char *Header)
+{
+ UINT8 SourceByte;
+ UINT32 Actual;
+ UINT32 MsgLength;
+ char *MainMessage;
+ char *ExtraMessage;
+ UINT32 SourceColumn;
+ UINT32 ErrorColumn;
+ FILE *OutputFile;
+ FILE *SourceFile;
+
+
+ /* Only listing files have a header, and remarks/optimizations are always output */
+
+ if (!Header)
+ {
+ /* Ignore remarks if requested */
+
+ switch (Enode->Level)
+ {
+ case ASL_REMARK:
+ if (!Gbl_DisplayRemarks)
+ {
+ return;
+ }
+ break;
+
+ case ASL_OPTIMIZATION:
+ if (!Gbl_DisplayOptimizations)
+ {
+ return;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /* Get the file handles */
+
+ OutputFile = Gbl_Files[FileId].Handle;
+ SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
+
+ if (Header)
+ {
+ fprintf (OutputFile, "%s", Header);
+ }
+
+ /* Print filename and line number if present and valid */
+
+ if (Enode->Filename)
+ {
+ if (Gbl_VerboseErrors)
+ {
+ fprintf (OutputFile, "%6s", Enode->Filename);
+
+ if (Enode->LineNumber)
+ {
+ fprintf (OutputFile, "%6u: ", Enode->LineNumber);
+
+ /*
+ * Seek to the offset in the combined source file, read the source
+ * line, and write it to the output.
+ */
+ Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, SEEK_SET);
+ if (Actual)
+ {
+ fprintf (OutputFile, "[*** iASL: Seek error on source code temp file ***]");
+ }
+ else
+ {
+ Actual = fread (&SourceByte, 1, 1, SourceFile);
+ if (!Actual)
+ {
+ fprintf (OutputFile, "[*** iASL: Read error on source code temp file ***]");
+ }
+
+ else while (Actual && SourceByte && (SourceByte != '\n'))
+ {
+ fwrite (&SourceByte, 1, 1, OutputFile);
+ Actual = fread (&SourceByte, 1, 1, SourceFile);
+ }
+ }
+ fprintf (OutputFile, "\n");
+ }
+ }
+ else
+ {
+ fprintf (OutputFile, "%s", Enode->Filename);
+
+ if (Enode->LineNumber)
+ {
+ fprintf (OutputFile, "(%u) : ", Enode->LineNumber);
+ }
+ }
+ }
+
+ /* NULL message ID, just print the raw message */
+
+ if (Enode->MessageId == 0)
+ {
+ fprintf (OutputFile, "%s\n", Enode->Message);
+ }
+ else
+ {
+ /* Decode the message ID */
+
+ fprintf (OutputFile, "%s %4.4d -",
+ AslErrorLevel[Enode->Level],
+ Enode->MessageId + ((Enode->Level+1) * 1000));
+
+ MainMessage = AslMessages[Enode->MessageId];
+ ExtraMessage = Enode->Message;
+
+ if (Enode->LineNumber)
+ {
+ MsgLength = strlen (MainMessage);
+ if (MsgLength == 0)
+ {
+ MainMessage = Enode->Message;
+
+ MsgLength = strlen (MainMessage);
+ ExtraMessage = NULL;
+ }
+
+ if (Gbl_VerboseErrors)
+ {
+ SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
+ ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
+
+ if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
+ {
+ fprintf (OutputFile, "%*s%s",
+ (int) ((SourceColumn - 1) - ErrorColumn),
+ MainMessage, " ^ ");
+ }
+ else
+ {
+ fprintf (OutputFile, "%*s %s",
+ (int) ((SourceColumn - ErrorColumn) + 1), "^",
+ MainMessage);
+ }
+ }
+ else
+ {
+ fprintf (OutputFile, " %s", MainMessage);
+ }
+
+ /* Print the extra info message if present */
+
+ if (ExtraMessage)
+ {
+ fprintf (OutputFile, " (%s)", ExtraMessage);
+ }
+
+ fprintf (OutputFile, "\n");
+ if (Gbl_VerboseErrors)
+ {
+ fprintf (OutputFile, "\n");
+ }
+ }
+ else
+ {
+ fprintf (OutputFile, " %s %s\n\n",
+ MainMessage,
+ ExtraMessage);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AePrintErrorLog
+ *
+ * PARAMETERS: FileId - Where to output the error log
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print the entire contents of the error log
+ *
+ ******************************************************************************/
+
+void
+AePrintErrorLog (
+ UINT32 FileId)
+{
+ ASL_ERROR_MSG *Enode = Gbl_ErrorLog;
+
+
+ /* Walk the error node list */
+
+ while (Enode)
+ {
+ AePrintException (FileId, Enode, NULL);
+ Enode = Enode->Next;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslCommonError
+ *
+ * PARAMETERS: Level - Seriousness (Warning/error, etc.)
+ * MessageId - Index into global message buffer
+ * CurrentLineNumber - Actual file line number
+ * LogicalLineNumber - Cumulative line number
+ * LogicalByteOffset - Byte offset in source file
+ * Column - Column in current line
+ * Filename - source filename
+ * ExtraMessage - additional error message
+ *
+ * RETURN: New error node for this error
+ *
+ * DESCRIPTION: Create a new error node and add it to the error log
+ *
+ ******************************************************************************/
+
+void
+AslCommonError (
+ UINT8 Level,
+ UINT8 MessageId,
+ UINT32 CurrentLineNumber,
+ UINT32 LogicalLineNumber,
+ UINT32 LogicalByteOffset,
+ UINT32 Column,
+ char *Filename,
+ char *ExtraMessage)
+{
+ UINT32 MessageSize;
+ char *MessageBuffer = NULL;
+ ASL_ERROR_MSG *Enode;
+
+
+ Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
+
+ if (ExtraMessage)
+ {
+ /* Allocate a buffer for the message and a new error node */
+
+ MessageSize = strlen (ExtraMessage) + 1;
+ MessageBuffer = UtLocalCalloc (MessageSize);
+
+ /* Keep a copy of the extra message */
+
+ ACPI_STRCPY (MessageBuffer, ExtraMessage);
+ }
+
+ /* Initialize the error node */
+
+ if (Filename)
+ {
+ Enode->Filename = Filename;
+ Enode->FilenameLength = strlen (Filename);
+ if (Enode->FilenameLength < 6)
+ {
+ Enode->FilenameLength = 6;
+ }
+ }
+
+ Enode->MessageId = MessageId;
+ Enode->Level = Level;
+ Enode->LineNumber = CurrentLineNumber;
+ Enode->LogicalLineNumber = LogicalLineNumber;
+ Enode->LogicalByteOffset = LogicalByteOffset;
+ Enode->Column = Column;
+ Enode->Message = MessageBuffer;
+
+ /* Add the new node to the error node list */
+
+ AeAddToErrorLog (Enode);
+
+ if (Gbl_DebugFlag)
+ {
+ /* stderr is a file, send error to it immediately */
+
+ AePrintException (ASL_FILE_STDERR, Enode, NULL);
+ }
+
+ Gbl_ExceptionCount[Level]++;
+ if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
+ {
+ printf ("\nMaximum error count (%d) exceeded.\n", ASL_MAX_ERROR_COUNT);
+
+ Gbl_SourceLine = 0;
+ Gbl_NextError = Gbl_ErrorLog;
+ CmDoOutputFiles ();
+ CmCleanupAndExit ();
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslError
+ *
+ * PARAMETERS: Level - Seriousness (Warning/error, etc.)
+ * MessageId - Index into global message buffer
+ * Op - Parse node where error happened
+ * ExtraMessage - additional error message
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
+ * except the parser.)
+ *
+ ******************************************************************************/
+
+void
+AslError (
+ UINT8 Level,
+ UINT8 MessageId,
+ ACPI_PARSE_OBJECT *Op,
+ char *ExtraMessage)
+{
+
+ if (Op)
+ {
+ AslCommonError (Level, MessageId, Op->Asl.LineNumber,
+ Op->Asl.LogicalLineNumber,
+ Op->Asl.LogicalByteOffset,
+ Op->Asl.Column,
+ Op->Asl.Filename, ExtraMessage);
+ }
+ else
+ {
+ AslCommonError (Level, MessageId, 0,
+ 0, 0, 0, NULL, ExtraMessage);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslCoreSubsystemError
+ *
+ * PARAMETERS: Op - Parse node where error happened
+ * Status - The ACPI CA Exception
+ * ExtraMessage - additional error message
+ * Abort - TRUE -> Abort compilation
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
+ * CA core subsystem.
+ *
+ ******************************************************************************/
+
+void
+AslCoreSubsystemError (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_STATUS Status,
+ char *ExtraMessage,
+ BOOLEAN Abort)
+{
+
+ sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
+
+ if (Op)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
+ Op->Asl.LogicalLineNumber,
+ Op->Asl.LogicalByteOffset,
+ Op->Asl.Column,
+ Op->Asl.Filename, MsgBuffer);
+ }
+ else
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
+ 0, 0, 0, NULL, MsgBuffer);
+ }
+
+ if (Abort)
+ {
+ AslAbort ();
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslCompilererror
+ *
+ * PARAMETERS: CompilerMessage - Error message from the parser
+ *
+ * RETURN: Status?
+ *
+ * DESCRIPTION: Report an error situation discovered in a production
+ * NOTE: don't change the name of this function.
+ *
+ ******************************************************************************/
+
+int
+AslCompilererror (
+ char *CompilerMessage)
+{
+
+ AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
+ Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
+ Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
+ CompilerMessage);
+
+ return 0;
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c
new file mode 100644
index 0000000..35c3122
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslfiles.c
@@ -0,0 +1,839 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslfiles - file I/O suppoert
+ * $Revision: 46 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "acapps.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslfiles")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslAbort
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
+ * I/O errors
+ *
+ ******************************************************************************/
+
+void
+AslAbort (void)
+{
+
+ AePrintErrorLog (ASL_FILE_STDOUT);
+ if (Gbl_DebugFlag)
+ {
+ /* Print error summary to the debug file */
+
+ AePrintErrorLog (ASL_FILE_STDERR);
+ }
+
+ exit (0);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlOpenLocalFile
+ *
+ * PARAMETERS: LocalName - Single filename (not a pathname)
+ * Mode - Open mode for fopen
+ *
+ * RETURN: File descriptor
+ *
+ * DESCRIPTION: Build a complete pathname for the input filename and open
+ * the file.
+ *
+ ******************************************************************************/
+
+FILE *
+FlOpenLocalFile (
+ char *LocalName,
+ char *Mode)
+{
+
+ strcpy (StringBuffer, Gbl_DirectoryPath);
+ strcat (StringBuffer, LocalName);
+
+ DbgPrint (ASL_PARSE_OUTPUT, "FlOpenLocalFile: %s\n", StringBuffer);
+ return (fopen (StringBuffer, (const char *) Mode));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlFileError
+ *
+ * PARAMETERS: FileId - Index into file info array
+ * ErrorId - Index into error message array
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode errno to an error message and add the entire error
+ * to the error log.
+ *
+ ******************************************************************************/
+
+void
+FlFileError (
+ UINT32 FileId,
+ UINT8 ErrorId)
+{
+
+ sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, strerror (errno));
+ AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlOpenFile
+ *
+ * PARAMETERS: FileId - Index into file info array
+ * Filename - file pathname to open
+ * Mode - Open mode for fopen
+ *
+ * RETURN: File descriptor
+ *
+ * DESCRIPTION: Open a file.
+ * NOTE: Aborts compiler on any error.
+ *
+ ******************************************************************************/
+
+void
+FlOpenFile (
+ UINT32 FileId,
+ char *Filename,
+ char *Mode)
+{
+ FILE *File;
+
+
+ File = fopen (Filename, Mode);
+
+ Gbl_Files[FileId].Filename = Filename;
+ Gbl_Files[FileId].Handle = File;
+
+ if (!File)
+ {
+ FlFileError (FileId, ASL_MSG_OPEN);
+ AslAbort ();
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlReadFile
+ *
+ * PARAMETERS: FileId - Index into file info array
+ * Buffer - Where to place the data
+ * Length - Amount to read
+ *
+ * RETURN: Status. AE_ERROR indicates EOF.
+ *
+ * DESCRIPTION: Read data from an open file.
+ * NOTE: Aborts compiler on any error.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+FlReadFile (
+ UINT32 FileId,
+ void *Buffer,
+ UINT32 Length)
+{
+ UINT32 Actual;
+
+
+ /* Read and check for error */
+
+ Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle);
+ if (Actual != Length)
+ {
+ if (feof (Gbl_Files[FileId].Handle))
+ {
+ /* End-of-file, just return error */
+
+ return (AE_ERROR);
+ }
+
+ FlFileError (FileId, ASL_MSG_READ);
+ AslAbort ();
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlWriteFile
+ *
+ * PARAMETERS: FileId - Index into file info array
+ * Buffer - Data to write
+ * Length - Amount of data to write
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write data to an open file.
+ * NOTE: Aborts compiler on any error.
+ *
+ ******************************************************************************/
+
+void
+FlWriteFile (
+ UINT32 FileId,
+ void *Buffer,
+ UINT32 Length)
+{
+ UINT32 Actual;
+
+
+ /* Write and check for error */
+
+ Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle);
+ if (Actual != Length)
+ {
+ FlFileError (FileId, ASL_MSG_WRITE);
+ AslAbort ();
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlPrintFile
+ *
+ * PARAMETERS: FileId - Index into file info array
+ * Format - Printf format string
+ * ... - Printf arguments
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Formatted write to an open file.
+ * NOTE: Aborts compiler on any error.
+ *
+ ******************************************************************************/
+
+void
+FlPrintFile (
+ UINT32 FileId,
+ char *Format,
+ ...)
+{
+ INT32 Actual;
+ va_list Args;
+
+
+ va_start (Args, Format);
+
+ Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
+ if (Actual == -1)
+ {
+ FlFileError (FileId, ASL_MSG_WRITE);
+ AslAbort ();
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlSeekFile
+ *
+ * PARAMETERS: FileId - Index into file info array
+ * Offset - Absolute byte offset in file
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Seek to absolute offset
+ * NOTE: Aborts compiler on any error.
+ *
+ ******************************************************************************/
+
+void
+FlSeekFile (
+ UINT32 FileId,
+ long Offset)
+{
+ int Error;
+
+
+ Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
+ if (Error)
+ {
+ FlFileError (FileId, ASL_MSG_SEEK);
+ AslAbort ();
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlCloseFile
+ *
+ * PARAMETERS: FileId - Index into file info array
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Close an open file. Aborts compiler on error
+ *
+ ******************************************************************************/
+
+void
+FlCloseFile (
+ UINT32 FileId)
+{
+ int Error;
+
+
+ if (!Gbl_Files[FileId].Handle)
+ {
+ return;
+ }
+
+ Error = fclose (Gbl_Files[FileId].Handle);
+ Gbl_Files[FileId].Handle = NULL;
+
+ if (Error)
+ {
+ FlFileError (FileId, ASL_MSG_CLOSE);
+ AslAbort ();
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlSetLineNumber
+ *
+ * PARAMETERS: Op - Parse node for the LINE asl statement
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Set the current line number
+ *
+ ******************************************************************************/
+
+void
+FlSetLineNumber (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ Gbl_CurrentLineNumber = (UINT32) Op->Asl.Value.Integer;
+ Gbl_LogicalLineNumber = (UINT32) Op->Asl.Value.Integer;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlOpenIncludeFile
+ *
+ * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Open an include file and push it on the input file stack.
+ *
+ ******************************************************************************/
+
+void
+FlOpenIncludeFile (
+ ACPI_PARSE_OBJECT *Op)
+{
+ FILE *IncFile;
+
+
+ /* Op must be valid */
+
+ if (!Op)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_InputByteCount, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
+
+ return;
+ }
+
+ /*
+ * Flush out the "include ()" statement on this line, start
+ * the actual include file on the next line
+ */
+ ResetCurrentLineBuffer ();
+ FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
+ Gbl_CurrentLineOffset++;
+
+ /* Prepend the directory pathname and open the include file */
+
+ DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n", Op->Asl.Value.String);
+ IncFile = FlOpenLocalFile (Op->Asl.Value.String, "r");
+ if (!IncFile)
+ {
+ sprintf (MsgBuffer, "%s (%s)", Op->Asl.Value.String, strerror (errno));
+ AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
+ return;
+ }
+
+ /* Push the include file on the open input file stack */
+
+ AslPushInputFileStack (IncFile, Op->Asl.Value.String);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlParseInputPathname
+ *
+ * PARAMETERS: InputFilename - The user-specified ASL source file to be
+ * compiled
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Split the input path into a directory and filename part
+ * 1) Directory part used to open include files
+ * 2) Filename part used to generate output filenames
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+FlParseInputPathname (
+ char *InputFilename)
+{
+ char *Substring;
+
+
+ if (!InputFilename)
+ {
+ return (AE_OK);
+ }
+
+ /* Get the path to the input filename's directory */
+
+ Gbl_DirectoryPath = strdup (InputFilename);
+ if (!Gbl_DirectoryPath)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ Substring = strrchr (Gbl_DirectoryPath, '\\');
+ if (!Substring)
+ {
+ Substring = strrchr (Gbl_DirectoryPath, '/');
+ if (!Substring)
+ {
+ Substring = strrchr (Gbl_DirectoryPath, ':');
+ }
+ }
+
+ if (!Substring)
+ {
+ Gbl_DirectoryPath[0] = 0;
+ if (Gbl_UseDefaultAmlFilename)
+ {
+ Gbl_OutputFilenamePrefix = strdup (InputFilename);
+ }
+ }
+ else
+ {
+ if (Gbl_UseDefaultAmlFilename)
+ {
+ Gbl_OutputFilenamePrefix = strdup (Substring + 1);
+ }
+ *(Substring+1) = 0;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlOpenInputFile
+ *
+ * PARAMETERS: InputFilename - The user-specified ASL source file to be
+ * compiled
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Open the specified input file, and save the directory path to
+ * the file so that include files can be opened in
+ * the same directory.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+FlOpenInputFile (
+ char *InputFilename)
+{
+
+
+ /* Open the input ASL file, text mode */
+
+ FlOpenFile (ASL_FILE_INPUT, InputFilename, "r");
+ AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlOpenAmlOutputFile
+ *
+ * PARAMETERS: FilenamePrefix - The user-specified ASL source file
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
+ * is created in the same directory as the parent input file.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+FlOpenAmlOutputFile (
+ char *FilenamePrefix)
+{
+ char *Filename;
+
+
+ /* Output filename usually comes from the ASL itself */
+
+ Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
+ if (!Filename)
+ {
+ /* Create the output AML filename */
+
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+ }
+
+ /* Open the output AML file in binary mode */
+
+ FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: FlOpenMiscOutputFiles
+ *
+ * PARAMETERS: FilenamePrefix - The user-specified ASL source file
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create and open the various output files needed, depending on
+ * the command line options
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+FlOpenMiscOutputFiles (
+ char *FilenamePrefix)
+{
+ char *Filename;
+
+
+ /* Create/Open a combined source output file */
+
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /*
+ * Open the source output file, binary mode (so that LF does not get
+ * expanded to CR/LF on some systems, messing up our seek
+ * calculations.)
+ */
+ FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
+
+ /* Create/Open a listing output file if asked */
+
+ if (Gbl_ListingFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the listing file, text mode */
+
+ FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+");
+
+ AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
+ }
+
+ /* Create/Open a assembly code source output file if asked */
+
+ if (Gbl_AsmOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the assembly code source file, text mode */
+
+ FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+");
+
+ AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
+ }
+
+ /* Create/Open a C code source output file if asked */
+
+ if (Gbl_C_OutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the C code source file, text mode */
+
+ FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+");
+
+ FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
+ AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
+ }
+
+ /* Create/Open a assembly include output file if asked */
+
+ if (Gbl_AsmIncludeOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the assembly include file, text mode */
+
+ FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+");
+
+ AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
+ }
+
+ /* Create/Open a C include output file if asked */
+
+ if (Gbl_C_IncludeOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the C include file, text mode */
+
+ FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+");
+
+ FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
+ AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
+ }
+
+ /* Create/Open a hex output file if asked */
+
+ if (Gbl_HexOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the hex file, text mode */
+
+ FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+");
+
+ AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
+ }
+
+ /* Create a namespace output file if asked */
+
+ if (Gbl_NsOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the namespace file, text mode */
+
+ FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+");
+
+ AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
+ }
+
+ /* Create/Open a debug output file if asked */
+
+ if (Gbl_DebugFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the debug file as STDERR, text mode */
+
+ /* TBD: hide this behind a FlReopenFile function */
+
+ Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
+ Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = freopen (Filename, "w+t", stderr);
+
+ AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
+ }
+
+ return (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c
new file mode 100644
index 0000000..3dbcf59
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslfold.c
@@ -0,0 +1,532 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslfold - Constant folding
+ * $Revision: 7 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+
+#include "acdispat.h"
+#include "acparser.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslfold")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcAmlEvaluationWalk1
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback for AML execution of constant subtrees
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OpcAmlEvaluationWalk1 (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = Context;
+ ACPI_STATUS Status;
+ ACPI_PARSE_OBJECT *OutOp;
+
+
+ WalkState->Op = Op;
+ WalkState->Opcode = Op->Common.AmlOpcode;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+
+ /* Copy child pointer to Arg for compatibility with Interpreter */
+
+ if (Op->Asl.Child)
+ {
+ Op->Common.Value.Arg = Op->Asl.Child;
+ }
+
+ /* Call AML dispatcher */
+
+ Status = AcpiDsExecBeginOp (WalkState, &OutOp);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Constant interpretation failed - %s\n",
+ AcpiFormatException (Status));
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcAmlEvaluationWalk2
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback for AML execution of constant subtrees
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OpcAmlEvaluationWalk2 (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = Context;
+ ACPI_STATUS Status;
+
+
+ WalkState->Op = Op;
+ WalkState->Opcode = Op->Common.AmlOpcode;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+
+ /* Copy child pointer to Arg for compatibility with Interpreter */
+
+ if (Op->Asl.Child)
+ {
+ Op->Common.Value.Arg = Op->Asl.Child;
+ }
+
+ /* Call AML dispatcher */
+
+ Status = AcpiDsExecEndOp (WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Constant interpretation failed - %s\n",
+ AcpiFormatException (Status));
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcAmlCheckForConstant
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check one Op for a type 3/4/5 AML opcode
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OpcAmlCheckForConstant (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = Context;
+
+
+ WalkState->Op = Op;
+ WalkState->Opcode = Op->Common.AmlOpcode;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+
+ DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
+ Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
+
+ if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
+ {
+ /* The opcode is not a Type 3/4/5 opcode */
+
+ if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ {
+ DbgPrint (ASL_PARSE_OUTPUT, "**** Valid Target, cannot reduce ****\n");
+ }
+ else
+ {
+ DbgPrint (ASL_PARSE_OUTPUT, "**** Not a Type 3/4/5 opcode ****\n");
+ }
+
+ if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)
+ {
+ /*
+ * We are looking at at normal expression to see if it can be
+ * reduced. It can't. No error
+ */
+ return (AE_TYPE);
+ }
+
+ /*
+ * This is an expression that MUST reduce to a constant, and it
+ * can't be reduced. This is an error
+ */
+ if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ {
+ AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, Op->Asl.ParseOpName);
+ }
+ else
+ {
+ AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op, Op->Asl.ParseOpName);
+ }
+
+ return (AE_TYPE);
+ }
+
+ /* Debug output */
+
+ DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");
+
+ if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ {
+ DbgPrint (ASL_PARSE_OUTPUT, " TARGET");
+ }
+ if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
+ {
+ DbgPrint (ASL_PARSE_OUTPUT, " TERMARG");
+ }
+ DbgPrint (ASL_PARSE_OUTPUT, "\n");
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcAmlConstantWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reduce an Op and its subtree to a constant if possible
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OpcAmlConstantWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_PARSE_OBJECT *RootOp;
+ ACPI_PARSE_OBJECT *OriginalParentOp;
+ UINT8 WalkType;
+
+
+ /*
+ * Only interested in subtrees that could possibly contain
+ * expressions that can be evaluated at this time
+ */
+ if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) ||
+ (Op->Asl.CompileFlags & NODE_IS_TARGET))
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * Set the walk type based on the reduction used for this op
+ */
+ if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
+ {
+ /* Op is a TermArg, constant folding is merely optional */
+
+ if (!Gbl_FoldConstants)
+ {
+ return (AE_CTRL_DEPTH);
+ }
+
+ WalkType = ACPI_WALK_CONST_OPTIONAL;
+ }
+ else
+ {
+ /* Op is a DataObject, the expression MUST reduced to a constant */
+
+ WalkType = ACPI_WALK_CONST_REQUIRED;
+ }
+
+ /* Create a new walk state */
+
+ WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ return AE_NO_MEMORY;
+ }
+
+ WalkState->NextOp = NULL;
+ WalkState->Params = NULL;
+ WalkState->CallerReturnDesc = &ObjDesc;
+ WalkState->WalkType = WalkType;
+
+ /* Examine the entire subtree -- all nodes must be constants or type 3/4/5 opcodes */
+
+ Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
+ OpcAmlCheckForConstant, NULL, WalkState);
+
+ /*
+ * Did we find an entire subtree that contains all constants and type 3/4/5
+ * opcodes? (Only AE_OK or AE_TYPE returned from above)
+ */
+ if (Status == AE_TYPE)
+ {
+ /* Subtree cannot be reduced to a constant */
+
+ if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ return (AE_OK);
+ }
+
+ /* Don't descend any further, and use a default "constant" value */
+
+ Status = AE_CTRL_DEPTH;
+ }
+ else
+ {
+ /* Subtree can be reduced */
+
+ /* Allocate a new temporary root for this subtree */
+
+ RootOp = TrAllocateNode (PARSEOP_INTEGER);
+ if (!RootOp)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
+
+ OriginalParentOp = Op->Common.Parent;
+ Op->Common.Parent = RootOp;
+
+ /*
+ * Hand off the subtree to the AML interpreter
+ */
+ Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
+ Op->Common.Parent = OriginalParentOp;
+
+ /* TBD: we really *should* release the RootOp node */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ TotalFolds++;
+
+ /* Get the final result */
+
+ Status = AcpiDsResultPop (&ObjDesc, WalkState);
+ }
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* We could not resolve the subtree for some reason */
+
+ AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op, Op->Asl.ParseOpName);
+
+ /* Set the subtree value to ZERO anyway. Eliminates further errors */
+
+ Op->Asl.ParseOpcode = PARSEOP_INTEGER;
+ Op->Common.Value.Integer = 0;
+ OpcSetOptimalIntegerSize (Op);
+ }
+ else
+ {
+ AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op, Op->Asl.ParseOpName);
+
+ /*
+ * Because we know we executed type 3/4/5 opcodes above, we know that
+ * the result must be either an Integer, String, or Buffer.
+ */
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_INTEGER:
+
+ Op->Asl.ParseOpcode = PARSEOP_INTEGER;
+ Op->Common.Value.Integer = ObjDesc->Integer.Value;
+ OpcSetOptimalIntegerSize (Op);
+
+ DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (INTEGER) %8.8X%8.8X\n",
+ ACPI_HIDWORD (ObjDesc->Integer.Value),
+ ACPI_LODWORD (ObjDesc->Integer.Value));
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
+ Op->Common.AmlOpcode = AML_STRING_OP;
+ Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
+ Op->Common.Value.String = ObjDesc->String.Pointer;
+
+ DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (STRING) %s\n",
+ Op->Common.Value.String);
+
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ Op->Asl.ParseOpcode = PARSEOP_BUFFER;
+ Op->Common.AmlOpcode = AML_BUFFER_OP;
+ UtSetParseOpName (Op);
+
+ /* Child node is the buffer length */
+
+ RootOp = TrAllocateNode (PARSEOP_INTEGER);
+
+ RootOp->Asl.AmlOpcode = AML_DWORD_OP;
+ RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
+ RootOp->Asl.Parent = Op;
+
+ (void) OpcSetOptimalIntegerSize (RootOp);
+
+ Op->Asl.Child = RootOp;
+ Op = RootOp;
+ UtSetParseOpName (Op);
+
+ /* Peer to the child is the raw buffer data */
+
+ RootOp = TrAllocateNode (PARSEOP_RAW_DATA);
+ RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
+ RootOp->Asl.AmlLength = ObjDesc->Buffer.Length;
+ RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
+ RootOp->Asl.Parent = Op->Asl.Parent;
+
+ Op->Asl.Next = RootOp;
+ Op = RootOp;
+
+ DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (BUFFER) length %X\n",
+ ObjDesc->Buffer.Length);
+ break;
+
+
+ default:
+ printf ("Unsupported return type: %s\n",
+ AcpiUtGetObjectTypeName (ObjDesc));
+ break;
+ }
+ }
+
+ UtSetParseOpName (Op);
+ Op->Asl.Child = NULL;
+
+ AcpiDsDeleteWalkState (WalkState);
+
+ return (AE_CTRL_DEPTH);
+}
+
diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h
new file mode 100644
index 0000000..4ffd5c5
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslglobal.h
@@ -0,0 +1,267 @@
+
+
+/******************************************************************************
+ *
+ * Module Name: aslglobal.h - Global variable definitions
+ * $Revision: 42 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#ifndef __ASLGLOBAL_H
+#define __ASLGLOBAL_H
+
+
+/*
+ * Global variables. Defined in aslmain.c only, externed in all other files
+ */
+
+#ifdef _DECLARE_GLOBALS
+#define ASL_EXTERN
+#define ASL_INIT_GLOBAL(a,b) (a)=(b)
+#else
+#define ASL_EXTERN extern
+#define ASL_INIT_GLOBAL(a,b) (a)
+#endif
+
+
+/*
+ * Parser and other externals
+ */
+extern int yydebug;
+extern FILE *AslCompilerin;
+extern int AslCompilerdebug;
+extern const ASL_MAPPING_ENTRY AslKeywordMapping[];
+extern char *AslCompilertext;
+extern char hex[];
+
+#define ASL_LINE_BUFFER_SIZE 512
+#define ASL_MSG_BUFFER_SIZE (ASL_LINE_BUFFER_SIZE * 2)
+#define HEX_TABLE_LINE_SIZE 8
+#define HEX_LISTING_LINE_SIZE 16
+
+
+/* Source code buffers and pointers for error reporting */
+
+ASL_EXTERN char Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE];
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_CurrentLineBuffer);
+
+
+/* Exception reporting */
+
+ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*Gbl_ErrorLog,NULL);
+ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*Gbl_NextError,NULL);
+extern UINT32 Gbl_ExceptionCount[];
+
+
+/* Option flags */
+
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmIncludeOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_IncludeOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ListingFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IgnoreErrors, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GenerateExternals, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ParseOnlyFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE);
+
+#define HEX_OUTPUT_NONE 0
+#define HEX_OUTPUT_C 1
+#define HEX_OUTPUT_ASM 2
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE);
+
+
+/* Files */
+
+ASL_EXTERN ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES];
+
+ASL_EXTERN char *Gbl_DirectoryPath;
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL);
+ASL_EXTERN char *Gbl_CurrentInputFilename;
+
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
+
+
+/* Statistics */
+
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_InputByteCount, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NsLookupCount, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalKeywords, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalNamedObjects, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalExecutableOpcodes, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalParseNodes, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalMethods, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocations, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocated, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0);
+
+
+/* Misc */
+
+ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0);
+ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL);
+ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheNext, NULL);
+ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL);
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL);
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TempCount, 0);
+ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode;
+
+
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLine, 0);
+ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0);
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG");
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID");
+ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswinxf only */
+
+
+/* Static structures */
+
+ASL_EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo;
+ASL_EXTERN ACPI_TABLE_HEADER TableHeader;
+extern const ASL_RESERVED_INFO ReservedMethods[];
+ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[21];
+
+
+/* Scratch buffers */
+
+ASL_EXTERN UINT8 Gbl_AmlBuffer[HEX_LISTING_LINE_SIZE];
+ASL_EXTERN char MsgBuffer[ASL_MSG_BUFFER_SIZE];
+ASL_EXTERN char StringBuffer[ASL_MSG_BUFFER_SIZE];
+ASL_EXTERN char StringBuffer2[ASL_MSG_BUFFER_SIZE];
+
+#endif /* __ASLGLOBAL_H */
+
diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c
new file mode 100644
index 0000000..5bf81ef
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asllength.c
@@ -0,0 +1,504 @@
+
+/******************************************************************************
+ *
+ * Module Name: asllength - Tree walk to determine package and opcode lengths
+ * $Revision: 30 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("asllength")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LnInitLengthsWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk callback to initialize (and re-initialize) the node
+ * subtree length(s) to zero. The Subtree lengths are bubbled
+ * up to the root node in order to get a total AML length.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LnInitLengthsWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ Op->Asl.AmlSubtreeLength = 0;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LnPackageLengthWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk callback to calculate the total AML length.
+ * 1) Calculate the AML lengths (opcode, package length, etc.) for
+ * THIS node.
+ * 2) Bubbble up all of these lengths to the parent node by summing
+ * them all into the parent subtree length.
+ *
+ * Note: The SubtreeLength represents the total AML length of all child nodes
+ * in all subtrees under a given node. Therefore, once this walk is
+ * complete, the Root Node subtree length is the AML length of the entire
+ * tree (and thus, the entire ACPI table)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LnPackageLengthWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ /* Generate the AML lengths for this node */
+
+ CgGenerateAmlLengths (Op);
+
+ /* Bubble up all lengths (this node and all below it) to the parent */
+
+ if ((Op->Asl.Parent) &&
+ (Op->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
+ {
+ Op->Asl.Parent->Asl.AmlSubtreeLength += (Op->Asl.AmlLength +
+ Op->Asl.AmlOpcodeLength +
+ Op->Asl.AmlPkgLenBytes +
+ Op->Asl.AmlSubtreeLength);
+ }
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LnAdjustLengthToRoot
+ *
+ * PARAMETERS: Op - Node whose Length was changed
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Change the Subtree length of the given node, and bubble the
+ * change all the way up to the root node. This allows for
+ * last second changes to a package length (for example, if the
+ * package length encoding gets shorter or longer.)
+ *
+ ******************************************************************************/
+
+void
+LnAdjustLengthToRoot (
+ ACPI_PARSE_OBJECT *SubtreeOp,
+ UINT32 LengthDelta)
+{
+ ACPI_PARSE_OBJECT *Op;
+
+
+ /* Adjust all subtree lengths up to the root */
+
+ Op = SubtreeOp->Asl.Parent;
+ while (Op)
+ {
+ Op->Asl.AmlSubtreeLength -= LengthDelta;
+ Op = Op->Asl.Parent;
+ }
+
+ /* Adjust the global table length */
+
+ Gbl_TableLength -= LengthDelta;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgGetPackageLenByteCount
+ *
+ * PARAMETERS: Op - Parse node
+ * PackageLength - Length to be encoded
+ *
+ * RETURN: Required length of the package length encoding
+ *
+ * DESCRIPTION: Calculate the number of bytes required to encode the given
+ * package length.
+ *
+ ******************************************************************************/
+
+UINT8
+CgGetPackageLenByteCount (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 PackageLength)
+{
+
+ /*
+ * Determine the number of bytes required to encode the package length
+ * Note: the package length includes the number of bytes used to encode
+ * the package length, so we must account for this also.
+ */
+ if (PackageLength <= (0x0000003F - 1))
+ {
+ return (1);
+ }
+ else if (PackageLength <= (0x00000FFF - 2))
+ {
+ return (2);
+ }
+ else if (PackageLength <= (0x000FFFFF - 3))
+ {
+ return (3);
+ }
+ else if (PackageLength <= (0x0FFFFFFF - 4))
+ {
+ return (4);
+ }
+ else
+ {
+ /* Fatal error - the package length is too large to encode */
+
+ AslError (ASL_ERROR, ASL_MSG_ENCODING_LENGTH, Op, NULL);
+ }
+
+ return (0);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgGenerateAmlOpcodeLength
+ *
+ * PARAMETERS: Op - Parse node whose AML opcode lengths will be
+ * calculated
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Calculate the AmlOpcodeLength, AmlPkgLenBytes, and AmlLength
+ * fields for this node.
+ *
+ ******************************************************************************/
+
+void
+CgGenerateAmlOpcodeLength (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ /* Check for two-byte opcode */
+
+ if (Op->Asl.AmlOpcode > 0x00FF)
+ {
+ Op->Asl.AmlOpcodeLength = 2;
+ }
+ else
+ {
+ Op->Asl.AmlOpcodeLength = 1;
+ }
+
+ /* Does this opcode have an associated "PackageLength" field? */
+
+ Op->Asl.AmlPkgLenBytes = 0;
+ if (Op->Asl.CompileFlags & NODE_AML_PACKAGE)
+ {
+ Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, Op->Asl.AmlSubtreeLength);
+ }
+
+ /* Data opcode lengths are easy */
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_BYTE_OP:
+
+ Op->Asl.AmlLength = 1;
+ break;
+
+ case AML_WORD_OP:
+
+ Op->Asl.AmlLength = 2;
+ break;
+
+ case AML_DWORD_OP:
+
+ Op->Asl.AmlLength = 4;
+ break;
+
+ case AML_QWORD_OP:
+
+ Op->Asl.AmlLength = 8;
+ break;
+
+ default:
+ /* All data opcodes must be above */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgGenerateAmlLengths
+ *
+ * PARAMETERS: Op - Parse node
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Generate internal length fields based on the AML opcode or
+ * parse opcode.
+ *
+ ******************************************************************************/
+
+void
+CgGenerateAmlLengths (
+ ACPI_PARSE_OBJECT *Op)
+{
+ char *Buffer;
+ ACPI_STATUS Status;
+
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_RAW_DATA_BYTE:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Op->Asl.AmlLength = 1;
+ return;
+
+ case AML_RAW_DATA_WORD:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Op->Asl.AmlLength = 2;
+ return;
+
+ case AML_RAW_DATA_DWORD:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Op->Asl.AmlLength = 4;
+ return;
+
+ case AML_RAW_DATA_QWORD:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Op->Asl.AmlLength = 8;
+ return;
+
+ case AML_RAW_DATA_BUFFER:
+
+ /* Aml length is/was set by creator */
+
+ Op->Asl.AmlOpcodeLength = 0;
+ return;
+
+ case AML_RAW_DATA_CHAIN:
+
+ /* Aml length is/was set by creator */
+
+ Op->Asl.AmlOpcodeLength = 0;
+ return;
+
+ default:
+ break;
+ }
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+
+ Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
+ break;
+
+ case PARSEOP_NAMESEG:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Op->Asl.AmlLength = 4;
+ Op->Asl.ExternalName = Op->Asl.Value.String;
+ break;
+
+ case PARSEOP_NAMESTRING:
+ case PARSEOP_METHODCALL:
+
+ if (Op->Asl.CompileFlags & NODE_NAME_INTERNALIZED)
+ {
+ break;
+ }
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Status = UtInternalizeName (Op->Asl.Value.String, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "Failure from internalize name %X\n", Status);
+ break;
+ }
+
+ Op->Asl.ExternalName = Op->Asl.Value.String;
+ Op->Asl.Value.String = Buffer;
+ Op->Asl.CompileFlags |= NODE_NAME_INTERNALIZED;
+
+ Op->Asl.AmlLength = strlen (Buffer);
+
+ /*
+ * Check for single backslash reference to root,
+ * make it a null terminated string in the AML
+ */
+ if (Op->Asl.AmlLength == 1)
+ {
+ Op->Asl.AmlLength = 2;
+ }
+ break;
+
+ case PARSEOP_STRING_LITERAL:
+
+ Op->Asl.AmlOpcodeLength = 1;
+ Op->Asl.AmlLength = strlen (Op->Asl.Value.String) + 1; /* Get null terminator */
+ break;
+
+ case PARSEOP_PACKAGE_LENGTH:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, (UINT32) Op->Asl.Value.Integer);
+ break;
+
+ case PARSEOP_RAW_DATA:
+
+ Op->Asl.AmlOpcodeLength = 0;
+ break;
+
+ case PARSEOP_DEFAULT_ARG:
+ case PARSEOP_EXTERNAL:
+ case PARSEOP_INCLUDE:
+ case PARSEOP_INCLUDE_END:
+
+ /* Ignore the "default arg" nodes, they are extraneous at this point */
+
+ break;
+
+ default:
+
+ CgGenerateAmlOpcodeLength (Op);
+ break;
+ }
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c
new file mode 100644
index 0000000..8d3d09c
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asllisting.c
@@ -0,0 +1,1319 @@
+
+/******************************************************************************
+ *
+ * Module Name: asllisting - Listing file generation
+ * $Revision: 50 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+#include "acparser.h"
+#include "acnamesp.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslisting")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDumpAscii
+ *
+ * PARAMETERS: FileId - ID of current listing file
+ * Count - Number of bytes to convert
+ * Buffer - Buffer of bytes to convert
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Convert hex bytes to ascii
+ *
+ ******************************************************************************/
+
+void
+LsDumpAscii (
+ UINT32 FileId,
+ UINT32 Count,
+ UINT8 *Buffer)
+{
+ UINT8 BufChar;
+ UINT32 i;
+
+
+ FlPrintFile (FileId, " \"");
+ for (i = 0; i < Count; i++)
+ {
+ BufChar = Buffer[i];
+ if (isprint (BufChar))
+ {
+ FlPrintFile (FileId, "%c", BufChar);
+ }
+ else
+ {
+ /* Not a printable character, just put out a dot */
+
+ FlPrintFile (FileId, ".");
+ }
+ }
+ FlPrintFile (FileId, "\"");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDumpAsciiInComment
+ *
+ * PARAMETERS: FileId - ID of current listing file
+ * Count - Number of bytes to convert
+ * Buffer - Buffer of bytes to convert
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Convert hex bytes to ascii
+ *
+ ******************************************************************************/
+
+void
+LsDumpAsciiInComment (
+ UINT32 FileId,
+ UINT32 Count,
+ UINT8 *Buffer)
+{
+ UINT8 BufChar = 0;
+ UINT8 LastChar;
+ UINT32 i;
+
+
+ FlPrintFile (FileId, " \"");
+ for (i = 0; i < Count; i++)
+ {
+ LastChar = BufChar;
+ BufChar = Buffer[i];
+
+ if (isprint (BufChar))
+ {
+ /* Handle embedded C comment sequences */
+
+ if (((LastChar == '*') && (BufChar == '/')) ||
+ ((LastChar == '/') && (BufChar == '*')))
+ {
+ /* Insert a space to break the sequence */
+
+ FlPrintFile (FileId, ".", BufChar);
+ }
+
+ FlPrintFile (FileId, "%c", BufChar);
+ }
+ else
+ {
+ /* Not a printable character, just put out a dot */
+
+ FlPrintFile (FileId, ".");
+ }
+ }
+ FlPrintFile (FileId, "\"");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsAmlListingWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Process one node during a listing file generation.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LsAmlListingWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ UINT8 FileByte;
+ UINT32 i;
+ UINT32 FileId = (UINT32) Context;
+
+
+ LsWriteNodeToListing (Op, FileId);
+
+ /* Write the hex bytes to the listing file(s) (if requested) */
+
+ for (i = 0; i < Op->Asl.FinalAmlLength; i++)
+ {
+ if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
+ {
+ FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
+ AslAbort ();
+ }
+ LsWriteListingHexBytes (&FileByte, 1, FileId);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsGenerateListing
+ *
+ * PARAMETERS: FileId - ID of listing file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generate a listing file. This can be one of the several types
+ * of "listings" supported.
+ *
+ ******************************************************************************/
+
+void
+LsGenerateListing (
+ UINT32 FileId)
+{
+
+ /* Start at the beginning of both the source and AML files */
+
+ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
+ FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+ Gbl_SourceLine = 0;
+ Gbl_CurrentHexColumn = 0;
+ LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename);
+
+ /* Process all parse nodes */
+
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
+ NULL, (void *) ACPI_TO_POINTER (FileId));
+
+ /* Final processing */
+
+ LsFinishSourceListing (FileId);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDoListings
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generate all requested listing files.
+ *
+ ******************************************************************************/
+
+void
+LsDoListings (void)
+{
+
+ if (Gbl_C_OutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
+ }
+
+ if (Gbl_ListingFlag)
+ {
+ LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
+ }
+
+ if (Gbl_AsmOutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
+ }
+
+ if (Gbl_C_IncludeOutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
+ }
+
+ if (Gbl_AsmIncludeOutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsPushNode
+ *
+ * PARAMETERS: Filename - Pointer to the include filename
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Push a listing node on the listing/include file stack. This
+ * stack enables tracking of include files (infinitely nested)
+ * and resumption of the listing of the parent file when the
+ * include file is finished.
+ *
+ ******************************************************************************/
+
+void
+LsPushNode (
+ char *Filename)
+{
+ ASL_LISTING_NODE *Lnode;
+
+
+ /* Create a new node */
+
+ Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE));
+
+ /* Initialize */
+
+ Lnode->Filename = Filename;
+ Lnode->LineNumber = 0;
+
+ /* Link (push) */
+
+ Lnode->Next = Gbl_ListingNode;
+ Gbl_ListingNode = Lnode;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsPopNode
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: List head after current head is popped off
+ *
+ * DESCRIPTION: Pop the current head of the list, free it, and return the
+ * next node on the stack (the new current node).
+ *
+ ******************************************************************************/
+
+ASL_LISTING_NODE *
+LsPopNode (void)
+{
+ ASL_LISTING_NODE *Lnode;
+
+
+ /* Just grab the node at the head of the list */
+
+ Lnode = Gbl_ListingNode;
+ if ((!Lnode) ||
+ (!Lnode->Next))
+ {
+ AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, "Could not pop empty listing stack");
+ return Gbl_ListingNode;
+ }
+
+ Gbl_ListingNode = Lnode->Next;
+ ACPI_MEM_FREE (Lnode);
+
+ /* New "Current" node is the new head */
+
+ return (Gbl_ListingNode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsCheckException
+ *
+ * PARAMETERS: LineNumber - Current logical (cumulative) line #
+ * FileId - ID of output listing file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Check if there is an exception for this line, and if there is,
+ * put it in the listing immediately. Handles multiple errors
+ * per line. Gbl_NextError points to the next error in the
+ * sorted (by line #) list of compile errors/warnings.
+ *
+ ******************************************************************************/
+
+void
+LsCheckException (
+ UINT32 LineNumber,
+ UINT32 FileId)
+{
+
+ if ((!Gbl_NextError) ||
+ (LineNumber < Gbl_NextError->LogicalLineNumber ))
+ {
+ return;
+ }
+
+ /* Handle multiple errors per line */
+
+ if (FileId == ASL_FILE_LISTING_OUTPUT)
+ {
+ while (Gbl_NextError &&
+ (LineNumber >= Gbl_NextError->LogicalLineNumber))
+ {
+ AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n");
+
+ Gbl_NextError = Gbl_NextError->Next;
+ }
+
+ FlPrintFile (FileId, "\n");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsFlushListingBuffer
+ *
+ * PARAMETERS: FileId - ID of the listing file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
+ * buffer. Usually called at the termination of a single line
+ * of source code or when the buffer is full.
+ *
+ ******************************************************************************/
+
+void
+LsFlushListingBuffer (
+ UINT32 FileId)
+{
+ UINT32 i;
+
+
+ if (Gbl_CurrentHexColumn == 0)
+ {
+ return;
+ }
+
+ /* Write the hex bytes */
+
+ switch (FileId)
+ {
+ case ASL_FILE_LISTING_OUTPUT:
+
+ for (i = 0; i < Gbl_CurrentHexColumn; i++)
+ {
+ FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]);
+ }
+
+ for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++)
+ {
+ FlWriteFile (FileId, ".", 1);
+ }
+
+ /* Write the ASCII character associated with each of the bytes */
+
+ LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
+ break;
+
+
+ case ASL_FILE_ASM_SOURCE_OUTPUT:
+
+ for (i = 0; i < Gbl_CurrentHexColumn; i++)
+ {
+ if (i > 0)
+ {
+ FlPrintFile (FileId, ",");
+ }
+ FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]);
+ }
+
+ for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
+ {
+ FlWriteFile (FileId, " ", 1);
+ }
+
+ FlPrintFile (FileId, " ;%8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
+
+ /* Write the ASCII character associated with each of the bytes */
+
+ LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
+ break;
+
+
+ case ASL_FILE_C_SOURCE_OUTPUT:
+
+ for (i = 0; i < Gbl_CurrentHexColumn; i++)
+ {
+ FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]);
+ }
+
+ for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
+ {
+ FlWriteFile (FileId, " ", 1);
+ }
+
+ FlPrintFile (FileId, " /* %8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
+
+ /* Write the ASCII character associated with each of the bytes */
+
+ LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
+ FlPrintFile (FileId, " */");
+ break;
+
+ default:
+ /* No other types supported */
+ return;
+ }
+
+ FlPrintFile (FileId, "\n");
+
+ Gbl_CurrentHexColumn = 0;
+ Gbl_HexBytesWereWritten = TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsWriteListingHexBytes
+ *
+ * PARAMETERS: Buffer - AML code buffer
+ * Length - Number of AML bytes to write
+ * FileId - ID of current listing file.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write the contents of the AML buffer to the listing file via
+ * the listing buffer. The listing buffer is flushed every 16
+ * AML bytes.
+ *
+ ******************************************************************************/
+
+void
+LsWriteListingHexBytes (
+ UINT8 *Buffer,
+ UINT32 Length,
+ UINT32 FileId)
+{
+ UINT32 i;
+
+
+ /* Transfer all requested bytes */
+
+ for (i = 0; i < Length; i++)
+ {
+ /* Print line header when buffer is empty */
+
+ if (Gbl_CurrentHexColumn == 0)
+ {
+ if (Gbl_HasIncludeFiles)
+ {
+ FlPrintFile (FileId, "%*s", 10, " ");
+ }
+
+ switch (FileId)
+ {
+ case ASL_FILE_LISTING_OUTPUT:
+
+ FlPrintFile (FileId, "%8.8X....", Gbl_CurrentAmlOffset);
+ break;
+
+ case ASL_FILE_ASM_SOURCE_OUTPUT:
+
+ FlPrintFile (FileId, " db ");
+ break;
+
+ case ASL_FILE_C_SOURCE_OUTPUT:
+
+ FlPrintFile (FileId, " ");
+ break;
+
+ default:
+ /* No other types supported */
+ return;
+ }
+ }
+
+ /* Transfer AML byte and update counts */
+
+ Gbl_AmlBuffer[Gbl_CurrentHexColumn] = Buffer[i];
+
+ Gbl_CurrentHexColumn++;
+ Gbl_CurrentAmlOffset++;
+
+ /* Flush buffer when it is full */
+
+ if (Gbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE)
+ {
+ LsFlushListingBuffer (FileId);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsWriteOneSourceLine
+ *
+ * PARAMETERS: FileID - ID of current listing file
+ *
+ * RETURN: FALSE on EOF (input source file), TRUE otherwise
+ *
+ * DESCRIPTION: Read one line from the input source file and echo it to the
+ * listing file, prefixed with the line number, and if the source
+ * file contains include files, prefixed with the current filename
+ *
+ ******************************************************************************/
+
+UINT32
+LsWriteOneSourceLine (
+ UINT32 FileId)
+{
+ UINT8 FileByte;
+
+
+ Gbl_SourceLine++;
+ Gbl_ListingNode->LineNumber++;
+
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, " *");
+ }
+ if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, "; ");
+ }
+
+ if (Gbl_HasIncludeFiles)
+ {
+ /*
+ * This file contains "include" statements, print the current
+ * filename and line number within the current file
+ */
+ FlPrintFile (FileId, "%12s %5d....",
+ Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber);
+ }
+ else
+ {
+ /* No include files, just print the line number */
+
+ FlPrintFile (FileId, "%8d....", Gbl_SourceLine);
+ }
+
+ /* Read one line (up to a newline or EOF) */
+
+ while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK)
+ {
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ if (FileByte == '/')
+ {
+ FileByte = '*';
+ }
+ }
+
+ FlWriteFile (FileId, &FileByte, 1);
+ if (FileByte == '\n')
+ {
+ /*
+ * Check if an error occurred on this source line during the compile.
+ * If so, we print the error message after the source line.
+ */
+ LsCheckException (Gbl_SourceLine, FileId);
+ return (1);
+ }
+ }
+
+ /* EOF on the input file was reached */
+
+ return (0);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsFinishSourceListing
+ *
+ * PARAMETERS: FileId - ID of current listing file.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
+ * listing buffer, and flush out any remaining lines in the
+ * source input file.
+ *
+ ******************************************************************************/
+
+void
+LsFinishSourceListing (
+ UINT32 FileId)
+{
+
+ if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
+ (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
+ {
+ return;
+ }
+
+ LsFlushListingBuffer (FileId);
+ Gbl_CurrentAmlOffset = 0;
+
+ /* Flush any remaining text in the source file */
+
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, " /*\n");
+ }
+
+ while (LsWriteOneSourceLine (FileId))
+ { ; }
+
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, "\n */\n };\n");
+ }
+
+ FlPrintFile (FileId, "\n");
+
+ if (FileId == ASL_FILE_LISTING_OUTPUT)
+ {
+ /* Print a summary of the compile exceptions */
+
+ FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
+ AePrintErrorLog (FileId);
+ FlPrintFile (FileId, "\n\n");
+ UtDisplaySummary (FileId);
+ FlPrintFile (FileId, "\n\n");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsWriteSourceLines
+ *
+ * PARAMETERS: ToLineNumber -
+ * ToLogicalLineNumber - Write up to this source line number
+ * FileId - ID of current listing file
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Read then write source lines to the listing file until we have
+ * reached the specified logical (cumulative) line number. This
+ * automatically echos out comment blocks and other non-AML
+ * generating text until we get to the actual AML-generating line
+ * of ASL code specified by the logical line number.
+ *
+ ******************************************************************************/
+
+void
+LsWriteSourceLines (
+ UINT32 ToLineNumber,
+ UINT32 ToLogicalLineNumber,
+ UINT32 FileId)
+{
+
+ if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
+ (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
+ {
+ return;
+ }
+
+ Gbl_CurrentLine = ToLogicalLineNumber;
+
+ /* Flush any hex bytes remaining from the last opcode */
+
+ LsFlushListingBuffer (FileId);
+
+ /*
+ * Read lines and write them as long as we are not caught up
+ */
+ if (Gbl_SourceLine < Gbl_CurrentLine)
+ {
+ /*
+ * If we just completed writing some AML hex bytes, output a linefeed
+ * to add some whitespace for readability.
+ */
+ if (Gbl_HexBytesWereWritten)
+ {
+ FlPrintFile (FileId, "\n");
+ Gbl_HexBytesWereWritten = FALSE;
+ }
+
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, " /*\n");
+ }
+
+ /*
+ * Write one line at a time until we have reached the target line #
+ */
+ while ((Gbl_SourceLine < Gbl_CurrentLine) &&
+ LsWriteOneSourceLine (FileId))
+ { ; }
+
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, " */");
+ }
+ FlPrintFile (FileId, "\n");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsWriteNodeToListing
+ *
+ * PARAMETERS: Op - Parse node to write to the listing file.
+ * FileId - ID of current listing file
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Write "a node" to the listing file. This means to
+ * 1) Write out all of the source text associated with the node
+ * 2) Write out all of the AML bytes associated with the node
+ * 3) Write any compiler exceptions associated with the node
+ *
+ ******************************************************************************/
+
+void
+LsWriteNodeToListing (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 FileId)
+{
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT32 OpClass;
+ char *Pathname;
+ UINT32 Length;
+ UINT32 i;
+
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
+ OpClass = OpInfo->Class;
+
+ /* TBD: clean this up with a single flag that says: I start a named output block */
+
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+ case PARSEOP_METHODCALL:
+ case PARSEOP_INCLUDE:
+ case PARSEOP_INCLUDE_END:
+ case PARSEOP_DEFAULT_ARG:
+
+ break;
+
+ default:
+ switch (OpClass)
+ {
+ case AML_CLASS_NAMED_OBJECT:
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_SCOPE_OP:
+ case AML_ALIAS_OP:
+ break;
+
+ default:
+ if (Op->Asl.ExternalName)
+ {
+ LsFlushListingBuffer (FileId);
+ FlPrintFile (FileId, " };\n");
+ }
+ break;
+ }
+ break;
+
+ default:
+ /* Don't care about other objects */
+ break;
+ }
+ break;
+ }
+ }
+
+
+ /* These cases do not have a corresponding AML opcode */
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+
+ LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
+
+ /* Use the table Signature and TableId to build a unique name */
+
+ if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, "%s_%s_Header \\\n",
+ Gbl_TableSignature, Gbl_TableId);
+ }
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, " unsigned char %s_%s_Header [] = \n {\n",
+ Gbl_TableSignature, Gbl_TableId);
+ }
+ if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
+ {
+ FlPrintFile (FileId, "extrn %s_%s_Header : byte\n",
+ Gbl_TableSignature, Gbl_TableId);
+ }
+ if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
+ {
+ FlPrintFile (FileId, "extern unsigned char %s_%s_Header [];\n",
+ Gbl_TableSignature, Gbl_TableId);
+ }
+ return;
+
+
+ case PARSEOP_METHODCALL:
+
+ LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
+ return;
+
+
+ case PARSEOP_INCLUDE:
+
+ /*
+ * Flush everything up to and including the include source line
+ */
+ LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
+
+ /*
+ * Create a new listing node and push it
+ */
+ LsPushNode (Op->Asl.Child->Asl.Value.String);
+ return;
+
+
+ case PARSEOP_INCLUDE_END:
+
+ /*
+ * Flush out the rest of the include file
+ */
+ LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
+
+ /*
+ * Pop off this listing node and go back to the parent file
+ */
+ LsPopNode ();
+ return;
+
+
+ case PARSEOP_DEFAULT_ARG:
+ return;
+
+
+ default:
+ /* All other opcodes have an AML opcode */
+ break;
+ }
+
+ /*
+ * Otherwise, we look at the AML opcode because we can
+ * switch on the opcode type, getting an entire class
+ * at once
+ */
+ switch (OpClass)
+ {
+ case AML_CLASS_ARGUMENT: /* argument type only */
+ case AML_CLASS_INTERNAL:
+
+ break;
+
+
+ case AML_CLASS_NAMED_OBJECT:
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+ case AML_BANK_FIELD_OP:
+ case AML_NAME_OP:
+
+ /* For fields, we want to dump all the AML after the entire definition */
+
+ LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
+ break;
+
+ default:
+ LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
+ break;
+ }
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_SCOPE_OP:
+ case AML_ALIAS_OP:
+
+ /* These opcodes do not declare a new object, ignore them */
+
+ break;
+
+ default:
+
+ /* All other named object opcodes come here */
+
+ switch (FileId)
+ {
+ case ASL_FILE_ASM_SOURCE_OUTPUT:
+ case ASL_FILE_C_SOURCE_OUTPUT:
+ case ASL_FILE_ASM_INCLUDE_OUTPUT:
+ case ASL_FILE_C_INCLUDE_OUTPUT:
+
+ /*
+ * For named objects, we will create a valid symbol so that the
+ * AML code can be referenced from C or ASM
+ */
+ if (Op->Asl.ExternalName)
+ {
+ /* Get the full pathname associated with this node */
+
+ Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
+ Length = strlen (Pathname);
+ if (Length >= 4)
+ {
+ /* Convert all dots in the path to underscores */
+
+ for (i = 0; i < Length; i++)
+ {
+ if (Pathname[i] == '.')
+ {
+ Pathname[i] = '_';
+ }
+ }
+
+ /* Create the appropriate symbol in the output file */
+
+ if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, "%s_%s_%s \\\n",
+ Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
+ }
+ if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
+ {
+ FlPrintFile (FileId, " unsigned char %s_%s_%s [] = \n {\n",
+ Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
+ }
+ if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
+ {
+ FlPrintFile (FileId, "extrn %s_%s_%s : byte\n",
+ Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
+ }
+ if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
+ {
+ FlPrintFile (FileId, "extern unsigned char %s_%s_%s [];\n",
+ Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
+ }
+ }
+ ACPI_MEM_FREE (Pathname);
+ }
+ break;
+
+ default:
+ /* Nothing to do for listing file */
+ break;
+ }
+ }
+ break;
+
+ case AML_CLASS_EXECUTE:
+ case AML_CLASS_CREATE:
+ default:
+
+ LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
+ break;
+
+ case AML_CLASS_UNKNOWN:
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDoHexOutput
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Create the hex output file.
+ *
+ ******************************************************************************/
+
+void
+LsDoHexOutput (void)
+{
+
+ switch (Gbl_HexOutputFlag)
+ {
+ case HEX_OUTPUT_C:
+
+ LsDoHexOutputC ();
+ break;
+
+ case HEX_OUTPUT_ASM:
+
+ LsDoHexOutputAsm ();
+ break;
+
+ default:
+ /* No other output types supported */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDoHexOutputC
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Create the hex output file. This is the same data as the AML
+ * output file, but formatted into hex/ascii bytes suitable for
+ * inclusion into a C source file.
+ *
+ ******************************************************************************/
+
+void
+LsDoHexOutputC (void)
+{
+ UINT32 j;
+ UINT8 FileByte[HEX_TABLE_LINE_SIZE];
+ UINT8 Buffer[4];
+ UINT32 Offset = 0;
+
+
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n");
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] = \n{\n");
+
+ /* Start at the beginning of the AML file */
+
+ FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+
+ /* Process all AML bytes in the AML file */
+
+ j = 0;
+ while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
+ {
+ if (j == 0)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
+ }
+
+ /*
+ * Convert each AML byte to hex
+ */
+ UtConvertByteToHex (FileByte[j], Buffer);
+ FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
+
+ /* An occasional linefeed improves readability */
+
+ Offset++;
+ j++;
+
+ if (j >= HEX_TABLE_LINE_SIZE)
+ {
+ /* End of line, emit the ascii dump of the entire line */
+
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE);
+
+ /* Write the ASCII character associated with each of the bytes */
+
+ LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n");
+
+ /* Start new line */
+
+ j = 0;
+ }
+
+ }
+
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n");
+ FlCloseFile (ASL_FILE_HEX_OUTPUT);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDoHexOutputAsm
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Create the hex output file. This is the same data as the AML
+ * output file, but formatted into hex/ascii bytes suitable for
+ * inclusion into a ASM source file.
+ *
+ ******************************************************************************/
+
+void
+LsDoHexOutputAsm (
+ void)
+{
+ UINT32 j;
+ UINT8 FileByte[HEX_TABLE_LINE_SIZE];
+ UINT8 Buffer[4];
+ UINT32 Offset = 0;
+ BOOLEAN DoComma = FALSE;
+
+
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n");
+
+ /* Start at the beginning of the AML file */
+
+ FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+
+ /* Process all AML bytes in the AML file */
+
+ j = 0;
+ while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
+ {
+ if (j == 0)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
+ }
+ else if (DoComma)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
+ DoComma = FALSE;
+ }
+
+ /*
+ * Convert each AML byte to hex
+ */
+ UtConvertByteToAsmHex (FileByte[j], Buffer);
+ FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
+
+ /* An occasional linefeed improves readability */
+
+ Offset++;
+ j++;
+ if (j >= HEX_TABLE_LINE_SIZE)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE);
+
+ /* Write the ASCII character associated with each of the bytes */
+
+ LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
+ j = 0;
+ }
+ else
+ {
+ DoComma = TRUE;
+ }
+ }
+
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
+ FlCloseFile (ASL_FILE_HEX_OUTPUT);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c
new file mode 100644
index 0000000..cafbbfb
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslload.c
@@ -0,0 +1,691 @@
+/******************************************************************************
+ *
+ * Module Name: dswload - Dispatcher namespace load callbacks
+ * $Revision: 59 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ASLLOAD_C__
+
+#include "aslcompiler.h"
+#include "amlcode.h"
+#include "acdispat.h"
+#include "acnamesp.h"
+
+#include "aslcompiler.y.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslload")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LdLoadNamespace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the
+ * named ASL/AML objects into the namespace. The namespace is
+ * constructed in order to resolve named references and references
+ * to named fields within resource templates/descriptors.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LdLoadNamespace (
+ ACPI_PARSE_OBJECT *RootOp)
+{
+ ACPI_WALK_STATE *WalkState;
+
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n");
+
+ /* Create a new walk state */
+
+ WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ return AE_NO_MEMORY;
+ }
+
+ /* Perform the walk of the parse tree */
+
+ TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin,
+ LdNamespace1End, WalkState);
+
+ /* Dump the namespace if debug is enabled */
+
+ AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX);
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LdLoadFieldElements
+ *
+ * PARAMETERS: Op - Parent node (Field)
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter the named elements of the field (children of the parent)
+ * into the namespace.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LdLoadFieldElements (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_PARSE_OBJECT *Child = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /* Get the first named field element */
+
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_BANK_FIELD_OP:
+
+ Child = UtGetArg (Op, 6);
+ break;
+
+ case AML_INDEX_FIELD_OP:
+
+ Child = UtGetArg (Op, 5);
+ break;
+
+ case AML_FIELD_OP:
+
+ Child = UtGetArg (Op, 4);
+ break;
+
+ default:
+ /* No other opcodes should arrive here */
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Enter all elements into the namespace */
+
+ while (Child)
+ {
+ switch (Child->Asl.AmlOpcode)
+ {
+ case AML_INT_RESERVEDFIELD_OP:
+ case AML_INT_ACCESSFIELD_OP:
+
+ break;
+
+ default:
+
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Child->Asl.Value.String,
+ ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_IMODE_LOAD_PASS1,
+ ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
+ NULL, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status != AE_ALREADY_EXISTS)
+ {
+ return (Status);
+ }
+
+ /*
+ * The name already exists in this scope
+ * But continue processing the elements
+ */
+ AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, Child->Asl.Value.String);
+ }
+ else
+ {
+ Child->Asl.Node = Node;
+ Node->Object = (ACPI_OPERAND_OBJECT *) Child;
+ }
+ break;
+ }
+ Child = Child->Asl.Next;
+ }
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LdLoadResourceElements
+ *
+ * PARAMETERS: Op - Parent node (Resource Descriptor)
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter the named elements of the resource descriptor (children
+ * of the parent) into the namespace.
+ *
+ * NOTE: In the real AML namespace, these named elements never exist. But
+ * we simply use the namespace here as a symbol table so we can look
+ * them up as they are referenced.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LdLoadResourceElements (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_PARSE_OBJECT *InitializerOp = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /*
+ * Enter the resouce name into the namespace
+ * This opens a scope
+ */
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath,
+ ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH,
+ WalkState, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Now enter the predefined fields, for easy lookup when referenced
+ * by the source ASL
+ */
+ InitializerOp = ASL_GET_CHILD_NODE (Op);
+ while (InitializerOp)
+ {
+
+ if (InitializerOp->Asl.ExternalName)
+ {
+ Status = AcpiNsLookup (WalkState->ScopeInfo,
+ InitializerOp->Asl.ExternalName,
+ ACPI_TYPE_LOCAL_RESOURCE_FIELD,
+ ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE,
+ NULL, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Store the field offset in the namespace node so it
+ * can be used when the field is referenced
+ */
+ Node->OwnerId = (UINT16) InitializerOp->Asl.Value.Integer;
+ InitializerOp->Asl.Node = Node;
+ Node->Object = (ACPI_OPERAND_OBJECT *) InitializerOp;
+
+ /* Pass thru the field type (Bitfield or Bytefield) */
+
+ if (InitializerOp->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
+ {
+ Node->Flags |= ANOBJ_IS_BIT_OFFSET;
+ }
+ }
+ InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LdNamespace1Begin
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback used during the parse tree walk. If this
+ * is a named AML opcode, enter into the namespace
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LdNamespace1Begin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+ ACPI_OBJECT_TYPE ObjectType;
+ ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY;
+ char *Path;
+ UINT32 Flags = ACPI_NS_NO_UPSEARCH;
+ ACPI_PARSE_OBJECT *Arg;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME ("LdNamespace1Begin");
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
+ Op, Op->Asl.ParseOpName));
+
+
+ /*
+ * We are only interested in opcodes that have an associated name
+ * (or multiple names)
+ */
+ switch (Op->Asl.AmlOpcode)
+ {
+ case AML_BANK_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+ case AML_FIELD_OP:
+
+ Status = LdLoadFieldElements (Op, WalkState);
+ return (Status);
+
+ default:
+
+ /* All other opcodes go below */
+ break;
+ }
+
+ /* Check if this object has already been installed in the namespace */
+
+ if (Op->Asl.Node)
+ {
+ return (AE_OK);
+ }
+
+ Path = Op->Asl.Namepath;
+ if (!Path)
+ {
+ return (AE_OK);
+ }
+
+ /* Map the raw opcode into an internal object type */
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_NAME:
+
+ Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */
+ Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */
+
+ /* Get the data type associated with the named object, not the name itself */
+
+ /* Log2 loop to convert from Btype (binary) to Etype (encoded) */
+
+ ObjectType = 1;
+ for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2)
+ {
+ ObjectType++;
+ }
+ break;
+
+
+ case PARSEOP_EXTERNAL:
+
+ /*
+ * "External" simply enters a name and type into the namespace.
+ * We must be careful to not open a new scope, however, no matter
+ * what type the external name refers to (e.g., a method)
+ *
+ * first child is name, next child is ObjectType
+ */
+ ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer;
+ ObjectType = ACPI_TYPE_ANY;
+ break;
+
+
+ case PARSEOP_DEFAULT_ARG:
+
+ if(Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)
+ {
+ Status = LdLoadResourceElements (Op, WalkState);
+ goto Exit;
+ }
+
+ ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
+ break;
+
+
+ case PARSEOP_SCOPE:
+
+ /*
+ * The name referenced by Scope(Name) must already exist at this point.
+ * In other words, forward references for Scope() are not supported.
+ * The only real reason for this is that the MS interpreter cannot
+ * handle this case. Perhaps someday this case can go away.
+ */
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
+ ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_FOUND)
+ {
+ /* The name was not found, go ahead and create it */
+
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_LOCAL_SCOPE,
+ ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
+
+ /*
+ * However, this is an error -- primarily because the MS
+ * interpreter can't handle a forward reference from the
+ * Scope() operator.
+ */
+ AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName);
+ AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, Op->Asl.ExternalName);
+ goto FinishNode;
+ }
+
+ AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE);
+ goto Exit;
+ }
+
+ /* We found a node with this name, now check the type */
+
+ switch (Node->Type)
+ {
+ case ACPI_TYPE_LOCAL_SCOPE:
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_THERMAL:
+
+ /* These are acceptable types - they all open a new scope */
+ break;
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * These types we will allow, but we will change the type. This
+ * enables some existing code of the form:
+ *
+ * Name (DEB, 0)
+ * Scope (DEB) { ... }
+ *
+ * Which is used to workaround the fact that the MS interpreter
+ * does not allow Scope() forward references.
+ */
+ sprintf (MsgBuffer, "%s, %s, Changing type to (Scope)",
+ Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
+ AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
+
+ /*
+ * Switch the type
+ */
+ Node->Type = ACPI_TYPE_ANY;
+ break;
+
+ default:
+
+ /*
+ * All other types are an error
+ */
+ sprintf (MsgBuffer, "%s, %s", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
+ AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
+
+ /*
+ * However, switch the type to be an actual scope so
+ * that compilation can continue without generating a whole
+ * cascade of additional errors.
+ */
+ Node->Type = ACPI_TYPE_ANY;
+ break;
+ }
+
+ Status = AE_OK;
+ goto FinishNode;
+
+
+ default:
+
+ ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
+ break;
+ }
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n",
+ Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType)));
+
+ /* The name must not already exist */
+
+ Flags |= ACPI_NS_ERROR_IF_FOUND;
+
+ /*
+ * Enter the named type into the internal namespace. We enter the name
+ * as we go downward in the parse tree. Any necessary subobjects that involve
+ * arguments to the opcode must be created as we go back up the parse tree later.
+ */
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
+ ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_ALREADY_EXISTS)
+ {
+ /* The name already exists in this scope */
+
+ if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
+ {
+ Node->Type = (UINT8) ObjectType;
+ Status = AE_OK;
+ }
+ else
+ {
+ AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, Op->Asl.ExternalName);
+ Status = AE_OK;
+ goto Exit;
+ }
+ }
+ else
+ {
+ AslCoreSubsystemError (Op, Status, "Failure from lookup %s\n", FALSE);
+ goto Exit;
+ }
+ }
+
+
+FinishNode:
+ /*
+ * Point the parse node to the new namespace node, and point
+ * the Node back to the original Parse node
+ */
+ Op->Asl.Node = Node;
+ Node->Object = (ACPI_OPERAND_OBJECT *) Op;
+
+ /* Set the actual data type if appropriate (EXTERNAL term only) */
+
+ if (ActualObjectType != ACPI_TYPE_ANY)
+ {
+ Node->Type = (UINT8) ActualObjectType;
+ Node->OwnerId = ASL_EXTERNAL_METHOD;
+ }
+
+ if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
+ {
+ /*
+ * Get the method argument count from "Extra" and store
+ * it in the OwnerId field of the namespace node
+ */
+ Node->OwnerId = (UINT16) Op->Asl.Extra;
+ }
+
+Exit:
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LdNamespace1End
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback used during the loading of the namespace,
+ * We only need to worry about managing the scope stack here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LdNamespace1End (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
+ ACPI_OBJECT_TYPE ObjectType;
+
+
+ ACPI_FUNCTION_NAME ("LdNamespace1End");
+
+
+ /* We are only interested in opcodes that have an associated name */
+
+ if (!Op->Asl.Namepath)
+ {
+ return (AE_OK);
+ }
+
+ /* Get the type to determine if we should pop the scope */
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) &&
+ (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC))
+ {
+ /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */
+
+ ObjectType = ACPI_TYPE_LOCAL_RESOURCE;
+ }
+ else
+ {
+ ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
+ }
+
+ /* Pop the scope stack */
+
+ if (AcpiNsOpensScope (ObjectType))
+ {
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "(%s): Popping scope for Op [%s] %p\n",
+ AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op));
+
+ AcpiDsScopeStackPop (WalkState);
+ }
+
+ return (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c
new file mode 100644
index 0000000..1981012
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asllookup.c
@@ -0,0 +1,974 @@
+/******************************************************************************
+ *
+ * Module Name: asllookup- Namespace lookup
+ * $Revision: 82 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+
+#include "acparser.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("asllookup")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDoOneNamespaceObject
+ *
+ * PARAMETERS: ACPI_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Dump a namespace object to the namespace output file.
+ * Called during the walk of the namespace to dump all objects.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LsDoOneNamespaceObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+ ACPI_PARSE_OBJECT *Op;
+
+
+ Gbl_NumNamespaceObjects++;
+
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5d [%d] %*s %4.4s - %s",
+ Gbl_NumNamespaceObjects, Level, (Level * 3), " ",
+ &Node->Name,
+ AcpiUtGetTypeName (Node->Type));
+
+ Op = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+
+ if (Op)
+ {
+ if (Op->Asl.ParseOpcode == PARSEOP_NAME)
+ {
+ Op = Op->Asl.Child;
+ }
+
+ switch (Node->Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
+ {
+ Op = Op->Asl.Next;
+ }
+
+ if (Op->Asl.Value.Integer > ACPI_UINT32_MAX)
+ {
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = 0x%X%X]",
+ ACPI_HIDWORD (Op->Asl.Value.Integer64), (UINT32) Op->Asl.Value.Integer);
+ }
+ else
+ {
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = 0x%X]",
+ (UINT32) Op->Asl.Value.Integer);
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
+ {
+ Op = Op->Asl.Next;
+ }
+
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = \"%s\"]",
+ Op->Asl.Value.String);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
+ {
+ Op = Op->Asl.Child;
+ }
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Offset 0x%02X, Length 0x%02X]",
+ Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer);
+ break;
+
+
+ default:
+ /* Nothing to do for other types */
+ break;
+ }
+ }
+
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDisplayNamespace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Walk the namespace an display information about each node
+ * in the tree. Information is written to the optional
+ * namespace output file.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LsDisplayNamespace (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ if (!Gbl_NsOutputFlag)
+ {
+ return (AE_OK);
+ }
+
+ /* File header */
+
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n");
+ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count Depth Name - Type\n\n");
+
+ /* Walk entire namespace from the root */
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject,
+ NULL, NULL);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsCompareOneNamespaceObject
+ *
+ * PARAMETERS: ACPI_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compare name of one object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LsCompareOneNamespaceObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+
+
+ /* Simply check the name */
+
+ if (*((UINT32 *) (Context)) == Node->Name.Integer)
+ {
+ /* Abort walk if we found one instance */
+
+ return (AE_CTRL_TRUE);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LkObjectExists
+ *
+ * PARAMETERS: Name - 4 char ACPI name
+ *
+ * RETURN: TRUE if name exists in namespace
+ *
+ * DESCRIPTION: Walk the namespace to find an object
+ *
+ ******************************************************************************/
+
+BOOLEAN
+LkObjectExists (
+ char *Name)
+{
+ ACPI_STATUS Status;
+
+
+ /* Walk entire namespace from the supplied root */
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject,
+ Name, NULL);
+ if (Status == AE_CTRL_TRUE)
+ {
+ /* At least one instance of the name was found */
+
+ return (TRUE);
+ }
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LkCrossReferenceNamespace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform a cross reference check of the parse tree against the
+ * namespace. Every named referenced within the parse tree
+ * should be get resolved with a namespace lookup. If not, the
+ * original reference in the ASL code is invalid -- i.e., refers
+ * to a non-existent object.
+ *
+ * NOTE: The ASL "External" operator causes the name to be inserted into the
+ * namespace so that references to the external name will be resolved
+ * correctly here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LkCrossReferenceNamespace (
+ void)
+{
+ ACPI_WALK_STATE *WalkState;
+
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n");
+
+ /*
+ * Create a new walk state for use when looking up names
+ * within the namespace (Passed as context to the callbacks)
+ */
+ WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ return AE_NO_MEMORY;
+ }
+
+ /* Walk the entire parse tree */
+
+ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, LkNamespaceLocateBegin,
+ LkNamespaceLocateEnd, WalkState);
+ return AE_OK;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LkCheckFieldRange
+ *
+ * PARAMETERS: RegionBitLength - Length of entire parent region
+ * FieldBitOffset - Start of the field unit (within region)
+ * FieldBitLength - Entire length of field unit
+ * AccessBitWidth - Access width of the field unit
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Check one field unit to make sure it fits in the parent
+ * op region.
+ *
+ * Note: AccessBitWidth must be either 8,16,32, or 64
+ *
+ ******************************************************************************/
+
+void
+LkCheckFieldRange (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 RegionBitLength,
+ UINT32 FieldBitOffset,
+ UINT32 FieldBitLength,
+ UINT32 AccessBitWidth)
+{
+ UINT32 FieldEndBitOffset;
+
+ /*
+ * Check each field unit against the region size. The entire
+ * field unit (start offset plus length) must fit within the
+ * region.
+ */
+ FieldEndBitOffset = FieldBitOffset + FieldBitLength;
+
+ if (FieldEndBitOffset > RegionBitLength)
+ {
+ /* Field definition itself is beyond the end-of-region */
+
+ AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
+ return;
+ }
+
+ /*
+ * Now check that the field plus AccessWidth doesn't go beyond
+ * the end-of-region. Assumes AccessBitWidth is a power of 2
+ */
+ FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
+
+ if (FieldEndBitOffset > RegionBitLength)
+ {
+ /* Field definition combined with the access is beyond EOR */
+
+ AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
+ }
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: LkNamespaceLocateBegin
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Descending callback used during cross-reference. For named
+ * object references, attempt to locate the name in the
+ * namespace.
+ *
+ * NOTE: ASL references to named fields within resource descriptors are
+ * resolved to integer values here. Therefore, this step is an
+ * important part of the code generation. We don't know that the
+ * name refers to a resource descriptor until now.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LkNamespaceLocateBegin (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+ ACPI_OBJECT_TYPE ObjectType;
+ char *Path;
+ UINT8 PassedArgs;
+ ACPI_PARSE_OBJECT *NextOp;
+ ACPI_PARSE_OBJECT *OwningOp;
+ ACPI_PARSE_OBJECT *SpaceIdOp;
+ UINT32 MinimumLength;
+ UINT32 Temp;
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT32 Flags;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("LkNamespaceLocateBegin", Op);
+
+ /*
+ * If this node is the actual declaration of a name
+ * [such as the XXXX name in "Method (XXXX)"],
+ * we are not interested in it here. We only care about names that are
+ * references to other objects within the namespace and the parent objects
+ * of name declarations
+ */
+ if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
+ {
+ return (AE_OK);
+ }
+
+ /* We are only interested in opcodes that have an associated name */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
+
+ if ((!(OpInfo->Flags & AML_NAMED)) &&
+ (!(OpInfo->Flags & AML_CREATE)) &&
+ (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
+ (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
+ (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * We must enable the "search-to-root" for single NameSegs, but
+ * we have to be very careful about opening up scopes
+ */
+ Flags = ACPI_NS_SEARCH_PARENT;
+ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
+ (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+ {
+ /*
+ * These are name references, do not push the scope stack
+ * for them.
+ */
+ Flags |= ACPI_NS_DONT_OPEN_SCOPE;
+ }
+
+ /* Get the NamePath from the appropriate place */
+
+ if (OpInfo->Flags & AML_NAMED)
+ {
+ /* For all NAMED operators, the name reference is the first child */
+
+ Path = Op->Asl.Child->Asl.Value.String;
+ if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
+ {
+ /*
+ * ALIAS is the only oddball opcode, the name declaration
+ * (alias name) is the second operand
+ */
+ Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
+ }
+ }
+ else if (OpInfo->Flags & AML_CREATE)
+ {
+ /* Name must appear as the last parameter */
+
+ NextOp = Op->Asl.Child;
+ while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
+ {
+ NextOp = NextOp->Asl.Next;
+ }
+ Path = NextOp->Asl.Value.String;
+ }
+ else
+ {
+ Path = Op->Asl.Value.String;
+ }
+
+ ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
+
+ /*
+ * Lookup the name in the namespace. Name must exist at this point, or it
+ * is an invalid reference.
+ *
+ * The namespace is also used as a lookup table for references to resource
+ * descriptors and the fields within them.
+ */
+ Gbl_NsLookupCount++;
+
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
+ ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_FOUND)
+ {
+ /*
+ * We didn't find the name reference by path -- we can qualify this
+ * a little better before we print an error message
+ */
+ if (strlen (Path) == ACPI_NAME_SIZE)
+ {
+ /* A simple, one-segment ACPI name */
+
+ if (LkObjectExists (Path))
+ {
+ /* There exists such a name, but we couldn't get to it from this scope */
+
+ AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, Op->Asl.ExternalName);
+ }
+ else
+ {
+ /* The name doesn't exist, period */
+
+ AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
+ }
+ }
+ else
+ {
+ /* Check for a fully qualified path */
+
+ if (Path[0] == AML_ROOT_PREFIX)
+ {
+ /* Gave full path, the object does not exist */
+
+ AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
+ }
+ else
+ {
+ /* We can't tell whether it doesn't exist or just can't be reached. */
+
+ AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName);
+ }
+ }
+
+ Status = AE_OK;
+ }
+ return (Status);
+ }
+
+ /* Attempt to optimize the NamePath */
+
+ OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
+
+ /*
+ * Dereference an alias. (A name reference that is an alias.)
+ * Aliases are not nested; The alias always points to the final object
+ */
+ if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
+ {
+ /* This node points back to the original PARSEOP_ALIAS */
+
+ NextOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+
+ /* The first child is the alias target op */
+
+ NextOp = NextOp->Asl.Child;
+
+ /* Who in turn points back to original target alias node */
+
+ if (NextOp->Asl.Node)
+ {
+ Node = NextOp->Asl.Node;
+ }
+ else
+ {
+ AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "Missing alias link");
+ }
+ }
+
+ /* 1) Check for a reference to a resource descriptor */
+
+ else if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
+ (Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
+ {
+ /*
+ * This was a reference to a field within a resource descriptor. Extract
+ * the associated field offset (either a bit or byte offset depending on
+ * the field type) and change the named reference into an integer for
+ * AML code generation
+ */
+ Temp = (UINT32) Node->OwnerId;
+ if (Node->Flags & ANOBJ_IS_BIT_OFFSET)
+ {
+ Op->Asl.CompileFlags |= NODE_IS_BIT_OFFSET;
+ }
+
+ /* Perform BitOffset <--> ByteOffset conversion if necessary */
+
+ switch (Op->Asl.Parent->Asl.AmlOpcode)
+ {
+ case AML_CREATE_FIELD_OP:
+
+ /* We allow a Byte offset to Bit Offset conversion for this op */
+
+ if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
+ {
+ /* Simply multiply byte offset times 8 to get bit offset */
+
+ Temp = ACPI_MUL_8 (Temp);
+ }
+ break;
+
+
+ case AML_CREATE_BIT_FIELD_OP:
+
+ /* This op requires a Bit Offset */
+
+ if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
+ {
+ AslError (ASL_ERROR, ASL_MSG_BYTES_TO_BITS, Op, NULL);
+ }
+ break;
+
+
+ case AML_CREATE_BYTE_FIELD_OP:
+ case AML_CREATE_WORD_FIELD_OP:
+ case AML_CREATE_DWORD_FIELD_OP:
+ case AML_CREATE_QWORD_FIELD_OP:
+ case AML_INDEX_OP:
+
+ /* These Ops require Byte offsets */
+
+ if (Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
+ {
+ AslError (ASL_ERROR, ASL_MSG_BITS_TO_BYTES, Op, NULL);
+ }
+ break;
+
+
+ default:
+ /* Nothing to do for other opcodes */
+ break;
+ }
+
+ /* Now convert this node to an integer whose value is the field offset */
+
+ Op->Asl.ParseOpcode = PARSEOP_INTEGER;
+ Op->Asl.Value.Integer = (UINT64) Temp;
+ Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
+
+ OpcGenerateAmlOpcode (Op);
+ Op->Asl.AmlLength = OpcSetOptimalIntegerSize (Op);
+ }
+
+ /* 2) Check for a method invocation */
+
+ else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
+ (Node->Type == ACPI_TYPE_METHOD) &&
+ (Op->Asl.Parent) &&
+ (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) ||
+
+ (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+ {
+
+ /*
+ * There are two types of method invocation:
+ * 1) Invocation with arguments -- the parser recognizes this as a METHODCALL
+ * 2) Invocation with no arguments --the parser cannot determine that this is a method
+ * invocation, therefore we have to figure it out here.
+ */
+ if (Node->Type != ACPI_TYPE_METHOD)
+ {
+ sprintf (MsgBuffer, "%s is a %s", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
+
+ AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer);
+ return (AE_OK);
+ }
+
+ /* Save the method node in the caller's op */
+
+ Op->Asl.Node = Node;
+ if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * This is a method invocation, with or without arguments.
+ * Count the number of arguments, each appears as a child
+ * under the parent node
+ */
+ Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
+ UtSetParseOpName (Op);
+
+ PassedArgs = 0;
+ NextOp = Op->Asl.Child;
+
+ while (NextOp)
+ {
+ PassedArgs++;
+ NextOp = NextOp->Asl.Next;
+ }
+
+ if (Node->OwnerId != ASL_EXTERNAL_METHOD)
+ {
+ /*
+ * Check the parsed arguments with the number expected by the
+ * method declaration itself
+ */
+ if (PassedArgs != Node->OwnerId)
+ {
+ sprintf (MsgBuffer, "%s requires %d", Op->Asl.ExternalName,
+ Node->OwnerId);
+
+ if (PassedArgs < Node->OwnerId)
+ {
+ AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer);
+ }
+ else
+ {
+ AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer);
+ }
+ }
+ }
+ }
+
+ /*
+ * 3) Check for an ASL Field definition
+ */
+ else if ((Op->Asl.Parent) &&
+ ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) ||
+ (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
+ {
+ /*
+ * Offset checking for fields. If the parent operation region has a
+ * constant length (known at compile time), we can check fields
+ * defined in that region against the region length. This will catch
+ * fields and field units that cannot possibly fit within the region.
+ *
+ * Note: Index fields do not directly reference an operation region,
+ * thus they are not included in this check.
+ */
+ if (Op == Op->Asl.Parent->Asl.Child)
+ {
+ /*
+ * This is the first child of the field node, which is
+ * the name of the region. Get the parse node for the
+ * region -- which contains the length of the region.
+ */
+ OwningOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+ Op->Asl.Parent->Asl.ExtraValue = ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
+
+ /* Examine the field access width */
+
+ switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
+ {
+ case AML_FIELD_ACCESS_ANY:
+ case AML_FIELD_ACCESS_BYTE:
+ case AML_FIELD_ACCESS_BUFFER:
+ default:
+ MinimumLength = 1;
+ break;
+
+ case AML_FIELD_ACCESS_WORD:
+ MinimumLength = 2;
+ break;
+
+ case AML_FIELD_ACCESS_DWORD:
+ MinimumLength = 4;
+ break;
+
+ case AML_FIELD_ACCESS_QWORD:
+ MinimumLength = 8;
+ break;
+ }
+
+ /*
+ * Is the region at least as big as the access width?
+ * Note: DataTableRegions have 0 length
+ */
+ if (((UINT32) OwningOp->Asl.Value.Integer) &&
+ ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
+ {
+ AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
+ }
+
+ /*
+ * Check EC/CMOS/SMBUS fields to make sure that the correct
+ * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
+ */
+ SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
+ switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
+ {
+ case REGION_EC:
+ case REGION_CMOS:
+
+ if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE)
+ {
+ AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
+ }
+ break;
+
+ case REGION_SMBUS:
+
+ if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER)
+ {
+ AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
+ }
+ break;
+
+ default:
+
+ /* Nothing to do for other address spaces */
+ break;
+ }
+ }
+ else
+ {
+ /*
+ * This is one element of the field list. Check to make sure
+ * that it does not go beyond the end of the parent operation region.
+ *
+ * In the code below:
+ * Op->Asl.Parent->Asl.ExtraValue - Region Length (bits)
+ * Op->Asl.ExtraValue - Field start offset (bits)
+ * Op->Asl.Child->Asl.Value.Integer32 - Field length (bits)
+ * Op->Asl.Child->Asl.ExtraValue - Field access width (bits)
+ */
+ if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
+ {
+ LkCheckFieldRange (Op,
+ Op->Asl.Parent->Asl.ExtraValue,
+ Op->Asl.ExtraValue,
+ (UINT32) Op->Asl.Child->Asl.Value.Integer,
+ Op->Asl.Child->Asl.ExtraValue);
+ }
+ }
+ }
+
+ Op->Asl.Node = Node;
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: LkNamespaceLocateEnd
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Ascending callback used during cross reference. We only
+ * need to worry about scope management here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+LkNamespaceLocateEnd (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_TRACE ("LkNamespaceLocateEnd");
+
+
+ /* We are only interested in opcodes that have an associated name */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
+ if (!(OpInfo->Flags & AML_NAMED))
+ {
+ return (AE_OK);
+ }
+
+ /* Not interested in name references, we did not open a scope for them */
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
+ (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+ (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+ {
+ return (AE_OK);
+ }
+
+ /* Pop the scope stack if necessary */
+
+ if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
+ {
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "%s: Popping scope for Op %p\n",
+ AcpiUtGetTypeName (OpInfo->ObjectType), Op));
+
+ AcpiDsScopeStackPop (WalkState);
+ }
+
+ return (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c
new file mode 100644
index 0000000..37fb5a0
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslmain.c
@@ -0,0 +1,794 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslmain - compiler main and utilities
+ * $Revision: 75 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 _DECLARE_GLOBALS
+
+#include "aslcompiler.h"
+#include "acnamesp.h"
+#include "acapps.h"
+
+#ifdef _DEBUG
+#include <crtdbg.h>
+#endif
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslmain")
+
+BOOLEAN AslToFile = TRUE;
+BOOLEAN DoCompile = TRUE;
+BOOLEAN DoSignon = TRUE;
+
+char hex[] = {'0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F'};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Options
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display option help message
+ *
+ ******************************************************************************/
+
+void
+Options (
+ void)
+{
+
+ printf ("General Output:\n");
+ printf (" -p <prefix> Specify filename prefix for all output files (including .aml)\n");
+ printf (" -vi Less verbose errors and warnings for use with IDEs\n");
+ printf (" -vo Enable optimization comments\n");
+ printf (" -vr Disable remarks\n");
+ printf (" -vs Disable signon\n");
+
+ printf ("\nAML Output:\n");
+ printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n");
+ printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n");
+ printf (" -t<a|c> Create AML in assembler or C hex table (*.hex)\n");
+
+ printf ("\nAML Optimization:\n");
+ printf (" -oa Disable all optimizations (compatibility mode)\n");
+ printf (" -of Disable constant folding\n");
+ printf (" -oi Disable integer optimization to Zero/One/Ones\n");
+ printf (" -on Disable named reference string optimization\n");
+
+ printf ("\nListings:\n");
+ printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n");
+ printf (" -ln Create namespace file (*.nsp)\n");
+ printf (" -ls Create combined source file (expanded includes) (*.src)\n");
+
+ printf ("\nAML Disassembler:\n");
+ printf (" -d [file] Disassemble AML to ASL source code file (*.dsl)\n");
+ printf (" -dc [file] Disassemble AML and immediately compile it\n");
+ printf (" (Obtain DSDT from current system if no input file)\n");
+ printf (" -e Generate External() statements for unresolved symbols\n");
+ printf (" -g Get ACPI tables and write to files (*.dat)\n");
+
+ printf ("\nHelp:\n");
+ printf (" -h Additional help and compiler debug options\n");
+ printf (" -hc Display operators allowed in constant expressions\n");
+ printf (" -hr Display ACPI reserved method names\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Usage
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display help message
+ *
+ ******************************************************************************/
+
+void
+HelpMessage (
+ void)
+{
+
+ printf ("AML output filename generation:\n");
+ printf (" Output filenames are generated by appending an extension to a common\n");
+ printf (" filename prefix. The filename prefix is obtained via one of the\n");
+ printf (" following methods (in priority order):\n");
+ printf (" 1) The -p option specifies the prefix\n");
+ printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n");
+ printf (" 3) The prefix of the input filename\n");
+ printf ("\n");
+
+ Options ();
+
+ printf ("\nCompiler Debug Options:\n");
+ printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n");
+ printf (" Types: Parse/Tree/Both\n");
+ printf (" -f Ignore errors, force creation of AML output file(s)\n");
+ printf (" -c Parse only, no output generation\n");
+ printf (" -ot Display compile times\n");
+ printf (" -x<level> Set debug level for trace output\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Usage
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display usage and option message
+ *
+ ******************************************************************************/
+
+void
+Usage (
+ void)
+{
+
+ printf ("Usage: %s [Options] [InputFile]\n\n", CompilerName);
+ Options ();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslInitialize
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize compiler globals
+ *
+ ******************************************************************************/
+
+void
+AslInitialize (void)
+{
+ UINT32 i;
+
+
+#ifdef _DEBUG
+ _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
+#endif
+
+ AcpiDbgLevel = 0;
+
+ for (i = 0; i < ASL_NUM_FILES; i++)
+ {
+ Gbl_Files[i].Handle = NULL;
+ Gbl_Files[i].Filename = NULL;
+ }
+
+ Gbl_Files[ASL_FILE_STDOUT].Handle = stdout;
+ Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
+
+ Gbl_Files[ASL_FILE_STDERR].Handle = stderr;
+ Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslCommandLine
+ *
+ * PARAMETERS: argc/argv
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Command line processing
+ *
+ ******************************************************************************/
+
+void
+AslCommandLine (
+ int argc,
+ char **argv)
+{
+ BOOLEAN BadCommandLine = FALSE;
+ ACPI_NATIVE_UINT j;
+
+
+ /* Minimum command line contains at least one option or an input file */
+
+ if (argc < 2)
+ {
+ AslCompilerSignon (ASL_FILE_STDOUT);
+ Usage ();
+ exit (1);
+ }
+
+ /* Get the command line options */
+
+ while ((j = AcpiGetopt (argc, argv, "b:cd^efgh^i^l^o:p:rs:t:v:x:")) != EOF) switch (j)
+ {
+ case 'b':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case 'b':
+ AslCompilerdebug = 1; /* same as yydebug */
+ break;
+
+ case 'p':
+ AslCompilerdebug = 1; /* same as yydebug */
+ break;
+
+ case 't':
+ break;
+
+ default:
+ printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+
+ /* Produce debug output file */
+
+ Gbl_DebugFlag = TRUE;
+ break;
+
+
+ case 'c':
+
+ /* Parse only */
+
+ Gbl_ParseOnlyFlag = TRUE;
+ break;
+
+
+ case 'd':
+ switch (AcpiGbl_Optarg[0])
+ {
+ case '^':
+ DoCompile = FALSE;
+ break;
+
+ case 'c':
+ break;
+
+ default:
+ printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+
+ Gbl_DisasmFlag = TRUE;
+ break;
+
+
+ case 'e':
+
+ /* Generate external statements for unresolved symbols */
+
+ Gbl_GenerateExternals = TRUE;
+ break;
+
+
+ case 'f':
+
+ /* Ignore errors and force creation of aml file */
+
+ Gbl_IgnoreErrors = TRUE;
+ break;
+
+
+ case 'g':
+
+ /* Get all ACPI tables */
+
+ Gbl_GetAllTables = TRUE;
+ DoCompile = FALSE;
+ break;
+
+
+ case 'h':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case '^':
+ HelpMessage ();
+ exit (0);
+
+ case 'c':
+ UtDisplayConstantOpcodes ();
+ exit (0);
+
+ case 'r':
+ /* reserved names */
+
+ MpDisplayReservedNames ();
+ exit (0);
+
+ default:
+ printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 'i':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case 'a':
+
+ /* Produce assembly code include file */
+
+ Gbl_AsmIncludeOutputFlag = TRUE;
+ break;
+
+ case 'c':
+
+ /* Produce C include file */
+
+ Gbl_C_IncludeOutputFlag = TRUE;
+ break;
+
+ default:
+ printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 'l':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case '^':
+ /* Produce listing file (Mixed source/aml) */
+
+ Gbl_ListingFlag = TRUE;
+ break;
+
+ case 'n':
+ /* Produce namespace file */
+
+ Gbl_NsOutputFlag = TRUE;
+ break;
+
+ case 's':
+ /* Produce combined source file */
+
+ Gbl_SourceOutputFlag = TRUE;
+ break;
+
+ default:
+ printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 'o':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case 'a':
+
+ /* Disable all optimizations */
+
+ Gbl_FoldConstants = FALSE;
+ Gbl_IntegerOptimizationFlag = FALSE;
+ Gbl_ReferenceOptimizationFlag = FALSE;
+ break;
+
+ case 'f':
+
+ /* Disable folding on "normal" expressions */
+
+ Gbl_FoldConstants = FALSE;
+ break;
+
+ case 'i':
+
+ /* Disable integer optimization to constants */
+
+ Gbl_IntegerOptimizationFlag = FALSE;
+ break;
+
+ case 'n':
+
+ /* Disable named reference optimization */
+
+ Gbl_ReferenceOptimizationFlag = FALSE;
+ break;
+
+ case 't':
+
+ /* Display compile time(s) */
+
+ Gbl_CompileTimesFlag = TRUE;
+ break;
+
+ default:
+ printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 'p':
+
+ /* Override default AML output filename */
+
+ Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
+ Gbl_UseDefaultAmlFilename = FALSE;
+ break;
+
+
+ case 'r':
+ AslToFile = FALSE;
+ break;
+
+
+ case 's':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case 'a':
+
+ /* Produce assembly code output file */
+
+ Gbl_AsmOutputFlag = TRUE;
+ break;
+
+ case 'c':
+
+ /* Produce C hex output file */
+
+ Gbl_C_OutputFlag = TRUE;
+ break;
+
+ default:
+ printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 't':
+
+ /* Produce hex table output file */
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case 'a':
+ Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
+ break;
+
+ case 'c':
+ Gbl_HexOutputFlag = HEX_OUTPUT_C;
+ break;
+
+ default:
+ printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 'v':
+
+ switch (AcpiGbl_Optarg[0])
+ {
+ case 'i':
+ /* Less verbose error messages */
+
+ Gbl_VerboseErrors = FALSE;
+ break;
+
+ case 'o':
+ Gbl_DisplayOptimizations = TRUE;
+ break;
+
+ case 'r':
+ Gbl_DisplayRemarks = FALSE;
+ break;
+
+ case 's':
+ DoSignon = FALSE;
+ break;
+
+ default:
+ printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
+ BadCommandLine = TRUE;
+ break;
+ }
+ break;
+
+
+ case 'x':
+
+ AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
+ break;
+
+
+ default:
+
+ BadCommandLine = TRUE;
+ break;
+ }
+
+ /* Next parameter must be the input filename */
+
+ Gbl_Files[ASL_FILE_INPUT].Filename = argv[AcpiGbl_Optind];
+ if (!Gbl_Files[ASL_FILE_INPUT].Filename && !Gbl_DisasmFlag && !Gbl_GetAllTables)
+ {
+ printf ("Missing input filename\n");
+ BadCommandLine = TRUE;
+ }
+
+ if (DoSignon)
+ {
+ AslCompilerSignon (ASL_FILE_STDOUT);
+ }
+
+ /* Abort if anything went wrong on the command line */
+
+ if (BadCommandLine)
+ {
+ printf ("\n");
+ Usage ();
+ exit (1);
+ }
+
+ if ((AcpiGbl_Optind + 1) < argc)
+ {
+ printf ("Warning: extra arguments (%d) after input filename are ignored\n\n",
+ argc - AcpiGbl_Optind - 1);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: main
+ *
+ * PARAMETERS: Standard argc/argv
+ *
+ * RETURN: Program termination code
+ *
+ * DESCRIPTION: C main routine for the Asl Compiler. Handle command line
+ * options and begin the compile.
+ *
+ ******************************************************************************/
+
+int ACPI_SYSTEM_XFACE
+main (
+ int argc,
+ char **argv)
+{
+ ACPI_STATUS Status;
+ char *Prefix;
+
+
+ /* Init and command line */
+
+ AslInitialize ();
+ AslCommandLine (argc, argv);
+
+ /*
+ * If -p not specified, we will use the input filename as the
+ * output filename prefix
+ */
+ FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
+ &Gbl_DirectoryPath, &Prefix);
+
+ if (Gbl_UseDefaultAmlFilename)
+ {
+ Gbl_OutputFilenamePrefix = Prefix;
+ }
+
+ /*
+ * AML Disassembly (Optional)
+ */
+ if (Gbl_DisasmFlag || Gbl_GetAllTables)
+ {
+ /* ACPI CA subsystem initialization */
+
+ Status = AcpiOsInitialize ();
+ AcpiUtInitGlobals ();
+ Status = AcpiUtMutexInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+
+ Status = AcpiNsRootInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+
+ /* This is where the disassembly happens */
+
+ AcpiGbl_DbOpt_disasm = TRUE;
+ Status = AdAmlDisassemble (AslToFile,
+ Gbl_Files[ASL_FILE_INPUT].Filename,
+ Gbl_OutputFilenamePrefix,
+ &Gbl_Files[ASL_FILE_INPUT].Filename,
+ Gbl_GetAllTables);
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+
+ /*
+ * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
+ * .DSL disassembly file, which can now be compiled if requested
+ */
+ if (DoCompile)
+ {
+ AcpiOsPrintf ("\nCompiling \"%s\"\n",
+ Gbl_Files[ASL_FILE_INPUT].Filename);
+ }
+ }
+
+ /*
+ * ASL Compilation (Optional)
+ */
+ if (DoCompile)
+ {
+ /*
+ * If -p not specified, we will use the input filename as the
+ * output filename prefix
+ */
+ FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
+ &Gbl_DirectoryPath, &Prefix);
+
+ if (Gbl_UseDefaultAmlFilename)
+ {
+ Gbl_OutputFilenamePrefix = Prefix;
+ }
+
+ /* ACPI CA subsystem initialization (Must be re-initialized) */
+
+ Status = AcpiOsInitialize ();
+ AcpiUtInitGlobals ();
+ Status = AcpiUtMutexInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+
+ Status = AcpiNsRootInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return -1;
+ }
+ Status = CmDoCompile ();
+ }
+
+ return (0);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c
new file mode 100644
index 0000000..a770c39
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslmap.c
@@ -0,0 +1,687 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslmap - parser to AML opcode mapping table
+ * $Revision: 70 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "amlcode.h"
+#include "acparser.h"
+
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslmap")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AslMapNamedOpcodeToDataType
+ *
+ * PARAMETERS: Opcode - The Named AML opcode to map
+ *
+ * RETURN: The ACPI type associated with the named opcode
+ *
+ * DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
+ * Named opcodes are a subset of the AML opcodes.
+ *
+ ******************************************************************************/
+
+ACPI_OBJECT_TYPE
+AslMapNamedOpcodeToDataType (
+ UINT16 Opcode)
+{
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ /*
+ * There are some differences from the opcode table types, we
+ * catch them here.
+ */
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+
+ if (Opcode == AML_INT_NAMEPATH_OP)
+ {
+ return (ACPI_TYPE_ANY);
+ }
+
+ if (Opcode == AML_INT_METHODCALL_OP)
+ {
+ return (ACPI_TYPE_ANY);
+ }
+
+ if (OpInfo->Flags & AML_NSOBJECT)
+ {
+ return (OpInfo->ObjectType);
+ }
+
+ return (ACPI_TYPE_ANY);
+}
+
+
+/*******************************************************************************
+ *
+ * DATA STRUCTURE: ReservedMethods
+ *
+ * DESCRIPTION: Contains all reserved methods and names as defined in the
+ * ACPI specification. Used during the analysis phase to
+ * ensure that reserved methods have the required number of
+ * arguments and the proper return type.
+ *
+ * Each entry in the table contains the following items:
+ *
+ * Name - The ACPI reserved name
+ * Args - Number of arguments to the method
+ * Flags - Whether this method must return a value or not
+ *
+ ******************************************************************************/
+
+const ASL_RESERVED_INFO ReservedMethods[] = {
+ {"_AC0", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC1", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC2", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC3", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC4", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC5", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC6", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC7", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC8", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AC9", 0, ASL_RSVD_RETURN_VALUE},
+ {"_ADR", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL0", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL1", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL2", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL3", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL4", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL5", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL6", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL7", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL8", 0, ASL_RSVD_RETURN_VALUE},
+ {"_AL9", 0, ASL_RSVD_RETURN_VALUE},
+ {"_ALN", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_ASI", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_BAS", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_BBN", 0, ASL_RSVD_RETURN_VALUE},
+ {"_BCL", 0, ASL_RSVD_RETURN_VALUE},
+ {"_BCM", 1, 0},
+ {"_BDN", 0, ASL_RSVD_RETURN_VALUE},
+ {"_BFS", 1, 0},
+ {"_BIF", 0, ASL_RSVD_RETURN_VALUE},
+ {"_BM_", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_BST", 0, ASL_RSVD_RETURN_VALUE},
+ {"_BTP", 1, 0},
+ {"_CID", 0, ASL_RSVD_RETURN_VALUE},
+ {"_CRS", 0, ASL_RSVD_RETURN_VALUE},
+ {"_CRT", 0, ASL_RSVD_RETURN_VALUE},
+ {"_CST", 0, ASL_RSVD_RETURN_VALUE},
+ {"_DCK", 1, ASL_RSVD_RETURN_VALUE},
+ {"_DCS", 0, ASL_RSVD_RETURN_VALUE},
+ {"_DDC", 1, ASL_RSVD_RETURN_VALUE},
+ {"_DDN", 0, 0},
+ {"_DEC", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_DGS", 0, ASL_RSVD_RETURN_VALUE},
+ {"_DIS", 0, 0},
+ {"_DMA", 0, ASL_RSVD_RETURN_VALUE},
+ {"_DOD", 0, ASL_RSVD_RETURN_VALUE},
+ {"_DOS", 1, 0},
+ {"_DSS", 1, 0},
+ {"_EC_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_EDL", 0, ASL_RSVD_RETURN_VALUE},
+ {"_EJ0", 1, 0},
+ {"_EJ1", 1, 0},
+ {"_EJ2", 1, 0},
+ {"_EJ3", 1, 0},
+ {"_EJ4", 1, 0},
+ {"_EJD", 0, ASL_RSVD_RETURN_VALUE},
+ {"_FDE", 0, ASL_RSVD_RETURN_VALUE},
+ {"_FDI", 0, ASL_RSVD_RETURN_VALUE},
+ {"_FDM", 1, 0},
+ {"_FIX", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GL_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GLK", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GPD", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GPE", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GRA", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_GTF", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GTM", 0, ASL_RSVD_RETURN_VALUE},
+ {"_GTS", 1, 0},
+ {"_HE_", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_HID", 0, ASL_RSVD_RETURN_VALUE},
+ {"_HOT", 0, ASL_RSVD_RETURN_VALUE},
+ {"_HPP", 0, ASL_RSVD_RETURN_VALUE},
+ {"_INI", 0, 0},
+ {"_INT", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_IRC", 0, 0},
+ {"_LCK", 1, 0},
+ {"_LEN", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_LID", 0, ASL_RSVD_RETURN_VALUE},
+ {"_LL_", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_MAF", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_MAT", 0, ASL_RSVD_RETURN_VALUE},
+ {"_MAX", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_MEM", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_MIF", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_MIN", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_MSG", 1, 0},
+ {"_OFF", 0, 0},
+ {"_ON_", 0, 0},
+ {"_OS_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_OSI", 1, ASL_RSVD_RETURN_VALUE},
+ {"_PCL", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PCT", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PDC", 1, 0},
+ {"_PIC", 1, 0},
+ {"_PPC", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PR0", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PR1", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PR2", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PRS", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PRT", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PRW", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PS0", 0, 0},
+ {"_PS1", 0, 0},
+ {"_PS2", 0, 0},
+ {"_PS3", 0, 0},
+ {"_PSC", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PSL", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PSR", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PSS", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PSV", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PSW", 1, 0},
+ {"_PTC", 0, ASL_RSVD_RETURN_VALUE},
+ {"_PTS", 1, 0},
+ {"_PXM", 0, ASL_RSVD_RETURN_VALUE},
+ {"_RBO", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_RBW", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_REG", 2, 0},
+ {"_REV", 0, ASL_RSVD_RETURN_VALUE},
+ {"_RMV", 0, ASL_RSVD_RETURN_VALUE},
+ {"_RNG", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_ROM", 2, ASL_RSVD_RETURN_VALUE},
+ {"_RW_", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_S0_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S1_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S2_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S3_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S4_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S5_", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S1D", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S2D", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S3D", 0, ASL_RSVD_RETURN_VALUE},
+ {"_S4D", 0, ASL_RSVD_RETURN_VALUE},
+ {"_SB_", 0, ASL_RSVD_SCOPE},
+ {"_SBS", 0, ASL_RSVD_RETURN_VALUE},
+ {"_SCP", 1, 0},
+ {"_SEG", 0, ASL_RSVD_RETURN_VALUE},
+ {"_SHR", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_SI_", 0, ASL_RSVD_SCOPE},
+ {"_SIZ", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_SPD", 1, ASL_RSVD_RETURN_VALUE},
+ {"_SRS", 1, 0},
+ {"_SST", 1, 0},
+ {"_STA", 0, ASL_RSVD_RETURN_VALUE},
+ {"_STM", 3, 0},
+ {"_STR", 0, ASL_RSVD_RETURN_VALUE},
+ {"_SUN", 0, ASL_RSVD_RETURN_VALUE},
+ {"_TC1", 0, ASL_RSVD_RETURN_VALUE},
+ {"_TC2", 0, ASL_RSVD_RETURN_VALUE},
+ {"_TMP", 0, ASL_RSVD_RETURN_VALUE},
+ {"_TRA", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_TRS", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_TSP", 0, ASL_RSVD_RETURN_VALUE},
+ {"_TTP", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_TYP", 0, ASL_RSVD_RESOURCE_NAME},
+ {"_TZ_", 0, ASL_RSVD_SCOPE},
+ {"_TZD", 0, ASL_RSVD_RETURN_VALUE},
+ {"_TZP", 0, ASL_RSVD_RETURN_VALUE},
+ {"_UID", 0, ASL_RSVD_RETURN_VALUE},
+ {"_VPO", 0, ASL_RSVD_RETURN_VALUE},
+ {"_WAK", 1, ASL_RSVD_RETURN_VALUE},
+ {NULL, 0, 0},
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: MpDisplayReservedNames
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print the table above
+ *
+ ******************************************************************************/
+
+void
+MpDisplayReservedNames (
+ void)
+{
+ UINT32 i;
+
+ printf ("Reserved name information\n\n");
+
+ for (i = 0; ReservedMethods[i].Name; i++)
+ {
+ printf ("%s ", ReservedMethods[i].Name);
+
+ if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE)
+ {
+ printf ("Reserved scope name\n");
+ }
+ else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME)
+ {
+ printf ("Resource data type reserved field name\n");
+ }
+ else
+ {
+ printf ("Method with %d arguments, ", ReservedMethods[i].NumArguments);
+ if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE)
+ {
+ printf ("must return a value\n");
+ }
+ else
+ {
+ printf ("no return value\n");
+ }
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * DATA STRUCTURE: AslKeywordMapping
+ *
+ * DESCRIPTION: Maps the ParseOpcode to the actual AML opcode. The parse
+ * opcodes are generated from Bison, and this table must
+ * track any additions to them.
+ *
+ * Each entry in the table contains the following items:
+ *
+ * AML opcode - Opcode that is written to the AML file
+ * Value - Value of the object to be written (if applicable)
+ * Flags - 1) Whether this opcode opens an AML "package".
+ *
+ ******************************************************************************/
+/*
+ * TBD:
+ * AccessAttrib
+ * AccessType
+ * AMlop for DMA?
+ * ObjectType keywords
+ * Register
+ */
+
+const ASL_MAPPING_ENTRY AslKeywordMapping [] =
+{
+/*! [Begin] no source code translation (keep the table structure) */
+
+
+/* ACCESSAS */ OP_TABLE_ENTRY (AML_INT_ACCESSFIELD_OP, 0, 0, 0),
+/* ACCESSATTRIB_BLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_BLOCK, 0, 0),
+/* ACCESSATTRIB_BLOCK_CALL */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_BLOCK_CALL,0, 0),
+/* ACCESSATTRIB_BYTE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_BYTE, 0, 0),
+/* ACCESSATTRIB_WORD_CALL */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_WORD_CALL, 0, 0),
+/* ACCESSATTRIB_QUICK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_QUICK, 0, 0),
+/* ACCESSATTRIB_SND_RCV */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_SEND_RCV, 0, 0),
+/* ACCESSATTRIB_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_WORD, 0, 0),
+/* ACCESSTYPE_ANY */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_ANY, 0, 0),
+/* ACCESSTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_BUFFER, 0, 0),
+/* ACCESSTYPE_BYTE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_BYTE, 0, 0),
+/* ACCESSTYPE_DWORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_DWORD, 0, 0),
+/* ACCESSTYPE_QWORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_QWORD, 0, 0),
+/* ACCESSTYPE_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_WORD, 0, 0),
+/* ACQUIRE */ OP_TABLE_ENTRY (AML_ACQUIRE_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* ADD */ OP_TABLE_ENTRY (AML_ADD_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* ADDRESSSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_BYTE_OP, REGION_FIXED_HW, 0, 0),
+/* ADDRESSTYPE_ACPI */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
+/* ADDRESSTYPE_MEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* ADDRESSTYPE_NVS */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
+/* ADDRESSTYPE_RESERVED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* ALIAS */ OP_TABLE_ENTRY (AML_ALIAS_OP, 0, 0, 0),
+/* AND */ OP_TABLE_ENTRY (AML_BIT_AND_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* ARG0 */ OP_TABLE_ENTRY (AML_ARG0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* ARG1 */ OP_TABLE_ENTRY (AML_ARG1, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* ARG2 */ OP_TABLE_ENTRY (AML_ARG2, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* ARG3 */ OP_TABLE_ENTRY (AML_ARG3, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* ARG4 */ OP_TABLE_ENTRY (AML_ARG4, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* ARG5 */ OP_TABLE_ENTRY (AML_ARG5, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* ARG6 */ OP_TABLE_ENTRY (AML_ARG6, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* BANKFIELD */ OP_TABLE_ENTRY (AML_BANK_FIELD_OP, 0, NODE_AML_PACKAGE, 0),
+/* BREAK */ OP_TABLE_ENTRY (AML_BREAK_OP, 0, 0, 0),
+/* BREAKPOINT */ OP_TABLE_ENTRY (AML_BREAK_POINT_OP, 0, 0, 0),
+/* BUFFER */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_BUFFER),
+/* BUSMASTERTYPE_MASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* BUSMASTERTYPE_NOTMASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* BYTECONST */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, 0, 0, ACPI_BTYPE_INTEGER),
+/* CASE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* CONCATENATE */ OP_TABLE_ENTRY (AML_CONCAT_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
+/* CONCATENATERESTEMPLATE */ OP_TABLE_ENTRY (AML_CONCAT_RES_OP, 0, 0, ACPI_BTYPE_BUFFER),
+/* CONDREFOF */ OP_TABLE_ENTRY (AML_COND_REF_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* CONTINUE */ OP_TABLE_ENTRY (AML_CONTINUE_OP, 0, 0, 0),
+/* COPY */ OP_TABLE_ENTRY (AML_COPY_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
+/* CREATEBITFIELD */ OP_TABLE_ENTRY (AML_CREATE_BIT_FIELD_OP, 0, 0, 0),
+/* CREATEBYTEFIELD */ OP_TABLE_ENTRY (AML_CREATE_BYTE_FIELD_OP, 0, 0, 0),
+/* CREATEDWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_DWORD_FIELD_OP, 0, 0, 0),
+/* CREATEFIELD */ OP_TABLE_ENTRY (AML_CREATE_FIELD_OP, 0, 0, 0),
+/* CREATEQWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_QWORD_FIELD_OP, 0, 0, 0),
+/* CREATEWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_WORD_FIELD_OP, 0, 0, 0),
+/* DATATABLEREGION */ OP_TABLE_ENTRY (AML_DATA_REGION_OP, 0, 0, 0),
+/* DEBUG */ OP_TABLE_ENTRY (AML_DEBUG_OP, 0, 0, ACPI_BTYPE_DEBUG_OBJECT),
+/* DECODETYPE_POS */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* DECODETYPE_SUB */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* DECREMENT */ OP_TABLE_ENTRY (AML_DECREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* DEFAULT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* DEFAULT_ARG */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* DEFINITIONBLOCK */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* DEREFOF */ OP_TABLE_ENTRY (AML_DEREF_OF_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE | ACPI_BTYPE_STRING),
+/* DEVICE */ OP_TABLE_ENTRY (AML_DEVICE_OP, 0, NODE_AML_PACKAGE, 0),
+/* DIVIDE */ OP_TABLE_ENTRY (AML_DIVIDE_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* DMA */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* DMATYPE_A */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* DMATYPE_COMPATIBILITY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* DMATYPE_B */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
+/* DMATYPE_F */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
+/* DWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_DWORD, 0, 0, ACPI_BTYPE_INTEGER),
+/* DWORDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* DWORDMEMORY */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* EISAID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* ELSE */ OP_TABLE_ENTRY (AML_ELSE_OP, 0, NODE_AML_PACKAGE, 0),
+/* ELSEIF */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, NODE_AML_PACKAGE, 0),
+/* ENDDEPENDENTFN */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* ERRORNODE */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0),
+/* EVENT */ OP_TABLE_ENTRY (AML_EVENT_OP, 0, 0, 0),
+/* EXTERNAL */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* FATAL */ OP_TABLE_ENTRY (AML_FATAL_OP, 0, 0, 0),
+/* FIELD */ OP_TABLE_ENTRY (AML_FIELD_OP, 0, NODE_AML_PACKAGE, 0),
+/* FINDSETLEFTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_LEFT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* FINDSETRIGHTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_RIGHT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* FIXEDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* FROMBCD */ OP_TABLE_ENTRY (AML_FROM_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* IF */ OP_TABLE_ENTRY (AML_IF_OP, 0, NODE_AML_PACKAGE, 0),
+/* INCLUDE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* INCLUDE_CSTYLE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* INCLUDE_END */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* INCREMENT */ OP_TABLE_ENTRY (AML_INCREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE),
+/* INDEXFIELD */ OP_TABLE_ENTRY (AML_INDEX_FIELD_OP, 0, NODE_AML_PACKAGE, 0),
+/* INTEGER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* INTERRUPT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* INTLEVEL_ACTIVEHIGH */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* INTLEVEL_ACTIVELOW */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* INTTYPE_EDGE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* INTTYPE_LEVEL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* IO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* IODECODETYPE_10 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* IODECODETYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* IRQ */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* IRQNOFLAGS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* LAND */ OP_TABLE_ENTRY (AML_LAND_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LEQUAL */ OP_TABLE_ENTRY (AML_LEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LGREATER */ OP_TABLE_ENTRY (AML_LGREATER_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LGREATEREQUAL */ OP_TABLE_ENTRY (AML_LGREATEREQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LINE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* LLESS */ OP_TABLE_ENTRY (AML_LLESS_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LLESSEQUAL */ OP_TABLE_ENTRY (AML_LLESSEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LNOT */ OP_TABLE_ENTRY (AML_LNOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LNOTEQUAL */ OP_TABLE_ENTRY (AML_LNOTEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LOAD */ OP_TABLE_ENTRY (AML_LOAD_OP, 0, 0, 0),
+/* LOADTABLE */ OP_TABLE_ENTRY (AML_LOAD_TABLE_OP, 0, 0, ACPI_BTYPE_DDB_HANDLE),
+/* LOCAL0 */ OP_TABLE_ENTRY (AML_LOCAL0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL1 */ OP_TABLE_ENTRY (AML_LOCAL1, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL2 */ OP_TABLE_ENTRY (AML_LOCAL2, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL3 */ OP_TABLE_ENTRY (AML_LOCAL3, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL4 */ OP_TABLE_ENTRY (AML_LOCAL4, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL5 */ OP_TABLE_ENTRY (AML_LOCAL5, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL6 */ OP_TABLE_ENTRY (AML_LOCAL6, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCAL7 */ OP_TABLE_ENTRY (AML_LOCAL7, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* LOCKRULE_LOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_ALWAYS, 0, 0),
+/* LOCKRULE_NOLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_NEVER, 0, 0),
+/* LOR */ OP_TABLE_ENTRY (AML_LOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* MATCH */ OP_TABLE_ENTRY (AML_MATCH_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* MATCHTYPE_MEQ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MEQ, 0, ACPI_BTYPE_INTEGER),
+/* MATCHTYPE_MGE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGE, 0, ACPI_BTYPE_INTEGER),
+/* MATCHTYPE_MGT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGT, 0, ACPI_BTYPE_INTEGER),
+/* MATCHTYPE_MLE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MLE, 0, ACPI_BTYPE_INTEGER),
+/* MATCHTYPE_MLT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MLT, 0, ACPI_BTYPE_INTEGER),
+/* MATCHTYPE_MTR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MTR, 0, ACPI_BTYPE_INTEGER),
+/* MAXTYPE_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* MAXTYPE_NOTFIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* MEMORY24 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* MEMORY32 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* MEMORY32FIXED */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* MEMTYPE_CACHEABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* MEMTYPE_NONCACHEABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* MEMTYPE_PREFETCHABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
+/* MEMTYPE_WRITECOMBINING */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
+/* METHOD */ OP_TABLE_ENTRY (AML_METHOD_OP, 0, NODE_AML_PACKAGE, 0),
+/* METHODCALL */ OP_TABLE_ENTRY (AML_INT_METHODCALL_OP, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
+/* MID */ OP_TABLE_ENTRY (AML_MID_OP, 0, 0, ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER),
+/* MINTYPE_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* MINTYPE_NOTFIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* MOD */ OP_TABLE_ENTRY (AML_MOD_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* MULTIPLY */ OP_TABLE_ENTRY (AML_MULTIPLY_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* MUTEX */ OP_TABLE_ENTRY (AML_MUTEX_OP, 0, 0, 0),
+/* NAME */ OP_TABLE_ENTRY (AML_NAME_OP, 0, 0, 0),
+/* NAMESEG */ OP_TABLE_ENTRY (AML_INT_NAMEPATH_OP, 0, 0, 0),
+/* NAMESTRING */ OP_TABLE_ENTRY (AML_INT_NAMEPATH_OP, 0, 0, 0),
+/* NAND */ OP_TABLE_ENTRY (AML_BIT_NAND_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* NOOP */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0),
+/* NOR */ OP_TABLE_ENTRY (AML_BIT_NOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* NOT */ OP_TABLE_ENTRY (AML_BIT_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* NOTIFY */ OP_TABLE_ENTRY (AML_NOTIFY_OP, 0, 0, 0),
+/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER_FIELD, 0, 0),
+/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER, 0, 0),
+/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DDB_HANDLE, 0, 0),
+/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DEVICE, 0, 0),
+/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_EVENT, 0, 0),
+/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_FIELD_UNIT, 0, 0),
+/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_INTEGER, 0, 0),
+/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_METHOD, 0, 0),
+/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_MUTEX, 0, 0),
+/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_REGION, 0, 0),
+/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PACKAGE, 0, 0),
+/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_POWER, 0, 0),
+/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_STRING, 0, 0),
+/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_THERMAL, 0, 0),
+/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_ANY, 0, 0),
+/* OFFSET */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
+/* ONE */ OP_TABLE_ENTRY (AML_ONE_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* ONES */ OP_TABLE_ENTRY (AML_ONES_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* OPERATIONREGION */ OP_TABLE_ENTRY (AML_REGION_OP, 0, 0, 0),
+/* OR */ OP_TABLE_ENTRY (AML_BIT_OR_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* PACKAGE */ OP_TABLE_ENTRY (AML_PACKAGE_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
+/* PACKAGEP_LENGTH */ OP_TABLE_ENTRY (AML_PACKAGE_LENGTH, 0, NODE_AML_PACKAGE, 0),
+/* POWERRESOURCE */ OP_TABLE_ENTRY (AML_POWER_RES_OP, 0, NODE_AML_PACKAGE, 0),
+/* PROCESSOR */ OP_TABLE_ENTRY (AML_PROCESSOR_OP, 0, NODE_AML_PACKAGE, 0),
+/* QWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER),
+/* QWORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* QWORDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* RANGE_TYPE_ENTIRE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
+/* RANGE_TYPE_ISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
+/* RANGE_TYPE_NONISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* RAW_DATA */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* READWRITETYPE_BOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* READWRITETYPE_READONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE),
+/* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_CMOS, 0, 0),
+/* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_EC, 0, 0),
+/* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IO, 0, 0),
+/* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_MEMORY, 0, 0),
+/* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_CONFIG, 0, 0),
+/* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_BAR, 0, 0),
+/* REGIONSPACE_SMBUS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_SMBUS, 0, 0),
+/* REGISTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* RELEASE */ OP_TABLE_ENTRY (AML_RELEASE_OP, 0, 0, 0),
+/* RESERVED_BYTES */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
+/* RESET */ OP_TABLE_ENTRY (AML_RESET_OP, 0, 0, 0),
+/* RESOURCETEMPLATE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, 0, ACPI_BTYPE_BUFFER),
+/* RESOURCETYPE_CONSUMER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* RESOURCETYPE_PRODUCER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* RETURN */ OP_TABLE_ENTRY (AML_RETURN_OP, 0, 0, 0),
+/* REVISION */ OP_TABLE_ENTRY (AML_REVISION_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* SCOPE */ OP_TABLE_ENTRY (AML_SCOPE_OP, 0, NODE_AML_PACKAGE, 0),
+/* SERIALIZERULE_NOTSERIAL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* SERIALIZERULE_SERIAL */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* SHARETYPE_EXCLUSIVE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* SHARETYPE_SHARED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* SHIFTLEFT */ OP_TABLE_ENTRY (AML_SHIFT_LEFT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* SHIFTRIGHT */ OP_TABLE_ENTRY (AML_SHIFT_RIGHT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* SIGNAL */ OP_TABLE_ENTRY (AML_SIGNAL_OP, 0, 0, 0),
+/* SIZEOF */ OP_TABLE_ENTRY (AML_SIZE_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* SLEEP */ OP_TABLE_ENTRY (AML_SLEEP_OP, 0, 0, 0),
+/* STALL */ OP_TABLE_ENTRY (AML_STALL_OP, 0, 0, 0),
+/* STARTDEPENDENTFN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* STARTDEPENDENTFN_NOPRI */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* STORE */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
+/* STRING_LITERAL */ OP_TABLE_ENTRY (AML_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
+/* SUBTRACT */ OP_TABLE_ENTRY (AML_SUBTRACT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* SWITCH */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
+/* THERMALZONE */ OP_TABLE_ENTRY (AML_THERMAL_ZONE_OP, 0, NODE_AML_PACKAGE, 0),
+/* TOBCD */ OP_TABLE_ENTRY (AML_TO_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* TOBUFFER */ OP_TABLE_ENTRY (AML_TO_BUFFER_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
+/* TODECIMALSTRING */ OP_TABLE_ENTRY (AML_TO_DECSTRING_OP, 0, 0, ACPI_BTYPE_STRING),
+/* TOHEXSTRING */ OP_TABLE_ENTRY (AML_TO_HEXSTRING_OP, 0, 0, ACPI_BTYPE_STRING),
+/* TOINTEGER */ OP_TABLE_ENTRY (AML_TO_INTEGER_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* TOSTRING */ OP_TABLE_ENTRY (AML_TO_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
+/* TRANSLATIONTYPE_DENSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* TRANSLATIONTYPE_SPARSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* TYPE_STATIC */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* TYPE_TRANSLATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* UNICODE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, 0),
+/* UNLOAD */ OP_TABLE_ENTRY (AML_UNLOAD_OP, 0, 0, 0),
+/* UPDATERULE_ONES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ONES, 0, 0),
+/* UPDATERULE_PRESERVE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_PRESERVE, 0, 0),
+/* UPDATERULE_ZEROS */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ZEROS,0, 0),
+/* VAR_PACKAGE */ OP_TABLE_ENTRY (AML_VAR_PACKAGE_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
+/* VENDORLONG */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* VENDORSHORT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* WAIT */ OP_TABLE_ENTRY (AML_WAIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* WHILE */ OP_TABLE_ENTRY (AML_WHILE_OP, 0, NODE_AML_PACKAGE, 0),
+/* WORDBUSNUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* WORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_WORD, 0, 0, ACPI_BTYPE_INTEGER),
+/* WORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* XFERTYPE_8 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
+/* XFERTYPE_8_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
+/* XFERTYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
+/* XOR */ OP_TABLE_ENTRY (AML_BIT_XOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* ZERO */ OP_TABLE_ENTRY (AML_ZERO_OP, 0, 0, ACPI_BTYPE_INTEGER),
+
+/*! [End] no source code translation !*/
+
+};
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c
new file mode 100644
index 0000000..c9581e6
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c
@@ -0,0 +1,620 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslopcode - AML opcode generation
+ * $Revision: 54 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslopcodes")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcAmlOpcodeWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
+ * operands.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OpcAmlOpcodeWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ TotalParseNodes++;
+
+ OpcGenerateAmlOpcode (Op);
+ OpnGenerateAmlOperands (Op);
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcGetIntegerWidth
+ *
+ * PARAMETERS: Op - DEFINITION BLOCK op
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Extract integer width from the table revision
+ *
+ ******************************************************************************/
+
+void
+OpcGetIntegerWidth (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Child;
+
+ if (!Op)
+ {
+ return;
+ }
+
+ Child = Op->Asl.Child;
+ Child = Child->Asl.Next;
+ Child = Child->Asl.Next;
+
+ /* Use the revision to set the integer width */
+
+ AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcSetOptimalIntegerSize
+ *
+ * PARAMETERS: Op - A parse tree node
+ *
+ * RETURN: Integer width, in bytes. Also sets the node AML opcode to the
+ * optimal integer AML prefix opcode.
+ *
+ * DESCRIPTION: Determine the optimal AML encoding of an integer. All leading
+ * zeros can be truncated to squeeze the integer into the
+ * minimal number of AML bytes.
+ *
+ ******************************************************************************/
+
+UINT32
+OpcSetOptimalIntegerSize (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ /*
+ * Check for the special AML integers first - Zero, One, Ones.
+ * These are single-byte opcodes that are the smallest possible
+ * representation of an integer.
+ *
+ * This optimization is optional.
+ */
+ if (Gbl_IntegerOptimizationFlag)
+ {
+ switch (Op->Asl.Value.Integer)
+ {
+ case 0:
+
+ Op->Asl.AmlOpcode = AML_ZERO_OP;
+ AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Zero");
+ return 1;
+
+ case 1:
+
+ Op->Asl.AmlOpcode = AML_ONE_OP;
+ AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "One");
+ return 1;
+
+ case ACPI_UINT32_MAX:
+
+ /* Check for table integer width (32 or 64) */
+
+ if (AcpiGbl_IntegerByteWidth == 4)
+ {
+ Op->Asl.AmlOpcode = AML_ONES_OP;
+ AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Ones");
+ return 1;
+ }
+ break;
+
+ case ACPI_INTEGER_MAX:
+
+ /* Check for table integer width (32 or 64) */
+
+ if (AcpiGbl_IntegerByteWidth == 8)
+ {
+ Op->Asl.AmlOpcode = AML_ONES_OP;
+ AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Ones");
+ return 1;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /* Find the best fit using the various AML integer prefixes */
+
+ if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
+ {
+ Op->Asl.AmlOpcode = AML_BYTE_OP;
+ return 1;
+ }
+ if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
+ {
+ Op->Asl.AmlOpcode = AML_WORD_OP;
+ return 2;
+ }
+ if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
+ {
+ Op->Asl.AmlOpcode = AML_DWORD_OP;
+ return 4;
+ }
+ else
+ {
+ Op->Asl.AmlOpcode = AML_QWORD_OP;
+ return 8;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcDoAccessAs
+ *
+ * PARAMETERS: Op - Parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Implement the ACCESS_AS ASL keyword.
+ *
+ ******************************************************************************/
+
+void
+OpcDoAccessAs (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ Op->Asl.AmlOpcodeLength = 1;
+ Next = Op->Asl.Child;
+
+ /* First child is the access type */
+
+ Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
+ Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+
+ /* Second child is the optional access attribute */
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
+ {
+ Next->Asl.Value.Integer = 0;
+ }
+ Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
+ Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcDoUnicode
+ *
+ * PARAMETERS: Op - Parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
+ * to a unicode buffer. There is no Unicode AML opcode.
+ *
+ * Note: The Unicode string is 16 bits per character, no leading signature,
+ * with a 16-bit terminating NULL.
+ *
+ ******************************************************************************/
+
+void
+OpcDoUnicode (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *InitializerOp;
+ UINT32 Length;
+ UINT32 Count;
+ UINT32 i;
+ UINT8 *AsciiString;
+ UINT16 *UnicodeString;
+ ACPI_PARSE_OBJECT *BufferLengthOp;
+
+
+ /* Change op into a buffer object */
+
+ Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
+ Op->Asl.ParseOpcode = PARSEOP_BUFFER;
+ UtSetParseOpName (Op);
+
+ /* Buffer Length is first, followed by the string */
+
+ BufferLengthOp = Op->Asl.Child;
+ InitializerOp = BufferLengthOp->Asl.Next;
+
+ AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
+
+ /* Create a new buffer for the Unicode string */
+
+ Count = strlen (InitializerOp->Asl.Value.String) + 1;
+ Length = Count * sizeof (UINT16);
+ UnicodeString = UtLocalCalloc (Length);
+
+ /* Convert to Unicode string (including null terminator) */
+
+ for (i = 0; i < Count; i++)
+ {
+ UnicodeString[i] = (UINT16) AsciiString[i];
+ }
+
+ /*
+ * Just set the buffer size node to be the buffer length, regardless
+ * of whether it was previously an integer or a default_arg placeholder
+ */
+ BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
+ BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
+ BufferLengthOp->Asl.Value.Integer = Length;
+ UtSetParseOpName (BufferLengthOp);
+
+ (void) OpcSetOptimalIntegerSize (BufferLengthOp);
+
+ /* The Unicode string is a raw data buffer */
+
+ InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString;
+ InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
+ InitializerOp->Asl.AmlLength = Length;
+ InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+ InitializerOp->Asl.Child = NULL;
+ UtSetParseOpName (InitializerOp);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcDoEisaId
+ *
+ * PARAMETERS: Op - Parse node
+ *
+ * RETURN: None
+ *
+ *
+ * DESCRIPTION: Convert a string EISA ID to numeric representation. See the
+ * Pnp BIOS Specification for details. Here is an excerpt:
+ *
+ * A seven character ASCII representation of the product
+ * identifier compressed into a 32-bit identifier. The seven
+ * character ID consists of a three character manufacturer code,
+ * a three character hexadecimal product identifier, and a one
+ * character hexadecimal revision number. The manufacturer code
+ * is a 3 uppercase character code that is compressed into 3 5-bit
+ * values as follows:
+ * 1) Find hex ASCII value for each letter
+ * 2) Subtract 40h from each ASCII value
+ * 3) Retain 5 least signficant bits for each letter by
+ * discarding upper 3 bits because they are always 0.
+ * 4) Compressed code = concatenate 0 and the 3 5-bit values
+ *
+ * The format of the compressed product identifier is as follows:
+ * Byte 0: Bit 7 - Reserved (0)
+ * Bits 6-2: - 1st character of compressed mfg code
+ * Bits 1-0 - Upper 2 bits of 2nd character of mfg code
+ * Byte 1: Bits 7-5 - Lower 3 bits of 2nd character of mfg code
+ * Bits 4-0 - 3rd character of mfg code
+ * Byte 2: Bits 7-4 - 1st hex digit of product number
+ * Bits 3-0 - 2nd hex digit of product number
+ * Byte 3: Bits 7-4 - 3st hex digit of product number
+ * Bits 3-0 - Hex digit of the revision number
+ *
+ ******************************************************************************/
+
+void
+OpcDoEisaId (
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT32 EisaId = 0;
+ UINT32 BigEndianId;
+ char *InString;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_NATIVE_UINT i;
+
+
+ InString = (char *) Op->Asl.Value.String;
+
+ /*
+ * The EISAID string must be exactly 7 characters and of the form
+ * "LLLXXXX" -- 3 letters and 4 hex digits (e.g., "PNP0001")
+ */
+ if (ACPI_STRLEN (InString) != 7)
+ {
+ Status = AE_BAD_PARAMETER;
+ }
+ else
+ {
+ /* Check all 7 characters for correct format */
+
+ for (i = 0; i < 7; i++)
+ {
+ /* First 3 characters must be letters */
+
+ if (i < 3)
+ {
+ if (!isalpha (InString[i]))
+ {
+ Status = AE_BAD_PARAMETER;
+ }
+ }
+
+ /* Last 4 characters must be hex digits */
+
+ else if (!isxdigit (InString[i]))
+ {
+ Status = AE_BAD_PARAMETER;
+ }
+ }
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
+ }
+ else
+ {
+ /* Create ID big-endian first (bits are contiguous) */
+
+ BigEndianId = (UINT32) (InString[0] - 0x40) << 26 |
+ (UINT32) (InString[1] - 0x40) << 21 |
+ (UINT32) (InString[2] - 0x40) << 16 |
+
+ (UtHexCharToValue (InString[3])) << 12 |
+ (UtHexCharToValue (InString[4])) << 8 |
+ (UtHexCharToValue (InString[5])) << 4 |
+ UtHexCharToValue (InString[6]);
+
+ /* Swap to little-endian to get final ID (see function header) */
+
+ EisaId = AcpiUtDwordByteSwap (BigEndianId);
+ }
+
+ /*
+ * Morph the Op into an integer, regardless of whether there
+ * was an error in the EISAID string
+ */
+ Op->Asl.Value.Integer = EisaId;
+
+ Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
+ Op->Asl.ParseOpcode = PARSEOP_INTEGER;
+ (void) OpcSetOptimalIntegerSize (Op);
+
+ /* Op is now an integer */
+
+ UtSetParseOpName (Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpcGenerateAmlOpcode
+ *
+ * PARAMETERS: Op - Parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generate the AML opcode associated with the node and its
+ * parse (lex/flex) keyword opcode. Essentially implements
+ * a mapping between the parse opcodes and the actual AML opcodes.
+ *
+ ******************************************************************************/
+
+void
+OpcGenerateAmlOpcode (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ UINT16 Index;
+
+
+ Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
+
+ Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode;
+ Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype;
+ Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
+
+ if (!Op->Asl.Value.Integer)
+ {
+ Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
+ }
+
+ /* Special handling for some opcodes */
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_INTEGER:
+ /*
+ * Set the opcode based on the size of the integer
+ */
+ (void) OpcSetOptimalIntegerSize (Op);
+ break;
+
+ case PARSEOP_OFFSET:
+
+ Op->Asl.AmlOpcodeLength = 1;
+ break;
+
+ case PARSEOP_ACCESSAS:
+
+ OpcDoAccessAs (Op);
+ break;
+
+ case PARSEOP_EISAID:
+
+ OpcDoEisaId (Op);
+ break;
+
+ case PARSEOP_UNICODE:
+
+ OpcDoUnicode (Op);
+ break;
+
+ case PARSEOP_INCLUDE:
+
+ Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ Gbl_HasIncludeFiles = TRUE;
+ break;
+
+ case PARSEOP_EXTERNAL:
+
+ Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ break;
+
+ case PARSEOP_PACKAGE:
+ /*
+ * The variable-length package has a different opcode
+ */
+ if ((Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) &&
+ (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_BYTECONST))
+ {
+ Op->Asl.AmlOpcode = AML_VAR_PACKAGE_OP;
+ }
+ break;
+
+ default:
+ /* Nothing to do for other opcodes */
+ break;
+ }
+
+ return;
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c
new file mode 100644
index 0000000..a92d0cc
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asloperands.c
@@ -0,0 +1,1112 @@
+
+/******************************************************************************
+ *
+ * Module Name: asloperands - AML operand processing
+ * $Revision: 45 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("asloperands")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoMethod
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
+ *
+ ******************************************************************************/
+
+void
+OpnDoMethod (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+ /* Optional arguments for this opcode with defaults */
+
+ UINT8 NumArgs = 0;
+ UINT8 Serialized = 0;
+ UINT8 Concurrency = 0;
+ UINT8 MethodFlags;
+
+
+ /* Opcode and package length first */
+ /* Method name */
+
+ Next = Op->Asl.Child;
+
+ /* Num args */
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ NumArgs = (UINT8) Next->Asl.Value.Integer;
+ Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ }
+
+ /* Serialized Flag */
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Serialized = (UINT8) Next->Asl.Value.Integer;
+ Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ }
+
+ /* Concurrency value (0-15 valid) */
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Concurrency = (UINT8) Next->Asl.Value.Integer;
+ }
+
+ /* Put the bits in their proper places */
+
+ MethodFlags = (UINT8) ((NumArgs & 0x7) |
+ ((Serialized & 0x1) << 3) |
+ ((Concurrency & 0xF) << 4));
+
+ /* Use the last node for the combined flags byte */
+
+ Next->Asl.Value.Integer = MethodFlags;
+ Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
+ Next->Asl.AmlLength = 1;
+ Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+
+ /* Save the arg count in the first node */
+
+ Op->Asl.Extra = NumArgs;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoFieldCommon
+ *
+ * PARAMETERS: FieldOp - Node for an ASL field
+ * Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the various field keywords,
+ * FIELD, BANKFIELD, INDEXFIELD
+ *
+ ******************************************************************************/
+
+void
+OpnDoFieldCommon (
+ ACPI_PARSE_OBJECT *FieldOp,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+ ACPI_PARSE_OBJECT *PkgLengthNode;
+ UINT32 CurrentBitOffset;
+ UINT32 NewBitOffset;
+ UINT8 AccessType;
+ UINT8 LockRule;
+ UINT8 UpdateRule;
+ UINT8 FieldFlags;
+ UINT32 MinimumLength;
+
+
+ /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
+
+ AccessType = (UINT8) Op->Asl.Value.Integer;
+ Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+
+ /* Set the access type in the parent (field) node for use later */
+
+ FieldOp->Asl.Value.Integer = AccessType;
+
+ /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
+
+ Next = Op->Asl.Next;
+ LockRule = (UINT8) Next->Asl.Value.Integer;
+ Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+
+ /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
+
+ Next = Next->Asl.Next;
+ UpdateRule = (UINT8) Next->Asl.Value.Integer;
+
+ /*
+ * Generate the flags byte. The various fields are already
+ * in the right bit position via translation from the
+ * keywords by the parser.
+ */
+ FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule);
+
+ /* Use the previous node to be the FieldFlags node */
+
+ /* Set the node to RAW_DATA */
+
+ Next->Asl.Value.Integer = FieldFlags;
+ Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
+ Next->Asl.AmlLength = 1;
+ Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+
+ /* Process the FieldUnitList */
+
+ Next = Next->Asl.Next;
+ CurrentBitOffset = 0;
+
+ while (Next)
+ {
+ /* Save the offset of this field unit */
+
+ Next->Asl.ExtraValue = CurrentBitOffset;
+
+ switch (Next->Asl.ParseOpcode)
+ {
+ case PARSEOP_ACCESSAS:
+
+ PkgLengthNode = Next->Asl.Child;
+ AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer;
+
+ /* Nothing additional to do */
+ break;
+
+
+ case PARSEOP_OFFSET:
+
+ /* New offset into the field */
+
+ PkgLengthNode = Next->Asl.Child;
+ NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8;
+
+ /*
+ * Examine the specified offset in relation to the
+ * current offset counter.
+ */
+ if (NewBitOffset < CurrentBitOffset)
+ {
+ /*
+ * Not allowed to specify a backwards offset!
+ * Issue error and ignore this node.
+ */
+ AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode, NULL);
+ Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ }
+ else if (NewBitOffset == CurrentBitOffset)
+ {
+ /*
+ * Offset is redundant; we don't need to output an
+ * offset opcode. Just set these nodes to default
+ */
+ Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ }
+ else
+ {
+ /*
+ * Valid new offset - set the value to be inserted into the AML
+ * and update the offset counter.
+ */
+ PkgLengthNode->Asl.Value.Integer = NewBitOffset - CurrentBitOffset;
+ CurrentBitOffset = NewBitOffset;
+ }
+ break;
+
+
+ case PARSEOP_NAMESEG:
+ case PARSEOP_RESERVED_BYTES:
+
+ /* Named or reserved field entry */
+
+ PkgLengthNode = Next->Asl.Child;
+ NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer;
+ CurrentBitOffset += NewBitOffset;
+
+ /* Save the current AccessAs value for error checking later */
+
+ switch (AccessType)
+ {
+ case AML_FIELD_ACCESS_ANY:
+ case AML_FIELD_ACCESS_BYTE:
+ case AML_FIELD_ACCESS_BUFFER:
+ default:
+ MinimumLength = 8;
+ break;
+
+ case AML_FIELD_ACCESS_WORD:
+ MinimumLength = 16;
+ break;
+
+ case AML_FIELD_ACCESS_DWORD:
+ MinimumLength = 32;
+ break;
+
+ case AML_FIELD_ACCESS_QWORD:
+ MinimumLength = 64;
+ break;
+ }
+
+ PkgLengthNode->Asl.ExtraValue = MinimumLength;
+ break;
+
+ default:
+ /* All supported field opcodes must appear above */
+ break;
+ }
+
+ /* Move on to next entry in the field list */
+
+ Next = Next->Asl.Next;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoField
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
+ *
+ ******************************************************************************/
+
+void
+OpnDoField (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ /* Opcode is parent node */
+ /* First child is field name */
+
+ Next = Op->Asl.Child;
+
+ /* Second child is the AccessType */
+
+ OpnDoFieldCommon (Op, Next->Asl.Next);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoIndexField
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
+ *
+ ******************************************************************************/
+
+void
+OpnDoIndexField (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ /* Opcode is parent node */
+ /* First child is the index name */
+
+ Next = Op->Asl.Child;
+
+ /* Second child is the data name */
+
+ Next = Next->Asl.Next;
+
+ /* Third child is the AccessType */
+
+ OpnDoFieldCommon (Op, Next->Asl.Next);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoBankField
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
+ *
+ ******************************************************************************/
+
+void
+OpnDoBankField (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ /* Opcode is parent node */
+ /* First child is the region name */
+
+ Next = Op->Asl.Child;
+
+ /* Second child is the bank name */
+
+ Next = Next->Asl.Next;
+
+ /* Third child is the bank value */
+
+ Next = Next->Asl.Next;
+
+ /* Fourth child is the AccessType */
+
+ OpnDoFieldCommon (Op, Next->Asl.Next);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoRegion
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Tries to get the length of the region. Can only do this at
+ * compile time if the length is a constant.
+ *
+ ******************************************************************************/
+
+void
+OpnDoRegion (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ /* Opcode is parent node */
+ /* First child is the region name */
+
+ Next = Op->Asl.Child;
+
+ /* Second child is the space ID*/
+
+ Next = Next->Asl.Next;
+
+ /* Third child is the region offset */
+
+ Next = Next->Asl.Next;
+
+ /* Fourth child is the region length */
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode == PARSEOP_INTEGER)
+ {
+ Op->Asl.Value.Integer = Next->Asl.Value.Integer;
+ }
+ else
+ {
+ Op->Asl.Value.Integer = ACPI_INTEGER_MAX;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoBuffer
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
+ * build a single raw byte buffer from the initialization nodes,
+ * each parse node contains a buffer byte.
+ *
+ ******************************************************************************/
+
+void
+OpnDoBuffer (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ACPI_PARSE_OBJECT *BufferLengthOp;
+
+ /* Optional arguments for this opcode with defaults */
+
+ UINT32 BufferLength = 0;
+
+
+ /* Opcode and package length first */
+ /* Buffer Length is next, followed by the initializer list */
+
+ BufferLengthOp = Op->Asl.Child;
+ InitializerOp = BufferLengthOp->Asl.Next;
+
+ /*
+ * If the BufferLength is not an INTEGER or was not specified in the ASL
+ * (DEFAULT_ARG), it is a TermArg that is
+ * evaluated at run-time, and we are therefore finished.
+ */
+ if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
+ (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
+ {
+ return;
+ }
+
+ /*
+ * We want to count the number of items in the initializer list, because if
+ * it is larger than the buffer length, we will define the buffer size
+ * to be the size of the initializer list (as per the ACPI Specification)
+ */
+ switch (InitializerOp->Asl.ParseOpcode)
+ {
+ case PARSEOP_INTEGER:
+ case PARSEOP_BYTECONST:
+ case PARSEOP_WORDCONST:
+ case PARSEOP_DWORDCONST:
+
+ /* The peer list contains the byte list (if any...) */
+
+ while (InitializerOp)
+ {
+ /* For buffers, this is a list of raw bytes */
+
+ InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
+ InitializerOp->Asl.AmlLength = 1;
+ InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+
+ BufferLength++;
+ InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
+ }
+ break;
+
+
+ case PARSEOP_STRING_LITERAL:
+
+ /*
+ * Only one initializer, the string. Buffer must be big enough to hold
+ * the string plus the null termination byte
+ */
+ BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
+
+ InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
+ InitializerOp->Asl.AmlLength = BufferLength;
+ InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+ break;
+
+
+ case PARSEOP_RAW_DATA:
+
+ /* Buffer nodes are already initialized (e.g. Unicode operator) */
+ return;
+
+
+ case PARSEOP_DEFAULT_ARG:
+ break;
+
+
+ default:
+ AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
+ "Unknown buffer initializer opcode");
+ printf ("Unknown buffer initializer opcode [%s]\n",
+ UtGetOpName (InitializerOp->Asl.ParseOpcode));
+ return;
+ }
+
+ /* Check if initializer list is longer than the buffer length */
+
+ if (BufferLengthOp->Asl.Value.Integer > BufferLength)
+ {
+ BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
+ }
+
+ if (!BufferLength)
+ {
+ /* No length AND no items -- issue a warning */
+
+ AslError (ASL_WARNING, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
+
+ /* But go ahead and put the buffer length of zero into the AML */
+ }
+
+ /*
+ * Just set the buffer size node to be the buffer length, regardless
+ * of whether it was previously an integer or a default_arg placeholder
+ */
+ BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
+ BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
+ BufferLengthOp->Asl.Value.Integer = BufferLength;
+
+ (void) OpcSetOptimalIntegerSize (BufferLengthOp);
+
+ /* Remaining nodes are handled via the tree walk */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoPackage
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword.
+ *
+ ******************************************************************************/
+
+void
+OpnDoPackage (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ACPI_PARSE_OBJECT *PackageLengthOp;
+
+ /* Optional arguments for this opcode with defaults */
+
+ UINT32 PackageLength = 0;
+
+
+ /* Opcode and package length first */
+ /* Buffer Length is next, followed by the initializer list */
+
+ PackageLengthOp = Op->Asl.Child;
+ InitializerOp = PackageLengthOp->Asl.Next;
+
+ /*
+ * We always count the number of items in the initializer list, because if
+ * it is larger than the buffer length, we will define the buffer size
+ * to be the size of the initializer list (Per ACPI Spec)
+ */
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ /* The peer list contains the byte list (if any...) */
+
+ while (InitializerOp)
+ {
+ PackageLength++;
+ InitializerOp = InitializerOp->Asl.Next;
+ }
+ }
+
+ /* Check if initializer list is longer than the buffer length */
+
+ if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
+ (PackageLengthOp->Asl.ParseOpcode == PARSEOP_BYTECONST))
+ {
+ if (PackageLengthOp->Asl.Value.Integer > PackageLength)
+ {
+ PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer;
+ }
+ }
+
+ /*
+ * If not a variable-length package, check for a zero
+ * package length
+ */
+ if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
+ (PackageLengthOp->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
+ (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
+ {
+ if (!PackageLength)
+ {
+ /* No length AND no items -- issue a warning */
+
+ AslError (ASL_WARNING, ASL_MSG_PACKAGE_LENGTH, PackageLengthOp, NULL);
+
+ /* But go ahead and put the buffer length of zero into the AML */
+ }
+ }
+
+ /*
+ * Just set the buffer size node to be the buffer length, regardless
+ * of whether it was previously an integer or a default_arg placeholder
+ */
+ PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
+ PackageLengthOp->Asl.AmlLength = 1;
+ PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+ PackageLengthOp->Asl.Value.Integer = PackageLength;
+
+ /* Remaining nodes are handled via the tree walk */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoLoadTable
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
+ *
+ ******************************************************************************/
+
+void
+OpnDoLoadTable (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ /* Opcode is parent node */
+ /* First child is the table signature */
+
+ Next = Op->Asl.Child;
+
+ /* Second child is the OEM ID*/
+
+ Next = Next->Asl.Next;
+
+ /* Third child is the OEM table ID */
+
+ Next = Next->Asl.Next;
+
+ /* Fourth child is the RootPath string */
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode == PARSEOP_ZERO)
+ {
+ Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
+ Next->Asl.Value.String = "\\";
+ Next->Asl.AmlLength = 2;
+ OpcGenerateAmlOpcode (Next);
+ }
+
+ /* Fifth child is the [optional] ParameterPathString */
+ /* Sixth child is the [optional] ParameterData */
+
+/*
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode == DEFAULT_ARG)
+ {
+ Next->Asl.AmlLength = 1;
+ Next->Asl.ParseOpcode = ZERO;
+ OpcGenerateAmlOpcode (Next);
+ }
+
+
+ Next = Next->Asl.Next;
+ if (Next->Asl.ParseOpcode == DEFAULT_ARG)
+ {
+ Next->Asl.AmlLength = 1;
+ Next->Asl.ParseOpcode = ZERO;
+ OpcGenerateAmlOpcode (Next);
+ }
+ */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnDoDefinitionBlock
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
+ *
+ ******************************************************************************/
+
+void
+OpnDoDefinitionBlock (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Child;
+ ACPI_SIZE Length;
+ ACPI_NATIVE_UINT i;
+
+
+ /*
+ * These nodes get stuffed into the table header. They are special
+ * cased when the table is written to the output file.
+ *
+ * Mark all of these nodes as non-usable so they won't get output
+ * as AML opcodes!
+ */
+
+ /* AML filename */
+
+ Child = Op->Asl.Child;
+ if ((Child->Asl.Value.Buffer) && (Gbl_UseDefaultAmlFilename))
+ {
+ Gbl_OutputFilenamePrefix = (char *) Child->Asl.Value.Buffer;
+ }
+ Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+
+ /* Signature */
+
+ Child = Child->Asl.Next;
+ Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ if (Child->Asl.Value.String)
+ {
+ Gbl_TableSignature = Child->Asl.Value.String;
+ if (ACPI_STRLEN (Gbl_TableSignature) != 4)
+ {
+ AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, "Length not exactly 4");
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ if (!isalnum (Gbl_TableSignature[i]))
+ {
+ AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, "Contains non-alphanumeric characters");
+ }
+ }
+ }
+
+ /* Revision */
+
+ Child = Child->Asl.Next;
+ Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+
+ /* Use the revision to set the integer width */
+
+ AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
+
+ /* OEMID */
+
+ Child = Child->Asl.Next;
+ Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+
+ /* OEM TableID */
+
+ Child = Child->Asl.Next;
+ Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ if (Child->Asl.Value.String)
+ {
+ Length = ACPI_STRLEN (Child->Asl.Value.String);
+ Gbl_TableId = AcpiOsAllocate (Length + 1);
+ ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
+
+ for (i = 0; i < Length; i++)
+ {
+ if (Gbl_TableId[i] == ' ')
+ {
+ Gbl_TableId[i] = 0;
+ break;
+ }
+ }
+ }
+
+ /* OEM Revision */
+
+ Child = Child->Asl.Next;
+ Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtGetArg
+ *
+ * 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 (peer)
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+UtGetArg (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Argn)
+{
+ ACPI_PARSE_OBJECT *Arg = NULL;
+
+
+ /* Get the requested argument object */
+
+ Arg = Op->Asl.Child;
+ while (Arg && Argn)
+ {
+ Argn--;
+ Arg = Arg->Asl.Next;
+ }
+
+ return (Arg);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnAttachNameToNode
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
+ * argument list and attach it to the parent node so that we
+ * can get to it quickly later.
+ *
+ ******************************************************************************/
+
+void
+OpnAttachNameToNode (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Child = NULL;
+
+
+ if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)
+ {
+ Child = UtGetArg (Op, 0);
+ }
+ else switch (Op->Asl.AmlOpcode)
+ {
+ case AML_DATA_REGION_OP:
+ case AML_DEVICE_OP:
+ case AML_EVENT_OP:
+ case AML_METHOD_OP:
+ case AML_MUTEX_OP:
+ case AML_REGION_OP:
+ case AML_POWER_RES_OP:
+ case AML_PROCESSOR_OP:
+ case AML_THERMAL_ZONE_OP:
+ case AML_NAME_OP:
+ case AML_SCOPE_OP:
+
+ Child = UtGetArg (Op, 0);
+ break;
+
+ case AML_ALIAS_OP:
+
+ Child = UtGetArg (Op, 1);
+ break;
+
+ case AML_CREATE_BIT_FIELD_OP:
+ case AML_CREATE_BYTE_FIELD_OP:
+ case AML_CREATE_WORD_FIELD_OP:
+ case AML_CREATE_DWORD_FIELD_OP:
+ case AML_CREATE_QWORD_FIELD_OP:
+
+ Child = UtGetArg (Op, 2);
+ break;
+
+ case AML_CREATE_FIELD_OP:
+
+ Child = UtGetArg (Op, 3);
+ break;
+
+ case AML_BANK_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+ case AML_FIELD_OP:
+
+ return;
+
+ default:
+ return;
+ }
+
+ if (Child)
+ {
+ UtAttachNamepathToOwner (Op, Child);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OpnGenerateAmlOperands
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
+ * complex AML opcodes require processing of the child nodes
+ * (arguments/operands).
+ *
+ ******************************************************************************/
+
+void
+OpnGenerateAmlOperands (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+
+ if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
+ {
+ return;
+ }
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+ OpnDoDefinitionBlock (Op);
+ break;
+
+ case PARSEOP_METHOD:
+ OpnDoMethod (Op);
+ break;
+
+ case PARSEOP_FIELD:
+ OpnDoField (Op);
+ break;
+
+ case PARSEOP_INDEXFIELD:
+ OpnDoIndexField (Op);
+ break;
+
+ case PARSEOP_BANKFIELD:
+ OpnDoBankField (Op);
+ break;
+
+ case PARSEOP_BUFFER:
+ OpnDoBuffer (Op);
+ break;
+
+ case PARSEOP_LOADTABLE:
+ OpnDoLoadTable (Op);
+ break;
+
+ case PARSEOP_PACKAGE:
+ OpnDoPackage (Op);
+ break;
+
+ case PARSEOP_OPERATIONREGION:
+ OpnDoRegion (Op);
+ break;
+
+ case PARSEOP_RESOURCETEMPLATE:
+ RsDoResourceTemplate (Op);
+ break;
+
+ case PARSEOP_NAMESEG:
+ case PARSEOP_NAMESTRING:
+ case PARSEOP_METHODCALL:
+ case PARSEOP_STRING_LITERAL:
+ break;
+
+ default:
+ break;
+ }
+
+ /* TBD: move */
+
+ OpnAttachNameToNode (Op);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c
new file mode 100644
index 0000000..73435c5
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslopt.c
@@ -0,0 +1,800 @@
+/******************************************************************************
+ *
+ * Module Name: aslopt- Compiler optimizations
+ * $Revision: 12 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+
+#include "acparser.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslopt")
+
+
+UINT32 OptTotal = 0;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OptSearchToRoot
+ *
+ * PARAMETERS: Op - Current parser op
+ * WalkState - Current state
+ * CurrentNode - Where we are in the namespace
+ * TargetNode - Node to which we are referring
+ * TargetPath - External full path to the target node
+ * NewPath - Where the optimized path is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Attempt to optimize a reference to a single 4-character ACPI
+ * name utilizing the search-to-root name resolution algorithm
+ * that is used by AML interpreters.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OptSearchToRoot (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *CurrentNode,
+ ACPI_NAMESPACE_NODE *TargetNode,
+ ACPI_BUFFER *TargetPath,
+ char **NewPath)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_GENERIC_STATE ScopeInfo;
+ ACPI_STATUS Status;
+ char *Path;
+
+
+ ACPI_FUNCTION_NAME ("OptSearchToRoot");
+
+
+ /*
+ * Check if search-to-root can be utilized. Use the last NameSeg of
+ * the NamePath and 1) See if can be found and 2) If found, make
+ * sure that it is the same node that we want. If there is another
+ * name in the search path before the one we want, the nodes will
+ * not match, and we cannot use this optimization.
+ */
+ Path = &(((char *) TargetPath->Pointer)[TargetPath->Length - ACPI_NAME_SIZE]),
+ ScopeInfo.Scope.Node = CurrentNode;
+
+ /* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
+
+ Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
+ WalkState, &(Node));
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * We found the name, but we must check to make sure that the node
+ * matches. Otherwise, there is another identical name in the search
+ * path that precludes the use of this optimization.
+ */
+ if (Node != TargetNode)
+ {
+ /*
+ * This means that another object with the same name was found first,
+ * and we cannot use this optimization.
+ */
+ return (AE_NOT_FOUND);
+ }
+
+ /* Found the node, we can use this optimization */
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ "NAMESEG: %-24s", Path));
+
+ /* We must allocate a new string for the name (TargetPath gets deleted) */
+
+ *NewPath = ACPI_MEM_CALLOCATE (ACPI_NAME_SIZE + 1);
+ ACPI_STRCPY (*NewPath, Path);
+
+ AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op,
+ *NewPath);
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OptBuildShortestPath
+ *
+ * PARAMETERS: Op - Current parser op
+ * WalkState - Current state
+ * CurrentNode - Where we are in the namespace
+ * TargetNode - Node to which we are referring
+ * CurrentPath - External full path to the current node
+ * TargetPath - External full path to the target node
+ * AmlNameStringLength - Length of the original namepath
+ * IsDeclaration - TRUE for declaration, FALSE for reference
+ * ReturnNewPath - Where the optimized path is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Build an optimal NamePath using carats
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OptBuildShortestPath (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *CurrentNode,
+ ACPI_NAMESPACE_NODE *TargetNode,
+ ACPI_BUFFER *CurrentPath,
+ ACPI_BUFFER *TargetPath,
+ ACPI_SIZE AmlNameStringLength,
+ UINT8 IsDeclaration,
+ char **ReturnNewPath)
+{
+ UINT32 NumCommonSegments;
+ UINT32 MaxCommonSegments;
+ ACPI_NATIVE_UINT Index;
+ UINT32 NumCarats;
+ ACPI_NATIVE_UINT i;
+ char *NewPath;
+ char *NewPathExternal;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_GENERIC_STATE ScopeInfo;
+ ACPI_STATUS Status;
+ BOOLEAN SubPath = FALSE;
+
+
+ ACPI_FUNCTION_NAME ("OptBuildShortestPath");
+
+
+ ScopeInfo.Scope.Node = CurrentNode;
+
+ /*
+ * Determine the maximum number of NameSegs that the Target and Current paths
+ * can possibly have in common. (To optimize, we have to have at least 1)
+ *
+ * Note: The external NamePath string lengths are always a multiple of 5
+ * (ACPI_NAME_SIZE + separator)
+ */
+ MaxCommonSegments = TargetPath->Length / ACPI_PATH_SEGMENT_LENGTH;
+ if (CurrentPath->Length < TargetPath->Length)
+ {
+ MaxCommonSegments = CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH;
+ }
+
+ /*
+ * Determine how many NameSegs the two paths have in common.
+ * (Starting from the root)
+ */
+ for (NumCommonSegments = 0;
+ NumCommonSegments < MaxCommonSegments;
+ NumCommonSegments++)
+ {
+ /* Compare two single NameSegs */
+
+ if (ACPI_STRNCMP (
+ &((char *) TargetPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
+ &((char *) CurrentPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
+ ACPI_NAME_SIZE))
+ {
+ /* Mismatch */
+
+ break;
+ }
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d", NumCommonSegments));
+
+ /* There must be at least 1 common NameSeg in order to optimize */
+
+ if (NumCommonSegments == 0)
+ {
+ return (AE_NOT_FOUND);
+ }
+
+ if (NumCommonSegments == MaxCommonSegments)
+ {
+ if (CurrentPath->Length == TargetPath->Length)
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SAME PATH"));
+ return (AE_NOT_FOUND);
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SUBPATH"));
+ SubPath = TRUE;
+ }
+ }
+
+ /* Determine how many prefix Carats are required */
+
+ NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - NumCommonSegments;
+
+ /*
+ * Construct a new target string
+ */
+ NewPathExternal = ACPI_MEM_CALLOCATE (TargetPath->Length + NumCarats);
+
+ /* Insert the Carats into the Target string */
+
+ for (i = 0; i < NumCarats; i++)
+ {
+ NewPathExternal[i] = '^';
+ }
+
+ /* Copy only the necessary (optimal) segments from the original target string */
+
+ Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
+
+ /* Special handling for exact subpath in a name declaration */
+
+ if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length))
+ {
+ /*
+ * The current path is longer than the target, and the target is a subpath
+ * of the current path. We must include one more NameSeg of the target path
+ */
+ Index -= ACPI_PATH_SEGMENT_LENGTH;
+ }
+
+ ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
+
+ /*
+ * Internalize the new target string and check it against the original string
+ * to make sure that this is in fact an optimization. If the original string
+ * is already optimal, there is no point in continuing.
+ */
+ Status = AcpiNsInternalizeName (NewPathExternal, &NewPath);
+
+ if (ACPI_FAILURE (Status))
+ {
+ AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT);
+ ACPI_MEM_FREE (NewPathExternal);
+ return (Status);
+ }
+
+ if (ACPI_STRLEN (NewPath) >= AmlNameStringLength)
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %d old %d)",
+ ACPI_STRLEN (NewPath), AmlNameStringLength));
+ ACPI_MEM_FREE (NewPathExternal);
+ return (AE_NOT_FOUND);
+ }
+
+ /*
+ * Check to make sure that the optimization finds the node we are
+ * looking for. This is simply a sanity check on the new
+ * path that has been created.
+ */
+ Status = AcpiNsLookup (&ScopeInfo, NewPath,
+ ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Found the namepath, but make sure the node is correct */
+
+ if (Node == TargetNode)
+ {
+ /* The lookup matched the node, accept this optimization */
+
+ AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
+ Op, NewPathExternal);
+ *ReturnNewPath = NewPath;
+ }
+ else
+ {
+ /* Node is not correct, do not use this optimization */
+
+ Status = AE_NOT_FOUND;
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
+ AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
+ "Not using optimized name - found wrong node");
+ }
+ }
+ else
+ {
+ /* The lookup failed, we obviously cannot use this optimization */
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
+ AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
+ "Not using optimized name - did not find node");
+ }
+
+ ACPI_MEM_FREE (NewPathExternal);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OptOptimizeNameDeclaration
+ *
+ * PARAMETERS: Op - Current parser op
+ * WalkState - Current state
+ * CurrentNode - Where we are in the namespace
+ * AmlNameString - Unoptimized namepath
+ * NewPath - Where the optimized path is returned
+ *
+ * RETURN: Status. AE_OK If path is optimized
+ *
+ * DESCRIPTION: Perform a simple optimization of removing an extraneous
+ * backslash prefix if we are already at the root scope.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+OptOptimizeNameDeclaration (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *CurrentNode,
+ ACPI_NAMESPACE_NODE *TargetNode,
+ char *AmlNameString,
+ char **NewPath)
+{
+ ACPI_STATUS Status;
+ char *NewPathExternal;
+ ACPI_GENERIC_STATE ScopeInfo;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE ("OptOptimizeNameDeclaration");
+
+
+ if (((CurrentNode == AcpiGbl_RootNode) ||
+ (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) &&
+ (AmlNameString[0] == '\\'))
+ {
+ /*
+ * The current scope is the root, and the namepath has a root prefix
+ * that is therefore extraneous. Remove it.
+ */
+ *NewPath = &AmlNameString[1];
+
+ /* Debug output */
+
+ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath,
+ NULL, &NewPathExternal);
+ if (ACPI_FAILURE (Status))
+ {
+ AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT);
+ return (Status);
+ }
+
+ /*
+ * Check to make sure that the optimization finds the node we are
+ * looking for. This is simply a sanity check on the new
+ * path that has been created.
+ */
+ ScopeInfo.Scope.Node = CurrentNode;
+ Status = AcpiNsLookup (&ScopeInfo, *NewPath,
+ ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Found the namepath, but make sure the node is correct */
+
+ if (Node == TargetNode)
+ {
+ /* The lookup matched the node, accept this optimization */
+
+ AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
+ Op, NewPathExternal);
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ "AT ROOT: %-24s", NewPathExternal));
+ }
+ else
+ {
+ /* Node is not correct, do not use this optimization */
+
+ Status = AE_NOT_FOUND;
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
+ AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
+ "Not using optimized name - found wrong node");
+ }
+ }
+ else
+ {
+ /* The lookup failed, we obviously cannot use this optimization */
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
+ AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
+ "Not using optimized name - did not find node");
+ }
+
+ ACPI_MEM_FREE (NewPathExternal);
+ return (Status);
+ }
+
+ /* Could not optimize */
+
+ return (AE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: OptOptimizeNamePath
+ *
+ * PARAMETERS: Op - Current parser op
+ * Flags - Opcode info flags
+ * WalkState - Current state
+ * AmlNameString - Unoptimized namepath
+ * TargetNode - Node to which AmlNameString refers
+ *
+ * RETURN: None. If path is optimized, the Op is updated with new path
+ *
+ * DESCRIPTION: Optimize a Named Declaration or Reference to the minimal length.
+ * Must take into account both the current location in the
+ * namespace and the actual reference path.
+ *
+ ******************************************************************************/
+
+void
+OptOptimizeNamePath (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Flags,
+ ACPI_WALK_STATE *WalkState,
+ char *AmlNameString,
+ ACPI_NAMESPACE_NODE *TargetNode)
+{
+ ACPI_STATUS Status;
+ ACPI_BUFFER TargetPath;
+ ACPI_BUFFER CurrentPath;
+ ACPI_SIZE AmlNameStringLength;
+ ACPI_NAMESPACE_NODE *CurrentNode;
+ char *ExternalNameString;
+ char *NewPath = NULL;
+ ACPI_SIZE HowMuchShorter;
+ ACPI_PARSE_OBJECT *NextOp;
+
+
+ ACPI_FUNCTION_TRACE ("OptOptimizeNamePath");
+
+
+ /* This is an optional optimization */
+
+ if (!Gbl_ReferenceOptimizationFlag)
+ {
+ return_VOID;
+ }
+
+ /* Various required items */
+
+ if (!TargetNode || !WalkState || !Op->Common.Parent)
+ {
+ return_VOID;
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "%5d [%12.12s] [%12.12s] ",
+ Op->Asl.LogicalLineNumber,
+ AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode),
+ AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
+
+ if (!(Flags & (AML_NAMED | AML_CREATE)))
+ {
+ if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
+ {
+ /* We don't want to fuss with actual name declaration nodes here */
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ "******* NAME DECLARATION\n"));
+ return_VOID;
+ }
+ }
+
+ /*
+ * The original path must be longer than one NameSeg (4 chars) for there
+ * to be any possibility that it can be optimized to a shorter string
+ */
+ AmlNameStringLength = ACPI_STRLEN (AmlNameString);
+ if (AmlNameStringLength <= ACPI_NAME_SIZE)
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ "NAMESEG %4.4s\n", AmlNameString));
+ return_VOID;
+ }
+
+ /*
+ * We need to obtain the node that represents the current scope -- where
+ * we are right now in the namespace. We will compare this path
+ * against the Namepath, looking for commonality.
+ */
+ CurrentNode = AcpiGbl_RootNode;
+ if (WalkState->ScopeInfo)
+ {
+ CurrentNode = WalkState->ScopeInfo->Scope.Node;
+ }
+
+ if (Flags & (AML_NAMED | AML_CREATE))
+ {
+ /* This is the declaration of a new name */
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME"));
+
+ /* The node of interest is the parent of this node (the containing scope) */
+
+ CurrentNode = Op->Asl.Parent->Asl.Node;
+ if (!CurrentNode)
+ {
+ CurrentNode = AcpiGbl_RootNode;
+ }
+ }
+ else
+ {
+ /* This is a reference to an existing named object */
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REF "));
+ }
+
+ /*
+ * Obtain the full paths to the two nodes that we are interested in
+ * (Target and current namespace location) in external
+ * format -- something we can easily manipulate
+ */
+ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (TargetNode, &TargetPath);
+ if (ACPI_FAILURE (Status))
+ {
+ AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT);
+ return_VOID;
+ }
+ TargetPath.Length--; /* Subtract one for null terminator */
+
+ /* CurrentPath is the path to this scope (where we are in the namespace) */
+
+ CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath);
+ if (ACPI_FAILURE (Status))
+ {
+ AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT);
+ return_VOID;
+ }
+ CurrentPath.Length--; /* Subtract one for null terminator */
+
+ /* Debug output only */
+
+ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString,
+ NULL, &ExternalNameString);
+ if (ACPI_FAILURE (Status))
+ {
+ AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT);
+ return_VOID;
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ "%37s (%2d) ==> %-32s(%2d) %-32s",
+ (char *) CurrentPath.Pointer, CurrentPath.Length,
+ (char *) TargetPath.Pointer, TargetPath.Length, ExternalNameString));
+
+ ACPI_MEM_FREE (ExternalNameString);
+
+ /*
+ * Attempt an optmization depending on the type of namepath
+ */
+ if (Flags & (AML_NAMED | AML_CREATE))
+ {
+ /*
+ * This is a named opcode and the namepath is a name declaration, not
+ * a reference.
+ */
+ Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode,
+ TargetNode, AmlNameString, &NewPath);
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * 2) now attempt to
+ * optimize the namestring with carats (up-arrow)
+ */
+ Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
+ TargetNode, &CurrentPath, &TargetPath,
+ AmlNameStringLength, 1, &NewPath);
+ }
+ }
+ else
+ {
+ /*
+ * This is a reference to an existing named object
+ *
+ * 1) Check if search-to-root can be utilized using the last
+ * NameSeg of the NamePath
+ */
+ Status = OptSearchToRoot (Op, WalkState, CurrentNode,
+ TargetNode, &TargetPath, &NewPath);
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * 2) Search-to-root could not be used, now attempt to
+ * optimize the namestring with carats (up-arrow)
+ */
+ Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
+ TargetNode, &CurrentPath, &TargetPath,
+ AmlNameStringLength, 0, &NewPath);
+ }
+ }
+
+ /*
+ * Success from above indicates that the NamePath was successfully
+ * optimized. We need to update the parse op with the new name
+ */
+ if (ACPI_SUCCESS (Status))
+ {
+ HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath));
+ OptTotal += HowMuchShorter;
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED %2d (%d)",
+ HowMuchShorter, OptTotal));
+
+ if (Flags & AML_NAMED)
+ {
+ if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
+ {
+ /*
+ * ALIAS is the only oddball opcode, the name declaration
+ * (alias name) is the second operand
+ */
+ Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
+ Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ }
+ else
+ {
+ Op->Asl.Child->Asl.Value.String = NewPath;
+ Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ }
+ }
+ else if (Flags & AML_CREATE)
+ {
+ /* Name must appear as the last parameter */
+
+ NextOp = Op->Asl.Child;
+ while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
+ {
+ NextOp = NextOp->Asl.Next;
+ }
+ /* Update the parse node with the new NamePath */
+
+ NextOp->Asl.Value.String = NewPath;
+ NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ }
+ else
+ {
+ /* Update the parse node with the new NamePath */
+
+ Op->Asl.Value.String = NewPath;
+ Op->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ }
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ALREADY OPTIMAL"));
+ }
+
+ /* Cleanup path buffers */
+
+ ACPI_MEM_FREE (TargetPath.Pointer);
+ ACPI_MEM_FREE (CurrentPath.Pointer);
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "\n"));
+ return_VOID;
+}
+
diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c
new file mode 100644
index 0000000..36d8070
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslresource.c
@@ -0,0 +1,632 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslresource - Resource templates and descriptors
+ * $Revision: 31 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslresource")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsAllocateResourceNode
+ *
+ * PARAMETERS: Size - Size of node in bytes
+ *
+ * RETURN: The allocated node - aborts on allocation failure
+ *
+ * DESCRIPTION: Allocate a resource description node and the resource
+ * descriptor itself (the nodes are used to link descriptors).
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsAllocateResourceNode (
+ UINT32 Size)
+{
+ ASL_RESOURCE_NODE *Rnode;
+
+
+ /* Allocate the node */
+
+ Rnode = UtLocalCalloc (sizeof (ASL_RESOURCE_NODE));
+
+ /* Allocate the resource descriptor itself */
+
+ Rnode->Buffer = UtLocalCalloc (Size);
+ Rnode->BufferLength = Size;
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsCreateBitField
+ *
+ * PARAMETERS: Op - Resource field node
+ * Name - Name of the field (Used only to reference
+ * the field in the ASL, not in the AML)
+ * ByteOffset - Offset from the field start
+ * BitOffset - Additional bit offset
+ *
+ * RETURN: None, sets fields within the input node
+ *
+ * DESCRIPTION: Utility function to generate a named bit field within a
+ * resource descriptor. Mark a node as 1) a field in a resource
+ * descriptor, and 2) set the value to be a BIT offset
+ *
+ ******************************************************************************/
+
+void
+RsCreateBitField (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name,
+ UINT32 ByteOffset,
+ UINT32 BitOffset)
+{
+
+ Op->Asl.ExternalName = Name;
+ Op->Asl.Value.Integer = (ByteOffset * 8) + BitOffset;
+ Op->Asl.CompileFlags |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsCreateByteField
+ *
+ * PARAMETERS: Op - Resource field node
+ * Name - Name of the field (Used only to reference
+ * the field in the ASL, not in the AML)
+ * ByteOffset - Offset from the field start
+ *
+ * RETURN: None, sets fields within the input node
+ *
+ * DESCRIPTION: Utility function to generate a named byte field within a
+ * resource descriptor. Mark a node as 1) a field in a resource
+ * descriptor, and 2) set the value to be a BYTE offset
+ *
+ ******************************************************************************/
+
+void
+RsCreateByteField (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name,
+ UINT32 ByteOffset)
+{
+
+ Op->Asl.ExternalName = Name;
+ Op->Asl.Value.Integer = ByteOffset;
+ Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsSetFlagBits
+ *
+ * PARAMETERS: *Flags - Pointer to the flag byte
+ * Op - Flag initialization node
+ * Position - Bit position within the flag byte
+ * Default - Used if the node is DEFAULT.
+ *
+ * RETURN: Sets bits within the *Flags output byte.
+ *
+ * DESCRIPTION: Set a bit in a cumulative flags word from an initialization
+ * node. Will use a default value if the node is DEFAULT, meaning
+ * that no value was specified in the ASL. Used to merge multiple
+ * keywords into a single flags byte.
+ *
+ ******************************************************************************/
+
+void
+RsSetFlagBits (
+ UINT8 *Flags,
+ ACPI_PARSE_OBJECT *Op,
+ UINT8 Position,
+ UINT8 DefaultBit)
+{
+
+ if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
+ {
+ /* Use the default bit */
+
+ *Flags |= (DefaultBit << Position);
+ }
+ else
+ {
+ /* Use the bit specified in the initialization node */
+
+ *Flags |= (((UINT8) Op->Asl.Value.Integer) << Position);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsCompleteNodeAndGetNext
+ *
+ * PARAMETERS: Op - Resource node to be completed
+ *
+ * RETURN: The next peer to the input node.
+ *
+ * DESCRIPTION: Mark the current node completed and return the next peer.
+ * The node ParseOpcode is set to DEFAULT_ARG, meaning that
+ * this node is to be ignored from now on.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+RsCompleteNodeAndGetNext (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ /* Mark this node unused */
+
+ Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+
+ /* Move on to the next peer node in the initializer list */
+
+ return (ASL_GET_PEER_NODE (Op));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoOneResourceDescriptor
+ *
+ * PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor
+ * CurrentByteOffset - Offset in the resource descriptor
+ * buffer.
+ *
+ * RETURN: A valid resource node for the descriptor
+ *
+ * DESCRIPTION: Dispatches the processing of one resource descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoOneResourceDescriptor (
+ ACPI_PARSE_OBJECT *DescriptorTypeOp,
+ UINT32 CurrentByteOffset,
+ UINT8 *State)
+{
+ ASL_RESOURCE_NODE *Rnode = NULL;
+
+
+ /* Determine type of resource */
+
+ switch (DescriptorTypeOp->Asl.ParseOpcode)
+ {
+ case PARSEOP_DMA:
+ Rnode = RsDoDmaDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_DWORDIO:
+ Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_DWORDMEMORY:
+ Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_ENDDEPENDENTFN:
+ switch (*State)
+ {
+ case ACPI_RSTATE_NORMAL:
+ AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, DescriptorTypeOp, NULL);
+ break;
+
+ case ACPI_RSTATE_START_DEPENDENT:
+ AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL);
+ break;
+
+ case ACPI_RSTATE_DEPENDENT_LIST:
+ default:
+ break;
+ }
+
+ *State = ACPI_RSTATE_NORMAL;
+ Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_FIXEDIO:
+ Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_INTERRUPT:
+ Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_IO:
+ Rnode = RsDoIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_IRQ:
+ Rnode = RsDoIrqDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_IRQNOFLAGS:
+ Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_MEMORY24:
+ Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_MEMORY32:
+ Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_MEMORY32FIXED:
+ Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_QWORDIO:
+ Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_QWORDMEMORY:
+ Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_REGISTER:
+ Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_STARTDEPENDENTFN:
+ switch (*State)
+ {
+ case ACPI_RSTATE_START_DEPENDENT:
+ AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL);
+ break;
+
+ case ACPI_RSTATE_NORMAL:
+ case ACPI_RSTATE_DEPENDENT_LIST:
+ default:
+ break;
+ }
+
+ *State = ACPI_RSTATE_START_DEPENDENT;
+ Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ *State = ACPI_RSTATE_DEPENDENT_LIST;
+ break;
+
+ case PARSEOP_STARTDEPENDENTFN_NOPRI:
+ switch (*State)
+ {
+ case ACPI_RSTATE_START_DEPENDENT:
+ AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL);
+ break;
+
+ case ACPI_RSTATE_NORMAL:
+ case ACPI_RSTATE_DEPENDENT_LIST:
+ default:
+ break;
+ }
+
+ *State = ACPI_RSTATE_START_DEPENDENT;
+ Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ *State = ACPI_RSTATE_DEPENDENT_LIST;
+ break;
+
+ case PARSEOP_VENDORLONG:
+ Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_VENDORSHORT:
+ Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_WORDBUSNUMBER:
+ Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_WORDIO:
+ Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
+ break;
+
+ case PARSEOP_DEFAULT_ARG:
+ /* Just ignore any of these, they are used as fillers/placeholders */
+ break;
+
+ default:
+ printf ("Unknown resource descriptor type [%s]\n",
+ DescriptorTypeOp->Asl.ParseOpName);
+ break;
+ }
+
+ /*
+ * Mark original node as unused, but head of a resource descriptor.
+ * This allows the resource to be installed in the namespace so that
+ * references to the descriptor can be resolved.
+ */
+ DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
+ DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC;
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsLinkDescriptorChain
+ *
+ * PARAMETERS: PreviousRnode - Pointer to the node that will be previous
+ * to the linked node, At exit, set to the
+ * last node in the new chain.
+ * Rnode - Resource node to link into the list
+ *
+ * RETURN: Cumulative buffer byte offset of the new segment of chain
+ *
+ * DESCRIPTION: Link a descriptor chain at the end of an existing chain.
+ *
+ ******************************************************************************/
+
+UINT32
+RsLinkDescriptorChain (
+ ASL_RESOURCE_NODE **PreviousRnode,
+ ASL_RESOURCE_NODE *Rnode)
+{
+ ASL_RESOURCE_NODE *LastRnode;
+ UINT32 CurrentByteOffset;
+
+
+ /* Anything to do? */
+
+ if (!Rnode)
+ {
+ return 0;
+ }
+
+ /* Point the previous node to the new node */
+
+ (*PreviousRnode)->Next = Rnode;
+ CurrentByteOffset = Rnode->BufferLength;
+
+ /* Walk to the end of the chain headed by Rnode */
+
+ LastRnode = Rnode;
+ while (LastRnode->Next)
+ {
+ LastRnode = LastRnode->Next;
+ CurrentByteOffset += LastRnode->BufferLength;
+ }
+
+ /* Previous node becomes the last node in the chain */
+
+ *PreviousRnode = LastRnode;
+ return CurrentByteOffset;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoResourceTemplate
+ *
+ * PARAMETERS: Op - Parent of a resource template list
+ *
+ * RETURN: None. Sets input node to point to a list of AML code
+ *
+ * DESCRIPTION: Merge a list of resource descriptors into a single AML buffer,
+ * in preparation for output to the AML output file.
+ *
+ ******************************************************************************/
+
+void
+RsDoResourceTemplate (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *BufferLengthOp;
+ ACPI_PARSE_OBJECT *BufferOp;
+ ACPI_PARSE_OBJECT *DescriptorTypeOp;
+ ACPI_PARSE_OBJECT *LastOp = NULL;
+ ASL_RESOURCE_DESC *Descriptor;
+ UINT32 CurrentByteOffset = 0;
+ ASL_RESOURCE_NODE HeadRnode;
+ ASL_RESOURCE_NODE *PreviousRnode;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT8 State;
+
+
+ /* ResourceTemplate Opcode is first (Op) */
+ /* Buffer Length node is first child */
+
+ BufferLengthOp = ASL_GET_CHILD_NODE (Op);
+
+ /* Buffer Op is first peer */
+
+ BufferOp = ASL_GET_PEER_NODE (BufferLengthOp);
+
+ /* First Descriptor type is next */
+
+ DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp);
+
+ /* Process all resource descriptors in the list */
+
+ State = ACPI_RSTATE_NORMAL;
+ PreviousRnode = &HeadRnode;
+ while (DescriptorTypeOp)
+ {
+ Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, &State);
+
+ /*
+ * Update current byte offset to indicate the number of bytes from the
+ * start of the buffer. Buffer can include multiple descriptors, we
+ * must keep track of the offset of not only each descriptor, but each
+ * element (field) within each descriptor as well.
+ */
+ CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
+
+ /* Get the next descriptor in the list */
+
+ LastOp = DescriptorTypeOp;
+ DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp);
+ }
+
+ if (State == ACPI_RSTATE_DEPENDENT_LIST)
+ {
+ if (LastOp)
+ {
+ LastOp = LastOp->Asl.Parent;
+ }
+ AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL);
+ }
+
+ /*
+ * Insert the EndTag descriptor after all other descriptors have been processed
+ */
+ Rnode = RsAllocateResourceNode (sizeof (ASL_END_TAG_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Et.DescriptorType = ACPI_RDESC_TYPE_END_TAG |
+ ASL_RDESC_END_TAG_SIZE;
+ Descriptor->Et.Checksum = 0;
+
+ CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
+
+ /*
+ * Transform the nodes into the following
+ *
+ * Op -> AML_BUFFER_OP
+ * First Child -> BufferLength
+ * Second Child -> Descriptor Buffer (raw byte data)
+ */
+ Op->Asl.ParseOpcode = PARSEOP_BUFFER;
+ Op->Asl.AmlOpcode = AML_BUFFER_OP;
+ Op->Asl.CompileFlags = NODE_AML_PACKAGE;
+
+ BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
+ BufferLengthOp->Asl.Value.Integer = CurrentByteOffset;
+
+ (void) OpcSetOptimalIntegerSize (BufferLengthOp);
+
+ BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
+ BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
+ BufferOp->Asl.AmlOpcodeLength = 0;
+ BufferOp->Asl.AmlLength = CurrentByteOffset;
+ BufferOp->Asl.Value.Buffer = (UINT8 *) HeadRnode.Next;
+
+ return;
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c
new file mode 100644
index 0000000..33193f6
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c
@@ -0,0 +1,1041 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslrestype1 - Short (type1) resource templates and descriptors
+ * $Revision: 25 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslrestype1")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoDmaDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "DMA" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoDmaDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+ UINT8 DmaChannelMask = 0;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_DMA_FORMAT_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Dma.DescriptorType = ACPI_RDESC_TYPE_DMA_FORMAT |
+ ASL_RDESC_DMA_SIZE;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* DMA type */
+
+ RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DMATYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5);
+ break;
+
+ case 1: /* Bus Master */
+
+ RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_BUSMASTER,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
+ break;
+
+ case 2: /* Xfer Type (transfer width) */
+
+ RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_XFERTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0);
+ break;
+
+ case 3: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ /* All DMA channel bytes are handled here, after the flags and name */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ DmaChannelMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
+ }
+
+ if (i == 4) /* case 4: First DMA byte */
+ {
+ RsCreateByteField (InitializerOp, ASL_RESNAME_DMA,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
+ }
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ /* Now we can set the channel mask */
+
+ Descriptor->Dma.DmaChannelMask = DmaChannelMask;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoEndDependentDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "EndDependentFn" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoEndDependentDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ASL_RESOURCE_NODE *Rnode;
+
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_END_DEPENDENT_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->End.DescriptorType = ACPI_RDESC_TYPE_END_DEPENDENT |
+ ASL_RDESC_END_DEPEND_SIZE;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoFixedIoDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "FixedIO" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoFixedIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_FIXED_IO_PORT_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Iop.DescriptorType = ACPI_RDESC_TYPE_FIXED_IO_PORT |
+ ASL_RDESC_FIXED_IO_SIZE;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Base Address */
+
+ Descriptor->Fio.BaseAddress = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Fio.BaseAddress));
+ break;
+
+ case 1: /* Length */
+
+ Descriptor->Fio.Length = (UINT8) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Fio.Length));
+ break;
+
+ case 2: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoIoDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "IO" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_IO_PORT_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Iop.DescriptorType = ACPI_RDESC_TYPE_IO_PORT |
+ ASL_RDESC_IO_SIZE;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Decode size */
+
+ RsSetFlagBits (&Descriptor->Iop.Information, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Information), 0);
+ break;
+
+ case 1: /* Min Address */
+
+ Descriptor->Iop.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.AddressMin));
+ break;
+
+ case 2: /* Max Address */
+
+ Descriptor->Iop.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.AddressMax));
+ break;
+
+ case 3: /* Alignment */
+
+ Descriptor->Iop.Alignment = (UINT8) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Alignment));
+ break;
+
+ case 4: /* Length */
+
+ Descriptor->Iop.Length = (UINT8) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Length));
+ break;
+
+ case 5: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoIrqDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "IRQ" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoIrqDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+ UINT16 IrqMask = 0;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_IRQ_FORMAT_DESC));
+
+ /* Length = 3 (with flag byte) */
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Irq.DescriptorType = ACPI_RDESC_TYPE_IRQ_FORMAT |
+ (ASL_RDESC_IRQ_SIZE + 0x01);
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Interrupt Type (or Mode - edge/level) */
+
+ RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
+ break;
+
+ case 1: /* Interrupt Level (or Polarity - Active high/low) */
+
+ RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTLEVEL,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
+ break;
+
+ case 2: /* Share Type - Default: exclusive (0) */
+
+ RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTSHARE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
+ break;
+
+ case 3: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ /* All IRQ bytes are handled here, after the flags and name */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
+ }
+
+ if (i == 4) /* case 4: First IRQ byte */
+ {
+ RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
+ }
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ /* Now we can set the channel mask */
+
+ Descriptor->Irq.IrqMask = IrqMask;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoIrqNoFlagsDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoIrqNoFlagsDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+ UINT16 IrqMask = 0;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_IRQ_NOFLAGS_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Irq.DescriptorType = ACPI_RDESC_TYPE_IRQ_FORMAT |
+ ASL_RDESC_IRQ_SIZE;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ /* IRQ bytes are handled here, after the flags and name */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
+ }
+
+ if (i == 1) /* case 1: First IRQ byte */
+ {
+ RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
+ }
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ /* Now we can set the interrupt mask */
+
+ Descriptor->Irq.IrqMask = IrqMask;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoMemory24Descriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "Memory24" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoMemory24Descriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_MEMORY_24_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->M24.DescriptorType = ACPI_RDESC_TYPE_MEMORY_24;
+ Descriptor->M24.Length = 9;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Read/Write type */
+
+ RsSetFlagBits (&Descriptor->M24.Information, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M24.Information), 0);
+ break;
+
+ case 1: /* Min Address */
+
+ Descriptor->M24.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M24.AddressMin));
+ break;
+
+ case 2: /* Max Address */
+
+ Descriptor->M24.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M24.AddressMax));
+ break;
+
+ case 3: /* Alignment */
+
+ Descriptor->M24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M24.Alignment));
+ break;
+
+ case 4: /* Length */
+
+ Descriptor->M24.RangeLength = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M24.RangeLength));
+ break;
+
+ case 5: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoMemory32Descriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "Memory32" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoMemory32Descriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_MEMORY_32_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->M32.DescriptorType = ACPI_RDESC_TYPE_MEMORY_32;
+ Descriptor->M32.Length = 17;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Read/Write type */
+
+ RsSetFlagBits (&Descriptor->M32.Information, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M32.Information), 0);
+ break;
+
+ case 1: /* Min Address */
+
+ Descriptor->M32.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M32.AddressMin));
+ break;
+
+ case 2: /* Max Address */
+
+ Descriptor->M32.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M32.AddressMax));
+ break;
+
+ case 3: /* Alignment */
+
+ Descriptor->M32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M32.Alignment));
+ break;
+
+ case 4: /* Length */
+
+ Descriptor->M32.RangeLength = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (M32.RangeLength));
+ break;
+
+ case 5: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoMemory32FixedDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoMemory32FixedDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_FIXED_MEMORY_32_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->F32.DescriptorType = ACPI_RDESC_TYPE_FIXED_MEMORY_32;
+ Descriptor->F32.Length = 9;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Read/Write type */
+
+ RsSetFlagBits (&Descriptor->F32.Information, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (F32.Information), 0);
+ break;
+
+ case 1: /* Address */
+
+ Descriptor->F32.BaseAddress = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (F32.BaseAddress));
+ break;
+
+ case 2: /* Length */
+
+ Descriptor->F32.RangeLength = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (F32.RangeLength));
+ break;
+
+ case 3: /* Name */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoStartDependentDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "StartDependentFn" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoStartDependentDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ ASL_RESOURCE_NODE *PreviousRnode;
+ ASL_RESOURCE_NODE *NextRnode;
+ UINT32 i;
+ UINT8 State;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_START_DEPENDENT_DESC));
+
+ PreviousRnode = Rnode;
+ Descriptor = Rnode->Buffer;
+
+ /* Descriptor has priority byte */
+
+ Descriptor->Std.DescriptorType = ACPI_RDESC_TYPE_START_DEPENDENT |
+ (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
+
+ /*
+ * Process all child initialization nodes
+ */
+ State = ACPI_RSTATE_START_DEPENDENT;
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Compatibility Priority */
+
+ if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
+ {
+ AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, InitializerOp, NULL);
+ }
+
+ RsSetFlagBits (&Descriptor->Std.Flags, InitializerOp, 0, 0);
+ break;
+
+ case 1: /* Performance/Robustness Priority */
+
+ if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
+ {
+ AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, InitializerOp, NULL);
+ }
+
+ RsSetFlagBits (&Descriptor->Std.Flags, InitializerOp, 2, 0);
+ break;
+
+ default:
+ NextRnode = RsDoOneResourceDescriptor (InitializerOp, CurrentByteOffset, &State);
+
+ /*
+ * Update current byte offset to indicate the number of bytes from the
+ * start of the buffer. Buffer can include multiple descriptors, we
+ * must keep track of the offset of not only each descriptor, but each
+ * element (field) within each descriptor as well.
+ */
+
+ CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoStartDependentNoPriDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoStartDependentNoPriDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ ASL_RESOURCE_NODE *PreviousRnode;
+ ASL_RESOURCE_NODE *NextRnode;
+ UINT8 State;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_START_DEPENDENT_NOPRIO_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Std.DescriptorType = ACPI_RDESC_TYPE_START_DEPENDENT |
+ ASL_RDESC_ST_DEPEND_SIZE;
+ PreviousRnode = Rnode;
+
+ /*
+ * Process all child initialization nodes
+ */
+ State = ACPI_RSTATE_START_DEPENDENT;
+ while (InitializerOp)
+ {
+ NextRnode = RsDoOneResourceDescriptor (InitializerOp, CurrentByteOffset, &State);
+
+ /*
+ * Update current byte offset to indicate the number of bytes from the
+ * start of the buffer. Buffer can include multiple descriptors, we
+ * must keep track of the offset of not only each descriptor, but each
+ * element (field) within each descriptor as well.
+ */
+
+ CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoVendorSmallDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a short "VendorShort" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoVendorSmallDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_SMALL_VENDOR_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Smv.DescriptorType = ACPI_RDESC_TYPE_SMALL_VENDOR;
+
+ /*
+ * Process all child initialization nodes
+ */
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ for (i = 0; (InitializerOp && (i < 7)); i++)
+ {
+ Descriptor->Smv.VendorDefined[i] = (UINT8) InitializerOp->Asl.Value.Integer;
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
+
+ Rnode->BufferLength -= (7 - i);
+
+ /* Set the length in the Type Tag */
+
+ Descriptor->Smv.DescriptorType |= (UINT8) i;
+ return (Rnode);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c
new file mode 100644
index 0000000..a8818a7
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c
@@ -0,0 +1,1536 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslrestype2 - Long (type2) resource templates and descriptors
+ * $Revision: 25 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslrestype2")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsGetStringDataLength
+ *
+ * PARAMETERS: InitializerOp - Start of a subtree of init nodes
+ *
+ * RETURN: Valid string length if a string node is found
+ *
+ * DESCRIPTION: In a list of peer nodes, find the first one that contains a
+ * string and return the length of the string.
+ *
+ ******************************************************************************/
+
+UINT32
+RsGetStringDataLength (
+ ACPI_PARSE_OBJECT *InitializerOp)
+{
+
+ while (InitializerOp)
+ {
+ if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
+ {
+ return (strlen (InitializerOp->Asl.Value.String) + 1);
+ }
+ InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
+ }
+
+ return 0;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoDwordIoDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "DwordIO" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoDwordIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_DWORD_ADDRESS_DESC) +
+ StringLength);
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Das.DescriptorType = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE;
+ Descriptor->Das.ResourceType = ACPI_RESOURCE_TYPE_IO_RANGE;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Das.Length = (UINT16) (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Das.ResourceType));
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* MinType */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 2);
+ break;
+
+ case 2: /* MaxType */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 3);
+ break;
+
+ case 3: /* DecodeType */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 1);
+ break;
+
+ case 4: /* Range Type */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 0, 3);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 0);
+ break;
+
+ case 5: /* Address Granularity */
+
+ Descriptor->Das.Granularity = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Granularity));
+ break;
+
+ case 6: /* Address Min */
+
+ Descriptor->Das.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMin));
+ break;
+
+ case 7: /* Address Max */
+
+ Descriptor->Das.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMax));
+ break;
+
+ case 8: /* Translation Offset */
+
+ Descriptor->Das.TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.TranslationOffset));
+ break;
+
+ case 9: /* Address Length */
+
+ Descriptor->Das.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressLength));
+ break;
+
+ case 10: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Descriptor->Das.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
+ OptionIndex++;
+ Descriptor->Das.Length++;
+ }
+ break;
+
+ case 11: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ Descriptor->Das.Length = (UINT16) (Descriptor->Das.Length + StringLength);
+
+ strcpy ((char *) &Descriptor->Das.OptionalFields[OptionIndex],
+ InitializerOp->Asl.Value.String);
+ }
+ }
+ break;
+
+ case 12: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ case 13: /* Type */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 4, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 4);
+ break;
+
+ case 14: /* Translation Type */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 5, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 5);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Das.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoDwordMemoryDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "DwordMemory" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoDwordMemoryDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_DWORD_ADDRESS_DESC) +
+ StringLength);
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Das.DescriptorType = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE;
+ Descriptor->Das.ResourceType = ACPI_RESOURCE_TYPE_MEMORY_RANGE;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Das.Length = (UINT16) (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Das.ResourceType));
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* DecodeType */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 1);
+ break;
+
+ case 2: /* MinType */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 2);
+ break;
+
+ case 3: /* MaxType */
+
+ RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 3);
+ break;
+
+ case 4: /* Memory Type */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MEMTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 1);
+ break;
+
+ case 5: /* Read/Write Type */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 0);
+ break;
+
+ case 6: /* Address Granularity */
+
+ Descriptor->Das.Granularity = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Granularity));
+ break;
+
+ case 7: /* Min Address */
+
+ Descriptor->Das.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMin));
+ break;
+
+ case 8: /* Max Address */
+
+ Descriptor->Das.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMax));
+ break;
+
+ case 9: /* Translation Offset */
+
+ Descriptor->Das.TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.TranslationOffset));
+ break;
+
+ case 10: /* Address Length */
+
+ Descriptor->Das.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressLength));
+ break;
+
+ case 11: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Descriptor->Das.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
+ OptionIndex++;
+ Descriptor->Das.Length++;
+ }
+ break;
+
+ case 12: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ Descriptor->Das.Length = (UINT16) (Descriptor->Das.Length + StringLength);
+
+ strcpy ((char *) &Descriptor->Das.OptionalFields[OptionIndex],
+ InitializerOp->Asl.Value.String);
+ }
+ }
+ break;
+
+ case 13: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+
+ case 14: /* Address Range */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MEMATTRIBUTES,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 3);
+ break;
+
+ case 15: /* Type */
+
+ RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 5, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 5);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Das.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoQwordIoDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "QwordIO" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoQwordIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_QWORD_ADDRESS_DESC) +
+ StringLength);
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Qas.DescriptorType = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
+ Descriptor->Qas.ResourceType = ACPI_RESOURCE_TYPE_IO_RANGE;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Qas.Length = (UINT16) (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Qas.ResourceType));
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* MinType */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 2);
+ break;
+
+ case 2: /* MaxType */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 3);
+ break;
+
+ case 3: /* DecodeType */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 1);
+ break;
+
+ case 4: /* Range Type */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 0, 3);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 0);
+ break;
+
+ case 5: /* Address Granularity */
+
+ Descriptor->Qas.Granularity = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Granularity));
+ break;
+
+ case 6: /* Address Min */
+
+ Descriptor->Qas.AddressMin = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMin));
+ break;
+
+ case 7: /* Address Max */
+
+ Descriptor->Qas.AddressMax = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMax));
+ break;
+
+ case 8: /* Translation Offset */
+
+ Descriptor->Qas.TranslationOffset = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.TranslationOffset));
+ break;
+
+ case 9: /* Address Length */
+
+ Descriptor->Qas.AddressLength = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressLength));
+ break;
+
+ case 10: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Descriptor->Qas.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
+ OptionIndex++;
+ Descriptor->Qas.Length++;
+ }
+ break;
+
+ case 11: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ Descriptor->Qas.Length = (UINT16) (Descriptor->Qas.Length + StringLength);
+
+ strcpy ((char *) &Descriptor->Qas.OptionalFields[OptionIndex],
+ InitializerOp->Asl.Value.String);
+ }
+ }
+ break;
+
+ case 12: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ case 13: /* Type */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 4, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 4);
+ break;
+
+ case 14: /* Translation Type */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 5, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 5);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Qas.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoQwordMemoryDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "QwordMemory" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoQwordMemoryDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_QWORD_ADDRESS_DESC) +
+ StringLength);
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Qas.DescriptorType = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
+ Descriptor->Qas.ResourceType = ACPI_RESOURCE_TYPE_MEMORY_RANGE;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Qas.Length = (UINT16) (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Qas.ResourceType));
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* DecodeType */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 1);
+ break;
+
+ case 2: /* MinType */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 2);
+ break;
+
+ case 3: /* MaxType */
+
+ RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 3);
+ break;
+
+ case 4: /* Memory Type */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MEMTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 1);
+ break;
+
+ case 5: /* Read/Write Type */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 0, 1);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 0);
+ break;
+
+ case 6: /* Address Granularity */
+
+ Descriptor->Qas.Granularity = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Granularity));
+ break;
+
+ case 7: /* Min Address */
+
+ Descriptor->Qas.AddressMin = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMin));
+ break;
+
+ case 8: /* Max Address */
+
+ Descriptor->Qas.AddressMax = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMax));
+ break;
+
+ case 9: /* Translation Offset */
+
+ Descriptor->Qas.TranslationOffset = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.TranslationOffset));
+ break;
+
+ case 10: /* Address Length */
+
+ Descriptor->Qas.AddressLength = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressLength));
+ break;
+
+ case 11: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Descriptor->Qas.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
+ OptionIndex++;
+ Descriptor->Qas.Length++;
+ }
+ break;
+
+ case 12: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ Descriptor->Qas.Length = (UINT16) (Descriptor->Qas.Length + StringLength);
+
+ strcpy ((char *) &Descriptor->Qas.OptionalFields[OptionIndex],
+ InitializerOp->Asl.Value.String);
+ }
+ }
+ break;
+
+ case 13: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+
+ case 14: /* Address Range */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MEMATTRIBUTES,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 3);
+ break;
+
+ case 15: /* Type */
+
+ RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 5, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 5);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Qas.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoWordIoDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "WordIO" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoWordIoDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_WORD_ADDRESS_DESC) +
+ StringLength);
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Was.DescriptorType = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE;
+ Descriptor->Was.ResourceType = ACPI_RESOURCE_TYPE_IO_RANGE;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Was.Length = (UINT16) (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Was.ResourceType));
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* MinType */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 2);
+ break;
+
+ case 2: /* MaxType */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 3);
+ break;
+
+ case 3: /* DecodeType */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 1);
+ break;
+
+ case 4: /* Range Type */
+
+ RsSetFlagBits (&Descriptor->Was.SpecificFlags, InitializerOp, 0, 3);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 0);
+ break;
+
+ case 5: /* Address Granularity */
+
+ Descriptor->Was.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Granularity));
+ break;
+
+ case 6: /* Address Min */
+
+ Descriptor->Was.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMin));
+ break;
+
+ case 7: /* Address Max */
+
+ Descriptor->Was.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMax));
+ break;
+
+ case 8: /* Translation Offset */
+
+ Descriptor->Was.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.TranslationOffset));
+ break;
+
+ case 9: /* Address Length */
+
+ Descriptor->Was.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressLength));
+ break;
+
+ case 10: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Descriptor->Was.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
+ OptionIndex++;
+ Descriptor->Was.Length++;
+ }
+ break;
+
+ case 11: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ Descriptor->Was.Length = (UINT16) (Descriptor->Was.Length +StringLength);
+
+ strcpy ((char *) &Descriptor->Was.OptionalFields[OptionIndex],
+ InitializerOp->Asl.Value.String);
+ }
+ }
+ break;
+
+ case 12: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ case 13: /* Type */
+
+ RsSetFlagBits (&Descriptor->Was.SpecificFlags, InitializerOp, 4, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 4);
+ break;
+
+ case 14: /* Translation Type */
+
+ RsSetFlagBits (&Descriptor->Was.SpecificFlags, InitializerOp, 5, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 5);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Was.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoWordBusNumberDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "WordBusNumber" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoWordBusNumberDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+
+ Rnode = RsAllocateResourceNode (sizeof (ASL_WORD_ADDRESS_DESC) +
+ StringLength);
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Was.DescriptorType = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE;
+ Descriptor->Was.ResourceType = ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Was.Length = (UINT16) (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Was.ResourceType));
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* MinType */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 2);
+ break;
+
+ case 2: /* MaxType */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 3);
+ break;
+
+ case 3: /* DecodeType */
+
+ RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 1);
+ break;
+
+ case 4: /* Address Granularity */
+
+ Descriptor->Was.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Granularity));
+ break;
+
+ case 5: /* Min Address */
+
+ Descriptor->Was.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMin));
+ break;
+
+ case 6: /* Max Address */
+
+ Descriptor->Was.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMax));
+ break;
+
+ case 7: /* Translation Offset */
+
+ Descriptor->Was.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.TranslationOffset));
+ break;
+
+ case 8: /* Address Length */
+
+ Descriptor->Was.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressLength));
+ break;
+
+ case 9: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ Descriptor->Was.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
+ OptionIndex++;
+ Descriptor->Was.Length++;
+ }
+ break;
+
+ case 10: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ Descriptor->Was.Length = (UINT16) (Descriptor->Was.Length + StringLength);
+
+ strcpy ((char *) &Descriptor->Was.OptionalFields[OptionIndex],
+ InitializerOp->Asl.Value.String);
+ }
+ }
+ break;
+
+ case 11: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) -
+ ASL_RESDESC_OFFSET (Was.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoInterruptDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "Interrupt" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoInterruptDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ASL_RESOURCE_DESC *Rover = NULL;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 StringLength = 0;
+ UINT32 OptionIndex = 0;
+ UINT32 i;
+ BOOLEAN HasResSourceIndex = FALSE;
+ UINT8 ResSourceIndex = 0;
+ UINT8 *ResSourceString = NULL;
+
+
+ InitializerOp = Op->Asl.Child;
+ StringLength = RsGetStringDataLength (InitializerOp);
+ if (StringLength)
+ {
+ /* Make room for the ResourceSourceIndex */
+
+ OptionIndex++;
+ }
+
+ /* Count the interrupt numbers */
+
+ for (i = 0; InitializerOp; i++)
+ {
+ InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
+ if (i <= 6)
+ {
+ continue;
+ }
+
+ OptionIndex += 4;
+ }
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_EXTENDED_XRUPT_DESC) +
+ OptionIndex + StringLength);
+ Descriptor = Rnode->Buffer;
+ Descriptor->Exx.DescriptorType = ACPI_RDESC_TYPE_EXTENDED_XRUPT;
+
+ /*
+ * Initial descriptor length -- may be enlarged if there are
+ * optional fields present
+ */
+ Descriptor->Exx.Length = 2; /* Flags and table length byte */
+ Descriptor->Exx.TableLength = 0;
+
+ Rover = ACPI_CAST_PTR (ASL_RESOURCE_DESC, (&(Descriptor->Exx.InterruptNumber[0])));
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Resource Type (Default: consumer (1) */
+
+ RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 0, 1);
+ break;
+
+ case 1: /* Interrupt Type (or Mode - edge/level) */
+
+ RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 1, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTTYPE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.Flags), 0);
+ break;
+
+ case 2: /* Interrupt Level (or Polarity - Active high/low) */
+
+ RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 2, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTLEVEL,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.Flags), 2);
+ break;
+
+ case 3: /* Share Type - Default: exclusive (0) */
+
+ RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 3, 0);
+ RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTSHARE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.Flags), 3);
+ break;
+
+ case 4: /* ResSourceIndex [Optional Field - BYTE] */
+
+ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
+ {
+ HasResSourceIndex = TRUE;
+ ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
+ }
+ break;
+
+ case 5: /* ResSource [Optional Field - STRING] */
+
+ if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (InitializerOp->Asl.Value.String))
+ {
+ if (StringLength)
+ {
+ ResSourceString = (UINT8 *) InitializerOp->Asl.Value.String;
+ }
+ }
+ break;
+
+ case 6: /* ResourceTag */
+
+ UtAttachNamepathToOwner (Op, InitializerOp);
+ break;
+
+ default:
+ /*
+ * Interrupt Numbers come through here, repeatedly.
+ * Store the integer and move pointer to the next one.
+ */
+ Rover->U32Item = (UINT32) InitializerOp->Asl.Value.Integer;
+ Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U32Item), 4);
+
+ Descriptor->Exx.TableLength++;
+ Descriptor->Exx.Length += 4;
+
+ if (i == 7) /* case 7: First interrupt number */
+ {
+ RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.InterruptNumber[0]));
+ }
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ /*
+ * Add optional ResSourceIndex if present
+ */
+ if (HasResSourceIndex)
+ {
+ Rover->U8Item = ResSourceIndex;
+ Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U8Item), 1);
+ Descriptor->Exx.Length += 1;
+ }
+
+ /*
+ * Add optional ResSource string if present
+ */
+ if (StringLength && ResSourceString)
+ {
+
+ strcpy ((char *) Rover, (char *) ResSourceString);
+ Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U8Item), StringLength);
+ Descriptor->Exx.Length = (UINT16) (Descriptor->Exx.Length + StringLength);
+ }
+
+ Rnode->BufferLength = (ASL_RESDESC_OFFSET (Exx.InterruptNumber[0]) -
+ ASL_RESDESC_OFFSET (Exx.DescriptorType))
+ + OptionIndex + StringLength;
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoVendorLargeDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "VendorLong" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoVendorLargeDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ /* Count the number of data bytes */
+
+ InitializerOp = Op->Asl.Child;
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+
+ for (i = 0; InitializerOp; i++)
+ {
+ InitializerOp = InitializerOp->Asl.Next;
+ }
+
+ InitializerOp = Op->Asl.Child;
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ Rnode = RsAllocateResourceNode (sizeof (ASL_LARGE_VENDOR_DESC) + (i - 1));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Lgv.DescriptorType = ACPI_RDESC_TYPE_LARGE_VENDOR;
+ Descriptor->Lgv.Length = (UINT16) i;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ Descriptor->Lgv.VendorDefined[i] = (UINT8) InitializerOp->Asl.Value.Integer;
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+
+ return (Rnode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: RsDoGeneralRegisterDescriptor
+ *
+ * PARAMETERS: Op - Parent resource descriptor parse node
+ * CurrentByteOffset - Offset into the resource template AML
+ * buffer (to track references to the desc)
+ *
+ * RETURN: Completed resource node
+ *
+ * DESCRIPTION: Construct a long "Register" descriptor
+ *
+ ******************************************************************************/
+
+ASL_RESOURCE_NODE *
+RsDoGeneralRegisterDescriptor (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 CurrentByteOffset)
+{
+ ASL_RESOURCE_DESC *Descriptor;
+ ACPI_PARSE_OBJECT *InitializerOp;
+ ASL_RESOURCE_NODE *Rnode;
+ UINT32 i;
+
+
+ InitializerOp = Op->Asl.Child;
+ Rnode = RsAllocateResourceNode (sizeof (ASL_GENERAL_REGISTER_DESC));
+
+ Descriptor = Rnode->Buffer;
+ Descriptor->Grg.DescriptorType = ACPI_RDESC_TYPE_GENERAL_REGISTER;
+ Descriptor->Grg.Length = 12;
+
+ /*
+ * Process all child initialization nodes
+ */
+ for (i = 0; InitializerOp; i++)
+ {
+ switch (i)
+ {
+ case 0: /* Address space */
+
+ Descriptor->Grg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_ADDRESSSPACE,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.AddressSpaceId));
+ break;
+
+ case 1: /* Register Bit Width */
+
+ Descriptor->Grg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_REGISTERBITWIDTH,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.BitWidth));
+ break;
+
+ case 2: /* Register Bit Offset */
+
+ Descriptor->Grg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_REGISTERBITOFFSET,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.BitOffset));
+ break;
+
+ case 3: /* Register Address */
+
+ Descriptor->Grg.Address = InitializerOp->Asl.Value.Integer;
+ RsCreateByteField (InitializerOp, ASL_RESNAME_ADDRESS,
+ CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.Address));
+ break;
+
+
+ default:
+
+ AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
+ break;
+ }
+
+ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
+ }
+ return (Rnode);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c
new file mode 100644
index 0000000..1224c19
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslstubs.c
@@ -0,0 +1,266 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslstubs - Stubs used to link to Aml interpreter
+ * $Revision: 11 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 <stdio.h>
+#include "aslcompiler.h"
+#include "acdispat.h"
+#include "actables.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslstubs")
+
+
+/*
+ * Stubs to simplify linkage to the ACPI CA core subsystem.
+ * Things like Events, Global Lock, etc. are not used
+ * by the compiler, so they are stubbed out here.
+ */
+ACPI_STATUS
+AeLocalGetRootPointer (
+ UINT32 Flags,
+ ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
+{
+ return AE_ERROR;
+}
+
+ACPI_STATUS
+AcpiDsMethodDataGetValue (
+ UINT16 Opcode,
+ UINT32 Index,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **DestDesc)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiDsMethodDataGetNode (
+ UINT16 Opcode,
+ UINT32 Index,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE **Node)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiDsStoreObjectToLocal (
+ UINT16 Opcode,
+ UINT32 Index,
+ ACPI_OPERAND_OBJECT *SrcDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiEvDeleteGpeBlock (
+ ACPI_GPE_BLOCK_INFO *GpeBlock)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiEvQueueNotifyRequest (
+ ACPI_NAMESPACE_NODE *Node,
+ UINT32 NotifyValue)
+{
+ return (AE_OK);
+}
+
+BOOLEAN
+AcpiEvIsNotifyObject (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ return (FALSE);
+}
+
+ACPI_STATUS
+AcpiEvAcquireGlobalLock(
+ UINT32 Timeout)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiEvReleaseGlobalLock(
+ void)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiEvInitializeRegion (
+ ACPI_OPERAND_OBJECT *RegionObj,
+ BOOLEAN AcpiNsLocked)
+{
+ return (AE_OK);
+}
+
+ACPI_STATUS
+AcpiExReadDataFromField (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **RetBufferDesc)
+{
+ return (AE_SUPPORT);
+}
+
+ACPI_STATUS
+AcpiExWriteDataToField (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc)
+{
+ return (AE_SUPPORT);
+}
+
+ACPI_STATUS
+AcpiExLoadTableOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ return (AE_SUPPORT);
+}
+
+
+ACPI_STATUS
+AcpiExUnloadTable (
+ ACPI_OPERAND_OBJECT *DdbHandle)
+{
+ return (AE_SUPPORT);
+}
+
+ACPI_STATUS
+AcpiExLoadOp (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT *Target,
+ ACPI_WALK_STATE *WalkState)
+{
+ return (AE_SUPPORT);
+}
+
+ACPI_STATUS
+AcpiTbFindTable (
+ char *Signature,
+ char *OemId,
+ char *OemTableId,
+ ACPI_TABLE_HEADER **TablePtr)
+{
+ return (AE_SUPPORT);
+}
+
diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c
new file mode 100644
index 0000000..ca5225d
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asltransform.c
@@ -0,0 +1,623 @@
+
+/******************************************************************************
+ *
+ * Module Name: asltransform - Parse tree transforms
+ * $Revision: 19 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("asltransform")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAmlGetNextTempName
+ *
+ * PARAMETERS: NamePath - Where a pointer to the temp name is returned
+ *
+ * RETURN: A pointer to the second character of the name
+ *
+ * DESCRIPTION: Generate an ACPI name of the form _Txx. These names are
+ * reserved for use by the ASL compiler.
+ *
+ ******************************************************************************/
+
+char *
+TrAmlGetNextTempName (
+ char **NamePath)
+{
+ char *TempName;
+
+
+ if (Gbl_TempCount > 255)
+ {
+ /* Too many temps */
+ /* TBD: issue eror message */
+ *NamePath = "ERROR";
+ return ("Error");
+ }
+
+ TempName = UtLocalCalloc (6);
+ UtConvertByteToHex ((UINT8) Gbl_TempCount, (UINT8 *) &TempName [1]);
+ Gbl_TempCount++;
+
+ /* First three characters are always "\_T" */
+
+ TempName[0] = '\\';
+ TempName[1] = '_';
+ TempName[2] = 'T';
+
+ *NamePath = TempName;
+ return (&TempName[1]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAmlInitLineNumbers
+ *
+ * PARAMETERS: Op - Op to be initialized
+ * Neighbor - Op used for initialization values
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialized the various line numbers for a parse node.
+ *
+ ******************************************************************************/
+
+void
+TrAmlInitLineNumbers (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *Neighbor)
+{
+
+ Op->Asl.EndLine = Neighbor->Asl.EndLine;
+ Op->Asl.EndLogicalLine = Neighbor->Asl.EndLogicalLine;
+ Op->Asl.LineNumber = Neighbor->Asl.LineNumber;
+ Op->Asl.LogicalByteOffset = Neighbor->Asl.LogicalByteOffset;
+ Op->Asl.LogicalLineNumber = Neighbor->Asl.LogicalLineNumber;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAmlInitNode
+ *
+ * PARAMETERS: Op - Op to be initialized
+ * ParseOpcode - Opcode for this node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize a node with the parse opcode and opcode name.
+ *
+ ******************************************************************************/
+
+void
+TrAmlInitNode (
+ ACPI_PARSE_OBJECT *Op,
+ UINT16 ParseOpcode)
+{
+
+ Op->Asl.ParseOpcode = ParseOpcode;
+ UtSetParseOpName (Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAmlSetSubtreeParent
+ *
+ * PARAMETERS: Op - First node in a list of peer nodes
+ * Parent - Parent of the subtree
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set the parent for all peer nodes in a subtree
+ *
+ ******************************************************************************/
+
+void
+TrAmlSetSubtreeParent (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *Parent)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ Next = Op;
+ while (Next)
+ {
+ Next->Asl.Parent = Parent;
+ Next = Next->Asl.Next;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAmlInsertPeer
+ *
+ * PARAMETERS: Op - First node in a list of peer nodes
+ * NewPeer - Peer node to insert
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Insert a new peer node into a list of peers.
+ *
+ ******************************************************************************/
+
+void
+TrAmlInsertPeer (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *NewPeer)
+{
+
+ NewPeer->Asl.Next = Op->Asl.Next;
+ Op->Asl.Next = NewPeer;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAmlTransformWalk
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
+ * operands.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+TrAmlTransformWalk (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+
+ TrTransformSubtree (Op);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrTransformSubtree
+ *
+ * PARAMETERS: Op - The parent parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
+ * complex AML opcodes require processing of the child nodes
+ * (arguments/operands).
+ *
+ ******************************************************************************/
+
+void
+TrTransformSubtree (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
+ {
+ return;
+ }
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+ TrDoDefinitionBlock (Op);
+ break;
+
+ case PARSEOP_ELSEIF:
+ TrDoElseif (Op);
+ break;
+
+ case PARSEOP_SWITCH:
+ TrDoSwitch (Op);
+ break;
+
+ default:
+ /* Nothing to do here for other opcodes */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrDoDefinitionBlock
+ *
+ * PARAMETERS: Op - Parse node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Find the end of the definition block and set a global to this
+ * node. It is used by the compiler to insert compiler-generated
+ * names at the root level of the namespace.
+ *
+ ******************************************************************************/
+
+void
+TrDoDefinitionBlock (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+ UINT32 i;
+
+
+ Next = Op->Asl.Child;
+ for (i = 0; i < 5; i++)
+ {
+ Next = Next->Asl.Next;
+ }
+
+ Gbl_FirstLevelInsertionNode = Next;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrDoElseif
+ *
+ * PARAMETERS: Op - Parse node for ELSEIF
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Transform an Elseif into an Else and If AML opcode pair.
+ * There is no AML opcode for ELSEIF -- it must be simulated
+ * with an if/else pair.
+ *
+ ******************************************************************************/
+
+void
+TrDoElseif (
+ ACPI_PARSE_OBJECT *ElseNode)
+{
+ ACPI_PARSE_OBJECT *IfNode = NULL;
+ ACPI_PARSE_OBJECT *NextNode;
+
+
+ /* Change the ELSEIF into an ELSE */
+
+ TrAmlInitNode (ElseNode, PARSEOP_ELSE);
+
+ /* Create a new IF node */
+
+ IfNode = TrCreateLeafNode (PARSEOP_IF);
+ IfNode->Asl.Parent = ElseNode;
+ TrAmlInitLineNumbers (IfNode, ElseNode);
+
+ /* Insert the the IF node first in the ELSE child list */
+
+ IfNode->Asl.Child = ElseNode->Asl.Child;
+ ElseNode->Asl.Child = IfNode;
+
+ /* Go to the end of the IF <Predicate><TermList> block */
+
+ NextNode = IfNode->Asl.Child; /* Next = Predicate */
+ NextNode = NextNode->Asl.Next; /* Nest = TermList */
+
+ /* Make the next node after the IF the rest of the original tree */
+
+ IfNode->Asl.Next = NextNode->Asl.Next;
+
+ /* Terminate the IF subtree and set IF node as the parent for all nodes */
+
+ NextNode->Asl.Next = NULL;
+ TrAmlSetSubtreeParent (IfNode->Asl.Child, IfNode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrDoSwitch
+ *
+ * PARAMETERS: StartNode - Parse node for SWITCH
+ *
+ * RETURN: None
+ *
+ *
+ * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is
+ * no actual AML opcode for SWITCH -- it must be simulated.
+ *
+ ******************************************************************************/
+
+void
+TrDoSwitch (
+ ACPI_PARSE_OBJECT *StartNode)
+{
+ ACPI_PARSE_OBJECT *Next;
+ ACPI_PARSE_OBJECT *CaseOp = NULL;
+ ACPI_PARSE_OBJECT *CaseBlock = NULL;
+ ACPI_PARSE_OBJECT *DefaultOp = NULL;
+ ACPI_PARSE_OBJECT *CurrentParentNode;
+ ACPI_PARSE_OBJECT *Conditional = NULL;
+ ACPI_PARSE_OBJECT *Predicate;
+ ACPI_PARSE_OBJECT *Peer;
+ ACPI_PARSE_OBJECT *NewOp;
+ ACPI_PARSE_OBJECT *NewOp2;
+ char *PredicateValueName;
+ char *PredicateValuePath;
+
+
+ CurrentParentNode = StartNode;
+ PredicateValueName = TrAmlGetNextTempName (&PredicateValuePath);
+
+ /* First child is the predicate */
+
+ Next = StartNode->Asl.Child;
+ Peer = Next->Asl.Next;
+
+ /* CASE statements start at next child */
+
+ while (Peer)
+ {
+ Next = Peer;
+ Peer = Next->Asl.Next;
+
+ if (Next->Asl.ParseOpcode == PARSEOP_CASE)
+ {
+ if (CaseOp)
+ {
+ /* Add an ELSE to complete the previous CASE */
+
+ NewOp = TrCreateLeafNode (PARSEOP_ELSE);
+ NewOp->Asl.Parent = Conditional->Asl.Parent;
+ TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent);
+
+ /* Link ELSE node as a peer to the previous IF */
+
+ TrAmlInsertPeer (Conditional, NewOp);
+ CurrentParentNode = NewOp;
+ }
+
+ CaseOp = Next;
+ Conditional = CaseOp;
+ CaseBlock = CaseOp->Asl.Child->Asl.Next;
+ Conditional->Asl.Child->Asl.Next = NULL;
+
+ /*
+ * change CaseOp() to: If (PredicateValue == CaseValue) {...}
+ * CaseOp->Child is the case value
+ * CaseOp->Child->Peer is the beginning of the case block
+ */
+ NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
+ (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath));
+
+ Predicate = CaseOp->Asl.Child;
+ Predicate->Asl.Next = NewOp;
+ TrAmlInitLineNumbers (NewOp, Predicate);
+
+ NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL);
+ NewOp2->Asl.Parent = Conditional;
+ NewOp2->Asl.Child = Predicate;
+ TrAmlInitLineNumbers (NewOp2, Conditional);
+
+ TrAmlSetSubtreeParent (Predicate, NewOp2);
+
+ Predicate = NewOp2;
+ Predicate->Asl.Next = CaseBlock;
+
+ TrAmlSetSubtreeParent (Predicate, Conditional);
+
+ /* Reinitialize the CASE node to an IF node */
+
+ Conditional->Asl.Child = Predicate;
+ TrAmlInitNode (Conditional, PARSEOP_IF);
+
+ /*
+ * The first CASE(IF) is not nested under an ELSE.
+ * All other CASEs are children of a parent ELSE.
+ */
+ if (CurrentParentNode == StartNode)
+ {
+ Conditional->Asl.Parent = CurrentParentNode->Asl.Parent;
+
+ /* Link IF into the peer list */
+
+ TrAmlInsertPeer (CurrentParentNode, Conditional);
+ }
+ else
+ {
+ /*
+ * The IF is a child of previous IF/ELSE. It
+ * is therefore without peer.
+ */
+ CurrentParentNode->Asl.Child = Conditional;
+ Conditional->Asl.Parent = CurrentParentNode;
+ Conditional->Asl.Next = NULL;
+ }
+ }
+ else if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT)
+ {
+ if (DefaultOp)
+ {
+ /* More than one Default */
+ }
+
+ /* Save the DEFAULT node for later, after CASEs */
+
+ DefaultOp = Next;
+ }
+ else
+ {
+ /* Unkown peer opcode */
+
+ printf ("Unknown parse opcode for switch statement: %s (%d)\n",
+ Next->Asl.ParseOpName, Next->Asl.ParseOpcode);
+ }
+ }
+
+ /*
+ * Add the default at the end of the if/else construct
+ */
+ if (DefaultOp)
+ {
+ if (CaseOp)
+ {
+ /* Add an ELSE first */
+
+ TrAmlInitNode (DefaultOp, PARSEOP_ELSE);
+ DefaultOp->Asl.Parent = Conditional->Asl.Parent;
+ }
+ else
+ {
+ /* There were no CASE statements, no ELSE needed */
+
+ TrAmlInsertPeer (CurrentParentNode, DefaultOp->Asl.Child);
+ }
+ }
+
+ /*
+ * Add a NAME node for the temp integer
+ */
+ NewOp = TrCreateLeafNode (PARSEOP_NAME);
+ NewOp->Asl.Parent = Gbl_FirstLevelInsertionNode->Asl.Parent;
+
+ NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
+ (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
+ NewOp->Asl.Child = NewOp2;
+ NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_INTEGER, (ACPI_INTEGER) 0);
+
+ TrAmlSetSubtreeParent (NewOp2, NewOp);
+
+ /* Insert this node at the global level of the ASL */
+
+ TrAmlInsertPeer (Gbl_FirstLevelInsertionNode, NewOp);
+ TrAmlInitLineNumbers (NewOp, Gbl_FirstLevelInsertionNode);
+ TrAmlInitLineNumbers (NewOp2, Gbl_FirstLevelInsertionNode);
+ TrAmlInitLineNumbers (NewOp2->Asl.Next, Gbl_FirstLevelInsertionNode);
+
+ /*
+ * Change the SWITCH node to a STORE (predicate value, _Txx)
+ */
+ TrAmlInitNode (StartNode, PARSEOP_STORE);
+
+ Predicate = StartNode->Asl.Child;
+ Predicate->Asl.Child = NULL;
+
+ NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
+ (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath));
+ NewOp->Asl.Parent = StartNode;
+ Predicate->Asl.Next = NewOp;
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c
new file mode 100644
index 0000000..0518303
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asltree.c
@@ -0,0 +1,1182 @@
+
+/******************************************************************************
+ *
+ * Module Name: asltree - parse tree management
+ * $Revision: 53 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("asltree")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrGetNextNode
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: New parse node. Aborts on allocation failure
+ *
+ * DESCRIPTION: Allocate a new parse node for the parse tree. Bypass the local
+ * dynamic memory manager for performance reasons (This has a
+ * major impact on the speed of the compiler.)
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrGetNextNode (void)
+{
+
+ if (Gbl_NodeCacheNext >= Gbl_NodeCacheLast)
+ {
+ Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ACPI_PARSE_OBJECT) * ASL_NODE_CACHE_SIZE);
+ Gbl_NodeCacheLast = Gbl_NodeCacheNext + ASL_NODE_CACHE_SIZE;
+ }
+
+ return (Gbl_NodeCacheNext++);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrAllocateNode
+ *
+ * PARAMETERS: ParseOpcode - Opcode to be assigned to the node
+ *
+ * RETURN: New parse node. Aborts on allocation failure
+ *
+ * DESCRIPTION: Allocate and initialize a new parse node for the parse tree
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrAllocateNode (
+ UINT32 ParseOpcode)
+{
+ ACPI_PARSE_OBJECT *Op;
+
+
+ Op = TrGetNextNode ();
+
+ Op->Asl.ParseOpcode = (UINT16) ParseOpcode;
+ Op->Asl.Filename = Gbl_Files[ASL_FILE_INPUT].Filename;
+ Op->Asl.LineNumber = Gbl_CurrentLineNumber;
+ Op->Asl.LogicalLineNumber = Gbl_LogicalLineNumber;
+ Op->Asl.LogicalByteOffset = Gbl_CurrentLineOffset;
+ Op->Asl.Column = Gbl_CurrentColumn;
+
+ UtSetParseOpName (Op);
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrReleaseNode
+ *
+ * PARAMETERS: Op - Op to be released
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: "release" a node. In truth, nothing is done since the node
+ * is part of a larger buffer
+ *
+ ******************************************************************************/
+
+void
+TrReleaseNode (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrUpdateNode
+ *
+ * PARAMETERS: ParseOpcode - New opcode to be assigned to the node
+ * Op - An existing parse node
+ *
+ * RETURN: The updated node
+ *
+ * DESCRIPTION: Change the parse opcode assigned to a node. Usually used to
+ * change an opcode to DEFAULT_ARG so that the node is ignored
+ * during the code generation. Also used to set generic integers
+ * to a specific size (8, 16, 32, or 64 bits)
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrUpdateNode (
+ UINT32 ParseOpcode,
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ if (!Op)
+ {
+ return NULL;
+ }
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nUpdateNode: Old - %s, New - %s\n\n",
+ UtGetOpName (Op->Asl.ParseOpcode),
+ UtGetOpName (ParseOpcode));
+
+ /* Assign new opcode and name */
+
+ if (Op->Asl.ParseOpcode == PARSEOP_ONES)
+ {
+ switch (ParseOpcode)
+ {
+ case PARSEOP_BYTECONST:
+ Op->Asl.Value.Integer = 0xFF;
+ break;
+
+ case PARSEOP_WORDCONST:
+ Op->Asl.Value.Integer = 0xFFFF;
+ break;
+
+ case PARSEOP_DWORDCONST:
+ Op->Asl.Value.Integer = 0xFFFFFFFF;
+ break;
+
+ default:
+ /* Don't care about others, don't need to check QWORD */
+ break;
+ }
+ }
+
+ Op->Asl.ParseOpcode = (UINT16) ParseOpcode;
+ UtSetParseOpName (Op);
+
+ /*
+ * For the BYTE, WORD, and DWORD constants, make sure that the integer
+ * that was passed in will actually fit into the data type
+ */
+ switch (ParseOpcode)
+ {
+ case PARSEOP_BYTECONST:
+ Op = UtCheckIntegerRange (Op, 0x00, ACPI_UINT8_MAX);
+ break;
+
+ case PARSEOP_WORDCONST:
+ Op = UtCheckIntegerRange (Op, 0x00, ACPI_UINT16_MAX);
+ break;
+
+ case PARSEOP_DWORDCONST:
+ Op = UtCheckIntegerRange (Op, 0x00, ACPI_UINT32_MAX);
+ break;
+
+ default:
+ /* Don't care about others, don't need to check QWORD */
+ break;
+ }
+
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrGetNodeFlagName
+ *
+ * PARAMETERS: Flags - Flags word to be decoded
+ *
+ * RETURN: Name string
+ *
+ * DESCRIPTION: Decode a flags word
+ *
+ ******************************************************************************/
+
+char *
+TrGetNodeFlagName (
+ UINT32 Flags)
+{
+
+ switch (Flags)
+ {
+ case NODE_VISITED:
+ return ("NODE_VISITED");
+
+ case NODE_AML_PACKAGE:
+ return ("NODE_AML_PACKAGE");
+
+ case NODE_IS_TARGET:
+ return ("NODE_IS_TARGET");
+
+ case NODE_IS_RESOURCE_DESC:
+ return ("NODE_IS_RESOURCE_DESC");
+
+ case NODE_IS_RESOURCE_FIELD:
+ return ("NODE_IS_RESOURCE_FIELD");
+
+ case NODE_HAS_NO_EXIT:
+ return ("NODE_HAS_NO_EXIT");
+
+ case NODE_IF_HAS_NO_EXIT:
+ return ("NODE_IF_HAS_NO_EXIT");
+
+ case NODE_NAME_INTERNALIZED:
+ return ("NODE_NAME_INTERNALIZED");
+
+ case NODE_METHOD_NO_RETVAL:
+ return ("NODE_METHOD_NO_RETVAL");
+
+ case NODE_METHOD_SOME_NO_RETVAL:
+ return ("NODE_METHOD_SOME_NO_RETVAL");
+
+ case NODE_RESULT_NOT_USED:
+ return ("NODE_RESULT_NOT_USED");
+
+ case NODE_METHOD_TYPED:
+ return ("NODE_METHOD_TYPED");
+
+ case NODE_IS_BIT_OFFSET:
+ return ("NODE_IS_BIT_OFFSET");
+
+ case NODE_COMPILE_TIME_CONST:
+ return ("NODE_COMPILE_TIME_CONST");
+
+ case NODE_IS_TERM_ARG:
+ return ("NODE_IS_TERM_ARG");
+
+ case NODE_WAS_ONES_OP:
+ return ("NODE_WAS_ONES_OP");
+
+ case NODE_IS_NAME_DECLARATION:
+ return ("NODE_IS_NAME_DECLARATION");
+
+ default:
+ return ("Multiple Flags (or unknown flag) set");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrSetNodeFlags
+ *
+ * PARAMETERS: Op - An existing parse node
+ * Flags - New flags word
+ *
+ * RETURN: The updated node
+ *
+ * DESCRIPTION: Set bits in the node flags word. Will not clear bits, only set
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrSetNodeFlags (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Flags)
+{
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nSetNodeFlags: Op %p, %8.8X %s\n\n", Op, Flags, TrGetNodeFlagName (Flags));
+
+ if (!Op)
+ {
+ return NULL;
+ }
+
+ Op->Asl.CompileFlags |= Flags;
+
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrSetEndLineNumber
+ *
+ * PARAMETERS: Op - An existing parse node
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Set the ending line numbers (file line and logical line) of a
+ * parse node to the current line numbers.
+ *
+ ******************************************************************************/
+
+void
+TrSetEndLineNumber (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ /* If the end line # is already set, just return */
+
+ if (Op->Asl.EndLine)
+ {
+ return;
+ }
+
+ Op->Asl.EndLine = Gbl_CurrentLineNumber;
+ Op->Asl.EndLogicalLine = Gbl_LogicalLineNumber;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrCreateLeafNode
+ *
+ * PARAMETERS: ParseOpcode - New opcode to be assigned to the node
+ *
+ * RETURN: Pointer to the new node. Aborts on allocation failure
+ *
+ * DESCRIPTION: Create a simple leaf node (no children or peers, and no value
+ * assigned to the node)
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrCreateLeafNode (
+ UINT32 ParseOpcode)
+{
+ ACPI_PARSE_OBJECT *Op;
+
+
+ Op = TrAllocateNode (ParseOpcode);
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nCreateLeafNode Line %d NewNode %p Op %s\n\n",
+ Op->Asl.LineNumber, Op, UtGetOpName(ParseOpcode));
+
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrCreateValuedLeafNode
+ *
+ * PARAMETERS: ParseOpcode - New opcode to be assigned to the node
+ * Value - Value to be assigned to the node
+ *
+ * RETURN: Pointer to the new node. Aborts on allocation failure
+ *
+ * DESCRIPTION: Create a leaf node (no children or peers) with a value
+ * assigned to it
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrCreateValuedLeafNode (
+ UINT32 ParseOpcode,
+ ACPI_INTEGER Value)
+{
+ ACPI_PARSE_OBJECT *Op;
+
+
+ Op = TrAllocateNode (ParseOpcode);
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nCreateValuedLeafNode Line %d NewNode %p Op %s Value %8.8X%8.8X ",
+ Op->Asl.LineNumber, Op, UtGetOpName(ParseOpcode),
+ ACPI_HIDWORD (Value), ACPI_LODWORD (Value));
+ Op->Asl.Value.Integer = Value;
+
+ switch (ParseOpcode)
+ {
+ case PARSEOP_STRING_LITERAL:
+ DbgPrint (ASL_PARSE_OUTPUT, "STRING->%s", Value);
+ break;
+
+ case PARSEOP_NAMESEG:
+ DbgPrint (ASL_PARSE_OUTPUT, "NAMESEG->%s", Value);
+ break;
+
+ case PARSEOP_NAMESTRING:
+ DbgPrint (ASL_PARSE_OUTPUT, "NAMESTRING->%s", Value);
+ break;
+
+ case PARSEOP_EISAID:
+ DbgPrint (ASL_PARSE_OUTPUT, "EISAID->%s", Value);
+ break;
+
+ case PARSEOP_METHOD:
+ DbgPrint (ASL_PARSE_OUTPUT, "METHOD");
+ break;
+
+ case PARSEOP_INTEGER:
+ DbgPrint (ASL_PARSE_OUTPUT, "INTEGER");
+ break;
+
+ default:
+ break;
+ }
+
+ DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrCreateNode
+ *
+ * PARAMETERS: ParseOpcode - Opcode to be assigned to the node
+ * NumChildren - Number of children to follow
+ * ... - A list of child nodes to link to the new
+ * node. NumChildren long.
+ *
+ * RETURN: Pointer to the new node. Aborts on allocation failure
+ *
+ * DESCRIPTION: Create a new parse node and link together a list of child
+ * nodes underneath the new node.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrCreateNode (
+ UINT32 ParseOpcode,
+ UINT32 NumChildren,
+ ...)
+{
+ ACPI_PARSE_OBJECT *Op;
+ ACPI_PARSE_OBJECT *Child;
+ ACPI_PARSE_OBJECT *PrevChild;
+ va_list ap;
+ UINT32 i;
+ BOOLEAN FirstChild;
+
+
+ va_start (ap, NumChildren);
+
+ /* Allocate one new node */
+
+ Op = TrAllocateNode (ParseOpcode);
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nCreateNode Line %d NewParent %p Child %d Op %s ",
+ Op->Asl.LineNumber, Op, NumChildren, UtGetOpName(ParseOpcode));
+
+ /* Some extra debug output based on the parse opcode */
+
+ switch (ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+ RootNode = Op;
+ DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->");
+ break;
+
+ case PARSEOP_OPERATIONREGION:
+ DbgPrint (ASL_PARSE_OUTPUT, "OPREGION->");
+ break;
+
+ case PARSEOP_OR:
+ DbgPrint (ASL_PARSE_OUTPUT, "OR->");
+ break;
+
+ default:
+ /* Nothing to do for other opcodes */
+ break;
+ }
+
+ /* Link the new node to its children */
+
+ PrevChild = NULL;
+ FirstChild = TRUE;
+ for (i = 0; i < NumChildren; i++)
+ {
+ /* Get the next child */
+
+ Child = va_arg (ap, ACPI_PARSE_OBJECT *);
+ DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
+
+ /*
+ * If child is NULL, this means that an optional argument
+ * was omitted. We must create a placeholder with a special
+ * opcode (DEFAULT_ARG) so that the code generator will know
+ * that it must emit the correct default for this argument
+ */
+ if (!Child)
+ {
+ Child = TrAllocateNode (PARSEOP_DEFAULT_ARG);
+ }
+
+ /* Link first child to parent */
+
+ if (FirstChild)
+ {
+ FirstChild = FALSE;
+ Op->Asl.Child = Child;
+ }
+
+ /* Point all children to parent */
+
+ Child->Asl.Parent = Op;
+
+ /* Link children in a peer list */
+
+ if (PrevChild)
+ {
+ PrevChild->Asl.Next = Child;
+ };
+
+ /*
+ * This child might be a list, point all nodes in the list
+ * to the same parent
+ */
+ while (Child->Asl.Next)
+ {
+ Child = Child->Asl.Next;
+ Child->Asl.Parent = Op;
+ }
+
+ PrevChild = Child;
+ }
+ va_end(ap);
+
+ DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrLinkChildren
+ *
+ * PARAMETERS: Op - An existing parse node
+ * NumChildren - Number of children to follow
+ * ... - A list of child nodes to link to the new
+ * node. NumChildren long.
+ *
+ * RETURN: The updated (linked) node
+ *
+ * DESCRIPTION: Link a group of nodes to an existing parse node
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrLinkChildren (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 NumChildren,
+ ...)
+{
+ ACPI_PARSE_OBJECT *Child;
+ ACPI_PARSE_OBJECT *PrevChild;
+ va_list ap;
+ UINT32 i;
+ BOOLEAN FirstChild;
+
+
+ va_start (ap, NumChildren);
+
+
+ TrSetEndLineNumber (Op);
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nLinkChildren Line [%d to %d] NewParent %p Child %d Op %s ",
+ Op->Asl.LineNumber, Op->Asl.EndLine,
+ Op, NumChildren, UtGetOpName(Op->Asl.ParseOpcode));
+
+ switch (Op->Asl.ParseOpcode)
+ {
+ case PARSEOP_DEFINITIONBLOCK:
+ RootNode = Op;
+ DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->");
+ break;
+
+ case PARSEOP_OPERATIONREGION:
+ DbgPrint (ASL_PARSE_OUTPUT, "OPREGION->");
+ break;
+
+ case PARSEOP_OR:
+ DbgPrint (ASL_PARSE_OUTPUT, "OR->");
+ break;
+
+ default:
+ /* Nothing to do for other opcodes */
+ break;
+ }
+
+ /* Link the new node to it's children */
+
+ PrevChild = NULL;
+ FirstChild = TRUE;
+ for (i = 0; i < NumChildren; i++)
+ {
+ Child = va_arg (ap, ACPI_PARSE_OBJECT *);
+
+ if ((Child == PrevChild) && (Child != NULL))
+ {
+ AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Child, "Child node list invalid");
+ return Op;
+ }
+
+ DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
+
+ /*
+ * If child is NULL, this means that an optional argument
+ * was omitted. We must create a placeholder with a special
+ * opcode (DEFAULT_ARG) so that the code generator will know
+ * that it must emit the correct default for this argument
+ */
+ if (!Child)
+ {
+ Child = TrAllocateNode (PARSEOP_DEFAULT_ARG);
+ }
+
+ /* Link first child to parent */
+
+ if (FirstChild)
+ {
+ FirstChild = FALSE;
+ Op->Asl.Child = Child;
+ }
+
+ /* Point all children to parent */
+
+ Child->Asl.Parent = Op;
+
+ /* Link children in a peer list */
+
+ if (PrevChild)
+ {
+ PrevChild->Asl.Next = Child;
+ };
+
+ /*
+ * This child might be a list, point all nodes in the list
+ * to the same parent
+ */
+ while (Child->Asl.Next)
+ {
+ Child = Child->Asl.Next;
+ Child->Asl.Parent = Op;
+ }
+ PrevChild = Child;
+ }
+ va_end(ap);
+
+ DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrLinkPeerNode
+ *
+ * PARAMETERS: Op1 - First peer
+ * Op2 - Second peer
+ *
+ * RETURN: Op1 or the non-null node.
+ *
+ * DESCRIPTION: Link two nodes as peers. Handles cases where one peer is null.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrLinkPeerNode (
+ ACPI_PARSE_OBJECT *Op1,
+ ACPI_PARSE_OBJECT *Op2)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nLinkPeerNode: 1=%p (%s), 2=%p (%s)\n\n",
+ Op1, Op1 ? UtGetOpName(Op1->Asl.ParseOpcode) : NULL,
+ Op2, Op2 ? UtGetOpName(Op2->Asl.ParseOpcode) : NULL);
+
+
+ if ((!Op1) && (!Op2))
+ {
+ DbgPrint (ASL_PARSE_OUTPUT, "\nTwo Null nodes!\n");
+ return Op1;
+ }
+
+ /* If one of the nodes is null, just return the non-null node */
+
+ if (!Op2)
+ {
+ return Op1;
+ }
+
+ if (!Op1)
+ {
+ return Op2;
+ }
+
+ if (Op1 == Op2)
+ {
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "\n\n************* Internal error, linking node to itself %p\n\n\n", Op1);
+ AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op1, "Linking node to itself");
+ return Op1;
+ }
+
+ Op1->Asl.Parent = Op2->Asl.Parent;
+
+ /*
+ * Op 1 may already have a peer list (such as an IF/ELSE pair),
+ * so we must walk to the end of the list and attach the new
+ * peer at the end
+ */
+ Next = Op1;
+ while (Next->Asl.Next)
+ {
+ Next = Next->Asl.Next;
+ }
+
+ Next->Asl.Next = Op2;
+ return Op1;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrLinkPeerNodes
+ *
+ * PARAMETERS: NumPeers - The number of nodes in the list to follow
+ * ... - A list of nodes to link together as peers
+ *
+ * RETURN: The first node in the list (head of the peer list)
+ *
+ * DESCRIPTION: Link together an arbitrary number of peer nodes.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrLinkPeerNodes (
+ UINT32 NumPeers,
+ ...)
+{
+ ACPI_PARSE_OBJECT *This;
+ ACPI_PARSE_OBJECT *Next;
+ va_list ap;
+ UINT32 i;
+ ACPI_PARSE_OBJECT *Start;
+
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nLinkPeerNodes: (%d) ", NumPeers);
+
+ va_start (ap, NumPeers);
+ This = va_arg (ap, ACPI_PARSE_OBJECT *);
+ Start = This;
+
+ /*
+ * Link all peers
+ */
+ for (i = 0; i < (NumPeers -1); i++)
+ {
+ DbgPrint (ASL_PARSE_OUTPUT, "%d=%p ", (i+1), This);
+
+ while (This->Asl.Next)
+ {
+ This = This->Asl.Next;
+ }
+
+ /* Get another peer node */
+
+ Next = va_arg (ap, ACPI_PARSE_OBJECT *);
+ if (!Next)
+ {
+ Next = TrAllocateNode (PARSEOP_DEFAULT_ARG);
+ }
+
+ /* link new node to the current node */
+
+ This->Asl.Next = Next;
+ This = Next;
+ }
+
+ DbgPrint (ASL_PARSE_OUTPUT,"\n\n");
+ return (Start);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrLinkChildNode
+ *
+ * PARAMETERS: Op1 - Parent node
+ * Op2 - Op to become a child
+ *
+ * RETURN: The parent node
+ *
+ * DESCRIPTION: Link two nodes together as a parent and child
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+TrLinkChildNode (
+ ACPI_PARSE_OBJECT *Op1,
+ ACPI_PARSE_OBJECT *Op2)
+{
+ ACPI_PARSE_OBJECT *Next;
+
+
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nLinkChildNode: Parent=%p (%s), Child=%p (%s)\n\n",
+ Op1, Op1 ? UtGetOpName(Op1->Asl.ParseOpcode): NULL,
+ Op2, Op2 ? UtGetOpName(Op2->Asl.ParseOpcode): NULL);
+
+ if (!Op1 || !Op2)
+ {
+ return Op1;
+ }
+
+ Op1->Asl.Child = Op2;
+
+ /* Set the child and all peers of the child to point to the parent */
+
+ Next = Op2;
+ while (Next)
+ {
+ Next->Asl.Parent = Op1;
+ Next = Next->Asl.Next;
+ }
+
+ return Op1;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: TrWalkParseTree
+ *
+ * PARAMETERS: Visitation - Type of walk
+ * DescendingCallback - Called during tree descent
+ * AscendingCallback - Called during tree ascent
+ * Context - To be passed to the callbacks
+ *
+ * RETURN: Status from callback(s)
+ *
+ * DESCRIPTION: Walk the entire parse tree.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+TrWalkParseTree (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Visitation,
+ ASL_WALK_CALLBACK DescendingCallback,
+ ASL_WALK_CALLBACK AscendingCallback,
+ void *Context)
+{
+ UINT32 Level;
+ BOOLEAN NodePreviouslyVisited;
+ ACPI_PARSE_OBJECT *StartOp = Op;
+ ACPI_STATUS Status;
+
+
+ if (!RootNode)
+ {
+ return (AE_OK);
+ }
+
+ Level = 0;
+ NodePreviouslyVisited = FALSE;
+
+ switch (Visitation)
+ {
+ case ASL_WALK_VISIT_DOWNWARD:
+
+ while (Op)
+ {
+ if (!NodePreviouslyVisited)
+ {
+ /*
+ * Let the callback process the node.
+ */
+ Status = DescendingCallback (Op, Level, Context);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Visit children first, once */
+
+ if (Op->Asl.Child)
+ {
+ Level++;
+ Op = Op->Asl.Child;
+ continue;
+ }
+ }
+ else if (Status != AE_CTRL_DEPTH)
+ {
+ /* Exit immediately on any error */
+
+ return (Status);
+ }
+ }
+
+ /* Terminate walk at start op */
+
+ if (Op == StartOp)
+ {
+ break;
+ }
+
+ /* No more children, visit peers */
+
+ if (Op->Asl.Next)
+ {
+ Op = Op->Asl.Next;
+ NodePreviouslyVisited = FALSE;
+ }
+ else
+ {
+ /* No children or peers, re-visit parent */
+
+ if (Level != 0 )
+ {
+ Level--;
+ }
+ Op = Op->Asl.Parent;
+ NodePreviouslyVisited = TRUE;
+ }
+ }
+ break;
+
+
+ case ASL_WALK_VISIT_UPWARD:
+
+ while (Op)
+ {
+ /* Visit leaf node (no children) or parent node on return trip */
+
+ if ((!Op->Asl.Child) ||
+ (NodePreviouslyVisited))
+ {
+ /*
+ * Let the callback process the node.
+ *
+ */
+ Status = AscendingCallback (Op, Level, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else
+ {
+ /* Visit children first, once */
+
+ Level++;
+ Op = Op->Asl.Child;
+ continue;
+ }
+
+ /* Terminate walk at start op */
+
+ if (Op == StartOp)
+ {
+ break;
+ }
+
+ /* No more children, visit peers */
+
+ if (Op->Asl.Next)
+ {
+ Op = Op->Asl.Next;
+ NodePreviouslyVisited = FALSE;
+ }
+ else
+ {
+ /* No children or peers, re-visit parent */
+
+ if (Level != 0 )
+ {
+ Level--;
+ }
+ Op = Op->Asl.Parent;
+ NodePreviouslyVisited = TRUE;
+ }
+ }
+ break;
+
+
+ case ASL_WALK_VISIT_TWICE:
+
+ while (Op)
+ {
+ if (NodePreviouslyVisited)
+ {
+ Status = AscendingCallback (Op, Level, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else
+ {
+ /*
+ * Let the callback process the node.
+ */
+ Status = DescendingCallback (Op, Level, Context);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Visit children first, once */
+
+ if (Op->Asl.Child)
+ {
+ Level++;
+ Op = Op->Asl.Child;
+ continue;
+ }
+ }
+ else if (Status != AE_CTRL_DEPTH)
+ {
+ /* Exit immediately on any error */
+
+ return (Status);
+ }
+ }
+
+ /* Terminate walk at start op */
+
+ if (Op == StartOp)
+ {
+ break;
+ }
+
+ /* No more children, visit peers */
+
+ if (Op->Asl.Next)
+ {
+ Op = Op->Asl.Next;
+ NodePreviouslyVisited = FALSE;
+ }
+ else
+ {
+ /* No children or peers, re-visit parent */
+
+ if (Level != 0 )
+ {
+ Level--;
+ }
+ Op = Op->Asl.Parent;
+ NodePreviouslyVisited = TRUE;
+ }
+ }
+ break;
+
+ default:
+ /* No other types supported */
+ break;
+ }
+
+ /* If we get here, the walk completed with no errors */
+
+ return (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h
new file mode 100644
index 0000000..8881ba5
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/asltypes.h
@@ -0,0 +1,496 @@
+
+/******************************************************************************
+ *
+ * Module Name: asltypes.h - compiler data types and struct definitions
+ * $Revision: 59 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#ifndef __ASLTYPES_H
+#define __ASLTYPES_H
+
+
+#include <time.h>
+
+
+/*******************************************************************************
+ *
+ * Structure definitions
+ *
+ ******************************************************************************/
+
+
+/* Op flags for the ACPI_PARSE_OBJECT */
+
+#define NODE_VISITED 0x00000001
+#define NODE_AML_PACKAGE 0x00000002
+#define NODE_IS_TARGET 0x00000004
+#define NODE_IS_RESOURCE_DESC 0x00000008
+#define NODE_IS_RESOURCE_FIELD 0x00000010
+#define NODE_HAS_NO_EXIT 0x00000020
+#define NODE_IF_HAS_NO_EXIT 0x00000040
+#define NODE_NAME_INTERNALIZED 0x00000080
+#define NODE_METHOD_NO_RETVAL 0x00000100
+#define NODE_METHOD_SOME_NO_RETVAL 0x00000200
+#define NODE_RESULT_NOT_USED 0x00000400
+#define NODE_METHOD_TYPED 0x00000800
+#define NODE_IS_BIT_OFFSET 0x00001000
+#define NODE_COMPILE_TIME_CONST 0x00002000
+#define NODE_IS_TERM_ARG 0x00004000
+#define NODE_WAS_ONES_OP 0x00008000
+#define NODE_IS_NAME_DECLARATION 0x00010000
+
+/* Keeps information about individual control methods */
+
+typedef struct asl_method_info
+{
+ UINT8 NumArguments;
+ UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS];
+ UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS];
+ UINT32 NumReturnNoValue;
+ UINT32 NumReturnWithValue;
+ ACPI_PARSE_OBJECT *Op;
+ struct asl_method_info *Next;
+ UINT8 HasBeenTyped;
+
+} ASL_METHOD_INFO;
+
+
+/* Parse tree walk info for control method analysis */
+
+typedef struct asl_analysis_walk_info
+{
+ ASL_METHOD_INFO *MethodStack;
+
+} ASL_ANALYSIS_WALK_INFO;
+
+
+/* An entry in the ParseOpcode to AmlOpcode mapping table */
+
+typedef struct asl_mapping_entry
+{
+ UINT32 Value;
+ UINT32 AcpiBtype; /* Object type or return type */
+ UINT16 AmlOpcode;
+ UINT8 Flags;
+
+} ASL_MAPPING_ENTRY;
+
+
+/* An entry in the Reserved Name information table */
+
+#define ASL_RSVD_RETURN_VALUE 0x01
+#define ASL_RSVD_RESOURCE_NAME 0x02
+#define ASL_RSVD_SCOPE 0x04
+
+typedef struct asl_reserved_info
+{
+ char *Name;
+ UINT8 NumArguments;
+ UINT8 Flags;
+
+} ASL_RESERVED_INFO;
+
+
+/* Parse tree walk info structure */
+
+typedef struct asl_walk_info
+{
+ ACPI_PARSE_OBJECT **NodePtr;
+ UINT32 *LevelPtr;
+
+} ASL_WALK_INFO;
+
+
+/* File info */
+
+typedef struct asl_file_info
+{
+ FILE *Handle;
+ char *Filename;
+
+} ASL_FILE_INFO;
+
+
+/* File types */
+
+typedef enum
+{
+ ASL_FILE_STDOUT = 0,
+ ASL_FILE_STDERR,
+ ASL_FILE_INPUT,
+ ASL_FILE_AML_OUTPUT,
+ ASL_FILE_SOURCE_OUTPUT,
+ ASL_FILE_LISTING_OUTPUT,
+ ASL_FILE_HEX_OUTPUT,
+ ASL_FILE_NAMESPACE_OUTPUT,
+ ASL_FILE_DEBUG_OUTPUT,
+ ASL_FILE_ASM_SOURCE_OUTPUT,
+ ASL_FILE_C_SOURCE_OUTPUT,
+ ASL_FILE_ASM_INCLUDE_OUTPUT,
+ ASL_FILE_C_INCLUDE_OUTPUT
+
+} ASL_FILE_TYPES;
+
+
+#define ASL_MAX_FILE_TYPE 12
+#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1)
+
+
+/* An entry in the exception list, one for each error/warning */
+
+typedef struct asl_error_msg
+{
+ UINT32 LineNumber;
+ UINT32 LogicalLineNumber;
+ UINT32 LogicalByteOffset;
+ UINT32 Column;
+ char *Message;
+ struct asl_error_msg *Next;
+ char *Filename;
+ UINT32 FilenameLength;
+ UINT8 MessageId;
+ UINT8 Level;
+
+} ASL_ERROR_MSG;
+
+
+/* An entry in the listing file stack (for include files) */
+
+typedef struct asl_listing_node
+{
+ char *Filename;
+ UINT32 LineNumber;
+ struct asl_listing_node *Next;
+
+} ASL_LISTING_NODE;
+
+
+/* Callback interface for a parse tree walk */
+
+typedef
+ACPI_STATUS (*ASL_WALK_CALLBACK) (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context);
+
+
+typedef struct asl_event_info
+{
+ time_t StartTime;
+ time_t EndTime;
+ char *EventName;
+ BOOLEAN Valid;
+
+} ASL_EVENT_INFO;
+
+
+#define ASL_ERROR 0
+#define ASL_WARNING 1
+#define ASL_REMARK 2
+#define ASL_OPTIMIZATION 3
+#define ASL_NUM_REPORT_LEVELS 4
+
+
+typedef enum
+{
+ ASL_MSG_NULL = 0,
+ ASL_MSG_MEMORY_ALLOCATION,
+ ASL_MSG_INPUT_FILE_OPEN,
+ ASL_MSG_OUTPUT_FILENAME,
+ ASL_MSG_OUTPUT_FILE_OPEN,
+ ASL_MSG_LISTING_FILENAME,
+ ASL_MSG_LISTING_FILE_OPEN,
+ ASL_MSG_DEBUG_FILENAME,
+ ASL_MSG_DEBUG_FILE_OPEN,
+ ASL_MSG_INCLUDE_FILE_OPEN,
+ ASL_MSG_ENCODING_LENGTH,
+ ASL_MSG_INVALID_PRIORITY,
+ ASL_MSG_INVALID_PERFORMANCE,
+ ASL_MSG_LOCAL_INIT,
+ ASL_MSG_ARG_INIT,
+ ASL_MSG_UNSUPPORTED,
+ ASL_MSG_RESERVED_WORD,
+ ASL_MSG_BUFFER_LENGTH,
+ ASL_MSG_PACKAGE_LENGTH,
+ ASL_MSG_RETURN_TYPES,
+ ASL_MSG_NOT_FOUND,
+ ASL_MSG_NOT_REACHABLE,
+ ASL_MSG_NOT_EXIST,
+ ASL_MSG_NESTED_COMMENT,
+ ASL_MSG_RESERVED_ARG_COUNT_HI,
+ ASL_MSG_RESERVED_ARG_COUNT_LO,
+ ASL_MSG_RESERVED_RETURN_VALUE,
+ ASL_MSG_ARG_COUNT_HI,
+ ASL_MSG_ARG_COUNT_LO,
+ ASL_MSG_NO_RETVAL,
+ ASL_MSG_SOME_NO_RETVAL,
+ ASL_MSG_COMPILER_INTERNAL,
+ ASL_MSG_BACKWARDS_OFFSET,
+ ASL_MSG_UNKNOWN_RESERVED_NAME,
+ ASL_MSG_NAME_EXISTS,
+ ASL_MSG_INVALID_TYPE,
+ ASL_MSG_MULTIPLE_TYPES,
+ ASL_MSG_SYNTAX,
+ ASL_MSG_NOT_METHOD,
+ ASL_MSG_LONG_LINE,
+ ASL_MSG_RECURSION,
+ ASL_MSG_NOT_PARAMETER,
+ ASL_MSG_OPEN,
+ ASL_MSG_READ,
+ ASL_MSG_WRITE,
+ ASL_MSG_SEEK,
+ ASL_MSG_CLOSE,
+ ASL_MSG_FIELD_ACCESS_WIDTH,
+ ASL_MSG_REGION_BYTE_ACCESS,
+ ASL_MSG_REGION_BUFFER_ACCESS,
+ ASL_MSG_FIELD_UNIT_OFFSET,
+ ASL_MSG_FIELD_UNIT_ACCESS_WIDTH,
+ ASL_MSG_RESOURCE_FIELD,
+ ASL_MSG_BYTES_TO_BITS,
+ ASL_MSG_BITS_TO_BYTES,
+ ASL_MSG_AML_NOT_IMPLEMENTED,
+ ASL_MSG_NO_WHILE,
+ ASL_MSG_INVALID_ESCAPE,
+ ASL_MSG_INVALID_STRING,
+ ASL_MSG_TABLE_SIGNATURE,
+ ASL_MSG_RESOURCE_LIST,
+ ASL_MSG_INVALID_TARGET,
+ ASL_MSG_INVALID_CONSTANT_OP,
+ ASL_MSG_CONSTANT_EVALUATION,
+ ASL_MSG_CONSTANT_FOLDED,
+ ASL_MSG_INVALID_EISAID,
+ ASL_MSG_RESERVED_OPERAND_TYPE,
+ ASL_MSG_RESERVED_METHOD,
+ ASL_MSG_ALPHANUMERIC_STRING,
+ ASL_MSG_RESERVED_USE,
+ ASL_MSG_INVALID_OPERAND,
+ ASL_MSG_MISSING_ENDDEPENDENT,
+ ASL_MSG_MISSING_STARTDEPENDENT,
+ ASL_MSG_DEPENDENT_NESTING,
+ ASL_MSG_NAME_OPTIMIZATION,
+ ASL_MSG_SINGLE_NAME_OPTIMIZATION,
+ ASL_MSG_INTEGER_OPTIMIZATION,
+ ASL_MSG_SCOPE_TYPE,
+ ASL_MSG_CORE_EXCEPTION,
+ ASL_MSG_UNREACHABLE_CODE,
+ ASL_MSG_EARLY_EOF,
+ ASL_MSG_SCOPE_FWD_REF
+
+} ASL_MESSAGE_IDS;
+
+#ifdef ASL_EXCEPTIONS
+
+char *AslMessages [] = {
+/* ASL_MSG_NULL */ NULL,
+/* ASL_MSG_MEMORY_ALLOCATION, */ "Memory allocation failure",
+/* ASL_MSG_INPUT_FILE_OPEN, */ "Could not open input file",
+/* ASL_MSG_OUTPUT_FILENAME, */ "Could not create output filename",
+/* ASL_MSG_OUTPUT_FILE_OPEN, */ "Could not open output AML file",
+/* ASL_MSG_LISTING_FILENAME, */ "Could not create listing filename",
+/* ASL_MSG_LISTING_FILE_OPEN, */ "Could not open listing file",
+/* ASL_MSG_DEBUG_FILENAME, */ "Could not create debug filename",
+/* ASL_MSG_DEBUG_FILE_OPEN, */ "Could not open debug file",
+/* ASL_MSG_INCLUDE_FILE_OPEN, */ "Could not open include file",
+/* ASL_MSG_ENCODING_LENGTH, */ "Package length too long to encode",
+/* ASL_MSG_INVALID_PRIORITY, */ "Invalid priority value",
+/* ASL_MSG_INVALID_PERFORMANCE, */ "Invalid performance/robustness value",
+/* ASL_MSG_LOCAL_INIT, */ "Method local variable is not initialized",
+/* ASL_MSG_ARG_INIT, */ "Method argument is not initialized",
+/* ASL_MSG_UNSUPPORTED, */ "Unsupported feature",
+/* ASL_MSG_RESERVED_WORD, */ "Use of reserved word",
+/* ASL_MSG_BUFFER_LENGTH, */ "Effective AML buffer length is zero",
+/* ASL_MSG_PACKAGE_LENGTH, */ "Effective AML package length is zero",
+/* ASL_MSG_RETURN_TYPES, */ "Not all control paths return a value",
+/* ASL_MSG_NOT_FOUND, */ "Object not found or not accessible from scope",
+/* ASL_MSG_NOT_REACHABLE, */ "Object not accessible from this scope",
+/* ASL_MSG_NOT_EXIST, */ "Object does not exist",
+/* ASL_MSG_NESTED_COMMENT, */ "Nested comment found",
+/* ASL_MSG_RESERVED_ARG_COUNT_HI, */ "Reserved method has too many arguments",
+/* ASL_MSG_RESERVED_ARG_COUNT_LO, */ "Reserved method has too few arguments",
+/* ASL_MSG_RESERVED_RETURN_VALUE, */ "Reserved method must return a value",
+/* ASL_MSG_ARG_COUNT_HI, */ "Too many arguments",
+/* ASL_MSG_ARG_COUNT_LO, */ "Too few arguments",
+/* ASL_MSG_NO_RETVAL, */ "Called method returns no value",
+/* ASL_MSG_SOME_NO_RETVAL, */ "Called method may not always return a value",
+/* ASL_MSG_COMPILER_INTERNAL, */ "Internal compiler error",
+/* ASL_MSG_BACKWARDS_OFFSET, */ "Invalid backwards offset",
+/* ASL_MSG_UNKNOWN_RESERVED_NAME, */ "Unknown reserved name",
+/* ASL_MSG_NAME_EXISTS, */ "Name already exists in scope",
+/* ASL_MSG_INVALID_TYPE, */ "Invalid type",
+/* ASL_MSG_MULTIPLE_TYPES, */ "Multiple types",
+/* ASL_MSG_SYNTAX, */ "",
+/* ASL_MSG_NOT_METHOD, */ "Not a control method, cannot invoke",
+/* ASL_MSG_LONG_LINE, */ "Splitting long input line",
+/* ASL_MSG_RECURSION, */ "Recursive method call",
+/* ASL_MSG_NOT_PARAMETER, */ "Not a parameter, used as local only",
+/* ASL_MSG_OPEN, */ "Could not open file",
+/* ASL_MSG_READ, */ "Could not read file",
+/* ASL_MSG_WRITE, */ "Could not write file",
+/* ASL_MSG_SEEK, */ "Could not seek file",
+/* ASL_MSG_CLOSE, */ "Could not close file",
+/* ASL_MSG_FIELD_ACCESS_WIDTH, */ "Access width is greater than region size",
+/* ASL_MSG_REGION_BYTE_ACCESS, */ "Host Operation Region requires ByteAcc access",
+/* ASL_MSG_REGION_BUFFER_ACCESS, */ "Host Operation Region requires BufferAcc access",
+/* ASL_MSG_FIELD_UNIT_OFFSET, */ "Field Unit extends beyond region limit",
+/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, */ "Access width of Field Unit extends beyond region limit",
+/* ASL_MSG_RESOURCE_FIELD, */ "Resource field name cannot be used as a target",
+/* ASL_MSG_BYTES_TO_BITS, */ "Field offset is in bytes, but a bit offset is required",
+/* ASL_MSG_BITS_TO_BYTES, */ "Field offset is in bits, but a byte offset is required",
+/* ASL_MSG_AML_NOT_IMPLEMENTED, */ "Opcode is not implemented in compiler AML code generator",
+/* ASL_MSG_NO_WHILE, */ "No enclosing While statement",
+/* ASL_MSG_INVALID_ESCAPE, */ "Invalid or unknown escape sequence",
+/* ASL_MSG_INVALID_STRING, */ "Invalid Hex/Octal Escape - Non-ASCII or NULL",
+/* ASL_MSG_TABLE_SIGNATURE, */ "Invalid Table Signature",
+/* ASL_MSG_RESOURCE_LIST, */ "Too many resource items (internal error)",
+/* ASL_MSG_INVALID_TARGET, */ "Target operand not allowed in constant expression",
+/* ASL_MSG_INVALID_CONSTANT_OP, */ "Invalid operator in constant expression (not type 3/4/5)",
+/* ASL_MSG_CONSTANT_EVALUATION, */ "Could not evaluate constant expression",
+/* ASL_MSG_CONSTANT_FOLDED, */ "Constant expression evaluated and reduced",
+/* ASL_MSG_INVALID_EISAID, */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)",
+/* ASL_MSG_RESERVED_OPERAND_TYPE, */ "Invalid operand type for reserved name, must be",
+/* ASL_MSG_RESERVED_METHOD, */ "Reserved name must be a control method",
+/* ASL_MSG_ALPHANUMERIC_STRING, */ "String must be entirely alphanumeric",
+/* ASL_MSG_RESERVED_USE, */ "Invalid use of reserved name",
+/* ASL_MSG_INVALID_OPERAND, */ "Invalid operand",
+/* ASL_MSG_MISSING_ENDDEPENDENT, */ "Missing EndDependentFn() macro in dependent resource list",
+/* ASL_MSG_MISSING_STARTDEPENDENT, */ "Missing StartDependentFn() macro in dependent resource list",
+/* ASL_MSG_DEPENDENT_NESTING, */ "Dependent function macros cannot be nested",\
+/* ASL_MSG_NAME_OPTIMIZATION, */ "NamePath optimized",
+/* ASL_MSG_SINGLE_NAME_OPTIMIZATION, */ "NamePath optimized to NameSeg (uses run-time search path)",
+/* ASL_MSG_INTEGER_OPTIMIZATION, */ "Integer optimized to single-byte AML opcode",
+/* ASL_MSG_SCOPE_TYPE, */ "Existing object has invalid type for Scope operator",
+/* ASL_MSG_CORE_EXCEPTION, */ "From ACPI CA Subsystem",
+/* ASL_MSG_UNREACHABLE_CODE, */ "Statement is unreachable",
+/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached",
+/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope() not allowed"
+};
+
+
+char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = {
+ "Error ",
+ "Warning ",
+ "Remark ",
+ "Optimize"
+};
+
+#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */
+
+/* Exception counters */
+
+UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0};
+
+#endif
+
+
+#endif /* __ASLTYPES_H */
diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c
new file mode 100644
index 0000000..18d0ec8
--- /dev/null
+++ b/sys/contrib/dev/acpica/compiler/aslutils.c
@@ -0,0 +1,1015 @@
+
+/******************************************************************************
+ *
+ * Module Name: aslutils -- compiler utilities
+ * $Revision: 56 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "acnamesp.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("aslutils")
+
+#ifdef _USE_BERKELEY_YACC
+extern const char * const AslCompilername[];
+static const char * const *yytname = &AslCompilername[254];
+#else
+extern const char * const yytname[];
+#endif
+
+
+void
+AslOptimizeNamepath (
+ char *Buffer)
+{
+ printf ("NamePath: %s\n", Buffer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsDisplayConstantOpcodes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print AML opcodes that can be used in constant expressions.
+ *
+ ******************************************************************************/
+
+void
+UtDisplayConstantOpcodes (
+ void)
+{
+ UINT32 i;
+
+ printf ("Constant expression opcode information\n\n");
+
+ for (i = 0; i < sizeof (AcpiGbl_AmlOpInfo) / sizeof (ACPI_OPCODE_INFO); i++)
+ {
+ if (AcpiGbl_AmlOpInfo[i].Flags & AML_CONSTANT)
+ {
+ printf ("%s\n", AcpiGbl_AmlOpInfo[i].Name);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtLocalCalloc
+ *
+ * PARAMETERS: Size - Bytes to be allocated
+ *
+ * RETURN: Pointer to the allocated memory. Guaranteed to be valid.
+ *
+ * DESCRIPTION: Allocate zero-initialized memory. Aborts the compile on an
+ * allocation failure, on the assumption that nothing more can be
+ * accomplished.
+ *
+ ******************************************************************************/
+
+void *
+UtLocalCalloc (
+ UINT32 Size)
+{
+ void *Allocated;
+
+
+ Allocated = ACPI_MEM_CALLOCATE (Size);
+ if (!Allocated)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_InputByteCount, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
+ exit (1);
+ }
+
+ TotalAllocations++;
+ TotalAllocated += Size;
+ return Allocated;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtBeginEvent
+ *
+ * PARAMETERS: Event - Event number (integer index)
+ * Name - Ascii name of this event
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Saves the current time with this event
+ *
+ ******************************************************************************/
+
+void
+UtBeginEvent (
+ UINT32 Event,
+ char *Name)
+{
+
+ AslGbl_Events[Event].StartTime = (time_t) AcpiOsGetTimer();
+ AslGbl_Events[Event].EventName = Name;
+ AslGbl_Events[Event].Valid = TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtEndEvent
+ *
+ * PARAMETERS: Event - Event number (integer index)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Saves the current time (end time) with this event
+ *
+ ******************************************************************************/
+
+void
+UtEndEvent (
+ UINT32 Event)
+{
+
+ AslGbl_Events[Event].EndTime = (time_t) AcpiOsGetTimer();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtHexCharToValue
+ *
+ * PARAMETERS: hc - Hex character in Ascii
+ *
+ * RETURN: The binary value of the hex character
+ *
+ * DESCRIPTION: Perform ascii-to-hex translation
+ *
+ ******************************************************************************/
+
+UINT8
+UtHexCharToValue (
+ int hc)
+{
+
+ if (hc <= 0x39)
+ {
+ return ((UINT8) (hc - 0x30));
+ }
+
+ if (hc <= 0x46)
+ {
+ return ((UINT8) (hc - 0x37));
+ }
+
+ return ((UINT8) (hc - 0x57));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtConvertByteToHex
+ *
+ * PARAMETERS: RawByte - Binary data
+ * *Buffer - Pointer to where the hex bytes will be stored
+ *
+ * RETURN: Ascii hex byte is stored in Buffer.
+ *
+ * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed
+ * with "0x"
+ *
+ ******************************************************************************/
+
+void
+UtConvertByteToHex (
+ UINT8 RawByte,
+ UINT8 *Buffer)
+{
+
+ Buffer[0] = '0';
+ Buffer[1] = 'x';
+
+ Buffer[2] = (UINT8) hex[(RawByte >> 4) & 0xF];
+ Buffer[3] = (UINT8) hex[RawByte & 0xF];
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtConvertByteToAsmHex
+ *
+ * PARAMETERS: RawByte - Binary data
+ * *Buffer - Pointer to where the hex bytes will be stored
+ *
+ * RETURN: Ascii hex byte is stored in Buffer.
+ *
+ * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed
+ * with "0x"
+ *
+ ******************************************************************************/
+
+void
+UtConvertByteToAsmHex (
+ UINT8 RawByte,
+ UINT8 *Buffer)
+{
+
+ Buffer[0] = '0';
+
+ Buffer[1] = (UINT8) hex[(RawByte >> 4) & 0xF];
+ Buffer[2] = (UINT8) hex[RawByte & 0xF];
+ Buffer[3] = 'h';
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: DbgPrint
+ *
+ * PARAMETERS: Fmt - Printf format string
+ * ... - variable printf list
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Conditional print statement. Prints to stderr only if the
+ * debug flag is set.
+ *
+ ******************************************************************************/
+
+void
+DbgPrint (
+ UINT32 Type,
+ char *Fmt,
+ ...)
+{
+ va_list Args;
+
+
+ va_start (Args, Fmt);
+
+ if (!Gbl_DebugFlag)
+ {
+ return;
+ }
+
+ if ((Type == ASL_PARSE_OUTPUT) &&
+ (!(AslCompilerdebug)))
+ {
+ return;
+ }
+
+ (void) vfprintf (stderr, Fmt, Args);
+ va_end (Args);
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtPrintFormattedName
+ *
+ * PARAMETERS: ParseOpcode - Parser keyword ID
+ * Level - Indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print the ascii name of the parse opcode.
+ *
+ ******************************************************************************/
+
+#define TEXT_OFFSET 10
+
+void
+UtPrintFormattedName (
+ UINT16 ParseOpcode,
+ UINT32 Level)
+{
+
+ DbgPrint (ASL_TREE_OUTPUT,
+ "%*s %-16.16s", (3 * Level), " ",
+ UtGetOpName (ParseOpcode));
+
+ if (Level < TEXT_OFFSET)
+ {
+ DbgPrint (ASL_TREE_OUTPUT,
+ "%*s", (TEXT_OFFSET - Level) * 3, " ");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtSetParseOpName
+ *
+ * PARAMETERS: Op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Insert the ascii name of the parse opcode
+ *
+ ******************************************************************************/
+
+void
+UtSetParseOpName (
+ ACPI_PARSE_OBJECT *Op)
+{
+ strncpy (Op->Asl.ParseOpName, UtGetOpName (Op->Asl.ParseOpcode), 12);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtGetOpName
+ *
+ * PARAMETERS: ParseOpcode - Parser keyword ID
+ *
+ * RETURN: Pointer to the opcode name
+ *
+ * DESCRIPTION: Get the ascii name of the parse opcode
+ *
+ ******************************************************************************/
+
+char *
+UtGetOpName (
+ UINT32 ParseOpcode)
+{
+
+ /*
+ * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
+ * Ignore first 8 characters of the name
+ */
+ return ((char *) yytname [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtDisplaySummary
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display compilation statistics
+ *
+ ******************************************************************************/
+
+void
+UtDisplaySummary (
+ UINT32 FileId)
+{
+
+ if (FileId != ASL_FILE_STDOUT)
+ {
+ /* Compiler name and version number */
+
+ FlPrintFile (FileId, "%s version %X [%s]\n",
+ CompilerId, (UINT32) ACPI_CA_VERSION, __DATE__);
+ }
+
+ /* Input/Output summary */
+
+ FlPrintFile (FileId,
+ "ASL Input: %s - %d lines, %d bytes, %d keywords\n",
+ Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber,
+ Gbl_InputByteCount, TotalKeywords);
+
+ /* AML summary */
+
+ if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors))
+ {
+ FlPrintFile (FileId,
+ "AML Output: %s - %d bytes %d named objects %d executable opcodes\n\n",
+ Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
+ TotalNamedObjects, TotalExecutableOpcodes);
+ }
+
+ /* Error summary */
+
+ FlPrintFile (FileId,
+ "Compilation complete. %d Errors, %d Warnings, %d Remarks, %d Optimizations\n",
+ Gbl_ExceptionCount[ASL_ERROR],
+ Gbl_ExceptionCount[ASL_WARNING],
+ Gbl_ExceptionCount[ASL_REMARK],
+ Gbl_ExceptionCount[ASL_OPTIMIZATION]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtDisplaySummary
+ *
+ * PARAMETERS: Op - Integer parse node
+ * LowValue - Smallest allowed value
+ * HighValue - Largest allowed value
+ *
+ * RETURN: Op if OK, otherwise NULL
+ *
+ * DESCRIPTION: Check integer for an allowable range
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+UtCheckIntegerRange (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 LowValue,
+ UINT32 HighValue)
+{
+ char *ParseError = NULL;
+ char Buffer[64];
+
+
+ if (!Op)
+ {
+ return NULL;
+ }
+
+ if (Op->Asl.Value.Integer < LowValue)
+ {
+ ParseError = "Value below valid range";
+ Op->Asl.Value.Integer = LowValue;
+ }
+
+ if (Op->Asl.Value.Integer > HighValue)
+ {
+ ParseError = "Value above valid range";
+ Op->Asl.Value.Integer = HighValue;
+ }
+
+ if (ParseError)
+ {
+ sprintf (Buffer, "%s 0x%X-0x%X", ParseError, LowValue, HighValue);
+ AslCompilererror (Buffer);
+
+ return NULL;
+ }
+
+ return Op;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtGetStringBuffer
+ *
+ * PARAMETERS: Length - Size of buffer requested
+ *
+ * RETURN: Pointer to the buffer. Aborts on allocation failure
+ *
+ * DESCRIPTION: Allocate a string buffer. Bypass the local
+ * dynamic memory manager for performance reasons (This has a
+ * major impact on the speed of the compiler.)
+ *
+ ******************************************************************************/
+
+char *
+UtGetStringBuffer (
+ UINT32 Length)
+{
+ char *Buffer;
+
+
+ if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast)
+ {
+ Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length);
+ Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + Length;
+ }
+
+ Buffer = Gbl_StringCacheNext;
+ Gbl_StringCacheNext += Length;
+
+ return (Buffer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtInternalizeName
+ *
+ * PARAMETERS: ExternalName - Name to convert
+ * ConvertedName - Where the converted name is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an external (ASL) name to an internal (AML) name
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+UtInternalizeName (
+ char *ExternalName,
+ char **ConvertedName)
+{
+ ACPI_NAMESTRING_INFO Info;
+ ACPI_STATUS Status;
+
+
+ if (!ExternalName)
+ {
+ return (AE_OK);
+ }
+
+ /* Get the length of the new internal name */
+
+ Info.ExternalName = ExternalName;
+ AcpiNsGetInternalNameLength (&Info);
+
+ /* We need a segment to store the internal name */
+
+ Info.InternalName = UtGetStringBuffer (Info.Length);
+ if (!Info.InternalName)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Build the name */
+
+ Status = AcpiNsBuildInternalName (&Info);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ *ConvertedName = Info.InternalName;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtPadNameWithUnderscores
+ *
+ * PARAMETERS: NameSeg - Input nameseg
+ * PaddedNameSeg - Output padded nameseg
+ *
+ * RETURN: Padded nameseg.
+ *
+ * DESCRIPTION: Pads a NameSeg with underscores if necessary to form a full
+ * ACPI_NAME.
+ *
+ ******************************************************************************/
+
+void
+UtPadNameWithUnderscores (
+ char *NameSeg,
+ char *PaddedNameSeg)
+{
+ UINT32 i;
+
+
+ for (i = 0; (i < ACPI_NAME_SIZE); i++)
+ {
+ if (*NameSeg)
+ {
+ *PaddedNameSeg = *NameSeg;
+ NameSeg++;
+ }
+ else
+ {
+ *PaddedNameSeg = '_';
+ }
+ PaddedNameSeg++;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtAttachNameseg
+ *
+ * PARAMETERS: Op - Parent parse node
+ * Name - Full ExternalName
+ *
+ * RETURN: Sets the NameSeg field in parent node
+ *
+ * DESCRIPTION: Extract the last nameseg of the ExternalName and store it
+ * in the NameSeg field of the Op.
+ *
+ ******************************************************************************/
+
+void
+UtAttachNameseg (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name)
+{
+ char *NameSeg;
+ char PaddedNameSeg[4];
+
+
+ if (!Name)
+ {
+ return;
+ }
+
+ /* Look for the last dot in the namepath */
+
+ NameSeg = strrchr (Name, '.');
+ if (NameSeg)
+ {
+ /* Found last dot, we have also found the final nameseg */
+
+ NameSeg++;
+ UtPadNameWithUnderscores (NameSeg, PaddedNameSeg);
+ }
+ else
+ {
+ /* No dots in the namepath, there is only a single nameseg. */
+ /* Handle prefixes */
+
+ while ((*Name == '\\') || (*Name == '^'))
+ {
+ Name++;
+ }
+
+ /* Remaing string should be one single nameseg */
+
+ UtPadNameWithUnderscores (Name, PaddedNameSeg);
+ }
+
+ strncpy (Op->Asl.NameSeg, PaddedNameSeg, 4);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtAttachNamepathToOwner
+ *
+ * PARAMETERS: Op - Parent parse node
+ * NameOp - Node that contains the name
+ *
+ * RETURN: Sets the ExternalName and Namepath in the parent node
+ *
+ * DESCRIPTION: Store the name in two forms in the parent node: The original
+ * (external) name, and the internalized name that is used within
+ * the ACPI namespace manager.
+ *
+ ******************************************************************************/
+
+void
+UtAttachNamepathToOwner (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *NameOp)
+{
+ ACPI_STATUS Status;
+
+
+ /* Full external path */
+
+ Op->Asl.ExternalName = NameOp->Asl.Value.String;
+
+ /* Last nameseg of the path */
+
+ UtAttachNameseg (Op, Op->Asl.ExternalName);
+
+ /* Create internalized path */
+
+ Status = UtInternalizeName (NameOp->Asl.Value.String, &Op->Asl.Namepath);
+ if (ACPI_FAILURE (Status))
+ {
+ /* TBD: abort on no memory */
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtDoConstant
+ *
+ * PARAMETERS: String - Hex, Octal, or Decimal string
+ *
+ * RETURN: Converted Integer
+ *
+ * DESCRIPTION: Convert a string to an integer. With error checking.
+ *
+ ******************************************************************************/
+
+ACPI_INTEGER
+UtDoConstant (
+ char *String)
+{
+ ACPI_STATUS Status;
+ ACPI_INTEGER Converted;
+ char ErrBuf[64];
+
+
+ Status = UtStrtoul64 (String, 0, &Converted);
+ if (ACPI_FAILURE (Status))
+ {
+ sprintf (ErrBuf, "%s %s\n", "Conversion error:", AcpiFormatException (Status));
+ AslCompilererror (ErrBuf);
+ }
+
+ return (Converted);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtStrtoul64
+ *
+ * PARAMETERS: String - Null terminated string
+ * Terminater - Where a pointer to the terminating byte is returned
+ * Base - Radix of the string
+ *
+ * RETURN: Converted value
+ *
+ * DESCRIPTION: Convert a string into an unsigned value.
+ *
+ ******************************************************************************/
+#define NEGATIVE 1
+#define POSITIVE 0
+
+ACPI_STATUS
+UtStrtoul64 (
+ char *String,
+ UINT32 Base,
+ ACPI_INTEGER *RetInteger)
+{
+ UINT32 Index;
+ UINT32 Sign;
+ ACPI_INTEGER ReturnValue = 0;
+ ACPI_STATUS Status = AE_OK;
+
+
+ *RetInteger = 0;
+
+ switch (Base)
+ {
+ case 0:
+ case 8:
+ case 10:
+ case 16:
+ break;
+
+ default:
+ /*
+ * The specified Base parameter is not in the domain of
+ * this function:
+ */
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * skip over any white space in the buffer:
+ */
+ while (isspace (*String) || *String == '\t')
+ {
+ ++String;
+ }
+
+ /*
+ * The buffer may contain an optional plus or minus sign.
+ * If it does, then skip over it but remember what is was:
+ */
+ if (*String == '-')
+ {
+ Sign = NEGATIVE;
+ ++String;
+ }
+ else if (*String == '+')
+ {
+ ++String;
+ Sign = POSITIVE;
+ }
+ else
+ {
+ Sign = POSITIVE;
+ }
+
+ /*
+ * If the input parameter Base is zero, then we need to
+ * determine if it is octal, decimal, or hexadecimal:
+ */
+ if (Base == 0)
+ {
+ if (*String == '0')
+ {
+ if (tolower (*(++String)) == 'x')
+ {
+ Base = 16;
+ ++String;
+ }
+ else
+ {
+ Base = 8;
+ }
+ }
+ else
+ {
+ Base = 10;
+ }
+ }
+
+ /*
+ * For octal and hexadecimal bases, skip over the leading
+ * 0 or 0x, if they are present.
+ */
+ if (Base == 8 && *String == '0')
+ {
+ String++;
+ }
+
+ if (Base == 16 &&
+ *String == '0' &&
+ tolower (*(++String)) == 'x')
+ {
+ String++;
+ }
+
+ /* Main loop: convert the string to an unsigned long */
+
+ while (*String)
+ {
+ if (isdigit (*String))
+ {
+ Index = ((UINT8) *String) - '0';
+ }
+ else
+ {
+ Index = (UINT8) toupper (*String);
+ if (isupper ((char) Index))
+ {
+ Index = Index - 'A' + 10;
+ }
+ else
+ {
+ goto ErrorExit;
+ }
+ }
+
+ if (Index >= Base)
+ {
+ goto ErrorExit;
+ }
+
+ /* Check to see if value is out of range: */
+
+ if (ReturnValue > ((ACPI_INTEGER_MAX - (ACPI_INTEGER) Index) /
+ (ACPI_INTEGER) Base))
+ {
+ goto ErrorExit;
+ }
+ else
+ {
+ ReturnValue *= Base;
+ ReturnValue += Index;
+ }
+
+ ++String;
+ }
+
+
+ /*
+ * If a minus sign was present, then "the conversion is negated":
+ */
+ if (Sign == NEGATIVE)
+ {
+ ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1;
+ }
+
+ *RetInteger = ReturnValue;
+ return (Status);
+
+
+ErrorExit:
+ switch (Base)
+ {
+ case 8:
+ Status = AE_BAD_OCTAL_CONSTANT;
+ break;
+
+ case 10:
+ Status = AE_BAD_DECIMAL_CONSTANT;
+ break;
+
+ case 16:
+ Status = AE_BAD_HEX_CONSTANT;
+ break;
+
+ default:
+ /* Base validated above */
+ break;
+ }
+
+ return (Status);
+}
+
+
OpenPOWER on IntegriCloud