summaryrefslogtreecommitdiff
path: root/source/components
diff options
context:
space:
mode:
Diffstat (limited to 'source/components')
-rw-r--r--source/components/debugger/dbdisply.c28
-rw-r--r--source/components/debugger/dbinput.c2
-rw-r--r--source/components/disassembler/dmopcode.c124
-rw-r--r--source/components/disassembler/dmwalk.c49
-rw-r--r--source/components/dispatcher/dsinit.c2
-rw-r--r--source/components/events/evhandler.c168
-rw-r--r--source/components/events/evregion.c124
-rw-r--r--source/components/events/evrgnini.c101
-rw-r--r--source/components/events/evxfregn.c40
-rw-r--r--source/components/executer/excreate.c7
-rw-r--r--source/components/executer/exdebug.c76
-rw-r--r--source/components/executer/exdump.c6
-rw-r--r--source/components/executer/exmisc.c45
-rw-r--r--source/components/executer/exoparg1.c2
-rw-r--r--source/components/namespace/nsconvert.c86
-rw-r--r--source/components/namespace/nseval.c66
-rw-r--r--source/components/namespace/nsload.c18
-rw-r--r--source/components/namespace/nsrepair.c11
-rw-r--r--source/components/parser/psargs.c19
-rw-r--r--source/components/parser/psloop.c4
-rw-r--r--source/components/parser/psopcode.c2
-rw-r--r--source/components/tables/tbutils.c9
-rw-r--r--source/components/utilities/utinit.c1
-rw-r--r--source/components/utilities/utstring.c9
-rw-r--r--source/components/utilities/utxfinit.c75
25 files changed, 707 insertions, 367 deletions
diff --git a/source/components/debugger/dbdisply.c b/source/components/debugger/dbdisply.c
index 09d1232a74ea3..75a29b526717b 100644
--- a/source/components/debugger/dbdisply.c
+++ b/source/components/debugger/dbdisply.c
@@ -48,6 +48,7 @@
#include "acnamesp.h"
#include "acparser.h"
#include "acinterp.h"
+#include "acevents.h"
#include "acdebug.h"
@@ -1034,26 +1035,21 @@ AcpiDbDisplayHandlers (
for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
{
SpaceId = AcpiGbl_SpaceIdList[i];
- HandlerObj = ObjDesc->Device.Handler;
AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
- while (HandlerObj)
+ HandlerObj = AcpiEvFindRegionHandler (
+ SpaceId, ObjDesc->CommonNotify.Handler);
+ if (HandlerObj)
{
- if (AcpiGbl_SpaceIdList[i] ==
- HandlerObj->AddressSpace.SpaceId)
- {
- AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
- (HandlerObj->AddressSpace.HandlerFlags &
- ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
- "Default" : "User",
- HandlerObj->AddressSpace.Handler);
-
- goto FoundHandler;
- }
+ AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
+ (HandlerObj->AddressSpace.HandlerFlags &
+ ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
+ "Default" : "User",
+ HandlerObj->AddressSpace.Handler);
- HandlerObj = HandlerObj->AddressSpace.Next;
+ goto FoundHandler;
}
/* There is no handler for this SpaceId */
@@ -1065,7 +1061,7 @@ AcpiDbDisplayHandlers (
/* Find all handlers for user-defined SpaceIDs */
- HandlerObj = ObjDesc->Device.Handler;
+ HandlerObj = ObjDesc->CommonNotify.Handler;
while (HandlerObj)
{
if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
@@ -1176,7 +1172,7 @@ AcpiDbDisplayNonRootHandlers (
/* Display all handlers associated with this device */
- HandlerObj = ObjDesc->Device.Handler;
+ HandlerObj = ObjDesc->CommonNotify.Handler;
while (HandlerObj)
{
AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c
index 68043cbed6f8b..96d4fb77c8b88 100644
--- a/source/components/debugger/dbinput.c
+++ b/source/components/debugger/dbinput.c
@@ -1122,7 +1122,7 @@ AcpiDbCommandDispatch (
{
ACPI_NEW_TABLE_DESC *ListHead = NULL;
- Status = AcpiAcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
+ Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
ACPI_GET_ALL_TABLES, &ListHead);
if (ACPI_SUCCESS (Status))
{
diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c
index 02c51bdefa41b..4615ebe869150 100644
--- a/source/components/disassembler/dmopcode.c
+++ b/source/components/disassembler/dmopcode.c
@@ -60,6 +60,10 @@ static void
AcpiDmMatchKeyword (
ACPI_PARSE_OBJECT *Op);
+static void
+AcpiDmConvertToElseIf (
+ ACPI_PARSE_OBJECT *Op);
+
/*******************************************************************************
*
@@ -683,6 +687,11 @@ AcpiDmDisassembleOneOp (
return;
}
+ if (Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)
+ {
+ return; /* ElseIf macro was already emitted */
+ }
+
switch (Op->Common.DisasmOpcode)
{
case ACPI_DASM_MATCHOP:
@@ -955,6 +964,11 @@ AcpiDmDisassembleOneOp (
AcpiDmNamestring (Op->Common.Value.Name);
break;
+ case AML_ELSE_OP:
+
+ AcpiDmConvertToElseIf (Op);
+ break;
+
default:
/* Just get the opcode name and print it */
@@ -979,3 +993,113 @@ AcpiDmDisassembleOneOp (
break;
}
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmConvertToElseIf
+ *
+ * PARAMETERS: OriginalElseOp - ELSE Object to be examined
+ *
+ * RETURN: None. Emits either an "Else" or an "ElseIf" ASL operator.
+ *
+ * DESCRIPTION: Detect and convert an If..Else..If sequence to If..ElseIf
+ *
+ * EXAMPLE:
+ *
+ * This If..Else..If nested sequence:
+ *
+ * If (Arg0 == 1)
+ * {
+ * Local0 = 4
+ * }
+ * Else
+ * {
+ * If (Arg0 == 2)
+ * {
+ * Local0 = 5
+ * }
+ * }
+ *
+ * Is converted to this simpler If..ElseIf sequence:
+ *
+ * If (Arg0 == 1)
+ * {
+ * Local0 = 4
+ * }
+ * ElseIf (Arg0 == 2)
+ * {
+ * Local0 = 5
+ * }
+ *
+ * NOTE: There is no actual ElseIf AML opcode. ElseIf is essentially an ASL
+ * macro that emits an Else opcode followed by an If opcode. This function
+ * reverses these AML sequences back to an ElseIf macro where possible. This
+ * can make the disassembled ASL code simpler and more like the original code.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmConvertToElseIf (
+ ACPI_PARSE_OBJECT *OriginalElseOp)
+{
+ ACPI_PARSE_OBJECT *IfOp;
+ ACPI_PARSE_OBJECT *ElseOp;
+
+
+ /* Examine the first child of the Else */
+
+ IfOp = OriginalElseOp->Common.Value.Arg;
+ if (!IfOp || (IfOp->Common.AmlOpcode != AML_IF_OP))
+ {
+ /* Not an Else..If sequence, cannot convert to ElseIf */
+
+ AcpiOsPrintf ("%s", "Else");
+ return;
+ }
+
+ /* Emit ElseIf, mark the IF as now an ELSEIF */
+
+ AcpiOsPrintf ("%s", "ElseIf");
+ IfOp->Common.DisasmFlags |= ACPI_PARSEOP_ELSEIF;
+
+ /* The IF parent will now be the same as the original ELSE parent */
+
+ IfOp->Common.Parent = OriginalElseOp->Common.Parent;
+
+ /*
+ * Update the NEXT pointers to restructure the parse tree, essentially
+ * promoting an If..Else block up to the same level as the original
+ * Else.
+ *
+ * Check if the IF has a corresponding ELSE peer
+ */
+ ElseOp = IfOp->Common.Next;
+ if (ElseOp &&
+ (ElseOp->Common.AmlOpcode == AML_ELSE_OP))
+ {
+ /* If an ELSE matches the IF, promote it also */
+
+ ElseOp->Common.Parent = OriginalElseOp->Common.Parent;
+ ElseOp->Common.Next = OriginalElseOp->Common.Next;
+ }
+ else
+ {
+ /* Otherwise, set the IF NEXT to the original ELSE NEXT */
+
+ IfOp->Common.Next = OriginalElseOp->Common.Next;
+ }
+
+ /* Detach the child IF block from the original ELSE */
+
+ OriginalElseOp->Common.Value.Arg = NULL;
+
+ /* Ignore the original ELSE from now on */
+
+ OriginalElseOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ OriginalElseOp->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
+
+ /* Insert IF (now ELSEIF) as next peer of the original ELSE */
+
+ OriginalElseOp->Common.Next = IfOp;
+}
diff --git a/source/components/disassembler/dmwalk.c b/source/components/disassembler/dmwalk.c
index 4a094789a7038..664e709d69aaa 100644
--- a/source/components/disassembler/dmwalk.c
+++ b/source/components/disassembler/dmwalk.c
@@ -488,39 +488,40 @@ AcpiDmDescendingOp (
}
else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
(!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
+ (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) &&
(Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
{
+ /*
+ * This is a first-level element of a term list,
+ * indent a new line
+ */
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_NOOP_OP:
/*
- * This is a first-level element of a term list,
- * indent a new line
+ * Optionally just ignore this opcode. Some tables use
+ * NoOp opcodes for "padding" out packages that the BIOS
+ * changes dynamically. This can leave hundreds or
+ * thousands of NoOp opcodes that if disassembled,
+ * cannot be compiled because they are syntactically
+ * incorrect.
*/
- switch (Op->Common.AmlOpcode)
+ if (AcpiGbl_IgnoreNoopOperator)
{
- case AML_NOOP_OP:
- /*
- * Optionally just ignore this opcode. Some tables use
- * NoOp opcodes for "padding" out packages that the BIOS
- * changes dynamically. This can leave hundreds or
- * thousands of NoOp opcodes that if disassembled,
- * cannot be compiled because they are syntactically
- * incorrect.
- */
- if (AcpiGbl_IgnoreNoopOperator)
- {
- Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
- return (AE_OK);
- }
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ return (AE_OK);
+ }
- /* Fallthrough */
+ /* Fallthrough */
- default:
+ default:
- AcpiDmIndent (Level);
- break;
- }
+ AcpiDmIndent (Level);
+ break;
+ }
- Info->LastLevel = Level;
- Info->Count = 0;
+ Info->LastLevel = Level;
+ Info->Count = 0;
}
/*
diff --git a/source/components/dispatcher/dsinit.c b/source/components/dispatcher/dsinit.c
index 573d0ddf0745b..10580a3c6fa61 100644
--- a/source/components/dispatcher/dsinit.c
+++ b/source/components/dispatcher/dsinit.c
@@ -266,7 +266,7 @@ AcpiDsInitializeObjects (
/* Summary of objects initialized */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
- "Table [%4.4s:%8.8s] (id %.2X) - %4u Objects with %3u Devices, "
+ "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, "
"%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n",
Table->Signature, Table->OemTableId, OwnerId, Info.ObjectCount,
Info.DeviceCount,Info.OpRegionCount, Info.MethodCount,
diff --git a/source/components/events/evhandler.c b/source/components/events/evhandler.c
index e2d5955a089c6..eca683f3921d1 100644
--- a/source/components/events/evhandler.c
+++ b/source/components/events/evhandler.c
@@ -60,6 +60,7 @@ AcpiEvInstallHandler (
void *Context,
void **ReturnValue);
+
/* These are the address spaces that will get default handlers */
UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] =
@@ -175,7 +176,7 @@ AcpiEvHasDefaultHandler (
ObjDesc = AcpiNsGetAttachedObject (Node);
if (ObjDesc)
{
- HandlerObj = ObjDesc->Device.Handler;
+ HandlerObj = ObjDesc->CommonNotify.Handler;
/* Walk the linked list of handlers for this object */
@@ -276,33 +277,25 @@ AcpiEvInstallHandler (
{
/* Check if this Device already has a handler for this address space */
- NextHandlerObj = ObjDesc->Device.Handler;
- while (NextHandlerObj)
+ NextHandlerObj = AcpiEvFindRegionHandler (
+ HandlerObj->AddressSpace.SpaceId, ObjDesc->CommonNotify.Handler);
+ if (NextHandlerObj)
{
/* Found a handler, is it for the same address space? */
- if (NextHandlerObj->AddressSpace.SpaceId ==
- HandlerObj->AddressSpace.SpaceId)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
- "Found handler for region [%s] in device %p(%p) "
- "handler %p\n",
- AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId),
- ObjDesc, NextHandlerObj, HandlerObj));
-
- /*
- * Since the object we found it on was a device, then it
- * means that someone has already installed a handler for
- * the branch of the namespace from this device on. Just
- * bail out telling the walk routine to not traverse this
- * branch. This preserves the scoping rule for handlers.
- */
- return (AE_CTRL_DEPTH);
- }
-
- /* Walk the linked list of handlers attached to this device */
-
- NextHandlerObj = NextHandlerObj->AddressSpace.Next;
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Found handler for region [%s] in device %p(%p) handler %p\n",
+ AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId),
+ ObjDesc, NextHandlerObj, HandlerObj));
+
+ /*
+ * Since the object we found it on was a device, then it means
+ * that someone has already installed a handler for the branch
+ * of the namespace from this device on. Just bail out telling
+ * the walk routine to not traverse this branch. This preserves
+ * the scoping rule for handlers.
+ */
+ return (AE_CTRL_DEPTH);
}
/*
@@ -337,6 +330,46 @@ AcpiEvInstallHandler (
/*******************************************************************************
*
+ * FUNCTION: AcpiEvFindRegionHandler
+ *
+ * PARAMETERS: SpaceId - The address space ID
+ * HandlerObj - Head of the handler object list
+ *
+ * RETURN: Matching handler object. NULL if space ID not matched
+ *
+ * DESCRIPTION: Search a handler object list for a match on the address
+ * space ID.
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiEvFindRegionHandler (
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_OPERAND_OBJECT *HandlerObj)
+{
+
+ /* Walk the handler list for this device */
+
+ while (HandlerObj)
+ {
+ /* Same SpaceId indicates a handler is installed */
+
+ if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+ {
+ return (HandlerObj);
+ }
+
+ /* Next handler object */
+
+ HandlerObj = HandlerObj->AddressSpace.Next;
+ }
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiEvInstallSpaceHandler
*
* PARAMETERS: Node - Namespace node for the device
@@ -362,17 +395,17 @@ AcpiEvInstallSpaceHandler (
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_OPERAND_OBJECT *HandlerObj;
- ACPI_STATUS Status;
+ ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_TYPE Type;
- UINT8 Flags = 0;
+ UINT8 Flags = 0;
ACPI_FUNCTION_TRACE (EvInstallSpaceHandler);
/*
- * This registration is valid for only the types below and the root. This
- * is where the default handlers get placed.
+ * This registration is valid for only the types below and the root.
+ * The root node is where the default handlers get installed.
*/
if ((Node->Type != ACPI_TYPE_DEVICE) &&
(Node->Type != ACPI_TYPE_PROCESSOR) &&
@@ -445,47 +478,39 @@ AcpiEvInstallSpaceHandler (
if (ObjDesc)
{
/*
- * The attached device object already exists. Make sure the handler
- * is not already installed.
+ * The attached device object already exists. Now make sure
+ * the handler is not already installed.
*/
- HandlerObj = ObjDesc->Device.Handler;
+ HandlerObj = AcpiEvFindRegionHandler (SpaceId,
+ ObjDesc->CommonNotify.Handler);
- /* Walk the handler list for this device */
-
- while (HandlerObj)
+ if (HandlerObj)
{
- /* Same SpaceId indicates a handler already installed */
-
- if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+ if (HandlerObj->AddressSpace.Handler == Handler)
{
- if (HandlerObj->AddressSpace.Handler == Handler)
- {
- /*
- * It is (relatively) OK to attempt to install the SAME
- * handler twice. This can easily happen with the
- * PCI_Config space.
- */
- Status = AE_SAME_HANDLER;
- goto UnlockAndExit;
- }
- else
- {
- /* A handler is already installed */
-
- Status = AE_ALREADY_EXISTS;
- }
+ /*
+ * It is (relatively) OK to attempt to install the SAME
+ * handler twice. This can easily happen with the
+ * PCI_Config space.
+ */
+ Status = AE_SAME_HANDLER;
goto UnlockAndExit;
}
+ else
+ {
+ /* A handler is already installed */
- /* Walk the linked list of handlers */
+ Status = AE_ALREADY_EXISTS;
+ }
- HandlerObj = HandlerObj->AddressSpace.Next;
+ goto UnlockAndExit;
}
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
- "Creating object on Device %p while installing handler\n", Node));
+ "Creating object on Device %p while installing handler\n",
+ Node));
/* ObjDesc does not exist, create one */
@@ -524,7 +549,8 @@ AcpiEvInstallSpaceHandler (
}
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
- "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
+ "Installing address handler for region %s(%X) "
+ "on Device %4.4s %p(%p)\n",
AcpiUtGetRegionName (SpaceId), SpaceId,
AcpiUtGetNodeName (Node), Node, ObjDesc));
@@ -549,33 +575,31 @@ AcpiEvInstallSpaceHandler (
HandlerObj->AddressSpace.Node = Node;
HandlerObj->AddressSpace.Handler = Handler;
HandlerObj->AddressSpace.Context = Context;
- HandlerObj->AddressSpace.Setup = Setup;
+ HandlerObj->AddressSpace.Setup = Setup;
/* Install at head of Device.AddressSpace list */
- HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler;
+ HandlerObj->AddressSpace.Next = ObjDesc->CommonNotify.Handler;
/*
* The Device object is the first reference on the HandlerObj.
* Each region that uses the handler adds a reference.
*/
- ObjDesc->Device.Handler = HandlerObj;
+ ObjDesc->CommonNotify.Handler = HandlerObj;
/*
- * Walk the namespace finding all of the regions this
- * handler will manage.
+ * Walk the namespace finding all of the regions this handler will
+ * manage.
*
- * Start at the device and search the branch toward
- * the leaf nodes until either the leaf is encountered or
- * a device is detected that has an address handler of the
- * same type.
+ * Start at the device and search the branch toward the leaf nodes
+ * until either the leaf is encountered or a device is detected that
+ * has an address handler of the same type.
*
- * In either case, back up and search down the remainder
- * of the branch
+ * In either case, back up and search down the remainder of the branch
*/
- Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
- ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL,
- HandlerObj, NULL);
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node,
+ ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
+ AcpiEvInstallHandler, NULL, HandlerObj, NULL);
UnlockAndExit:
return_ACPI_STATUS (Status);
diff --git a/source/components/events/evregion.c b/source/components/events/evregion.c
index c2f2292706550..7a6ce65b7afab 100644
--- a/source/components/events/evregion.c
+++ b/source/components/events/evregion.c
@@ -99,6 +99,7 @@ AcpiEvInitializeOpRegions (
/* Run the _REG methods for OpRegions in each default address space */
+ AcpiGbl_RegMethodsEnabled = TRUE;
for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
{
/*
@@ -109,13 +110,11 @@ AcpiEvInitializeOpRegions (
if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode,
AcpiGbl_DefaultAddressSpaces[i]))
{
- Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
- AcpiGbl_DefaultAddressSpaces[i]);
+ AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
+ AcpiGbl_DefaultAddressSpaces[i], ACPI_REG_CONNECT);
}
}
- AcpiGbl_RegMethodsExecuted = TRUE;
-
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (Status);
}
@@ -138,6 +137,12 @@ AcpiEvInitializeOpRegions (
* DESCRIPTION: Dispatch an address space or operation region access to
* a previously installed handler.
*
+ * NOTE: During early initialization, we always install the default region
+ * handlers for Memory, I/O and PCI_Config. This ensures that these operation
+ * region address spaces are always available as per the ACPI specification.
+ * This is especially needed in order to support the execution of
+ * module-level AML code during loading of the ACPI tables.
+ *
******************************************************************************/
ACPI_STATUS
@@ -320,7 +325,7 @@ AcpiEvAddressSpaceDispatch (
* We just returned from a non-default handler, we must re-enter the
* interpreter
*/
- AcpiExEnterInterpreter ();
+ AcpiExEnterInterpreter ();
}
return_ACPI_STATUS (Status);
@@ -342,7 +347,7 @@ AcpiEvAddressSpaceDispatch (
******************************************************************************/
void
-AcpiEvDetachRegion(
+AcpiEvDetachRegion (
ACPI_OPERAND_OBJECT *RegionObj,
BOOLEAN AcpiNsIsLocked)
{
@@ -521,6 +526,13 @@ AcpiEvAttachRegion (
ACPI_FUNCTION_TRACE (EvAttachRegion);
+ /* Install the region's handler */
+
+ if (RegionObj->Region.Handler)
+ {
+ return_ACPI_STATUS (AE_ALREADY_EXISTS);
+ }
+
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
"Adding Region [%4.4s] %p to address handler %p [%s]\n",
AcpiUtGetNodeName (RegionObj->Region.Node),
@@ -531,18 +543,62 @@ AcpiEvAttachRegion (
RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList;
HandlerObj->AddressSpace.RegionList = RegionObj;
+ RegionObj->Region.Handler = HandlerObj;
+ AcpiUtAddReference (HandlerObj);
- /* Install the region's handler */
+ return_ACPI_STATUS (AE_OK);
+}
- if (RegionObj->Region.Handler)
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvAssociateRegMethod
+ *
+ * PARAMETERS: RegionObj - Region object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Find and associate _REG method to a region
+ *
+ ******************************************************************************/
+
+void
+AcpiEvAssociateRegMethod (
+ ACPI_OPERAND_OBJECT *RegionObj)
+{
+ ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG;
+ ACPI_NAMESPACE_NODE *MethodNode;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *RegionObj2;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (EvAssociateRegMethod);
+
+
+ RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
+ if (!RegionObj2)
{
- return_ACPI_STATUS (AE_ALREADY_EXISTS);
+ return_VOID;
}
- RegionObj->Region.Handler = HandlerObj;
- AcpiUtAddReference (HandlerObj);
+ Node = RegionObj->Region.Node->Parent;
- return_ACPI_STATUS (AE_OK);
+ /* Find any "_REG" method associated with this region definition */
+
+ Status = AcpiNsSearchOneScope (
+ *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * The _REG method is optional and there can be only one per region
+ * definition. This will be executed when the handler is attached
+ * or removed
+ */
+ RegionObj2->Extra.Method_REG = MethodNode;
+ }
+
+ return_VOID;
}
@@ -579,7 +635,19 @@ AcpiEvExecuteRegMethod (
return_ACPI_STATUS (AE_NOT_EXIST);
}
- if (RegionObj2->Extra.Method_REG == NULL)
+ if (RegionObj2->Extra.Method_REG == NULL ||
+ RegionObj->Region.Handler == NULL ||
+ !AcpiGbl_RegMethodsEnabled)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */
+
+ if ((Function == ACPI_REG_CONNECT &&
+ RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED) ||
+ (Function == ACPI_REG_DISCONNECT &&
+ !(RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED)))
{
return_ACPI_STATUS (AE_OK);
}
@@ -631,6 +699,20 @@ AcpiEvExecuteRegMethod (
Status = AcpiNsEvaluate (Info);
AcpiUtRemoveReference (Args[1]);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup2;
+ }
+
+ if (Function == ACPI_REG_CONNECT)
+ {
+ RegionObj->Common.Flags |= AOPOBJ_REG_CONNECTED;
+ }
+ else
+ {
+ RegionObj->Common.Flags &= ~AOPOBJ_REG_CONNECTED;
+ }
+
Cleanup2:
AcpiUtRemoveReference (Args[0]);
@@ -646,26 +728,28 @@ Cleanup1:
*
* PARAMETERS: Node - Namespace node for the device
* SpaceId - The address space ID
+ * Function - Passed to _REG: On (1) or Off (0)
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Run all _REG methods for the input Space ID;
* Note: assumes namespace is locked, or system init time.
*
******************************************************************************/
-ACPI_STATUS
+void
AcpiEvExecuteRegMethods (
ACPI_NAMESPACE_NODE *Node,
- ACPI_ADR_SPACE_TYPE SpaceId)
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ UINT32 Function)
{
- ACPI_STATUS Status;
ACPI_REG_WALK_INFO Info;
ACPI_FUNCTION_TRACE (EvExecuteRegMethods);
Info.SpaceId = SpaceId;
+ Info.Function = Function;
Info.RegRunCount = 0;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES,
@@ -678,7 +762,7 @@ AcpiEvExecuteRegMethods (
* regions and _REG methods. (i.e. handlers must be installed for all
* regions of this Space ID before we can run any _REG methods)
*/
- Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
+ (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, &Info, NULL);
/* Special case for EC: handle "orphan" _REG methods with no region */
@@ -692,7 +776,7 @@ AcpiEvExecuteRegMethods (
" Executed %u _REG methods for SpaceId %s\n",
Info.RegRunCount, AcpiUtGetRegionName (Info.SpaceId)));
- return_ACPI_STATUS (Status);
+ return_VOID;
}
@@ -759,7 +843,7 @@ AcpiEvRegRun (
}
Info->RegRunCount++;
- Status = AcpiEvExecuteRegMethod (ObjDesc, ACPI_REG_CONNECT);
+ Status = AcpiEvExecuteRegMethod (ObjDesc, Info->Function);
return (Status);
}
diff --git a/source/components/events/evrgnini.c b/source/components/events/evrgnini.c
index cc0240d9de178..6bb0e6e5bdff1 100644
--- a/source/components/events/evrgnini.c
+++ b/source/components/events/evrgnini.c
@@ -567,9 +567,6 @@ AcpiEvInitializeRegion (
ACPI_ADR_SPACE_TYPE SpaceId;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *MethodNode;
- ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG;
- ACPI_OPERAND_OBJECT *RegionObj2;
ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked);
@@ -585,39 +582,15 @@ AcpiEvInitializeRegion (
return_ACPI_STATUS (AE_OK);
}
- RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
- if (!RegionObj2)
- {
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
+ AcpiEvAssociateRegMethod (RegionObj);
+ RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
Node = RegionObj->Region.Node->Parent;
SpaceId = RegionObj->Region.SpaceId;
- /* Setup defaults */
-
- RegionObj->Region.Handler = NULL;
- RegionObj2->Extra.Method_REG = NULL;
- RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
- RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
-
- /* Find any "_REG" method associated with this region definition */
-
- Status = AcpiNsSearchOneScope (
- *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
- if (ACPI_SUCCESS (Status))
- {
- /*
- * The _REG method is optional and there can be only one per region
- * definition. This will be executed when the handler is attached
- * or removed
- */
- RegionObj2->Extra.Method_REG = MethodNode;
- }
-
/*
* The following loop depends upon the root Node having no parent
- * ie: AcpiGbl_RootNode->ParentEntry being set to NULL
+ * ie: AcpiGbl_RootNode->Parent being set to NULL
*/
while (Node)
{
@@ -632,18 +605,10 @@ AcpiEvInitializeRegion (
switch (Node->Type)
{
case ACPI_TYPE_DEVICE:
-
- HandlerObj = ObjDesc->Device.Handler;
- break;
-
case ACPI_TYPE_PROCESSOR:
-
- HandlerObj = ObjDesc->Processor.Handler;
- break;
-
case ACPI_TYPE_THERMAL:
- HandlerObj = ObjDesc->ThermalZone.Handler;
+ HandlerObj = ObjDesc->CommonNotify.Handler;
break;
case ACPI_TYPE_METHOD:
@@ -667,51 +632,43 @@ AcpiEvInitializeRegion (
break;
}
- while (HandlerObj)
+ HandlerObj = AcpiEvFindRegionHandler (SpaceId, HandlerObj);
+ if (HandlerObj)
{
- /* Is this handler of the correct type? */
-
- if (HandlerObj->AddressSpace.SpaceId == SpaceId)
- {
- /* Found correct handler */
+ /* Found correct handler */
- ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
- "Found handler %p for region %p in obj %p\n",
- HandlerObj, RegionObj, ObjDesc));
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Found handler %p for region %p in obj %p\n",
+ HandlerObj, RegionObj, ObjDesc));
- Status = AcpiEvAttachRegion (HandlerObj, RegionObj,
- AcpiNsLocked);
+ Status = AcpiEvAttachRegion (HandlerObj, RegionObj,
+ AcpiNsLocked);
- /*
- * Tell all users that this region is usable by
- * running the _REG method
- */
- if (AcpiNsLocked)
+ /*
+ * Tell all users that this region is usable by
+ * running the _REG method
+ */
+ if (AcpiNsLocked)
+ {
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
{
- Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
+ return_ACPI_STATUS (Status);
}
+ }
- Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
+ Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
- if (AcpiNsLocked)
+ if (AcpiNsLocked)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
{
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
+ return_ACPI_STATUS (Status);
}
-
- return_ACPI_STATUS (AE_OK);
}
- /* Try next handler in the list */
-
- HandlerObj = HandlerObj->AddressSpace.Next;
+ return_ACPI_STATUS (AE_OK);
}
}
diff --git a/source/components/events/evxfregn.c b/source/components/events/evxfregn.c
index d26f3bf053dde..7c6e1cbc33c03 100644
--- a/source/components/events/evxfregn.c
+++ b/source/components/events/evxfregn.c
@@ -121,43 +121,9 @@ AcpiInstallAddressSpaceHandler (
goto UnlockAndExit;
}
- /*
- * For the default SpaceIDs, (the IDs for which there are default region handlers
- * installed) Only execute the _REG methods if the global initialization _REG
- * methods have already been run (via AcpiInitializeObjects). In other words,
- * we will defer the execution of the _REG methods for these SpaceIDs until
- * execution of AcpiInitializeObjects. This is done because we need the handlers
- * for the default spaces (mem/io/pci/table) to be installed before we can run
- * any control methods (or _REG methods). There is known BIOS code that depends
- * on this.
- *
- * For all other SpaceIDs, we can safely execute the _REG methods immediately.
- * This means that for IDs like EmbeddedController, this function should be called
- * only after AcpiEnableSubsystem has been called.
- */
- switch (SpaceId)
- {
- case ACPI_ADR_SPACE_SYSTEM_MEMORY:
- case ACPI_ADR_SPACE_SYSTEM_IO:
- case ACPI_ADR_SPACE_PCI_CONFIG:
- case ACPI_ADR_SPACE_DATA_TABLE:
-
- if (!AcpiGbl_RegMethodsExecuted)
- {
- /* We will defer execution of the _REG methods for this space */
-
- goto UnlockAndExit;
- }
- break;
-
- default:
-
- break;
- }
-
/* Run all _REG methods for this address space */
- Status = AcpiEvExecuteRegMethods (Node, SpaceId);
+ AcpiEvExecuteRegMethods (Node, SpaceId, ACPI_REG_CONNECT);
UnlockAndExit:
@@ -236,8 +202,8 @@ AcpiRemoveAddressSpaceHandler (
/* Find the address handler the user requested */
- HandlerObj = ObjDesc->Device.Handler;
- LastObjPtr = &ObjDesc->Device.Handler;
+ HandlerObj = ObjDesc->CommonNotify.Handler;
+ LastObjPtr = &ObjDesc->CommonNotify.Handler;
while (HandlerObj)
{
/* We have a handler, see if user requested this one */
diff --git a/source/components/executer/excreate.c b/source/components/executer/excreate.c
index 5e67346091d7d..82e7e767491b3 100644
--- a/source/components/executer/excreate.c
+++ b/source/components/executer/excreate.c
@@ -350,9 +350,10 @@ AcpiExCreateRegion (
* Remember location in AML stream of address & length
* operands since they need to be evaluated at run time.
*/
- RegionObj2 = ObjDesc->Common.NextObject;
+ RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
RegionObj2->Extra.AmlStart = AmlStart;
RegionObj2->Extra.AmlLength = AmlLength;
+ RegionObj2->Extra.Method_REG = NULL;
if (WalkState->ScopeInfo)
{
RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
@@ -368,6 +369,10 @@ AcpiExCreateRegion (
ObjDesc->Region.Address = 0;
ObjDesc->Region.Length = 0;
ObjDesc->Region.Node = Node;
+ ObjDesc->Region.Handler = NULL;
+ ObjDesc->Common.Flags &=
+ ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED |
+ AOPOBJ_OBJECT_INITIALIZED);
/* Install the new region object in the parent Node */
diff --git a/source/components/executer/exdebug.c b/source/components/executer/exdebug.c
index 4d97cda0d3721..982760b91c07c 100644
--- a/source/components/executer/exdebug.c
+++ b/source/components/executer/exdebug.c
@@ -96,13 +96,20 @@ AcpiExDoDebugObject (
return_VOID;
}
- /*
- * We will emit the current timer value (in microseconds) with each
- * debug output. Only need the lower 26 bits. This allows for 67
- * million microseconds or 67 seconds before rollover.
- */
- Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
- Timer &= 0x03FFFFFF;
+ /* Null string or newline -- don't emit the line header */
+
+ if (SourceDesc &&
+ (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) &&
+ (SourceDesc->Common.Type == ACPI_TYPE_STRING))
+ {
+ if ((SourceDesc->String.Length == 0) ||
+ ((SourceDesc->String.Length == 1) &&
+ (*SourceDesc->String.Pointer == '\n')))
+ {
+ AcpiOsPrintf ("\n");
+ return_VOID;
+ }
+ }
/*
* Print line header as long as we are not in the middle of an
@@ -110,14 +117,31 @@ AcpiExDoDebugObject (
*/
if (!((Level > 0) && Index == 0))
{
- AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
+ if (AcpiGbl_DisplayDebugTimer)
+ {
+ /*
+ * We will emit the current timer value (in microseconds) with each
+ * debug output. Only need the lower 26 bits. This allows for 67
+ * million microseconds or 67 seconds before rollover.
+ *
+ * Convert 100 nanosecond units to microseconds
+ */
+ Timer = ((UINT32) AcpiOsGetTimer () / 10);
+ Timer &= 0x03FFFFFF;
+
+ AcpiOsPrintf ("[ACPI Debug T=0x%8.8X] %*s", Timer, Level, " ");
+ }
+ else
+ {
+ AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
+ }
}
/* Display the index for package output only */
if (Index > 0)
{
- AcpiOsPrintf ("(%.2u) ", Index-1);
+ AcpiOsPrintf ("(%.2u) ", Index - 1);
}
if (!SourceDesc)
@@ -128,7 +152,13 @@ AcpiExDoDebugObject (
if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
{
- AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
+ /* No object type prefix needed for integers and strings */
+
+ if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
+ (SourceDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
+ }
if (!AcpiUtValidInternalObject (SourceDesc))
{
@@ -138,7 +168,7 @@ AcpiExDoDebugObject (
}
else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
{
- AcpiOsPrintf ("%s: %p\n",
+ AcpiOsPrintf ("%s (Node %p)\n",
AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
SourceDesc);
return_VOID;
@@ -178,13 +208,12 @@ AcpiExDoDebugObject (
case ACPI_TYPE_STRING:
- AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
- SourceDesc->String.Length, SourceDesc->String.Pointer);
+ AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer);
break;
case ACPI_TYPE_PACKAGE:
- AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
+ AcpiOsPrintf ("(Contains 0x%.2X Elements):\n",
SourceDesc->Package.Count);
/* Output the entire contents of the package */
@@ -263,8 +292,10 @@ AcpiExDoDebugObject (
if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
ACPI_DESC_TYPE_NAMED)
{
- AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
- SourceDesc->Reference.Object)->Object,
+ /* Reference object is a namespace node */
+
+ AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT,
+ SourceDesc->Reference.Object),
Level + 4, 0);
}
else
@@ -290,8 +321,15 @@ AcpiExDoDebugObject (
case ACPI_TYPE_PACKAGE:
AcpiOsPrintf ("Package[%u] = ", Value);
- AcpiExDoDebugObject (*SourceDesc->Reference.Where,
- Level+4, 0);
+ if (!(*SourceDesc->Reference.Where))
+ {
+ AcpiOsPrintf ("[Uninitialized Package Element]\n");
+ }
+ else
+ {
+ AcpiExDoDebugObject (*SourceDesc->Reference.Where,
+ Level+4, 0);
+ }
break;
default:
@@ -306,7 +344,7 @@ AcpiExDoDebugObject (
default:
- AcpiOsPrintf ("%p\n", SourceDesc);
+ AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc);
break;
}
diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c
index ebd78d9af5fd4..a09d779c24cc6 100644
--- a/source/components/executer/exdump.c
+++ b/source/components/executer/exdump.c
@@ -522,7 +522,8 @@ AcpiExDumpObject (
if (Next)
{
AcpiOsPrintf ("(%s %2.2X)",
- AcpiUtGetObjectTypeName (Next), Next->Common.Type);
+ AcpiUtGetObjectTypeName (Next),
+ Next->AddressSpace.SpaceId);
while (Next->AddressSpace.Next)
{
@@ -534,7 +535,8 @@ AcpiExDumpObject (
Next = Next->AddressSpace.Next;
AcpiOsPrintf ("->%p(%s %2.2X)", Next,
- AcpiUtGetObjectTypeName (Next), Next->Common.Type);
+ AcpiUtGetObjectTypeName (Next),
+ Next->AddressSpace.SpaceId);
if ((Next == Start) || (Next == Data))
{
diff --git a/source/components/executer/exmisc.c b/source/components/executer/exmisc.c
index ab01f6ea50dd5..b56645cc33d7d 100644
--- a/source/components/executer/exmisc.c
+++ b/source/components/executer/exmisc.c
@@ -107,9 +107,9 @@ AcpiExGetObjectReference (
default:
- ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
+ ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X",
ObjDesc->Reference.Class));
- return_ACPI_STATUS (AE_AML_INTERNAL);
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
break;
@@ -265,6 +265,7 @@ AcpiExDoConcatenate (
ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
ACPI_OPERAND_OBJECT *ReturnDesc;
char *NewBuf;
+ const char *TypeString;
ACPI_STATUS Status;
@@ -286,9 +287,42 @@ AcpiExDoConcatenate (
break;
case ACPI_TYPE_STRING:
+ /*
+ * Per the ACPI spec, Concatenate only supports int/str/buf.
+ * However, we support all objects here as an extension.
+ * This improves the usefulness of the Printf() macro.
+ * 12/2015.
+ */
+ switch (Operand1->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
- Status = AcpiExConvertToString (
- Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
+ Status = AcpiExConvertToString (
+ Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+ default:
+ /*
+ * Just emit a string containing the object type.
+ */
+ TypeString = AcpiUtGetTypeName (Operand1->Common.Type);
+
+ LocalOperand1 = AcpiUtCreateStringObject (
+ ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[Object]" */
+ if (!LocalOperand1)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ strcpy (LocalOperand1->String.Pointer, "[");
+ strcat (LocalOperand1->String.Pointer, TypeString);
+ strcat (LocalOperand1->String.Pointer, " Object]");
+ Status = AE_OK;
+ break;
+ }
break;
case ACPI_TYPE_BUFFER:
@@ -367,8 +401,7 @@ AcpiExDoConcatenate (
/* Concatenate the strings */
strcpy (NewBuf, Operand0->String.Pointer);
- strcpy (NewBuf + Operand0->String.Length,
- LocalOperand1->String.Pointer);
+ strcat (NewBuf, LocalOperand1->String.Pointer);
break;
case ACPI_TYPE_BUFFER:
diff --git a/source/components/executer/exoparg1.c b/source/components/executer/exoparg1.c
index 4d2d88f648625..efaa827701931 100644
--- a/source/components/executer/exoparg1.c
+++ b/source/components/executer/exoparg1.c
@@ -724,7 +724,7 @@ AcpiExOpcode_1A_0T_1R (
Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
break;
- case AML_TYPE_OP: /* ObjectType (SourceObject) */
+ case AML_OBJECT_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
diff --git a/source/components/namespace/nsconvert.c b/source/components/namespace/nsconvert.c
index 84eeec1fa48a4..5d3eb033e713e 100644
--- a/source/components/namespace/nsconvert.c
+++ b/source/components/namespace/nsconvert.c
@@ -332,7 +332,8 @@ AcpiNsConvertToBuffer (
*
* FUNCTION: AcpiNsConvertToUnicode
*
- * PARAMETERS: OriginalObject - ASCII String Object to be converted
+ * PARAMETERS: Scope - Namespace node for the method/object
+ * OriginalObject - ASCII String Object to be converted
* ReturnObject - Where the new converted object is returned
*
* RETURN: Status. AE_OK if conversion was successful.
@@ -343,6 +344,7 @@ AcpiNsConvertToBuffer (
ACPI_STATUS
AcpiNsConvertToUnicode (
+ ACPI_NAMESPACE_NODE *Scope,
ACPI_OPERAND_OBJECT *OriginalObject,
ACPI_OPERAND_OBJECT **ReturnObject)
{
@@ -404,7 +406,8 @@ AcpiNsConvertToUnicode (
*
* FUNCTION: AcpiNsConvertToResource
*
- * PARAMETERS: OriginalObject - Object to be converted
+ * PARAMETERS: Scope - Namespace node for the method/object
+ * OriginalObject - Object to be converted
* ReturnObject - Where the new converted object is returned
*
* RETURN: Status. AE_OK if conversion was successful
@@ -416,6 +419,7 @@ AcpiNsConvertToUnicode (
ACPI_STATUS
AcpiNsConvertToResource (
+ ACPI_NAMESPACE_NODE *Scope,
ACPI_OPERAND_OBJECT *OriginalObject,
ACPI_OPERAND_OBJECT **ReturnObject)
{
@@ -482,3 +486,81 @@ AcpiNsConvertToResource (
*ReturnObject = NewObject;
return (AE_OK);
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsConvertToReference
+ *
+ * PARAMETERS: Scope - Namespace node for the method/object
+ * OriginalObject - Object to be converted
+ * ReturnObject - Where the new converted object is returned
+ *
+ * RETURN: Status. AE_OK if conversion was successful
+ *
+ * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference.
+ * Buffer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsConvertToReference (
+ ACPI_NAMESPACE_NODE *Scope,
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_OPERAND_OBJECT *NewObject = NULL;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_GENERIC_STATE ScopeInfo;
+ char *Name;
+
+
+ ACPI_FUNCTION_NAME (NsConvertToReference);
+
+
+ /* Convert path into internal presentation */
+
+ Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Find the namespace node */
+
+ ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope);
+ Status = AcpiNsLookup (&ScopeInfo, Name,
+ ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Check if we are resolving a named reference within a package */
+
+ ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status);
+ goto ErrorExit;
+ }
+
+ /* Create and init a new internal ACPI object */
+
+ NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+ if (!NewObject)
+ {
+ Status = AE_NO_MEMORY;
+ goto ErrorExit;
+ }
+ NewObject->Reference.Node = Node;
+ NewObject->Reference.Object = Node->Object;
+ NewObject->Reference.Class = ACPI_REFCLASS_NAME;
+
+ /*
+ * Increase reference of the object if needed (the object is likely a
+ * null for device nodes).
+ */
+ AcpiUtAddReference (Node->Object);
+
+ErrorExit:
+ ACPI_FREE (Name);
+ *ReturnObject = NewObject;
+ return (AE_OK);
+}
diff --git a/source/components/namespace/nseval.c b/source/components/namespace/nseval.c
index 0509c80e7a0c7..a4819947dae40 100644
--- a/source/components/namespace/nseval.c
+++ b/source/components/namespace/nseval.c
@@ -418,7 +418,7 @@ AcpiNsExecModuleCodeList (
*
* DESCRIPTION: Execute a control method containing a block of module-level
* executable AML code. The control method is temporarily
- * installed to the root node, then evaluated.
+ * installed to a local copy of the root node, then evaluated.
*
******************************************************************************/
@@ -427,10 +427,9 @@ AcpiNsExecModuleCode (
ACPI_OPERAND_OBJECT *MethodObj,
ACPI_EVALUATE_INFO *Info)
{
- ACPI_OPERAND_OBJECT *ParentObj;
- ACPI_NAMESPACE_NODE *ParentNode;
- ACPI_OBJECT_TYPE Type;
ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *TempNode;
+ ACPI_NAMESPACE_NODE *ParentNode;
ACPI_FUNCTION_TRACE (NsExecModuleCode);
@@ -442,21 +441,18 @@ AcpiNsExecModuleCode (
*/
ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
MethodObj->Method.NextObject);
- Type = AcpiNsGetType (ParentNode);
- /*
- * Get the region handler and save it in the method object. We may need
- * this if an operation region declaration causes a _REG method to be run.
- *
- * We can't do this in AcpiPsLinkModuleCode because
- * AcpiGbl_RootNode->Object is NULL at PASS1.
- */
- if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
+ /* Take a copy of the parent node to act as parent of this method */
+
+ TempNode = ACPI_ALLOCATE (sizeof (ACPI_NAMESPACE_NODE));
+ if (!TempNode)
{
- MethodObj->Method.Dispatch.Handler =
- ParentNode->Object->Device.Handler;
+ return_VOID;
}
+ memcpy (TempNode, ParentNode, sizeof (ACPI_NAMESPACE_NODE));
+ TempNode->Object = NULL; /* Clear the subobject */
+
/* Must clear NextObject (AcpiNsAttachObject needs the field) */
MethodObj->Method.NextObject = NULL;
@@ -464,26 +460,14 @@ AcpiNsExecModuleCode (
/* Initialize the evaluation information block */
memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));
- Info->PrefixNode = ParentNode;
-
- /*
- * Get the currently attached parent object. Add a reference, because the
- * ref count will be decreased when the method object is installed to
- * the parent node.
- */
- ParentObj = AcpiNsGetAttachedObject (ParentNode);
- if (ParentObj)
- {
- AcpiUtAddReference (ParentObj);
- }
+ Info->PrefixNode = TempNode;
/* Install the method (module-level code) in the parent node */
- Status = AcpiNsAttachObject (ParentNode, MethodObj,
- ACPI_TYPE_METHOD);
+ Status = AcpiNsAttachObject (TempNode, MethodObj, ACPI_TYPE_METHOD);
if (ACPI_FAILURE (Status))
{
- goto Exit;
+ goto Cleanup;
}
/* Execute the parent node as a control method */
@@ -501,25 +485,7 @@ AcpiNsExecModuleCode (
AcpiUtRemoveReference (Info->ReturnObject);
}
- /* Detach the temporary method object */
-
- AcpiNsDetachObject (ParentNode);
-
- /* Restore the original parent object */
-
- if (ParentObj)
- {
- Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
- }
- else
- {
- ParentNode->Type = (UINT8) Type;
- }
-
-Exit:
- if (ParentObj)
- {
- AcpiUtRemoveReference (ParentObj);
- }
+Cleanup:
+ ACPI_FREE (TempNode);
return_VOID;
}
diff --git a/source/components/namespace/nsload.c b/source/components/namespace/nsload.c
index b1b6afa70615c..edd79327ff932 100644
--- a/source/components/namespace/nsload.c
+++ b/source/components/namespace/nsload.c
@@ -167,6 +167,24 @@ Unlock:
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"**** Completed Table Object Initialization\n"));
+ /*
+ * Execute any module-level code that was detected during the table load
+ * phase. Although illegal since ACPI 2.0, there are many machines that
+ * contain this type of code. Each block of detected executable AML code
+ * outside of any control method is wrapped with a temporary control
+ * method object and placed on a global list. The methods on this list
+ * are executed below.
+ *
+ * This case executes the module-level code for each table immediately
+ * after the table has been loaded. This provides compatibility with
+ * other ACPI implementations. Optionally, the execution can be deferred
+ * until later, see AcpiInitializeObjects.
+ */
+ if (!AcpiGbl_GroupModuleLevelCode)
+ {
+ AcpiNsExecModuleCodeList ();
+ }
+
return_ACPI_STATUS (Status);
}
diff --git a/source/components/namespace/nsrepair.c b/source/components/namespace/nsrepair.c
index d98e11022eefa..bb4b8a2fd7208 100644
--- a/source/components/namespace/nsrepair.c
+++ b/source/components/namespace/nsrepair.c
@@ -114,6 +114,11 @@ static const ACPI_SIMPLE_REPAIR_INFO AcpiObjectRepairInfo[] =
ACPI_NOT_PACKAGE_ELEMENT,
AcpiNsConvertToResource },
+ /* Object reference conversions */
+
+ { "_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS,
+ AcpiNsConvertToReference },
+
/* Unicode conversions */
{ "_MLS", ACPI_RTYPE_STRING, 1,
@@ -174,7 +179,8 @@ AcpiNsSimpleRepair (
ACPI_WARN_ALWAYS, "Missing expected return value"));
}
- Status = Predefined->ObjectConverter (ReturnObject, &NewObject);
+ Status = Predefined->ObjectConverter (Info->Node, ReturnObject,
+ &NewObject);
if (ACPI_FAILURE (Status))
{
/* A fatal error occurred during a conversion */
@@ -373,7 +379,8 @@ AcpiNsMatchSimpleRepair (
/* Check if we can actually repair this name/type combination */
if ((ReturnBtype & ThisName->UnexpectedBtypes) &&
- (PackageIndex == ThisName->PackageIndex))
+ (ThisName->PackageIndex == ACPI_ALL_PACKAGE_ELEMENTS ||
+ PackageIndex == ThisName->PackageIndex))
{
return (ThisName);
}
diff --git a/source/components/parser/psargs.c b/source/components/parser/psargs.c
index 7876a0eb49887..deab704bea888 100644
--- a/source/components/parser/psargs.c
+++ b/source/components/parser/psargs.c
@@ -298,7 +298,7 @@ AcpiPsGetNextNamepath (
PossibleMethodCall &&
(Node->Type == ACPI_TYPE_METHOD))
{
- if (WalkState->Opcode == AML_UNLOAD_OP)
+ if (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_SUPERNAME)
{
/*
* AcpiPsGetNextNamestring has increased the AML pointer,
@@ -744,7 +744,7 @@ AcpiPsGetNextField (
*
* PARAMETERS: WalkState - Current state
* ParserState - Current parser state object
- * ArgType - The argument type (AML_*_ARG)
+ * ArgType - The parser argument type (ARGP_*)
* ReturnArg - Where the next arg is returned
*
* RETURN: Status, and an op object containing the next argument.
@@ -857,6 +857,7 @@ AcpiPsGetNextArg (
case ARGP_TARGET:
case ARGP_SUPERNAME:
case ARGP_SIMPLENAME:
+ case ARGP_NAME_OR_REF:
Subop = AcpiPsPeekOpcode (ParserState);
if (Subop == 0 ||
@@ -872,15 +873,16 @@ AcpiPsGetNextArg (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /* To support SuperName arg of Unload */
+ /* SuperName allows argument to be a method call */
- if (WalkState->Opcode == AML_UNLOAD_OP)
+ if (ArgType == ARGP_SUPERNAME)
{
- Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
+ Status = AcpiPsGetNextNamepath (WalkState, ParserState,
+ Arg, ACPI_POSSIBLE_METHOD_CALL);
/*
- * If the SuperName arg of Unload is a method call,
- * we have restored the AML pointer, just free this Arg
+ * If the SuperName argument is a method call, we have
+ * already restored the AML pointer, just free this Arg
*/
if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
{
@@ -890,7 +892,8 @@ AcpiPsGetNextArg (
}
else
{
- Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
+ Status = AcpiPsGetNextNamepath (WalkState, ParserState,
+ Arg, ACPI_NOT_METHOD_CALL);
}
}
else
diff --git a/source/components/parser/psloop.c b/source/components/parser/psloop.c
index 044cf9d3e77ef..f1bd607ab206d 100644
--- a/source/components/parser/psloop.c
+++ b/source/components/parser/psloop.c
@@ -120,8 +120,8 @@ AcpiPsGetArguments (
case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
- Status = AcpiPsGetNextNamepath (
- WalkState, &(WalkState->ParserState), Op, 1);
+ Status = AcpiPsGetNextNamepath (WalkState,
+ &(WalkState->ParserState), Op, ACPI_POSSIBLE_METHOD_CALL);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
diff --git a/source/components/parser/psopcode.c b/source/components/parser/psopcode.c
index 0376da55b8ef4..9961a63319f37 100644
--- a/source/components/parser/psopcode.c
+++ b/source/components/parser/psopcode.c
@@ -245,7 +245,7 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] =
/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
+/* 37 */ ACPI_OP ("ObjectType", ARGP_OBJECT_TYPE_OP, ARGI_OBJECT_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c
index 19daea867e35f..910854997bb48 100644
--- a/source/components/tables/tbutils.c
+++ b/source/components/tables/tbutils.c
@@ -419,7 +419,7 @@ NextTable:
*
* PARAMETERS: Signature - Sig string to be validated
*
- * RETURN: TRUE if signature is correct length and has valid characters
+ * RETURN: TRUE if signature is has 4 valid ACPI characters
*
* DESCRIPTION: Validate an ACPI table signature.
*
@@ -432,13 +432,6 @@ AcpiIsValidSignature (
UINT32 i;
- /* Validate the signature length */
-
- if (strlen (Signature) != ACPI_NAME_SIZE)
- {
- return (FALSE);
- }
-
/* Validate each character in the signature */
for (i = 0; i < ACPI_NAME_SIZE; i++)
diff --git a/source/components/utilities/utinit.c b/source/components/utilities/utinit.c
index 9689abb435164..2c7061678d35c 100644
--- a/source/components/utilities/utinit.c
+++ b/source/components/utilities/utinit.c
@@ -226,7 +226,6 @@ AcpiUtInitGlobals (
AcpiGbl_NextOwnerIdOffset = 0;
AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
AcpiGbl_OsiMutex = NULL;
- AcpiGbl_RegMethodsExecuted = FALSE;
AcpiGbl_MaxLoopIterations = 0xFFFF;
/* Hardware oriented */
diff --git a/source/components/utilities/utstring.c b/source/components/utilities/utstring.c
index c8b41f10ad78f..5c761b785b14f 100644
--- a/source/components/utilities/utstring.c
+++ b/source/components/utilities/utstring.c
@@ -271,6 +271,15 @@ AcpiUtRepairName (
ACPI_FUNCTION_NAME (UtRepairName);
+ /*
+ * Special case for the root node. This can happen if we get an
+ * error during the execution of module-level code.
+ */
+ if (ACPI_COMPARE_NAME (Name, "\\___"))
+ {
+ return;
+ }
+
ACPI_MOVE_NAME (&OriginalName, Name);
/* Check each character in the name */
diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c
index 7502c61f07890..0efd35bda753c 100644
--- a/source/components/utilities/utxfinit.c
+++ b/source/components/utilities/utxfinit.c
@@ -132,6 +132,25 @@ AcpiInitializeSubsystem (
return_ACPI_STATUS (Status);
}
+ if (!AcpiGbl_OverrideDefaultRegionHandlers)
+ {
+ /*
+ * Install the default operation region handlers. These are the
+ * handlers that are defined by the ACPI specification to be
+ * "always accessible" -- namely, SystemMemory, SystemIO, and
+ * PCI_Config. This also means that no _REG methods need to be
+ * run for these address spaces. We need to have these handlers
+ * installed before any AML code can be executed, especially any
+ * module-level code (11/2015).
+ */
+ Status = AcpiEvInstallRegionHandlers ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
+ return_ACPI_STATUS (Status);
+ }
+ }
+
return_ACPI_STATUS (AE_OK);
}
@@ -161,6 +180,33 @@ AcpiEnableSubsystem (
ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
+ /*
+ * The early initialization phase is complete. The namespace is loaded,
+ * and we can now support address spaces other than Memory, I/O, and
+ * PCI_Config.
+ */
+ AcpiGbl_EarlyInitialization = FALSE;
+
+ if (AcpiGbl_OverrideDefaultRegionHandlers)
+ {
+ /*
+ * Install the default operation region handlers. These are the
+ * handlers that are defined by the ACPI specification to be
+ * "always accessible" -- namely, SystemMemory, SystemIO, and
+ * PCI_Config. This also means that no _REG methods need to be
+ * run for these address spaces. We need to have these handlers
+ * installed before any AML code can be executed, especially any
+ * module-level code (11/2015).
+ */
+ Status = AcpiEvInstallRegionHandlers ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+
#if (!ACPI_REDUCED_HARDWARE)
/* Enable ACPI mode */
@@ -193,26 +239,6 @@ AcpiEnableSubsystem (
}
}
-#endif /* !ACPI_REDUCED_HARDWARE */
-
- /*
- * Install the default OpRegion handlers. These are installed unless
- * other handlers have already been installed via the
- * InstallAddressSpaceHandler interface.
- */
- if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Installing default address space handlers\n"));
-
- Status = AcpiEvInstallRegionHandlers ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
-#if (!ACPI_REDUCED_HARDWARE)
/*
* Initialize ACPI Event handling (Fixed and General Purpose)
*
@@ -320,8 +346,15 @@ AcpiInitializeObjects (
* outside of any control method is wrapped with a temporary control
* method object and placed on a global list. The methods on this list
* are executed below.
+ *
+ * This case executes the module-level code for all tables only after
+ * all of the tables have been loaded. It is a legacy option and is
+ * not compatible with other ACPI implementations. See AcpiNsLoadTable.
*/
- AcpiNsExecModuleCodeList ();
+ if (AcpiGbl_GroupModuleLevelCode)
+ {
+ AcpiNsExecModuleCodeList ();
+ }
/*
* Initialize the objects that remain uninitialized. This runs the