aboutsummaryrefslogtreecommitdiff
path: root/source/components/executer
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2012-02-16 00:24:10 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2012-02-16 00:24:10 +0000
commit5437485bdb98c4b00f15969e013c454426e9c862 (patch)
tree71526afe7e3c45a4c88ba7b5d8d57d1e469feec2 /source/components/executer
parent234358d94982312d34c80b868fea481307fb3a48 (diff)
downloadsrc-5437485bdb98c4b00f15969e013c454426e9c862.tar.gz
src-5437485bdb98c4b00f15969e013c454426e9c862.zip
Import ACPICA 20120215.vendor/acpica/20120215
Notes
Notes: svn path=/vendor-sys/acpica/dist/; revision=231798 svn path=/vendor-sys/acpica/20120215/; revision=231799; tag=vendor/acpica/20120215
Diffstat (limited to 'source/components/executer')
-rw-r--r--source/components/executer/exconfig.c688
-rw-r--r--source/components/executer/exconvrt.c754
-rw-r--r--source/components/executer/excreate.c574
-rw-r--r--source/components/executer/exdebug.c278
-rw-r--r--source/components/executer/exdump.c1124
-rw-r--r--source/components/executer/exfield.c406
-rw-r--r--source/components/executer/exfldio.c1055
-rw-r--r--source/components/executer/exmisc.c800
-rw-r--r--source/components/executer/exmutex.c554
-rw-r--r--source/components/executer/exnames.c488
-rw-r--r--source/components/executer/exoparg1.c1111
-rw-r--r--source/components/executer/exoparg2.c642
-rw-r--r--source/components/executer/exoparg3.c304
-rw-r--r--source/components/executer/exoparg6.c365
-rw-r--r--source/components/executer/exprep.c648
-rw-r--r--source/components/executer/exregion.c565
-rw-r--r--source/components/executer/exresnte.c302
-rw-r--r--source/components/executer/exresolv.c580
-rw-r--r--source/components/executer/exresop.c738
-rw-r--r--source/components/executer/exstore.c531
-rw-r--r--source/components/executer/exstoren.c314
-rw-r--r--source/components/executer/exstorob.c244
-rw-r--r--source/components/executer/exsystem.c355
-rw-r--r--source/components/executer/exutils.c532
24 files changed, 13952 insertions, 0 deletions
diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c
new file mode 100644
index 000000000000..9e05497b9f56
--- /dev/null
+++ b/source/components/executer/exconfig.c
@@ -0,0 +1,688 @@
+/******************************************************************************
+ *
+ * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXCONFIG_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "actables.h"
+#include "acdispat.h"
+#include "acevents.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exconfig")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExAddTable (
+ UINT32 TableIndex,
+ ACPI_NAMESPACE_NODE *ParentNode,
+ ACPI_OPERAND_OBJECT **DdbHandle);
+
+static ACPI_STATUS
+AcpiExRegionRead (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Length,
+ UINT8 *Buffer);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAddTable
+ *
+ * PARAMETERS: Table - Pointer to raw table
+ * ParentNode - Where to load the table (scope)
+ * DdbHandle - Where to return the table handle.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common function to Install and Load an ACPI table with a
+ * returned table handle.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExAddTable (
+ UINT32 TableIndex,
+ ACPI_NAMESPACE_NODE *ParentNode,
+ ACPI_OPERAND_OBJECT **DdbHandle)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ ACPI_OWNER_ID OwnerId;
+
+
+ ACPI_FUNCTION_TRACE (ExAddTable);
+
+
+ /* Create an object to be the table handle */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Init the table handle */
+
+ ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
+ ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE;
+ *DdbHandle = ObjDesc;
+
+ /* Install the new table into the local data structures */
+
+ ObjDesc->Reference.Value = TableIndex;
+
+ /* Add the table to the namespace */
+
+ Status = AcpiNsLoadTable (TableIndex, ParentNode);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ *DdbHandle = NULL;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Execute any module-level code that was found in the table */
+
+ AcpiExExitInterpreter ();
+ AcpiNsExecModuleCodeList ();
+ AcpiExEnterInterpreter ();
+
+ /*
+ * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
+ * responsible for discovering any new wake GPEs by running _PRW methods
+ * that may have been loaded by this table.
+ */
+ Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiEvUpdateGpes (OwnerId);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExLoadTableOp
+ *
+ * PARAMETERS: WalkState - Current state with operands
+ * ReturnDesc - Where to store the return object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load an ACPI table from the RSDT/XSDT
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExLoadTableOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_NAMESPACE_NODE *ParentNode;
+ ACPI_NAMESPACE_NODE *StartNode;
+ ACPI_NAMESPACE_NODE *ParameterNode = NULL;
+ ACPI_OPERAND_OBJECT *DdbHandle;
+ ACPI_TABLE_HEADER *Table;
+ UINT32 TableIndex;
+
+
+ ACPI_FUNCTION_TRACE (ExLoadTableOp);
+
+
+ /* Validate lengths for the SignatureString, OEMIDString, OEMTableID */
+
+ if ((Operand[0]->String.Length > ACPI_NAME_SIZE) ||
+ (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) ||
+ (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Find the ACPI table in the RSDT/XSDT */
+
+ Status = AcpiTbFindTable (Operand[0]->String.Pointer,
+ Operand[1]->String.Pointer,
+ Operand[2]->String.Pointer, &TableIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status != AE_NOT_FOUND)
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Table not found, return an Integer=0 and AE_OK */
+
+ DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!DdbHandle)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ *ReturnDesc = DdbHandle;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Default nodes */
+
+ StartNode = WalkState->ScopeInfo->Scope.Node;
+ ParentNode = AcpiGbl_RootNode;
+
+ /* RootPath (optional parameter) */
+
+ if (Operand[3]->String.Length > 0)
+ {
+ /*
+ * Find the node referenced by the RootPathString. This is the
+ * location within the namespace where the table will be loaded.
+ */
+ Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer,
+ ACPI_NS_SEARCH_PARENT, &ParentNode);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* ParameterPath (optional parameter) */
+
+ if (Operand[4]->String.Length > 0)
+ {
+ if ((Operand[4]->String.Pointer[0] != '\\') &&
+ (Operand[4]->String.Pointer[0] != '^'))
+ {
+ /*
+ * Path is not absolute, so it will be relative to the node
+ * referenced by the RootPathString (or the NS root if omitted)
+ */
+ StartNode = ParentNode;
+ }
+
+ /* Find the node referenced by the ParameterPathString */
+
+ Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer,
+ ACPI_NS_SEARCH_PARENT, &ParameterNode);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Load the table into the namespace */
+
+ Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Parameter Data (optional) */
+
+ if (ParameterNode)
+ {
+ /* Store the parameter data into the optional parameter object */
+
+ Status = AcpiExStore (Operand[5],
+ ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode),
+ WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ (void) AcpiExUnloadTable (DdbHandle);
+
+ AcpiUtRemoveReference (DdbHandle);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ Status = AcpiGetTableByIndex (TableIndex, &Table);
+ if (ACPI_SUCCESS (Status))
+ {
+ ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:"));
+ AcpiTbPrintTableHeader (0, Table);
+ }
+
+ /* Invoke table handler if present */
+
+ if (AcpiGbl_TableHandler)
+ {
+ (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
+ AcpiGbl_TableHandlerContext);
+ }
+
+ *ReturnDesc = DdbHandle;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRegionRead
+ *
+ * PARAMETERS: ObjDesc - Region descriptor
+ * Length - Number of bytes to read
+ * Buffer - Pointer to where to put the data
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read data from an operation region. The read starts from the
+ * beginning of the region.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExRegionRead (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Length,
+ UINT8 *Buffer)
+{
+ ACPI_STATUS Status;
+ UINT64 Value;
+ UINT32 RegionOffset = 0;
+ UINT32 i;
+
+
+ /* Bytewise reads */
+
+ for (i = 0; i < Length; i++)
+ {
+ Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ,
+ RegionOffset, 8, &Value);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ *Buffer = (UINT8) Value;
+ Buffer++;
+ RegionOffset++;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExLoadOp
+ *
+ * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be
+ * obtained
+ * Target - Where a handle to the table will be stored
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load an ACPI table from a field or operation region
+ *
+ * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer
+ * objects before this code is reached.
+ *
+ * If source is an operation region, it must refer to SystemMemory, as
+ * per the ACPI specification.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExLoadOp (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT *Target,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *DdbHandle;
+ ACPI_TABLE_HEADER *Table;
+ ACPI_TABLE_DESC TableDesc;
+ UINT32 TableIndex;
+ ACPI_STATUS Status;
+ UINT32 Length;
+
+
+ ACPI_FUNCTION_TRACE (ExLoadOp);
+
+
+ ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC));
+
+ /* Source Object can be either an OpRegion or a Buffer/Field */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_REGION:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Load table from Region %p\n", ObjDesc));
+
+ /* Region must be SystemMemory (from ACPI spec) */
+
+ if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY)
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * If the Region Address and Length have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetRegionArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Get the table header first so we can get the table length */
+
+ Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
+ if (!Table)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER),
+ ACPI_CAST_PTR (UINT8, Table));
+ Length = Table->Length;
+ ACPI_FREE (Table);
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Must have at least an ACPI table header */
+
+ if (Length < sizeof (ACPI_TABLE_HEADER))
+ {
+ return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+ }
+
+ /*
+ * The original implementation simply mapped the table, with no copy.
+ * However, the memory region is not guaranteed to remain stable and
+ * we must copy the table to a local buffer. For example, the memory
+ * region is corrupted after suspend on some machines. Dynamically
+ * loaded tables are usually small, so this overhead is minimal.
+ *
+ * The latest implementation (5/2009) does not use a mapping at all.
+ * We use the low-level operation region interface to read the table
+ * instead of the obvious optimization of using a direct mapping.
+ * This maintains a consistent use of operation regions across the
+ * entire subsystem. This is important if additional processing must
+ * be performed in the (possibly user-installed) operation region
+ * handler. For example, AcpiExec and ASLTS depend on this.
+ */
+
+ /* Allocate a buffer for the table */
+
+ TableDesc.Pointer = ACPI_ALLOCATE (Length);
+ if (!TableDesc.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Read the entire table */
+
+ Status = AcpiExRegionRead (ObjDesc, Length,
+ ACPI_CAST_PTR (UINT8, TableDesc.Pointer));
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (TableDesc.Pointer);
+ return_ACPI_STATUS (Status);
+ }
+
+ TableDesc.Address = ObjDesc->Region.Address;
+ break;
+
+
+ case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Load table from Buffer or Field %p\n", ObjDesc));
+
+ /* Must have at least an ACPI table header */
+
+ if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER))
+ {
+ return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+ }
+
+ /* Get the actual table length from the table header */
+
+ Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer);
+ Length = Table->Length;
+
+ /* Table cannot extend beyond the buffer */
+
+ if (Length > ObjDesc->Buffer.Length)
+ {
+ return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+ }
+ if (Length < sizeof (ACPI_TABLE_HEADER))
+ {
+ return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+ }
+
+ /*
+ * Copy the table from the buffer because the buffer could be modified
+ * or even deleted in the future
+ */
+ TableDesc.Pointer = ACPI_ALLOCATE (Length);
+ if (!TableDesc.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ACPI_MEMCPY (TableDesc.Pointer, Table, Length);
+ TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer);
+ break;
+
+
+ default:
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Validate table checksum (will not get validated in TbAddTable) */
+
+ Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (TableDesc.Pointer);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Complete the table descriptor */
+
+ TableDesc.Length = Length;
+ TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
+
+ /* Install the new table into the local data structures */
+
+ Status = AcpiTbAddTable (&TableDesc, &TableIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Delete allocated table buffer */
+
+ AcpiTbDeleteTable (&TableDesc);
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Add the table to the namespace.
+ *
+ * Note: Load the table objects relative to the root of the namespace.
+ * This appears to go against the ACPI specification, but we do it for
+ * compatibility with other ACPI implementations.
+ */
+ Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ /* On error, TablePtr was deallocated above */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Store the DdbHandle into the Target operand */
+
+ Status = AcpiExStore (DdbHandle, Target, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ (void) AcpiExUnloadTable (DdbHandle);
+
+ /* TablePtr was deallocated above */
+
+ AcpiUtRemoveReference (DdbHandle);
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:"));
+ AcpiTbPrintTableHeader (0, TableDesc.Pointer);
+
+ /* Remove the reference by added by AcpiExStore above */
+
+ AcpiUtRemoveReference (DdbHandle);
+
+ /* Invoke table handler if present */
+
+ if (AcpiGbl_TableHandler)
+ {
+ (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer,
+ AcpiGbl_TableHandlerContext);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExUnloadTable
+ *
+ * PARAMETERS: DdbHandle - Handle to a previously loaded table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Unload an ACPI table
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExUnloadTable (
+ ACPI_OPERAND_OBJECT *DdbHandle)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *TableDesc = DdbHandle;
+ UINT32 TableIndex;
+ ACPI_TABLE_HEADER *Table;
+
+
+ ACPI_FUNCTION_TRACE (ExUnloadTable);
+
+
+ /*
+ * Validate the handle
+ * Although the handle is partially validated in AcpiExReconfiguration()
+ * when it calls AcpiExResolveOperands(), the handle is more completely
+ * validated here.
+ *
+ * Handle must be a valid operand object of type reference. Also, the
+ * DdbHandle must still be marked valid (table has not been previously
+ * unloaded)
+ */
+ if ((!DdbHandle) ||
+ (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) ||
+ (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) ||
+ (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID)))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Get the table index from the DdbHandle */
+
+ TableIndex = TableDesc->Reference.Value;
+
+ /* Ensure the table is still loaded */
+
+ if (!AcpiTbIsTableLoaded (TableIndex))
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /* Invoke table handler if present */
+
+ if (AcpiGbl_TableHandler)
+ {
+ Status = AcpiGetTableByIndex (TableIndex, &Table);
+ if (ACPI_SUCCESS (Status))
+ {
+ (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table,
+ AcpiGbl_TableHandlerContext);
+ }
+ }
+
+ /* Delete the portion of the namespace owned by this table */
+
+ Status = AcpiTbDeleteNamespaceByOwner (TableIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ (void) AcpiTbReleaseOwnerId (TableIndex);
+ AcpiTbSetTableLoadedFlag (TableIndex, FALSE);
+
+ /*
+ * Invalidate the handle. We do this because the handle may be stored
+ * in a named object and may not be actually deleted until much later.
+ */
+ DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/source/components/executer/exconvrt.c b/source/components/executer/exconvrt.c
new file mode 100644
index 000000000000..e79cbc96e975
--- /dev/null
+++ b/source/components/executer/exconvrt.c
@@ -0,0 +1,754 @@
+/******************************************************************************
+ *
+ * Module Name: exconvrt - Object conversion routines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EXCONVRT_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exconvrt")
+
+/* Local prototypes */
+
+static UINT32
+AcpiExConvertToAscii (
+ UINT64 Integer,
+ UINT16 Base,
+ UINT8 *String,
+ UINT8 MaxLength);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToInteger
+ *
+ * PARAMETERS: ObjDesc - Object to be converted. Must be an
+ * Integer, Buffer, or String
+ * ResultDesc - Where the new Integer object is returned
+ * Flags - Used for string conversion
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an ACPI Object to an integer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToInteger (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc,
+ UINT32 Flags)
+{
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *Pointer;
+ UINT64 Result;
+ UINT32 i;
+ UINT32 Count;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
+
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* No conversion necessary */
+
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_STRING:
+
+ /* Note: Takes advantage of common buffer/string fields */
+
+ Pointer = ObjDesc->Buffer.Pointer;
+ Count = ObjDesc->Buffer.Length;
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /*
+ * Convert the buffer/string to an integer. Note that both buffers and
+ * strings are treated as raw data - we don't convert ascii to hex for
+ * strings.
+ *
+ * There are two terminating conditions for the loop:
+ * 1) The size of an integer has been reached, or
+ * 2) The end of the buffer or string has been reached
+ */
+ Result = 0;
+
+ /* String conversion is different than Buffer conversion */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Convert string to an integer - for most cases, the string must be
+ * hexadecimal as per the ACPI specification. The only exception (as
+ * of ACPI 3.0) is that the ToInteger() operator allows both decimal
+ * and hexadecimal strings (hex prefixed with "0x").
+ */
+ Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Check for zero-length buffer */
+
+ if (!Count)
+ {
+ return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+ }
+
+ /* Transfer no more than an integer's worth of data */
+
+ if (Count > AcpiGbl_IntegerByteWidth)
+ {
+ Count = AcpiGbl_IntegerByteWidth;
+ }
+
+ /*
+ * Convert buffer to an integer - we simply grab enough raw data
+ * from the buffer to fill an integer
+ */
+ for (i = 0; i < Count; i++)
+ {
+ /*
+ * Get next byte and shift it into the Result.
+ * Little endian is used, meaning that the first byte of the buffer
+ * is the LSB of the integer
+ */
+ Result |= (((UINT64) Pointer[i]) << (i * 8));
+ }
+ break;
+
+
+ default:
+
+ /* No other types can get here */
+ break;
+ }
+
+ /* Create a new integer */
+
+ ReturnDesc = AcpiUtCreateIntegerObject (Result);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (Result)));
+
+ /* Save the Result */
+
+ AcpiExTruncateFor32bitTable (ReturnDesc);
+ *ResultDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToBuffer
+ *
+ * PARAMETERS: ObjDesc - Object to be converted. Must be an
+ * Integer, Buffer, or String
+ * ResultDesc - Where the new buffer object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an ACPI Object to a Buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToBuffer (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc)
+{
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *NewBuf;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
+
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+
+ /* No conversion necessary */
+
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+
+
+ case ACPI_TYPE_INTEGER:
+
+ /*
+ * Create a new Buffer object.
+ * Need enough space for one integer
+ */
+ ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the integer to the buffer, LSB first */
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+ ACPI_MEMCPY (NewBuf,
+ &ObjDesc->Integer.Value,
+ AcpiGbl_IntegerByteWidth);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Create a new Buffer object
+ * Size will be the string length
+ *
+ * NOTE: Add one to the string length to include the null terminator.
+ * The ACPI spec is unclear on this subject, but there is existing
+ * ASL/AML code that depends on the null being transferred to the new
+ * buffer.
+ */
+ ReturnDesc = AcpiUtCreateBufferObject (
+ (ACPI_SIZE) ObjDesc->String.Length + 1);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the string to the buffer */
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+ ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
+ ObjDesc->String.Length);
+ break;
+
+
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /* Mark buffer initialized */
+
+ ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
+ *ResultDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToAscii
+ *
+ * PARAMETERS: Integer - Value to be converted
+ * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
+ * String - Where the string is returned
+ * DataWidth - Size of data item to be converted, in bytes
+ *
+ * RETURN: Actual string length
+ *
+ * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExConvertToAscii (
+ UINT64 Integer,
+ UINT16 Base,
+ UINT8 *String,
+ UINT8 DataWidth)
+{
+ UINT64 Digit;
+ UINT32 i;
+ UINT32 j;
+ UINT32 k = 0;
+ UINT32 HexLength;
+ UINT32 DecimalLength;
+ UINT32 Remainder;
+ BOOLEAN SupressZeros;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (Base)
+ {
+ case 10:
+
+ /* Setup max length for the decimal number */
+
+ switch (DataWidth)
+ {
+ case 1:
+ DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
+ break;
+
+ case 4:
+ DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
+ break;
+
+ case 8:
+ default:
+ DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
+ break;
+ }
+
+ SupressZeros = TRUE; /* No leading zeros */
+ Remainder = 0;
+
+ for (i = DecimalLength; i > 0; i--)
+ {
+ /* Divide by nth factor of 10 */
+
+ Digit = Integer;
+ for (j = 0; j < i; j++)
+ {
+ (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
+ }
+
+ /* Handle leading zeros */
+
+ if (Remainder != 0)
+ {
+ SupressZeros = FALSE;
+ }
+
+ if (!SupressZeros)
+ {
+ String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
+ k++;
+ }
+ }
+ break;
+
+ case 16:
+
+ /* HexLength: 2 ascii hex chars per data byte */
+
+ HexLength = ACPI_MUL_2 (DataWidth);
+ for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
+ {
+ /* Get one hex digit, most significant digits first */
+
+ String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
+ k++;
+ }
+ break;
+
+ default:
+ return (0);
+ }
+
+ /*
+ * Since leading zeros are suppressed, we must check for the case where
+ * the integer equals 0
+ *
+ * Finally, null terminate the string and return the length
+ */
+ if (!k)
+ {
+ String [0] = ACPI_ASCII_ZERO;
+ k = 1;
+ }
+
+ String [k] = 0;
+ return ((UINT32) k);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToString
+ *
+ * PARAMETERS: ObjDesc - Object to be converted. Must be an
+ * Integer, Buffer, or String
+ * ResultDesc - Where the string object is returned
+ * Type - String flags (base and conversion type)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an ACPI Object to a string
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToString (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc,
+ UINT32 Type)
+{
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *NewBuf;
+ UINT32 i;
+ UINT32 StringLength = 0;
+ UINT16 Base = 16;
+ UINT8 Separator = ',';
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
+
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ /* No conversion necessary */
+
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+
+
+ case ACPI_TYPE_INTEGER:
+
+ switch (Type)
+ {
+ case ACPI_EXPLICIT_CONVERT_DECIMAL:
+
+ /* Make room for maximum decimal number */
+
+ StringLength = ACPI_MAX_DECIMAL_DIGITS;
+ Base = 10;
+ break;
+
+ default:
+
+ /* Two hex string characters for each integer byte */
+
+ StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
+ break;
+ }
+
+ /*
+ * Create a new String
+ * Need enough space for one ASCII integer (plus null terminator)
+ */
+ ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+
+ /* Convert integer to string */
+
+ StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base,
+ NewBuf, AcpiGbl_IntegerByteWidth);
+
+ /* Null terminate at the correct place */
+
+ ReturnDesc->String.Length = StringLength;
+ NewBuf [StringLength] = 0;
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Setup string length, base, and separator */
+
+ switch (Type)
+ {
+ case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
+ /*
+ * From ACPI: "If Data is a buffer, it is converted to a string of
+ * decimal values separated by commas."
+ */
+ Base = 10;
+
+ /*
+ * Calculate the final string length. Individual string values
+ * are variable length (include separator for each)
+ */
+ for (i = 0; i < ObjDesc->Buffer.Length; i++)
+ {
+ if (ObjDesc->Buffer.Pointer[i] >= 100)
+ {
+ StringLength += 4;
+ }
+ else if (ObjDesc->Buffer.Pointer[i] >= 10)
+ {
+ StringLength += 3;
+ }
+ else
+ {
+ StringLength += 2;
+ }
+ }
+ break;
+
+ case ACPI_IMPLICIT_CONVERT_HEX:
+ /*
+ * From the ACPI spec:
+ *"The entire contents of the buffer are converted to a string of
+ * two-character hexadecimal numbers, each separated by a space."
+ */
+ Separator = ' ';
+ StringLength = (ObjDesc->Buffer.Length * 3);
+ break;
+
+ case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */
+ /*
+ * From ACPI: "If Data is a buffer, it is converted to a string of
+ * hexadecimal values separated by commas."
+ */
+ StringLength = (ObjDesc->Buffer.Length * 3);
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Create a new string object and string buffer
+ * (-1 because of extra separator included in StringLength from above)
+ * Allow creation of zero-length strings from zero-length buffers.
+ */
+ if (StringLength)
+ {
+ StringLength--;
+ }
+
+ ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+
+ /*
+ * Convert buffer bytes to hex or decimal values
+ * (separated by commas or spaces)
+ */
+ for (i = 0; i < ObjDesc->Buffer.Length; i++)
+ {
+ NewBuf += AcpiExConvertToAscii (
+ (UINT64) ObjDesc->Buffer.Pointer[i], Base,
+ NewBuf, 1);
+ *NewBuf++ = Separator; /* each separated by a comma or space */
+ }
+
+ /*
+ * Null terminate the string
+ * (overwrites final comma/space from above)
+ */
+ if (ObjDesc->Buffer.Length)
+ {
+ NewBuf--;
+ }
+ *NewBuf = 0;
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ *ResultDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToTargetType
+ *
+ * PARAMETERS: DestinationType - Current type of the destination
+ * SourceDesc - Source object to be converted.
+ * ResultDesc - Where the converted object is returned
+ * WalkState - Current method state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToTargetType (
+ ACPI_OBJECT_TYPE DestinationType,
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExConvertToTargetType);
+
+
+ /* Default behavior */
+
+ *ResultDesc = SourceDesc;
+
+ /*
+ * If required by the target,
+ * perform implicit conversion on the source before we store it.
+ */
+ switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
+ {
+ case ARGI_SIMPLE_TARGET:
+ case ARGI_FIXED_TARGET:
+ case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
+
+ switch (DestinationType)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ /*
+ * Named field can always handle conversions
+ */
+ break;
+
+ default:
+ /* No conversion allowed for these types */
+
+ if (DestinationType != SourceDesc->Common.Type)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Explicit operator, will store (%s) over existing type (%s)\n",
+ AcpiUtGetObjectTypeName (SourceDesc),
+ AcpiUtGetTypeName (DestinationType)));
+ Status = AE_TYPE;
+ }
+ }
+ break;
+
+
+ case ARGI_TARGETREF:
+
+ switch (DestinationType)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ /*
+ * These types require an Integer operand. We can convert
+ * a Buffer or a String to an Integer if necessary.
+ */
+ Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
+ 16);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+ /*
+ * The operand must be a String. We can convert an
+ * Integer or Buffer if necessary
+ */
+ Status = AcpiExConvertToString (SourceDesc, ResultDesc,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+ /*
+ * The operand must be a Buffer. We can convert an
+ * Integer or String if necessary
+ */
+ Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X",
+ DestinationType));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ break;
+
+
+ case ARGI_REFERENCE:
+ /*
+ * CreateXxxxField cases - we are storing the field object into the name
+ */
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
+ GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
+ WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
+ Status = AE_AML_INTERNAL;
+ }
+
+ /*
+ * Source-to-Target conversion semantics:
+ *
+ * If conversion to the target type cannot be performed, then simply
+ * overwrite the target with the new object and type.
+ */
+ if (Status == AE_TYPE)
+ {
+ Status = AE_OK;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/excreate.c b/source/components/executer/excreate.c
new file mode 100644
index 000000000000..888ff7d7c4ad
--- /dev/null
+++ b/source/components/executer/excreate.c
@@ -0,0 +1,574 @@
+/******************************************************************************
+ *
+ * Module Name: excreate - Named object creation
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXCREATE_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("excreate")
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateAlias
+ *
+ * PARAMETERS: WalkState - Current state, contains operands
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new named alias
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateAlias (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_NAMESPACE_NODE *TargetNode;
+ ACPI_NAMESPACE_NODE *AliasNode;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExCreateAlias);
+
+
+ /* Get the source/alias operands (both namespace nodes) */
+
+ AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
+ TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
+
+ if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
+ (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
+ {
+ /*
+ * Dereference an existing alias so that we don't create a chain
+ * of aliases. With this code, we guarantee that an alias is
+ * always exactly one level of indirection away from the
+ * actual aliased name.
+ */
+ TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
+ }
+
+ /*
+ * For objects that can never change (i.e., the NS node will
+ * permanently point to the same object), we can simply attach
+ * the object to the new NS node. For other objects (such as
+ * Integers, buffers, etc.), we have to point the Alias node
+ * to the original Node.
+ */
+ switch (TargetNode->Type)
+ {
+
+ /* For these types, the sub-object can change dynamically via a Store */
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /*
+ * These types open a new scope, so we need the NS node in order to access
+ * any children.
+ */
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_THERMAL:
+ case ACPI_TYPE_LOCAL_SCOPE:
+
+ /*
+ * The new alias has the type ALIAS and points to the original
+ * NS node, not the object itself.
+ */
+ AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
+ AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
+ break;
+
+ case ACPI_TYPE_METHOD:
+
+ /*
+ * Control method aliases need to be differentiated
+ */
+ AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
+ AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
+ break;
+
+ default:
+
+ /* Attach the original source object to the new Alias Node */
+
+ /*
+ * The new alias assumes the type of the target, and it points
+ * to the same object. The reference count of the object has an
+ * additional reference to prevent deletion out from under either the
+ * target node or the alias Node
+ */
+ Status = AcpiNsAttachObject (AliasNode,
+ AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
+ break;
+ }
+
+ /* Since both operands are Nodes, we don't need to delete them */
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateEvent
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new event object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateEvent (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE (ExCreateEvent);
+
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Create the actual OS semaphore, with zero initial units -- meaning
+ * that the event is created in an unsignalled state
+ */
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
+ &ObjDesc->Event.OsSemaphore);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Attach object to the Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
+ ObjDesc, ACPI_TYPE_EVENT);
+
+Cleanup:
+ /*
+ * Remove local reference to the object (on error, will cause deletion
+ * of both object and semaphore if present.)
+ */
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateMutex
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new mutex object
+ *
+ * Mutex (Name[0], SyncLevel[1])
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateMutex (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
+
+
+ /* Create the new mutex object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Create the actual OS Mutex */
+
+ Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Init object and attach to NS node */
+
+ ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
+ ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
+
+ Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
+
+
+Cleanup:
+ /*
+ * Remove local reference to the object (on error, will cause deletion
+ * of both object and semaphore if present.)
+ */
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateRegion
+ *
+ * PARAMETERS: AmlStart - Pointer to the region declaration AML
+ * AmlLength - Max length of the declaration AML
+ * SpaceId - Address space ID for the region
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new operation region object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateRegion (
+ UINT8 *AmlStart,
+ UINT32 AmlLength,
+ UINT8 SpaceId,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *RegionObj2;
+
+
+ ACPI_FUNCTION_TRACE (ExCreateRegion);
+
+
+ /* Get the Namespace Node */
+
+ Node = WalkState->Op->Common.Node;
+
+ /*
+ * If the region object is already attached to this node,
+ * just return
+ */
+ if (AcpiNsGetAttachedObject (Node))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Space ID must be one of the predefined IDs, or in the user-defined
+ * range
+ */
+ if (!AcpiIsValidSpaceId (SpaceId))
+ {
+ /*
+ * Print an error message, but continue. We don't want to abort
+ * a table load for this exception. Instead, if the region is
+ * actually used at runtime, abort the executing method.
+ */
+ ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
+ AcpiUtGetRegionName (SpaceId), SpaceId));
+
+ /* Create the region descriptor */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Remember location in AML stream of address & length
+ * operands since they need to be evaluated at run time.
+ */
+ RegionObj2 = ObjDesc->Common.NextObject;
+ RegionObj2->Extra.AmlStart = AmlStart;
+ RegionObj2->Extra.AmlLength = AmlLength;
+ if (WalkState->ScopeInfo)
+ {
+ RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
+ }
+ else
+ {
+ RegionObj2->Extra.ScopeNode = Node;
+ }
+
+ /* Init the region from the operands */
+
+ ObjDesc->Region.SpaceId = SpaceId;
+ ObjDesc->Region.Address = 0;
+ ObjDesc->Region.Length = 0;
+ ObjDesc->Region.Node = Node;
+
+ /* Install the new region object in the parent Node */
+
+ Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
+
+
+Cleanup:
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateProcessor
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new processor object and populate the fields
+ *
+ * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateProcessor (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
+
+
+ /* Create the processor object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize the processor object from the operands */
+
+ ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
+ ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
+ ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
+
+ /* Install the processor object in the parent Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
+ ObjDesc, ACPI_TYPE_PROCESSOR);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreatePowerResource
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new PowerResource object and populate the fields
+ *
+ * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreatePowerResource (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
+
+
+ /* Create the power resource object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize the power object from the operands */
+
+ ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
+ ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
+
+ /* Install the power resource object in the parent Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
+ ObjDesc, ACPI_TYPE_POWER);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateMethod
+ *
+ * PARAMETERS: AmlStart - First byte of the method's AML
+ * AmlLength - AML byte count for this method
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new method object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateMethod (
+ UINT8 *AmlStart,
+ UINT32 AmlLength,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ UINT8 MethodFlags;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
+
+
+ /* Create a new method object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Exit;
+ }
+
+ /* Save the method's AML pointer and length */
+
+ ObjDesc->Method.AmlStart = AmlStart;
+ ObjDesc->Method.AmlLength = AmlLength;
+
+ /*
+ * Disassemble the method flags. Split off the ArgCount, Serialized
+ * flag, and SyncLevel for efficiency.
+ */
+ MethodFlags = (UINT8) Operand[1]->Integer.Value;
+ ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
+
+ /*
+ * Get the SyncLevel. If method is serialized, a mutex will be
+ * created for this method when it is parsed.
+ */
+ if (MethodFlags & AML_METHOD_SERIALIZED)
+ {
+ ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
+
+ /*
+ * ACPI 1.0: SyncLevel = 0
+ * ACPI 2.0: SyncLevel = SyncLevel in method declaration
+ */
+ ObjDesc->Method.SyncLevel = (UINT8)
+ ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
+ }
+
+ /* Attach the new object to the method Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
+ ObjDesc, ACPI_TYPE_METHOD);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+
+Exit:
+ /* Remove a reference to the operand */
+
+ AcpiUtRemoveReference (Operand[1]);
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exdebug.c b/source/components/executer/exdebug.c
new file mode 100644
index 000000000000..166b2af170ff
--- /dev/null
+++ b/source/components/executer/exdebug.c
@@ -0,0 +1,278 @@
+/******************************************************************************
+ *
+ * Module Name: exdebug - Support for stores to the AML Debug Object
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXDEBUG_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exdebug")
+
+
+#ifndef ACPI_NO_ERROR_MESSAGES
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoDebugObject
+ *
+ * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
+ * Level - Indentation level (used for packages)
+ * Index - Current package element, zero if not pkg
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Handles stores to the AML Debug Object. For example:
+ * Store(INT1, Debug)
+ *
+ * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
+ *
+ * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
+ * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
+ * operational case, stores to the debug object are ignored but can be easily
+ * enabled if necessary.
+ *
+ ******************************************************************************/
+
+void
+AcpiExDoDebugObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ UINT32 Level,
+ UINT32 Index)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
+
+
+ /* Output must be enabled via the DebugObject global or the DbgLevel */
+
+ if (!AcpiGbl_EnableAmlDebugObject &&
+ !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
+ {
+ return_VOID;
+ }
+
+ /*
+ * Print line header as long as we are not in the middle of an
+ * object display
+ */
+ if (!((Level > 0) && Index == 0))
+ {
+ AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
+ }
+
+ /* Display the index for package output only */
+
+ if (Index > 0)
+ {
+ AcpiOsPrintf ("(%.2u) ", Index-1);
+ }
+
+ if (!SourceDesc)
+ {
+ AcpiOsPrintf ("[Null Object]\n");
+ return_VOID;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
+
+ if (!AcpiUtValidInternalObject (SourceDesc))
+ {
+ AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
+ return_VOID;
+ }
+ }
+ else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiOsPrintf ("%s: %p\n",
+ AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
+ SourceDesc);
+ return_VOID;
+ }
+ else
+ {
+ return_VOID;
+ }
+
+ /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
+
+ switch (SourceDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Output correct integer width */
+
+ if (AcpiGbl_IntegerByteWidth == 4)
+ {
+ AcpiOsPrintf ("0x%8.8X\n",
+ (UINT32) SourceDesc->Integer.Value);
+ }
+ else
+ {
+ AcpiOsPrintf ("0x%8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
+ AcpiUtDumpBuffer2 (SourceDesc->Buffer.Pointer,
+ (SourceDesc->Buffer.Length < 256) ?
+ SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
+ SourceDesc->String.Length, SourceDesc->String.Pointer);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
+ SourceDesc->Package.Count);
+
+ /* Output the entire contents of the package */
+
+ for (i = 0; i < SourceDesc->Package.Count; i++)
+ {
+ AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
+ Level+4, i+1);
+ }
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
+
+ /* Decode the reference */
+
+ switch (SourceDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_INDEX:
+
+ AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
+ break;
+
+ case ACPI_REFCLASS_TABLE:
+
+ /* Case for DdbHandle */
+
+ AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
+ return;
+
+ default:
+ break;
+ }
+
+ AcpiOsPrintf (" ");
+
+ /* Check for valid node first, then valid object */
+
+ if (SourceDesc->Reference.Node)
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
+ ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiOsPrintf (" %p - Not a valid namespace node\n",
+ SourceDesc->Reference.Node);
+ }
+ else
+ {
+ AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
+ (SourceDesc->Reference.Node)->Name.Ascii);
+
+ switch ((SourceDesc->Reference.Node)->Type)
+ {
+ /* These types have no attached object */
+
+ case ACPI_TYPE_DEVICE:
+ AcpiOsPrintf ("Device\n");
+ break;
+
+ case ACPI_TYPE_THERMAL:
+ AcpiOsPrintf ("Thermal Zone\n");
+ break;
+
+ default:
+ AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
+ Level+4, 0);
+ break;
+ }
+ }
+ }
+ else if (SourceDesc->Reference.Object)
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
+ ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
+ SourceDesc->Reference.Object)->Object,
+ Level+4, 0);
+ }
+ else
+ {
+ AcpiExDoDebugObject (SourceDesc->Reference.Object,
+ Level+4, 0);
+ }
+ }
+ break;
+
+ default:
+
+ AcpiOsPrintf ("%p\n", SourceDesc);
+ break;
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
+ return_VOID;
+}
+#endif
+
+
diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c
new file mode 100644
index 000000000000..4b49ceca09e7
--- /dev/null
+++ b/source/components/executer/exdump.c
@@ -0,0 +1,1124 @@
+/******************************************************************************
+ *
+ * Module Name: exdump - Interpreter debug output routines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXDUMP_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exdump")
+
+/*
+ * The following routines are used for debug output only
+ */
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/* Local prototypes */
+
+static void
+AcpiExOutString (
+ char *Title,
+ char *Value);
+
+static void
+AcpiExOutPointer (
+ char *Title,
+ void *Value);
+
+static void
+AcpiExDumpObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_EXDUMP_INFO *Info);
+
+static void
+AcpiExDumpReferenceObj (
+ ACPI_OPERAND_OBJECT *ObjDesc);
+
+static void
+AcpiExDumpPackageObj (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Level,
+ UINT32 Index);
+
+
+/*******************************************************************************
+ *
+ * Object Descriptor info tables
+ *
+ * Note: The first table entry must be an INIT opcode and must contain
+ * the table length (number of table entries)
+ *
+ ******************************************************************************/
+
+static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL},
+ {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpString[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"},
+ {ACPI_EXD_STRING, 0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"},
+ {ACPI_EXD_BUFFER, 0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"},
+ {ACPI_EXD_PACKAGE, 0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.DeviceNotify), "Device Notify"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.InfoFlags), "Info Flags"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"},
+ {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"},
+ {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpPower[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.DeviceNotify), "Device Notify"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"},
+ {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"},
+ {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.DeviceNotify), "Device Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpRegionField[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Field.AccessLength), "AccessLength"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.ResourceBuffer), "ResourceBuffer"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpReference[8] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"},
+ {ACPI_EXD_REFERENCE,0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpNotify[3] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"}
+};
+
+
+/* Miscellaneous tables */
+
+static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL},
+ {ACPI_EXD_TYPE , 0, NULL},
+ {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpNode[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"},
+ {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"},
+ {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"},
+ {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"}
+};
+
+
+/* Dispatch table, indexed by object type */
+
+static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] =
+{
+ NULL,
+ AcpiExDumpInteger,
+ AcpiExDumpString,
+ AcpiExDumpBuffer,
+ AcpiExDumpPackage,
+ NULL,
+ AcpiExDumpDevice,
+ AcpiExDumpEvent,
+ AcpiExDumpMethod,
+ AcpiExDumpMutex,
+ AcpiExDumpRegion,
+ AcpiExDumpPower,
+ AcpiExDumpProcessor,
+ AcpiExDumpThermal,
+ AcpiExDumpBufferField,
+ NULL,
+ NULL,
+ AcpiExDumpRegionField,
+ AcpiExDumpBankField,
+ AcpiExDumpIndexField,
+ AcpiExDumpReference,
+ NULL,
+ NULL,
+ AcpiExDumpNotify,
+ AcpiExDumpAddressHandler,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpObject
+ *
+ * PARAMETERS: ObjDesc - Descriptor to dump
+ * Info - Info table corresponding to this object
+ * type
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Walk the info table for this object
+ *
+ ******************************************************************************/
+
+static void
+AcpiExDumpObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_EXDUMP_INFO *Info)
+{
+ UINT8 *Target;
+ char *Name;
+ UINT8 Count;
+
+
+ if (!Info)
+ {
+ AcpiOsPrintf (
+ "ExDumpObject: Display not implemented for object type %s\n",
+ AcpiUtGetObjectTypeName (ObjDesc));
+ return;
+ }
+
+ /* First table entry must contain the table length (# of table entries) */
+
+ Count = Info->Offset;
+
+ while (Count)
+ {
+ Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset);
+ Name = Info->Name;
+
+ switch (Info->Opcode)
+ {
+ case ACPI_EXD_INIT:
+ break;
+
+ case ACPI_EXD_TYPE:
+
+ AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc));
+ break;
+
+ case ACPI_EXD_UINT8:
+
+ AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target);
+ break;
+
+ case ACPI_EXD_UINT16:
+
+ AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target));
+ break;
+
+ case ACPI_EXD_UINT32:
+
+ AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target));
+ break;
+
+ case ACPI_EXD_UINT64:
+
+ AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
+ ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
+ break;
+
+ case ACPI_EXD_POINTER:
+ case ACPI_EXD_ADDRESS:
+
+ AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target));
+ break;
+
+ case ACPI_EXD_STRING:
+
+ AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
+ AcpiOsPrintf ("\n");
+ break;
+
+ case ACPI_EXD_BUFFER:
+
+ ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
+ break;
+
+ case ACPI_EXD_PACKAGE:
+
+ /* Dump the package contents */
+
+ AcpiOsPrintf ("\nPackage Contents:\n");
+ AcpiExDumpPackageObj (ObjDesc, 0, 0);
+ break;
+
+ case ACPI_EXD_FIELD:
+
+ AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon);
+ break;
+
+ case ACPI_EXD_REFERENCE:
+
+ AcpiExOutString ("Class Name",
+ ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc)));
+ AcpiExDumpReferenceObj (ObjDesc);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
+ Info->Opcode);
+ return;
+ }
+
+ Info++;
+ Count--;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpOperand
+ *
+ * PARAMETERS: *ObjDesc - Pointer to entry to be dumped
+ * Depth - Current nesting depth
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump an operand object
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpOperand (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Depth)
+{
+ UINT32 Length;
+ UINT32 Index;
+
+
+ ACPI_FUNCTION_NAME (ExDumpOperand)
+
+
+ if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return;
+ }
+
+ if (!ObjDesc)
+ {
+ /* This could be a null element of a package */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
+ return;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
+ ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
+ return;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "%p is not a node or operand object: [%s]\n",
+ ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
+ ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
+ return;
+ }
+
+ /* ObjDesc is a valid object */
+
+ if (Depth > 0)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
+ Depth, " ", Depth, ObjDesc));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
+ }
+
+ /* Decode object type */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc));
+
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_DEBUG:
+
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object);
+ break;
+
+
+ case ACPI_REFCLASS_TABLE:
+
+ AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value);
+ break;
+
+
+ case ACPI_REFCLASS_REFOF:
+
+ AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object,
+ AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
+ ObjDesc->Reference.Object)->Common.Type));
+ break;
+
+
+ case ACPI_REFCLASS_NAME:
+
+ AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii);
+ break;
+
+
+ case ACPI_REFCLASS_ARG:
+ case ACPI_REFCLASS_LOCAL:
+
+ AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value);
+ break;
+
+
+ default: /* Unknown reference class */
+
+ AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
+ break;
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("Buffer length %.2X @ %p\n",
+ ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
+
+ /* Debug only -- dump the buffer contents */
+
+ if (ObjDesc->Buffer.Pointer)
+ {
+ Length = ObjDesc->Buffer.Length;
+ if (Length > 128)
+ {
+ Length = 128;
+ }
+
+ AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n",
+ Length);
+ ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length);
+ }
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ AcpiOsPrintf ("Integer %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
+ ObjDesc->Package.Count, ObjDesc->Package.Elements);
+
+ /*
+ * If elements exist, package element pointer is valid,
+ * and debug_level exceeds 1, dump package's elements.
+ */
+ if (ObjDesc->Package.Count &&
+ ObjDesc->Package.Elements &&
+ AcpiDbgLevel > 1)
+ {
+ for (Index = 0; Index < ObjDesc->Package.Count; Index++)
+ {
+ AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1);
+ }
+ }
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ AcpiOsPrintf ("Region %s (%X)",
+ AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
+ ObjDesc->Region.SpaceId);
+
+ /*
+ * If the address and length have not been evaluated,
+ * don't print them.
+ */
+ if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
+ {
+ AcpiOsPrintf ("\n");
+ }
+ else
+ {
+ AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
+ ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
+ ObjDesc->Region.Length);
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("String length %X @ %p ",
+ ObjDesc->String.Length,
+ ObjDesc->String.Pointer);
+
+ AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ AcpiOsPrintf ("BankField\n");
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
+ "byte=%X bit=%X of below:\n",
+ ObjDesc->Field.BitLength,
+ ObjDesc->Field.AccessByteWidth,
+ ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
+ ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
+ ObjDesc->Field.BaseByteOffset,
+ ObjDesc->Field.StartFieldBitOffset);
+
+ AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ AcpiOsPrintf ("IndexField\n");
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n",
+ ObjDesc->BufferField.BitLength,
+ ObjDesc->BufferField.BaseByteOffset,
+ ObjDesc->BufferField.StartFieldBitOffset);
+
+ if (!ObjDesc->BufferField.BufferObj)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
+ }
+ else if ((ObjDesc->BufferField.BufferObj)->Common.Type !=
+ ACPI_TYPE_BUFFER)
+ {
+ AcpiOsPrintf ("*not a Buffer*\n");
+ }
+ else
+ {
+ AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1);
+ }
+ break;
+
+
+ case ACPI_TYPE_EVENT:
+
+ AcpiOsPrintf ("Event\n");
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ AcpiOsPrintf ("Method(%X) @ %p:%X\n",
+ ObjDesc->Method.ParamCount,
+ ObjDesc->Method.AmlStart,
+ ObjDesc->Method.AmlLength);
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ AcpiOsPrintf ("Mutex\n");
+ break;
+
+
+ case ACPI_TYPE_DEVICE:
+
+ AcpiOsPrintf ("Device\n");
+ break;
+
+
+ case ACPI_TYPE_POWER:
+
+ AcpiOsPrintf ("Power\n");
+ break;
+
+
+ case ACPI_TYPE_PROCESSOR:
+
+ AcpiOsPrintf ("Processor\n");
+ break;
+
+
+ case ACPI_TYPE_THERMAL:
+
+ AcpiOsPrintf ("Thermal\n");
+ break;
+
+
+ default:
+ /* Unknown Type */
+
+ AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type);
+ break;
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpOperands
+ *
+ * PARAMETERS: Operands - A list of Operand objects
+ * OpcodeName - AML opcode name
+ * NumOperands - Operand count for this opcode
+ *
+ * DESCRIPTION: Dump the operands associated with the opcode
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpOperands (
+ ACPI_OPERAND_OBJECT **Operands,
+ const char *OpcodeName,
+ UINT32 NumOperands)
+{
+ ACPI_FUNCTION_NAME (ExDumpOperands);
+
+
+ if (!OpcodeName)
+ {
+ OpcodeName = "UNKNOWN";
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "**** Start operand dump for opcode [%s], %u operands\n",
+ OpcodeName, NumOperands));
+
+ if (NumOperands == 0)
+ {
+ NumOperands = 1;
+ }
+
+ /* Dump the individual operands */
+
+ while (NumOperands)
+ {
+ AcpiExDumpOperand (*Operands, 0);
+ Operands++;
+ NumOperands--;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "**** End operand dump for [%s]\n", OpcodeName));
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOut* functions
+ *
+ * PARAMETERS: Title - Descriptive text
+ * Value - Value to be displayed
+ *
+ * DESCRIPTION: Object dump output formatting functions. These functions
+ * reduce the number of format strings required and keeps them
+ * all in one place for easy modification.
+ *
+ ******************************************************************************/
+
+static void
+AcpiExOutString (
+ char *Title,
+ char *Value)
+{
+ AcpiOsPrintf ("%20s : %s\n", Title, Value);
+}
+
+static void
+AcpiExOutPointer (
+ char *Title,
+ void *Value)
+{
+ AcpiOsPrintf ("%20s : %p\n", Title, Value);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpNamespaceNode
+ *
+ * PARAMETERS: Node - Descriptor to dump
+ * Flags - Force display if TRUE
+ *
+ * DESCRIPTION: Dumps the members of the given.Node
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpNamespaceNode (
+ ACPI_NAMESPACE_NODE *Node,
+ UINT32 Flags)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Flags)
+ {
+ if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return;
+ }
+ }
+
+ AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node));
+ AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type));
+ AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node));
+ AcpiExOutPointer ("Parent", Node->Parent);
+
+ AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node),
+ AcpiExDumpNode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpReferenceObj
+ *
+ * PARAMETERS: Object - Descriptor to dump
+ *
+ * DESCRIPTION: Dumps a reference object
+ *
+ ******************************************************************************/
+
+static void
+AcpiExDumpReferenceObj (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_BUFFER RetBuf;
+ ACPI_STATUS Status;
+
+
+ RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+ if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME)
+ {
+ AcpiOsPrintf (" %p ", ObjDesc->Reference.Node);
+
+ Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf (" Could not convert name to pathname\n");
+ }
+ else
+ {
+ AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
+ ACPI_FREE (RetBuf.Pointer);
+ }
+ }
+ else if (ObjDesc->Reference.Object)
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object);
+ if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE)
+ {
+ AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value);
+ }
+ else
+ {
+ AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object,
+ AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
+ ObjDesc->Reference.Object)->Common.Type));
+ }
+ }
+ else
+ {
+ AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpPackageObj
+ *
+ * PARAMETERS: ObjDesc - Descriptor to dump
+ * Level - Indentation Level
+ * Index - Package index for this object
+ *
+ * DESCRIPTION: Dumps the elements of the package
+ *
+ ******************************************************************************/
+
+static void
+AcpiExDumpPackageObj (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Level,
+ UINT32 Index)
+{
+ UINT32 i;
+
+
+ /* Indentation and index output */
+
+ if (Level > 0)
+ {
+ for (i = 0; i < Level; i++)
+ {
+ AcpiOsPrintf (" ");
+ }
+
+ AcpiOsPrintf ("[%.2d] ", Index);
+ }
+
+ AcpiOsPrintf ("%p ", ObjDesc);
+
+ /* Null package elements are allowed */
+
+ if (!ObjDesc)
+ {
+ AcpiOsPrintf ("[Null Object]\n");
+ return;
+ }
+
+ /* Packages may only contain a few object types */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("[String] Value: ");
+ for (i = 0; i < ObjDesc->String.Length; i++)
+ {
+ AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
+ }
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
+ if (ObjDesc->Buffer.Length)
+ {
+ AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
+ ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
+ }
+ else
+ {
+ AcpiOsPrintf ("\n");
+ }
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("[Package] Contains %u Elements:\n",
+ ObjDesc->Package.Count);
+
+ for (i = 0; i < ObjDesc->Package.Count; i++)
+ {
+ AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i);
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X",
+ AcpiUtGetReferenceName (ObjDesc),
+ ObjDesc->Reference.Class);
+ AcpiExDumpReferenceObj (ObjDesc);
+ break;
+
+
+ default:
+
+ AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type);
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpObjectDescriptor
+ *
+ * PARAMETERS: ObjDesc - Descriptor to dump
+ * Flags - Force display if TRUE
+ *
+ * DESCRIPTION: Dumps the members of the object descriptor given.
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpObjectDescriptor (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Flags)
+{
+ ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor);
+
+
+ if (!ObjDesc)
+ {
+ return_VOID;
+ }
+
+ if (!Flags)
+ {
+ if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return_VOID;
+ }
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
+
+ AcpiOsPrintf ("\nAttached Object (%p):\n",
+ ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
+
+ AcpiExDumpObjectDescriptor (
+ ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags);
+ return_VOID;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf (
+ "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
+ ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
+ return_VOID;
+ }
+
+ if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX)
+ {
+ return_VOID;
+ }
+
+ /* Common Fields */
+
+ AcpiExDumpObject (ObjDesc, AcpiExDumpCommon);
+
+ /* Object-specific fields */
+
+ AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
+ return_VOID;
+}
+
+#endif
+
diff --git a/source/components/executer/exfield.c b/source/components/executer/exfield.c
new file mode 100644
index 000000000000..a68240682607
--- /dev/null
+++ b/source/components/executer/exfield.c
@@ -0,0 +1,406 @@
+/******************************************************************************
+ *
+ * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EXFIELD_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acdispat.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exfield")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReadDataFromField
+ *
+ * PARAMETERS: WalkState - Current execution state
+ * ObjDesc - The named field
+ * RetBufferDesc - Where the return data object is stored
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read from a named field. Returns either an Integer or a
+ * Buffer, depending on the size of the field.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExReadDataFromField (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **RetBufferDesc)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *BufferDesc;
+ ACPI_SIZE Length;
+ void *Buffer;
+ UINT32 Function;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc);
+
+
+ /* Parameter validation */
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+ if (!RetBufferDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+ else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
+ (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
+ {
+ /*
+ * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold
+ * the data and then directly access the region handler.
+ *
+ * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function
+ */
+ if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
+ {
+ Length = ACPI_SMBUS_BUFFER_SIZE;
+ Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
+ }
+ else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
+ {
+ Length = ACPI_GSBUS_BUFFER_SIZE;
+ Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
+ }
+ else /* IPMI */
+ {
+ Length = ACPI_IPMI_BUFFER_SIZE;
+ Function = ACPI_READ;
+ }
+
+ BufferDesc = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /* Call the region handler for the read */
+
+ Status = AcpiExAccessRegion (ObjDesc, 0,
+ ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer),
+ Function);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+ goto Exit;
+ }
+
+ /*
+ * Allocate a buffer for the contents of the field.
+ *
+ * If the field is larger than the current integer width, create
+ * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
+ * the use of arithmetic operators on the returned value if the
+ * field size is equal or smaller than an Integer.
+ *
+ * Note: Field.length is in bits.
+ */
+ Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
+ if (Length > AcpiGbl_IntegerByteWidth)
+ {
+ /* Field is too large for an Integer, create a Buffer instead */
+
+ BufferDesc = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ Buffer = BufferDesc->Buffer.Pointer;
+ }
+ else
+ {
+ /* Field will fit within an Integer (normal case) */
+
+ BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Length = AcpiGbl_IntegerByteWidth;
+ Buffer = &BufferDesc->Integer.Value;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
+ ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length));
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
+ ObjDesc->CommonField.BitLength,
+ ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BaseByteOffset));
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /* Read from the field */
+
+ Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+
+Exit:
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (BufferDesc);
+ }
+ else
+ {
+ *RetBufferDesc = BufferDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExWriteDataToField
+ *
+ * PARAMETERS: SourceDesc - Contains data to write
+ * ObjDesc - The named field
+ * ResultDesc - Where the return value is returned, if any
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write to a named field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExWriteDataToField (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc)
+{
+ ACPI_STATUS Status;
+ UINT32 Length;
+ void *Buffer;
+ ACPI_OPERAND_OBJECT *BufferDesc;
+ UINT32 Function;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc);
+
+
+ /* Parameter validation */
+
+ if (!SourceDesc || !ObjDesc)
+ {
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+ else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
+ (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
+ {
+ /*
+ * This is an SMBus, GSBus or IPMI write. We will bypass the entire field
+ * mechanism and handoff the buffer directly to the handler. For
+ * these address spaces, the buffer is bi-directional; on a write,
+ * return data is returned in the same buffer.
+ *
+ * Source must be a buffer of sufficient size:
+ * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE.
+ *
+ * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function
+ */
+ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
+ {
+ Length = ACPI_SMBUS_BUFFER_SIZE;
+ Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
+ }
+ else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
+ {
+ Length = ACPI_GSBUS_BUFFER_SIZE;
+ Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
+ }
+ else /* IPMI */
+ {
+ Length = ACPI_IPMI_BUFFER_SIZE;
+ Function = ACPI_WRITE;
+ }
+
+ if (SourceDesc->Buffer.Length < Length)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u",
+ Length, SourceDesc->Buffer.Length));
+
+ return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+ }
+
+ /* Create the bi-directional buffer */
+
+ BufferDesc = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Buffer = BufferDesc->Buffer.Pointer;
+ ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length);
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /*
+ * Perform the write (returns status and perhaps data in the
+ * same buffer)
+ */
+ Status = AcpiExAccessRegion (ObjDesc, 0,
+ (UINT64 *) Buffer, Function);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ *ResultDesc = BufferDesc;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get a pointer to the data to be written */
+
+ switch (SourceDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Buffer = &SourceDesc->Integer.Value;
+ Length = sizeof (SourceDesc->Integer.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = SourceDesc->Buffer.Pointer;
+ Length = SourceDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = SourceDesc->String.Pointer;
+ Length = SourceDesc->String.Length;
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
+ SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
+ SourceDesc->Common.Type, Buffer, Length));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
+ ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type),
+ ObjDesc->Common.Type,
+ ObjDesc->CommonField.BitLength,
+ ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BaseByteOffset));
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /* Write to the field */
+
+ Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exfldio.c b/source/components/executer/exfldio.c
new file mode 100644
index 000000000000..e138e9a13ce4
--- /dev/null
+++ b/source/components/executer/exfldio.c
@@ -0,0 +1,1055 @@
+/******************************************************************************
+ *
+ * Module Name: exfldio - Aml Field I/O
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EXFLDIO_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acevents.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exfldio")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExFieldDatumIo (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ UINT64 *Value,
+ UINT32 ReadWrite);
+
+static BOOLEAN
+AcpiExRegisterOverflow (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT64 Value);
+
+static ACPI_STATUS
+AcpiExSetupRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSetupRegion
+ *
+ * PARAMETERS: ObjDesc - Field to be read or written
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common processing for AcpiExExtractFromField and
+ * AcpiExInsertIntoField. Initialize the Region if necessary and
+ * validate the request.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExSetupRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *RgnDesc;
+ UINT8 SpaceId;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset);
+
+
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+
+ /* We must have a valid region */
+
+ if (RgnDesc->Common.Type != ACPI_TYPE_REGION)
+ {
+ ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
+ RgnDesc->Common.Type,
+ AcpiUtGetObjectTypeName (RgnDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ SpaceId = RgnDesc->Region.SpaceId;
+
+ /* Validate the Space ID */
+
+ if (!AcpiIsValidSpaceId (SpaceId))
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
+ return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
+ }
+
+ /*
+ * If the Region Address and Length have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetRegionArguments (RgnDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Exit now for SMBus, GSBus or IPMI address space, it has a non-linear
+ * address space and the request cannot be directly validated
+ */
+ if (SpaceId == ACPI_ADR_SPACE_SMBUS ||
+ SpaceId == ACPI_ADR_SPACE_GSBUS ||
+ SpaceId == ACPI_ADR_SPACE_IPMI)
+ {
+ /* SMBus or IPMI has a non-linear address space */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+#ifdef ACPI_UNDER_DEVELOPMENT
+ /*
+ * If the Field access is AnyAcc, we can now compute the optimal
+ * access (because we know know the length of the parent region)
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+#endif
+
+ /*
+ * Validate the request. The entire request from the byte offset for a
+ * length of one field datum (access width) must fit within the region.
+ * (Region length is specified in bytes)
+ */
+ if (RgnDesc->Region.Length <
+ (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset +
+ ObjDesc->CommonField.AccessByteWidth))
+ {
+ if (AcpiGbl_EnableInterpreterSlack)
+ {
+ /*
+ * Slack mode only: We will go ahead and allow access to this
+ * field if it is within the region length rounded up to the next
+ * access width boundary. ACPI_SIZE cast for 64-bit compile.
+ */
+ if (ACPI_ROUND_UP (RgnDesc->Region.Length,
+ ObjDesc->CommonField.AccessByteWidth) >=
+ ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset +
+ ObjDesc->CommonField.AccessByteWidth +
+ FieldDatumByteOffset))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
+ {
+ /*
+ * This is the case where the AccessType (AccWord, etc.) is wider
+ * than the region itself. For example, a region of length one
+ * byte, and a field with Dword access specified.
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Field [%4.4s] access width (%u bytes) too large for region [%4.4s] (length %u)",
+ AcpiUtGetNodeName (ObjDesc->CommonField.Node),
+ ObjDesc->CommonField.AccessByteWidth,
+ AcpiUtGetNodeName (RgnDesc->Region.Node),
+ RgnDesc->Region.Length));
+ }
+
+ /*
+ * Offset rounded up to next multiple of field width
+ * exceeds region length, indicate an error
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Field [%4.4s] Base+Offset+Width %u+%u+%u is beyond end of region [%4.4s] (length %u)",
+ AcpiUtGetNodeName (ObjDesc->CommonField.Node),
+ ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth,
+ AcpiUtGetNodeName (RgnDesc->Region.Node),
+ RgnDesc->Region.Length));
+
+ return_ACPI_STATUS (AE_AML_REGION_LIMIT);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAccessRegion
+ *
+ * PARAMETERS: ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * Value - Where to store value (must at least
+ * 64 bits)
+ * Function - Read or Write flag plus other region-
+ * dependent flags
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single field datum to an Operation Region.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAccessRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ UINT64 *Value,
+ UINT32 Function)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *RgnDesc;
+ UINT32 RegionOffset;
+
+
+ ACPI_FUNCTION_TRACE (ExAccessRegion);
+
+
+ /*
+ * Ensure that the region operands are fully evaluated and verify
+ * the validity of the request
+ */
+ Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The physical address of this field datum is:
+ *
+ * 1) The base of the region, plus
+ * 2) The base offset of the field, plus
+ * 3) The current offset into the field
+ */
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+ RegionOffset =
+ ObjDesc->CommonField.BaseByteOffset +
+ FieldDatumByteOffset;
+
+ if ((Function & ACPI_IO_MASK) == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
+ " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId,
+ ObjDesc->CommonField.AccessByteWidth,
+ ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset,
+ ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset))));
+
+ /* Invoke the appropriate AddressSpace/OpRegion handler */
+
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc,
+ Function, RegionOffset,
+ ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
+
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_IMPLEMENTED)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Region %s (ID=%u) not implemented",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ else if (Status == AE_NOT_EXIST)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Region %s (ID=%u) has no handler",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRegisterOverflow
+ *
+ * PARAMETERS: ObjDesc - Register(Field) to be written
+ * Value - Value to be stored
+ *
+ * RETURN: TRUE if value overflows the field, FALSE otherwise
+ *
+ * DESCRIPTION: Check if a value is out of range of the field being written.
+ * Used to check if the values written to Index and Bank registers
+ * are out of range. Normally, the value is simply truncated
+ * to fit the field, but this case is most likely a serious
+ * coding error in the ASL.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiExRegisterOverflow (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT64 Value)
+{
+
+ if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE)
+ {
+ /*
+ * The field is large enough to hold the maximum integer, so we can
+ * never overflow it.
+ */
+ return (FALSE);
+ }
+
+ if (Value >= ((UINT64) 1 << ObjDesc->CommonField.BitLength))
+ {
+ /*
+ * The Value is larger than the maximum value that can fit into
+ * the register.
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Index value 0x%8.8X%8.8X overflows field width 0x%X",
+ ACPI_FORMAT_UINT64 (Value),
+ ObjDesc->CommonField.BitLength));
+
+ return (TRUE);
+ }
+
+ /* The Value will fit into the field with no truncation */
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExFieldDatumIo
+ *
+ * PARAMETERS: ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * Value - Where to store value (must be 64 bits)
+ * ReadWrite - Read or Write flag
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single datum of a field. The FieldType is
+ * demultiplexed here to handle the different types of fields
+ * (BufferField, RegionField, IndexField, BankField)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExFieldDatumIo (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ UINT64 *Value,
+ UINT32 ReadWrite)
+{
+ ACPI_STATUS Status;
+ UINT64 LocalValue;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset);
+
+
+ if (ReadWrite == ACPI_READ)
+ {
+ if (!Value)
+ {
+ LocalValue = 0;
+
+ /* To support reads without saving return value */
+ Value = &LocalValue;
+ }
+
+ /* Clear the entire return buffer first, [Very Important!] */
+
+ *Value = 0;
+ }
+
+ /*
+ * The four types of fields are:
+ *
+ * BufferField - Read/write from/to a Buffer
+ * RegionField - Read/write from/to a Operation Region.
+ * BankField - Write to a Bank Register, then read/write from/to an
+ * OperationRegion
+ * IndexField - Write to an Index Register, then read/write from/to a
+ * Data Register
+ */
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ /*
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /*
+ * Copy the data from the source buffer.
+ * Length is the field width in bytes.
+ */
+ ACPI_MEMCPY (Value,
+ (ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
+ ObjDesc->BufferField.BaseByteOffset +
+ FieldDatumByteOffset,
+ ObjDesc->CommonField.AccessByteWidth);
+ }
+ else
+ {
+ /*
+ * Copy the data to the target buffer.
+ * Length is the field width in bytes.
+ */
+ ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
+ ObjDesc->BufferField.BaseByteOffset +
+ FieldDatumByteOffset,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+
+ Status = AE_OK;
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ /*
+ * Ensure that the BankValue is not beyond the capacity of
+ * the register
+ */
+ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
+ (UINT64) ObjDesc->BankField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /*
+ * For BankFields, we must write the BankValue to the BankRegister
+ * (itself a RegionField) before we can access the data.
+ */
+ Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
+ &ObjDesc->BankField.Value,
+ sizeof (ObjDesc->BankField.Value));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now that the Bank has been selected, fall through to the
+ * RegionField case and write the datum to the Operation Region
+ */
+
+ /*lint -fallthrough */
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ /*
+ * For simple RegionFields, we just directly access the owning
+ * Operation Region.
+ */
+ Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
+ ReadWrite);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+
+ /*
+ * Ensure that the IndexValue is not beyond the capacity of
+ * the register
+ */
+ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
+ (UINT64) ObjDesc->IndexField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /* Write the index value to the IndexRegister (itself a RegionField) */
+
+ FieldDatumByteOffset += ObjDesc->IndexField.Value;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Write to Index Register: Value %8.8X\n",
+ FieldDatumByteOffset));
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
+ &FieldDatumByteOffset,
+ sizeof (FieldDatumByteOffset));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /* Read the datum from the DataRegister */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Read from Data Register\n"));
+
+ Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
+ Value, sizeof (UINT64));
+ }
+ else
+ {
+ /* Write the datum to the DataRegister */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Write to Data Register: Value %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (*Value)));
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
+ Value, sizeof (UINT64));
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %u",
+ ObjDesc->Common.Type));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ if (ReadWrite == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Value Read %8.8X%8.8X, Width %u\n",
+ ACPI_FORMAT_UINT64 (*Value),
+ ObjDesc->CommonField.AccessByteWidth));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Value Written %8.8X%8.8X, Width %u\n",
+ ACPI_FORMAT_UINT64 (*Value),
+ ObjDesc->CommonField.AccessByteWidth));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExWriteWithUpdateRule
+ *
+ * PARAMETERS: ObjDesc - Field to be written
+ * Mask - bitmask within field datum
+ * FieldValue - Value to write
+ * FieldDatumByteOffset - Offset of datum within field
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExWriteWithUpdateRule (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT64 Mask,
+ UINT64 FieldValue,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT64 MergedValue;
+ UINT64 CurrentValue;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask);
+
+
+ /* Start with the new bits */
+
+ MergedValue = FieldValue;
+
+ /* If the mask is all ones, we don't need to worry about the update rule */
+
+ if (Mask != ACPI_UINT64_MAX)
+ {
+ /* Decode the update rule */
+
+ switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
+ {
+ case AML_FIELD_UPDATE_PRESERVE:
+ /*
+ * Check if update rule needs to be applied (not if mask is all
+ * ones) The left shift drops the bits we want to ignore.
+ */
+ if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
+ ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
+ {
+ /*
+ * Read the current contents of the byte/word/dword containing
+ * the field, and merge with the new field value.
+ */
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &CurrentValue, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ MergedValue |= (CurrentValue & ~Mask);
+ }
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ONES:
+
+ /* Set positions outside the field to all ones */
+
+ MergedValue |= ~Mask;
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
+
+ /* Set positions outside the field to all zeros */
+
+ MergedValue &= Mask;
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown UpdateRule value: 0x%X",
+ (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (Mask),
+ FieldDatumByteOffset,
+ ObjDesc->CommonField.AccessByteWidth,
+ ACPI_FORMAT_UINT64 (FieldValue),
+ ACPI_FORMAT_UINT64 (MergedValue)));
+
+ /* Write the merged value */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &MergedValue, ACPI_WRITE);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExExtractFromField
+ *
+ * PARAMETERS: ObjDesc - Field to be read
+ * Buffer - Where to store the field data
+ * BufferLength - Length of Buffer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the current value of the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExExtractFromField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ ACPI_STATUS Status;
+ UINT64 RawDatum;
+ UINT64 MergedDatum;
+ UINT32 FieldOffset = 0;
+ UINT32 BufferOffset = 0;
+ UINT32 BufferTailBits;
+ UINT32 DatumCount;
+ UINT32 FieldDatumCount;
+ UINT32 AccessBitWidth;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (ExExtractFromField);
+
+
+ /* Validate target buffer and clear it */
+
+ if (BufferLength <
+ ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Field size %u (bits) is too large for buffer (%u)",
+ ObjDesc->CommonField.BitLength, BufferLength));
+
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ ACPI_MEMSET (Buffer, 0, BufferLength);
+ AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
+
+ /* Handle the simple case here */
+
+ if ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
+ (ObjDesc->CommonField.BitLength == AccessBitWidth))
+ {
+ Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ);
+ return_ACPI_STATUS (Status);
+ }
+
+/* TBD: Move to common setup code */
+
+ /* Field algorithm is limited to sizeof(UINT64), truncate if needed */
+
+ if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
+ {
+ ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
+ AccessBitWidth = sizeof (UINT64) * 8;
+ }
+
+ /* Compute the number of datums (access width data items) */
+
+ DatumCount = ACPI_ROUND_UP_TO (
+ ObjDesc->CommonField.BitLength, AccessBitWidth);
+
+ FieldDatumCount = ACPI_ROUND_UP_TO (
+ ObjDesc->CommonField.BitLength +
+ ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth);
+
+ /* Priming read from the field */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
+
+ /* Read the rest of the field */
+
+ for (i = 1; i < FieldDatumCount; i++)
+ {
+ /* Get next input datum from the field */
+
+ FieldOffset += ObjDesc->CommonField.AccessByteWidth;
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset,
+ &RawDatum, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Merge with previous datum if necessary.
+ *
+ * Note: Before the shift, check if the shift value will be larger than
+ * the integer size. If so, there is no need to perform the operation.
+ * This avoids the differences in behavior between different compilers
+ * concerning shift values larger than the target data width.
+ */
+ if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset <
+ ACPI_INTEGER_BIT_SIZE)
+ {
+ MergedDatum |= RawDatum <<
+ (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
+ }
+
+ if (i == DatumCount)
+ {
+ break;
+ }
+
+ /* Write merged datum to target buffer */
+
+ ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ BufferOffset += ObjDesc->CommonField.AccessByteWidth;
+ MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
+ }
+
+ /* Mask off any extra bits in the last datum */
+
+ BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth;
+ if (BufferTailBits)
+ {
+ MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
+ }
+
+ /* Write the last datum to the buffer */
+
+ ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExInsertIntoField
+ *
+ * PARAMETERS: ObjDesc - Field to be written
+ * Buffer - Data to be written
+ * BufferLength - Length of Buffer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the Buffer contents into the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExInsertIntoField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ void *NewBuffer;
+ ACPI_STATUS Status;
+ UINT64 Mask;
+ UINT64 WidthMask;
+ UINT64 MergedDatum;
+ UINT64 RawDatum = 0;
+ UINT32 FieldOffset = 0;
+ UINT32 BufferOffset = 0;
+ UINT32 BufferTailBits;
+ UINT32 DatumCount;
+ UINT32 FieldDatumCount;
+ UINT32 AccessBitWidth;
+ UINT32 RequiredLength;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (ExInsertIntoField);
+
+
+ /* Validate input buffer */
+
+ NewBuffer = NULL;
+ RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
+ ObjDesc->CommonField.BitLength);
+ /*
+ * We must have a buffer that is at least as long as the field
+ * we are writing to. This is because individual fields are
+ * indivisible and partial writes are not supported -- as per
+ * the ACPI specification.
+ */
+ if (BufferLength < RequiredLength)
+ {
+ /* We need to create a new buffer */
+
+ NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength);
+ if (!NewBuffer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the original data to the new buffer, starting
+ * at Byte zero. All unused (upper) bytes of the
+ * buffer will be 0.
+ */
+ ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength);
+ Buffer = NewBuffer;
+ BufferLength = RequiredLength;
+ }
+
+/* TBD: Move to common setup code */
+
+ /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */
+ if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
+ {
+ ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
+ }
+
+ AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
+
+ /*
+ * Create the bitmasks used for bit insertion.
+ * Note: This if/else is used to bypass compiler differences with the
+ * shift operator
+ */
+ if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
+ {
+ WidthMask = ACPI_UINT64_MAX;
+ }
+ else
+ {
+ WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
+ }
+
+ Mask = WidthMask &
+ ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
+
+ /* Compute the number of datums (access width data items) */
+
+ DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
+ AccessBitWidth);
+
+ FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
+ ObjDesc->CommonField.StartFieldBitOffset,
+ AccessBitWidth);
+
+ /* Get initial Datum from the input buffer */
+
+ ACPI_MEMCPY (&RawDatum, Buffer,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
+
+ /* Write the entire field */
+
+ for (i = 1; i < FieldDatumCount; i++)
+ {
+ /* Write merged datum to the target field */
+
+ MergedDatum &= Mask;
+ Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask,
+ MergedDatum, FieldOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ FieldOffset += ObjDesc->CommonField.AccessByteWidth;
+
+ /*
+ * Start new output datum by merging with previous input datum
+ * if necessary.
+ *
+ * Note: Before the shift, check if the shift value will be larger than
+ * the integer size. If so, there is no need to perform the operation.
+ * This avoids the differences in behavior between different compilers
+ * concerning shift values larger than the target data width.
+ */
+ if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) <
+ ACPI_INTEGER_BIT_SIZE)
+ {
+ MergedDatum = RawDatum >>
+ (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
+ }
+ else
+ {
+ MergedDatum = 0;
+ }
+
+ Mask = WidthMask;
+
+ if (i == DatumCount)
+ {
+ break;
+ }
+
+ /* Get the next input datum from the buffer */
+
+ BufferOffset += ObjDesc->CommonField.AccessByteWidth;
+ ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
+ }
+
+ /* Mask off any extra bits in the last datum */
+
+ BufferTailBits = (ObjDesc->CommonField.BitLength +
+ ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth;
+ if (BufferTailBits)
+ {
+ Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
+ }
+
+ /* Write the last datum to the field */
+
+ MergedDatum &= Mask;
+ Status = AcpiExWriteWithUpdateRule (ObjDesc,
+ Mask, MergedDatum, FieldOffset);
+
+Exit:
+ /* Free temporary buffer if we used one */
+
+ if (NewBuffer)
+ {
+ ACPI_FREE (NewBuffer);
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exmisc.c b/source/components/executer/exmisc.c
new file mode 100644
index 000000000000..63114f5584d6
--- /dev/null
+++ b/source/components/executer/exmisc.c
@@ -0,0 +1,800 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXMISC_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "amlresrc.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exmisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGetObjectReference
+ *
+ * PARAMETERS: ObjDesc - Create a reference to this object
+ * ReturnDesc - Where to store the reference
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Obtain and return a "reference" to the target object
+ * Common code for the RefOfOp and the CondRefOfOp.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExGetObjectReference (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ReturnDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ReferenceObj;
+ ACPI_OPERAND_OBJECT *ReferencedObj;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
+
+
+ *ReturnDesc = NULL;
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+
+ if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Must be a reference to a Local or Arg
+ */
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+ case ACPI_REFCLASS_DEBUG:
+
+ /* The referenced object is the pseudo-node for the local/arg */
+
+ ReferencedObj = ObjDesc->Reference.Object;
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
+ ObjDesc->Reference.Class));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+ break;
+
+
+ case ACPI_DESC_TYPE_NAMED:
+
+ /*
+ * A named reference that has already been resolved to a Node
+ */
+ ReferencedObj = ObjDesc;
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
+ ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+
+ /* Create a new reference object */
+
+ ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+ if (!ReferenceObj)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
+ ReferenceObj->Reference.Object = ReferencedObj;
+ *ReturnDesc = ReferenceObj;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Object %p Type [%s], returning Reference %p\n",
+ ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConcatTemplate
+ *
+ * PARAMETERS: Operand0 - First source object
+ * Operand1 - Second source object
+ * ActualReturnDesc - Where to place the return object
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Concatenate two resource templates
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConcatTemplate (
+ ACPI_OPERAND_OBJECT *Operand0,
+ ACPI_OPERAND_OBJECT *Operand1,
+ ACPI_OPERAND_OBJECT **ActualReturnDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *NewBuf;
+ UINT8 *EndTag;
+ ACPI_SIZE Length0;
+ ACPI_SIZE Length1;
+ ACPI_SIZE NewLength;
+
+
+ ACPI_FUNCTION_TRACE (ExConcatTemplate);
+
+
+ /*
+ * Find the EndTag descriptor in each resource template.
+ * Note1: returned pointers point TO the EndTag, not past it.
+ * Note2: zero-length buffers are allowed; treated like one EndTag
+ */
+
+ /* Get the length of the first resource template */
+
+ Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
+
+ /* Get the length of the second resource template */
+
+ Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
+
+ /* Combine both lengths, minimum size will be 2 for EndTag */
+
+ NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
+
+ /* Create a new buffer object for the result (with one EndTag) */
+
+ ReturnDesc = AcpiUtCreateBufferObject (NewLength);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the templates to the new buffer, 0 first, then 1 follows. One
+ * EndTag descriptor is copied from Operand1.
+ */
+ NewBuf = ReturnDesc->Buffer.Pointer;
+ ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
+ ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
+
+ /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
+
+ NewBuf[NewLength - 1] = 0;
+ NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
+
+ /* Return the completed resource template */
+
+ *ActualReturnDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoConcatenate
+ *
+ * PARAMETERS: Operand0 - First source object
+ * Operand1 - Second source object
+ * ActualReturnDesc - Where to place the return object
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoConcatenate (
+ ACPI_OPERAND_OBJECT *Operand0,
+ ACPI_OPERAND_OBJECT *Operand1,
+ ACPI_OPERAND_OBJECT **ActualReturnDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ char *NewBuf;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExDoConcatenate);
+
+
+ /*
+ * Convert the second operand if necessary. The first operand
+ * determines the type of the second operand, (See the Data Types
+ * section of the ACPI specification.) Both object types are
+ * guaranteed to be either Integer/String/Buffer by the operand
+ * resolution mechanism.
+ */
+ switch (Operand0->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
+ break;
+
+ case ACPI_TYPE_STRING:
+ Status = AcpiExConvertToString (Operand1, &LocalOperand1,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
+ Operand0->Common.Type));
+ Status = AE_AML_INTERNAL;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Both operands are now known to be the same object type
+ * (Both are Integer, String, or Buffer), and we can now perform the
+ * concatenation.
+ */
+
+ /*
+ * There are three cases to handle:
+ *
+ * 1) Two Integers concatenated to produce a new Buffer
+ * 2) Two Strings concatenated to produce a new String
+ * 3) Two Buffers concatenated to produce a new Buffer
+ */
+ switch (Operand0->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Result of two Integers is a Buffer */
+ /* Need enough buffer space for two integers */
+
+ ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
+ ACPI_MUL_2 (AcpiGbl_IntegerByteWidth));
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = (char *) ReturnDesc->Buffer.Pointer;
+
+ /* Copy the first integer, LSB first */
+
+ ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
+ AcpiGbl_IntegerByteWidth);
+
+ /* Copy the second integer (LSB first) after the first */
+
+ ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
+ &LocalOperand1->Integer.Value,
+ AcpiGbl_IntegerByteWidth);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ /* Result of two Strings is a String */
+
+ ReturnDesc = AcpiUtCreateStringObject (
+ ((ACPI_SIZE) Operand0->String.Length +
+ LocalOperand1->String.Length));
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = ReturnDesc->String.Pointer;
+
+ /* Concatenate the strings */
+
+ ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
+ ACPI_STRCPY (NewBuf + Operand0->String.Length,
+ LocalOperand1->String.Pointer);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Result of two Buffers is a Buffer */
+
+ ReturnDesc = AcpiUtCreateBufferObject (
+ ((ACPI_SIZE) Operand0->Buffer.Length +
+ LocalOperand1->Buffer.Length));
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = (char *) ReturnDesc->Buffer.Pointer;
+
+ /* Concatenate the buffers */
+
+ ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
+ Operand0->Buffer.Length);
+ ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
+ LocalOperand1->Buffer.Pointer,
+ LocalOperand1->Buffer.Length);
+ break;
+
+ default:
+
+ /* Invalid object type, should not happen here */
+
+ ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
+ Operand0->Common.Type));
+ Status =AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ *ActualReturnDesc = ReturnDesc;
+
+Cleanup:
+ if (LocalOperand1 != Operand1)
+ {
+ AcpiUtRemoveReference (LocalOperand1);
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoMathOp
+ *
+ * PARAMETERS: Opcode - AML opcode
+ * Integer0 - Integer operand #0
+ * Integer1 - Integer operand #1
+ *
+ * RETURN: Integer result of the operation
+ *
+ * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
+ * math functions here is to prevent a lot of pointer dereferencing
+ * to obtain the operands.
+ *
+ ******************************************************************************/
+
+UINT64
+AcpiExDoMathOp (
+ UINT16 Opcode,
+ UINT64 Integer0,
+ UINT64 Integer1)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (Opcode)
+ {
+ case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
+
+ return (Integer0 + Integer1);
+
+
+ case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
+
+ return (Integer0 & Integer1);
+
+
+ case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
+
+ return (~(Integer0 & Integer1));
+
+
+ case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
+
+ return (Integer0 | Integer1);
+
+
+ case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
+
+ return (~(Integer0 | Integer1));
+
+
+ case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
+
+ return (Integer0 ^ Integer1);
+
+
+ case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
+
+ return (Integer0 * Integer1);
+
+
+ case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
+
+ /*
+ * We need to check if the shiftcount is larger than the integer bit
+ * width since the behavior of this is not well-defined in the C language.
+ */
+ if (Integer1 >= AcpiGbl_IntegerBitWidth)
+ {
+ return (0);
+ }
+ return (Integer0 << Integer1);
+
+
+ case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
+
+ /*
+ * We need to check if the shiftcount is larger than the integer bit
+ * width since the behavior of this is not well-defined in the C language.
+ */
+ if (Integer1 >= AcpiGbl_IntegerBitWidth)
+ {
+ return (0);
+ }
+ return (Integer0 >> Integer1);
+
+
+ case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
+
+ return (Integer0 - Integer1);
+
+ default:
+
+ return (0);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoLogicalNumericOp
+ *
+ * PARAMETERS: Opcode - AML opcode
+ * Integer0 - Integer operand #0
+ * Integer1 - Integer operand #1
+ * LogicalResult - TRUE/FALSE result of the operation
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
+ * operators (LAnd and LOr), both operands must be integers.
+ *
+ * Note: cleanest machine code seems to be produced by the code
+ * below, rather than using statements of the form:
+ * Result = (Integer0 && Integer1);
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoLogicalNumericOp (
+ UINT16 Opcode,
+ UINT64 Integer0,
+ UINT64 Integer1,
+ BOOLEAN *LogicalResult)
+{
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN LocalResult = FALSE;
+
+
+ ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
+
+
+ switch (Opcode)
+ {
+ case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
+
+ if (Integer0 && Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LOR_OP: /* LOr (Integer0, Integer1) */
+
+ if (Integer0 || Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ /* Return the logical result and status */
+
+ *LogicalResult = LocalResult;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoLogicalOp
+ *
+ * PARAMETERS: Opcode - AML opcode
+ * Operand0 - operand #0
+ * Operand1 - operand #1
+ * LogicalResult - TRUE/FALSE result of the operation
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
+ * functions here is to prevent a lot of pointer dereferencing
+ * to obtain the operands and to simplify the generation of the
+ * logical value. For the Numeric operators (LAnd and LOr), both
+ * operands must be integers. For the other logical operators,
+ * operands can be any combination of Integer/String/Buffer. The
+ * first operand determines the type to which the second operand
+ * will be converted.
+ *
+ * Note: cleanest machine code seems to be produced by the code
+ * below, rather than using statements of the form:
+ * Result = (Operand0 == Operand1);
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoLogicalOp (
+ UINT16 Opcode,
+ ACPI_OPERAND_OBJECT *Operand0,
+ ACPI_OPERAND_OBJECT *Operand1,
+ BOOLEAN *LogicalResult)
+{
+ ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
+ UINT64 Integer0;
+ UINT64 Integer1;
+ UINT32 Length0;
+ UINT32 Length1;
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN LocalResult = FALSE;
+ int Compare;
+
+
+ ACPI_FUNCTION_TRACE (ExDoLogicalOp);
+
+
+ /*
+ * Convert the second operand if necessary. The first operand
+ * determines the type of the second operand, (See the Data Types
+ * section of the ACPI 3.0+ specification.) Both object types are
+ * guaranteed to be either Integer/String/Buffer by the operand
+ * resolution mechanism.
+ */
+ switch (Operand0->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
+ break;
+
+ case ACPI_TYPE_STRING:
+ Status = AcpiExConvertToString (Operand1, &LocalOperand1,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Two cases: 1) Both Integers, 2) Both Strings or Buffers
+ */
+ if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ /*
+ * 1) Both operands are of type integer
+ * Note: LocalOperand1 may have changed above
+ */
+ Integer0 = Operand0->Integer.Value;
+ Integer1 = LocalOperand1->Integer.Value;
+
+ switch (Opcode)
+ {
+ case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
+
+ if (Integer0 == Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
+
+ if (Integer0 > Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
+
+ if (Integer0 < Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ }
+ else
+ {
+ /*
+ * 2) Both operands are Strings or both are Buffers
+ * Note: Code below takes advantage of common Buffer/String
+ * object fields. LocalOperand1 may have changed above. Use
+ * memcmp to handle nulls in buffers.
+ */
+ Length0 = Operand0->Buffer.Length;
+ Length1 = LocalOperand1->Buffer.Length;
+
+ /* Lexicographic compare: compare the data bytes */
+
+ Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer,
+ LocalOperand1->Buffer.Pointer,
+ (Length0 > Length1) ? Length1 : Length0);
+
+ switch (Opcode)
+ {
+ case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
+
+ /* Length and all bytes must be equal */
+
+ if ((Length0 == Length1) &&
+ (Compare == 0))
+ {
+ /* Length and all bytes match ==> TRUE */
+
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
+
+ if (Compare > 0)
+ {
+ LocalResult = TRUE;
+ goto Cleanup; /* TRUE */
+ }
+ if (Compare < 0)
+ {
+ goto Cleanup; /* FALSE */
+ }
+
+ /* Bytes match (to shortest length), compare lengths */
+
+ if (Length0 > Length1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
+
+ if (Compare > 0)
+ {
+ goto Cleanup; /* FALSE */
+ }
+ if (Compare < 0)
+ {
+ LocalResult = TRUE;
+ goto Cleanup; /* TRUE */
+ }
+
+ /* Bytes match (to shortest length), compare lengths */
+
+ if (Length0 < Length1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ }
+
+Cleanup:
+
+ /* New object was created if implicit conversion performed - delete */
+
+ if (LocalOperand1 != Operand1)
+ {
+ AcpiUtRemoveReference (LocalOperand1);
+ }
+
+ /* Return the logical result and status */
+
+ *LogicalResult = LocalResult;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exmutex.c b/source/components/executer/exmutex.c
new file mode 100644
index 000000000000..4c702b8baa6d
--- /dev/null
+++ b/source/components/executer/exmutex.c
@@ -0,0 +1,554 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmutex - ASL Mutex Acquire/Release functions
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXMUTEX_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "acevents.h"
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exmutex")
+
+/* Local prototypes */
+
+static void
+AcpiExLinkMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_THREAD_STATE *Thread);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExUnlinkMutex
+ *
+ * PARAMETERS: ObjDesc - The mutex to be unlinked
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
+ *
+ ******************************************************************************/
+
+void
+AcpiExUnlinkMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread;
+
+
+ if (!Thread)
+ {
+ return;
+ }
+
+ /* Doubly linked list */
+
+ if (ObjDesc->Mutex.Next)
+ {
+ (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
+ }
+
+ if (ObjDesc->Mutex.Prev)
+ {
+ (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next;
+
+ /*
+ * Migrate the previous sync level associated with this mutex to
+ * the previous mutex on the list so that it may be preserved.
+ * This handles the case where several mutexes have been acquired
+ * at the same level, but are not released in opposite order.
+ */
+ (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel =
+ ObjDesc->Mutex.OriginalSyncLevel;
+ }
+ else
+ {
+ Thread->AcquiredMutexList = ObjDesc->Mutex.Next;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExLinkMutex
+ *
+ * PARAMETERS: ObjDesc - The mutex to be linked
+ * Thread - Current executing thread object
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
+ *
+ ******************************************************************************/
+
+static void
+AcpiExLinkMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_THREAD_STATE *Thread)
+{
+ ACPI_OPERAND_OBJECT *ListHead;
+
+
+ ListHead = Thread->AcquiredMutexList;
+
+ /* This object will be the first object in the list */
+
+ ObjDesc->Mutex.Prev = NULL;
+ ObjDesc->Mutex.Next = ListHead;
+
+ /* Update old first object to point back to this object */
+
+ if (ListHead)
+ {
+ ListHead->Mutex.Prev = ObjDesc;
+ }
+
+ /* Update list head */
+
+ Thread->AcquiredMutexList = ObjDesc;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAcquireMutexObject
+ *
+ * PARAMETERS: Timeout - Timeout in milliseconds
+ * ObjDesc - Mutex object
+ * ThreadId - Current thread state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
+ * path that supports multiple acquires by the same thread.
+ *
+ * MUTEX: Interpreter must be locked
+ *
+ * NOTE: This interface is called from three places:
+ * 1) From AcpiExAcquireMutex, via an AML Acquire() operator
+ * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the
+ * global lock
+ * 3) From the external interface, AcpiAcquireGlobalLock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAcquireMutexObject (
+ UINT16 Timeout,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_THREAD_ID ThreadId)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Support for multiple acquires by the owning thread */
+
+ if (ObjDesc->Mutex.ThreadId == ThreadId)
+ {
+ /*
+ * The mutex is already owned by this thread, just increment the
+ * acquisition depth
+ */
+ ObjDesc->Mutex.AcquisitionDepth++;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Acquire the mutex, wait if necessary. Special case for Global Lock */
+
+ if (ObjDesc == AcpiGbl_GlobalLockMutex)
+ {
+ Status = AcpiEvAcquireGlobalLock (Timeout);
+ }
+ else
+ {
+ Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex,
+ Timeout);
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Includes failure from a timeout on TimeDesc */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Acquired the mutex: update mutex object */
+
+ ObjDesc->Mutex.ThreadId = ThreadId;
+ ObjDesc->Mutex.AcquisitionDepth = 1;
+ ObjDesc->Mutex.OriginalSyncLevel = 0;
+ ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAcquireMutex
+ *
+ * PARAMETERS: TimeDesc - Timeout integer
+ * ObjDesc - Mutex object
+ * WalkState - Current method execution state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Acquire an AML mutex
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAcquireMutex (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Must have a valid thread state struct */
+
+ if (!WalkState->Thread)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot acquire Mutex [%4.4s], null thread info",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /*
+ * Current sync level must be less than or equal to the sync level of the
+ * mutex. This mechanism provides some deadlock prevention
+ */
+ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%u)",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node),
+ WalkState->Thread->CurrentSyncLevel));
+ return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
+ }
+
+ Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value,
+ ObjDesc, WalkState->Thread->ThreadId);
+ if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1)
+ {
+ /* Save Thread object, original/current sync levels */
+
+ ObjDesc->Mutex.OwnerThread = WalkState->Thread;
+ ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel;
+ WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel;
+
+ /* Link the mutex to the current thread for force-unlock at method exit */
+
+ AcpiExLinkMutex (ObjDesc, WalkState->Thread);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseMutexObject
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release a previously acquired Mutex, low level interface.
+ * Provides a common path that supports multiple releases (after
+ * previous multiple acquires) by the same thread.
+ *
+ * MUTEX: Interpreter must be locked
+ *
+ * NOTE: This interface is called from three places:
+ * 1) From AcpiExReleaseMutex, via an AML Acquire() operator
+ * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
+ * global lock
+ * 3) From the external interface, AcpiReleaseGlobalLock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExReleaseMutexObject (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
+
+
+ if (ObjDesc->Mutex.AcquisitionDepth == 0)
+ {
+ return (AE_NOT_ACQUIRED);
+ }
+
+ /* Match multiple Acquires with multiple Releases */
+
+ ObjDesc->Mutex.AcquisitionDepth--;
+ if (ObjDesc->Mutex.AcquisitionDepth != 0)
+ {
+ /* Just decrement the depth and return */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ if (ObjDesc->Mutex.OwnerThread)
+ {
+ /* Unlink the mutex from the owner's list */
+
+ AcpiExUnlinkMutex (ObjDesc);
+ ObjDesc->Mutex.OwnerThread = NULL;
+ }
+
+ /* Release the mutex, special case for Global Lock */
+
+ if (ObjDesc == AcpiGbl_GlobalLockMutex)
+ {
+ Status = AcpiEvReleaseGlobalLock ();
+ }
+ else
+ {
+ AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
+ }
+
+ /* Clear mutex info */
+
+ ObjDesc->Mutex.ThreadId = 0;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseMutex
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ * WalkState - Current method execution state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release a previously acquired Mutex.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExReleaseMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 PreviousSyncLevel;
+ ACPI_THREAD_STATE *OwnerThread;
+
+
+ ACPI_FUNCTION_TRACE (ExReleaseMutex);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ OwnerThread = ObjDesc->Mutex.OwnerThread;
+
+ /* The mutex must have been previously acquired in order to release it */
+
+ if (!OwnerThread)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot release Mutex [%4.4s], not acquired",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
+ return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
+ }
+
+ /* Must have a valid thread ID */
+
+ if (!WalkState->Thread)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot release Mutex [%4.4s], null thread info",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /*
+ * The Mutex is owned, but this thread must be the owner.
+ * Special case for Global Lock, any thread can release
+ */
+ if ((OwnerThread->ThreadId != WalkState->Thread->ThreadId) &&
+ (ObjDesc != AcpiGbl_GlobalLockMutex))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
+ (UINT32) WalkState->Thread->ThreadId,
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node),
+ (UINT32) OwnerThread->ThreadId));
+ return_ACPI_STATUS (AE_AML_NOT_OWNER);
+ }
+
+ /*
+ * The sync level of the mutex must be equal to the current sync level. In
+ * other words, the current level means that at least one mutex at that
+ * level is currently being held. Attempting to release a mutex of a
+ * different level can only mean that the mutex ordering rule is being
+ * violated. This behavior is clarified in ACPI 4.0 specification.
+ */
+ if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node),
+ ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel));
+ return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
+ }
+
+ /*
+ * Get the previous SyncLevel from the head of the acquired mutex list.
+ * This handles the case where several mutexes at the same level have been
+ * acquired, but are not released in reverse order.
+ */
+ PreviousSyncLevel =
+ OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel;
+
+ Status = AcpiExReleaseMutexObject (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc->Mutex.AcquisitionDepth == 0)
+ {
+ /* Restore the previous SyncLevel */
+
+ OwnerThread->CurrentSyncLevel = PreviousSyncLevel;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseAllMutexes
+ *
+ * PARAMETERS: Thread - Current executing thread object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release all mutexes held by this thread
+ *
+ * NOTE: This function is called as the thread is exiting the interpreter.
+ * Mutexes are not released when an individual control method is exited, but
+ * only when the parent thread actually exits the interpreter. This allows one
+ * method to acquire a mutex, and a different method to release it, as long as
+ * this is performed underneath a single parent control method.
+ *
+ ******************************************************************************/
+
+void
+AcpiExReleaseAllMutexes (
+ ACPI_THREAD_STATE *Thread)
+{
+ ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Traverse the list of owned mutexes, releasing each one */
+
+ while (Next)
+ {
+ ObjDesc = Next;
+ Next = ObjDesc->Mutex.Next;
+
+ ObjDesc->Mutex.Prev = NULL;
+ ObjDesc->Mutex.Next = NULL;
+ ObjDesc->Mutex.AcquisitionDepth = 0;
+
+ /* Release the mutex, special case for Global Lock */
+
+ if (ObjDesc == AcpiGbl_GlobalLockMutex)
+ {
+ /* Ignore errors */
+
+ (void) AcpiEvReleaseGlobalLock ();
+ }
+ else
+ {
+ AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
+ }
+
+ /* Mark mutex unowned */
+
+ ObjDesc->Mutex.OwnerThread = NULL;
+ ObjDesc->Mutex.ThreadId = 0;
+
+ /* Update Thread SyncLevel (Last mutex is the important one) */
+
+ Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;
+ }
+}
diff --git a/source/components/executer/exnames.c b/source/components/executer/exnames.c
new file mode 100644
index 000000000000..c3cb6b0b4cad
--- /dev/null
+++ b/source/components/executer/exnames.c
@@ -0,0 +1,488 @@
+
+/******************************************************************************
+ *
+ * Module Name: exnames - interpreter/scanner name load/execute
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXNAMES_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exnames")
+
+/* Local prototypes */
+
+static char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs);
+
+static ACPI_STATUS
+AcpiExNameSegment (
+ UINT8 **InAmlAddress,
+ char *NameString);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAllocateNameString
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs)
+{
+ char *TempPtr;
+ char *NameString;
+ UINT32 SizeNeeded;
+
+ ACPI_FUNCTION_TRACE (ExAllocateNameString);
+
+
+ /*
+ * 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 == ACPI_UINT32_MAX)
+ {
+ /* 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 = ACPI_ALLOCATE (SizeNeeded);
+ if (!NameString)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not allocate size %u", SizeNeeded));
+ return_PTR (NULL);
+ }
+
+ TempPtr = NameString;
+
+ /* Set up Root or Parent prefixes if needed */
+
+ if (PrefixCount == ACPI_UINT32_MAX)
+ {
+ *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. AcpiExNameSegment() will
+ * append the segment(s)
+ */
+ *TempPtr = 0;
+
+ return_PTR (NameString);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExNameSegment
+ *
+ * PARAMETERS: InAmlAddress - Pointer to the name in the AML code
+ * NameString - Where to return the name. The name is appended
+ * to any existing string to form a namepath
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExNameSegment (
+ UINT8 **InAmlAddress,
+ char *NameString)
+{
+ char *AmlAddress = (void *) *InAmlAddress;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Index;
+ char CharBuf[5];
+
+
+ ACPI_FUNCTION_TRACE (ExNameSegment);
+
+
+ /*
+ * 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')
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0]));
+ return_ACPI_STATUS (AE_CTRL_PENDING);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n"));
+
+ for (Index = 0;
+ (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0));
+ Index++)
+ {
+ CharBuf[Index] = *AmlAddress++;
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index]));
+ }
+
+
+ /* Valid name segment */
+
+ if (Index == 4)
+ {
+ /* Found 4 valid characters */
+
+ CharBuf[4] = '\0';
+
+ if (NameString)
+ {
+ ACPI_STRCAT (NameString, CharBuf);
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Appended to - %s\n", NameString));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "No Name string - %s\n", CharBuf));
+ }
+ }
+ else if (Index == 0)
+ {
+ /*
+ * First character was not a valid name character,
+ * so we are looking at something other than a name.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Leading character is 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
+ * the required 4
+ */
+ Status = AE_AML_BAD_NAME;
+ ACPI_ERROR ((AE_INFO,
+ "Bad character 0x%02x in name, at %p",
+ *AmlAddress, AmlAddress));
+ }
+
+ *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGetNameString
+ *
+ * PARAMETERS: DataType - Object type to be associated with this
+ * name
+ * InAmlAddress - Pointer to the namestring in the AML code
+ * OutNameString - Where the namestring is returned
+ * OutNameLength - Length of the returned string
+ *
+ * RETURN: Status, namestring and length
+ *
+ * DESCRIPTION: Extract a full namepath from the AML byte stream,
+ * including any prefixes.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExGetNameString (
+ ACPI_OBJECT_TYPE DataType,
+ UINT8 *InAmlAddress,
+ char **OutNameString,
+ UINT32 *OutNameLength)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 *AmlAddress = InAmlAddress;
+ char *NameString = NULL;
+ UINT32 NumSegments;
+ UINT32 PrefixCount = 0;
+ BOOLEAN HasPrefix = FALSE;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress);
+
+
+ if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType ||
+ ACPI_TYPE_LOCAL_BANK_FIELD == DataType ||
+ ACPI_TYPE_LOCAL_INDEX_FIELD == DataType)
+ {
+ /* Disallow prefixes for types associated with FieldUnit names */
+
+ NameString = AcpiExAllocateNameString (0, 1);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ else
+ {
+ Status = AcpiExNameSegment (&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:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
+ AmlAddress));
+
+ /*
+ * Remember that we have a RootPrefix --
+ * see comment in AcpiExAllocateNameString()
+ */
+ AmlAddress++;
+ PrefixCount = ACPI_UINT32_MAX;
+ HasPrefix = TRUE;
+ break;
+
+
+ case AML_PARENT_PREFIX:
+
+ /* Increment past possibly multiple parent prefixes */
+
+ do
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
+ AmlAddress));
+
+ AmlAddress++;
+ PrefixCount++;
+
+ } while (*AmlAddress == AML_PARENT_PREFIX);
+
+ HasPrefix = TRUE;
+ break;
+
+
+ default:
+
+ /* Not a prefix character */
+
+ break;
+ }
+
+ /* Examine first character of name for name segment prefix operator */
+
+ switch (*AmlAddress)
+ {
+ case AML_DUAL_NAME_PREFIX:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
+ AmlAddress));
+
+ AmlAddress++;
+ NameString = AcpiExAllocateNameString (PrefixCount, 2);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ /* Indicate that we processed a prefix */
+
+ HasPrefix = TRUE;
+
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ }
+ break;
+
+
+ case AML_MULTI_NAME_PREFIX_OP:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
+ AmlAddress));
+
+ /* Fetch count of segments remaining in name path */
+
+ AmlAddress++;
+ NumSegments = *AmlAddress;
+
+ NameString = AcpiExAllocateNameString (PrefixCount, NumSegments);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ /* Indicate that we processed a prefix */
+
+ AmlAddress++;
+ HasPrefix = TRUE;
+
+ while (NumSegments &&
+ (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
+ AE_OK)
+ {
+ NumSegments--;
+ }
+
+ break;
+
+
+ case 0:
+
+ /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
+
+ if (PrefixCount == ACPI_UINT32_MAX)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "NameSeg is \"\\\" followed by NULL\n"));
+ }
+
+ /* Consume the NULL byte */
+
+ AmlAddress++;
+ NameString = AcpiExAllocateNameString (PrefixCount, 0);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ break;
+
+
+ default:
+
+ /* Name segment string */
+
+ NameString = AcpiExAllocateNameString (PrefixCount, 1);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ break;
+ }
+ }
+
+ if (AE_CTRL_PENDING == Status && HasPrefix)
+ {
+ /* Ran out of segments after processing a prefix */
+
+ ACPI_ERROR ((AE_INFO,
+ "Malformed Name at %p", NameString));
+ Status = AE_AML_BAD_NAME;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ if (NameString)
+ {
+ ACPI_FREE (NameString);
+ }
+ return_ACPI_STATUS (Status);
+ }
+
+ *OutNameString = NameString;
+ *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exoparg1.c b/source/components/executer/exoparg1.c
new file mode 100644
index 000000000000..9a6cd9fcab75
--- /dev/null
+++ b/source/components/executer/exoparg1.c
@@ -0,0 +1,1111 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg1 - AML execution - opcodes with 1 argument
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXOPARG1_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg1")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (0 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_0A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute operator with no operands, one return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_0A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_TIMER_OP: /* Timer () */
+
+ /* Create a return object of type Integer */
+
+ ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ WalkState->ResultObj = NULL;
+ }
+ else
+ {
+ /* Save the return value */
+
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_0T_0R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
+ * object stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_0T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_RELEASE_OP: /* Release (MutexObject) */
+
+ Status = AcpiExReleaseMutex (Operand[0], WalkState);
+ break;
+
+
+ case AML_RESET_OP: /* Reset (EventObject) */
+
+ Status = AcpiExSystemResetEvent (Operand[0]);
+ break;
+
+
+ case AML_SIGNAL_OP: /* Signal (EventObject) */
+
+ Status = AcpiExSystemSignalEvent (Operand[0]);
+ break;
+
+
+ case AML_SLEEP_OP: /* Sleep (MsecTime) */
+
+ Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
+ break;
+
+
+ case AML_STALL_OP: /* Stall (UsecTime) */
+
+ Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
+ break;
+
+
+ case AML_UNLOAD_OP: /* Unload (Handle) */
+
+ Status = AcpiExUnloadTable (Operand[0]);
+ break;
+
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_1T_0R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with one argument, one target, and no
+ * return value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_1T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_LOAD_OP:
+
+ Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
+ break;
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_1T_1R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with one argument, one target, and a
+ * return value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_1T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
+ UINT32 Temp32;
+ UINT32 i;
+ UINT64 PowerOfTen;
+ UINT64 Digit;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->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:
+
+ /* Create a return object of type Integer for these opcodes */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ switch (WalkState->Opcode)
+ {
+ case AML_BIT_NOT_OP: /* Not (Operand, Result) */
+
+ ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
+ break;
+
+
+ case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
+
+ ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
+
+ /*
+ * Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundary condition is valid.
+ */
+ for (Temp32 = 0; ReturnDesc->Integer.Value &&
+ Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
+ {
+ ReturnDesc->Integer.Value >>= 1;
+ }
+
+ ReturnDesc->Integer.Value = Temp32;
+ break;
+
+
+ case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
+
+ ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
+
+ /*
+ * The Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundary condition is valid.
+ */
+ for (Temp32 = 0; ReturnDesc->Integer.Value &&
+ Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
+ {
+ ReturnDesc->Integer.Value <<= 1;
+ }
+
+ /* Since the bit position is one-based, subtract from 33 (65) */
+
+ ReturnDesc->Integer.Value =
+ Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
+ break;
+
+
+ case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
+
+ /*
+ * The 64-bit ACPI integer can hold 16 4-bit BCD characters
+ * (if table is 32-bit, integer can hold 8 BCD characters)
+ * Convert each 4-bit BCD value
+ */
+ PowerOfTen = 1;
+ ReturnDesc->Integer.Value = 0;
+ Digit = Operand[0]->Integer.Value;
+
+ /* Convert each BCD digit (each is one nybble wide) */
+
+ for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
+ {
+ /* Get the least significant 4-bit BCD digit */
+
+ Temp32 = ((UINT32) Digit) & 0xF;
+
+ /* Check the range of the digit */
+
+ if (Temp32 > 9)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "BCD digit too large (not decimal): 0x%X",
+ Temp32));
+
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+
+ /* Sum the digit into the result with the current power of 10 */
+
+ ReturnDesc->Integer.Value +=
+ (((UINT64) Temp32) * PowerOfTen);
+
+ /* Shift to next BCD digit */
+
+ Digit >>= 4;
+
+ /* Next power of 10 */
+
+ PowerOfTen *= 10;
+ }
+ break;
+
+
+ case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
+
+ ReturnDesc->Integer.Value = 0;
+ Digit = Operand[0]->Integer.Value;
+
+ /* Each BCD digit is one nybble wide */
+
+ for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
+ {
+ (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
+
+ /*
+ * Insert the BCD digit that resides in the
+ * remainder from above
+ */
+ ReturnDesc->Integer.Value |=
+ (((UINT64) Temp32) << ACPI_MUL_4 (i));
+ }
+
+ /* Overflow if there is any data left in Digit */
+
+ if (Digit > 0)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Integer too large to convert to BCD: 0x%8.8X%8.8X",
+ ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
+
+ /*
+ * 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 *) Operand[0] == AcpiGbl_RootNode)
+ {
+ /*
+ * This means that the object does not exist in the namespace,
+ * return FALSE
+ */
+ ReturnDesc->Integer.Value = 0;
+ goto Cleanup;
+ }
+
+ /* Get the object reference, store it, and remove our reference */
+
+ Status = AcpiExGetObjectReference (Operand[0],
+ &ReturnDesc2, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
+ AcpiUtRemoveReference (ReturnDesc2);
+
+ /* The object exists in the namespace, return TRUE */
+
+ ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
+ goto Cleanup;
+
+
+ default:
+ /* No other opcodes get here */
+ break;
+ }
+ break;
+
+
+ case AML_STORE_OP: /* Store (Source, Target) */
+
+ /*
+ * A store operand is typically a number, string, buffer or lvalue
+ * Be careful about deleting the source object,
+ * since the object itself may have been stored.
+ */
+ Status = AcpiExStore (Operand[0], Operand[1], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* It is possible that the Store already produced a return object */
+
+ if (!WalkState->ResultObj)
+ {
+ /*
+ * Normally, we would remove a reference on the Operand[0]
+ * 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.
+ */
+ WalkState->ResultObj = Operand[0];
+ WalkState->Operands[0] = NULL; /* Prevent deletion */
+ }
+ return_ACPI_STATUS (Status);
+
+
+ /*
+ * ACPI 2.0 Opcodes
+ */
+ case AML_COPY_OP: /* Copy (Source, Target) */
+
+ Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
+ WalkState);
+ break;
+
+
+ case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
+
+ Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
+ ACPI_EXPLICIT_CONVERT_DECIMAL);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
+
+ Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
+ ACPI_EXPLICIT_CONVERT_HEX);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
+
+ Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
+
+ Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
+ ACPI_ANY_BASE);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
+ case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
+
+ /* These are two obsolete opcodes */
+
+ ACPI_ERROR ((AE_INFO,
+ "%s is obsolete and not implemented",
+ AcpiPsGetOpcodeName (WalkState->Opcode)));
+ Status = AE_SUPPORT;
+ goto Cleanup;
+
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Store the return value computed above into the target object */
+
+ Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else if (!WalkState->ResultObj)
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with one argument, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *TempDesc;
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Type;
+ UINT64 Value;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_LNOT_OP: /* LNot (Operand) */
+
+ ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Set result to ONES (TRUE) if Value == 0. Note:
+ * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
+ */
+ if (!Operand[0]->Integer.Value)
+ {
+ ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
+ }
+ break;
+
+
+ case AML_DECREMENT_OP: /* Decrement (Operand) */
+ case AML_INCREMENT_OP: /* Increment (Operand) */
+
+ /*
+ * Create a new integer. Can't just get the base integer and
+ * increment it because it may be an Arg or Field.
+ */
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Since we are expecting a Reference operand, it can be either a
+ * NS Node or an internal object.
+ */
+ TempDesc = Operand[0];
+ if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ /* Internal reference object - prevent deletion */
+
+ AcpiUtAddReference (TempDesc);
+ }
+
+ /*
+ * Convert the Reference operand to an Integer (This removes a
+ * reference on the Operand[0] object)
+ *
+ * NOTE: We use LNOT_OP here in order to force resolution of the
+ * reference operand to an actual integer.
+ */
+ Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "While resolving operands for [%s]",
+ AcpiPsGetOpcodeName (WalkState->Opcode)));
+
+ goto Cleanup;
+ }
+
+ /*
+ * TempDesc is now guaranteed to be an Integer object --
+ * Perform the actual increment or decrement
+ */
+ if (WalkState->Opcode == AML_INCREMENT_OP)
+ {
+ ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
+ }
+ else
+ {
+ ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
+ }
+
+ /* Finished with this Integer object */
+
+ AcpiUtRemoveReference (TempDesc);
+
+ /*
+ * Store the result back (indirectly) through the original
+ * Reference object
+ */
+ Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
+ break;
+
+
+ case AML_TYPE_OP: /* ObjectType (SourceObject) */
+
+ /*
+ * Note: The operand is not resolved at this point because we want to
+ * get the associated object, not its value. For example, we don't
+ * want to resolve a FieldUnit to its value, we want the actual
+ * FieldUnit object.
+ */
+
+ /* Get the type of the base object */
+
+ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Allocate a descriptor to hold the type. */
+
+ ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
+
+ /*
+ * Note: The operand is not resolved at this point because we want to
+ * get the associated object, not its value.
+ */
+
+ /* Get the base object */
+
+ Status = AcpiExResolveMultiple (WalkState,
+ Operand[0], &Type, &TempDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * The type of the base object must be integer, buffer, string, or
+ * package. All others are not supported.
+ *
+ * NOTE: Integer is not specifically supported by the ACPI spec,
+ * but is supported implicitly via implicit operand conversion.
+ * rather than bother with conversion, we just use the byte width
+ * global (4 or 8 bytes).
+ */
+ switch (Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Value = AcpiGbl_IntegerByteWidth;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Value = TempDesc->String.Length;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Buffer arguments may not be evaluated at this point */
+
+ Status = AcpiDsGetBufferArguments (TempDesc);
+ Value = TempDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ /* Package arguments may not be evaluated at this point */
+
+ Status = AcpiDsGetPackageArguments (TempDesc);
+ Value = TempDesc->Package.Count;
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Operand must be Buffer/Integer/String/Package - found type %s",
+ AcpiUtGetTypeName (Type)));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Now that we have the size of the object, create a result
+ * object to hold the value
+ */
+ ReturnDesc = AcpiUtCreateIntegerObject (Value);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_REF_OF_OP: /* RefOf (SourceObject) */
+
+ Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
+
+ /* Check for a method local or argument, or standalone String */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
+ {
+ TempDesc = AcpiNsGetAttachedObject (
+ (ACPI_NAMESPACE_NODE *) Operand[0]);
+ if (TempDesc &&
+ ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
+ (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
+ {
+ Operand[0] = TempDesc;
+ AcpiUtAddReference (TempDesc);
+ }
+ else
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ }
+ else
+ {
+ switch ((Operand[0])->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ /*
+ * This is a DerefOf (LocalX | ArgX)
+ *
+ * Must resolve/dereference the local/arg reference first
+ */
+ switch (Operand[0]->Reference.Class)
+ {
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ /* Set Operand[0] to the value of the local/arg */
+
+ Status = AcpiDsMethodDataGetValue (
+ Operand[0]->Reference.Class,
+ Operand[0]->Reference.Value,
+ WalkState, &TempDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Delete our reference to the input object and
+ * point to the object just retrieved
+ */
+ AcpiUtRemoveReference (Operand[0]);
+ Operand[0] = TempDesc;
+ break;
+
+ case ACPI_REFCLASS_REFOF:
+
+ /* Get the object to which the reference refers */
+
+ TempDesc = Operand[0]->Reference.Object;
+ AcpiUtRemoveReference (Operand[0]);
+ Operand[0] = TempDesc;
+ break;
+
+ default:
+
+ /* Must be an Index op - handled below */
+ break;
+ }
+ break;
+
+ case ACPI_TYPE_STRING:
+ break;
+
+ default:
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
+ {
+ if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
+ {
+ /*
+ * This is a DerefOf (String). The string is a reference
+ * to a named ACPI object.
+ *
+ * 1) Find the owning Node
+ * 2) Dereference the node to an actual object. Could be a
+ * Field, so we need to resolve the node to a value.
+ */
+ Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
+ Operand[0]->String.Pointer,
+ ACPI_NS_SEARCH_PARENT,
+ ACPI_CAST_INDIRECT_PTR (
+ ACPI_NAMESPACE_NODE, &ReturnDesc));
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExResolveNodeToValue (
+ ACPI_CAST_INDIRECT_PTR (
+ ACPI_NAMESPACE_NODE, &ReturnDesc),
+ WalkState);
+ goto Cleanup;
+ }
+ }
+
+ /* Operand[0] may have changed from the code above */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
+ {
+ /*
+ * This is a DerefOf (ObjectReference)
+ * Get the actual object from the Node (This is the dereference).
+ * This case may only happen when a LocalX or ArgX is
+ * dereferenced above.
+ */
+ ReturnDesc = AcpiNsGetAttachedObject (
+ (ACPI_NAMESPACE_NODE *) Operand[0]);
+ AcpiUtAddReference (ReturnDesc);
+ }
+ else
+ {
+ /*
+ * This must be a reference object produced by either the
+ * Index() or RefOf() operator
+ */
+ switch (Operand[0]->Reference.Class)
+ {
+ case ACPI_REFCLASS_INDEX:
+
+ /*
+ * The target type for the Index operator must be
+ * either a Buffer or a Package
+ */
+ switch (Operand[0]->Reference.TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ TempDesc = Operand[0]->Reference.Object;
+
+ /*
+ * 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!
+ *
+ * Since we are returning the value of the buffer at the
+ * indexed location, we don't need to add an additional
+ * reference to the buffer itself.
+ */
+ ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
+ TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ /*
+ * Return the referenced element of the package. We must
+ * add another reference to the referenced object, however.
+ */
+ ReturnDesc = *(Operand[0]->Reference.Where);
+ if (ReturnDesc)
+ {
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Index TargetType 0x%X in reference object %p",
+ Operand[0]->Reference.TargetType, Operand[0]));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ACPI_REFCLASS_REFOF:
+
+ ReturnDesc = Operand[0]->Reference.Object;
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
+ ACPI_DESC_TYPE_NAMED)
+ {
+ ReturnDesc = AcpiNsGetAttachedObject (
+ (ACPI_NAMESPACE_NODE *) ReturnDesc);
+ }
+
+ /* Add another reference to the object! */
+
+ AcpiUtAddReference (ReturnDesc);
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Unknown class in reference(%p) - 0x%2.2X",
+ Operand[0], Operand[0]->Reference.Class));
+
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/source/components/executer/exoparg2.c b/source/components/executer/exoparg2.c
new file mode 100644
index 000000000000..b76da75c49d4
--- /dev/null
+++ b/source/components/executer/exoparg2.c
@@ -0,0 +1,642 @@
+/******************************************************************************
+ *
+ * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EXOPARG2_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "acevents.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg2")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (1 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_0T_0R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with two arguments, no target, and no return
+ * value.
+ *
+ * ALLOCATION: Deletes both operands
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_0T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_NAMESPACE_NODE *Node;
+ UINT32 Value;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */
+
+ /* The first operand is a namespace node */
+
+ Node = (ACPI_NAMESPACE_NODE *) Operand[0];
+
+ /* Second value is the notify value */
+
+ Value = (UINT32) Operand[1]->Integer.Value;
+
+ /* Are notifies allowed on this object? */
+
+ if (!AcpiEvIsNotifyObject (Node))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Unexpected notify object type [%s]",
+ AcpiUtGetTypeName (Node->Type)));
+
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ /*
+ * Dispatch the notify to the appropriate handler
+ * NOTE: the request is queued for execution after this method
+ * completes. The notify handlers are NOT invoked synchronously
+ * from this thread -- because handlers may in turn run other
+ * control methods.
+ */
+ Status = AcpiEvQueueNotifyRequest (Node, Value);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_2T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
+ * and one implicit return value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_2T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL;
+ ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Execute the opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_DIVIDE_OP:
+
+ /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
+
+ ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc1)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc2)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
+
+ Status = AcpiUtDivide (Operand[0]->Integer.Value,
+ Operand[1]->Integer.Value,
+ &ReturnDesc1->Integer.Value,
+ &ReturnDesc2->Integer.Value);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+ /* Store the results to the target reference operands */
+
+ Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+Cleanup:
+ /*
+ * Since the remainder is not returned indirectly, remove a reference to
+ * it. Only the quotient is returned indirectly.
+ */
+ AcpiUtRemoveReference (ReturnDesc2);
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Delete the return object */
+
+ AcpiUtRemoveReference (ReturnDesc1);
+ }
+
+ /* Save return object (the remainder) on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc1;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_1T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with two arguments, one target, and a return
+ * value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_1T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ UINT64 Index;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_SIZE Length;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Execute the opcode */
+
+ if (WalkState->OpInfo->Flags & AML_MATH)
+ {
+ /* All simple math opcodes (add, etc.) */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode,
+ Operand[0]->Integer.Value,
+ Operand[1]->Integer.Value);
+ goto StoreResultToTarget;
+ }
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* ReturnDesc will contain the remainder */
+
+ Status = AcpiUtDivide (Operand[0]->Integer.Value,
+ Operand[1]->Integer.Value,
+ NULL,
+ &ReturnDesc->Integer.Value);
+ break;
+
+
+ case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
+
+ Status = AcpiExDoConcatenate (Operand[0], Operand[1],
+ &ReturnDesc, WalkState);
+ break;
+
+
+ case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
+
+ /*
+ * Input object is guaranteed to be a buffer at this point (it may have
+ * been converted.) Copy the raw buffer data to a new object of
+ * type String.
+ */
+
+ /*
+ * Get the length of the new string. It is the smallest of:
+ * 1) Length of the input buffer
+ * 2) Max length as specified in the ToString operator
+ * 3) Length of input buffer up to a zero byte (null terminator)
+ *
+ * NOTE: A length of zero is ok, and will create a zero-length, null
+ * terminated string.
+ */
+ Length = 0;
+ while ((Length < Operand[0]->Buffer.Length) &&
+ (Length < Operand[1]->Integer.Value) &&
+ (Operand[0]->Buffer.Pointer[Length]))
+ {
+ Length++;
+ }
+
+ /* Allocate a new string object */
+
+ ReturnDesc = AcpiUtCreateStringObject (Length);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Copy the raw buffer data with no transform.
+ * (NULL terminated already)
+ */
+ ACPI_MEMCPY (ReturnDesc->String.Pointer,
+ Operand[0]->Buffer.Pointer, Length);
+ break;
+
+
+ case AML_CONCAT_RES_OP:
+
+ /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
+
+ Status = AcpiExConcatTemplate (Operand[0], Operand[1],
+ &ReturnDesc, WalkState);
+ break;
+
+
+ case AML_INDEX_OP: /* Index (Source Index Result) */
+
+ /* Create the internal return object */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Initialize the Index reference object */
+
+ Index = Operand[1]->Integer.Value;
+ ReturnDesc->Reference.Value = (UINT32) Index;
+ ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
+
+ /*
+ * At this point, the Source operand is a String, Buffer, or Package.
+ * Verify that the index is within range.
+ */
+ switch ((Operand[0])->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ if (Index >= Operand[0]->String.Length)
+ {
+ Status = AE_AML_STRING_LIMIT;
+ }
+
+ ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ if (Index >= Operand[0]->Buffer.Length)
+ {
+ Status = AE_AML_BUFFER_LIMIT;
+ }
+
+ ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ if (Index >= Operand[0]->Package.Count)
+ {
+ Status = AE_AML_PACKAGE_LIMIT;
+ }
+
+ ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
+ ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index];
+ break;
+
+ default:
+
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ /* Failure means that the Index was beyond the end of the object */
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Index (0x%8.8X%8.8X) is beyond end of object",
+ ACPI_FORMAT_UINT64 (Index)));
+ goto Cleanup;
+ }
+
+ /*
+ * Save the target object and add a reference to it for the life
+ * of the index
+ */
+ ReturnDesc->Reference.Object = Operand[0];
+ AcpiUtAddReference (Operand[0]);
+
+ /* Store the reference to the Target */
+
+ Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
+
+ /* Return the reference */
+
+ WalkState->ResultObj = ReturnDesc;
+ goto Cleanup;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+
+StoreResultToTarget:
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * Store the result of the operation (which is now in ReturnDesc) into
+ * the Target descriptor.
+ */
+ Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (!WalkState->ResultObj)
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ WalkState->ResultObj = NULL;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN LogicalResult = FALSE;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Create the internal return object */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Execute the Opcode */
+
+ if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
+ {
+ /* LogicalOp (Operand0, Operand1) */
+
+ Status = AcpiExDoLogicalNumericOp (WalkState->Opcode,
+ Operand[0]->Integer.Value, Operand[1]->Integer.Value,
+ &LogicalResult);
+ goto StoreLogicalResult;
+ }
+ else if (WalkState->OpInfo->Flags & AML_LOGICAL)
+ {
+ /* LogicalOp (Operand0, Operand1) */
+
+ Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
+ Operand[1], &LogicalResult);
+ goto StoreLogicalResult;
+ }
+
+ switch (WalkState->Opcode)
+ {
+ case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
+
+ Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
+ if (Status == AE_TIME)
+ {
+ LogicalResult = TRUE; /* TRUE = Acquire timed out */
+ Status = AE_OK;
+ }
+ break;
+
+
+ case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
+
+ Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
+ if (Status == AE_TIME)
+ {
+ LogicalResult = TRUE; /* TRUE, Wait timed out */
+ Status = AE_OK;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+StoreLogicalResult:
+ /*
+ * Set return value to according to LogicalResult. logical TRUE (all ones)
+ * Default is FALSE (zero)
+ */
+ if (LogicalResult)
+ {
+ ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
+ }
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exoparg3.c b/source/components/executer/exoparg3.c
new file mode 100644
index 000000000000..0edac68e60ab
--- /dev/null
+++ b/source/components/executer/exoparg3.c
@@ -0,0 +1,304 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXOPARG3_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "acparser.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg3")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (1 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_3A_0T_0R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Triadic operator (3 operands)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_3A_0T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_SIGNAL_FATAL_INFO *Fatal;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
+ (UINT32) Operand[0]->Integer.Value,
+ (UINT32) Operand[1]->Integer.Value,
+ (UINT32) Operand[2]->Integer.Value));
+
+ Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO));
+ if (Fatal)
+ {
+ Fatal->Type = (UINT32) Operand[0]->Integer.Value;
+ Fatal->Code = (UINT32) Operand[1]->Integer.Value;
+ Fatal->Argument = (UINT32) Operand[2]->Integer.Value;
+ }
+
+ /* Always signal the OS! */
+
+ Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal);
+
+ /* Might return while OS is shutting down, just continue */
+
+ ACPI_FREE (Fatal);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_3A_1T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Triadic operator (3 operands)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_3A_1T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ char *Buffer = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT64 Index;
+ ACPI_SIZE Length;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
+
+ /*
+ * Create the return object. The Source operand is guaranteed to be
+ * either a String or a Buffer, so just use its type.
+ */
+ ReturnDesc = AcpiUtCreateInternalObject (
+ (Operand[0])->Common.Type);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Get the Integer values from the objects */
+
+ Index = Operand[1]->Integer.Value;
+ Length = (ACPI_SIZE) Operand[2]->Integer.Value;
+
+ /*
+ * If the index is beyond the length of the String/Buffer, or if the
+ * requested length is zero, return a zero-length String/Buffer
+ */
+ if (Index >= Operand[0]->String.Length)
+ {
+ Length = 0;
+ }
+
+ /* Truncate request if larger than the actual String/Buffer */
+
+ else if ((Index + Length) > Operand[0]->String.Length)
+ {
+ Length = (ACPI_SIZE) Operand[0]->String.Length -
+ (ACPI_SIZE) Index;
+ }
+
+ /* Strings always have a sub-pointer, not so for buffers */
+
+ switch ((Operand[0])->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ /* Always allocate a new buffer for the String */
+
+ Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
+ if (!Buffer)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* If the requested length is zero, don't allocate a buffer */
+
+ if (Length > 0)
+ {
+ /* Allocate a new buffer for the Buffer */
+
+ Buffer = ACPI_ALLOCATE_ZEROED (Length);
+ if (!Buffer)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ }
+ break;
+
+ default: /* Should not happen */
+
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ if (Buffer)
+ {
+ /* We have a buffer, copy the portion requested */
+
+ ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index,
+ Length);
+ }
+
+ /* Set the length of the new String/Buffer */
+
+ ReturnDesc->String.Pointer = Buffer;
+ ReturnDesc->String.Length = (UINT32) Length;
+
+ /* Mark buffer initialized */
+
+ ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+ /* Store the result in the target */
+
+ Status = AcpiExStore (ReturnDesc, Operand[3], WalkState);
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) || WalkState->ResultObj)
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ WalkState->ResultObj = NULL;
+ }
+
+ /* Set the return object and exit */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exoparg6.c b/source/components/executer/exoparg6.c
new file mode 100644
index 000000000000..bfc6585301f6
--- /dev/null
+++ b/source/components/executer/exoparg6.c
@@ -0,0 +1,365 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXOPARG6_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "acparser.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg6")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (1 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+/* Local prototypes */
+
+static BOOLEAN
+AcpiExDoMatch (
+ UINT32 MatchOp,
+ ACPI_OPERAND_OBJECT *PackageObj,
+ ACPI_OPERAND_OBJECT *MatchObj);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoMatch
+ *
+ * PARAMETERS: MatchOp - The AML match operand
+ * PackageObj - Object from the target package
+ * MatchObj - Object to be matched
+ *
+ * RETURN: TRUE if the match is successful, FALSE otherwise
+ *
+ * DESCRIPTION: Implements the low-level match for the ASL Match operator.
+ * Package elements will be implicitly converted to the type of
+ * the match object (Integer/Buffer/String).
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiExDoMatch (
+ UINT32 MatchOp,
+ ACPI_OPERAND_OBJECT *PackageObj,
+ ACPI_OPERAND_OBJECT *MatchObj)
+{
+ BOOLEAN LogicalResult = TRUE;
+ ACPI_STATUS Status;
+
+
+ /*
+ * Note: Since the PackageObj/MatchObj ordering is opposite to that of
+ * the standard logical operators, we have to reverse them when we call
+ * DoLogicalOp in order to make the implicit conversion rules work
+ * correctly. However, this means we have to flip the entire equation
+ * also. A bit ugly perhaps, but overall, better than fussing the
+ * parameters around at runtime, over and over again.
+ *
+ * Below, P[i] refers to the package element, M refers to the Match object.
+ */
+ switch (MatchOp)
+ {
+ case MATCH_MTR:
+
+ /* Always true */
+
+ break;
+
+ case MATCH_MEQ:
+
+ /*
+ * True if equal: (P[i] == M)
+ * Change to: (M == P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ break;
+
+ case MATCH_MLE:
+
+ /*
+ * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M)
+ * Change to: (M >= P[i]) (M NotLess than P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ LogicalResult = (BOOLEAN) !LogicalResult;
+ break;
+
+ case MATCH_MLT:
+
+ /*
+ * True if less than: (P[i] < M)
+ * Change to: (M > P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ break;
+
+ case MATCH_MGE:
+
+ /*
+ * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M)
+ * Change to: (M <= P[i]) (M NotGreater than P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ LogicalResult = (BOOLEAN)!LogicalResult;
+ break;
+
+ case MATCH_MGT:
+
+ /*
+ * True if greater than: (P[i] > M)
+ * Change to: (M < P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ break;
+
+ default:
+
+ /* Undefined */
+
+ return (FALSE);
+ }
+
+ return LogicalResult;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_6A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_6A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT64 Index;
+ ACPI_OPERAND_OBJECT *ThisElement;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MATCH_OP:
+ /*
+ * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2],
+ * MatchOp2[3], MatchObj2[4], StartIndex[5])
+ */
+
+ /* Validate both Match Term Operators (MTR, MEQ, etc.) */
+
+ if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
+ (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
+ {
+ ACPI_ERROR ((AE_INFO, "Match operator out of range"));
+ Status = AE_AML_OPERAND_VALUE;
+ goto Cleanup;
+ }
+
+ /* Get the package StartIndex, validate against the package length */
+
+ Index = Operand[5]->Integer.Value;
+ if (Index >= Operand[0]->Package.Count)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
+ ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count));
+ Status = AE_AML_PACKAGE_LIMIT;
+ goto Cleanup;
+ }
+
+ /* Create an integer for the return value */
+ /* Default return value is ACPI_UINT64_MAX if no match found */
+
+ ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+
+ }
+
+ /*
+ * Examine each element until a match is found. Both match conditions
+ * must be satisfied for a match to occur. 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
+ * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
+ * match was found.
+ */
+ for ( ; Index < Operand[0]->Package.Count; Index++)
+ {
+ /* Get the current package element */
+
+ ThisElement = Operand[0]->Package.Elements[Index];
+
+ /* Treat any uninitialized (NULL) elements as non-matching */
+
+ if (!ThisElement)
+ {
+ continue;
+ }
+
+ /*
+ * Both match conditions must be satisfied. Execution of a continue
+ * (proceed to next iteration of enclosing for loop) signifies a
+ * non-match.
+ */
+ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
+ ThisElement, Operand[2]))
+ {
+ continue;
+ }
+
+ if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
+ ThisElement, Operand[4]))
+ {
+ continue;
+ }
+
+ /* Match found: Index is the return value */
+
+ ReturnDesc->Integer.Value = Index;
+ break;
+ }
+ break;
+
+
+ case AML_LOAD_TABLE_OP:
+
+ Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
diff --git a/source/components/executer/exprep.c b/source/components/executer/exprep.c
new file mode 100644
index 000000000000..9ec78275bd6f
--- /dev/null
+++ b/source/components/executer/exprep.c
@@ -0,0 +1,648 @@
+
+/******************************************************************************
+ *
+ * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXPREP_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exprep")
+
+/* Local prototypes */
+
+static UINT32
+AcpiExDecodeFieldAccess (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT32 *ReturnByteAlignment);
+
+
+#ifdef ACPI_UNDER_DEVELOPMENT
+
+static UINT32
+AcpiExGenerateAccess (
+ UINT32 FieldBitOffset,
+ UINT32 FieldBitLength,
+ UINT32 RegionLength);
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGenerateAccess
+ *
+ * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer
+ * FieldBitLength - Length of field in bits
+ * RegionLength - Length of parent in bytes
+ *
+ * RETURN: Field granularity (8, 16, 32 or 64) and
+ * ByteAlignment (1, 2, 3, or 4)
+ *
+ * DESCRIPTION: Generate an optimal access width for fields defined with the
+ * AnyAcc keyword.
+ *
+ * NOTE: Need to have the RegionLength in order to check for boundary
+ * conditions (end-of-region). However, the RegionLength is a deferred
+ * operation. Therefore, to complete this implementation, the generation
+ * of this access width must be deferred until the region length has
+ * been evaluated.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExGenerateAccess (
+ UINT32 FieldBitOffset,
+ UINT32 FieldBitLength,
+ UINT32 RegionLength)
+{
+ UINT32 FieldByteLength;
+ UINT32 FieldByteOffset;
+ UINT32 FieldByteEndOffset;
+ UINT32 AccessByteWidth;
+ UINT32 FieldStartOffset;
+ UINT32 FieldEndOffset;
+ UINT32 MinimumAccessWidth = 0xFFFFFFFF;
+ UINT32 MinimumAccesses = 0xFFFFFFFF;
+ UINT32 Accesses;
+
+
+ ACPI_FUNCTION_TRACE (ExGenerateAccess);
+
+
+ /* Round Field start offset and length to "minimal" byte boundaries */
+
+ FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
+ FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength +
+ FieldBitOffset, 8));
+ FieldByteLength = FieldByteEndOffset - FieldByteOffset;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Bit length %u, Bit offset %u\n",
+ FieldBitLength, FieldBitOffset));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Byte Length %u, Byte Offset %u, End Offset %u\n",
+ FieldByteLength, FieldByteOffset, FieldByteEndOffset));
+
+ /*
+ * Iterative search for the maximum access width that is both aligned
+ * and does not go beyond the end of the region
+ *
+ * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
+ */
+ for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
+ {
+ /*
+ * 1) Round end offset up to next access boundary and make sure that
+ * this does not go beyond the end of the parent region.
+ * 2) When the Access width is greater than the FieldByteLength, we
+ * are done. (This does not optimize for the perfectly aligned
+ * case yet).
+ */
+ if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
+ {
+ FieldStartOffset =
+ ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
+ AccessByteWidth;
+
+ FieldEndOffset =
+ ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset),
+ AccessByteWidth) / AccessByteWidth;
+
+ Accesses = FieldEndOffset - FieldStartOffset;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "AccessWidth %u end is within region\n", AccessByteWidth));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Field Start %u, Field End %u -- requires %u accesses\n",
+ FieldStartOffset, FieldEndOffset, Accesses));
+
+ /* Single access is optimal */
+
+ if (Accesses <= 1)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Entire field can be accessed with one operation of size %u\n",
+ AccessByteWidth));
+ return_VALUE (AccessByteWidth);
+ }
+
+ /*
+ * Fits in the region, but requires more than one read/write.
+ * try the next wider access on next iteration
+ */
+ if (Accesses < MinimumAccesses)
+ {
+ MinimumAccesses = Accesses;
+ MinimumAccessWidth = AccessByteWidth;
+ }
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "AccessWidth %u end is NOT within region\n", AccessByteWidth));
+ if (AccessByteWidth == 1)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Field goes beyond end-of-region!\n"));
+
+ /* Field does not fit in the region at all */
+
+ return_VALUE (0);
+ }
+
+ /*
+ * This width goes beyond the end-of-region, back off to
+ * previous access
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Backing off to previous optimal access width of %u\n",
+ MinimumAccessWidth));
+ return_VALUE (MinimumAccessWidth);
+ }
+ }
+
+ /*
+ * Could not read/write field with one operation,
+ * just use max access width
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Cannot access field in one operation, using width 8\n"));
+ return_VALUE (8);
+}
+#endif /* ACPI_UNDER_DEVELOPMENT */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDecodeFieldAccess
+ *
+ * PARAMETERS: ObjDesc - Field object
+ * FieldFlags - Encoded fieldflags (contains access bits)
+ * ReturnByteAlignment - Where the byte alignment is returned
+ *
+ * RETURN: Field granularity (8, 16, 32 or 64) and
+ * ByteAlignment (1, 2, 3, or 4)
+ *
+ * DESCRIPTION: Decode the AccessType bits of a field definition.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExDecodeFieldAccess (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT32 *ReturnByteAlignment)
+{
+ UINT32 Access;
+ UINT32 ByteAlignment;
+ UINT32 BitLength;
+
+
+ ACPI_FUNCTION_TRACE (ExDecodeFieldAccess);
+
+
+ Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
+
+ switch (Access)
+ {
+ case AML_FIELD_ACCESS_ANY:
+
+#ifdef ACPI_UNDER_DEVELOPMENT
+ ByteAlignment =
+ AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BitLength,
+ 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */);
+ BitLength = ByteAlignment * 8;
+#endif
+
+ ByteAlignment = 1;
+ BitLength = 8;
+ break;
+
+ case AML_FIELD_ACCESS_BYTE:
+ case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
+ ByteAlignment = 1;
+ BitLength = 8;
+ break;
+
+ case AML_FIELD_ACCESS_WORD:
+ ByteAlignment = 2;
+ BitLength = 16;
+ break;
+
+ case AML_FIELD_ACCESS_DWORD:
+ ByteAlignment = 4;
+ BitLength = 32;
+ break;
+
+ case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
+ ByteAlignment = 8;
+ BitLength = 64;
+ break;
+
+ default:
+ /* Invalid field access type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown field access type 0x%X",
+ Access));
+ return_UINT32 (0);
+ }
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * BufferField access can be on any byte boundary, so the
+ * ByteAlignment is always 1 byte -- regardless of any ByteAlignment
+ * implied by the field access type.
+ */
+ ByteAlignment = 1;
+ }
+
+ *ReturnByteAlignment = ByteAlignment;
+ return_UINT32 (BitLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPrepCommonFieldObject
+ *
+ * PARAMETERS: ObjDesc - The field object
+ * FieldFlags - Access, LockRule, and UpdateRule.
+ * The format of a FieldFlag is described
+ * in the ACPI specification
+ * FieldAttribute - Special attributes (not used)
+ * FieldBitPosition - Field start position
+ * FieldBitLength - Field length in number of bits
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize the areas of the field object that are common
+ * to the various types of fields. Note: This is very "sensitive"
+ * code because we are solving the general case for field
+ * alignment.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPrepCommonFieldObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT8 FieldAttribute,
+ UINT32 FieldBitPosition,
+ UINT32 FieldBitLength)
+{
+ UINT32 AccessBitWidth;
+ UINT32 ByteAlignment;
+ UINT32 NearestByteAddress;
+
+
+ ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject);
+
+
+ /*
+ * Note: the structure being initialized is the
+ * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common
+ * area are initialized by this procedure.
+ */
+ ObjDesc->CommonField.FieldFlags = FieldFlags;
+ ObjDesc->CommonField.Attribute = FieldAttribute;
+ ObjDesc->CommonField.BitLength = FieldBitLength;
+
+ /*
+ * Decode the access type so we can compute offsets. The access type gives
+ * two pieces of information - the width of each field access and the
+ * necessary ByteAlignment (address granularity) of the access.
+ *
+ * For AnyAcc, the AccessBitWidth is the largest width that is both
+ * necessary and possible in an attempt to access the whole field in one
+ * I/O operation. However, for AnyAcc, the ByteAlignment is always one
+ * byte.
+ *
+ * For all Buffer Fields, the ByteAlignment is always one byte.
+ *
+ * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
+ * the same (equivalent) as the ByteAlignment.
+ */
+ AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
+ &ByteAlignment);
+ if (!AccessBitWidth)
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+ /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */
+
+ ObjDesc->CommonField.AccessByteWidth = (UINT8)
+ ACPI_DIV_8 (AccessBitWidth);
+
+ /*
+ * BaseByteOffset is the address of the start of the field within the
+ * region. It is the byte address of the first *datum* (field-width data
+ * unit) of the field. (i.e., the first datum that contains at least the
+ * first *bit* of the field.)
+ *
+ * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
+ * (Byte access), and it defines the addressing granularity of the parent
+ * region or buffer.
+ */
+ NearestByteAddress =
+ ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
+ ObjDesc->CommonField.BaseByteOffset = (UINT32)
+ ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
+
+ /*
+ * StartFieldBitOffset is the offset of the first bit of the field within
+ * a field datum.
+ */
+ ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
+ (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPrepFieldValue
+ *
+ * PARAMETERS: Info - Contains all field creation info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
+ * connect it to the parent Node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPrepFieldValue (
+ ACPI_CREATE_FIELD_INFO *Info)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *SecondDesc = NULL;
+ ACPI_STATUS Status;
+ UINT32 AccessByteWidth;
+ UINT32 Type;
+
+
+ ACPI_FUNCTION_TRACE (ExPrepFieldValue);
+
+
+ /* Parameter validation */
+
+ if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
+ {
+ if (!Info->RegionNode)
+ {
+ ACPI_ERROR ((AE_INFO, "Null RegionNode"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ Type = AcpiNsGetType (Info->RegionNode);
+ if (Type != ACPI_TYPE_REGION)
+ {
+ ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
+ Type, AcpiUtGetTypeName (Type)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ }
+
+ /* Allocate a new field object */
+
+ ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize areas of the object that are common to all fields */
+
+ ObjDesc->CommonField.Node = Info->FieldNode;
+ Status = AcpiExPrepCommonFieldObject (ObjDesc,
+ Info->FieldFlags, Info->Attribute,
+ Info->FieldBitPosition, Info->FieldBitLength);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtDeleteObjectDesc (ObjDesc);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize areas of the object that are specific to the field type */
+
+ switch (Info->FieldType)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
+
+ /* Fields specific to GenericSerialBus fields */
+
+ ObjDesc->Field.AccessLength = Info->AccessLength;
+
+ if (Info->ConnectionNode)
+ {
+ SecondDesc = Info->ConnectionNode->Object;
+ if (!(SecondDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferArguments (SecondDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtDeleteObjectDesc (ObjDesc);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ ObjDesc->Field.ResourceBuffer = SecondDesc->Buffer.Pointer;
+ ObjDesc->Field.ResourceLength = (UINT16) SecondDesc->Buffer.Length;
+ }
+ else if (Info->ResourceBuffer)
+ {
+ ObjDesc->Field.ResourceBuffer = Info->ResourceBuffer;
+ ObjDesc->Field.ResourceLength = Info->ResourceLength;
+ }
+
+ /* Allow full data read from EC address space */
+
+ if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
+ (ObjDesc->CommonField.BitLength > 8))
+ {
+ AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES (
+ ObjDesc->CommonField.BitLength);
+
+ /* Maximum byte width supported is 255 */
+
+ if (AccessByteWidth < 256)
+ {
+ ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth;
+ }
+ }
+
+ /* An additional reference for the container */
+
+ AcpiUtAddReference (ObjDesc->Field.RegionObj);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
+ ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
+ ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ ObjDesc->BankField.Value = Info->BankValue;
+ ObjDesc->BankField.RegionObj =
+ AcpiNsGetAttachedObject (Info->RegionNode);
+ ObjDesc->BankField.BankObj =
+ AcpiNsGetAttachedObject (Info->RegisterNode);
+
+ /* An additional reference for the attached objects */
+
+ AcpiUtAddReference (ObjDesc->BankField.RegionObj);
+ AcpiUtAddReference (ObjDesc->BankField.BankObj);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
+ ObjDesc->BankField.StartFieldBitOffset,
+ ObjDesc->BankField.BaseByteOffset,
+ ObjDesc->Field.AccessByteWidth,
+ ObjDesc->BankField.RegionObj,
+ ObjDesc->BankField.BankObj));
+
+ /*
+ * Remember location in AML stream of the field unit
+ * opcode and operands -- since the BankValue
+ * operands must be evaluated.
+ */
+ SecondDesc = ObjDesc->Common.NextObject;
+ SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
+ Info->DataRegisterNode)->Named.Data;
+ SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
+ Info->DataRegisterNode)->Named.Length;
+
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ /* Get the Index and Data registers */
+
+ ObjDesc->IndexField.IndexObj =
+ AcpiNsGetAttachedObject (Info->RegisterNode);
+ ObjDesc->IndexField.DataObj =
+ AcpiNsGetAttachedObject (Info->DataRegisterNode);
+
+ if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
+ {
+ ACPI_ERROR ((AE_INFO, "Null Index Object during field prep"));
+ AcpiUtDeleteObjectDesc (ObjDesc);
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* An additional reference for the attached objects */
+
+ AcpiUtAddReference (ObjDesc->IndexField.DataObj);
+ AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
+
+ /*
+ * April 2006: Changed to match MS behavior
+ *
+ * The value written to the Index register is the byte offset of the
+ * target field in units of the granularity of the IndexField
+ *
+ * Previously, the value was calculated as an index in terms of the
+ * width of the Data register, as below:
+ *
+ * ObjDesc->IndexField.Value = (UINT32)
+ * (Info->FieldBitPosition / ACPI_MUL_8 (
+ * ObjDesc->Field.AccessByteWidth));
+ *
+ * February 2006: Tried value as a byte offset:
+ * ObjDesc->IndexField.Value = (UINT32)
+ * ACPI_DIV_8 (Info->FieldBitPosition);
+ */
+ ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN (
+ ACPI_DIV_8 (Info->FieldBitPosition),
+ ObjDesc->IndexField.AccessByteWidth);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
+ ObjDesc->IndexField.StartFieldBitOffset,
+ ObjDesc->IndexField.BaseByteOffset,
+ ObjDesc->IndexField.Value,
+ ObjDesc->Field.AccessByteWidth,
+ ObjDesc->IndexField.IndexObj,
+ ObjDesc->IndexField.DataObj));
+ break;
+
+ default:
+ /* No other types should get here */
+ break;
+ }
+
+ /*
+ * Store the constructed descriptor (ObjDesc) into the parent Node,
+ * preserving the current type of that NamedObj.
+ */
+ Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
+ AcpiNsGetType (Info->FieldNode));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
+ Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/source/components/executer/exregion.c b/source/components/executer/exregion.c
new file mode 100644
index 000000000000..8a40250794e7
--- /dev/null
+++ b/source/components/executer/exregion.c
@@ -0,0 +1,565 @@
+
+/******************************************************************************
+ *
+ * Module Name: exregion - ACPI default OpRegion (address space) handlers
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EXREGION_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exregion")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemMemorySpaceHandler
+ *
+ * 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
+AcpiExSystemMemorySpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ void *LogicalAddrPtr = NULL;
+ ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
+ UINT32 Length;
+ ACPI_SIZE MapLength;
+ ACPI_SIZE PageBoundaryMapLength;
+#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
+ UINT32 Remainder;
+#endif
+
+
+ ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
+
+
+ /* Validate and translate the bit width */
+
+ switch (BitWidth)
+ {
+ case 8:
+ Length = 1;
+ break;
+
+ case 16:
+ Length = 2;
+ break;
+
+ case 32:
+ Length = 4;
+ break;
+
+ case 64:
+ Length = 8;
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
+ BitWidth));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
+ /*
+ * Hardware does not support non-aligned data transfers, we must verify
+ * the request.
+ */
+ (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
+ if (Remainder != 0)
+ {
+ return_ACPI_STATUS (AE_AML_ALIGNMENT);
+ }
+#endif
+
+ /*
+ * 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 < MemInfo->MappedPhysicalAddress) ||
+ (((UINT64) Address + Length) >
+ ((UINT64)
+ 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);
+ }
+
+ /*
+ * October 2009: Attempt to map from the requested address to the
+ * end of the region. However, we will never map more than one
+ * page, nor will we cross a page boundary.
+ */
+ MapLength = (ACPI_SIZE)
+ ((MemInfo->Address + MemInfo->Length) - Address);
+
+ /*
+ * If mapping the entire remaining portion of the region will cross
+ * a page boundary, just map up to the page boundary, do not cross.
+ * On some systems, crossing a page boundary while mapping regions
+ * can cause warnings if the pages have different attributes
+ * due to resource management.
+ *
+ * This has the added benefit of constraining a single mapping to
+ * one page, which is similar to the original code that used a 4k
+ * maximum window.
+ */
+ PageBoundaryMapLength =
+ ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address;
+ if (PageBoundaryMapLength == 0)
+ {
+ PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
+ }
+
+ if (MapLength > PageBoundaryMapLength)
+ {
+ MapLength = PageBoundaryMapLength;
+ }
+
+ /* Create a new mapping starting at the address given */
+
+ MemInfo->MappedLogicalAddress = AcpiOsMapMemory (
+ (ACPI_PHYSICAL_ADDRESS) Address, MapLength);
+ if (!MemInfo->MappedLogicalAddress)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not map memory at 0x%8.8X%8.8X, size %u",
+ ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength));
+ MemInfo->MappedLength = 0;
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Save the physical address and mapping size */
+
+ MemInfo->MappedPhysicalAddress = Address;
+ MemInfo->MappedLength = MapLength;
+ }
+
+ /*
+ * Generate a logical pointer corresponding to the address we want to
+ * access
+ */
+ LogicalAddrPtr = MemInfo->MappedLogicalAddress +
+ ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
+ BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
+
+ /*
+ * Perform the memory read or write
+ *
+ * Note: For machines that do not support non-aligned transfers, the target
+ * address was checked for alignment above. We do not attempt to break the
+ * transfer up into smaller (byte-size) chunks because the AML specifically
+ * asked for a transfer width that the hardware may require.
+ */
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ switch (BitWidth)
+ {
+ case 8:
+ *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
+ break;
+
+ case 16:
+ *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
+ break;
+
+ case 32:
+ *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
+ break;
+
+ case 64:
+ *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
+ break;
+
+ default:
+ /* BitWidth was already validated */
+ break;
+ }
+ break;
+
+ case ACPI_WRITE:
+
+ switch (BitWidth)
+ {
+ case 8:
+ ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value;
+ break;
+
+ case 16:
+ ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value;
+ break;
+
+ case 32:
+ ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value;
+ break;
+
+ case 64:
+ ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value;
+ break;
+
+ default:
+ /* BitWidth was already validated */
+ break;
+ }
+ break;
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemIoSpaceHandler
+ *
+ * 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
+AcpiExSystemIoSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Value32;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
+ BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
+
+ /* Decode the function parameter */
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
+ &Value32, BitWidth);
+ *Value = Value32;
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
+ (UINT32) *Value, BitWidth);
+ break;
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPciConfigSpaceHandler
+ *
+ * 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
+AcpiExPciConfigSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PCI_ID *PciId;
+ UINT16 PciRegister;
+
+
+ ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
+
+
+ /*
+ * The arguments to AcpiOs(Read|Write)PciConfiguration are:
+ *
+ * PciSegment is the PCI bus segment range 0-31
+ * PciBus is the PCI bus number range 0-255
+ * PciDevice is the PCI device number range 0-31
+ * PciFunction is the PCI device function number
+ * PciRegister is the Config space register range 0-255 bytes
+ *
+ * Value - input value for write, output address for read
+ *
+ */
+ PciId = (ACPI_PCI_ID *) RegionContext;
+ PciRegister = (UINT16) (UINT32) Address;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
+ Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
+ PciId->Function, PciRegister));
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ Status = AcpiOsReadPciConfiguration (PciId, PciRegister,
+ Value, BitWidth);
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiOsWritePciConfiguration (PciId, PciRegister,
+ *Value, BitWidth);
+ break;
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCmosSpaceHandler
+ *
+ * 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 CMOS address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCmosSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPciBarSpaceHandler
+ *
+ * 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 BarTarget address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPciBarSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDataTableSpaceHandler
+ *
+ * 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 Data Table address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDataTableSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
+
+
+ /*
+ * Perform the memory read or write. The BitWidth was already
+ * validated.
+ */
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
+ ACPI_DIV_8 (BitWidth));
+ break;
+
+ case ACPI_WRITE:
+
+ ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
+ ACPI_DIV_8 (BitWidth));
+ break;
+
+ default:
+
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/source/components/executer/exresnte.c b/source/components/executer/exresnte.c
new file mode 100644
index 000000000000..03962edf9705
--- /dev/null
+++ b/source/components/executer/exresnte.c
@@ -0,0 +1,302 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresnte - AML Interpreter object resolution
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXRESNTE_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exresnte")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveNodeToValue
+ *
+ * PARAMETERS: ObjectPtr - Pointer to a location that contains
+ * a pointer to a NS node, and will receive a
+ * pointer to the resolved object.
+ * WalkState - Current state. Valid only if executing AML
+ * code. NULL if simply resolving an object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Resolve a Namespace node to a valued object
+ *
+ * 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_INTEGER
+ * ACPI_TYPE_STRING
+ * ACPI_TYPE_BUFFER
+ * ACPI_TYPE_MUTEX
+ * ACPI_TYPE_PACKAGE
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveNodeToValue (
+ ACPI_NAMESPACE_NODE **ObjectPtr,
+ ACPI_WALK_STATE *WalkState)
+
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *SourceDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OBJECT_TYPE EntryType;
+
+
+ ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
+
+
+ /*
+ * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
+ * object that is attached to the Node.
+ */
+ Node = *ObjectPtr;
+ SourceDesc = AcpiNsGetAttachedObject (Node);
+ EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
+ Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
+
+ if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
+ (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
+ {
+ /* There is always exactly one level of indirection */
+
+ Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
+ SourceDesc = AcpiNsGetAttachedObject (Node);
+ EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
+ *ObjectPtr = Node;
+ }
+
+ /*
+ * Several object types require no further processing:
+ * 1) Device/Thermal objects don't have a "real" subobject, return the Node
+ * 2) Method locals and arguments have a pseudo-Node
+ * 3) 10/2007: Added method type to assist with Package construction.
+ */
+ if ((EntryType == ACPI_TYPE_DEVICE) ||
+ (EntryType == ACPI_TYPE_THERMAL) ||
+ (EntryType == ACPI_TYPE_METHOD) ||
+ (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ if (!SourceDesc)
+ {
+ ACPI_ERROR ((AE_INFO, "No object attached to node %p",
+ 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 (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ Status = AcpiDsGetPackageArguments (SourceDesc);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ Status = AcpiDsGetBufferArguments (SourceDesc);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "FieldRead Node=%p SourceDesc=%p Type=%X\n",
+ Node, SourceDesc, EntryType));
+
+ Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
+ break;
+
+ /* For these objects, just return the object attached to the Node */
+
+ case ACPI_TYPE_MUTEX:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_EVENT:
+ case ACPI_TYPE_REGION:
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+ /* TYPE_ANY is untyped, and thus there is no object associated with it */
+
+ case ACPI_TYPE_ANY:
+
+ ACPI_ERROR ((AE_INFO,
+ "Untyped entry %p, no attached object!", Node));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ switch (SourceDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_INDEX:
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+ default:
+ /* No named references are allowed here */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unsupported Reference type 0x%X",
+ SourceDesc->Reference.Class));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ break;
+
+
+ default:
+
+ /* Default case is for unknown types */
+
+ ACPI_ERROR ((AE_INFO,
+ "Node %p - Unknown object type 0x%X",
+ Node, EntryType));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+
+ } /* switch (EntryType) */
+
+
+ /* Return the object descriptor */
+
+ *ObjectPtr = (void *) ObjDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exresolv.c b/source/components/executer/exresolv.c
new file mode 100644
index 000000000000..e92fb2468e77
--- /dev/null
+++ b/source/components/executer/exresolv.c
@@ -0,0 +1,580 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresolv - AML Interpreter object resolution
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXRESOLV_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "amlcode.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exresolv")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExResolveObjectToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveToValue
+ *
+ * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
+ * be either an (ACPI_OPERAND_OBJECT *)
+ * or an ACPI_HANDLE.
+ * WalkState - Current method state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert Reference objects to values
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
+
+
+ if (!StackPtr || !*StackPtr)
+ {
+ ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
+ 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 (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
+ {
+ Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!*StackPtr)
+ {
+ ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+ }
+
+ /*
+ * Object on the stack may have changed if AcpiExResolveObjectToValue()
+ * was called (i.e., we can't use an _else_ here.)
+ */
+ if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
+ {
+ Status = AcpiExResolveNodeToValue (
+ ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
+ WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveObjectToValue
+ *
+ * PARAMETERS: StackPtr - Pointer to an internal object
+ * WalkState - Current method state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value from an internal object. The Reference type
+ * uses the associated AML opcode to determine the value.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExResolveObjectToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *StackDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ UINT8 RefType;
+
+
+ ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
+
+
+ StackDesc = *StackPtr;
+
+ /* This is an ACPI_OPERAND_OBJECT */
+
+ switch (StackDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ RefType = StackDesc->Reference.Class;
+
+ switch (RefType)
+ {
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ /*
+ * Get the local from the method's state info
+ * Note: this increments the local's object reference count
+ */
+ Status = AcpiDsMethodDataGetValue (RefType,
+ StackDesc->Reference.Value, WalkState, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
+ StackDesc->Reference.Value, ObjDesc));
+
+ /*
+ * Now we can delete the original Reference Object and
+ * replace it with the resolved value
+ */
+ AcpiUtRemoveReference (StackDesc);
+ *StackPtr = ObjDesc;
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ switch (StackDesc->Reference.TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /* Just return - do not dereference */
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ /* If method call or CopyObject - do not dereference */
+
+ if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
+ (WalkState->Opcode == AML_COPY_OP))
+ {
+ break;
+ }
+
+ /* Otherwise, dereference the PackageIndex to a package element */
+
+ ObjDesc = *StackDesc->Reference.Where;
+ if (ObjDesc)
+ {
+ /*
+ * Valid object descriptor, copy pointer to return value
+ * (i.e., dereference the package index)
+ * Delete the ref object, increment the returned object
+ */
+ AcpiUtRemoveReference (StackDesc);
+ AcpiUtAddReference (ObjDesc);
+ *StackPtr = ObjDesc;
+ }
+ else
+ {
+ /*
+ * A NULL object descriptor means an uninitialized element of
+ * the package, can't dereference it
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Attempt to dereference an Index to NULL package element Idx=%p",
+ StackDesc));
+ Status = AE_AML_UNINITIALIZED_ELEMENT;
+ }
+ break;
+
+
+ default:
+
+ /* Invalid reference object */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown TargetType 0x%X in Index/Reference object %p",
+ StackDesc->Reference.TargetType, StackDesc));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ break;
+
+
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_DEBUG:
+ case ACPI_REFCLASS_TABLE:
+
+ /* Just leave the object as-is, do not dereference */
+
+ break;
+
+ case ACPI_REFCLASS_NAME: /* Reference to a named object */
+
+ /* Dereference the name */
+
+ if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
+ (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
+ {
+ /* These node types do not have 'real' subobjects */
+
+ *StackPtr = (void *) StackDesc->Reference.Node;
+ }
+ else
+ {
+ /* Get the object pointed to by the namespace node */
+
+ *StackPtr = (StackDesc->Reference.Node)->Object;
+ AcpiUtAddReference (*StackPtr);
+ }
+
+ AcpiUtRemoveReference (StackDesc);
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Reference type 0x%X in %p", RefType, StackDesc));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ Status = AcpiDsGetBufferArguments (StackDesc);
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ Status = AcpiDsGetPackageArguments (StackDesc);
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n",
+ StackDesc, StackDesc->Common.Type));
+
+ Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
+
+ /* Remove a reference to the original operand, then override */
+
+ AcpiUtRemoveReference (*StackPtr);
+ *StackPtr = (void *) ObjDesc;
+ break;
+
+ default:
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveMultiple
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ * Operand - Starting point for resolution
+ * ReturnType - Where the object type is returned
+ * ReturnDesc - Where the resolved object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return the base object and type. Traverse a reference list if
+ * necessary to get to the base object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveMultiple (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT *Operand,
+ ACPI_OBJECT_TYPE *ReturnType,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OBJECT_TYPE Type;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
+
+
+ /* Operand can be either a namespace node or an operand descriptor */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+ Type = ObjDesc->Common.Type;
+ break;
+
+ case ACPI_DESC_TYPE_NAMED:
+ Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+
+ /* If we had an Alias node, use the attached object for type info */
+
+ if (Type == ACPI_TYPE_LOCAL_ALIAS)
+ {
+ Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+ }
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* If type is anything other than a reference, we are done */
+
+ if (Type != ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ goto Exit;
+ }
+
+ /*
+ * For reference objects created via the RefOf, Index, or Load/LoadTable
+ * operators, we need to get to the base object (as per the ACPI
+ * specification of the ObjectType and SizeOf operators). This means
+ * traversing the list of possibly many nested references.
+ */
+ while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_NAME:
+
+ /* Dereference the reference pointer */
+
+ if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
+ {
+ Node = ObjDesc->Reference.Object;
+ }
+ else /* AML_INT_NAMEPATH_OP */
+ {
+ Node = ObjDesc->Reference.Node;
+ }
+
+ /* All "References" point to a NS node */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Not a namespace node %p [%s]",
+ Node, AcpiUtGetDescriptorName (Node)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* Get the attached object */
+
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (!ObjDesc)
+ {
+ /* No object, use the NS node type */
+
+ Type = AcpiNsGetType (Node);
+ goto Exit;
+ }
+
+ /* Check for circular references */
+
+ if (ObjDesc == Operand)
+ {
+ return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
+ }
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ /* Get the type of this reference (index into another object) */
+
+ Type = ObjDesc->Reference.TargetType;
+ if (Type != ACPI_TYPE_PACKAGE)
+ {
+ goto Exit;
+ }
+
+ /*
+ * The main object is a package, we want to get the type
+ * of the individual package element that is referenced by
+ * the index.
+ *
+ * This could of course in turn be another reference object.
+ */
+ ObjDesc = *(ObjDesc->Reference.Where);
+ if (!ObjDesc)
+ {
+ /* NULL package elements are allowed */
+
+ Type = 0; /* Uninitialized */
+ goto Exit;
+ }
+ break;
+
+
+ case ACPI_REFCLASS_TABLE:
+
+ Type = ACPI_TYPE_DDB_HANDLE;
+ goto Exit;
+
+
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ if (ReturnDesc)
+ {
+ Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
+ ObjDesc->Reference.Value, WalkState, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ else
+ {
+ Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
+ ObjDesc->Reference.Value, WalkState, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (!ObjDesc)
+ {
+ Type = ACPI_TYPE_ANY;
+ goto Exit;
+ }
+ }
+ break;
+
+
+ case ACPI_REFCLASS_DEBUG:
+
+ /* The Debug Object is of type "DebugObject" */
+
+ Type = ACPI_TYPE_DEBUG_OBJECT;
+ goto Exit;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+ }
+
+ /*
+ * Now we are guaranteed to have an object that has not been created
+ * via the RefOf or Index operators.
+ */
+ Type = ObjDesc->Common.Type;
+
+
+Exit:
+ /* Convert internal types to external types */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ Type = ACPI_TYPE_FIELD_UNIT;
+ break;
+
+ case ACPI_TYPE_LOCAL_SCOPE:
+
+ /* Per ACPI Specification, Scope is untyped */
+
+ Type = ACPI_TYPE_ANY;
+ break;
+
+ default:
+ /* No change to Type required */
+ break;
+ }
+
+ *ReturnType = Type;
+ if (ReturnDesc)
+ {
+ *ReturnDesc = ObjDesc;
+ }
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/source/components/executer/exresop.c b/source/components/executer/exresop.c
new file mode 100644
index 000000000000..1bcba690333b
--- /dev/null
+++ b/source/components/executer/exresop.c
@@ -0,0 +1,738 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresop - AML Interpreter operand/object resolution
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXRESOP_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "amlcode.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exresop")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExCheckObjectType (
+ ACPI_OBJECT_TYPE TypeNeeded,
+ ACPI_OBJECT_TYPE ThisType,
+ void *Object);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCheckObjectType
+ *
+ * PARAMETERS: TypeNeeded Object type needed
+ * ThisType Actual object type
+ * Object Object pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check required type against actual type
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExCheckObjectType (
+ ACPI_OBJECT_TYPE TypeNeeded,
+ ACPI_OBJECT_TYPE ThisType,
+ void *Object)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (TypeNeeded == ACPI_TYPE_ANY)
+ {
+ /* All types OK, so we don't perform any typechecks */
+
+ return (AE_OK);
+ }
+
+ if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ /*
+ * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
+ * objects and thus allow them to be targets. (As per the ACPI
+ * specification, a store to a constant is a noop.)
+ */
+ if ((ThisType == ACPI_TYPE_INTEGER) &&
+ (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
+ {
+ return (AE_OK);
+ }
+ }
+
+ if (TypeNeeded != ThisType)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed type [%s], found [%s] %p",
+ AcpiUtGetTypeName (TypeNeeded),
+ AcpiUtGetTypeName (ThisType), Object));
+
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveOperands
+ *
+ * PARAMETERS: Opcode - Opcode being interpreted
+ * StackPtr - Pointer to the operand stack to be
+ * resolved
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert multiple input operands to the types required by the
+ * target operator.
+ *
+ * Each 5-bit group in ArgTypes represents one required
+ * operand and indicates the required Type. The corresponding operand
+ * will be converted to the required type if possible, otherwise we
+ * abort with an exception.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveOperands (
+ UINT16 Opcode,
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status = AE_OK;
+ UINT8 ObjectType;
+ UINT32 ArgTypes;
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT32 ThisArgType;
+ ACPI_OBJECT_TYPE TypeNeeded;
+ UINT16 TargetOp = 0;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode);
+
+
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+ if (OpInfo->Class == AML_CLASS_UNKNOWN)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+ }
+
+ ArgTypes = OpInfo->RuntimeArgs;
+ if (ArgTypes == ARGI_INVALID_OPCODE)
+ {
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ Opcode));
+
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
+ Opcode, OpInfo->Name, ArgTypes));
+
+ /*
+ * Normal exit is with (ArgTypes == 0) at end of argument list.
+ * Function will return an exception from within the loop upon
+ * finding an entry which is not (or cannot be converted
+ * to) the required type; if stack underflows; or upon
+ * finding a NULL stack entry (which should not happen).
+ */
+ while (GET_CURRENT_ARG_TYPE (ArgTypes))
+ {
+ if (!StackPtr || !*StackPtr)
+ {
+ ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
+ StackPtr));
+
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* Extract useful items */
+
+ ObjDesc = *StackPtr;
+
+ /* Decode the descriptor type */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_NAMED:
+
+ /* Namespace Node */
+
+ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+
+ /*
+ * Resolve an alias object. The construction of these objects
+ * guarantees that there is only one level of alias indirection;
+ * thus, the attached object is always the aliased namespace node
+ */
+ if (ObjectType == ACPI_TYPE_LOCAL_ALIAS)
+ {
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+ *StackPtr = ObjDesc;
+ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ }
+ break;
+
+
+ case ACPI_DESC_TYPE_OPERAND:
+
+ /* ACPI internal object */
+
+ ObjectType = ObjDesc->Common.Type;
+
+ /* Check for bad ACPI_OBJECT_TYPE */
+
+ if (!AcpiUtValidObjectType (ObjectType))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Bad operand object type [0x%X]", ObjectType));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ /* Validate the Reference */
+
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_DEBUG:
+
+ TargetOp = AML_DEBUG_OP;
+
+ /*lint -fallthrough */
+
+ case ACPI_REFCLASS_ARG:
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_INDEX:
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
+ case ACPI_REFCLASS_NAME: /* Reference to a named object */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Operand is a Reference, Class [%s] %2.2X\n",
+ AcpiUtGetReferenceName (ObjDesc),
+ ObjDesc->Reference.Class));
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Reference Class 0x%2.2X in %p",
+ ObjDesc->Reference.Class, ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ }
+ break;
+
+
+ default:
+
+ /* Invalid descriptor */
+
+ ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]",
+ ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Get one argument type, point to the next */
+
+ ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
+ INCREMENT_ARG_LIST (ArgTypes);
+
+ /*
+ * Handle cases where the object does not need to be
+ * resolved to a value
+ */
+ switch (ThisArgType)
+ {
+ case ARGI_REF_OR_STRING: /* Can be a String or Reference */
+
+ if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
+ (ObjDesc->Common.Type == ACPI_TYPE_STRING))
+ {
+ /*
+ * String found - the string references a named object and
+ * must be resolved to a node
+ */
+ goto NextOperand;
+ }
+
+ /*
+ * Else not a string - fall through to the normal Reference
+ * case below
+ */
+ /*lint -fallthrough */
+
+ case ARGI_REFERENCE: /* References: */
+ case ARGI_INTEGER_REF:
+ case ARGI_OBJECT_REF:
+ case ARGI_DEVICE_REF:
+ case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
+ case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
+ case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
+
+ /*
+ * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
+ * A Namespace Node is OK as-is
+ */
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ goto NextOperand;
+ }
+
+ Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE,
+ ObjectType, ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ goto NextOperand;
+
+
+ case ARGI_DATAREFOBJ: /* Store operator only */
+
+ /*
+ * 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.
+ * -- All others must be resolved below.
+ */
+ if ((Opcode == AML_STORE_OP) &&
+ ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+ ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
+ {
+ goto NextOperand;
+ }
+ break;
+
+ default:
+ /* All cases covered above */
+ break;
+ }
+
+ /*
+ * Resolve this object to a value
+ */
+ Status = AcpiExResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the resolved object */
+
+ ObjDesc = *StackPtr;
+
+ /*
+ * Check the resulting object (value) type
+ */
+ switch (ThisArgType)
+ {
+ /*
+ * For the simple cases, only one type of resolved object
+ * is allowed
+ */
+ case ARGI_MUTEX:
+
+ /* Need an operand of type ACPI_TYPE_MUTEX */
+
+ TypeNeeded = ACPI_TYPE_MUTEX;
+ break;
+
+ case ARGI_EVENT:
+
+ /* Need an operand of type ACPI_TYPE_EVENT */
+
+ TypeNeeded = ACPI_TYPE_EVENT;
+ break;
+
+ case ARGI_PACKAGE: /* Package */
+
+ /* Need an operand of type ACPI_TYPE_PACKAGE */
+
+ TypeNeeded = ACPI_TYPE_PACKAGE;
+ break;
+
+ case ARGI_ANYTYPE:
+
+ /* Any operand type will do */
+
+ TypeNeeded = ACPI_TYPE_ANY;
+ break;
+
+ case ARGI_DDBHANDLE:
+
+ /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
+
+ TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
+ break;
+
+
+ /*
+ * The more complex cases allow multiple resolved object types
+ */
+ case ARGI_INTEGER:
+
+ /*
+ * Need an operand of type ACPI_TYPE_INTEGER,
+ * But we can implicitly convert from a STRING or BUFFER
+ * Aka - "Implicit Source Operand Conversion"
+ */
+ Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_TYPE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ goto NextOperand;
+
+
+ case ARGI_BUFFER:
+
+ /*
+ * Need an operand of type ACPI_TYPE_BUFFER,
+ * But we can implicitly convert from a STRING or INTEGER
+ * Aka - "Implicit Source Operand Conversion"
+ */
+ Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_TYPE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ goto NextOperand;
+
+
+ case ARGI_STRING:
+
+ /*
+ * Need an operand of type ACPI_TYPE_STRING,
+ * But we can implicitly convert from a BUFFER or INTEGER
+ * Aka - "Implicit Source Operand Conversion"
+ */
+ Status = AcpiExConvertToString (ObjDesc, StackPtr,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_TYPE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ goto NextOperand;
+
+
+ case ARGI_COMPUTEDATA:
+
+ /* Need an operand of type INTEGER, STRING or BUFFER */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_BUFFER_OR_STRING:
+
+ /* Need an operand of type STRING or BUFFER */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ /* Highest priority conversion is to type Buffer */
+
+ Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_DATAOBJECT:
+ /*
+ * ARGI_DATAOBJECT is only used by the SizeOf operator.
+ * Need a buffer, string, package, or RefOf reference.
+ *
+ * The only reference allowed here is a direct reference to
+ * a namespace node.
+ */
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Buffer/String/Package/Reference], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_COMPLEXOBJ:
+
+ /* Need a buffer or package or (ACPI 2.0) String */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Buffer/String/Package], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
+
+ /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_REGION:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Region/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_DATAREFOBJ:
+
+ /* Used by the Store() operator only */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ case ACPI_TYPE_DDB_HANDLE:
+
+ /* Valid operand */
+ break;
+
+ default:
+
+ if (AcpiGbl_EnableInterpreterSlack)
+ {
+ /*
+ * Enable original behavior of Store(), allowing any and all
+ * objects as the source operand. The ACPI spec does not
+ * allow this, however.
+ */
+ break;
+ }
+
+ if (TargetOp == AML_DEBUG_OP)
+ {
+ /* Allow store of any object to the Debug object */
+
+ break;
+ }
+
+ ACPI_ERROR ((AE_INFO,
+ "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ default:
+
+ /* Unknown type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Internal - Unknown ARGI (required operand) type 0x%X",
+ ThisArgType));
+
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Make sure that the original object was resolved to the
+ * required object type (Simple cases only).
+ */
+ Status = AcpiExCheckObjectType (TypeNeeded,
+ (*StackPtr)->Common.Type, *StackPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+NextOperand:
+ /*
+ * If more operands needed, decrement StackPtr to point
+ * to next operand on stack
+ */
+ if (GET_CURRENT_ARG_TYPE (ArgTypes))
+ {
+ StackPtr--;
+ }
+ }
+
+ ACPI_DUMP_OPERANDS (WalkState->Operands,
+ AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exstore.c b/source/components/executer/exstore.c
new file mode 100644
index 000000000000..656b64947862
--- /dev/null
+++ b/source/components/executer/exstore.c
@@ -0,0 +1,531 @@
+/******************************************************************************
+ *
+ * Module Name: exstore - AML Interpreter object store support
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXSTORE_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exstore")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExStoreObjectToIndex (
+ ACPI_OPERAND_OBJECT *ValDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_WALK_STATE *WalkState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStore
+ *
+ * PARAMETERS: *SourceDesc - Value to be stored
+ * *DestDesc - Where to store it. Must be an NS node
+ * or an ACPI_OPERAND_OBJECT of type
+ * Reference;
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the value described by SourceDesc into the location
+ * described by DestDesc. Called by various interpreter
+ * functions to store the result of an operation into
+ * the destination operand -- not just simply the actual "Store"
+ * ASL operator.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStore (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
+
+
+ /* Validate parameters */
+
+ if (!SourceDesc || !DestDesc)
+ {
+ ACPI_ERROR ((AE_INFO, "Null parameter"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /* DestDesc can be either a namespace node or an ACPI object */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ /*
+ * Dest is a namespace node,
+ * Storing an object into a Named node.
+ */
+ Status = AcpiExStoreObjectToNode (SourceDesc,
+ (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
+ ACPI_IMPLICIT_CONVERSION);
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Destination object must be a Reference or a Constant object */
+
+ switch (DestDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ /* Allow stores to Constants -- a Noop as per ACPI spec */
+
+ if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*lint -fallthrough */
+
+ default:
+
+ /* Destination is not a Reference object */
+
+ ACPI_ERROR ((AE_INFO,
+ "Target is not a Reference or Constant object - %s [%p]",
+ AcpiUtGetObjectTypeName (DestDesc), DestDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Examine the Reference class. These cases are handled:
+ *
+ * 1) Store to Name (Change the object associated with a name)
+ * 2) Store to an indexed area of a Buffer or Package
+ * 3) Store to a Method Local or Arg
+ * 4) Store to the debug object
+ */
+ switch (RefDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_REFOF:
+
+ /* Storing an object into a Name "container" */
+
+ Status = AcpiExStoreObjectToNode (SourceDesc,
+ RefDesc->Reference.Object,
+ WalkState, ACPI_IMPLICIT_CONVERSION);
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ /* Storing to an Index (pointer into a packager or buffer) */
+
+ Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
+ break;
+
+
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ /* Store to a method local/arg */
+
+ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class,
+ RefDesc->Reference.Value, SourceDesc, WalkState);
+ break;
+
+
+ case ACPI_REFCLASS_DEBUG:
+
+ /*
+ * Storing to the Debug object causes the value stored to be
+ * displayed and otherwise has no effect -- see ACPI Specification
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "**** Write to Debug Object: Object %p %s ****:\n\n",
+ SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
+
+ ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
+ RefDesc->Reference.Class));
+ ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
+
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreObjectToIndex
+ *
+ * PARAMETERS: *SourceDesc - Value to be stored
+ * *DestDesc - Named object to receive the value
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the object to indexed Buffer or Package element
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExStoreObjectToIndex (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *IndexDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *NewDesc;
+ UINT8 Value = 0;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
+
+
+ /*
+ * Destination must be a reference pointer, and
+ * must point to either a buffer or a package
+ */
+ switch (IndexDesc->Reference.TargetType)
+ {
+ case ACPI_TYPE_PACKAGE:
+ /*
+ * Storing to a package element. Copy the object and replace
+ * any existing object with the new object. No implicit
+ * conversion is performed.
+ *
+ * The object at *(IndexDesc->Reference.Where) is the
+ * element within the package that is to be modified.
+ * The parent package object is at IndexDesc->Reference.Object
+ */
+ ObjDesc = *(IndexDesc->Reference.Where);
+
+ if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
+ SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
+ {
+ /* This is a DDBHandle, just add a reference to it */
+
+ AcpiUtAddReference (SourceDesc);
+ NewDesc = SourceDesc;
+ }
+ else
+ {
+ /* Normal object, copy it */
+
+ Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (ObjDesc)
+ {
+ /* Decrement reference count by the ref count of the parent package */
+
+ for (i = 0;
+ i < ((ACPI_OPERAND_OBJECT *)
+ IndexDesc->Reference.Object)->Common.ReferenceCount;
+ i++)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ }
+
+ *(IndexDesc->Reference.Where) = NewDesc;
+
+ /* Increment ref count by the ref count of the parent package-1 */
+
+ for (i = 1;
+ i < ((ACPI_OPERAND_OBJECT *)
+ IndexDesc->Reference.Object)->Common.ReferenceCount;
+ i++)
+ {
+ AcpiUtAddReference (NewDesc);
+ }
+
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /*
+ * Store into a Buffer or String (not actually a real BufferField)
+ * at a location defined by an Index.
+ *
+ * The first 8-bit element of the source object is written to the
+ * 8-bit Buffer location defined by the Index destination object,
+ * according to the ACPI 2.0 specification.
+ */
+
+ /*
+ * Make sure the target is a Buffer or String. An error should
+ * not happen here, since the ReferenceObject was constructed
+ * by the INDEX_OP code.
+ */
+ ObjDesc = IndexDesc->Reference.Object;
+ if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (ObjDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * The assignment of the individual elements will be slightly
+ * different for each source type.
+ */
+ switch (SourceDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Use the least-significant byte of the integer */
+
+ Value = (UINT8) (SourceDesc->Integer.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_STRING:
+
+ /* Note: Takes advantage of common string/buffer fields */
+
+ Value = SourceDesc->Buffer.Pointer[0];
+ break;
+
+ default:
+
+ /* All other types are invalid */
+
+ ACPI_ERROR ((AE_INFO,
+ "Source must be Integer/Buffer/String type, not %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Store the source value into the target buffer byte */
+
+ ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Target is not a Package or BufferField"));
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreObjectToNode
+ *
+ * PARAMETERS: SourceDesc - Value to be stored
+ * Node - Named object to receive the value
+ * WalkState - Current walk state
+ * ImplicitConversion - Perform implicit conversion (yes/no)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the object to the named object.
+ *
+ * The Assignment of an object to a named object is handled here
+ * The value 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.
+ *
+ * Assumes parameters are already validated.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreObjectToNode (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_WALK_STATE *WalkState,
+ UINT8 ImplicitConversion)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *TargetDesc;
+ ACPI_OPERAND_OBJECT *NewDesc;
+ ACPI_OBJECT_TYPE TargetType;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
+
+
+ /* Get current type of the node, and object attached to Node */
+
+ TargetType = AcpiNsGetType (Node);
+ TargetDesc = AcpiNsGetAttachedObject (Node);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
+ SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
+ Node, AcpiUtGetTypeName (TargetType)));
+
+ /*
+ * Resolve the source object to an actual value
+ * (If it is a reference object)
+ */
+ Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* If no implicit conversion, drop into the default case below */
+
+ if ((!ImplicitConversion) ||
+ ((WalkState->Opcode == AML_COPY_OP) &&
+ (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) &&
+ (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) &&
+ (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD)))
+ {
+ /*
+ * Force execution of default (no implicit conversion). Note:
+ * CopyObject does not perform an implicit conversion, as per the ACPI
+ * spec -- except in case of region/bank/index fields -- because these
+ * objects must retain their original type permanently.
+ */
+ TargetType = ACPI_TYPE_ANY;
+ }
+
+ /* Do the actual store operation */
+
+ switch (TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ /* For fields, copy the source data to the target field. */
+
+ Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
+ &WalkState->ResultObj);
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * These target types are all of type Integer/String/Buffer, and
+ * therefore support implicit conversion before the store.
+ *
+ * Copy and/or convert the source object to a new target object
+ */
+ Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
+ &NewDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (NewDesc != TargetDesc)
+ {
+ /*
+ * Store the new NewDesc as the new value of the Name, and set
+ * the Name's type to that of the value being stored in it.
+ * SourceDesc reference count is incremented by AttachObject.
+ *
+ * Note: This may change the type of the node if an explicit store
+ * has been performed such that the node/object type has been
+ * changed.
+ */
+ Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Store %s into %s via Convert/Attach\n",
+ AcpiUtGetObjectTypeName (SourceDesc),
+ AcpiUtGetObjectTypeName (NewDesc)));
+ }
+ break;
+
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
+ AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node));
+
+ /* No conversions for all other types. Just attach the source object */
+
+ Status = AcpiNsAttachObject (Node, SourceDesc,
+ SourceDesc->Common.Type);
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exstoren.c b/source/components/executer/exstoren.c
new file mode 100644
index 000000000000..464d6b106504
--- /dev/null
+++ b/source/components/executer/exstoren.c
@@ -0,0 +1,314 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstoren - AML Interpreter object store support,
+ * Store to Node (namespace object)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXSTOREN_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exstoren")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveObject
+ *
+ * PARAMETERS: SourceDescPtr - Pointer to the source object
+ * TargetType - Current type of the target
+ * WalkState - Current walk state
+ *
+ * RETURN: Status, resolved object in SourceDescPtr.
+ *
+ * DESCRIPTION: Resolve an object. If the object is a reference, dereference
+ * it and return the actual object in the SourceDescPtr.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveObject (
+ ACPI_OPERAND_OBJECT **SourceDescPtr,
+ ACPI_OBJECT_TYPE TargetType,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExResolveObject);
+
+
+ /* Ensure we have a Target that can be stored to */
+
+ switch (TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ /*
+ * These cases all require only Integers or values that
+ * can be converted to Integers (Strings or Buffers)
+ */
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * Stores into a Field/Region or into a Integer/Buffer/String
+ * are all essentially the same. This case handles the
+ * "interchangeable" types Integer, String, and Buffer.
+ */
+ if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ /* Resolve a reference object first */
+
+ Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+ }
+
+ /* For CopyObject, no further validation necessary */
+
+ if (WalkState->Opcode == AML_COPY_OP)
+ {
+ break;
+ }
+
+ /* Must have a Integer, Buffer, or String */
+
+ if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
+ (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (SourceDesc->Common.Type != ACPI_TYPE_STRING) &&
+ !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+ (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
+ {
+ /* Conversion successful but still not a valid type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Cannot assign type %s to %s (must be type Int/Str/Buf)",
+ AcpiUtGetObjectTypeName (SourceDesc),
+ AcpiUtGetTypeName (TargetType)));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_ALIAS:
+ case ACPI_TYPE_LOCAL_METHOD_ALIAS:
+
+ /*
+ * All aliases should have been resolved earlier, during the
+ * operand resolution phase.
+ */
+ ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
+ Status = AE_AML_INTERNAL;
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+ default:
+
+ /*
+ * All other types than Alias and the various Fields come here,
+ * including the untyped case - ACPI_TYPE_ANY.
+ */
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreObjectToObject
+ *
+ * PARAMETERS: SourceDesc - Object to store
+ * DestDesc - Object to receive a copy of the source
+ * NewDesc - New object if DestDesc is obsoleted
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: "Store" an object to another object. This may include
+ * converting the source type to the target type (implicit
+ * conversion), and a copy of the value of the source to
+ * the target.
+ *
+ * The Assignment of an object to another (not named) object
+ * is handled here.
+ * The Source 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,
+ * Buffer, and Package.
+ *
+ * Assumes parameters are already validated. NOTE: SourceDesc
+ * resolution (from a reference object) must be performed by
+ * the caller if necessary.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreObjectToObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_OPERAND_OBJECT **NewDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ActualSrcDesc;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc);
+
+
+ ActualSrcDesc = SourceDesc;
+ if (!DestDesc)
+ {
+ /*
+ * There is no destination object (An uninitialized node or
+ * package element), so we can simply copy the source object
+ * creating a new destination object
+ */
+ Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState);
+ return_ACPI_STATUS (Status);
+ }
+
+ if (SourceDesc->Common.Type != DestDesc->Common.Type)
+ {
+ /*
+ * The source type does not match the type of the destination.
+ * Perform the "implicit conversion" of the source to the current type
+ * of the target as per the ACPI specification.
+ *
+ * If no conversion performed, ActualSrcDesc = SourceDesc.
+ * Otherwise, ActualSrcDesc is a temporary object to hold the
+ * converted object.
+ */
+ Status = AcpiExConvertToTargetType (DestDesc->Common.Type,
+ SourceDesc, &ActualSrcDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (SourceDesc == ActualSrcDesc)
+ {
+ /*
+ * No conversion was performed. Return the SourceDesc as the
+ * new object.
+ */
+ *NewDesc = SourceDesc;
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ /*
+ * We now have two objects of identical types, and we can perform a
+ * copy of the *value* of the source object.
+ */
+ switch (DestDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
+
+ /* Truncate value if we are executing from a 32-bit ACPI table */
+
+ AcpiExTruncateFor32bitTable (DestDesc);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
+ WalkState);
+ break;
+
+ default:
+ /*
+ * All other types come here.
+ */
+ ACPI_WARNING ((AE_INFO, "Store into type %s not implemented",
+ AcpiUtGetObjectTypeName (DestDesc)));
+
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+ }
+
+ if (ActualSrcDesc != SourceDesc)
+ {
+ /* Delete the intermediate (temporary) source object */
+
+ AcpiUtRemoveReference (ActualSrcDesc);
+ }
+
+ *NewDesc = DestDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/source/components/executer/exstorob.c b/source/components/executer/exstorob.c
new file mode 100644
index 000000000000..e74d5b3485fc
--- /dev/null
+++ b/source/components/executer/exstorob.c
@@ -0,0 +1,244 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstorob - AML Interpreter object store support, store to object
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXSTOROB_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exstorob")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreBufferToBuffer
+ *
+ * PARAMETERS: SourceDesc - Source object to copy
+ * TargetDesc - Destination object of the copy
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy a buffer object to another buffer object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreBufferToBuffer (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *TargetDesc)
+{
+ UINT32 Length;
+ UINT8 *Buffer;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc);
+
+
+ /* If Source and Target are the same, just return */
+
+ if (SourceDesc == TargetDesc)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* We know that SourceDesc is a buffer by now */
+
+ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer);
+ Length = SourceDesc->Buffer.Length;
+
+ /*
+ * If target is a buffer of length zero or is a static buffer,
+ * allocate a new buffer of the proper length
+ */
+ if ((TargetDesc->Buffer.Length == 0) ||
+ (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
+ {
+ TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length);
+ if (!TargetDesc->Buffer.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ TargetDesc->Buffer.Length = Length;
+ }
+
+ /* Copy source buffer to target buffer */
+
+ if (Length <= TargetDesc->Buffer.Length)
+ {
+ /* Clear existing buffer and copy in the new one */
+
+ ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
+ ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length);
+
+#ifdef ACPI_OBSOLETE_BEHAVIOR
+ /*
+ * NOTE: ACPI versions up to 3.0 specified that the buffer must be
+ * truncated if the string is smaller than the buffer. However, "other"
+ * implementations of ACPI never did this and thus became the defacto
+ * standard. ACPI 3.0A changes this behavior such that the buffer
+ * is no longer truncated.
+ */
+
+ /*
+ * OBSOLETE BEHAVIOR:
+ * If the original source was a string, we must truncate the buffer,
+ * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
+ * copy must not truncate the original buffer.
+ */
+ if (OriginalSrcType == ACPI_TYPE_STRING)
+ {
+ /* Set the new length of the target */
+
+ TargetDesc->Buffer.Length = Length;
+ }
+#endif
+ }
+ else
+ {
+ /* Truncate the source, copy only what will fit */
+
+ ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer,
+ TargetDesc->Buffer.Length);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Truncating source buffer from %X to %X\n",
+ Length, TargetDesc->Buffer.Length));
+ }
+
+ /* Copy flags */
+
+ TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags;
+ TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreStringToString
+ *
+ * PARAMETERS: SourceDesc - Source object to copy
+ * TargetDesc - Destination object of the copy
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy a String object to another String object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreStringToString (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *TargetDesc)
+{
+ UINT32 Length;
+ UINT8 *Buffer;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc);
+
+
+ /* If Source and Target are the same, just return */
+
+ if (SourceDesc == TargetDesc)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* We know that SourceDesc is a string by now */
+
+ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer);
+ Length = SourceDesc->String.Length;
+
+ /*
+ * Replace existing string value if it will fit and the string
+ * pointer is not a static pointer (part of an ACPI table)
+ */
+ if ((Length < TargetDesc->String.Length) &&
+ (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ /*
+ * String will fit in existing non-static buffer.
+ * Clear old string and copy in the new one
+ */
+ ACPI_MEMSET (TargetDesc->String.Pointer, 0,
+ (ACPI_SIZE) TargetDesc->String.Length + 1);
+ ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ }
+ else
+ {
+ /*
+ * Free the current buffer, then allocate a new buffer
+ * large enough to hold the value
+ */
+ if (TargetDesc->String.Pointer &&
+ (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ /* Only free if not a pointer into the DSDT */
+
+ ACPI_FREE (TargetDesc->String.Pointer);
+ }
+
+ TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED (
+ (ACPI_SIZE) Length + 1);
+ if (!TargetDesc->String.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+ ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ }
+
+ /* Set the new target length */
+
+ TargetDesc->String.Length = Length;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/source/components/executer/exsystem.c b/source/components/executer/exsystem.c
new file mode 100644
index 000000000000..37f5b234a373
--- /dev/null
+++ b/source/components/executer/exsystem.c
@@ -0,0 +1,355 @@
+
+/******************************************************************************
+ *
+ * Module Name: exsystem - Interface to OS services
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXSYSTEM_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exsystem")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitSemaphore
+ *
+ * PARAMETERS: Semaphore - 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 before waiting.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitSemaphore (
+ ACPI_SEMAPHORE Semaphore,
+ UINT16 Timeout)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore);
+
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Status == AE_TIME)
+ {
+ /* We must wait, so unlock the interpreter */
+
+ AcpiExRelinquishInterpreter ();
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "*** Thread awake after blocking, %s\n",
+ AcpiFormatException (Status)));
+
+ /* Reacquire the interpreter */
+
+ AcpiExReacquireInterpreter ();
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitMutex
+ *
+ * PARAMETERS: Mutex - Mutex to wait on
+ * Timeout - Max time to wait
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements a mutex wait with a check to see if the
+ * mutex is available immediately. If it is not, the
+ * interpreter is released before waiting.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitMutex (
+ ACPI_MUTEX Mutex,
+ UINT16 Timeout)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemWaitMutex);
+
+
+ Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Status == AE_TIME)
+ {
+ /* We must wait, so unlock the interpreter */
+
+ AcpiExRelinquishInterpreter ();
+
+ Status = AcpiOsAcquireMutex (Mutex, Timeout);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "*** Thread awake after blocking, %s\n",
+ AcpiFormatException (Status)));
+
+ /* Reacquire the interpreter */
+
+ AcpiExReacquireInterpreter ();
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemDoStall
+ *
+ * PARAMETERS: HowLong - The amount of time to stall,
+ * in microseconds
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Suspend running thread for specified amount of time.
+ * Note: ACPI specification requires that Stall() does not
+ * relinquish the processor, and delays longer than 100 usec
+ * should use Sleep() instead. We allow stalls up to 255 usec
+ * for compatibility with other interpreters and existing BIOSs.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemDoStall (
+ UINT32 HowLong)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (HowLong > 255) /* 255 microseconds */
+ {
+ /*
+ * Longer than 255 usec, this is an error
+ *
+ * (ACPI specifies 100 usec as max, but this gives some slack in
+ * order to support existing BIOSs)
+ */
+ ACPI_ERROR ((AE_INFO, "Time parameter is too large (%u)",
+ HowLong));
+ Status = AE_AML_OPERAND_VALUE;
+ }
+ else
+ {
+ AcpiOsStall (HowLong);
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemDoSleep
+ *
+ * PARAMETERS: HowLong - The amount of time to sleep,
+ * in milliseconds
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Sleep the running thread for specified amount of time.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemDoSleep (
+ UINT64 HowLong)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Since this thread will sleep, we must release the interpreter */
+
+ AcpiExRelinquishInterpreter ();
+
+ /*
+ * For compatibility with other ACPI implementations and to prevent
+ * accidental deep sleeps, limit the sleep time to something reasonable.
+ */
+ if (HowLong > ACPI_MAX_SLEEP)
+ {
+ HowLong = ACPI_MAX_SLEEP;
+ }
+
+ AcpiOsSleep (HowLong);
+
+ /* And now we must get the interpreter again */
+
+ AcpiExReacquireInterpreter ();
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemSignalEvent
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemSignalEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemSignalEvent);
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitEvent
+ *
+ * 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
+AcpiExSystemWaitEvent (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemWaitEvent);
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore,
+ (UINT16) TimeDesc->Integer.Value);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemResetEvent
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reset an event to a known state.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemResetEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_SEMAPHORE TempSemaphore;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * 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))
+ {
+ (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore);
+ ObjDesc->Event.OsSemaphore = TempSemaphore;
+ }
+
+ return (Status);
+}
+
diff --git a/source/components/executer/exutils.c b/source/components/executer/exutils.c
new file mode 100644
index 000000000000..b5eca064a20b
--- /dev/null
+++ b/source/components/executer/exutils.c
@@ -0,0 +1,532 @@
+
+/******************************************************************************
+ *
+ * Module Name: exutils - interpreter/scanner utilities
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXUTILS_C__
+
+/*
+ * 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 "acpi.h"
+#include "accommon.h"
+#include "acinterp.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exutils")
+
+/* Local prototypes */
+
+static UINT32
+AcpiExDigitsNeeded (
+ UINT64 Value,
+ UINT32 Base);
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExEnterInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Enter the interpreter execution region. Failure to enter
+ * the interpreter region is a fatal system error. Used in
+ * conjunction with ExitInterpreter.
+ *
+ ******************************************************************************/
+
+void
+AcpiExEnterInterpreter (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExEnterInterpreter);
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReacquireInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Reacquire the interpreter execution region from within the
+ * interpreter code. Failure to enter the interpreter region is a
+ * fatal system error. Used in conjuction with
+ * RelinquishInterpreter
+ *
+ ******************************************************************************/
+
+void
+AcpiExReacquireInterpreter (
+ void)
+{
+ ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
+
+
+ /*
+ * If the global serialized flag is set, do not release the interpreter,
+ * since it was not actually released by AcpiExRelinquishInterpreter.
+ * This forces the interpreter to be single threaded.
+ */
+ if (!AcpiGbl_AllMethodsSerialized)
+ {
+ AcpiExEnterInterpreter ();
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExExitInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Exit the interpreter execution region. This is the top level
+ * routine used to exit the interpreter when all processing has
+ * been completed.
+ *
+ ******************************************************************************/
+
+void
+AcpiExExitInterpreter (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExExitInterpreter);
+
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRelinquishInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Exit the interpreter execution region, from within the
+ * interpreter - before attempting an operation that will possibly
+ * block the running thread.
+ *
+ * Cases where the interpreter is unlocked internally
+ * 1) Method to be blocked on a Sleep() AML opcode
+ * 2) Method to be blocked on an Acquire() AML opcode
+ * 3) Method to be blocked on a Wait() AML opcode
+ * 4) Method to be blocked to acquire the global lock
+ * 5) Method to be blocked waiting to execute a serialized control method
+ * that is currently executing
+ * 6) About to invoke a user-installed opregion handler
+ *
+ ******************************************************************************/
+
+void
+AcpiExRelinquishInterpreter (
+ void)
+{
+ ACPI_FUNCTION_TRACE (ExRelinquishInterpreter);
+
+
+ /*
+ * If the global serialized flag is set, do not release the interpreter.
+ * This forces the interpreter to be single threaded.
+ */
+ if (!AcpiGbl_AllMethodsSerialized)
+ {
+ AcpiExExitInterpreter ();
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExTruncateFor32bitTable
+ *
+ * PARAMETERS: ObjDesc - Object to be truncated
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
+ * 32-bit, as determined by the revision of the DSDT.
+ *
+ ******************************************************************************/
+
+void
+AcpiExTruncateFor32bitTable (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Object must be a valid number and we must be executing
+ * a control method. NS node could be there for AML_INT_NAMEPATH_OP.
+ */
+ if ((!ObjDesc) ||
+ (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
+ (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
+ {
+ return;
+ }
+
+ if (AcpiGbl_IntegerByteWidth == 4)
+ {
+ /*
+ * We are running a method that exists in a 32-bit ACPI table.
+ * Truncate the value to 32 bits by zeroing out the upper 32-bit field
+ */
+ ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAcquireGlobalLock
+ *
+ * PARAMETERS: FieldFlags - Flags with Lock rule:
+ * AlwaysLock or NeverLock
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
+ * flags specifiy that it is to be obtained before field access.
+ *
+ ******************************************************************************/
+
+void
+AcpiExAcquireGlobalLock (
+ UINT32 FieldFlags)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExAcquireGlobalLock);
+
+
+ /* Only use the lock if the AlwaysLock bit is set */
+
+ if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
+ {
+ return_VOID;
+ }
+
+ /* Attempt to get the global lock, wait forever */
+
+ Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER,
+ AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not acquire Global Lock"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseGlobalLock
+ *
+ * PARAMETERS: FieldFlags - Flags with Lock rule:
+ * AlwaysLock or NeverLock
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Release the ACPI hardware Global Lock
+ *
+ ******************************************************************************/
+
+void
+AcpiExReleaseGlobalLock (
+ UINT32 FieldFlags)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExReleaseGlobalLock);
+
+
+ /* Only use the lock if the AlwaysLock bit is set */
+
+ if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
+ {
+ return_VOID;
+ }
+
+ /* Release the global lock */
+
+ Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Report the error, but there isn't much else we can do */
+
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not release Global Lock"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDigitsNeeded
+ *
+ * PARAMETERS: Value - Value to be represented
+ * Base - Base of representation
+ *
+ * RETURN: The number of digits.
+ *
+ * DESCRIPTION: Calculate the number of digits needed to represent the Value
+ * in the given Base (Radix)
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExDigitsNeeded (
+ UINT64 Value,
+ UINT32 Base)
+{
+ UINT32 NumDigits;
+ UINT64 CurrentValue;
+
+
+ ACPI_FUNCTION_TRACE (ExDigitsNeeded);
+
+
+ /* UINT64 is unsigned, so we don't worry about a '-' prefix */
+
+ if (Value == 0)
+ {
+ return_UINT32 (1);
+ }
+
+ CurrentValue = Value;
+ NumDigits = 0;
+
+ /* Count the digits in the requested base */
+
+ while (CurrentValue)
+ {
+ (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL);
+ NumDigits++;
+ }
+
+ return_UINT32 (NumDigits);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExEisaIdToString
+ *
+ * PARAMETERS: CompressedId - EISAID to be converted
+ * OutString - Where to put the converted string (8 bytes)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Convert a numeric EISAID to string representation. Return
+ * buffer must be large enough to hold the string. The string
+ * returned is always exactly of length ACPI_EISAID_STRING_SIZE
+ * (includes null terminator). The EISAID is always 32 bits.
+ *
+ ******************************************************************************/
+
+void
+AcpiExEisaIdToString (
+ char *OutString,
+ UINT64 CompressedId)
+{
+ UINT32 SwappedId;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* The EISAID should be a 32-bit integer */
+
+ if (CompressedId > ACPI_UINT32_MAX)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating",
+ ACPI_FORMAT_UINT64 (CompressedId)));
+ }
+
+ /* Swap ID to big-endian to get contiguous bits */
+
+ SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId);
+
+ /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
+
+ OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F));
+ OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F));
+ OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F));
+ OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12);
+ OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8);
+ OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4);
+ OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0);
+ OutString[7] = 0;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExIntegerToString
+ *
+ * PARAMETERS: OutString - Where to put the converted string. At least
+ * 21 bytes are needed to hold the largest
+ * possible 64-bit integer.
+ * Value - Value to be converted
+ *
+ * RETURN: None, string
+ *
+ * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
+ * Assumes string buffer is large enough to hold the string. The
+ * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
+ *
+ ******************************************************************************/
+
+void
+AcpiExIntegerToString (
+ char *OutString,
+ UINT64 Value)
+{
+ UINT32 Count;
+ UINT32 DigitsNeeded;
+ UINT32 Remainder;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
+ OutString[DigitsNeeded] = 0;
+
+ for (Count = DigitsNeeded; Count > 0; Count--)
+ {
+ (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
+ OutString[Count-1] = (char) ('0' + Remainder);\
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiIsValidSpaceId
+ *
+ * PARAMETERS: SpaceId - ID to be validated
+ *
+ * RETURN: TRUE if valid/supported ID.
+ *
+ * DESCRIPTION: Validate an operation region SpaceID.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiIsValidSpaceId (
+ UINT8 SpaceId)
+{
+
+ if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) &&
+ (SpaceId < ACPI_USER_REGION_BEGIN) &&
+ (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) &&
+ (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE))
+ {
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+
+#endif