static ACPI_STATUS AcpiDmXrefDescendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { ACPI_OP_WALK_INFO *Info = Context; const ACPI_OPCODE_INFO *OpInfo; ACPI_WALK_STATE *WalkState; ACPI_OBJECT_TYPE ObjectType; ACPI_OBJECT_TYPE ObjectType2; ACPI_STATUS Status; char *Path = NULL; ACPI_PARSE_OBJECT *NextOp; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; WalkState = Info->WalkState; OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); ObjectType = OpInfo->ObjectType; ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); if ((!(OpInfo->Flags & AML_NAMED)) && (!(OpInfo->Flags & AML_CREATE)) && (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) { goto Exit; } /* Get the NamePath from the appropriate place */ if (OpInfo->Flags & AML_NAMED) { if ((Op->Common.AmlOpcode == AML_ALIAS_OP) || (Op->Common.AmlOpcode == AML_SCOPE_OP)) { /* * Only these two operators refer to an existing name, * first argument */ Path = (char *) Op->Named.Path; } } else if (OpInfo->Flags & AML_CREATE) { /* Referenced Buffer Name is the first child */ NextOp = Op->Common.Value.Arg; if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { Path = NextOp->Common.Value.String; } } else { Path = Op->Common.Value.String; } if (!Path) { goto Exit; } /* * Lookup the name in the namespace. Name must exist at this point, or it * is an invalid reference. * * The namespace is also used as a lookup table for references to resource * descriptors and the fields within them. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { AcpiDmAddToExternalList (Path, (UINT8) ObjectType, 0); /* * We could install this into the namespace, but we catch duplicate * externals when they are added to the list. */ #if 0 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Node); #endif } } /* * Found the node in external table, add it to external list * Node->OwnerId == 0 indicates built-in ACPI Names, _OS_ etc */ else if (Node->OwnerId && WalkState->OwnerId != Node->OwnerId) { ObjectType2 = ObjectType; Object = AcpiNsGetAttachedObject (Node); if (Object) { ObjectType2 = Object->Common.Type; } if (ObjectType2 == ACPI_TYPE_METHOD) { AcpiDmAddToExternalList (Path, ACPI_TYPE_METHOD, Object->Method.ParamCount); } else { AcpiDmAddToExternalList (Path, (UINT8) ObjectType2, 0); } Op->Common.Node = Node; } else { Op->Common.Node = Node; } Exit: /* Open new scope if necessary */ if (AcpiNsOpensScope (ObjectType)) { if (Op->Common.Node) { Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { return (Status); } } } return (AE_OK); }
ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp) { ACPI_PARSE_OBJECT *Op; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; char *Path; UINT32 Flags; ACPI_FUNCTION_TRACE (DsLoad1BeginOp); Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); /* We are only interested in opcodes that have an associated name */ if (Op) { if (!(WalkState->OpInfo->Flags & AML_NAMED)) { *OutOp = Op; return_ACPI_STATUS (AE_OK); } /* Check if this object has already been installed in the namespace */ if (Op->Common.Node) { *OutOp = Op; return_ACPI_STATUS (AE_OK); } } Path = AcpiPsGetNextNamestring (&WalkState->ParserState); /* Map the raw opcode into an internal object type */ ObjectType = WalkState->OpInfo->ObjectType; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType))); switch (WalkState->Opcode) { case AML_SCOPE_OP: /* * The target name of the Scope() operator must exist at this point so * that we can actually open the scope to enter new names underneath it. * Allow search-to-root for single namesegs. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); #ifdef ACPI_ASL_COMPILER if (Status == AE_NOT_FOUND) { /* * Table disassembly: * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ AcpiDmAddToExternalList (Path, ACPI_TYPE_DEVICE, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &Node); } #endif if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Path, Status); return_ACPI_STATUS (Status); } /* * Check to make sure that the target is * one of the opcodes that actually opens a scope */ switch (Node->Type) { case ACPI_TYPE_ANY: case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: /* These are acceptable types */ break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } * * Note: silently change the type here. On the second pass, we will report * a warning */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", Path, AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; break; default: /* All other types are an error */ ACPI_ERROR ((AE_INFO, "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)", AcpiUtGetTypeName (Node->Type), Path)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } break; default: /* * For all other named opcodes, we will enter the name into * the namespace. * * Setup the search flags. * Since we are entering a name into the namespace, we do not want to * enable the search-to-root upsearch. * * There are only two conditions where it is acceptable that the name * already exists: * 1) the Scope() operator can reopen a scoping object that was * previously defined (Scope, Method, Device, etc.) * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, * BufferField, or Package), the name of the object is already * in the namespace. */ if (WalkState->DeferredNode) { /* This name is already in the namespace, get the node */ Node = WalkState->DeferredNode; Status = AE_OK; break; } /* * If we are executing a method, do not create any namespace objects * during the load phase, only during execution. */ if (WalkState->MethodNode) { Node = NULL; Status = AE_OK; break; } Flags = ACPI_NS_NO_UPSEARCH; if ((WalkState->Opcode != AML_SCOPE_OP) && (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) { Flags |= ACPI_NS_ERROR_IF_FOUND; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", AcpiUtGetTypeName (ObjectType))); } else { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n", AcpiUtGetTypeName (ObjectType))); } /* * Enter the named type into the internal namespace. We enter the name * as we go downward in the parse tree. Any necessary subobjects that * involve arguments to the opcode must be created as we go back up the * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) { /* The name already exists in this scope */ if (Node->Flags & ANOBJ_IS_EXTERNAL) { /* * Allow one create on an object or segment that was * previously declared External */ Node->Flags &= ~ANOBJ_IS_EXTERNAL; Node->Type = (UINT8) ObjectType; /* Just retyped a node, probably will need to open a scope */ if (AcpiNsOpensScope (ObjectType)) { Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } Status = AE_OK; } } if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Path, Status); return_ACPI_STATUS (Status); } } break; } /* Common exit */ if (!Op) { /* Create a new op */ Op = AcpiPsAllocOp (WalkState->Opcode); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); } } /* Initialize the op */ #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); #endif if (Node) { /* * Put the Node in the "op" object that the parser uses, so we * can get it again quickly when this scope is closed */ Op->Common.Node = Node; Op->Named.Name = Node->Name.Integer; } AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); *OutOp = Op; return_ACPI_STATUS (Status); }
static ACPI_STATUS AcpiDmFindOrphanDescending ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { const ACPI_OPCODE_INFO *OpInfo; ACPI_PARSE_OBJECT *ChildOp; ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *ParentOp; UINT32 ArgCount; if (!Op) { return (AE_OK); } OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); switch (Op->Common.AmlOpcode) { #ifdef ACPI_UNDER_DEVELOPMENT case AML_ADD_OP: ChildOp = Op->Common.Value.Arg; if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && !ChildOp->Common.Node) { AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String, NULL, &Path); AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", Op->Common.AmlOpName, Path); ACPI_FREE (Path); NextOp = Op->Common.Next; if (!NextOp) { /* This NamePath has no args, assume it is an integer */ AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp); AcpiOsPrintf ("/* A-CHILDREN: %d Actual %d */\n", ArgCount, AcpiDmCountChildren (Op)); if (ArgCount < 1) { /* One Arg means this is just a Store(Name,Target) */ AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); } break; #endif case AML_STORE_OP: ChildOp = Op->Common.Value.Arg; if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && !ChildOp->Common.Node) { NextOp = Op->Common.Next; if (!NextOp) { /* This NamePath has no args, assume it is an integer */ AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp); if (ArgCount <= 1) { /* One Arg means this is just a Store(Name,Target) */ AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); } break; case AML_INT_NAMEPATH_OP: /* Must examine parent to see if this namepath is an argument */ ParentOp = Op->Common.Parent; OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); if ((OpInfo->Class != AML_CLASS_EXECUTE) && (OpInfo->Class != AML_CLASS_CREATE) && (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && !Op->Common.Node) { ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op->Common.Next); /* * Check if namepath is a predicate for if/while or lone parameter to * a return. */ if (ArgCount == 0) { if (((ParentOp->Common.AmlOpcode == AML_IF_OP) || (ParentOp->Common.AmlOpcode == AML_WHILE_OP) || (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) && /* And namepath is the first argument */ (ParentOp->Common.Value.Arg == Op)) { AcpiDmAddToExternalList (Op->Common.Value.String, ACPI_TYPE_INTEGER, 0); break; } } /* * This is a standalone namestring (not a parameter to another * operator) - it *must* be a method invocation, nothing else is * grammatically possible. */ AcpiDmAddToExternalList (Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); } break; default: break; } return (AE_OK); }