summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/Subsystem/Interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Interpreter')
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c433
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c1216
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c992
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c906
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c446
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c857
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c682
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c1183
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c551
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c580
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c561
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c693
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c629
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c629
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c531
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c713
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c442
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c463
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c652
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c190
20 files changed, 13349 insertions, 0 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c
new file mode 100644
index 0000000..835bc76
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c
@@ -0,0 +1,433 @@
+/******************************************************************************
+ *
+ * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes)
+ * $Revision: 24 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMCONFIG_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acevents.h"
+#include "actables.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amconfig")
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecLoadTable
+ *
+ * PARAMETERS: RgnDesc - Op region where the table will be obtained
+ * DdbHandle - Where a handle to the table will be returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load an ACPI table
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecLoadTable (
+ ACPI_OPERAND_OBJECT *RgnDesc,
+ ACPI_HANDLE *DdbHandle)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *TableDesc = NULL;
+ UINT8 *TablePtr;
+ UINT8 *TableDataPtr;
+ ACPI_TABLE_HEADER TableHeader;
+ ACPI_TABLE_DESC TableInfo;
+ UINT32 i;
+
+
+ FUNCTION_TRACE ("AmlExecLoadTable");
+
+ /* TBD: [Unhandled] Object can be either a field or an opregion */
+
+
+ /* Get the table header */
+
+ TableHeader.Length = 0;
+ for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++)
+ {
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ,
+ i, 8, (UINT32 *) ((UINT8 *) &TableHeader + i));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Allocate a buffer for the entire table */
+
+ TablePtr = AcpiCmAllocate (TableHeader.Length);
+ if (!TablePtr)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the header to the buffer */
+
+ MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER));
+ TableDataPtr = TablePtr + sizeof (ACPI_TABLE_HEADER);
+
+
+ /* Get the table from the op region */
+
+ for (i = 0; i < TableHeader.Length; i++)
+ {
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ,
+ i, 8, (UINT32 *) (TableDataPtr + i));
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ }
+
+
+ /* Table must be either an SSDT or a PSDT */
+
+ if ((!STRNCMP (TableHeader.Signature,
+ AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].Signature,
+ AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].SigLength)) &&
+ (!STRNCMP (TableHeader.Signature,
+ AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].Signature,
+ AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].SigLength)))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
+ TableHeader.Signature));
+ Status = AE_BAD_SIGNATURE;
+ goto Cleanup;
+ }
+
+ /* Create an object to be the table handle */
+
+ TableDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE);
+ if (!TableDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+
+ /* Install the new table into the local data structures */
+
+ TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr;
+ TableInfo.Length = TableHeader.Length;
+ TableInfo.Allocation = ACPI_MEM_ALLOCATED;
+ TableInfo.BasePointer = TablePtr;
+
+ Status = AcpiTbInstallTable (NULL, &TableInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Add the table to the namespace */
+
+ /* TBD: [Restructure] - change to whatever new interface is appropriate */
+/*
+ Status = AcpiLoadNamespace ();
+ if (ACPI_FAILURE (Status))
+ {
+*/
+ /* TBD: [Errors] Unload the table on failure ? */
+/*
+ goto Cleanup;
+ }
+*/
+
+
+ /* TBD: [Investigate] we need a pointer to the table desc */
+
+ /* Init the table handle */
+
+ TableDesc->Reference.OpCode = AML_LOAD_OP;
+ TableDesc->Reference.Object = TableInfo.InstalledDesc;
+
+ *DdbHandle = TableDesc;
+
+ return_ACPI_STATUS (Status);
+
+
+Cleanup:
+
+ AcpiCmFree (TableDesc);
+ AcpiCmFree (TablePtr);
+ return_ACPI_STATUS (Status);
+
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecUnloadTable
+ *
+ * PARAMETERS: DdbHandle - Handle to a previously loaded table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Unload an ACPI table
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecUnloadTable (
+ ACPI_HANDLE DdbHandle)
+{
+ ACPI_STATUS Status = AE_NOT_IMPLEMENTED;
+ ACPI_OPERAND_OBJECT *TableDesc = (ACPI_OPERAND_OBJECT *) DdbHandle;
+ ACPI_TABLE_DESC *TableInfo;
+
+
+ FUNCTION_TRACE ("AmlExecUnloadTable");
+
+
+ /* Validate the handle */
+ /* Although the handle is partially validated in AcpiAmlExecReconfiguration(),
+ * when it calls AcpiAmlResolveOperands(), the handle is more completely
+ * validated here.
+ */
+
+ if ((!DdbHandle) ||
+ (!VALID_DESCRIPTOR_TYPE (DdbHandle, ACPI_DESC_TYPE_INTERNAL)) ||
+ (((ACPI_OPERAND_OBJECT *)DdbHandle)->Common.Type !=
+ INTERNAL_TYPE_REFERENCE))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+
+ /* Get the actual table descriptor from the DdbHandle */
+
+ TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object;
+
+ /*
+ * Delete the entire namespace under this table Node
+ * (Offset contains the TableId)
+ */
+
+ Status = AcpiNsDeleteNamespaceByOwner (TableInfo->TableId);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Delete the table itself */
+
+ AcpiTbUninstallTable (TableInfo->InstalledDesc);
+
+ /* Delete the table descriptor (DdbHandle) */
+
+ AcpiCmRemoveReference (TableDesc);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecReconfiguration
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ * WalkState - Current state of the parse tree walk
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reconfiguration opcodes such as LOAD and UNLOAD
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecReconfiguration (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *RegionDesc = NULL;
+ ACPI_HANDLE *DdbHandle;
+
+
+ FUNCTION_TRACE ("AmlExecReconfiguration");
+
+
+ /* Resolve the operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode),
+ 2, "after AcpiAmlResolveOperands");
+
+ /* Get the table handle, common for both opcodes */
+
+ Status |= AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &DdbHandle,
+ WalkState);
+
+ switch (Opcode)
+ {
+
+ case AML_LOAD_OP:
+
+ /* Get the region or field descriptor */
+
+ Status |= AcpiDsObjStackPopObject (&RegionDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecReconfiguration/AML_LOAD_OP: bad operand(s) (0x%X)\n",
+ Status));
+
+ AcpiCmRemoveReference (RegionDesc);
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiAmlExecLoadTable (RegionDesc, DdbHandle);
+ break;
+
+
+ case AML_UNLOAD_OP:
+
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecReconfiguration/AML_UNLOAD_OP: bad operand(s) (0x%X)\n",
+ Status));
+
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiAmlExecUnloadTable (DdbHandle);
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR, ("AmlExecReconfiguration: bad opcode=%X\n",
+ Opcode));
+
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c
new file mode 100644
index 0000000..e1c93d9
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c
@@ -0,0 +1,1216 @@
+/******************************************************************************
+ *
+ * Module Name: amcreate - Named object creation
+ * $Revision: 48 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMCREATE_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acevents.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amcreate")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateField
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ * Operands - List of operands for the opcode
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute CreateField operators: CreateBitFieldOp,
+ * CreateByteFieldOp, CreateWordFieldOp, CreateDWordFieldOp,
+ * CreateFieldOp (which define fields in buffers)
+ *
+ * ALLOCATION: Deletes CreateFieldOp's count operand descriptor
+ *
+ *
+ * ACPI SPECIFICATION REFERENCES:
+ * DefCreateBitField := CreateBitFieldOp SrcBuf BitIdx NameString
+ * DefCreateByteField := CreateByteFieldOp SrcBuf ByteIdx NameString
+ * DefCreateDWordField := CreateDWordFieldOp SrcBuf ByteIdx NameString
+ * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString
+ * DefCreateWordField := CreateWordFieldOp SrcBuf ByteIdx NameString
+ * BitIndex := TermArg=>Integer
+ * ByteIndex := TermArg=>Integer
+ * NumBits := TermArg=>Integer
+ * SourceBuff := TermArg=>Buffer
+ *
+ ******************************************************************************/
+
+
+ACPI_STATUS
+AcpiAmlExecCreateField (
+ UINT8 *AmlPtr,
+ UINT32 AmlLength,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *TmpDesc;
+
+
+ FUNCTION_TRACE ("AmlExecCreateField");
+
+
+ /* Create the region descriptor */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Construct the field object */
+
+ ObjDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC;
+ ObjDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK;
+ ObjDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE;
+
+ /*
+ * Allocate a method object for this field unit
+ */
+
+ ObjDesc->FieldUnit.Extra = AcpiCmCreateInternalObject (
+ INTERNAL_TYPE_EXTRA);
+ if (!ObjDesc->FieldUnit.Extra)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Remember location in AML stream of the field unit
+ * opcode and operands -- since the buffer and index
+ * operands must be evaluated.
+ */
+
+ ObjDesc->FieldUnit.Extra->Extra.Pcode = AmlPtr;
+ ObjDesc->FieldUnit.Extra->Extra.PcodeLength = AmlLength;
+ ObjDesc->FieldUnit.Node = Node;
+
+
+/*
+ Status = AcpiNsAttachObject (Node, ObjDesc,
+ (UINT8) ACPI_TYPE_FIELD_UNIT);
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+*/
+
+ /*
+ * This operation is supposed to cause the destination Name to refer
+ * to the defined FieldUnit -- it must not store the constructed
+ * FieldUnit object (or its current value) in some location that the
+ * Name may already be pointing to. So, if the Name currently contains
+ * a reference which would cause AcpiAmlExecStore() to perform an indirect
+ * store rather than setting the value of the Name itself, clobber that
+ * reference before calling AcpiAmlExecStore().
+ */
+
+ /* Type of Name's existing value */
+
+ switch (AcpiNsGetType (Node))
+ {
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+ case INTERNAL_TYPE_ALIAS:
+ case INTERNAL_TYPE_BANK_FIELD:
+ case INTERNAL_TYPE_DEF_FIELD:
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ TmpDesc = AcpiNsGetAttachedObject (Node);
+ if (TmpDesc)
+ {
+ /*
+ * There is an existing object here; delete it and zero out the
+ * object field within the Node
+ */
+
+ DUMP_PATHNAME (Node,
+ "AmlExecCreateField: Removing Current Reference",
+ TRACE_BFIELD, _COMPONENT);
+
+ DUMP_ENTRY (Node, TRACE_BFIELD);
+ DUMP_STACK_ENTRY (TmpDesc);
+
+ AcpiCmRemoveReference (TmpDesc);
+ AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Node, NULL,
+ ACPI_TYPE_ANY);
+ }
+
+ /* Set the type to ANY (or the store below will fail) */
+
+ ((ACPI_NAMESPACE_NODE *) Node)->Type = ACPI_TYPE_ANY;
+
+ break;
+
+
+ default:
+
+ break;
+ }
+
+
+ /* Store constructed field descriptor in result location */
+
+ Status = AcpiAmlExecStore (ObjDesc, (ACPI_OPERAND_OBJECT *) Node, WalkState);
+
+ /*
+ * If the field descriptor was not physically stored (or if a failure
+ * above), we must delete it
+ */
+ if (ObjDesc->Common.ReferenceCount <= 1)
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ }
+
+
+ return_ACPI_STATUS (AE_OK);
+
+
+Cleanup:
+
+ /* Delete region object and method subobject */
+
+ if (ObjDesc)
+ {
+ /* Remove deletes both objects! */
+
+ AcpiCmRemoveReference (ObjDesc);
+ ObjDesc = NULL;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+ACPI_STATUS
+AcpiAmlExecCreateField_original (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ResDesc = NULL;
+ ACPI_OPERAND_OBJECT *CntDesc = NULL;
+ ACPI_OPERAND_OBJECT *OffDesc = NULL;
+ ACPI_OPERAND_OBJECT *SrcDesc = NULL;
+ ACPI_OPERAND_OBJECT *FieldDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ OBJECT_TYPE_INTERNAL ResType;
+ ACPI_STATUS Status;
+ UINT32 NumOperands = 3;
+ UINT32 Offset;
+ UINT32 BitOffset;
+ UINT16 BitCount;
+ UINT8 TypeFound;
+
+
+ FUNCTION_TRACE ("AmlExecCreateField");
+
+
+ /* Resolve the operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode),
+ NumOperands, "after AcpiAmlResolveOperands");
+
+
+ /* Get the operands */
+
+ Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState);
+ if (AML_CREATE_FIELD_OP == Opcode)
+ {
+ NumOperands = 4;
+ Status |= AcpiDsObjStackPopObject (&CntDesc, WalkState);
+ }
+
+ Status |= AcpiDsObjStackPopObject (&OffDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&SrcDesc, WalkState);
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecCreateField/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ Offset = (UINT32) OffDesc->Number.Value;
+
+
+ /*
+ * If ResDesc is a Name, it will be a direct name pointer after
+ * AcpiAmlResolveOperands()
+ */
+
+ if (!VALID_DESCRIPTOR_TYPE (ResDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecCreateField (%s): destination must be a Node\n",
+ AcpiPsGetOpcodeName (Opcode)));
+
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Setup the Bit offsets and counts, according to the opcode
+ */
+
+ switch (Opcode)
+ {
+
+ /* DefCreateBitField */
+
+ case AML_BIT_FIELD_OP:
+
+ /* Offset is in bits, Field is a bit */
+
+ BitOffset = Offset;
+ BitCount = 1;
+ break;
+
+
+ /* DefCreateByteField */
+
+ case AML_BYTE_FIELD_OP:
+
+ /* Offset is in bytes, field is a byte */
+
+ BitOffset = 8 * Offset;
+ BitCount = 8;
+ break;
+
+
+ /* DefCreateWordField */
+
+ case AML_WORD_FIELD_OP:
+
+ /* Offset is in bytes, field is a word */
+
+ BitOffset = 8 * Offset;
+ BitCount = 16;
+ break;
+
+
+ /* DefCreateDWordField */
+
+ case AML_DWORD_FIELD_OP:
+
+ /* Offset is in bytes, field is a dword */
+
+ BitOffset = 8 * Offset;
+ BitCount = 32;
+ break;
+
+
+ /* DefCreateField */
+
+ case AML_CREATE_FIELD_OP:
+
+ /* Offset is in bits, count is in bits */
+
+ BitOffset = Offset;
+ BitCount = (UINT16) CntDesc->Number.Value;
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecCreateField: Internal error - unknown field creation opcode %02x\n",
+ Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Setup field according to the object type
+ */
+
+ switch (SrcDesc->Common.Type)
+ {
+
+ /* SourceBuff := TermArg=>Buffer */
+
+ case ACPI_TYPE_BUFFER:
+
+ if (BitOffset + (UINT32) BitCount >
+ (8 * (UINT32) SrcDesc->Buffer.Length))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecCreateField: Field exceeds Buffer %d > %d\n",
+ BitOffset + (UINT32) BitCount,
+ 8 * (UINT32) SrcDesc->Buffer.Length));
+ Status = AE_AML_BUFFER_LIMIT;
+ goto Cleanup;
+ }
+
+
+ /* Allocate an object for the field */
+
+ FieldDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT);
+ if (!FieldDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Construct the field object */
+
+ FieldDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC;
+ FieldDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK;
+ FieldDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE;
+ FieldDesc->FieldUnit.Length = BitCount;
+ FieldDesc->FieldUnit.BitOffset = (UINT8) (BitOffset % 8);
+ FieldDesc->FieldUnit.Offset = DIV_8 (BitOffset);
+ FieldDesc->FieldUnit.Container = SrcDesc;
+
+ /* An additional reference for SrcDesc */
+
+ AcpiCmAddReference (SrcDesc);
+
+ break;
+
+
+ /* Improper object type */
+
+ default:
+
+ TypeFound = SrcDesc->Common.Type;
+
+ if ((TypeFound > (UINT8) INTERNAL_TYPE_REFERENCE) ||
+ !AcpiCmValidObjectType (TypeFound))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecCreateField: Tried to create field in invalid object type - 0x%X\n",
+ TypeFound));
+ }
+
+ else
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecCreateField: Tried to create field in improper object type - %s\n",
+ AcpiCmGetTypeName (TypeFound)));
+ }
+
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+
+ if (AML_CREATE_FIELD_OP == Opcode)
+ {
+ /* Delete object descriptor unique to CreateField */
+
+ AcpiCmRemoveReference (CntDesc);
+ CntDesc = NULL;
+ }
+
+ /*
+ * This operation is supposed to cause the destination Name to refer
+ * to the defined FieldUnit -- it must not store the constructed
+ * FieldUnit object (or its current value) in some location that the
+ * Name may already be pointing to. So, if the Name currently contains
+ * a reference which would cause AcpiAmlExecStore() to perform an indirect
+ * store rather than setting the value of the Name itself, clobber that
+ * reference before calling AcpiAmlExecStore().
+ */
+
+ ResType = AcpiNsGetType (ResDesc);
+
+ /* Type of Name's existing value */
+
+ switch (ResType)
+ {
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+ case INTERNAL_TYPE_ALIAS:
+ case INTERNAL_TYPE_BANK_FIELD:
+ case INTERNAL_TYPE_DEF_FIELD:
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ ObjDesc = AcpiNsGetAttachedObject (ResDesc);
+ if (ObjDesc)
+ {
+ /*
+ * There is an existing object here; delete it and zero out the
+ * object field within the Node
+ */
+
+ DUMP_PATHNAME (ResDesc,
+ "AmlExecCreateField: Removing Current Reference",
+ TRACE_BFIELD, _COMPONENT);
+
+ DUMP_ENTRY (ResDesc, TRACE_BFIELD);
+ DUMP_STACK_ENTRY (ObjDesc);
+
+ AcpiCmRemoveReference (ObjDesc);
+ AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) ResDesc, NULL,
+ ACPI_TYPE_ANY);
+ }
+
+ /* Set the type to ANY (or the store below will fail) */
+
+ ((ACPI_NAMESPACE_NODE *) ResDesc)->Type = ACPI_TYPE_ANY;
+
+ break;
+
+
+ default:
+
+ break;
+ }
+
+
+ /* Store constructed field descriptor in result location */
+
+ Status = AcpiAmlExecStore (FieldDesc, ResDesc, WalkState);
+
+ /*
+ * If the field descriptor was not physically stored (or if a failure
+ * above), we must delete it
+ */
+ if (FieldDesc->Common.ReferenceCount <= 1)
+ {
+ AcpiCmRemoveReference (FieldDesc);
+ }
+
+
+Cleanup:
+
+ /* Always delete the operands */
+
+ AcpiCmRemoveReference (OffDesc);
+ AcpiCmRemoveReference (SrcDesc);
+
+ if (AML_CREATE_FIELD_OP == Opcode)
+ {
+ AcpiCmRemoveReference (CntDesc);
+ }
+
+ /* On failure, delete the result descriptor */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ResDesc); /* Result descriptor */
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateAlias
+ *
+ * PARAMETERS: Operands - List of operands for the opcode
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new named alias
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreateAlias (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_NAMESPACE_NODE *SourceNode;
+ ACPI_NAMESPACE_NODE *AliasNode;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlExecCreateAlias");
+
+
+ /* Get the source/alias operands (both NTEs) */
+
+ Status = AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &SourceNode,
+ WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Don't pop it, it gets removed in the calling routine
+ */
+
+ AliasNode = AcpiDsObjStackGetValue (0, WalkState);
+
+ /* Add an additional reference to the object */
+
+ AcpiCmAddReference (SourceNode->Object);
+
+ /*
+ * Attach the original source Node to the new Alias Node.
+ */
+ Status = AcpiNsAttachObject (AliasNode, SourceNode->Object,
+ SourceNode->Type);
+
+
+ /*
+ * The new alias assumes the type of the source, but it points
+ * to the same object. The reference count of the object has two
+ * additional references to prevent deletion out from under either the
+ * source or the alias Node
+ */
+
+ /* Since both operands are NTEs, we don't need to delete them */
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateEvent
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new event object
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreateEvent (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ FUNCTION_TRACE ("AmlExecCreateEvent");
+
+
+ BREAKPOINT3;
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_EVENT);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Create the actual OS semaphore */
+
+ /* TBD: [Investigate] should be created with 0 or 1 units? */
+
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1,
+ &ObjDesc->Event.Semaphore);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ goto Cleanup;
+ }
+
+ /* Attach object to the Node */
+
+ Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState),
+ ObjDesc, (UINT8) ACPI_TYPE_EVENT);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore);
+ AcpiCmRemoveReference (ObjDesc);
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateMutex
+ *
+ * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec)
+ * Operands - List of operands for the opcode
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new mutex object
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreateMutex (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *SyncDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecCreateMutex", WALK_OPERANDS);
+
+
+ /* Get the operand */
+
+ Status = AcpiDsObjStackPopObject (&SyncDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Attempt to allocate a new object */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_MUTEX);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Create the actual OS semaphore */
+
+ Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ goto Cleanup;
+ }
+
+ ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Number.Value;
+
+ /* ObjDesc was on the stack top, and the name is below it */
+
+ Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState),
+ ObjDesc, (UINT8) ACPI_TYPE_MUTEX);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore);
+ AcpiCmRemoveReference (ObjDesc);
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ /* Always delete the operand */
+
+ AcpiCmRemoveReference (SyncDesc);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateRegion
+ *
+ * PARAMETERS: AmlPtr - Pointer to the region declaration AML
+ * AmlLength - Max length of the declaration AML
+ * Operands - List of operands for the opcode
+ * InterpreterMode - Load1/Load2/Execute
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new operation region object
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreateRegion (
+ UINT8 *AmlPtr,
+ UINT32 AmlLength,
+ UINT32 RegionSpace,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ FUNCTION_TRACE ("AmlExecCreateRegion");
+
+
+ if (RegionSpace >= NUM_REGION_TYPES)
+ {
+ /* TBD: [Future] In ACPI 2.0, valid region space
+ * includes types 0-6 (Adding CMOS and PCIBARTarget).
+ * Also, types 0x80-0xff are defined as "OEM Region
+ * Space handler"
+ *
+ * Should this return an error, or should we just keep
+ * going? How do we handle the OEM region handlers?
+ */
+ REPORT_WARNING (("Invalid AddressSpace type %X\n", RegionSpace));
+ }
+
+ DEBUG_PRINT (TRACE_LOAD, ("AmlDoNode: Region Type [%s]\n",
+ AcpiGbl_RegionTypes[RegionSpace]));
+
+
+ /* Get the Node from the object stack */
+
+ Node = (ACPI_NAMESPACE_NODE *) AcpiDsObjStackGetValue (0, WalkState);
+
+ /* Create the region descriptor */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_REGION);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Allocate a method object for this region.
+ */
+
+ ObjDesc->Region.Extra = AcpiCmCreateInternalObject (
+ INTERNAL_TYPE_EXTRA);
+ if (!ObjDesc->Region.Extra)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Remember location in AML stream of address & length
+ * operands since they need to be evaluated at run time.
+ */
+
+ ObjDesc->Region.Extra->Extra.Pcode = AmlPtr;
+ ObjDesc->Region.Extra->Extra.PcodeLength = AmlLength;
+
+ /* Init the region from the operands */
+
+ ObjDesc->Region.SpaceId = (UINT8) RegionSpace;
+ ObjDesc->Region.Address = 0;
+ ObjDesc->Region.Length = 0;
+
+
+ /* Install the new region object in the parent Node */
+
+ ObjDesc->Region.Node = Node;
+
+ Status = AcpiNsAttachObject (Node, ObjDesc,
+ (UINT8) ACPI_TYPE_REGION);
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * If we have a valid region, initialize it
+ * Namespace is NOT locked at this point.
+ */
+
+ Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
+
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * If AE_NOT_EXIST is returned, it is not fatal
+ * because many regions get created before a handler
+ * is installed for said region.
+ */
+ if (AE_NOT_EXIST == Status)
+ {
+ Status = AE_OK;
+ }
+ }
+
+Cleanup:
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Delete region object and method subobject */
+
+ if (ObjDesc)
+ {
+ /* Remove deletes both objects! */
+
+ AcpiCmRemoveReference (ObjDesc);
+ ObjDesc = NULL;
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateProcessor
+ *
+ * PARAMETERS: Op - Op containing the Processor definition and
+ * args
+ * ProcessorNTE - Node for the containing Node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new processor object and populate the fields
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreateProcessor (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_HANDLE ProcessorNTE)
+{
+ ACPI_STATUS Status;
+ ACPI_PARSE_OBJECT *Arg;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecCreateProcessor", Op);
+
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PROCESSOR);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Install the new processor object in the parent Node */
+
+ Status = AcpiNsAttachObject (ProcessorNTE, ObjDesc,
+ (UINT8) ACPI_TYPE_PROCESSOR);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS(Status);
+ }
+
+ Arg = Op->Value.Arg;
+
+ /* check existence */
+
+ if (!Arg)
+ {
+ Status = AE_AML_NO_OPERAND;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* First arg is the Processor ID */
+
+ ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer;
+
+ /* Move to next arg and check existence */
+
+ Arg = Arg->Next;
+ if (!Arg)
+ {
+ Status = AE_AML_NO_OPERAND;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Second arg is the PBlock Address */
+
+ ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Arg->Value.Integer;
+
+ /* Move to next arg and check existence */
+
+ Arg = Arg->Next;
+ if (!Arg)
+ {
+ Status = AE_AML_NO_OPERAND;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Third arg is the PBlock Length */
+
+ ObjDesc->Processor.Length = (UINT8) Arg->Value.Integer;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreatePowerResource
+ *
+ * PARAMETERS: Op - Op containing the PowerResource definition
+ * and args
+ * PowerResNTE - Node for the containing Node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new PowerResource object and populate the fields
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreatePowerResource (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_HANDLE PowerResNTE)
+{
+ ACPI_STATUS Status;
+ ACPI_PARSE_OBJECT *Arg;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecCreatePowerResource", Op);
+
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_POWER);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Install the new power resource object in the parent Node */
+
+ Status = AcpiNsAttachObject (PowerResNTE, ObjDesc,
+ (UINT8) ACPI_TYPE_POWER);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS(Status);
+ }
+
+ Arg = Op->Value.Arg;
+
+ /* check existence */
+
+ if (!Arg)
+ {
+ Status = AE_AML_NO_OPERAND;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* First arg is the SystemLevel */
+
+ ObjDesc->PowerResource.SystemLevel = (UINT8) Arg->Value.Integer;
+
+ /* Move to next arg and check existence */
+
+ Arg = Arg->Next;
+ if (!Arg)
+ {
+ Status = AE_AML_NO_OPERAND;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Second arg is the PBlock Address */
+
+ ObjDesc->PowerResource.ResourceOrder = (UINT16) Arg->Value.Integer;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecCreateMethod
+ *
+ * PARAMETERS: AmlPtr - First byte of the method's AML
+ * AmlLength - AML byte count for this method
+ * MethodFlags - AML method flag byte
+ * Method - Method Node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new method object
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecCreateMethod (
+ UINT8 *AmlPtr,
+ UINT32 AmlLength,
+ UINT32 MethodFlags,
+ ACPI_HANDLE Method)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecCreateMethod", Method);
+
+
+ /* Create a new method object */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_METHOD);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Get the method's AML pointer/length from the Op */
+
+ ObjDesc->Method.Pcode = AmlPtr;
+ ObjDesc->Method.PcodeLength = AmlLength;
+
+ /*
+ * First argument is the Method Flags (contains parameter count for the
+ * method)
+ */
+
+ ObjDesc->Method.MethodFlags = (UINT8) MethodFlags;
+ ObjDesc->Method.ParamCount = (UINT8) (MethodFlags &
+ METHOD_FLAGS_ARG_COUNT);
+
+ /*
+ * Get the concurrency count. If required, a semaphore will be
+ * created for this method when it is parsed.
+ *
+ * TBD: [Future] for APCI 2.0, there will be a SyncLevel value, not
+ * just a flag
+ * Concurrency = SyncLevel + 1;.
+ */
+
+ if (MethodFlags & METHOD_FLAGS_SERIALIZED)
+ {
+ ObjDesc->Method.Concurrency = 1;
+ }
+
+ else
+ {
+ ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY;
+ }
+
+ /* Attach the new object to the method Node */
+
+ Status = AcpiNsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_METHOD);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmDeleteObjectDesc (ObjDesc);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c
new file mode 100644
index 0000000..a3662d7
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c
@@ -0,0 +1,992 @@
+/******************************************************************************
+ *
+ * Module Name: amdump - Interpreter debug output routines
+ * $Revision: 94 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMDUMP_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "actables.h"
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amdump")
+
+
+/*
+ * The following routines are used for debug output only
+ */
+
+#ifdef ACPI_DEBUG
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlShowHexValue
+ *
+ * PARAMETERS: ByteCount - Number of bytes to print (1, 2, or 4)
+ * *AmlPtr - Address in AML stream of bytes to print
+ * InterpreterMode - Current running mode (load1/Load2/Exec)
+ * LeadSpace - # of spaces to print ahead of value
+ * 0 => none ahead but one behind
+ *
+ * DESCRIPTION: Print ByteCount byte(s) starting at AcpiAmlPtr as a single
+ * value, in hex. If ByteCount > 1 or the value printed is > 9, also
+ * print in decimal.
+ *
+ ****************************************************************************/
+
+void
+AcpiAmlShowHexValue (
+ UINT32 ByteCount,
+ UINT8 *AmlPtr,
+ UINT32 LeadSpace)
+{
+ UINT32 Value; /* Value retrieved from AML stream */
+ UINT32 ShowDecimalValue;
+ UINT32 Length; /* Length of printed field */
+ UINT8 *CurrentAmlPtr = NULL; /* Pointer to current byte of AML value */
+
+
+ FUNCTION_TRACE ("AmlShowHexValue");
+
+
+ if (!AmlPtr)
+ {
+ REPORT_ERROR (("AmlShowHexValue: null pointer\n"));
+ }
+
+ /*
+ * AML numbers are always stored little-endian,
+ * even if the processor is big-endian.
+ */
+ for (CurrentAmlPtr = AmlPtr + ByteCount,
+ Value = 0;
+ CurrentAmlPtr > AmlPtr; )
+ {
+ Value = (Value << 8) + (UINT32)* --CurrentAmlPtr;
+ }
+
+ Length = LeadSpace * ByteCount + 2;
+ if (ByteCount > 1)
+ {
+ Length += (ByteCount - 1);
+ }
+
+ ShowDecimalValue = (ByteCount > 1 || Value > 9);
+ if (ShowDecimalValue)
+ {
+ Length += 3 + AcpiAmlDigitsNeeded (Value, 10);
+ }
+
+ DEBUG_PRINT (TRACE_LOAD, (""));
+
+ for (Length = LeadSpace; Length; --Length )
+ {
+ DEBUG_PRINT_RAW (TRACE_LOAD, (" "));
+ }
+
+ while (ByteCount--)
+ {
+ DEBUG_PRINT_RAW (TRACE_LOAD, ("%02x", *AmlPtr++));
+
+ if (ByteCount)
+ {
+ DEBUG_PRINT_RAW (TRACE_LOAD, (" "));
+ }
+ }
+
+ if (ShowDecimalValue)
+ {
+ DEBUG_PRINT_RAW (TRACE_LOAD, (" [%ld]", Value));
+ }
+
+ if (0 == LeadSpace)
+ {
+ DEBUG_PRINT_RAW (TRACE_LOAD, (" "));
+ }
+
+ DEBUG_PRINT_RAW (TRACE_LOAD, ("\n"));
+ return_VOID;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlDumpOperand
+ *
+ * PARAMETERS: *EntryDesc - Pointer to entry to be dumped
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Dump a stack entry
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlDumpOperand (
+ ACPI_OPERAND_OBJECT *EntryDesc)
+{
+ UINT8 *Buf = NULL;
+ UINT32 Length;
+ UINT32 i;
+
+
+ if (!EntryDesc)
+ {
+ /*
+ * This usually indicates that something serious is wrong --
+ * since most (if not all)
+ * code that dumps the stack expects something to be there!
+ */
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlDumpOperand: *** Possible error: Null stack entry ptr\n"));
+ return (AE_OK);
+ }
+
+ if (VALID_DESCRIPTOR_TYPE (EntryDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlDumpOperand: Node: \n"));
+ DUMP_ENTRY (EntryDesc, ACPI_INFO);
+ return (AE_OK);
+ }
+
+ if (AcpiTbSystemTablePointer (EntryDesc))
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlDumpOperand: %p is a Pcode pointer\n",
+ EntryDesc));
+ return (AE_OK);
+ }
+
+ if (!VALID_DESCRIPTOR_TYPE (EntryDesc, ACPI_DESC_TYPE_INTERNAL))
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlDumpOperand: %p Not a local object \n", EntryDesc));
+ DUMP_BUFFER (EntryDesc, sizeof (ACPI_OPERAND_OBJECT));
+ return (AE_OK);
+ }
+
+ /* EntryDesc is a valid object */
+
+ DEBUG_PRINT (ACPI_INFO, ("AmlDumpOperand: %p ", EntryDesc));
+
+ switch (EntryDesc->Common.Type)
+ {
+ case INTERNAL_TYPE_REFERENCE:
+
+ switch (EntryDesc->Reference.OpCode)
+ {
+ case AML_ZERO_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Zero\n"));
+ break;
+
+
+ case AML_ONE_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: One\n"));
+ break;
+
+
+ case AML_ONES_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Ones\n"));
+ break;
+
+
+ case AML_DEBUG_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Debug\n"));
+ break;
+
+
+ case AML_NAME_OP:
+
+ DUMP_PATHNAME (EntryDesc->Reference.Object, "Reference: Name: ",
+ ACPI_INFO, _COMPONENT);
+ DUMP_ENTRY (EntryDesc->Reference.Object, ACPI_INFO);
+ break;
+
+
+ case AML_INDEX_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Index %p\n",
+ EntryDesc->Reference.Object));
+ break;
+
+
+ case AML_ARG_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Arg%d",
+ EntryDesc->Reference.Offset));
+
+ if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type)
+ {
+ /* Value is a Number */
+
+ DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]",
+ EntryDesc->Number.Value));
+ }
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("\n"));
+ break;
+
+
+ case AML_LOCAL_OP:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Local%d",
+ EntryDesc->Reference.Offset));
+
+ if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type)
+ {
+
+ /* Value is a Number */
+
+ DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]",
+ EntryDesc->Number.Value));
+ }
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("\n"));
+ break;
+
+
+ case AML_NAMEPATH_OP:
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Reference.Node->Name %x\n",
+ EntryDesc->Reference.Node->Name));
+ break;
+
+ default:
+
+ /* unknown opcode */
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Unknown opcode=%X\n",
+ EntryDesc->Reference.OpCode));
+ break;
+
+ }
+
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Buffer[%d] seq %lx @ %p \n",
+ EntryDesc->Buffer.Length, EntryDesc->Buffer.Sequence,
+ EntryDesc->Buffer.Pointer));
+
+ Length = EntryDesc->Buffer.Length;
+
+ if (Length > 64)
+ {
+ Length = 64;
+ }
+
+ /* Debug only -- dump the buffer contents */
+
+ if (EntryDesc->Buffer.Pointer)
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Buffer Contents: "));
+
+ for (Buf = EntryDesc->Buffer.Pointer; Length--; ++Buf)
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO,
+ (Length ? " %02x" : " %02x", *Buf));
+ }
+ DEBUG_PRINT_RAW (ACPI_INFO,("\n"));
+ }
+
+ break;
+
+
+ case ACPI_TYPE_NUMBER:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Number 0x%lx\n",
+ EntryDesc->Number.Value));
+ break;
+
+
+ case INTERNAL_TYPE_IF:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("If [Number] 0x%lx\n",
+ EntryDesc->Number.Value));
+ break;
+
+
+ case INTERNAL_TYPE_WHILE:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("While [Number] 0x%lx\n",
+ EntryDesc->Number.Value));
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Package[%d] @ %p\n",
+ EntryDesc->Package.Count, EntryDesc->Package.Elements));
+
+
+ /*
+ * If elements exist, package vector pointer is valid,
+ * and debug_level exceeds 1, dump package's elements.
+ */
+ if (EntryDesc->Package.Count &&
+ EntryDesc->Package.Elements &&
+ GetDebugLevel () > 1)
+ {
+ ACPI_OPERAND_OBJECT**Element;
+ UINT16 ElementIndex;
+
+ for (ElementIndex = 0, Element = EntryDesc->Package.Elements;
+ ElementIndex < EntryDesc->Package.Count;
+ ++ElementIndex, ++Element)
+ {
+ AcpiAmlDumpOperand (*Element);
+ }
+ }
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("\n"));
+
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ if (EntryDesc->Region.SpaceId >= NUM_REGION_TYPES)
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Region **** Unknown ID=0x%X",
+ EntryDesc->Region.SpaceId));
+ }
+ else
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Region %s",
+ AcpiGbl_RegionTypes[EntryDesc->Region.SpaceId]));
+ }
+
+ /*
+ * If the address and length have not been evaluated,
+ * don't print them.
+ */
+ if (!(EntryDesc->Region.Flags & AOPOBJ_DATA_VALID))
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, ("\n"));
+ }
+ else
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, (" base %p Length 0x%X\n",
+ EntryDesc->Region.Address, EntryDesc->Region.Length));
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("String[%d] @ %p\n\n",
+ EntryDesc->String.Length, EntryDesc->String.Pointer));
+
+ for (i=0; i < EntryDesc->String.Length; i++)
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, ("%c",
+ EntryDesc->String.Pointer[i]));
+ }
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("\n\n"));
+ break;
+
+
+ case INTERNAL_TYPE_BANK_FIELD:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("BankField\n"));
+ break;
+
+
+ case INTERNAL_TYPE_DEF_FIELD:
+
+ DEBUG_PRINT_RAW (ACPI_INFO,
+ ("DefField: bits=%d acc=%d lock=%d update=%d at byte=%lx bit=%d of below:\n",
+ EntryDesc->Field.Length, EntryDesc->Field.Access,
+ EntryDesc->Field.LockRule, EntryDesc->Field.UpdateRule,
+ EntryDesc->Field.Offset, EntryDesc->Field.BitOffset));
+ DUMP_STACK_ENTRY (EntryDesc->Field.Container);
+ break;
+
+
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("IndexField\n"));
+ break;
+
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+ DEBUG_PRINT_RAW (ACPI_INFO,
+ ("FieldUnit: %d bits acc %d lock %d update %d at byte %lx bit %d of \n",
+ EntryDesc->FieldUnit.Length, EntryDesc->FieldUnit.Access,
+ EntryDesc->FieldUnit.LockRule, EntryDesc->FieldUnit.UpdateRule,
+ EntryDesc->FieldUnit.Offset, EntryDesc->FieldUnit.BitOffset));
+
+ if (!EntryDesc->FieldUnit.Container)
+ {
+ DEBUG_PRINT (ACPI_INFO, ("*NULL* \n"));
+ }
+
+ else if (ACPI_TYPE_BUFFER !=
+ EntryDesc->FieldUnit.Container->Common.Type)
+ {
+ DEBUG_PRINT_RAW (ACPI_INFO, ("*not a Buffer* \n"));
+ }
+
+ else
+ {
+ DUMP_STACK_ENTRY (EntryDesc->FieldUnit.Container);
+ }
+
+ break;
+
+
+ case ACPI_TYPE_EVENT:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Event\n"));
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ DEBUG_PRINT_RAW (ACPI_INFO,
+ ("Method(%d) @ %p:%lx\n",
+ EntryDesc->Method.ParamCount,
+ EntryDesc->Method.Pcode, EntryDesc->Method.PcodeLength));
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Mutex\n"));
+ break;
+
+
+ case ACPI_TYPE_DEVICE:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Device\n"));
+ break;
+
+
+ case ACPI_TYPE_POWER:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Power\n"));
+ break;
+
+
+ case ACPI_TYPE_PROCESSOR:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Processor\n"));
+ break;
+
+
+ case ACPI_TYPE_THERMAL:
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Thermal\n"));
+ break;
+
+
+ default:
+ /* unknown EntryDesc->Common.Type value */
+
+ DEBUG_PRINT_RAW (ACPI_INFO, ("Unknown Type 0x%X\n",
+ EntryDesc->Common.Type));
+
+ /* Back up to previous entry */
+
+ EntryDesc--;
+
+
+ /* TBD: [Restructure] Change to use dump object routine !! */
+ /* What is all of this?? */
+
+ DUMP_BUFFER (EntryDesc, sizeof (ACPI_OPERAND_OBJECT));
+ DUMP_BUFFER (++EntryDesc, sizeof (ACPI_OPERAND_OBJECT));
+ DUMP_BUFFER (++EntryDesc, sizeof (ACPI_OPERAND_OBJECT));
+ break;
+
+ }
+
+ return (AE_OK);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlDumpOperands
+ *
+ * PARAMETERS: InterpreterMode - Load or Exec
+ * *Ident - Identification
+ * NumLevels - # of stack entries to dump above line
+ * *Note - Output notation
+ *
+ * DESCRIPTION: Dump the object stack
+ *
+ ****************************************************************************/
+
+void
+AcpiAmlDumpOperands (
+ ACPI_OPERAND_OBJECT **Operands,
+ OPERATING_MODE InterpreterMode,
+ NATIVE_CHAR *Ident,
+ UINT32 NumLevels,
+ NATIVE_CHAR *Note,
+ NATIVE_CHAR *ModuleName,
+ UINT32 LineNumber)
+{
+ NATIVE_UINT i;
+ ACPI_OPERAND_OBJECT **EntryDesc;
+
+
+ if (!Ident)
+ {
+ Ident = "?";
+ }
+
+ if (!Note)
+ {
+ Note = "?";
+ }
+
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("************* AcpiAmlDumpOperands Mode=%X ******************\n",
+ InterpreterMode));
+ DEBUG_PRINT (ACPI_INFO,
+ ("From %12s(%d) %s: %s\n", ModuleName, LineNumber, Ident, Note));
+
+ if (NumLevels == 0)
+ NumLevels = 1;
+
+ /* Dump the stack starting at the top, working down */
+
+ for (i = 0; NumLevels > 0; i--, NumLevels--)
+ {
+ EntryDesc = &Operands[i];
+
+ if (ACPI_FAILURE (AcpiAmlDumpOperand (*EntryDesc)))
+ {
+ break;
+ }
+ }
+
+ return;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlDumpNode
+ *
+ * PARAMETERS: *Node - Descriptor to dump
+ * Flags - Force display
+ *
+ * DESCRIPTION: Dumps the members of the given.Node
+ *
+ ****************************************************************************/
+
+void
+AcpiAmlDumpNode (
+ ACPI_NAMESPACE_NODE *Node,
+ UINT32 Flags)
+{
+
+ if (!Flags)
+ {
+ if (!((TRACE_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return;
+ }
+ }
+
+
+ AcpiOsPrintf ("%20s : %4.4s\n", "Name", &Node->Name);
+ AcpiOsPrintf ("%20s : %s\n", "Type", AcpiCmGetTypeName (Node->Type));
+ AcpiOsPrintf ("%20s : 0x%X\n", "Flags", Node->Flags);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Owner Id", Node->OwnerId);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Reference Count", Node->ReferenceCount);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Attached Object", Node->Object);
+ AcpiOsPrintf ("%20s : 0x%p\n", "ChildList", Node->Child);
+ AcpiOsPrintf ("%20s : 0x%p\n", "NextPeer", Node->Peer);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Parent", AcpiNsGetParentObject (Node));
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlDumpObjectDescriptor
+ *
+ * PARAMETERS: *Object - Descriptor to dump
+ * Flags - Force display
+ *
+ * DESCRIPTION: Dumps the members of the object descriptor given.
+ *
+ ****************************************************************************/
+
+void
+AcpiAmlDumpObjectDescriptor (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Flags)
+{
+ FUNCTION_TRACE ("AmlDumpObjectDescriptor");
+
+
+ if (!Flags)
+ {
+ if (!((TRACE_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return;
+ }
+ }
+
+ if (!(VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)))
+ {
+ AcpiOsPrintf ("0x%p is not a valid ACPI object\n", ObjDesc);
+ return;
+ }
+
+ /* Common Fields */
+
+ AcpiOsPrintf ("%20s : 0x%X\n", "Reference Count", ObjDesc->Common.ReferenceCount);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Flags", ObjDesc->Common.Flags);
+
+ /* Object-specific Fields */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_NUMBER:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Number");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->Number.Value);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "String");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->String.Length);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Pointer", ObjDesc->String.Pointer);
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Buffer");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Buffer.Length);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Sequence", ObjDesc->Buffer.Sequence);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Pointer", ObjDesc->Buffer.Pointer);
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Package");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Count", ObjDesc->Package.Count);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Elements", ObjDesc->Package.Elements);
+ AcpiOsPrintf ("%20s : 0x%p\n", "NextElement", ObjDesc->Package.NextElement);
+ break;
+
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "FieldUnit");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->FieldUnit.Access);
+ AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->FieldUnit.LockRule);
+ AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->FieldUnit.UpdateRule);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->FieldUnit.Length);
+ AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->FieldUnit.BitOffset);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->FieldUnit.Offset);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->FieldUnit.Container);
+ break;
+
+
+ case ACPI_TYPE_DEVICE:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Device");
+ AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Device.AddrHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->Device.SysHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->Device.DrvHandler);
+ break;
+
+ case ACPI_TYPE_EVENT:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Event");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Semaphore", ObjDesc->Event.Semaphore);
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Method");
+ AcpiOsPrintf ("%20s : 0x%X\n", "ParamCount", ObjDesc->Method.ParamCount);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Concurrency", ObjDesc->Method.Concurrency);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Semaphore", ObjDesc->Method.Semaphore);
+ AcpiOsPrintf ("%20s : 0x%X\n", "PcodeLength", ObjDesc->Method.PcodeLength);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Pcode", ObjDesc->Method.Pcode);
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Mutex");
+ AcpiOsPrintf ("%20s : 0x%X\n", "SyncLevel", ObjDesc->Mutex.SyncLevel);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Semaphore", ObjDesc->Mutex.Semaphore);
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Region");
+ AcpiOsPrintf ("%20s : 0x%X\n", "SpaceId", ObjDesc->Region.SpaceId);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Flags", ObjDesc->Region.Flags);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Address", ObjDesc->Region.Address);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Region.Length);
+ AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Region.AddrHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Next", ObjDesc->Region.Next);
+ break;
+
+
+ case ACPI_TYPE_POWER:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "PowerResource");
+ AcpiOsPrintf ("%20s : 0x%X\n", "SystemLevel", ObjDesc->PowerResource.SystemLevel);
+ AcpiOsPrintf ("%20s : 0x%X\n", "ResourceOrder", ObjDesc->PowerResource.ResourceOrder);
+ AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->PowerResource.SysHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->PowerResource.DrvHandler);
+ break;
+
+
+ case ACPI_TYPE_PROCESSOR:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Processor");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Processor ID", ObjDesc->Processor.ProcId);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Processor.Length);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Address", ObjDesc->Processor.Address);
+ AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->Processor.SysHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->Processor.DrvHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Processor.AddrHandler);
+ break;
+
+
+ case ACPI_TYPE_THERMAL:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "ThermalZone");
+ AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->ThermalZone.SysHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->ThermalZone.DrvHandler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->ThermalZone.AddrHandler);
+ break;
+
+ case INTERNAL_TYPE_BANK_FIELD:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "BankField");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->BankField.Access);
+ AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->BankField.LockRule);
+ AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->BankField.UpdateRule);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->BankField.Length);
+ AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->BankField.BitOffset);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->BankField.Offset);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->BankField.Value);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->BankField.Container);
+ AcpiOsPrintf ("%20s : 0x%X\n", "BankSelect", ObjDesc->BankField.BankSelect);
+ break;
+
+
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "IndexField");
+ AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->IndexField.Access);
+ AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->IndexField.LockRule);
+ AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->IndexField.UpdateRule);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->IndexField.Length);
+ AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->IndexField.BitOffset);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->IndexField.Value);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Index", ObjDesc->IndexField.Index);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Data", ObjDesc->IndexField.Data);
+ break;
+
+
+ case INTERNAL_TYPE_REFERENCE:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Reference");
+ AcpiOsPrintf ("%20s : 0x%X\n", "TargetType", ObjDesc->Reference.TargetType);
+ AcpiOsPrintf ("%20s : 0x%X\n", "OpCode", ObjDesc->Reference.OpCode);
+ AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->Reference.Offset);
+ AcpiOsPrintf ("%20s : 0x%p\n", "ObjDesc", ObjDesc->Reference.Object);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->Reference.Node);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Where", ObjDesc->Reference.Where);
+ break;
+
+
+ case INTERNAL_TYPE_ADDRESS_HANDLER:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Address Handler");
+ AcpiOsPrintf ("%20s : 0x%X\n", "SpaceId", ObjDesc->AddrHandler.SpaceId);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Next", ObjDesc->AddrHandler.Next);
+ AcpiOsPrintf ("%20s : 0x%p\n", "RegionList", ObjDesc->AddrHandler.RegionList);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->AddrHandler.Node);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Handler", ObjDesc->AddrHandler.Handler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Context", ObjDesc->AddrHandler.Context);
+ break;
+
+
+ case INTERNAL_TYPE_NOTIFY:
+
+ AcpiOsPrintf ("%20s : %s\n", "Type", "Notify Handler");
+ AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->NotifyHandler.Node);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Handler", ObjDesc->NotifyHandler.Handler);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Context", ObjDesc->NotifyHandler.Context);
+ break;
+
+
+ case INTERNAL_TYPE_DEF_FIELD:
+
+ AcpiOsPrintf ("%20s : 0x%p\n", "Granularity", ObjDesc->Field.Granularity);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Length", ObjDesc->Field.Length);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Offset", ObjDesc->Field.Offset);
+ AcpiOsPrintf ("%20s : 0x%p\n", "BitOffset", ObjDesc->Field.BitOffset);
+ AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->Field.Container);
+ break;
+
+
+ case INTERNAL_TYPE_ALIAS:
+ case INTERNAL_TYPE_DEF_FIELD_DEFN:
+ case INTERNAL_TYPE_BANK_FIELD_DEFN:
+ case INTERNAL_TYPE_INDEX_FIELD_DEFN:
+ case INTERNAL_TYPE_IF:
+ case INTERNAL_TYPE_ELSE:
+ case INTERNAL_TYPE_WHILE:
+ case INTERNAL_TYPE_SCOPE:
+ case INTERNAL_TYPE_DEF_ANY:
+
+ AcpiOsPrintf ("*** Structure display not implemented for type 0x%X! ***\n",
+ ObjDesc->Common.Type);
+ break;
+
+
+ default:
+
+ AcpiOsPrintf ("*** Cannot display unknown type 0x%X! ***\n", ObjDesc->Common.Type);
+ break;
+ }
+
+ return_VOID;
+}
+
+#endif
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c
new file mode 100644
index 0000000..fdc998b
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c
@@ -0,0 +1,906 @@
+/******************************************************************************
+ *
+ * Module Name: amdyadic - ACPI AML (p-code) execution for dyadic operators
+ * $Revision: 65 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __AMDYADIC_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acnamesp.h"
+#include "acinterp.h"
+#include "acevents.h"
+#include "amlcode.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amdyadic")
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecDyadic1
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 1 dyadic operator with numeric operands:
+ * NotifyOp
+ *
+ * ALLOCATION: Deletes both operands
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecDyadic1 (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_OPERAND_OBJECT *ValDesc = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecDyadic1", WALK_OPERANDS);
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode),
+ 2, "after AcpiAmlResolveOperands");
+
+ /* Get the operands */
+
+ Status |= AcpiDsObjStackPopObject (&ValDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecDyadic1/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Examine the opcode */
+
+ switch (Opcode)
+ {
+
+ /* DefNotify := NotifyOp NotifyObject NotifyValue */
+
+ case AML_NOTIFY_OP:
+
+ /* The ObjDesc is actually an Node */
+
+ Node = (ACPI_NAMESPACE_NODE *) ObjDesc;
+ ObjDesc = NULL;
+
+ /* Object must be a device or thermal zone */
+
+ if (Node && ValDesc)
+ {
+ switch (Node->Type)
+ {
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_THERMAL:
+
+ /*
+ * Requires that Device and ThermalZone be compatible
+ * mappings
+ */
+
+ /* Dispatch the notify to the appropriate handler */
+
+ AcpiEvNotifyDispatch (Node, (UINT32) ValDesc->Number.Value);
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecDyadic1/NotifyOp: unexpected notify object type %d\n",
+ ObjDesc->Common.Type));
+
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ }
+ break;
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecDyadic1: Unknown dyadic opcode %X\n",
+ Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ }
+
+
+Cleanup:
+
+ /* Always delete both operands */
+
+ AcpiCmRemoveReference (ValDesc);
+ AcpiCmRemoveReference (ObjDesc);
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecDyadic2R
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and
+ * one or two result operands.
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecDyadic2R (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_OPERAND_OBJECT *ObjDesc2 = NULL;
+ ACPI_OPERAND_OBJECT *ResDesc = NULL;
+ ACPI_OPERAND_OBJECT *ResDesc2 = NULL;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_OPERAND_OBJECT *RetDesc2 = NULL;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_INTEGER Remainder;
+ UINT32 NumOperands = 3;
+ NATIVE_CHAR *NewBuf;
+
+
+ FUNCTION_TRACE_U32 ("AmlExecDyadic2R", Opcode);
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode),
+ NumOperands, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ if (AML_DIVIDE_OP == Opcode)
+ {
+ NumOperands = 4;
+ Status |= AcpiDsObjStackPopObject (&ResDesc2, WalkState);
+ }
+
+ Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecDyadic2R/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Create an internal return object if necessary */
+
+ switch (Opcode)
+ {
+ case AML_ADD_OP:
+ case AML_BIT_AND_OP:
+ case AML_BIT_NAND_OP:
+ case AML_BIT_OR_OP:
+ case AML_BIT_NOR_OP:
+ case AML_BIT_XOR_OP:
+ case AML_DIVIDE_OP:
+ case AML_MULTIPLY_OP:
+ case AML_SHIFT_LEFT_OP:
+ case AML_SHIFT_RIGHT_OP:
+ case AML_SUBTRACT_OP:
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ break;
+ }
+
+
+ /*
+ * Execute the opcode
+ */
+
+ switch (Opcode)
+ {
+
+ /* DefAdd := AddOp Operand1 Operand2 Result */
+
+ case AML_ADD_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value +
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefAnd := AndOp Operand1 Operand2 Result */
+
+ case AML_BIT_AND_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value &
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefNAnd := NAndOp Operand1 Operand2 Result */
+
+ case AML_BIT_NAND_OP:
+
+ RetDesc->Number.Value = ~(ObjDesc->Number.Value &
+ ObjDesc2->Number.Value);
+ break;
+
+
+ /* DefOr := OrOp Operand1 Operand2 Result */
+
+ case AML_BIT_OR_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value |
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefNOr := NOrOp Operand1 Operand2 Result */
+
+ case AML_BIT_NOR_OP:
+
+ RetDesc->Number.Value = ~(ObjDesc->Number.Value |
+ ObjDesc2->Number.Value);
+ break;
+
+
+ /* DefXOr := XOrOp Operand1 Operand2 Result */
+
+ case AML_BIT_XOR_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value ^
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefDivide := DivideOp Dividend Divisor Remainder Quotient */
+
+ case AML_DIVIDE_OP:
+
+ if ((UINT32) 0 == ObjDesc2->Number.Value)
+ {
+ REPORT_ERROR
+ (("AmlExecDyadic2R/DivideOp: Divide by zero\n"));
+
+ Status = AE_AML_DIVIDE_BY_ZERO;
+ goto Cleanup;
+ }
+
+ RetDesc2 = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc2)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ Remainder = ObjDesc->Number.Value %
+ ObjDesc2->Number.Value;
+ RetDesc->Number.Value = Remainder;
+
+ /* Result (what we used to call the quotient) */
+
+ RetDesc2->Number.Value = ObjDesc->Number.Value /
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefMultiply := MultiplyOp Operand1 Operand2 Result */
+
+ case AML_MULTIPLY_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value *
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefShiftLeft := ShiftLeftOp Operand ShiftCount Result */
+
+ case AML_SHIFT_LEFT_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value <<
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefShiftRight := ShiftRightOp Operand ShiftCount Result */
+
+ case AML_SHIFT_RIGHT_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value >>
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefSubtract := SubtractOp Operand1 Operand2 Result */
+
+ case AML_SUBTRACT_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value -
+ ObjDesc2->Number.Value;
+ break;
+
+
+ /* DefConcat := ConcatOp Data1 Data2 Result */
+
+ case AML_CONCAT_OP:
+
+ if (ObjDesc2->Common.Type != ObjDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecDyadic2R/ConcatOp: operand type mismatch %d %d\n",
+ ObjDesc->Common.Type, ObjDesc2->Common.Type));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ /* Both operands are now known to be the same */
+
+ if (ACPI_TYPE_STRING == ObjDesc->Common.Type)
+ {
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Operand1 is string */
+
+ NewBuf = AcpiCmAllocate (ObjDesc->String.Length +
+ ObjDesc2->String.Length + 1);
+ if (!NewBuf)
+ {
+ REPORT_ERROR
+ (("AmlExecDyadic2R/ConcatOp: String allocation failure\n"));
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ STRCPY (NewBuf, ObjDesc->String.Pointer);
+ STRCPY (NewBuf + ObjDesc->String.Length,
+ ObjDesc2->String.Pointer);
+
+ /* Point the return object to the new string */
+
+ RetDesc->String.Pointer = NewBuf;
+ RetDesc->String.Length = ObjDesc->String.Length +=
+ ObjDesc2->String.Length;
+ }
+
+ else
+ {
+ /* Operand1 is not a string ==> must be a buffer */
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = AcpiCmAllocate (ObjDesc->Buffer.Length +
+ ObjDesc2->Buffer.Length);
+ if (!NewBuf)
+ {
+ REPORT_ERROR
+ (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n"));
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ MEMCPY (NewBuf, ObjDesc->Buffer.Pointer,
+ ObjDesc->Buffer.Length);
+ MEMCPY (NewBuf + ObjDesc->Buffer.Length, ObjDesc2->Buffer.Pointer,
+ ObjDesc2->Buffer.Length);
+
+ /*
+ * Point the return object to the new buffer
+ */
+
+ RetDesc->Buffer.Pointer = (UINT8 *) NewBuf;
+ RetDesc->Buffer.Length = ObjDesc->Buffer.Length +
+ ObjDesc2->Buffer.Length;
+ }
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecDyadic2R: Unknown dyadic opcode %X\n", Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Store the result of the operation (which is now in ObjDesc) into
+ * the result descriptor, or the location pointed to by the result
+ * descriptor (ResDesc).
+ */
+
+ Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (AML_DIVIDE_OP == Opcode)
+ {
+ Status = AcpiAmlExecStore (RetDesc2, ResDesc2, WalkState);
+
+ /*
+ * Since the remainder is not returned, remove a reference to
+ * the object we created earlier
+ */
+
+ AcpiCmRemoveReference (RetDesc2);
+ }
+
+
+Cleanup:
+
+ /* Always delete the operands */
+
+ AcpiCmRemoveReference (ObjDesc);
+ AcpiCmRemoveReference (ObjDesc2);
+
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* On failure, delete the result ops */
+
+ AcpiCmRemoveReference (ResDesc);
+ AcpiCmRemoveReference (ResDesc2);
+
+ if (RetDesc)
+ {
+ /* And delete the internal return object */
+
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+ }
+
+ /* Set the return object and exit */
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecDyadic2S
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 dyadic synchronization operator
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecDyadic2S (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *TimeDesc;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecDyadic2S", WALK_OPERANDS);
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode),
+ 2, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ Status |= AcpiDsObjStackPopObject (&TimeDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecDyadic2S/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Create the internal return object */
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Default return value is FALSE, operation did not time out */
+
+ RetDesc->Number.Value = 0;
+
+
+ /* Examine the opcode */
+
+ switch (Opcode)
+ {
+
+ /* DefAcquire := AcquireOp MutexObject Timeout */
+
+ case AML_ACQUIRE_OP:
+
+ Status = AcpiAmlSystemAcquireMutex (TimeDesc, ObjDesc);
+ break;
+
+
+ /* DefWait := WaitOp AcpiEventObject Timeout */
+
+ case AML_WAIT_OP:
+
+ Status = AcpiAmlSystemWaitEvent (TimeDesc, ObjDesc);
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecDyadic2S: Unknown dyadic synchronization opcode %X\n", Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Return a boolean indicating if operation timed out
+ * (TRUE) or not (FALSE)
+ */
+
+ if (Status == AE_TIME)
+ {
+ RetDesc->Number.Value = ACPI_INTEGER_MAX; /* TRUE, op timed out */
+ Status = AE_OK;
+ }
+
+
+Cleanup:
+
+ /* Delete params */
+
+ AcpiCmRemoveReference (TimeDesc);
+ AcpiCmRemoveReference (ObjDesc);
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+
+ /* Set the return object and exit */
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecDyadic2
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and
+ * no result operands
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ * containing result value
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecDyadic2 (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc2;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS Status;
+ BOOLEAN Lboolean;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecDyadic2", WALK_OPERANDS);
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode),
+ 2, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecDyadic2/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Create the internal return object */
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Execute the Opcode
+ */
+
+ Lboolean = FALSE;
+ switch (Opcode)
+ {
+
+ /* DefLAnd := LAndOp Operand1 Operand2 */
+
+ case AML_LAND_OP:
+
+ Lboolean = (BOOLEAN) (ObjDesc->Number.Value &&
+ ObjDesc2->Number.Value);
+ break;
+
+
+ /* DefLEqual := LEqualOp Operand1 Operand2 */
+
+ case AML_LEQUAL_OP:
+
+ Lboolean = (BOOLEAN) (ObjDesc->Number.Value ==
+ ObjDesc2->Number.Value);
+ break;
+
+
+ /* DefLGreater := LGreaterOp Operand1 Operand2 */
+
+ case AML_LGREATER_OP:
+
+ Lboolean = (BOOLEAN) (ObjDesc->Number.Value >
+ ObjDesc2->Number.Value);
+ break;
+
+
+ /* DefLLess := LLessOp Operand1 Operand2 */
+
+ case AML_LLESS_OP:
+
+ Lboolean = (BOOLEAN) (ObjDesc->Number.Value <
+ ObjDesc2->Number.Value);
+ break;
+
+
+ /* DefLOr := LOrOp Operand1 Operand2 */
+
+ case AML_LOR_OP:
+
+ Lboolean = (BOOLEAN) (ObjDesc->Number.Value ||
+ ObjDesc2->Number.Value);
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecDyadic2: Unknown dyadic opcode %X\n", Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ break;
+ }
+
+
+ /* Set return value to logical TRUE (all ones) or FALSE (zero) */
+
+ if (Lboolean)
+ {
+ RetDesc->Number.Value = ACPI_INTEGER_MAX;
+ }
+ else
+ {
+ RetDesc->Number.Value = 0;
+ }
+
+
+Cleanup:
+
+ /* Always delete operands */
+
+ AcpiCmRemoveReference (ObjDesc);
+ AcpiCmRemoveReference (ObjDesc2);
+
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+
+ /* Set the return object and exit */
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c
new file mode 100644
index 0000000..d450fbf
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c
@@ -0,0 +1,446 @@
+/******************************************************************************
+ *
+ * Module Name: amfield - ACPI AML (p-code) execution - field manipulation
+ * $Revision: 73 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __AMFIELD_C__
+
+#include "acpi.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "achware.h"
+#include "acevents.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amfield")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSetupField
+ *
+ * PARAMETERS: *ObjDesc - Field to be read or written
+ * *RgnDesc - Region containing field
+ * FieldBitWidth - Field Width in bits (8, 16, or 32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common processing for AcpiAmlReadField and AcpiAmlWriteField
+ *
+ * ACPI SPECIFICATION REFERENCES:
+ * Each of the Type1Opcodes is defined as specified in in-line
+ * comments below. For each one, use the following definitions.
+ *
+ * DefBitField := BitFieldOp SrcBuf BitIdx Destination
+ * DefByteField := ByteFieldOp SrcBuf ByteIdx Destination
+ * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString
+ * DefDWordField := DWordFieldOp SrcBuf ByteIdx Destination
+ * DefWordField := WordFieldOp SrcBuf ByteIdx Destination
+ * BitIndex := TermArg=>Integer
+ * ByteIndex := TermArg=>Integer
+ * Destination := NameString
+ * NumBits := TermArg=>Integer
+ * SourceBuf := TermArg=>Buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSetupField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT *RgnDesc,
+ UINT32 FieldBitWidth)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 FieldByteWidth;
+
+
+ FUNCTION_TRACE ("AmlSetupField");
+
+
+ /* Parameter validation */
+
+ if (!ObjDesc || !RgnDesc)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlSetupField: Internal error - null handle\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ if (ACPI_TYPE_REGION != RgnDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlSetupField: Needed Region, found type %x %s\n",
+ RgnDesc->Common.Type, AcpiCmGetTypeName (RgnDesc->Common.Type)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+
+ /*
+ * TBD: [Future] Acpi 2.0 supports Qword fields
+ *
+ * Init and validate Field width
+ * Possible values are 1, 2, 4
+ */
+
+ FieldByteWidth = DIV_8 (FieldBitWidth);
+
+ if ((FieldBitWidth != 8) &&
+ (FieldBitWidth != 16) &&
+ (FieldBitWidth != 32))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlSetupField: Internal error - bad width %d\n", FieldBitWidth));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+
+ /*
+ * If the Region Address and Length have not been previously evaluated,
+ * evaluate them and save the results.
+ */
+ if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID))
+ {
+
+ Status = AcpiDsGetRegionArguments (RgnDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+
+ if ((ObjDesc->Common.Type == ACPI_TYPE_FIELD_UNIT) &&
+ (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)))
+ {
+ /*
+ * Field Buffer and Index have not been previously evaluated,
+ */
+ DEBUG_PRINT (ACPI_ERROR, ("Uninitialized field!\n"));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ if (RgnDesc->Region.Length <
+ (ObjDesc->Field.Offset & ~((UINT32) FieldByteWidth - 1)) +
+ FieldByteWidth)
+ {
+ /*
+ * Offset rounded up to next multiple of field width
+ * exceeds region length, indicate an error
+ */
+
+ DUMP_STACK_ENTRY (RgnDesc);
+ DUMP_STACK_ENTRY (ObjDesc);
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlSetupField: Operation at %08lX width %d bits exceeds len %08lX field=%p region=%p\n",
+ ObjDesc->Field.Offset, FieldBitWidth, RgnDesc->Region.Length,
+ ObjDesc, RgnDesc));
+
+ return_ACPI_STATUS (AE_AML_REGION_LIMIT);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlAccessNamedField
+ *
+ * PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
+ * NamedField - Handle for field to be accessed
+ * *Buffer - Value(s) to be read or written
+ * BufferLength - Number of bytes to transfer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or write a named field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlAccessNamedField (
+ UINT32 Mode,
+ ACPI_HANDLE NamedField,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN Locked = FALSE;
+ UINT32 BitGranularity = 0;
+ UINT32 ByteGranularity;
+ UINT32 DatumLength;
+ UINT32 ActualByteLength;
+ UINT32 ByteFieldLength;
+
+
+ FUNCTION_TRACE_PTR ("AmlAccessNamedField", NamedField);
+
+
+ /* Basic data checking */
+ if ((!NamedField) || (ACPI_READ == Mode && !Buffer))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AcpiAmlAccessNamedField: Internal error - null parameter\n"));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* Get the attached field object */
+
+ ObjDesc = AcpiNsGetAttachedObject (NamedField);
+ if (!ObjDesc)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlAccessNamedField: Internal error - null value pointer\n"));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* Check the type */
+
+ if (INTERNAL_TYPE_DEF_FIELD != AcpiNsGetType (NamedField))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlAccessNamedField: Name %4.4s type %x is not a defined field\n",
+ &(((ACPI_NAMESPACE_NODE *) NamedField)->Name),
+ AcpiNsGetType (NamedField)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* ObjDesc valid and NamedField is a defined field */
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AccessNamedField: Obj=%p Type=%x Buf=%p Len=%x\n",
+ ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength));
+ DEBUG_PRINT (ACPI_INFO,
+ ("AccessNamedField: Mode=%d FieldLen=%d, BitOffset=%d\n",
+ Mode, ObjDesc->FieldUnit.Length, ObjDesc->FieldUnit.BitOffset));
+ DUMP_ENTRY (NamedField, ACPI_INFO);
+
+
+ /* Double-check that the attached object is also a field */
+
+ if (INTERNAL_TYPE_DEF_FIELD != ObjDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlAccessNamedField: Internal error - Name %4.4s type %x does not match value-type %x at %p\n",
+ &(((ACPI_NAMESPACE_NODE *) NamedField)->Name),
+ AcpiNsGetType (NamedField), ObjDesc->Common.Type, ObjDesc));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+
+ /*
+ * Granularity was decoded from the field access type
+ * (AnyAcc will be the same as ByteAcc)
+ */
+
+ BitGranularity = ObjDesc->FieldUnit.Granularity;
+ ByteGranularity = DIV_8 (BitGranularity);
+
+ /*
+ * Check if request is too large for the field, and silently truncate
+ * if necessary
+ */
+
+ /* TBD: [Errors] should an error be returned in this case? */
+
+ ByteFieldLength = (UINT32) DIV_8 (ObjDesc->FieldUnit.Length + 7);
+
+
+ ActualByteLength = BufferLength;
+ if (BufferLength > ByteFieldLength)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlAccessNamedField: Byte length %d too large, truncated to %x\n",
+ ActualByteLength, ByteFieldLength));
+
+ ActualByteLength = ByteFieldLength;
+ }
+
+ /* TBD: should these round down to a power of 2? */
+
+ if (DIV_8(BitGranularity) > ByteFieldLength)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlAccessNamedField: Bit granularity %d too large, truncated to %x\n",
+ BitGranularity, MUL_8(ByteFieldLength)));
+
+ BitGranularity = MUL_8(ByteFieldLength);
+ }
+
+ if (ByteGranularity > ByteFieldLength)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlAccessNamedField: Byte granularity %d too large, truncated to %x\n",
+ ByteGranularity, ByteFieldLength));
+
+ ByteGranularity = ByteFieldLength;
+ }
+
+
+ /* Convert byte count to datum count, round up if necessary */
+
+ DatumLength = (ActualByteLength + (ByteGranularity-1)) / ByteGranularity;
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n",
+ ActualByteLength, DatumLength, BitGranularity, ByteGranularity));
+
+
+ /* Get the global lock if needed */
+
+ Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
+
+
+ /* Perform the actual read or write of the buffer */
+
+ switch (Mode)
+ {
+ case ACPI_READ:
+
+ Status = AcpiAmlReadField (ObjDesc, Buffer, BufferLength,
+ ActualByteLength, DatumLength,
+ BitGranularity, ByteGranularity);
+ break;
+
+
+ case ACPI_WRITE:
+
+ Status = AcpiAmlWriteField (ObjDesc, Buffer, BufferLength,
+ ActualByteLength, DatumLength,
+ BitGranularity, ByteGranularity);
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AccessNamedField: Unknown I/O Mode: %X\n", Mode));
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+
+ /* Release global lock if we acquired it earlier */
+
+ AcpiAmlReleaseGlobalLock (Locked);
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c
new file mode 100644
index 0000000..ce7bb28
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c
@@ -0,0 +1,857 @@
+/******************************************************************************
+ *
+ * Module Name: amfldio - Aml Field I/O
+ * $Revision: 28 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __AMFLDIO_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "achware.h"
+#include "acevents.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amfldio")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlReadFieldData
+ *
+ * PARAMETERS: *ObjDesc - Field to be read
+ * *Value - Where to store value
+ * FieldBitWidth - Field Width in bits (8, 16, or 32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value of the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlReadFieldData (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldByteOffset,
+ UINT32 FieldBitWidth,
+ UINT32 *Value)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *RgnDesc = NULL;
+ ACPI_INTEGER Address;
+ UINT32 LocalValue = 0;
+ UINT32 FieldByteWidth;
+
+
+ FUNCTION_TRACE ("AmlReadFieldData");
+
+
+ /* ObjDesc is validated by callers */
+
+ if (ObjDesc)
+ {
+ RgnDesc = ObjDesc->Field.Container;
+ }
+
+
+ FieldByteWidth = DIV_8 (FieldBitWidth);
+ Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* SetupField validated RgnDesc and FieldBitWidth */
+
+ if (!Value)
+ {
+ Value = &LocalValue; /* support reads without saving value */
+ }
+
+
+ /*
+ * Set offset to next multiple of field width,
+ * add region base address and offset within the field
+ */
+ Address = RgnDesc->Region.Address +
+ (ObjDesc->Field.Offset * FieldByteWidth) +
+ FieldByteOffset;
+
+
+ if (RgnDesc->Region.SpaceId >= NUM_REGION_TYPES)
+ {
+ DEBUG_PRINT (TRACE_OPREGION,
+ ("AmlReadFieldData: **** Unknown OpRegion SpaceID %d at %08lx width %d\n",
+ RgnDesc->Region.SpaceId, Address, FieldBitWidth));
+ }
+
+ else
+ {
+ DEBUG_PRINT (TRACE_OPREGION,
+ ("AmlReadFieldData: OpRegion %s at %08lx width %d\n",
+ AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId], Address,
+ FieldBitWidth));
+ }
+
+
+ /* Invoke the appropriate AddressSpace/OpRegion handler */
+
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ,
+ Address, FieldBitWidth, Value);
+
+ if (Status == AE_NOT_IMPLEMENTED)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlReadFieldData: **** OpRegion type %s not implemented\n",
+ AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId]));
+ }
+
+ else if (Status == AE_NOT_EXIST)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlReadFieldData: **** Unknown OpRegion SpaceID %d\n",
+ RgnDesc->Region.SpaceId));
+ }
+
+ DEBUG_PRINT (TRACE_OPREGION,
+ ("AmlReadField: Returned value=%08lx \n", *Value));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlReadField
+ *
+ * PARAMETERS: *ObjDesc - Field to be read
+ * *Value - Where to store value
+ * FieldBitWidth - Field Width in bits (8, 16, or 32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value of the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlReadField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength,
+ UINT32 ByteLength,
+ UINT32 DatumLength,
+ UINT32 BitGranularity,
+ UINT32 ByteGranularity)
+{
+ ACPI_STATUS Status;
+ UINT32 ThisFieldByteOffset;
+ UINT32 ThisFieldDatumOffset;
+ UINT32 PreviousRawDatum;
+ UINT32 ThisRawDatum;
+ UINT32 ValidFieldBits;
+ UINT32 Mask;
+ UINT32 MergedDatum = 0;
+
+
+ FUNCTION_TRACE ("AmlReadField");
+
+ /*
+ * Clear the caller's buffer (the whole buffer length as given)
+ * This is very important, especially in the cases where a byte is read,
+ * but the buffer is really a UINT32 (4 bytes).
+ */
+
+ MEMSET (Buffer, 0, BufferLength);
+
+ /* Read the first raw datum to prime the loop */
+
+ ThisFieldByteOffset = 0;
+ ThisFieldDatumOffset= 0;
+
+ Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, BitGranularity,
+ &PreviousRawDatum);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* We might actually be done if the request fits in one datum */
+
+ if ((DatumLength == 1) &&
+ ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <=
+ (UINT16) BitGranularity))
+ {
+ MergedDatum = PreviousRawDatum;
+
+ MergedDatum = (MergedDatum >> ObjDesc->Field.BitOffset);
+
+ ValidFieldBits = ObjDesc->FieldUnit.Length % BitGranularity;
+ if (ValidFieldBits)
+ {
+ Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1);
+ MergedDatum &= Mask;
+ }
+
+
+ /*
+ * Place the MergedDatum into the proper format and return buffer
+ * field
+ */
+
+ switch (ByteGranularity)
+ {
+ case 1:
+ ((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum;
+ break;
+
+ case 2:
+ MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[ThisFieldDatumOffset]), &MergedDatum);
+ break;
+
+ case 4:
+ MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[ThisFieldDatumOffset]), &MergedDatum);
+ break;
+ }
+
+ ThisFieldByteOffset = 1;
+ ThisFieldDatumOffset = 1;
+ }
+
+ else
+ {
+ /* We need to get more raw data to complete one or more field data */
+
+ while (ThisFieldDatumOffset < DatumLength)
+ {
+ /*
+ * Get the next raw datum, it contains bits of the current
+ * field datum
+ */
+
+ Status = AcpiAmlReadFieldData (ObjDesc,
+ ThisFieldByteOffset + ByteGranularity,
+ BitGranularity, &ThisRawDatum);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Before merging the data, make sure the unused bits are clear */
+
+ switch (ByteGranularity)
+ {
+ case 1:
+ ThisRawDatum &= 0x000000FF;
+ PreviousRawDatum &= 0x000000FF;
+ break;
+
+ case 2:
+ ThisRawDatum &= 0x0000FFFF;
+ PreviousRawDatum &= 0x0000FFFF;
+ break;
+ }
+
+ /*
+ * Put together bits of the two raw data to make a complete
+ * field datum
+ */
+
+
+ if (ObjDesc->Field.BitOffset != 0)
+ {
+ MergedDatum =
+ (PreviousRawDatum >> ObjDesc->Field.BitOffset) |
+ (ThisRawDatum << (BitGranularity - ObjDesc->Field.BitOffset));
+ }
+
+ else
+ {
+ MergedDatum = PreviousRawDatum;
+ }
+
+ /*
+ * Prepare the merged datum for storing into the caller's
+ * buffer. It is possible to have a 32-bit buffer
+ * (ByteGranularity == 4), but a ObjDesc->Field.Length
+ * of 8 or 16, meaning that the upper bytes of merged data
+ * are undesired. This section fixes that.
+ */
+ switch (ObjDesc->Field.Length)
+ {
+ case 8:
+ MergedDatum &= 0x000000FF;
+ break;
+
+ case 16:
+ MergedDatum &= 0x0000FFFF;
+ break;
+ }
+
+ /*
+ * Now store the datum in the caller's buffer, according to
+ * the data type
+ */
+ switch (ByteGranularity)
+ {
+ case 1:
+ ((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum;
+ break;
+
+ case 2:
+ MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer) [ThisFieldDatumOffset]), &MergedDatum);
+ break;
+
+ case 4:
+ MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer) [ThisFieldDatumOffset]), &MergedDatum);
+ break;
+ }
+
+ /*
+ * Save the most recent datum since it contains bits of
+ * the *next* field datum
+ */
+
+ PreviousRawDatum = ThisRawDatum;
+
+ ThisFieldByteOffset += ByteGranularity;
+ ThisFieldDatumOffset++;
+
+ } /* while */
+ }
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlWriteFieldData
+ *
+ * PARAMETERS: *ObjDesc - Field to be set
+ * Value - Value to store
+ * FieldBitWidth - Field Width in bits (8, 16, or 32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the value into the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlWriteFieldData (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldByteOffset,
+ UINT32 FieldBitWidth,
+ UINT32 Value)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *RgnDesc = NULL;
+ ACPI_INTEGER Address;
+ UINT32 FieldByteWidth;
+
+
+ FUNCTION_TRACE ("AmlWriteFieldData");
+
+
+ /* ObjDesc is validated by callers */
+
+ if (ObjDesc)
+ {
+ RgnDesc = ObjDesc->Field.Container;
+ }
+
+ FieldByteWidth = DIV_8 (FieldBitWidth);
+ Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+
+ /*
+ * Set offset to next multiple of field width,
+ * add region base address and offset within the field
+ */
+ Address = RgnDesc->Region.Address +
+ (ObjDesc->Field.Offset * FieldByteWidth) +
+ FieldByteOffset;
+
+
+ if (RgnDesc->Region.SpaceId >= NUM_REGION_TYPES)
+ {
+ DEBUG_PRINT (TRACE_OPREGION,
+ ("AmlWriteField: **** Store %lx in unknown OpRegion SpaceID %d at %p width %d ** \n",
+ Value, RgnDesc->Region.SpaceId, Address, FieldBitWidth));
+ }
+ else
+ {
+ DEBUG_PRINT (TRACE_OPREGION,
+ ("AmlWriteField: Store %lx in OpRegion %s at %p width %d\n",
+ Value, AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId], Address,
+ FieldBitWidth));
+ }
+
+ /* Invoke the appropriate AddressSpace/OpRegion handler */
+
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_WRITE,
+ Address, FieldBitWidth, &Value);
+
+ if (Status == AE_NOT_IMPLEMENTED)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlWriteField: **** OpRegion type %s not implemented\n",
+ AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId]));
+ }
+
+ else if (Status == AE_NOT_EXIST)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlWriteField: **** Unknown OpRegion SpaceID %x\n",
+ RgnDesc->Region.SpaceId));
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlWriteFieldDataWithUpdateRule
+ *
+ * PARAMETERS: *ObjDesc - Field to be set
+ * Value - Value to store
+ * FieldBitWidth - Field Width in bits (8, 16, or 32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlWriteFieldDataWithUpdateRule (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Mask,
+ UINT32 FieldValue,
+ UINT32 ThisFieldByteOffset,
+ UINT32 BitGranularity)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 MergedValue;
+ UINT32 CurrentValue;
+
+
+ /* Start with the new bits */
+
+ MergedValue = FieldValue;
+
+ /* Check if update rule needs to be applied (not if mask is all ones) */
+
+
+ /* Decode the update rule */
+
+ switch (ObjDesc->Field.UpdateRule)
+ {
+
+ case UPDATE_PRESERVE:
+
+ /*
+ * Read the current contents of the byte/word/dword containing
+ * the field, and merge with the new field value.
+ */
+ Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset,
+ BitGranularity, &CurrentValue);
+ MergedValue |= (CurrentValue & ~Mask);
+ break;
+
+
+ case UPDATE_WRITE_AS_ONES:
+
+ /* Set positions outside the field to all ones */
+
+ MergedValue |= ~Mask;
+ break;
+
+
+ case UPDATE_WRITE_AS_ZEROS:
+
+ /* Set positions outside the field to all zeros */
+
+ MergedValue &= Mask;
+ break;
+
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("WriteFieldDataWithUpdateRule: Unknown UpdateRule setting: %x\n",
+ ObjDesc->Field.UpdateRule));
+ Status = AE_AML_OPERAND_VALUE;
+ }
+
+
+ /* Write the merged value */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiAmlWriteFieldData (ObjDesc, ThisFieldByteOffset,
+ BitGranularity, MergedValue);
+ }
+
+ return (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiAmlWriteField
+ *
+ * PARAMETERS: *ObjDesc - Field to be set
+ * Value - Value to store
+ * FieldBitWidth - Field Width in bits (8, 16, or 32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the value into the given field
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiAmlWriteField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength,
+ UINT32 ByteLength,
+ UINT32 DatumLength,
+ UINT32 BitGranularity,
+ UINT32 ByteGranularity)
+{
+ ACPI_STATUS Status;
+ UINT32 ThisFieldByteOffset;
+ UINT32 ThisFieldDatumOffset;
+ UINT32 Mask;
+ UINT32 MergedDatum;
+ UINT32 PreviousRawDatum;
+ UINT32 ThisRawDatum;
+ UINT32 FieldValue;
+ UINT32 ValidFieldBits;
+
+
+ FUNCTION_TRACE ("AmlWriteField");
+
+
+ /*
+ * Break the request into up to three parts:
+ * non-aligned part at start, aligned part in middle, non-aligned part
+ * at end --- Just like an I/O request ---
+ */
+
+ ThisFieldByteOffset = 0;
+ ThisFieldDatumOffset= 0;
+
+ /* Get a datum */
+
+ switch (ByteGranularity)
+ {
+ case 1:
+ PreviousRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset];
+ break;
+
+ case 2:
+ MOVE_UNALIGNED16_TO_32 (&PreviousRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset]));
+ break;
+
+ case 4:
+ MOVE_UNALIGNED32_TO_32 (&PreviousRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset]));
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR, ("AmlWriteField: Invalid granularity: %x\n",
+ ByteGranularity));
+ Status = AE_AML_OPERAND_VALUE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Write a partial field datum if field does not begin on a datum boundary
+ *
+ * Construct Mask with 1 bits where the field is, 0 bits elsewhere
+ *
+ * 1) Bits above the field
+ */
+
+ Mask = (((UINT32)(-1)) << (UINT32)ObjDesc->Field.BitOffset);
+
+ /* 2) Only the bottom 5 bits are valid for a shift operation. */
+
+ if ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) < 32)
+ {
+ /* Bits above the field */
+
+ Mask &= (~(((UINT32)(-1)) << ((UINT32)ObjDesc->Field.BitOffset +
+ (UINT32)ObjDesc->FieldUnit.Length)));
+ }
+
+ /* 3) Shift and mask the value into the field position */
+
+ FieldValue = (PreviousRawDatum << ObjDesc->Field.BitOffset) & Mask;
+
+ Status = AcpiAmlWriteFieldDataWithUpdateRule (ObjDesc, Mask, FieldValue,
+ ThisFieldByteOffset,
+ BitGranularity);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+
+ /* If the field fits within one datum, we are done. */
+
+ if ((DatumLength == 1) &&
+ ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <=
+ (UINT16) BitGranularity))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * We don't need to worry about the update rule for these data, because
+ * all of the bits are part of the field.
+ *
+ * Can't write the last datum, however, because it might contain bits that
+ * are not part of the field -- the update rule must be applied.
+ */
+
+ while (ThisFieldDatumOffset < (DatumLength - 1))
+ {
+ ThisFieldDatumOffset++;
+
+ /* Get the next raw datum, it contains bits of the current field datum... */
+
+ switch (ByteGranularity)
+ {
+ case 1:
+ ThisRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset];
+ break;
+
+ case 2:
+ MOVE_UNALIGNED16_TO_32 (&ThisRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset]));
+ break;
+
+ case 4:
+ MOVE_UNALIGNED32_TO_32 (&ThisRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset]));
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR, ("AmlWriteField: Invalid Byte Granularity: %x\n",
+ ByteGranularity));
+ Status = AE_AML_OPERAND_VALUE;
+ goto Cleanup;
+ }
+
+ /*
+ * Put together bits of the two raw data to make a complete field
+ * datum
+ */
+
+ if (ObjDesc->Field.BitOffset != 0)
+ {
+ MergedDatum =
+ (PreviousRawDatum >> (BitGranularity - ObjDesc->Field.BitOffset)) |
+ (ThisRawDatum << ObjDesc->Field.BitOffset);
+ }
+
+ else
+ {
+ MergedDatum = ThisRawDatum;
+ }
+
+ /* Now write the completed datum */
+
+
+ Status = AcpiAmlWriteFieldData (ObjDesc,
+ ThisFieldByteOffset + ByteGranularity,
+ BitGranularity, MergedDatum);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+
+ /*
+ * Save the most recent datum since it contains bits of
+ * the *next* field datum
+ */
+
+ PreviousRawDatum = ThisRawDatum;
+
+ ThisFieldByteOffset += ByteGranularity;
+
+ } /* while */
+
+
+ /* Write a partial field datum if field does not end on a datum boundary */
+
+ if ((ObjDesc->FieldUnit.Length + ObjDesc->FieldUnit.BitOffset) %
+ BitGranularity)
+ {
+ switch (ByteGranularity)
+ {
+ case 1:
+ ThisRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset];
+ break;
+
+ case 2:
+ MOVE_UNALIGNED16_TO_32 (&ThisRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset]));
+ break;
+
+ case 4:
+ MOVE_UNALIGNED32_TO_32 (&ThisRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset]));
+ break;
+ }
+
+ /* Construct Mask with 1 bits where the field is, 0 bits elsewhere */
+
+ ValidFieldBits = ((ObjDesc->FieldUnit.Length % BitGranularity) +
+ ObjDesc->Field.BitOffset);
+
+ Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1);
+
+ /* Shift and mask the value into the field position */
+
+ FieldValue = (PreviousRawDatum >>
+ (BitGranularity - ObjDesc->Field.BitOffset)) & Mask;
+
+ Status = AcpiAmlWriteFieldDataWithUpdateRule (ObjDesc, Mask, FieldValue,
+ ThisFieldByteOffset + ByteGranularity,
+ BitGranularity);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ }
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c
new file mode 100644
index 0000000..7decf64
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c
@@ -0,0 +1,682 @@
+
+/******************************************************************************
+ *
+ * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes
+ * $Revision: 70 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMMISC_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("ammisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecFatal
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Status. If the OS returns from the OSD call, we just keep
+ * on going.
+ *
+ * DESCRIPTION: Execute Fatal operator
+ *
+ * ACPI SPECIFICATION REFERENCES:
+ * DefFatal := FatalOp FatalType FatalCode FatalArg
+ * FatalType := ByteData
+ * FatalCode := DWordData
+ * FatalArg := TermArg=>Integer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecFatal (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *TypeDesc;
+ ACPI_OPERAND_OBJECT *CodeDesc;
+ ACPI_OPERAND_OBJECT *ArgDesc;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlExecFatal");
+
+
+ /* Resolve operands */
+
+ Status = AcpiAmlResolveOperands (AML_FATAL_OP, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+ AcpiPsGetOpcodeName (AML_FATAL_OP),
+ 3, "after AcpiAmlResolveOperands");
+
+ /* Get operands */
+
+ Status |= AcpiDsObjStackPopObject (&ArgDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&CodeDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&TypeDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AcpiAmlExecFatal/AML_FATAL_OP: bad operand(s) (0x%X)\n",
+ Status));
+
+ goto Cleanup;
+ }
+
+
+ /* DefFatal := FatalOp FatalType FatalCode FatalArg */
+
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
+ TypeDesc->Number.Value, CodeDesc->Number.Value, ArgDesc->Number.Value));
+
+
+ /*
+ * TBD: [Unhandled] call OSD interface to notify OS of fatal error
+ * requiring shutdown!
+ */
+
+
+Cleanup:
+
+ /* Free the operands */
+
+ AcpiCmRemoveReference (ArgDesc);
+ AcpiCmRemoveReference (CodeDesc);
+ AcpiCmRemoveReference (TypeDesc);
+
+
+ /* If we get back from the OS call, we might as well keep going. */
+
+ REPORT_WARNING (("An AML \"Fatal\" Opcode (FatalOp) was executed\n"));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecIndex
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Index operator
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ *
+ * ACPI SPECIFICATION REFERENCES:
+ * DefIndex := IndexOp BuffPkgObj IndexValue Result
+ * IndexValue := TermArg=>Integer
+ * NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ * Result := SuperName
+ * SuperName := NameString | ArgObj | LocalObj | DebugObj | DefIndex
+ * Local4Op | Local5Op | Local6Op | Local7Op
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecIndex (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *IdxDesc;
+ ACPI_OPERAND_OBJECT *ResDesc;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_OPERAND_OBJECT *TmpDesc;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlExecIndex");
+
+
+ /* Resolve operands */
+ /* First operand can be either a package or a buffer */
+
+ Status = AcpiAmlResolveOperands (AML_INDEX_OP, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+ AcpiPsGetOpcodeName (AML_INDEX_OP),
+ 3, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&IdxDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AcpiAmlExecIndex/AML_INDEX_OP: bad operand(s) (0x%X)\n",
+ Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Create the internal return object */
+
+ RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+
+ /*
+ * At this point, the ObjDesc operand is either a Package or a Buffer
+ */
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ /* Object to be indexed is a Package */
+
+ if (IdxDesc->Number.Value >= ObjDesc->Package.Count)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecIndex: Index value out of range\n"));
+ Status = AE_AML_PACKAGE_LIMIT;
+ goto Cleanup;
+ }
+
+ if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) &&
+ (ResDesc->Reference.OpCode == AML_ZERO_OP))
+ {
+ /*
+ * There is no actual result descriptor (the ZeroOp Result
+ * descriptor is a placeholder), so just delete the placeholder and
+ * return a reference to the package element
+ */
+
+ AcpiCmRemoveReference (ResDesc);
+ }
+
+ else
+ {
+ /*
+ * Each element of the package is an internal object. Get the one
+ * we are after.
+ */
+
+ TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value];
+ RetDesc->Reference.OpCode = AML_INDEX_OP;
+ RetDesc->Reference.TargetType = TmpDesc->Common.Type;
+ RetDesc->Reference.Object = TmpDesc;
+
+ Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState);
+ RetDesc->Reference.Object = NULL;
+ }
+
+ /*
+ * The local return object must always be a reference to the package element,
+ * not the element itself.
+ */
+ RetDesc->Reference.OpCode = AML_INDEX_OP;
+ RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
+ RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value];
+ }
+
+ else
+ {
+ /* Object to be indexed is a Buffer */
+
+ if (IdxDesc->Number.Value >= ObjDesc->Buffer.Length)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecIndex: Index value out of range\n"));
+ Status = AE_AML_BUFFER_LIMIT;
+ goto Cleanup;
+ }
+
+ RetDesc->Reference.OpCode = AML_INDEX_OP;
+ RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ RetDesc->Reference.Object = ObjDesc;
+ RetDesc->Reference.Offset = (UINT32) IdxDesc->Number.Value;
+
+ Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState);
+ }
+
+
+Cleanup:
+
+ /* Always delete operands */
+
+ AcpiCmRemoveReference (ObjDesc);
+ AcpiCmRemoveReference (IdxDesc);
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ResDesc);
+
+ if (RetDesc)
+ {
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+ }
+
+ /* Set the return object and exit */
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecMatch
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Match operator
+ *
+ * ACPI SPECIFICATION REFERENCES:
+ * DefMatch := MatchOp SearchPkg Opcode1 Operand1
+ * Opcode2 Operand2 StartIndex
+ * Opcode1 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT
+ * Opcode2 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT
+ * Operand1 := TermArg=>Integer
+ * Operand2 := TermArg=>Integer
+ * SearchPkg := TermArg=>PackageObject
+ * StartIndex := TermArg=>Integer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecMatch (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *PkgDesc;
+ ACPI_OPERAND_OBJECT *Op1Desc;
+ ACPI_OPERAND_OBJECT *V1Desc;
+ ACPI_OPERAND_OBJECT *Op2Desc;
+ ACPI_OPERAND_OBJECT *V2Desc;
+ ACPI_OPERAND_OBJECT *StartDesc;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS Status;
+ UINT32 Index;
+ UINT32 MatchValue = (UINT32) -1;
+
+
+ FUNCTION_TRACE ("AmlExecMatch");
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (AML_MATCH_OP, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+ AcpiPsGetOpcodeName (AML_MATCH_OP),
+ 6, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ Status |= AcpiDsObjStackPopObject (&StartDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&V2Desc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&Op2Desc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&V1Desc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&Op1Desc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&PkgDesc, WalkState);
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Invalid parameters on object stack */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecMatch/AML_MATCH_OP: bad operand(s) (0x%X)\n",
+ Status));
+
+ goto Cleanup;
+ }
+
+ /* Validate match comparison sub-opcodes */
+
+ if ((Op1Desc->Number.Value > MAX_MATCH_OPERATOR) ||
+ (Op2Desc->Number.Value > MAX_MATCH_OPERATOR))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMatch: operation encoding out of range\n"));
+ Status = AE_AML_OPERAND_VALUE;
+ goto Cleanup;
+ }
+
+ Index = (UINT32) StartDesc->Number.Value;
+ if (Index >= (UINT32) PkgDesc->Package.Count)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMatch: start position value out of range\n"));
+ Status = AE_AML_PACKAGE_LIMIT;
+ goto Cleanup;
+ }
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+
+ }
+
+ /*
+ * Examine each element until a match is found. Within the loop,
+ * "continue" signifies that the current element does not match
+ * and the next should be examined.
+ * Upon finding a match, the loop will terminate via "break" at
+ * the bottom. If it terminates "normally", MatchValue will be -1
+ * (its initial value) indicating that no match was found. When
+ * returned as a Number, this will produce the Ones value as specified.
+ */
+
+ for ( ; Index < PkgDesc->Package.Count; ++Index)
+ {
+ /*
+ * Treat any NULL or non-numeric elements as non-matching.
+ * TBD [Unhandled] - if an element is a Name,
+ * should we examine its value?
+ */
+ if (!PkgDesc->Package.Elements[Index] ||
+ ACPI_TYPE_NUMBER != PkgDesc->Package.Elements[Index]->Common.Type)
+ {
+ continue;
+ }
+
+ /*
+ * Within these switch statements:
+ * "break" (exit from the switch) signifies a match;
+ * "continue" (proceed to next iteration of enclosing
+ * "for" loop) signifies a non-match.
+ */
+ switch (Op1Desc->Number.Value)
+ {
+
+ case MATCH_MTR: /* always true */
+
+ break;
+
+
+ case MATCH_MEQ: /* true if equal */
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ != V1Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MLE: /* true if less than or equal */
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ > V1Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MLT: /* true if less than */
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ >= V1Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MGE: /* true if greater than or equal */
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ < V1Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MGT: /* true if greater than */
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ <= V1Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ default: /* undefined */
+
+ continue;
+ }
+
+
+ switch(Op2Desc->Number.Value)
+ {
+
+ case MATCH_MTR:
+
+ break;
+
+
+ case MATCH_MEQ:
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ != V2Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MLE:
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ > V2Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MLT:
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ >= V2Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MGE:
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ < V2Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ case MATCH_MGT:
+
+ if (PkgDesc->Package.Elements[Index]->Number.Value
+ <= V2Desc->Number.Value)
+ {
+ continue;
+ }
+ break;
+
+
+ default:
+
+ continue;
+ }
+
+ /* Match found: exit from loop */
+
+ MatchValue = Index;
+ break;
+ }
+
+ /* MatchValue is the return value */
+
+ RetDesc->Number.Value = MatchValue;
+
+
+Cleanup:
+
+ /* Free the operands */
+
+ AcpiCmRemoveReference (StartDesc);
+ AcpiCmRemoveReference (V2Desc);
+ AcpiCmRemoveReference (Op2Desc);
+ AcpiCmRemoveReference (V1Desc);
+ AcpiCmRemoveReference (Op1Desc);
+ AcpiCmRemoveReference (PkgDesc);
+
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+
+ /* Set the return object and exit */
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c
new file mode 100644
index 0000000..dbba804
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c
@@ -0,0 +1,1183 @@
+
+/******************************************************************************
+ *
+ * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators
+ * $Revision: 81 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMMONAD_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("ammonad")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlGetObjectReference
+ *
+ * PARAMETERS: ObjDesc - Create a reference to this object
+ * RetDesc - Where to store the reference
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Obtain and return a "reference" to the target object
+ * Common code for the RefOfOp and the CondRefOfOp.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlGetObjectReference (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **RetDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_PTR ("AmlGetObjectReference", ObjDesc);
+
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
+ {
+ if (ObjDesc->Common.Type != INTERNAL_TYPE_REFERENCE)
+ {
+ *RetDesc = NULL;
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+
+ /*
+ * Not a Name -- an indirect name pointer would have
+ * been converted to a direct name pointer in AcpiAmlResolveOperands
+ */
+ switch (ObjDesc->Reference.OpCode)
+ {
+ case AML_LOCAL_OP:
+
+ *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_LOCAL,
+ (ObjDesc->Reference.Offset), WalkState);
+ break;
+
+
+ case AML_ARG_OP:
+
+ *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_ARG,
+ (ObjDesc->Reference.Offset), WalkState);
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlGetObjectReference: (Internal) Unknown Ref subtype %02x\n",
+ ObjDesc->Reference.OpCode));
+ *RetDesc = NULL;
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ }
+
+ else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /* Must be a named object; Just return the Node */
+
+ *RetDesc = ObjDesc;
+ }
+
+ else
+ {
+ *RetDesc = NULL;
+ Status = AE_TYPE;
+ }
+
+
+Cleanup:
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlGetObjectReference: Obj=%p Ref=%p\n", ObjDesc, *RetDesc));
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecMonadic1
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
+ * object stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecMonadic1 (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecMonadic1", WALK_OPERANDS);
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+ AcpiPsGetOpcodeName (Opcode),
+ 1, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecMonadic1/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Examine the opcode */
+
+ switch (Opcode)
+ {
+
+ /* DefRelease := ReleaseOp MutexObject */
+
+ case AML_RELEASE_OP:
+
+ Status = AcpiAmlSystemReleaseMutex (ObjDesc);
+ break;
+
+
+ /* DefReset := ResetOp AcpiEventObject */
+
+ case AML_RESET_OP:
+
+ Status = AcpiAmlSystemResetEvent (ObjDesc);
+ break;
+
+
+ /* DefSignal := SignalOp AcpiEventObject */
+
+ case AML_SIGNAL_OP:
+
+ Status = AcpiAmlSystemSignalEvent (ObjDesc);
+ break;
+
+
+ /* DefSleep := SleepOp MsecTime */
+
+ case AML_SLEEP_OP:
+
+ AcpiAmlSystemDoSuspend ((UINT32) ObjDesc->Number.Value);
+ break;
+
+
+ /* DefStall := StallOp UsecTime */
+
+ case AML_STALL_OP:
+
+ AcpiAmlSystemDoStall ((UINT32) ObjDesc->Number.Value);
+ break;
+
+
+ /* Unknown opcode */
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecMonadic1: Unknown monadic opcode %X\n",
+ Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+
+ } /* switch */
+
+
+Cleanup:
+
+ /* Always delete the operand */
+
+ AcpiCmRemoveReference (ObjDesc);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecMonadic2R
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 monadic operator with numeric operand and
+ * result operand on operand stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecMonadic2R (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *ResDesc;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_OPERAND_OBJECT *RetDesc2 = NULL;
+ UINT32 ResVal;
+ ACPI_STATUS Status;
+ UINT32 d0;
+ UINT32 d1;
+ UINT32 d2;
+ UINT32 d3;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecMonadic2R", WALK_OPERANDS);
+
+
+ /* Resolve all operands */
+
+ Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+ AcpiPsGetOpcodeName (Opcode),
+ 2, "after AcpiAmlResolveOperands");
+
+ /* Get all operands */
+
+ Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState);
+ Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecMonadic2R/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+
+ /* Create a return object of type NUMBER for most opcodes */
+
+ switch (Opcode)
+ {
+ case AML_BIT_NOT_OP:
+ case AML_FIND_SET_LEFT_BIT_OP:
+ case AML_FIND_SET_RIGHT_BIT_OP:
+ case AML_FROM_BCD_OP:
+ case AML_TO_BCD_OP:
+ case AML_COND_REF_OF_OP:
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ break;
+ }
+
+
+ switch (Opcode)
+ {
+ /* DefNot := NotOp Operand Result */
+
+ case AML_BIT_NOT_OP:
+
+ RetDesc->Number.Value = ~ObjDesc->Number.Value;
+ break;
+
+
+ /* DefFindSetLeftBit := FindSetLeftBitOp Operand Result */
+
+ case AML_FIND_SET_LEFT_BIT_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value;
+
+ /*
+ * Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundry condition is valid.
+ */
+ for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal)
+ {
+ RetDesc->Number.Value >>= 1;
+ }
+
+ RetDesc->Number.Value = ResVal;
+ break;
+
+
+ /* DefFindSetRightBit := FindSetRightBitOp Operand Result */
+
+ case AML_FIND_SET_RIGHT_BIT_OP:
+
+ RetDesc->Number.Value = ObjDesc->Number.Value;
+
+ /*
+ * Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundry condition is valid.
+ */
+ for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal)
+ {
+ RetDesc->Number.Value <<= 1;
+ }
+
+ /* Since returns must be 1-based, subtract from 33 (65) */
+
+ RetDesc->Number.Value = ResVal == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - ResVal;
+ break;
+
+
+ /* DefFromBDC := FromBCDOp BCDValue Result */
+
+ case AML_FROM_BCD_OP:
+
+ d0 = (UINT32) (ObjDesc->Number.Value & 15);
+ d1 = (UINT32) (ObjDesc->Number.Value >> 4 & 15);
+ d2 = (UINT32) (ObjDesc->Number.Value >> 8 & 15);
+ d3 = (UINT32) (ObjDesc->Number.Value >> 12 & 15);
+
+ if (d0 > 9 || d1 > 9 || d2 > 9 || d3 > 9)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("Monadic2R/FromBCDOp: BCD digit too large %d %d %d %d\n",
+ d3, d2, d1, d0));
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+
+ RetDesc->Number.Value = d0 + d1 * 10 + d2 * 100 + d3 * 1000;
+ break;
+
+
+ /* DefToBDC := ToBCDOp Operand Result */
+
+ case AML_TO_BCD_OP:
+
+
+ if (ObjDesc->Number.Value > 9999)
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("Monadic2R/ToBCDOp: BCD overflow: %d\n",
+ ObjDesc->Number.Value));
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+
+ RetDesc->Number.Value
+ = ObjDesc->Number.Value % 10
+ + (ObjDesc->Number.Value / 10 % 10 << 4)
+ + (ObjDesc->Number.Value / 100 % 10 << 8)
+ + (ObjDesc->Number.Value / 1000 % 10 << 12);
+
+ break;
+
+
+ /* DefCondRefOf := CondRefOfOp SourceObject Result */
+
+ case AML_COND_REF_OF_OP:
+
+ /*
+ * This op is a little strange because the internal return value is
+ * different than the return value stored in the result descriptor
+ * (There are really two return values)
+ */
+
+ if ((ACPI_NAMESPACE_NODE *) ObjDesc == AcpiGbl_RootNode)
+ {
+ /*
+ * This means that the object does not exist in the namespace,
+ * return FALSE
+ */
+
+ RetDesc->Number.Value = 0;
+
+ /*
+ * Must delete the result descriptor since there is no reference
+ * being returned
+ */
+
+ AcpiCmRemoveReference (ResDesc);
+ goto Cleanup;
+ }
+
+ /* Get the object reference and store it */
+
+ Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc2, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiAmlExecStore (RetDesc2, ResDesc, WalkState);
+
+ /* The object exists in the namespace, return TRUE */
+
+ RetDesc->Number.Value = ACPI_INTEGER_MAX
+ goto Cleanup;
+ break;
+
+
+ case AML_STORE_OP:
+
+ /*
+ * A store operand is typically a number, string, buffer or lvalue
+ * TBD: [Unhandled] What about a store to a package?
+ */
+
+ /*
+ * Do the store, and be careful about deleting the source object,
+ * since the object itself may have been stored.
+ */
+
+ Status = AcpiAmlExecStore (ObjDesc, ResDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* On failure, just delete the ObjDesc */
+
+ AcpiCmRemoveReference (ObjDesc);
+ }
+
+ else
+ {
+ /*
+ * Normally, we would remove a reference on the ObjDesc parameter;
+ * But since it is being used as the internal return object
+ * (meaning we would normally increment it), the two cancel out,
+ * and we simply don't do anything.
+ */
+ *ReturnDesc = ObjDesc;
+ }
+
+ ObjDesc = NULL;
+ return_ACPI_STATUS (Status);
+
+ break;
+
+
+ case AML_DEBUG_OP:
+
+ /* Reference, returning an Reference */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMonadic2R: DebugOp should never get here!\n"));
+ return_ACPI_STATUS (AE_OK);
+ break;
+
+
+ /*
+ * These are obsolete opcodes
+ */
+
+ /* DefShiftLeftBit := ShiftLeftBitOp Source BitNum */
+ /* DefShiftRightBit := ShiftRightBitOp Source BitNum */
+
+ case AML_SHIFT_LEFT_BIT_OP:
+ case AML_SHIFT_RIGHT_BIT_OP:
+
+ DEBUG_PRINT (ACPI_ERROR, ("AmlExecMonadic2R: %s unimplemented\n",
+ AcpiPsGetOpcodeName (Opcode)));
+ Status = AE_SUPPORT;
+ goto Cleanup;
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecMonadic2R: Unknown monadic opcode %X\n",
+ Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState);
+
+
+Cleanup:
+ /* Always delete the operand object */
+
+ AcpiCmRemoveReference (ObjDesc);
+
+ /* Delete return object(s) on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ResDesc); /* Result descriptor */
+ if (RetDesc)
+ {
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+ }
+
+ /* Set the return object and exit */
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecMonadic2
+ *
+ * PARAMETERS: Opcode - The opcode to be executed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 monadic operator with numeric operand:
+ * DerefOfOp, RefOfOp, SizeOfOp, TypeOp, IncrementOp,
+ * DecrementOp, LNotOp,
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecMonadic2 (
+ UINT16 Opcode,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *TmpDesc;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS ResolveStatus;
+ ACPI_STATUS Status;
+ UINT32 Type;
+ ACPI_INTEGER Value;
+
+
+ FUNCTION_TRACE_PTR ("AmlExecMonadic2", WALK_OPERANDS);
+
+
+ /* Attempt to resolve the operands */
+
+ ResolveStatus = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState);
+ DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+ AcpiPsGetOpcodeName (Opcode),
+ 1, "after AcpiAmlResolveOperands");
+
+ /* Always get all operands */
+
+ Status = AcpiDsObjStackPopObject (&ObjDesc, WalkState);
+
+
+ /* Now we can check the status codes */
+
+ if (ACPI_FAILURE (ResolveStatus))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecMonadic2[%s]: Could not resolve operands, %s\n",
+ AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (ResolveStatus)));
+
+ goto Cleanup;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecMonadic2[%s]: Bad operand(s), %s\n",
+ AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (Status)));
+
+ goto Cleanup;
+ }
+
+
+ /* Get the operand and decode the opcode */
+
+
+ switch (Opcode)
+ {
+
+ /* DefLNot := LNotOp Operand */
+
+ case AML_LNOT_OP:
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Number.Value = !ObjDesc->Number.Value;
+ break;
+
+
+ /* DefDecrement := DecrementOp Target */
+ /* DefIncrement := IncrementOp Target */
+
+ case AML_DECREMENT_OP:
+ case AML_INCREMENT_OP:
+
+ /*
+ * Since we are expecting an Reference on the top of the stack, it
+ * can be either an Node or an internal object.
+ *
+ * TBD: [Future] This may be the prototype code for all cases where
+ * an Reference is expected!! 10/99
+ */
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ RetDesc = ObjDesc;
+ }
+
+ else
+ {
+ /*
+ * Duplicate the Reference in a new object so that we can resolve it
+ * without destroying the original Reference object
+ */
+
+ RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Reference.OpCode = ObjDesc->Reference.OpCode;
+ RetDesc->Reference.Offset = ObjDesc->Reference.Offset;
+ RetDesc->Reference.Object = ObjDesc->Reference.Object;
+ }
+
+
+ /*
+ * Convert the RetDesc Reference to a Number
+ * (This deletes the original RetDesc)
+ */
+
+ Status = AcpiAmlResolveOperands (AML_LNOT_OP, &RetDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ExecMonadic2/%s: bad operand(s) (0x%X)\n",
+ AcpiPsGetOpcodeName (Opcode), Status));
+
+ goto Cleanup;
+ }
+
+ /* Do the actual increment or decrement */
+
+ if (AML_INCREMENT_OP == Opcode)
+ {
+ RetDesc->Number.Value++;
+ }
+ else
+ {
+ RetDesc->Number.Value--;
+ }
+
+ /* Store the result back in the original descriptor */
+
+ Status = AcpiAmlExecStore (RetDesc, ObjDesc, WalkState);
+
+ /* Objdesc was just deleted (because it is an Reference) */
+
+ ObjDesc = NULL;
+
+ break;
+
+
+ /* DefObjectType := ObjectTypeOp SourceObject */
+
+ case AML_TYPE_OP:
+
+ if (INTERNAL_TYPE_REFERENCE == ObjDesc->Common.Type)
+ {
+ /*
+ * Not a Name -- an indirect name pointer would have
+ * been converted to a direct name pointer in ResolveOperands
+ */
+ switch (ObjDesc->Reference.OpCode)
+ {
+ case AML_ZERO_OP:
+ case AML_ONE_OP:
+ case AML_ONES_OP:
+
+ /* Constants are of type Number */
+
+ Type = ACPI_TYPE_NUMBER;
+ break;
+
+
+ case AML_DEBUG_OP:
+
+ /* Per 1.0b spec, Debug object is of type DebugObject */
+
+ Type = ACPI_TYPE_DEBUG_OBJECT;
+ break;
+
+
+ case AML_INDEX_OP:
+
+ /* Get the type of this reference (index into another object) */
+
+ Type = ObjDesc->Reference.TargetType;
+ if (Type == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * The main object is a package, we want to get the type
+ * of the individual package element that is referenced by
+ * the index.
+ */
+ Type = (*(ObjDesc->Reference.Where))->Common.Type;
+ }
+
+ break;
+
+
+ case AML_LOCAL_OP:
+
+ Type = AcpiDsMethodDataGetType (MTH_TYPE_LOCAL,
+ (ObjDesc->Reference.Offset), WalkState);
+ break;
+
+
+ case AML_ARG_OP:
+
+ Type = AcpiDsMethodDataGetType (MTH_TYPE_ARG,
+ (ObjDesc->Reference.Offset), WalkState);
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecMonadic2/TypeOp: Internal error - Unknown Reference subtype %X\n",
+ ObjDesc->Reference.OpCode));
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+ }
+
+ else
+ {
+ /*
+ * It's not a Reference, so it must be a direct name pointer.
+ */
+ Type = AcpiNsGetType ((ACPI_HANDLE) ObjDesc);
+ }
+
+ /* Allocate a descriptor to hold the type. */
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Number.Value = Type;
+ break;
+
+
+ /* DefSizeOf := SizeOfOp SourceObject */
+
+ case AML_SIZE_OF_OP:
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ ObjDesc = AcpiNsGetAttachedObject (ObjDesc);
+ }
+
+ if (!ObjDesc)
+ {
+ Value = 0;
+ }
+
+ else
+ {
+ switch (ObjDesc->Common.Type)
+ {
+
+ case ACPI_TYPE_BUFFER:
+
+ Value = ObjDesc->Buffer.Length;
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ Value = ObjDesc->String.Length;
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ Value = ObjDesc->Package.Count;
+ break;
+
+ case INTERNAL_TYPE_REFERENCE:
+
+ Value = 4;
+ break;
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMonadic2: Not Buf/Str/Pkg - found type 0x%X\n",
+ ObjDesc->Common.Type));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ }
+
+ /*
+ * Now that we have the size of the object, create a result
+ * object to hold the value
+ */
+
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Number.Value = Value;
+ break;
+
+
+ /* DefRefOf := RefOfOp SourceObject */
+
+ case AML_REF_OF_OP:
+
+ Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ /* DefDerefOf := DerefOfOp ObjReference */
+
+ case AML_DEREF_OF_OP:
+
+
+ /* Check for a method local or argument */
+
+ if (!VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /*
+ * Must resolve/dereference the local/arg reference first
+ */
+ switch (ObjDesc->Reference.OpCode)
+ {
+ /* Set ObjDesc to the value of the local/arg */
+
+ case AML_LOCAL_OP:
+
+ AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL,
+ (ObjDesc->Reference.Offset), WalkState, &TmpDesc);
+
+ /*
+ * Delete our reference to the input object and
+ * point to the object just retrieved
+ */
+ AcpiCmRemoveReference (ObjDesc);
+ ObjDesc = TmpDesc;
+ break;
+
+
+ case AML_ARG_OP:
+
+ AcpiDsMethodDataGetValue (MTH_TYPE_ARG,
+ (ObjDesc->Reference.Offset), WalkState, &TmpDesc);
+
+ /*
+ * Delete our reference to the input object and
+ * point to the object just retrieved
+ */
+ AcpiCmRemoveReference (ObjDesc);
+ ObjDesc = TmpDesc;
+ break;
+
+ default:
+
+ /* Index op - handled below */
+ break;
+ }
+ }
+
+
+ /* ObjDesc may have changed from the code above */
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /* Get the actual object from the Node (This is the dereference) */
+
+ RetDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object;
+
+ /* Returning a pointer to the object, add another reference! */
+
+ AcpiCmAddReference (RetDesc);
+ }
+
+ else
+ {
+ /*
+ * This must be a reference object produced by the Index
+ * ASL operation -- check internal opcode
+ */
+
+ if ((ObjDesc->Reference.OpCode != AML_INDEX_OP) &&
+ (ObjDesc->Reference.OpCode != AML_REF_OF_OP))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMonadic2: DerefOf, invalid obj ref %p\n",
+ ObjDesc));
+
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+
+
+ switch (ObjDesc->Reference.OpCode)
+ {
+ case AML_INDEX_OP:
+
+ /*
+ * Supported target types for the Index operator are
+ * 1) A Buffer
+ * 2) A Package
+ */
+
+ if (ObjDesc->Reference.TargetType == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * The target is a buffer, we must create a new object that
+ * contains one element of the buffer, the element pointed
+ * to by the index.
+ *
+ * NOTE: index into a buffer is NOT a pointer to a
+ * sub-buffer of the main buffer, it is only a pointer to a
+ * single element (byte) of the buffer!
+ */
+ RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ TmpDesc = ObjDesc->Reference.Object;
+ RetDesc->Number.Value =
+ TmpDesc->Buffer.Pointer[ObjDesc->Reference.Offset];
+
+ /* TBD: [Investigate] (see below) Don't add an additional
+ * ref!
+ */
+ }
+
+ else if (ObjDesc->Reference.TargetType == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * The target is a package, we want to return the referenced
+ * element of the package. We must add another reference to
+ * this object, however.
+ */
+
+ RetDesc = *(ObjDesc->Reference.Where);
+ if (!RetDesc)
+ {
+ /*
+ * We can't return a NULL dereferenced value. This is
+ * an uninitialized package element and is thus a
+ * severe error.
+ */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMonadic2: DerefOf, NULL package element obj %p\n",
+ ObjDesc));
+ Status = AE_AML_UNINITIALIZED_ELEMENT;
+ goto Cleanup;
+ }
+
+ AcpiCmAddReference (RetDesc);
+ }
+
+ else
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecMonadic2: DerefOf, Unknown TargetType %X in obj %p\n",
+ ObjDesc->Reference.TargetType, ObjDesc));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ break;
+
+
+ case AML_REF_OF_OP:
+
+ RetDesc = ObjDesc->Reference.Object;
+
+ /* Add another reference to the object! */
+
+ AcpiCmAddReference (RetDesc);
+ break;
+ }
+ }
+
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiAmlExecMonadic2: Unknown monadic opcode %X\n",
+ Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ if (ObjDesc)
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ }
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiCmRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+ *ReturnDesc = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c
new file mode 100644
index 0000000..60de051
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c
@@ -0,0 +1,551 @@
+
+/******************************************************************************
+ *
+ * Module Name: amnames - interpreter/scanner name load/execute
+ * $Revision: 71 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMNAMES_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amnames")
+
+
+/* AML Package Length encodings */
+
+#define ACPI_AML_PACKAGE_TYPE1 0x40
+#define ACPI_AML_PACKAGE_TYPE2 0x4000
+#define ACPI_AML_PACKAGE_TYPE3 0x400000
+#define ACPI_AML_PACKAGE_TYPE4 0x40000000
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlAllocateNameString
+ *
+ * PARAMETERS: PrefixCount - Count of parent levels. Special cases:
+ * (-1) = root, 0 = none
+ * NumNameSegs - count of 4-character name segments
+ *
+ * RETURN: A pointer to the allocated string segment. This segment must
+ * be deleted by the caller.
+ *
+ * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name
+ * string is long enough, and set up prefix if any.
+ *
+ ******************************************************************************/
+
+NATIVE_CHAR *
+AcpiAmlAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs)
+{
+ NATIVE_CHAR *TempPtr;
+ NATIVE_CHAR *NameString;
+ UINT32 SizeNeeded;
+
+ FUNCTION_TRACE ("AmlAllocateNameString");
+
+
+ /*
+ * Allow room for all \ and ^ prefixes, all segments, and a MultiNamePrefix.
+ * Also, one byte for the null terminator.
+ * This may actually be somewhat longer than needed.
+ */
+
+ if (PrefixCount == (UINT32) -1)
+ {
+ /* Special case for root */
+
+ SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
+ }
+ else
+ {
+ SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
+ }
+
+ /*
+ * Allocate a buffer for the name.
+ * This buffer must be deleted by the caller!
+ */
+
+ NameString = AcpiCmAllocate (SizeNeeded);
+ if (!NameString)
+ {
+ REPORT_ERROR (("AmlAllocateNameString: name allocation failure\n"));
+ return_PTR (NULL);
+ }
+
+ TempPtr = NameString;
+
+ /* Set up Root or Parent prefixes if needed */
+
+ if (PrefixCount == (UINT32) -1)
+ {
+ *TempPtr++ = AML_ROOT_PREFIX;
+ }
+
+ else
+ {
+ while (PrefixCount--)
+ {
+ *TempPtr++ = AML_PARENT_PREFIX;
+ }
+ }
+
+
+ /* Set up Dual or Multi prefixes if needed */
+
+ if (NumNameSegs > 2)
+ {
+ /* Set up multi prefixes */
+
+ *TempPtr++ = AML_MULTI_NAME_PREFIX_OP;
+ *TempPtr++ = (char) NumNameSegs;
+ }
+
+ else if (2 == NumNameSegs)
+ {
+ /* Set up dual prefixes */
+
+ *TempPtr++ = AML_DUAL_NAME_PREFIX;
+ }
+
+ /*
+ * Terminate string following prefixes. AcpiAmlExecNameSegment() will
+ * append the segment(s)
+ */
+
+ *TempPtr = 0;
+
+ return_PTR (NameString);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecNameSegment
+ *
+ * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a name segment (4 bytes)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecNameSegment (
+ UINT8 **InAmlAddress,
+ NATIVE_CHAR *NameString)
+{
+ UINT8 *AmlAddress = *InAmlAddress;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Index;
+ NATIVE_CHAR CharBuf[5];
+
+
+ FUNCTION_TRACE ("AmlExecNameSegment");
+
+
+ /*
+ * If first character is a digit, then we know that we aren't looking at a
+ * valid name segment
+ */
+
+ CharBuf[0] = *AmlAddress;
+
+ if ('0' <= CharBuf[0] && CharBuf[0] <= '9')
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecNameSegment: leading digit: %c\n", CharBuf[0]));
+ return_ACPI_STATUS (AE_CTRL_PENDING);
+ }
+
+ DEBUG_PRINT (TRACE_LOAD, ("AmlExecNameSegment: Bytes from stream:\n"));
+
+ for (Index = 4;
+ (Index > 0) && (AcpiCmValidAcpiCharacter (*AmlAddress));
+ --Index)
+ {
+ CharBuf[4 - Index] = *AmlAddress++;
+ DEBUG_PRINT (TRACE_LOAD, ("%c\n", CharBuf[4 - Index]));
+ }
+
+
+ /* Valid name segment */
+
+ if (0 == Index)
+ {
+ /* Found 4 valid characters */
+
+ CharBuf[4] = '\0';
+
+ if (NameString)
+ {
+ STRCAT (NameString, CharBuf);
+ DEBUG_PRINT (TRACE_NAMES,
+ ("AmlExecNameSegment: Appended to - %s \n", NameString));
+ }
+
+ else
+ {
+ DEBUG_PRINT (TRACE_NAMES,
+ ("AmlExecNameSegment: No Name string - %s \n", CharBuf));
+ }
+ }
+
+ else if (4 == Index)
+ {
+ /*
+ * First character was not a valid name character,
+ * so we are looking at something other than a name.
+ */
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlExecNameSegment: Leading INT8 not alpha: %02Xh (not a name)\n",
+ CharBuf[0]));
+ Status = AE_CTRL_PENDING;
+ }
+
+ else
+ {
+ /* Segment started with one or more valid characters, but fewer than 4 */
+
+ Status = AE_AML_BAD_NAME;
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecNameSegment: Bad INT8 %02x in name, at %p\n",
+ *AmlAddress, AmlAddress));
+ }
+
+ DEBUG_PRINT (TRACE_EXEC, ("Leave AcpiAmlExecNameSegment %s \n",
+ AcpiCmFormatException (Status)));
+
+ *InAmlAddress = AmlAddress;
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlGetNameString
+ *
+ * PARAMETERS: DataType - Data type to be associated with this name
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get a name, including any prefixes.
+ *
+ ******************************************************************************/
+
+
+ACPI_STATUS
+AcpiAmlGetNameString (
+ OBJECT_TYPE_INTERNAL DataType,
+ UINT8 *InAmlAddress,
+ NATIVE_CHAR **OutNameString,
+ UINT32 *OutNameLength)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 *AmlAddress = InAmlAddress;
+ NATIVE_CHAR *NameString = NULL;
+ UINT32 NumSegments;
+ UINT32 PrefixCount = 0;
+ UINT8 Prefix = 0;
+ BOOLEAN HasPrefix = FALSE;
+
+
+ FUNCTION_TRACE_PTR ("AmlGetNameString", AmlAddress);
+
+
+ if (INTERNAL_TYPE_DEF_FIELD == DataType ||
+ INTERNAL_TYPE_BANK_FIELD == DataType ||
+ INTERNAL_TYPE_INDEX_FIELD == DataType)
+ {
+ /* Disallow prefixes for types associated with field names */
+
+ NameString = AcpiAmlAllocateNameString (0, 1);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ else
+ {
+ Status = AcpiAmlExecNameSegment (&AmlAddress, NameString);
+ }
+ }
+
+ else
+ {
+ /*
+ * DataType is not a field name.
+ * Examine first character of name for root or parent prefix operators
+ */
+
+ switch (*AmlAddress)
+ {
+
+ case AML_ROOT_PREFIX:
+
+ Prefix = *AmlAddress++;
+ DEBUG_PRINT (TRACE_LOAD, ("RootPrefix: %x\n", Prefix));
+
+ /*
+ * Remember that we have a RootPrefix --
+ * see comment in AcpiAmlAllocateNameString()
+ */
+ PrefixCount = (UINT32) -1;
+ HasPrefix = TRUE;
+ break;
+
+
+ case AML_PARENT_PREFIX:
+
+ /* Increment past possibly multiple parent prefixes */
+
+ do
+ {
+ Prefix = *AmlAddress++;
+ DEBUG_PRINT (TRACE_LOAD, ("ParentPrefix: %x\n", Prefix));
+
+ ++PrefixCount;
+
+ } while (*AmlAddress == AML_PARENT_PREFIX);
+ HasPrefix = TRUE;
+ break;
+
+
+ default:
+
+ break;
+ }
+
+
+ /* Examine first character of name for name segment prefix operator */
+
+ switch (*AmlAddress)
+ {
+
+ case AML_DUAL_NAME_PREFIX:
+
+ Prefix = *AmlAddress++;
+ DEBUG_PRINT (TRACE_LOAD, ("DualNamePrefix: %x\n", Prefix));
+
+ NameString = AcpiAmlAllocateNameString (PrefixCount, 2);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ /* Indicate that we processed a prefix */
+ HasPrefix = TRUE;
+
+ Status = AcpiAmlExecNameSegment (&AmlAddress, NameString);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiAmlExecNameSegment (&AmlAddress, NameString);
+ }
+ break;
+
+
+ case AML_MULTI_NAME_PREFIX_OP:
+
+ Prefix = *AmlAddress++;
+ DEBUG_PRINT (TRACE_LOAD, ("MultiNamePrefix: %x\n", Prefix));
+
+ /* Fetch count of segments remaining in name path */
+
+ NumSegments = *AmlAddress++;
+
+ NameString = AcpiAmlAllocateNameString (PrefixCount, NumSegments);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ /* Indicate that we processed a prefix */
+ HasPrefix = TRUE;
+
+ while (NumSegments &&
+ (Status = AcpiAmlExecNameSegment (&AmlAddress, NameString)) == AE_OK)
+ {
+ --NumSegments;
+ }
+
+ break;
+
+
+ case 0:
+
+ /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
+
+ if (-1 == PrefixCount)
+ {
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlDoName: NameSeg is \"\\\" followed by NULL\n"));
+ }
+
+ /* Consume the NULL byte */
+
+ AmlAddress++;
+ NameString = AcpiAmlAllocateNameString (PrefixCount, 0);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ break;
+
+
+ default:
+
+ /* Name segment string */
+
+ NameString = AcpiAmlAllocateNameString (PrefixCount, 1);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ Status = AcpiAmlExecNameSegment (&AmlAddress, NameString);
+ break;
+
+ } /* Switch (PeekOp ()) */
+ }
+
+
+ if (AE_CTRL_PENDING == Status && HasPrefix)
+ {
+ /* Ran out of segments after processing a prefix */
+
+ REPORT_ERROR (
+ ("AmlDoName: Malformed Name at %p\n", NameString));
+ Status = AE_AML_BAD_NAME;
+ }
+
+
+ *OutNameString = NameString;
+ *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c
new file mode 100644
index 0000000..5771610
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c
@@ -0,0 +1,580 @@
+
+/******************************************************************************
+ *
+ * Module Name: amprep - ACPI AML (p-code) execution - field prep utilities
+ * $Revision: 67 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMPREP_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acparser.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amprep")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlDecodeFieldAccessType
+ *
+ * PARAMETERS: Access - Encoded field access bits
+ *
+ * RETURN: Field granularity (8, 16, or 32)
+ *
+ * DESCRIPTION: Decode the AccessType bits of a field definition.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiAmlDecodeFieldAccessType (
+ UINT32 Access)
+{
+
+ switch (Access)
+ {
+ case ACCESS_ANY_ACC:
+ return (8);
+ break;
+
+ case ACCESS_BYTE_ACC:
+ return (8);
+ break;
+
+ case ACCESS_WORD_ACC:
+ return (16);
+ break;
+
+ case ACCESS_DWORD_ACC:
+ return (32);
+ break;
+
+ default:
+ /* Invalid field access type */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlDecodeFieldAccessType: Unknown field access type %x\n",
+ Access));
+ return (0);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlPrepCommonFieldObjec
+ *
+ * PARAMETERS: ObjDesc - The field object
+ * FieldFlags - Access, LockRule, or UpdateRule.
+ * The format of a FieldFlag is described
+ * in the ACPI specification
+ * FieldPosition - Field position
+ * FieldLength - Field length
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize the areas of the field object that are common
+ * to the various types of fields.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlPrepCommonFieldObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT8 FieldAttribute,
+ UINT32 FieldPosition,
+ UINT32 FieldLength)
+{
+ UINT32 Granularity;
+
+
+ FUNCTION_TRACE ("AmlPrepCommonFieldObject");
+
+
+ /*
+ * Note: the structure being initialized is the
+ * ACPI_COMMON_FIELD_INFO; Therefore, we can just use the Field union to
+ * access this common area. No structure fields outside of the common area
+ * are initialized by this procedure.
+ */
+
+ /* Decode the FieldFlags */
+
+ ObjDesc->Field.Access = (UINT8) ((FieldFlags & ACCESS_TYPE_MASK)
+ >> ACCESS_TYPE_SHIFT);
+ ObjDesc->Field.LockRule = (UINT8) ((FieldFlags & LOCK_RULE_MASK)
+ >> LOCK_RULE_SHIFT);
+ ObjDesc->Field.UpdateRule = (UINT8) ((FieldFlags & UPDATE_RULE_MASK)
+ >> UPDATE_RULE_SHIFT);
+
+ /* Other misc fields */
+
+ ObjDesc->Field.Length = (UINT16) FieldLength;
+ ObjDesc->Field.AccessAttribute = FieldAttribute;
+
+ /* Decode the access type so we can compute offsets */
+
+ Granularity = AcpiAmlDecodeFieldAccessType (ObjDesc->Field.Access);
+ if (!Granularity)
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+ /* Access granularity based fields */
+
+ ObjDesc->Field.Granularity = (UINT8) Granularity;
+ ObjDesc->Field.BitOffset = (UINT8) (FieldPosition % Granularity);
+ ObjDesc->Field.Offset = (UINT32) FieldPosition / Granularity;
+
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlPrepDefFieldValue
+ *
+ * PARAMETERS: Node - Owning Node
+ * Region - Region in which field is being defined
+ * FieldFlags - Access, LockRule, or UpdateRule.
+ * The format of a FieldFlag is described
+ * in the ACPI specification
+ * FieldPosition - Field position
+ * FieldLength - Field length
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
+ * connect it to the parent Node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlPrepDefFieldValue (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_HANDLE Region,
+ UINT8 FieldFlags,
+ UINT8 FieldAttribute,
+ UINT32 FieldPosition,
+ UINT32 FieldLength)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ UINT32 Type;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlPrepDefFieldValue");
+
+
+ /* Parameter validation */
+
+ if (!Region)
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: null Region\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ Type = AcpiNsGetType (Region);
+ if (Type != ACPI_TYPE_REGION)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlPrepDefFieldValue: Needed Region, found %d %s\n",
+ Type, AcpiCmGetTypeName (Type)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Allocate a new object */
+
+ ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_DEF_FIELD);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+
+ /* ObjDesc and Region valid */
+
+ DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE,
+ "AmlPrepDefFieldValue", 1, "case DefField");
+ DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE,
+ "AmlPrepDefFieldValue", 1, "case DefField");
+
+ /* Initialize areas of the object that are common to all fields */
+
+ Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute,
+ FieldPosition, FieldLength);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize areas of the object that are specific to this field type */
+
+ ObjDesc->Field.Container = AcpiNsGetAttachedObject (Region);
+
+ /* An additional reference for the container */
+
+ AcpiCmAddReference (ObjDesc->Field.Container);
+
+
+ /* Debug info */
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlPrepDefFieldValue: bitoff=%X off=%X gran=%X\n",
+ ObjDesc->Field.BitOffset, ObjDesc->Field.Offset,
+ ObjDesc->Field.Granularity));
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlPrepDefFieldValue: set NamedObj %p (%4.4s) val = %p\n",
+ Node, &(Node->Name), ObjDesc));
+
+ DUMP_STACK_ENTRY (ObjDesc);
+ DUMP_ENTRY (Region, ACPI_INFO);
+ DEBUG_PRINT (ACPI_INFO, ("\t%p \n", ObjDesc->Field.Container));
+ if (ObjDesc->Field.Container)
+ {
+ DUMP_STACK_ENTRY (ObjDesc->Field.Container);
+ }
+ DEBUG_PRINT (ACPI_INFO,
+ ("============================================================\n"));
+
+ /*
+ * Store the constructed descriptor (ObjDesc) into the NamedObj whose
+ * handle is on TOS, preserving the current type of that NamedObj.
+ */
+ Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
+ (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlPrepBankFieldValue
+ *
+ * PARAMETERS: Node - Owning Node
+ * Region - Region in which field is being defined
+ * BankReg - Bank selection register
+ * BankVal - Value to store in selection register
+ * FieldFlags - Access, LockRule, or UpdateRule
+ * FieldPosition - Field position
+ * FieldLength - Field length
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type BankField and
+ * connect it to the parent Node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlPrepBankFieldValue (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_HANDLE Region,
+ ACPI_HANDLE BankReg,
+ UINT32 BankVal,
+ UINT8 FieldFlags,
+ UINT8 FieldAttribute,
+ UINT32 FieldPosition,
+ UINT32 FieldLength)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ UINT32 Type;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlPrepBankFieldValue");
+
+
+ /* Parameter validation */
+
+ if (!Region)
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: null Region\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ Type = AcpiNsGetType (Region);
+ if (Type != ACPI_TYPE_REGION)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlPrepBankFieldValue: Needed Region, found %d %s\n",
+ Type, AcpiCmGetTypeName (Type)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Allocate a new object */
+
+ ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_BANK_FIELD);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* ObjDesc and Region valid */
+
+ DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE,
+ "AmlPrepBankFieldValue", 1, "case BankField");
+ DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE,
+ "AmlPrepBankFieldValue", 1, "case BankField");
+
+ /* Initialize areas of the object that are common to all fields */
+
+ Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute,
+ FieldPosition, FieldLength);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize areas of the object that are specific to this field type */
+
+ ObjDesc->BankField.Value = BankVal;
+ ObjDesc->BankField.Container = AcpiNsGetAttachedObject (Region);
+ ObjDesc->BankField.BankSelect = AcpiNsGetAttachedObject (BankReg);
+
+ /* An additional reference for the container and bank select */
+ /* TBD: [Restructure] is "BankSelect" ever a real internal object?? */
+
+ AcpiCmAddReference (ObjDesc->BankField.Container);
+ AcpiCmAddReference (ObjDesc->BankField.BankSelect);
+
+ /* Debug info */
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlPrepBankFieldValue: bitoff=%X off=%X gran=%X\n",
+ ObjDesc->BankField.BitOffset, ObjDesc->BankField.Offset,
+ ObjDesc->Field.Granularity));
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlPrepBankFieldValue: set NamedObj %p (%4.4s) val = %p\n",
+ Node, &(Node->Name), ObjDesc));
+
+ DUMP_STACK_ENTRY (ObjDesc);
+ DUMP_ENTRY (Region, ACPI_INFO);
+ DUMP_ENTRY (BankReg, ACPI_INFO);
+ DEBUG_PRINT (ACPI_INFO,
+ ("============================================================\n"));
+
+ /*
+ * Store the constructed descriptor (ObjDesc) into the NamedObj whose
+ * handle is on TOS, preserving the current type of that NamedObj.
+ */
+ Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
+ (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlPrepIndexFieldValue
+ *
+ * PARAMETERS: Node - Owning Node
+ * IndexReg - Index register
+ * DataReg - Data register
+ * FieldFlags - Access, LockRule, or UpdateRule
+ * FieldPosition - Field position
+ * FieldLength - Field length
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type IndexField and
+ * connect it to the parent Node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlPrepIndexFieldValue (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_HANDLE IndexReg,
+ ACPI_HANDLE DataReg,
+ UINT8 FieldFlags,
+ UINT8 FieldAttribute,
+ UINT32 FieldPosition,
+ UINT32 FieldLength)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlPrepIndexFieldValue");
+
+
+ /* Parameter validation */
+
+ if (!IndexReg || !DataReg)
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("AmlPrepIndexFieldValue: null handle\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /* Allocate a new object descriptor */
+
+ ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_INDEX_FIELD);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize areas of the object that are common to all fields */
+
+ Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute,
+ FieldPosition, FieldLength);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize areas of the object that are specific to this field type */
+
+ ObjDesc->IndexField.Value = (UINT32) (FieldPosition /
+ ObjDesc->Field.Granularity);
+ ObjDesc->IndexField.Index = IndexReg;
+ ObjDesc->IndexField.Data = DataReg;
+
+ /* Debug info */
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlPrepIndexFieldValue: bitoff=%X off=%X gran=%X\n",
+ ObjDesc->IndexField.BitOffset, ObjDesc->IndexField.Offset,
+ ObjDesc->Field.Granularity));
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlPrepIndexFieldValue: set NamedObj %p (%4.4s) val = %p\n",
+ Node, &(Node->Name), ObjDesc));
+
+ DUMP_STACK_ENTRY (ObjDesc);
+ DUMP_ENTRY (IndexReg, ACPI_INFO);
+ DUMP_ENTRY (DataReg, ACPI_INFO);
+ DEBUG_PRINT (ACPI_INFO,
+ ("============================================================\n"));
+
+ /*
+ * Store the constructed descriptor (ObjDesc) into the NamedObj whose
+ * handle is on TOS, preserving the current type of that NamedObj.
+ */
+ Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
+ (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node));
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c
new file mode 100644
index 0000000..181ef59
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c
@@ -0,0 +1,561 @@
+
+/******************************************************************************
+ *
+ * Module Name: amregion - ACPI default OpRegion (address space) handlers
+ * $Revision: 36 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __AMREGION_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "achware.h"
+#include "acevents.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amregion")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemMemorySpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the System Memory address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemMemorySpaceHandler (
+ UINT32 Function,
+ ACPI_INTEGER Address,
+ UINT32 BitWidth,
+ UINT32 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ void *LogicalAddrPtr = NULL;
+ MEM_HANDLER_CONTEXT *MemInfo = RegionContext;
+ UINT32 Length;
+
+
+ FUNCTION_TRACE ("AmlSystemMemorySpaceHandler");
+
+
+ /* Validate and translate the bit width */
+
+ switch (BitWidth)
+ {
+ case 8:
+ Length = 1;
+ break;
+
+ case 16:
+ Length = 2;
+ break;
+
+ case 32:
+ Length = 4;
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlSystemMemorySpaceHandler: Invalid SystemMemory width %d\n",
+ BitWidth));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ break;
+ }
+
+
+ /*
+ * Does the request fit into the cached memory mapping?
+ * Is 1) Address below the current mapping? OR
+ * 2) Address beyond the current mapping?
+ */
+
+ if ((Address < (ACPI_INTEGER) MemInfo->MappedPhysicalAddress) ||
+ ((Address + Length) >
+ (ACPI_INTEGER) (MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
+ {
+ /*
+ * The request cannot be resolved by the current memory mapping;
+ * Delete the existing mapping and create a new one.
+ */
+
+ if (MemInfo->MappedLength)
+ {
+ /* Valid mapping, delete it */
+
+ AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress,
+ MemInfo->MappedLength);
+ }
+
+ MemInfo->MappedLength = 0; /* In case of failure below */
+
+ /* Create a new mapping starting at the address given */
+
+ Status = AcpiOsMapMemory ((void *) (UINT32) Address, SYSMEM_REGION_WINDOW_SIZE,
+ (void **) &MemInfo->MappedLogicalAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* TBD: should these pointers go to 64-bit in all cases ? */
+
+ MemInfo->MappedPhysicalAddress = (UINT8 *) (UINT32) Address;
+ MemInfo->MappedLength = SYSMEM_REGION_WINDOW_SIZE;
+ }
+
+
+ /*
+ * Generate a logical pointer corresponding to the address we want to
+ * access
+ */
+
+ /* TBD: should these pointers go to 64-bit in all cases ? */
+
+ LogicalAddrPtr = MemInfo->MappedLogicalAddress +
+ ((UINT8 *) (UINT32) Address - MemInfo->MappedPhysicalAddress);
+
+ /* Perform the memory read or write */
+
+ switch (Function)
+ {
+
+ case ADDRESS_SPACE_READ:
+
+ DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
+ ("Read (%d width) Address:0x%X\n", BitWidth, Address));
+
+ switch (BitWidth)
+ {
+ case 8:
+ *Value = (UINT32)* (UINT8 *) LogicalAddrPtr;
+ break;
+
+ case 16:
+ MOVE_UNALIGNED16_TO_32 (Value, LogicalAddrPtr);
+ break;
+
+ case 32:
+ MOVE_UNALIGNED32_TO_32 (Value, LogicalAddrPtr);
+ break;
+ }
+
+ break;
+
+
+ case ADDRESS_SPACE_WRITE:
+
+ DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
+ ("Write (%d width) Address:0x%p Value 0x%X\n",
+ BitWidth, Address, *Value));
+
+ switch (BitWidth)
+ {
+ case 8:
+ *(UINT8 *) LogicalAddrPtr = (UINT8) *Value;
+ break;
+
+ case 16:
+ MOVE_UNALIGNED16_TO_16 (LogicalAddrPtr, Value);
+ break;
+
+ case 32:
+ MOVE_UNALIGNED32_TO_32 (LogicalAddrPtr, Value);
+ break;
+ }
+
+ break;
+
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemIoSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the System IO address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemIoSpaceHandler (
+ UINT32 Function,
+ ACPI_INTEGER Address,
+ UINT32 BitWidth,
+ UINT32 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE ("AmlSystemIoSpaceHandler");
+
+
+ /* Decode the function parameter */
+
+ switch (Function)
+ {
+
+ case ADDRESS_SPACE_READ:
+
+ DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
+ ("Read(%d width) Address:0x%08x\n", BitWidth, Address));
+
+ switch (BitWidth)
+ {
+ /* I/O Port width */
+
+ case 8:
+ *Value = (UINT32) AcpiOsIn8 ((ACPI_IO_ADDRESS) Address);
+ break;
+
+ case 16:
+ *Value = (UINT32) AcpiOsIn16 ((ACPI_IO_ADDRESS) Address);
+ break;
+
+ case 32:
+ *Value = AcpiOsIn32 ((ACPI_IO_ADDRESS) Address);
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlSystemIoSpaceHandler: Invalid SystemIO width %d\n",
+ BitWidth));
+ Status = AE_AML_OPERAND_VALUE;
+ }
+
+ break;
+
+
+ case ADDRESS_SPACE_WRITE:
+
+ DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
+ ("Write(%d width) Address:0x%08x Value 0x%08x\n",
+ BitWidth, Address, *Value));
+
+ switch (BitWidth)
+ {
+ /* I/O Port width */
+ case 8:
+ AcpiOsOut8 ((ACPI_IO_ADDRESS) Address, (UINT8) *Value);
+ break;
+
+ case 16:
+ AcpiOsOut16 ((ACPI_IO_ADDRESS) Address, (UINT16) *Value);
+ break;
+
+ case 32:
+ AcpiOsOut32 ((ACPI_IO_ADDRESS) Address, *Value);
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR, (
+ "AmlSystemIoSpaceHandler: Invalid SystemIO width %d\n",
+ BitWidth));
+ Status = AE_AML_OPERAND_VALUE;
+ }
+
+ break;
+
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlPciConfigSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the PCI Config address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlPciConfigSpaceHandler (
+ UINT32 Function,
+ ACPI_INTEGER Address,
+ UINT32 BitWidth,
+ UINT32 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 PciBus;
+ UINT32 DevFunc;
+ UINT8 PciReg;
+ PCI_HANDLER_CONTEXT *PCIContext;
+
+
+ FUNCTION_TRACE ("AmlPciConfigSpaceHandler");
+
+ /*
+ * The arguments to AcpiOs(Read|Write)PciCfg(Byte|Word|Dword) are:
+ *
+ * SegBus - 0xSSSSBBBB - SSSS is the PCI bus segment
+ * BBBB is the PCI bus number
+ *
+ * DevFunc - 0xDDDDFFFF - DDDD is the PCI device number
+ * FFFF is the PCI device function number
+ *
+ * RegNum - Config space register must be < 40h
+ *
+ * Value - input value for write, output for read
+ *
+ */
+
+ PCIContext = (PCI_HANDLER_CONTEXT *) RegionContext;
+
+ PciBus = LOWORD(PCIContext->Seg) << 16;
+ PciBus |= LOWORD(PCIContext->Bus);
+
+ DevFunc = PCIContext->DevFunc;
+
+ PciReg = (UINT8) Address;
+
+ switch (Function)
+ {
+
+ case ADDRESS_SPACE_READ:
+
+ DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
+ ("R%d S(%04x) B(%04x) DF(%08x) R(%04x)\n", BitWidth,
+ PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, PciReg));
+
+ *Value = 0;
+
+ switch (BitWidth)
+ {
+ /* PCI Register width */
+
+ case 8:
+ Status = AcpiOsReadPciCfgByte (PciBus, DevFunc, PciReg,
+ (UINT8 *) Value);
+ break;
+
+ case 16:
+ Status = AcpiOsReadPciCfgWord (PciBus, DevFunc, PciReg,
+ (UINT16 *) Value);
+ break;
+
+ case 32:
+ Status = AcpiOsReadPciCfgDword (PciBus, DevFunc, PciReg,
+ Value);
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlPciConfigSpaceHandler: Invalid PCIConfig width %d\n",
+ BitWidth));
+ Status = AE_AML_OPERAND_VALUE;
+
+ } /* Switch bitWidth */
+
+ break;
+
+
+ case ADDRESS_SPACE_WRITE:
+
+ DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
+ ("W%d S(%04x) B(%04x) DF(%08x) R(%04x) D(%08x)\n", BitWidth,
+ PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc,
+ PciReg,*Value));
+
+ switch (BitWidth)
+ {
+ /* PCI Register width */
+
+ case 8:
+ Status = AcpiOsWritePciCfgByte (PciBus, DevFunc, PciReg,
+ *(UINT8 *) Value);
+ break;
+
+ case 16:
+ Status = AcpiOsWritePciCfgWord (PciBus, DevFunc, PciReg,
+ *(UINT16 *) Value);
+ break;
+
+ case 32:
+ Status = AcpiOsWritePciCfgDword (PciBus, DevFunc, PciReg,
+ *Value);
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR, (
+ "AmlPciConfigSpaceHandler: Invalid PCIConfig width %d\n",
+ BitWidth));
+ Status = AE_AML_OPERAND_VALUE;
+
+ } /* Switch bitWidth */
+
+ break;
+
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ break;
+
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c
new file mode 100644
index 0000000..a7785a9
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c
@@ -0,0 +1,693 @@
+
+/******************************************************************************
+ *
+ * Module Name: amresnte - AML Interpreter object resolution
+ * $Revision: 23 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMRESNTE_C__
+
+#include "acpi.h"
+#include "amlcode.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "actables.h"
+#include "acevents.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amresnte")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlResolveNodeToValue
+ *
+ * PARAMETERS: StackPtr - Pointer to a location on a stack that contains
+ * a pointer to an Node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node,
+ * A.K.A. a "direct name pointer")
+ *
+ * Note: for some of the data types, the pointer attached to the Node
+ * can be either a pointer to an actual internal object or a pointer into the
+ * AML stream itself. These types are currently:
+ *
+ * ACPI_TYPE_NUMBER
+ * ACPI_TYPE_STRING
+ * ACPI_TYPE_BUFFER
+ * ACPI_TYPE_MUTEX
+ * ACPI_TYPE_PACKAGE
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlResolveNodeToValue (
+ ACPI_NAMESPACE_NODE **StackPtr)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ValDesc = NULL;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+ UINT8 *AmlPointer = NULL;
+ OBJECT_TYPE_INTERNAL EntryType;
+ BOOLEAN Locked;
+ BOOLEAN AttachedAmlPointer = FALSE;
+ UINT8 AmlOpcode = 0;
+ ACPI_INTEGER TempVal;
+ OBJECT_TYPE_INTERNAL ObjectType;
+
+
+ FUNCTION_TRACE ("AmlResolveEntryToValue");
+
+ Node = *StackPtr;
+
+
+ /*
+ * The stack pointer is a "Direct name ptr", and points to a
+ * a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to
+ * the Node.
+ */
+
+ ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node);
+ EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlResolveEntryToValue: Entry=%p ValDesc=%p Type=%X\n",
+ Node, ValDesc, EntryType));
+
+ /*
+ * The ValDesc attached to the Node can be either:
+ * 1) An internal ACPI object
+ * 2) A pointer into the AML stream (into one of the ACPI system tables)
+ */
+
+ if (AcpiTbSystemTablePointer (ValDesc))
+ {
+ AttachedAmlPointer = TRUE;
+ AmlOpcode = *((UINT8 *) ValDesc);
+ AmlPointer = ((UINT8 *) ValDesc) + 1;
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlResolveEntryToValue: Unparsed AML: %p Len=%X\n",
+ AmlOpcode, AmlPointer));
+ }
+
+
+ /*
+ * Several EntryTypes do not require further processing, so
+ * we will return immediately
+ */
+ /* Devices rarely have an attached object, return the Node
+ * and Method locals and arguments have a pseudo-Node
+ */
+ if (EntryType == ACPI_TYPE_DEVICE ||
+ EntryType == INTERNAL_TYPE_METHOD_ARGUMENT ||
+ EntryType == INTERNAL_TYPE_METHOD_LOCAL_VAR)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ if (!ValDesc)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: No object attached to node %p\n",
+ Node));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /*
+ * Action is based on the type of the Node, which indicates the type
+ * of the attached object or pointer
+ */
+ switch (EntryType)
+ {
+
+ case ACPI_TYPE_PACKAGE:
+
+ if (AttachedAmlPointer)
+ {
+ /*
+ * This means that the package initialization is not parsed
+ * -- should not happen
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Unparsed Packages not supported!\n"));
+ return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
+ }
+
+ /* ValDesc is an internal object in all cases by the time we get here */
+
+ if (ACPI_TYPE_PACKAGE != ValDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Object not a package, type %X\n",
+ ValDesc->Common.Type));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = ValDesc;
+ AcpiCmAddReference (ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ if (AttachedAmlPointer)
+ {
+ /*
+ * This means that the buffer initialization is not parsed
+ * -- should not happen
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Unparsed Buffers not supported!\n"));
+ return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
+ }
+
+ /* ValDesc is an internal object in all cases by the time we get here */
+
+ if (ACPI_TYPE_BUFFER != ValDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Object not a buffer, type %X\n",
+ ValDesc->Common.Type));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = ValDesc;
+ AcpiCmAddReference (ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ if (AttachedAmlPointer)
+ {
+ /* Allocate a new string object */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Init the internal object */
+
+ ObjDesc->String.Pointer = (NATIVE_CHAR *) AmlPointer;
+ ObjDesc->String.Length = STRLEN (ObjDesc->String.Pointer);
+ }
+
+ else
+ {
+ if (ACPI_TYPE_STRING != ValDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Object not a string, type %X\n",
+ ValDesc->Common.Type));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = ValDesc;
+ AcpiCmAddReference (ObjDesc);
+ }
+
+ break;
+
+
+ case ACPI_TYPE_NUMBER:
+
+ DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: case Number \n"));
+
+ /*
+ * The Node has an attached internal object, make sure that it's a
+ * number
+ */
+
+ if (ACPI_TYPE_NUMBER != ValDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveToValue: Object not a Number, type %X\n",
+ ValDesc->Common.Type));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = ValDesc;
+ AcpiCmAddReference (ObjDesc);
+ break;
+
+
+ case INTERNAL_TYPE_DEF_FIELD:
+
+ /*
+ * TBD: [Investigate] Is this the correct solution?
+ *
+ * This section was extended to convert to generic buffer if
+ * the return length is greater than 32 bits, but still allows
+ * for returning a type Number for smaller values because the
+ * caller can then apply arithmetic operators on those fields.
+ *
+ * XXX - Implementation limitation: Fields are implemented as type
+ * XXX - Number, but they really are supposed to be type Buffer.
+ * XXX - The two are interchangeable only for lengths <= 32 bits.
+ */
+ if(ValDesc->Field.Length > 32)
+ {
+ ObjectType = ACPI_TYPE_BUFFER;
+ }
+ else
+ {
+ ObjectType = ACPI_TYPE_NUMBER;
+ }
+
+ /*
+ * Create the destination buffer object and the buffer space.
+ */
+ ObjDesc = AcpiCmCreateInternalObject (ObjectType);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Fill in the object specific details
+ */
+ if (ACPI_TYPE_BUFFER == ObjectType)
+ {
+ ObjDesc->Buffer.Pointer = AcpiCmCallocate (ValDesc->Field.Length);
+ if (!ObjDesc->Buffer.Pointer)
+ {
+ AcpiCmRemoveReference(ObjDesc);
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ObjDesc->Buffer.Length = ValDesc->Field.Length;
+
+ Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node,
+ ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ else
+ {
+ Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node,
+ &TempVal, sizeof (TempVal));
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ObjDesc->Number.Value = TempVal;
+ }
+
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlResolveEntryToValue: DefField Entry=%p ValDesc=%p Type=%X\n",
+ Node, ValDesc, EntryType));
+ break;
+
+
+ case INTERNAL_TYPE_BANK_FIELD:
+
+ if (AttachedAmlPointer)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: BankField cannot be an Aml ptr\n"));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (INTERNAL_TYPE_BANK_FIELD != ValDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR, (
+ "AmlResolveToValue: Object not a BankField, type %X\n",
+ ValDesc->Common.Type));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+
+ /* Get the global lock if needed */
+
+ ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr;
+ Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
+
+ /* Set Index value to select proper Data register */
+ /* perform the update */
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ ValDesc->BankField.BankSelect, &ValDesc->BankField.Value,
+ sizeof (ValDesc->BankField.Value));
+
+ AcpiAmlReleaseGlobalLock (Locked);
+
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Read Data value */
+
+ Status = AcpiAmlAccessNamedField (ACPI_READ,
+ (ACPI_HANDLE) ValDesc->BankField.Container,
+ &TempVal, sizeof (TempVal));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create an object for the result */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ObjDesc->Number.Value = TempVal;
+ break;
+
+
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ if (AttachedAmlPointer)
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal - IndexField cannot be an Aml ptr\n"));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (INTERNAL_TYPE_INDEX_FIELD != ValDesc->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR, (
+ "AmlResolveToValue: Object not an IndexField, type %X\n",
+ ValDesc->Common.Type));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+
+ /* Set Index value to select proper Data register */
+ /* Get the global lock if needed */
+
+ ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr;
+ Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
+
+ /* Perform the update */
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ ValDesc->IndexField.Index, &ValDesc->IndexField.Value,
+ sizeof (ValDesc->IndexField.Value));
+
+ AcpiAmlReleaseGlobalLock (Locked);
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Read Data value */
+
+ Status = AcpiAmlAccessNamedField (ACPI_READ, ValDesc->IndexField.Data,
+ &TempVal, sizeof (TempVal));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create an object for the result */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ObjDesc->Number.Value = TempVal;
+ break;
+
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+ if (AttachedAmlPointer)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: FieldUnit cannot be an Aml ptr\n"));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (ValDesc->Common.Type != (UINT8) EntryType)
+ {
+ DEBUG_PRINT (ACPI_ERROR, (
+ "AmlResolveToValue: Object type %X not same as EntryType %X\n",
+ ValDesc->Common.Type, EntryType));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ break;
+ }
+
+ /* Create object for result */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiAmlGetFieldUnitValue (ValDesc, ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+ }
+
+ break;
+
+
+ /*
+ * For these objects, just return the object attached to the Node
+ */
+
+ case ACPI_TYPE_MUTEX:
+ case ACPI_TYPE_METHOD:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_THERMAL:
+ case ACPI_TYPE_EVENT:
+ case ACPI_TYPE_REGION:
+
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = ValDesc;
+ AcpiCmAddReference (ObjDesc);
+ break;
+
+
+ /* TYPE_Any is untyped, and thus there is no object associated with it */
+
+ case ACPI_TYPE_ANY:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Untyped entry %p, no attached object!\n",
+ Node));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
+ break;
+
+
+ /*
+ * The only named references allowed are named constants
+ *
+ * e.g. Name (\OSFL, Ones)
+ */
+ case INTERNAL_TYPE_REFERENCE:
+
+ switch (ValDesc->Reference.OpCode)
+ {
+
+ case AML_ZERO_OP:
+
+ TempVal = 0;
+ break;
+
+
+ case AML_ONE_OP:
+
+ TempVal = 1;
+ break;
+
+
+ case AML_ONES_OP:
+
+ TempVal = ACPI_UINT32_MAX;
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveToValue/Number: Unsupported reference opcode %X\n",
+ ValDesc->Reference.OpCode));
+
+ return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+ }
+
+ /* Create object for result */
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ObjDesc->Number.Value = TempVal;
+
+ break;
+
+
+ /* Default case is for unknown types */
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveEntryToValue: Node %p - Unknown object type %X\n",
+ Node, EntryType));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+
+ } /* switch (EntryType) */
+
+
+ /* Put the object descriptor on the stack */
+
+ *StackPtr = (void *) ObjDesc;
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c
new file mode 100644
index 0000000..5f23c2d
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c
@@ -0,0 +1,629 @@
+
+/******************************************************************************
+ *
+ * Module Name: amresolv - AML Interpreter object resolution
+ * $Revision: 76 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMRESOLV_C__
+
+#include "acpi.h"
+#include "amlcode.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "actables.h"
+#include "acevents.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amresolv")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlGetFieldUnitValue
+ *
+ * PARAMETERS: *FieldDesc - Pointer to a FieldUnit
+ * *ResultDesc - Pointer to an empty descriptor
+ * which will become a Number
+ * containing the field's value.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value from a FieldUnit
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlGetFieldUnitValue (
+ ACPI_OPERAND_OBJECT *FieldDesc,
+ ACPI_OPERAND_OBJECT *ResultDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Mask;
+ UINT8 *Location = NULL;
+ BOOLEAN Locked = FALSE;
+
+
+ FUNCTION_TRACE ("AmlGetFieldUnitValue");
+
+
+ if (!FieldDesc)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlGetFieldUnitValue: Internal error - null field pointer\n"));
+ Status = AE_AML_NO_OPERAND;
+ }
+
+ if (!(FieldDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetFieldUnitArguments (FieldDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (!FieldDesc->FieldUnit.Container)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlGetFieldUnitValue: Internal error - null container pointer\n"));
+ Status = AE_AML_INTERNAL;
+ }
+
+ else if (ACPI_TYPE_BUFFER != FieldDesc->FieldUnit.Container->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlGetFieldUnitValue: Internal error - container is not a Buffer\n"));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+
+ else if (!ResultDesc)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlGetFieldUnitValue: Internal error - null result pointer\n"));
+ Status = AE_AML_INTERNAL;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+
+ /* Get the global lock if needed */
+
+ Locked = AcpiAmlAcquireGlobalLock (FieldDesc->FieldUnit.LockRule);
+
+ /* Field location is (base of buffer) + (byte offset) */
+
+ Location = FieldDesc->FieldUnit.Container->Buffer.Pointer
+ + FieldDesc->FieldUnit.Offset;
+
+ /*
+ * Construct Mask with as many 1 bits as the field width
+ *
+ * NOTE: Only the bottom 5 bits are valid for a shift operation, so
+ * special care must be taken for any shift greater than 31 bits.
+ *
+ * TBD: [Unhandled] Fields greater than 32-bits will not work.
+ */
+
+ if (FieldDesc->FieldUnit.Length < 32)
+ {
+ Mask = ((UINT32) 1 << FieldDesc->FieldUnit.Length) - (UINT32) 1;
+ }
+ else
+ {
+ Mask = ACPI_UINT32_MAX;
+ }
+
+ ResultDesc->Number.Type = (UINT8) ACPI_TYPE_NUMBER;
+
+ /* Get the 32 bit value at the location */
+
+ MOVE_UNALIGNED32_TO_32 (&ResultDesc->Number.Value, Location);
+
+ /*
+ * Shift the 32-bit word containing the field, and mask off the
+ * resulting value
+ */
+
+ ResultDesc->Number.Value =
+ (ResultDesc->Number.Value >> FieldDesc->FieldUnit.BitOffset) & Mask;
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n",
+ FieldDesc->FieldUnit.Container->Buffer.Pointer,
+ FieldDesc->FieldUnit.Offset,
+ FieldDesc->FieldUnit.BitOffset,
+ FieldDesc->FieldUnit.Length,
+ Location, Mask, ResultDesc->Number.Value));
+
+ /* Release global lock if we acquired it earlier */
+
+ AcpiAmlReleaseGlobalLock (Locked);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlResolveToValue
+ *
+ * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
+ * be either an (ACPI_OPERAND_OBJECT *)
+ * or an ACPI_HANDLE.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert Reference entries on ObjStack to Rvalues
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlResolveToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_PTR ("AmlResolveToValue", StackPtr);
+
+
+ if (!StackPtr || !*StackPtr)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveToValue: Internal error - null pointer\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+
+ /*
+ * The entity pointed to by the StackPtr can be either
+ * 1) A valid ACPI_OPERAND_OBJECT, or
+ * 2) A ACPI_NAMESPACE_NODE (NamedObj)
+ */
+
+ if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_INTERNAL))
+ {
+
+ Status = AcpiAmlResolveObjectToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Object on the stack may have changed if AcpiAmlResolveObjectToValue()
+ * was called (i.e., we can't use an _else_ here.)
+ */
+
+ if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_NAMED))
+ {
+ Status = AcpiAmlResolveNodeToValue ((ACPI_NAMESPACE_NODE **) StackPtr);
+ }
+
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveToValue: Returning resolved object %p\n", *StackPtr));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlResolveObjectToValue
+ *
+ * PARAMETERS: StackPtr - Pointer to a stack location that contains a
+ * ptr to an internal object.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value from an internal object. The Reference type
+ * uses the associated AML opcode to determine the value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlResolveObjectToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *StackDesc;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_HANDLE TempHandle = NULL;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ UINT32 Index = 0;
+ UINT16 Opcode;
+
+
+ FUNCTION_TRACE ("AmlResolveObjectToValue");
+
+
+ StackDesc = *StackPtr;
+
+ /* This is an ACPI_OPERAND_OBJECT */
+
+ switch (StackDesc->Common.Type)
+ {
+
+ case INTERNAL_TYPE_REFERENCE:
+
+ Opcode = StackDesc->Reference.OpCode;
+
+ switch (Opcode)
+ {
+
+ case AML_NAME_OP:
+
+ /*
+ * Convert indirect name ptr to a direct name ptr.
+ * Then, AcpiAmlResolveNodeToValue can be used to get the value
+ */
+
+ TempHandle = StackDesc->Reference.Object;
+
+ /* Delete the Reference Object */
+
+ AcpiCmRemoveReference (StackDesc);
+
+ /* Put direct name pointer onto stack and exit */
+
+ (*StackPtr) = TempHandle;
+ Status = AE_OK;
+ break;
+
+
+ case AML_LOCAL_OP:
+
+ Index = StackDesc->Reference.Offset;
+
+ /*
+ * Get the local from the method's state info
+ * Note: this increments the local's object reference count
+ */
+
+ Status = AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, Index,
+ WalkState, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now we can delete the original Reference Object and
+ * replace it with the resolve value
+ */
+
+ AcpiCmRemoveReference (StackDesc);
+ *StackPtr = ObjDesc;
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveObjectToValue: [Local%d] ValueObj is %p\n",
+ Index, ObjDesc));
+
+ if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type)
+ {
+ /* Value is a Number */
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveObjectToValue: [Local%d] value is [0x%X] \n",
+ Index, ObjDesc->Number.Value));
+ }
+
+ break;
+
+
+ case AML_ARG_OP:
+
+ Index = StackDesc->Reference.Offset;
+
+
+ /*
+ * Get the argument from the method's state info
+ * Note: this increments the object reference count
+ */
+
+ Status = AcpiDsMethodDataGetValue (MTH_TYPE_ARG, Index,
+ WalkState, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now we can delete the original Reference Object and
+ * replace it with the resolve value
+ */
+
+ AcpiCmRemoveReference (StackDesc);
+ *StackPtr = ObjDesc;
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlResolveObjectToValue: [Arg%d] ValueObj is %p\n",
+ Index, ObjDesc));
+
+ if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type)
+ {
+ /* Value is a Number */
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveObjectToValue: [Arg%d] value is [0x%X] \n",
+ Index, ObjDesc->Number.Value));
+ }
+
+ break;
+
+
+ /*
+ * TBD: [Restructure] These next three opcodes change the type of
+ * the object, which is actually a no-no.
+ */
+
+ case AML_ZERO_OP:
+
+ StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER;
+ StackDesc->Number.Value = 0;
+ break;
+
+
+ case AML_ONE_OP:
+
+ StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER;
+ StackDesc->Number.Value = 1;
+ break;
+
+
+ case AML_ONES_OP:
+
+ StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER;
+ StackDesc->Number.Value = ACPI_INTEGER_MAX;
+ break;
+
+
+ case AML_INDEX_OP:
+
+ switch (StackDesc->Reference.TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /* Just return - leave the Reference on the stack */
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+ ObjDesc = *StackDesc->Reference.Where;
+ if (ObjDesc)
+ {
+ /*
+ * Valid obj descriptor, copy pointer to return value
+ * (i.e., dereference the package index)
+ * Delete the ref object, increment the returned object
+ */
+ AcpiCmRemoveReference (StackDesc);
+ AcpiCmAddReference (ObjDesc);
+ *StackPtr = ObjDesc;
+ }
+
+ else
+ {
+ /*
+ * A NULL object descriptor means an unitialized element of
+ * the package, can't deref it
+ */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveObjectToValue: Attempt to deref an Index to NULL pkg element Idx=%p\n", StackDesc));
+ Status = AE_AML_UNINITIALIZED_ELEMENT;
+ }
+ break;
+
+ default:
+ /* Invalid reference OBJ*/
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveObjectToValue: Unknown TargetType %d in Index/Reference obj %p\n",
+ StackDesc->Reference.TargetType, StackDesc));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ break;
+
+
+ case AML_DEBUG_OP:
+
+ /* Just leave the object as-is */
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveObjectToValue: Unknown Reference object subtype %02x in %p\n",
+ Opcode, StackDesc));
+ Status = AE_AML_INTERNAL;
+
+ } /* switch (Opcode) */
+
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ break; /* case INTERNAL_TYPE_REFERENCE */
+
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
+ if (!ObjDesc)
+ {
+ /* Descriptor allocation failure */
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ ObjDesc = NULL;
+ }
+
+ *StackPtr = (void *) ObjDesc;
+ break;
+
+
+ case INTERNAL_TYPE_BANK_FIELD:
+
+ ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
+ if (!ObjDesc)
+ {
+ /* Descriptor allocation failure */
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (ObjDesc);
+ ObjDesc = NULL;
+ }
+
+ *StackPtr = (void *) ObjDesc;
+ break;
+
+
+ /* TBD: [Future] - may need to handle IndexField, and DefField someday */
+
+ default:
+
+ break;
+
+ } /* switch (StackDesc->Common.Type) */
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c
new file mode 100644
index 0000000..02a13d4
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c
@@ -0,0 +1,629 @@
+
+/******************************************************************************
+ *
+ * Module Name: amresop - AML Interpreter operand/object resolution
+ * $Revision: 15 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMRESOP_C__
+
+#include "acpi.h"
+#include "amlcode.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "actables.h"
+#include "acevents.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amresop")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlResolveOperands
+ *
+ * PARAMETERS: Opcode Opcode being interpreted
+ * StackPtr Top of operand stack
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert stack entries to required types
+ *
+ * Each nibble in ArgTypes represents one required operand
+ * and indicates the required Type:
+ *
+ * The corresponding stack entry will be converted to the
+ * required type if possible, else return an exception
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlResolveOperands (
+ UINT16 Opcode,
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status = AE_OK;
+ UINT8 ObjectType;
+ ACPI_HANDLE TempHandle;
+ UINT32 ArgTypes;
+ ACPI_OPCODE_INFO *OpInfo;
+ UINT32 ThisArgType;
+
+
+ FUNCTION_TRACE_U32 ("AmlResolveOperands", Opcode);
+
+
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+ if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+ }
+
+
+ ArgTypes = OpInfo->RuntimeArgs;
+ if (ArgTypes == ARGI_INVALID_OPCODE)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveOperands: Internal error - %X is not a runtime opcode\n", Opcode));
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("AmlResolveOperands: Opcode %X OperandTypes=%X \n",
+ Opcode, ArgTypes));
+
+
+ /*
+ * Normal exit is with *Types == '\0' at end of string.
+ * Function will return an exception from within the loop upon
+ * finding an entry which is not, and cannot be converted
+ * to, the required type; if stack underflows; or upon
+ * finding a NULL stack entry (which "should never happen").
+ */
+
+ while (GET_CURRENT_ARG_TYPE (ArgTypes))
+ {
+ if (!StackPtr || !*StackPtr)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveOperands: Internal error - null stack entry at %X\n", StackPtr));
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ /* Extract useful items */
+
+ ObjDesc = *StackPtr;
+
+ /* Decode the descriptor type */
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /* Node */
+
+ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ }
+
+ else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
+ {
+ /* ACPI internal object */
+
+ ObjectType = ObjDesc->Common.Type;
+
+ /* Check for bad ACPI_OBJECT_TYPE */
+
+ if (!AcpiAmlValidateObjectType (ObjectType))
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveOperands: Bad operand object type [0x%x]\n",
+ ObjectType));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ if (ObjectType == (UINT8) INTERNAL_TYPE_REFERENCE)
+ {
+ /*
+ * Decode the Reference
+ */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+ if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+ }
+
+
+ switch (ObjDesc->Reference.OpCode)
+ {
+ case AML_ZERO_OP:
+ case AML_ONE_OP:
+ case AML_ONES_OP:
+ case AML_DEBUG_OP:
+ case AML_NAME_OP:
+ case AML_INDEX_OP:
+ case AML_ARG_OP:
+ case AML_LOCAL_OP:
+
+ DEBUG_ONLY_MEMBERS (DEBUG_PRINT (ACPI_INFO,
+ ("Reference Opcode: %s\n", OpInfo->Name)));
+ break;
+
+ default:
+ DEBUG_PRINT (ACPI_INFO,
+ ("Reference Opcode: Unknown [%02x]\n",
+ ObjDesc->Reference.OpCode));
+
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ break;
+ }
+ }
+
+ }
+
+ else
+ {
+ /* Invalid descriptor */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("Bad descriptor type 0x%X in Obj %p\n",
+ ObjDesc->Common.DataType, ObjDesc));
+
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Decode a character from the type string
+ */
+
+ ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
+ INCREMENT_ARG_LIST (ArgTypes);
+
+
+ switch (ThisArgType)
+ {
+
+ case ARGI_REFERENCE: /* Reference */
+ case ARGI_TARGETREF:
+
+ /* Need an operand of type INTERNAL_TYPE_REFERENCE */
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */
+ {
+ break;
+ }
+
+ if (INTERNAL_TYPE_REFERENCE != ObjectType)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Reference, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ if (AML_NAME_OP == ObjDesc->Reference.OpCode)
+ {
+ /*
+ * Convert an indirect name ptr to direct name ptr and put
+ * it on the stack
+ */
+
+ TempHandle = ObjDesc->Reference.Object;
+ AcpiCmRemoveReference (ObjDesc);
+ (*StackPtr) = TempHandle;
+ }
+ break;
+
+
+ case ARGI_NUMBER: /* Number */
+
+ /* Need an operand of type ACPI_TYPE_NUMBER */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (ACPI_TYPE_NUMBER != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Number, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_STRING:
+
+ /* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if ((ACPI_TYPE_STRING != (*StackPtr)->Common.Type) &&
+ (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type))
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed String or Buffer, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_BUFFER:
+
+ /* Need an operand of type ACPI_TYPE_BUFFER */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Buffer, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_MUTEX:
+
+ /* Need an operand of type ACPI_TYPE_MUTEX */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (ACPI_TYPE_MUTEX != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Mutex, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_EVENT:
+
+ /* Need an operand of type ACPI_TYPE_EVENT */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (ACPI_TYPE_EVENT != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed AcpiEvent, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_REGION:
+
+ /* Need an operand of type ACPI_TYPE_REGION */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (ACPI_TYPE_REGION != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Region, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_IF: /* If */
+
+ /* Need an operand of type INTERNAL_TYPE_IF */
+
+ if (INTERNAL_TYPE_IF != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed If, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_PACKAGE: /* Package */
+
+ /* Need an operand of type ACPI_TYPE_PACKAGE */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (ACPI_TYPE_PACKAGE != (*StackPtr)->Common.Type)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Package, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ARGI_ANYTYPE:
+
+
+ /*
+ * We don't want to resolve IndexOp reference objects during
+ * a store because this would be an implicit DeRefOf operation.
+ * Instead, we just want to store the reference object.
+ */
+
+ if ((Opcode == AML_STORE_OP) &&
+ ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) &&
+ ((*StackPtr)->Reference.OpCode == AML_INDEX_OP))
+ {
+ break;
+ }
+
+ /* All others must be resolved */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* All types OK, so we don't perform any typechecks */
+
+ break;
+
+
+ case ARGI_DATAOBJECT:
+ /*
+ * ARGI_DATAOBJECT is only used by the SizeOf operator.
+ *
+ * The ACPI specification allows SizeOf to return the size of
+ * a Buffer, String or Package. However, the MS ACPI.SYS AML
+ * Interpreter also allows an Node reference to return without
+ * error with a size of 4.
+ */
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Need a buffer, string, package or Node reference */
+
+ if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) &&
+ ((*StackPtr)->Common.Type != ACPI_TYPE_STRING) &&
+ ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE) &&
+ ((*StackPtr)->Common.Type != INTERNAL_TYPE_REFERENCE))
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Buf/Str/Pkg, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ /*
+ * If this is a reference, only allow a reference to an Node.
+ */
+ if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE)
+ {
+ if (!(*StackPtr)->Reference.Node)
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Node reference, found %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ }
+
+ break;
+
+
+ case ARGI_COMPLEXOBJ:
+
+ Status = AcpiAmlResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Need a buffer or package */
+
+ if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) &&
+ ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE))
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlResolveOperands: Needed Package, Buf/Pkg %s Obj=%p\n",
+ AcpiCmGetTypeName (ObjectType), *StackPtr));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ /* Unknown abbreviation passed in */
+
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlResolveOperands: Internal error - Unknown arg type %X\n",
+ ThisArgType));
+ Status = AE_BAD_PARAMETER;
+ goto Cleanup;
+
+ } /* switch (*Types++) */
+
+
+ /*
+ * If more operands needed, decrement StackPtr to point
+ * to next operand on stack (after checking for underflow).
+ */
+ if (GET_CURRENT_ARG_TYPE (ArgTypes))
+ {
+ StackPtr--;
+ }
+
+ } /* while (*Types) */
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c
new file mode 100644
index 0000000..976ecc7
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c
@@ -0,0 +1,531 @@
+
+/******************************************************************************
+ *
+ * Module Name: amstore - AML Interpreter object store support
+ * $Revision: 116 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMSTORE_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "actables.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amstore")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecStore
+ *
+ * PARAMETERS: *ValDesc - Value to be stored
+ * *DestDesc - Where to store it 0 Must be (ACPI_HANDLE)
+ * or an ACPI_OPERAND_OBJECT of type
+ * Reference; if the latter the descriptor
+ * will be either reused or deleted.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the value described by ValDesc into the location
+ * described by DestDesc. Called by various interpreter
+ * functions to store the result of an operation into
+ * the destination operand.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecStore (
+ ACPI_OPERAND_OBJECT *ValDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *DeleteDestDesc = NULL;
+ ACPI_OPERAND_OBJECT *TmpDesc;
+ ACPI_NAMESPACE_NODE *Node = NULL;
+ UINT8 Value = 0;
+ UINT32 Length;
+ UINT32 i;
+
+
+ FUNCTION_TRACE ("AmlExecStore");
+
+ DEBUG_PRINT (ACPI_INFO, ("entered AcpiAmlExecStore: Val=%p, Dest=%p\n",
+ ValDesc, DestDesc));
+
+
+ /* Validate parameters */
+
+ if (!ValDesc || !DestDesc)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecStore: Internal error - null pointer\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /* Examine the datatype of the DestDesc */
+
+ if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /* Dest is an ACPI_HANDLE, create a new object */
+
+ Node = (ACPI_NAMESPACE_NODE *) DestDesc;
+ DestDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE);
+ if (!DestDesc)
+ {
+ /* Allocation failure */
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Build a new Reference wrapper around the handle */
+
+ DestDesc->Reference.OpCode = AML_NAME_OP;
+ DestDesc->Reference.Object = Node;
+ }
+
+ else
+ {
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlExecStore: Dest is object (not handle) - may be deleted!\n"));
+ }
+
+ /* Destination object must be of type Reference */
+
+ if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE)
+ {
+ /* Destination is not an Reference */
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecStore: Destination is not an Reference [%p]\n", DestDesc));
+
+ DUMP_STACK_ENTRY (ValDesc);
+ DUMP_STACK_ENTRY (DestDesc);
+ DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "AmlExecStore",
+ 2, "target not Reference");
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Examine the Reference opcode */
+
+ switch (DestDesc->Reference.OpCode)
+ {
+
+ case AML_NAME_OP:
+
+ /*
+ * Storing into a Name
+ */
+ DeleteDestDesc = DestDesc;
+ Status = AcpiAmlStoreObjectToNode (ValDesc, DestDesc->Reference.Object,
+ WalkState);
+
+ break; /* Case NameOp */
+
+
+ case AML_INDEX_OP:
+
+ DeleteDestDesc = DestDesc;
+
+ /*
+ * Valid source value and destination reference pointer.
+ *
+ * ACPI Specification 1.0B section 15.2.3.4.2.13:
+ * Destination should point to either a buffer or a package
+ */
+
+ /*
+ * Actually, storing to a package is not so simple. The source must be
+ * evaluated and converted to the type of the destination and then the
+ * source is copied into the destination - we can't just point to the
+ * source object.
+ */
+ if (DestDesc->Reference.TargetType == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * The object at *(DestDesc->Reference.Where) is the
+ * element within the package that is to be modified.
+ */
+ TmpDesc = *(DestDesc->Reference.Where);
+ if (TmpDesc)
+ {
+ /*
+ * If the Destination element is a package, we will delete
+ * that object and construct a new one.
+ *
+ * TBD: [Investigate] Should both the src and dest be required
+ * to be packages?
+ * && (ValDesc->Common.Type == ACPI_TYPE_PACKAGE)
+ */
+ if (TmpDesc->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * Take away the reference for being part of a package and
+ * delete
+ */
+ AcpiCmRemoveReference (TmpDesc);
+ AcpiCmRemoveReference (TmpDesc);
+
+ TmpDesc = NULL;
+ }
+ }
+
+ if (!TmpDesc)
+ {
+ /*
+ * If the TmpDesc is NULL, that means an uninitialized package
+ * has been used as a destination, therefore, we must create
+ * the destination element to match the type of the source
+ * element NOTE: ValDesc can be of any type.
+ */
+ TmpDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type);
+ if (!TmpDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * If the source is a package, copy the source to the new dest
+ */
+ if (ACPI_TYPE_PACKAGE == TmpDesc->Common.Type)
+ {
+ Status = AcpiAmlBuildCopyInternalPackageObject (
+ ValDesc, TmpDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiCmRemoveReference (TmpDesc);
+ TmpDesc = NULL;
+ goto Cleanup;
+ }
+ }
+
+ /*
+ * Install the new descriptor into the package and add a
+ * reference to the newly created descriptor for now being
+ * part of the parent package
+ */
+
+ *(DestDesc->Reference.Where) = TmpDesc;
+ AcpiCmAddReference (TmpDesc);
+ }
+
+ if (ACPI_TYPE_PACKAGE != TmpDesc->Common.Type)
+ {
+ /*
+ * The destination element is not a package, so we need to
+ * convert the contents of the source (ValDesc) and copy into
+ * the destination (TmpDesc)
+ */
+ Status = AcpiAmlStoreObjectToObject (ValDesc, TmpDesc,
+ WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * An error occurrered when copying the internal object
+ * so delete the reference.
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecStore/Index: Unable to copy the internal object\n"));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ }
+
+ break;
+ }
+
+ /*
+ * Check that the destination is a Buffer Field type
+ */
+ if (DestDesc->Reference.TargetType != ACPI_TYPE_BUFFER_FIELD)
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ /*
+ * Storing into a buffer at a location defined by an Index.
+ *
+ * Each 8-bit element of the source object is written to the
+ * 8-bit Buffer Field of the Index destination object.
+ */
+
+ /*
+ * Set the TmpDesc to the destination object and type check.
+ */
+ TmpDesc = DestDesc->Reference.Object;
+
+ if (TmpDesc->Common.Type != ACPI_TYPE_BUFFER)
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ /*
+ * The assignment of the individual elements will be slightly
+ * different for each source type.
+ */
+
+ switch (ValDesc->Common.Type)
+ {
+ /*
+ * If the type is Integer, the Length is 4.
+ * This loop to assign each of the elements is somewhat
+ * backward because of the Big Endian-ness of IA-64
+ */
+ case ACPI_TYPE_NUMBER:
+ Length = 4;
+ for (i = Length; i != 0; i--)
+ {
+ Value = (UINT8)(ValDesc->Number.Value >> (MUL_8 (i - 1)));
+ TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
+ }
+ break;
+
+ /*
+ * If the type is Buffer, the Length is in the structure.
+ * Just loop through the elements and assign each one in turn.
+ */
+ case ACPI_TYPE_BUFFER:
+ Length = ValDesc->Buffer.Length;
+ for (i = 0; i < Length; i++)
+ {
+ Value = *(ValDesc->Buffer.Pointer + i);
+ TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
+ }
+ break;
+
+ /*
+ * If the type is String, the Length is in the structure.
+ * Just loop through the elements and assign each one in turn.
+ */
+ case ACPI_TYPE_STRING:
+ Length = ValDesc->String.Length;
+ for (i = 0; i < Length; i++)
+ {
+ Value = *(ValDesc->String.Pointer + i);
+ TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
+ }
+ break;
+
+ /*
+ * If source is not a valid type so return an error.
+ */
+ default:
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecStore/Index: Source must be Number/Buffer/String type, not 0x%x\n",
+ ValDesc->Common.Type));
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ /*
+ * If we had an error, break out of this case statement.
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+
+ /*
+ * Set the return pointer
+ */
+ DestDesc = TmpDesc;
+
+ break;
+
+ case AML_ZERO_OP:
+ case AML_ONE_OP:
+ case AML_ONES_OP:
+
+ /*
+ * Storing to a constant is a no-op -- see ACPI Specification
+ * Delete the result descriptor.
+ */
+
+ DeleteDestDesc = DestDesc;
+ break;
+
+
+ case AML_LOCAL_OP:
+
+ Status = AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL,
+ (DestDesc->Reference.Offset), ValDesc, WalkState);
+ DeleteDestDesc = DestDesc;
+ break;
+
+
+ case AML_ARG_OP:
+
+ Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG,
+ (DestDesc->Reference.Offset), ValDesc, WalkState);
+ DeleteDestDesc = DestDesc;
+ break;
+
+
+ case AML_DEBUG_OP:
+
+ /*
+ * Storing to the Debug object causes the value stored to be
+ * displayed and otherwise has no effect -- see ACPI Specification
+ */
+ DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n"));
+ if (ValDesc->Common.Type == ACPI_TYPE_STRING)
+ {
+ DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer));
+ }
+ else
+ {
+ DUMP_STACK_ENTRY (ValDesc);
+ }
+
+ DeleteDestDesc = DestDesc;
+ break;
+
+
+ default:
+
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlExecStore: Internal error - Unknown Reference subtype %02x\n",
+ DestDesc->Reference.OpCode));
+
+ /* TBD: [Restructure] use object dump routine !! */
+
+ DUMP_BUFFER (DestDesc, sizeof (ACPI_OPERAND_OBJECT));
+
+ DeleteDestDesc = DestDesc;
+ Status = AE_AML_INTERNAL;
+
+ } /* switch(DestDesc->Reference.OpCode) */
+
+
+Cleanup:
+
+ /* Cleanup and exit*/
+
+ if (DeleteDestDesc)
+ {
+ AcpiCmRemoveReference (DeleteDestDesc);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c
new file mode 100644
index 0000000..1b626bf
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c
@@ -0,0 +1,713 @@
+
+/******************************************************************************
+ *
+ * Module Name: amstoren - AML Interpreter object store support,
+ * Store to Node (namespace object)
+ * $Revision: 22 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMSTOREN_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "actables.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amstoren")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlStoreObjectToNode
+ *
+ * PARAMETERS: *ValDesc - Value to be stored
+ * *Node - Named object to recieve the value
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the object to the named object.
+ *
+ * The Assignment of an object to a named object is handled here
+ * The val passed in will replace the current value (if any)
+ * with the input value.
+ *
+ * When storing into an object the data is converted to the
+ * target object type then stored in the object. This means
+ * that the target object type (for an initialized target) will
+ * not be changed by a store operation.
+ *
+ * NOTE: the global lock is acquired early. This will result
+ * in the global lock being held a bit longer. Also, if the
+ * function fails during set up we may get the lock when we
+ * don't really need it. I don't think we care.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlStoreObjectToNode (
+ ACPI_OPERAND_OBJECT *ValDesc,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 *Buffer = NULL;
+ UINT32 Length = 0;
+ UINT32 Mask;
+ UINT32 NewValue;
+ BOOLEAN Locked = FALSE;
+ UINT8 *Location=NULL;
+ ACPI_OPERAND_OBJECT *DestDesc;
+ OBJECT_TYPE_INTERNAL DestinationType = ACPI_TYPE_ANY;
+
+
+ FUNCTION_TRACE ("AmlStoreObjectToNte");
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("entered AcpiAmlStoreObjectToNode: NamedObj=%p, Obj=%p\n",
+ Node, ValDesc));
+
+ /*
+ * Assuming the parameters are valid!!!
+ */
+ ACPI_ASSERT((Node) && (ValDesc));
+
+ DestinationType = AcpiNsGetType (Node);
+
+ DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNte: Storing %s into %s\n",
+ AcpiCmGetTypeName (ValDesc->Common.Type),
+ AcpiCmGetTypeName (DestinationType)));
+
+ /*
+ * First ensure we have a value that can be stored in the target
+ */
+ switch (DestinationType)
+ {
+ /* Type of Name's existing value */
+
+ case INTERNAL_TYPE_ALIAS:
+
+ /*
+ * Aliases are resolved by AcpiAmlPrepOperands
+ */
+
+ DEBUG_PRINT (ACPI_WARN,
+ ("AmlStoreObjectToNte: Store into Alias - should never happen\n"));
+ Status = AE_AML_INTERNAL;
+ break;
+
+
+ case INTERNAL_TYPE_BANK_FIELD:
+ case INTERNAL_TYPE_INDEX_FIELD:
+ case ACPI_TYPE_FIELD_UNIT:
+ case ACPI_TYPE_NUMBER:
+
+ /*
+ * These cases all require only number values or values that
+ * can be converted to numbers.
+ *
+ * If value is not a Number, try to resolve it to one.
+ */
+
+ if (ValDesc->Common.Type != ACPI_TYPE_NUMBER)
+ {
+ /*
+ * Initially not a number, convert
+ */
+ Status = AcpiAmlResolveToValue (&ValDesc, WalkState);
+ if (ACPI_SUCCESS (Status) &&
+ (ValDesc->Common.Type != ACPI_TYPE_NUMBER))
+ {
+ /*
+ * Conversion successful but still not a number
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToNte: Value assigned to %s must be Number, not %s\n",
+ AcpiCmGetTypeName (DestinationType),
+ AcpiCmGetTypeName (ValDesc->Common.Type)));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ }
+
+ break;
+
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case INTERNAL_TYPE_DEF_FIELD:
+
+ /*
+ * Storing into a Field in a region or into a buffer or into
+ * a string all is essentially the same.
+ *
+ * If value is not a valid type, try to resolve it to one.
+ */
+
+ if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ /*
+ * Initially not a valid type, convert
+ */
+ Status = AcpiAmlResolveToValue (&ValDesc, WalkState);
+ if (ACPI_SUCCESS (Status) &&
+ (ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ /*
+ * Conversion successful but still not a valid type
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToNte: Assign wrong type %s to %s (must be type Num/Str/Buf)\n",
+ AcpiCmGetTypeName (ValDesc->Common.Type),
+ AcpiCmGetTypeName (DestinationType)));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ }
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ /*
+ * TBD: [Unhandled] Not real sure what to do here
+ */
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+
+
+ default:
+
+ /*
+ * All other types than Alias and the various Fields come here.
+ * Store ValDesc as the new value of the Name, and set
+ * the Name's type to that of the value being stored in it.
+ * ValDesc reference count is incremented by AttachObject.
+ */
+
+ Status = AcpiNsAttachObject (Node, ValDesc, ValDesc->Common.Type);
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlStoreObjectToNte: Store %s into %s via Attach\n",
+ AcpiCmGetTypeName (ValDesc->Common.Type),
+ AcpiCmGetTypeName (DestinationType)));
+
+ goto CleanUpAndBailOut;
+ break;
+ }
+
+ /* Exit now if failure above */
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto CleanUpAndBailOut;
+ }
+
+ /*
+ * Get descriptor for object attached to Node
+ */
+ DestDesc = AcpiNsGetAttachedObject (Node);
+ if (!DestDesc)
+ {
+ /*
+ * There is no existing object attached to this Node
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToNte: Internal error - no destination object for %4.4s type %d\n",
+ &Node->Name, DestinationType));
+ Status = AE_AML_INTERNAL;
+ goto CleanUpAndBailOut;
+ }
+
+ /*
+ * Make sure the destination Object is the same as the Node
+ */
+ if (DestDesc->Common.Type != (UINT8) DestinationType)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToNte: Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
+ &Node->Name, AcpiNsGetType (Node),
+ DestDesc->Common.Type, DestDesc));
+ Status = AE_AML_INTERNAL;
+ goto CleanUpAndBailOut;
+ }
+
+ /*
+ * AcpiEverything is ready to execute now, We have
+ * a value we can handle, just perform the update
+ */
+
+ switch (DestinationType)
+ {
+ /* Type of Name's existing value */
+
+ case INTERNAL_TYPE_BANK_FIELD:
+
+ /*
+ * Get the global lock if needed
+ */
+ Locked = AcpiAmlAcquireGlobalLock (DestDesc->BankField.LockRule);
+
+ /*
+ * Set Bank value to select proper Bank
+ * Perform the update (Set Bank Select)
+ */
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ DestDesc->BankField.BankSelect,
+ &DestDesc->BankField.Value,
+ sizeof (DestDesc->BankField.Value));
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Set bank select successful, set data value */
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ DestDesc->BankField.BankSelect,
+ &ValDesc->BankField.Value,
+ sizeof (ValDesc->BankField.Value));
+ }
+
+ break;
+
+
+ case INTERNAL_TYPE_DEF_FIELD:
+
+ /*
+ * Get the global lock if needed
+ */
+ Locked = AcpiAmlAcquireGlobalLock (ValDesc->Field.LockRule);
+
+ /*
+ * Perform the update
+ */
+
+ switch (ValDesc->Common.Type)
+ {
+ case ACPI_TYPE_NUMBER:
+ Buffer = (UINT8 *) &ValDesc->Number.Value;
+ Length = sizeof (ValDesc->Number.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
+ Length = ValDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = (UINT8 *) ValDesc->String.Pointer;
+ Length = ValDesc->String.Length;
+ break;
+ }
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ Node, Buffer, Length);
+
+ break; /* Global Lock released below */
+
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Perform the update
+ */
+
+ switch (ValDesc->Common.Type)
+ {
+ case ACPI_TYPE_NUMBER:
+ Buffer = (UINT8 *) &ValDesc->Number.Value;
+ Length = sizeof (ValDesc->Number.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
+ Length = ValDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = (UINT8 *) ValDesc->String.Pointer;
+ Length = ValDesc->String.Length;
+ break;
+ }
+
+ /*
+ * Setting a string value replaces the old string
+ */
+
+ if (Length < DestDesc->String.Length)
+ {
+ /*
+ * Zero fill, not willing to do pointer arithmetic for
+ * archetecture independance. Just clear the whole thing
+ */
+ MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length);
+ MEMCPY(DestDesc->String.Pointer, Buffer, Length);
+ }
+ else
+ {
+ /*
+ * Free the current buffer, then allocate a buffer
+ * large enough to hold the value
+ */
+ if ( DestDesc->String.Pointer &&
+ !AcpiTbSystemTablePointer (DestDesc->String.Pointer))
+ {
+ /*
+ * Only free if not a pointer into the DSDT
+ */
+
+ AcpiCmFree(DestDesc->String.Pointer);
+ }
+
+ DestDesc->String.Pointer = AcpiCmAllocate (Length + 1);
+ DestDesc->String.Length = Length;
+
+ if (!DestDesc->String.Pointer)
+ {
+ Status = AE_NO_MEMORY;
+ goto CleanUpAndBailOut;
+ }
+
+ MEMCPY(DestDesc->String.Pointer, Buffer, Length);
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * Perform the update to the buffer
+ */
+
+ switch (ValDesc->Common.Type)
+ {
+ case ACPI_TYPE_NUMBER:
+ Buffer = (UINT8 *) &ValDesc->Number.Value;
+ Length = sizeof (ValDesc->Number.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
+ Length = ValDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = (UINT8 *) ValDesc->String.Pointer;
+ Length = ValDesc->String.Length;
+ break;
+ }
+
+ /*
+ * Buffer is a static allocation,
+ * only place what will fit in the buffer.
+ */
+ if (Length <= DestDesc->Buffer.Length)
+ {
+ /*
+ * Zero fill first, not willing to do pointer arithmetic for
+ * archetecture independence. Just clear the whole thing
+ */
+ MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length);
+ MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length);
+ }
+ else
+ {
+ /*
+ * truncate, copy only what will fit
+ */
+ MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length);
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlStoreObjectToNte: Truncating src buffer from %d to %d\n",
+ Length, DestDesc->Buffer.Length));
+ }
+ break;
+
+
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ /*
+ * Get the global lock if needed
+ */
+ Locked = AcpiAmlAcquireGlobalLock (DestDesc->IndexField.LockRule);
+
+ /*
+ * Set Index value to select proper Data register
+ * perform the update (Set index)
+ */
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ DestDesc->IndexField.Index,
+ &DestDesc->IndexField.Value,
+ sizeof (DestDesc->IndexField.Value));
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlStoreObjectToNte: IndexField: set index returned %s\n",
+ AcpiCmFormatException (Status)));
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* set index successful, next set Data value */
+
+ Status = AcpiAmlAccessNamedField (ACPI_WRITE,
+ DestDesc->IndexField.Data,
+ &ValDesc->Number.Value,
+ sizeof (ValDesc->Number.Value));
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlStoreObjectToNte: IndexField: set data returned %s\n",
+ AcpiCmFormatException (Status)));
+ }
+ break;
+
+
+ case ACPI_TYPE_FIELD_UNIT:
+
+
+ /*
+ * If the Field Buffer and Index have not been previously evaluated,
+ * evaluate them and save the results.
+ */
+ if (!(DestDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetFieldUnitArguments (DestDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if ((!DestDesc->FieldUnit.Container ||
+ ACPI_TYPE_BUFFER != DestDesc->FieldUnit.Container->Common.Type))
+ {
+ DUMP_PATHNAME (Node,
+ "AmlStoreObjectToNte: FieldUnit: Bad container in ",
+ ACPI_ERROR, _COMPONENT);
+ DUMP_ENTRY (Node, ACPI_ERROR);
+ DEBUG_PRINT (ACPI_ERROR,
+ ("Container: %p", DestDesc->FieldUnit.Container));
+
+ if (DestDesc->FieldUnit.Container)
+ {
+ DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %d",
+ DestDesc->FieldUnit.Container->Common.Type));
+ }
+ DEBUG_PRINT_RAW (ACPI_ERROR, ("\n"));
+
+ Status = AE_AML_INTERNAL;
+ goto CleanUpAndBailOut;
+ }
+
+ /*
+ * Get the global lock if needed
+ */
+ Locked = AcpiAmlAcquireGlobalLock (DestDesc->FieldUnit.LockRule);
+
+ /*
+ * TBD: [Unhandled] REMOVE this limitation
+ * Make sure the operation is within the limits of our implementation
+ * this is not a Spec limitation!!
+ */
+ if (DestDesc->FieldUnit.Length + DestDesc->FieldUnit.BitOffset > 32)
+ {
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToNte: FieldUnit: Implementation limitation - Field exceeds UINT32\n"));
+ Status = AE_NOT_IMPLEMENTED;
+ goto CleanUpAndBailOut;
+ }
+
+ /* Field location is (base of buffer) + (byte offset) */
+
+ Location = DestDesc->FieldUnit.Container->Buffer.Pointer
+ + DestDesc->FieldUnit.Offset;
+
+ /*
+ * Construct Mask with 1 bits where the field is,
+ * 0 bits elsewhere
+ */
+ Mask = ((UINT32) 1 << DestDesc->FieldUnit.Length) - ((UINT32)1
+ << DestDesc->FieldUnit.BitOffset);
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("** Store %lx in buffer %p byte %ld bit %d width %d addr %p mask %08lx\n",
+ ValDesc->Number.Value,
+ DestDesc->FieldUnit.Container->Buffer.Pointer,
+ DestDesc->FieldUnit.Offset, DestDesc->FieldUnit.BitOffset,
+ DestDesc->FieldUnit.Length,Location, Mask));
+
+ /* Zero out the field in the buffer */
+
+ MOVE_UNALIGNED32_TO_32 (&NewValue, Location);
+ NewValue &= ~Mask;
+
+ /*
+ * Shift and mask the new value into position,
+ * and or it into the buffer.
+ */
+ NewValue |= (ValDesc->Number.Value << DestDesc->FieldUnit.BitOffset) &
+ Mask;
+
+ /* Store back the value */
+
+ MOVE_UNALIGNED32_TO_32 (Location, &NewValue);
+
+ DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue));
+ break;
+
+
+ case ACPI_TYPE_NUMBER:
+
+ DestDesc->Number.Value = ValDesc->Number.Value;
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ /*
+ * TBD: [Unhandled] Not real sure what to do here
+ */
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+
+
+ default:
+
+ /*
+ * All other types than Alias and the various Fields come here.
+ * Store ValDesc as the new value of the Name, and set
+ * the Name's type to that of the value being stored in it.
+ * ValDesc reference count is incremented by AttachObject.
+ */
+
+ DEBUG_PRINT (ACPI_WARN,
+ ("AmlStoreObjectToNte: Store into %s not implemented\n",
+ AcpiCmGetTypeName (AcpiNsGetType (Node))));
+
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+ }
+
+
+CleanUpAndBailOut:
+
+ /*
+ * Release global lock if we acquired it earlier
+ */
+ AcpiAmlReleaseGlobalLock (Locked);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c
new file mode 100644
index 0000000..205fdad
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c
@@ -0,0 +1,442 @@
+
+/******************************************************************************
+ *
+ * Module Name: amstorob - AML Interpreter object store support, store to object
+ * $Revision: 16 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMSTOROB_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "actables.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amstorob")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlStoreObjectToObject
+ *
+ * PARAMETERS: *ValDesc - Value to be stored
+ * *DestDesc - Object to receive the value
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store an object to another object.
+ *
+ * The Assignment of an object to another (not named) object
+ * is handled here.
+ * The val passed in will replace the current value (if any)
+ * with the input value.
+ *
+ * When storing into an object the data is converted to the
+ * target object type then stored in the object. This means
+ * that the target object type (for an initialized target) will
+ * not be changed by a store operation.
+ *
+ * This module allows destination types of Number, String,
+ * and Buffer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlStoreObjectToObject (
+ ACPI_OPERAND_OBJECT *ValDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 *Buffer = NULL;
+ UINT32 Length = 0;
+ OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type;
+
+
+ FUNCTION_TRACE ("AmlStoreObjectToObject");
+
+ DEBUG_PRINT (ACPI_INFO,
+ ("entered AcpiAmlStoreObjectToObject: Dest=%p, Val=%p\n",
+ DestDesc, ValDesc));
+
+ /*
+ * Assuming the parameters are valid!!!
+ */
+ ACPI_ASSERT((DestDesc) && (ValDesc));
+
+ DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %s into %s\n",
+ AcpiCmGetTypeName (ValDesc->Common.Type),
+ AcpiCmGetTypeName (DestDesc->Common.Type)));
+
+ /*
+ * First ensure we have a value that can be stored in the target
+ */
+ switch (DestinationType)
+ {
+ /* Type of Name's existing value */
+
+ case ACPI_TYPE_NUMBER:
+
+ /*
+ * These cases all require only number values or values that
+ * can be converted to numbers.
+ *
+ * If value is not a Number, try to resolve it to one.
+ */
+
+ if (ValDesc->Common.Type != ACPI_TYPE_NUMBER)
+ {
+ /*
+ * Initially not a number, convert
+ */
+ Status = AcpiAmlResolveToValue (&ValDesc, WalkState);
+ if (ACPI_SUCCESS (Status) &&
+ (ValDesc->Common.Type != ACPI_TYPE_NUMBER))
+ {
+ /*
+ * Conversion successful but still not a number
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToObject: Value assigned to %s must be Number, not %s\n",
+ AcpiCmGetTypeName (DestinationType),
+ AcpiCmGetTypeName (ValDesc->Common.Type)));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ }
+
+ break;
+
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * Storing into a Field in a region or into a buffer or into
+ * a string all is essentially the same.
+ *
+ * If value is not a valid type, try to resolve it to one.
+ */
+
+ if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ /*
+ * Initially not a valid type, convert
+ */
+ Status = AcpiAmlResolveToValue (&ValDesc, WalkState);
+ if (ACPI_SUCCESS (Status) &&
+ (ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (ValDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ /*
+ * Conversion successful but still not a valid type
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlStoreObjectToObject: Assign wrong type %s to %s (must be type Num/Str/Buf)\n",
+ AcpiCmGetTypeName (ValDesc->Common.Type),
+ AcpiCmGetTypeName (DestinationType)));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ }
+ break;
+
+
+ default:
+
+ /*
+ * TBD: [Unhandled] What other combinations must be implemented?
+ */
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+ }
+
+ /* Exit now if failure above */
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto CleanUpAndBailOut;
+ }
+
+ /*
+ * AcpiEverything is ready to execute now, We have
+ * a value we can handle, just perform the update
+ */
+
+ switch (DestinationType)
+ {
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Perform the update
+ */
+
+ switch (ValDesc->Common.Type)
+ {
+ case ACPI_TYPE_NUMBER:
+ Buffer = (UINT8 *) &ValDesc->Number.Value;
+ Length = sizeof (ValDesc->Number.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
+ Length = ValDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = (UINT8 *) ValDesc->String.Pointer;
+ Length = ValDesc->String.Length;
+ break;
+ }
+
+ /*
+ * Setting a string value replaces the old string
+ */
+
+ if (Length < DestDesc->String.Length)
+ {
+ /*
+ * Zero fill, not willing to do pointer arithmetic for
+ * architecture independence. Just clear the whole thing
+ */
+ MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length);
+ MEMCPY(DestDesc->String.Pointer, Buffer, Length);
+ }
+ else
+ {
+ /*
+ * Free the current buffer, then allocate a buffer
+ * large enough to hold the value
+ */
+ if ( DestDesc->String.Pointer &&
+ !AcpiTbSystemTablePointer (DestDesc->String.Pointer))
+ {
+ /*
+ * Only free if not a pointer into the DSDT
+ */
+
+ AcpiCmFree(DestDesc->String.Pointer);
+ }
+
+ DestDesc->String.Pointer = AcpiCmAllocate (Length + 1);
+ DestDesc->String.Length = Length;
+
+ if (!DestDesc->String.Pointer)
+ {
+ Status = AE_NO_MEMORY;
+ goto CleanUpAndBailOut;
+ }
+
+ MEMCPY(DestDesc->String.Pointer, Buffer, Length);
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * Perform the update to the buffer
+ */
+
+ switch (ValDesc->Common.Type)
+ {
+ case ACPI_TYPE_NUMBER:
+ Buffer = (UINT8 *) &ValDesc->Number.Value;
+ Length = sizeof (ValDesc->Number.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
+ Length = ValDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = (UINT8 *) ValDesc->String.Pointer;
+ Length = ValDesc->String.Length;
+ break;
+ }
+
+ /*
+ * If the buffer is uninitialized,
+ * memory needs to be allocated for the copy.
+ */
+ if(0 == DestDesc->Buffer.Length)
+ {
+ DestDesc->Buffer.Pointer = AcpiCmCallocate(Length);
+ DestDesc->Buffer.Length = Length;
+
+ if (!DestDesc->Buffer.Pointer)
+ {
+ Status = AE_NO_MEMORY;
+ goto CleanUpAndBailOut;
+ }
+ }
+
+ /*
+ * Buffer is a static allocation,
+ * only place what will fit in the buffer.
+ */
+ if (Length <= DestDesc->Buffer.Length)
+ {
+ /*
+ * Zero fill first, not willing to do pointer arithmetic for
+ * architecture independence. Just clear the whole thing
+ */
+ MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length);
+ MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length);
+ }
+ else
+ {
+ /*
+ * truncate, copy only what will fit
+ */
+ MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length);
+ DEBUG_PRINT (ACPI_INFO,
+ ("AmlStoreObjectToObject: Truncating src buffer from %d to %d\n",
+ Length, DestDesc->Buffer.Length));
+ }
+ break;
+
+ case ACPI_TYPE_NUMBER:
+
+ DestDesc->Number.Value = ValDesc->Number.Value;
+ break;
+
+ default:
+
+ /*
+ * All other types than Alias and the various Fields come here.
+ * Store ValDesc as the new value of the Name, and set
+ * the Name's type to that of the value being stored in it.
+ * ValDesc reference count is incremented by AttachObject.
+ */
+
+ DEBUG_PRINT (ACPI_WARN,
+ ("AmlStoreObjectToObject: Store into %s not implemented\n",
+ AcpiCmGetTypeName (DestDesc->Common.Type)));
+
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+ }
+
+CleanUpAndBailOut:
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c
new file mode 100644
index 0000000..d4c1923
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c
@@ -0,0 +1,463 @@
+
+/******************************************************************************
+ *
+ * Module Name: amsystem - Interface to OS services
+ * $Revision: 52 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMSYSTEM_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "achware.h"
+#include "acevents.h"
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amsystem")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemThreadId
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Current Thread ID (for this implementation a 1 is returned)
+ *
+ * DESCRIPTION: An invocation is identified by its Thread ID. In a single
+ * threaded OS the Thread ID is undefined so a 1 will be
+ * returned.
+ *
+ ******************************************************************************/
+
+UINT16
+AcpiAmlSystemThreadId (void)
+{
+ return (1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemWaitSemaphore
+ *
+ * PARAMETERS: Semaphore - OSD semaphore to wait on
+ * Timeout - Max time to wait
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements a semaphore wait with a check to see if the
+ * semaphore is available immediately. If it is not, the
+ * interpreter is released.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemWaitSemaphore (
+ ACPI_HANDLE Semaphore,
+ UINT32 Timeout)
+{
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AcpiAmlSystemWaitSemaphore");
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, 0);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Status == AE_TIME)
+ {
+ /* We must wait, so unlock the interpreter */
+
+ AcpiAmlExitInterpreter ();
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
+
+ /* Reacquire the interpreter */
+
+ AcpiAmlEnterInterpreter ();
+
+ DEBUG_PRINT (TRACE_EXEC,
+ ("*** Thread awake and inside interpreter after blocking, %s\n",
+ AcpiCmFormatException (Status)));
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemDoStall
+ *
+ * PARAMETERS: HowLong - The amount of time to stall
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Suspend running thread for specified amount of time.
+ *
+ ******************************************************************************/
+
+void
+AcpiAmlSystemDoStall (
+ UINT32 HowLong)
+{
+
+ if (HowLong > 1000) /* 1 millisecond */
+ {
+ /* Since this thread will sleep, we must release the interpreter */
+
+ AcpiAmlExitInterpreter ();
+
+ AcpiOsSleepUsec (HowLong);
+
+ /* And now we must get the interpreter again */
+
+ AcpiAmlEnterInterpreter ();
+ }
+
+ else
+ {
+ AcpiOsSleepUsec (HowLong);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemDoSuspend
+ *
+ * PARAMETERS: HowLong - The amount of time to suspend
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Suspend running thread for specified amount of time.
+ *
+ ******************************************************************************/
+
+void
+AcpiAmlSystemDoSuspend (
+ UINT32 HowLong)
+{
+ /* Since this thread will sleep, we must release the interpreter */
+
+ AcpiAmlExitInterpreter ();
+
+ AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000),
+ (UINT16) (HowLong % (UINT32) 1000));
+
+ /* And now we must get the interpreter again */
+
+ AcpiAmlEnterInterpreter ();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemAcquireMutex
+ *
+ * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor
+ * *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This function will cause a lock to be generated
+ * for the Mutex pointed to by ObjDesc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemAcquireMutex (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_PTR ("AcpiAmlSystemAcquireMutex", ObjDesc);
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Support for the _GL_ Mutex object -- go get the global lock
+ */
+
+ if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)
+ {
+ Status = AcpiEvAcquireGlobalLock ();
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Mutex.Semaphore,
+ (UINT32) TimeDesc->Number.Value);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemReleaseMutex
+ *
+ * PARAMETERS: *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This operation is a request to release a
+ * previously acquired Mutex. If the Mutex variable is set then
+ * it will be decremented.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemReleaseMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE ("AcpiAmlSystemReleaseMutex");
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Support for the _GL_ Mutex object -- release the global lock
+ */
+ if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)
+ {
+ AcpiEvReleaseGlobalLock ();
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ Status = AcpiOsSignalSemaphore (ObjDesc->Mutex.Semaphore, 1);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemSignalEvent
+ *
+ * PARAMETERS: *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: AE_OK
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemSignalEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE ("AcpiAmlSystemSignalEvent");
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiOsSignalSemaphore (ObjDesc->Event.Semaphore, 1);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemWaitEvent
+ *
+ * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor
+ * *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This operation is a request to wait for an
+ * event.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemWaitEvent (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE ("AcpiAmlSystemWaitEvent");
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Event.Semaphore,
+ (UINT32) TimeDesc->Number.Value);
+ }
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlSystemResetEvent
+ *
+ * PARAMETERS: *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlSystemResetEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+ void *TempSemaphore;
+
+
+ /*
+ * We are going to simply delete the existing semaphore and
+ * create a new one!
+ */
+
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore);
+ ObjDesc->Mutex.Semaphore = TempSemaphore;
+ }
+
+ return (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c
new file mode 100644
index 0000000..56dbc67
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c
@@ -0,0 +1,652 @@
+
+/******************************************************************************
+ *
+ * Module Name: amutils - interpreter/scanner utilities
+ * $Revision: 56 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMUTILS_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acevents.h"
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amutils")
+
+
+typedef struct Internal_Search_st
+{
+ ACPI_OPERAND_OBJECT *DestObj;
+ UINT32 Index;
+ ACPI_OPERAND_OBJECT *SourceObj;
+
+} INTERNAL_PKG_SEARCH_INFO;
+
+
+/* Used to traverse nested packages when copying*/
+
+INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH];
+
+
+static NATIVE_CHAR hex[] =
+ {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlEnterInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * DESCRIPTION: Enter the interpreter execution region
+ *
+ ******************************************************************************/
+
+void
+AcpiAmlEnterInterpreter (void)
+{
+ FUNCTION_TRACE ("AmlEnterInterpreter");
+
+
+ AcpiCmAcquireMutex (ACPI_MTX_EXECUTE);
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExitInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * DESCRIPTION: Exit the interpreter execution region
+ *
+ * Cases where the interpreter is unlocked:
+ * 1) Completion of the execution of a control method
+ * 2) Method blocked on a Sleep() AML opcode
+ * 3) Method blocked on an Acquire() AML opcode
+ * 4) Method blocked on a Wait() AML opcode
+ * 5) Method blocked to acquire the global lock
+ * 6) Method blocked to execute a serialized control method that is
+ * already executing
+ * 7) About to invoke a user-installed opregion handler
+ *
+ ******************************************************************************/
+
+void
+AcpiAmlExitInterpreter (void)
+{
+ FUNCTION_TRACE ("AmlExitInterpreter");
+
+
+ AcpiCmReleaseMutex (ACPI_MTX_EXECUTE);
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlValidateObjectType
+ *
+ * PARAMETERS: Type Object type to validate
+ *
+ * DESCRIPTION: Determine if a type is a valid ACPI object type
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiAmlValidateObjectType (
+ ACPI_OBJECT_TYPE Type)
+{
+
+ if ((Type > ACPI_TYPE_MAX && Type < INTERNAL_TYPE_BEGIN) ||
+ (Type > INTERNAL_TYPE_MAX))
+ {
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlBufSeq
+ *
+ * RETURN: The next buffer descriptor sequence number
+ *
+ * DESCRIPTION: Provide a unique sequence number for each Buffer descriptor
+ * allocated during the interpreter's existence. These numbers
+ * are used to relate FieldUnit descriptors to the Buffers
+ * within which the fields are defined.
+ *
+ * Just increment the global counter and return it.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiAmlBufSeq (void)
+{
+
+ return (++AcpiGbl_BufSeq);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlAcquireGlobalLock
+ *
+ * PARAMETERS: Rule - Lock rule: AlwaysLock, NeverLock
+ *
+ * RETURN: TRUE/FALSE indicating whether the lock was actually acquired
+ *
+ * DESCRIPTION: Obtain the global lock and keep track of this fact via two
+ * methods. A global variable keeps the state of the lock, and
+ * the state is returned to the caller.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiAmlAcquireGlobalLock (
+ UINT32 Rule)
+{
+ BOOLEAN Locked = FALSE;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlAcquireGlobalLock");
+
+
+ /* Only attempt lock if the Rule says so */
+
+ if (Rule == (UINT32) GLOCK_ALWAYS_LOCK)
+ {
+ /* OK to get the lock */
+
+ Status = AcpiEvAcquireGlobalLock ();
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("Get Global Lock Failed!!\n"));
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiGbl_GlobalLockSet = TRUE;
+ Locked = TRUE;
+ }
+ }
+
+ return_VALUE (Locked);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlReleaseGlobalLock
+ *
+ * PARAMETERS: LockedByMe - Return value from corresponding call to
+ * AcquireGlobalLock.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release the global lock if it is locked.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlReleaseGlobalLock (
+ BOOLEAN LockedByMe)
+{
+
+ FUNCTION_TRACE ("AmlReleaseGlobalLock");
+
+
+ /* Only attempt unlock if the caller locked it */
+
+ if (LockedByMe)
+ {
+ /* Double check against the global flag */
+
+ if (AcpiGbl_GlobalLockSet)
+ {
+ /* OK, now release the lock */
+
+ AcpiEvReleaseGlobalLock ();
+ AcpiGbl_GlobalLockSet = FALSE;
+ }
+
+ else
+ {
+ DEBUG_PRINT (ACPI_ERROR, ("Global lock was not set\n"));
+ }
+ }
+
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlDigitsNeeded
+ *
+ * PARAMETERS: val - Value to be represented
+ * base - Base of representation
+ *
+ * RETURN: the number of digits needed to represent val in base
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiAmlDigitsNeeded (
+ ACPI_INTEGER val,
+ UINT32 base)
+{
+ UINT32 NumDigits = 0;
+
+
+ FUNCTION_TRACE ("AmlDigitsNeeded");
+
+
+ if (base < 1)
+ {
+ REPORT_ERROR (("AmlDigitsNeeded: Internal error - Invalid base\n"));
+ }
+
+ else
+ {
+ for (NumDigits = 1 + (val < 0) ; val /= base ; ++NumDigits)
+ { ; }
+ }
+
+ return_VALUE (NumDigits);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: ntohl
+ *
+ * PARAMETERS: Value - Value to be converted
+ *
+ * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
+ *
+ ******************************************************************************/
+
+UINT32
+_ntohl (
+ UINT32 Value)
+{
+ union
+ {
+ UINT32 Value;
+ UINT8 Bytes[4];
+ } Out;
+
+ union
+ {
+ UINT32 Value;
+ UINT8 Bytes[4];
+ } In;
+
+
+ In.Value = Value;
+
+ Out.Bytes[0] = In.Bytes[3];
+ Out.Bytes[1] = In.Bytes[2];
+ Out.Bytes[2] = In.Bytes[1];
+ Out.Bytes[3] = In.Bytes[0];
+
+ return (Out.Value);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlEisaIdToString
+ *
+ * PARAMETERS: NumericId - EISA ID to be converted
+ * OutString - Where to put the converted string (8 bytes)
+ *
+ * DESCRIPTION: Convert a numeric EISA ID to string representation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlEisaIdToString (
+ UINT32 NumericId,
+ NATIVE_CHAR *OutString)
+{
+ UINT32 id;
+
+ /* swap to big-endian to get contiguous bits */
+
+ id = _ntohl (NumericId);
+
+ OutString[0] = (char) ('@' + ((id >> 26) & 0x1f));
+ OutString[1] = (char) ('@' + ((id >> 21) & 0x1f));
+ OutString[2] = (char) ('@' + ((id >> 16) & 0x1f));
+ OutString[3] = hex[(id >> 12) & 0xf];
+ OutString[4] = hex[(id >> 8) & 0xf];
+ OutString[5] = hex[(id >> 4) & 0xf];
+ OutString[6] = hex[id & 0xf];
+ OutString[7] = 0;
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlUnsignedIntegerToString
+ *
+ * PARAMETERS: Value - Value to be converted
+ * OutString - Where to put the converted string (8 bytes)
+ *
+ * RETURN: Convert a number to string representation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlUnsignedIntegerToString (
+ ACPI_INTEGER Value,
+ NATIVE_CHAR *OutString)
+{
+ UINT32 Count;
+ UINT32 DigitsNeeded;
+
+
+ DigitsNeeded = AcpiAmlDigitsNeeded (Value, 10);
+
+ OutString[DigitsNeeded] = '\0';
+
+ for (Count = DigitsNeeded; Count > 0; Count--)
+ {
+ OutString[Count-1] = (NATIVE_CHAR) ('0' + (Value % 10));
+ Value /= 10;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlBuildCopyInternalPackageObject
+ *
+ * PARAMETERS: *SourceObj - Pointer to the source package object
+ * *DestObj - Where the internal object is returned
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to copy an internal package object
+ * into another internal package object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlBuildCopyInternalPackageObject (
+ ACPI_OPERAND_OBJECT *SourceObj,
+ ACPI_OPERAND_OBJECT *DestObj,
+ ACPI_WALK_STATE *WalkState)
+{
+ UINT32 CurrentDepth = 0;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Length = 0;
+ UINT32 ThisIndex;
+ UINT32 ObjectSpace = 0;
+ ACPI_OPERAND_OBJECT *ThisDestObj;
+ ACPI_OPERAND_OBJECT *ThisSourceObj;
+ INTERNAL_PKG_SEARCH_INFO *LevelPtr;
+
+
+ FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject");
+
+
+ /*
+ * Initialize the working variables
+ */
+
+ MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel));
+
+ CopyLevel[0].DestObj = DestObj;
+ CopyLevel[0].SourceObj = SourceObj;
+ LevelPtr = &CopyLevel[0];
+ CurrentDepth = 0;
+
+ DestObj->Common.Type = SourceObj->Common.Type;
+ DestObj->Package.Count = SourceObj->Package.Count;
+
+
+ /*
+ * Build an array of ACPI_OBJECTS in the buffer
+ * and move the free space past it
+ */
+
+ DestObj->Package.Elements = AcpiCmCallocate (
+ (DestObj->Package.Count + 1) *
+ sizeof (void *));
+ if (!DestObj->Package.Elements)
+ {
+ /* Package vector allocation failure */
+
+ REPORT_ERROR (("AmlBuildCopyInternalPackageObject: Package vector allocation failure\n"));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ DestObj->Package.NextElement = DestObj->Package.Elements;
+
+
+ while (1)
+ {
+ ThisIndex = LevelPtr->Index;
+ ThisDestObj = (ACPI_OPERAND_OBJECT *) LevelPtr->DestObj->Package.Elements[ThisIndex];
+ ThisSourceObj = (ACPI_OPERAND_OBJECT *) LevelPtr->SourceObj->Package.Elements[ThisIndex];
+
+ if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE))
+ {
+ /*
+ * If this object is a package then we go one deeper
+ */
+ if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
+ {
+ /*
+ * Too many nested levels of packages for us to handle
+ */
+ DEBUG_PRINT (ACPI_ERROR,
+ ("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %d)\n",
+ MAX_PACKAGE_DEPTH));
+ return_ACPI_STATUS (AE_LIMIT);
+ }
+
+ /*
+ * Build the package object
+ */
+ ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE);
+ LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj;
+
+
+ ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE;
+ ThisDestObj->Package.Count = ThisDestObj->Package.Count;
+
+ /*
+ * Save space for the array of objects (Package elements)
+ * update the buffer length counter
+ */
+ ObjectSpace = ThisDestObj->Package.Count *
+ sizeof (ACPI_OPERAND_OBJECT);
+ Length += ObjectSpace;
+ CurrentDepth++;
+ LevelPtr = &CopyLevel[CurrentDepth];
+ LevelPtr->DestObj = ThisDestObj;
+ LevelPtr->SourceObj = ThisSourceObj;
+ LevelPtr->Index = 0;
+
+ } /* if object is a package */
+
+ else
+ {
+
+ ThisDestObj = AcpiCmCreateInternalObject (
+ ThisSourceObj->Common.Type);
+ LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj;
+
+ Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj, WalkState);
+
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * Failure get out
+ */
+ return_ACPI_STATUS (Status);
+ }
+
+ Length +=ObjectSpace;
+
+ LevelPtr->Index++;
+ while (LevelPtr->Index >= LevelPtr->DestObj->Package.Count)
+ {
+ /*
+ * We've handled all of the objects at this level, This means
+ * that we have just completed a package. That package may
+ * have contained one or more packages itself
+ */
+ if (CurrentDepth == 0)
+ {
+ /*
+ * We have handled all of the objects in the top level
+ * package just add the length of the package objects
+ * and exit
+ */
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Go back up a level and move the index past the just
+ * completed package object.
+ */
+ CurrentDepth--;
+ LevelPtr = &CopyLevel[CurrentDepth];
+ LevelPtr->Index++;
+ }
+ } /* else object is NOT a package */
+ } /* while (1) */
+}
+
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c
new file mode 100644
index 0000000..1c0380e
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c
@@ -0,0 +1,190 @@
+
+/******************************************************************************
+ *
+ * Module Name: amxface - External interpreter interfaces
+ * $Revision: 22 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __AMXFACE_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT INTERPRETER
+ MODULE_NAME ("amxface")
+
+
+/*
+ * DEFINE_AML_GLOBALS is tested in amlcode.h
+ * to determine whether certain global names should be "defined" or only
+ * "declared" in the current compilation. This enhances maintainability
+ * by enabling a single header file to embody all knowledge of the names
+ * in question.
+ *
+ * Exactly one module of any executable should #define DEFINE_GLOBALS
+ * before #including the header files which use this convention. The
+ * names in question will be defined and initialized in that module,
+ * and declared as extern in all other modules which #include those
+ * header files.
+ */
+
+#define DEFINE_AML_GLOBALS
+#include "amlcode.h"
+#include "acparser.h"
+#include "acnamesp.h"
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAmlExecuteMethod
+ *
+ * PARAMETERS: Pcode - Pointer to the pcode stream
+ * PcodeLength - Length of pcode that comprises the method
+ * **Params - List of parameters to pass to method,
+ * terminated by NULL. Params itself may be
+ * NULL if no parameters are being passed.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a control method
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAmlExecuteMethod (
+ ACPI_NAMESPACE_NODE *MethodNode,
+ ACPI_OPERAND_OBJECT **Params,
+ ACPI_OPERAND_OBJECT **ReturnObjDesc)
+{
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AmlExecuteMethod");
+
+
+ /*
+ * The point here is to lock the interpreter and call the low
+ * level execute.
+ */
+
+ AcpiAmlEnterInterpreter ();
+
+ Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc);
+
+ AcpiAmlExitInterpreter ();
+
+ return_ACPI_STATUS (Status);
+}
+
+
OpenPOWER on IntegriCloud