📄 asllookup.c
字号:
return (AE_OK);}/******************************************************************************* * * FUNCTION: LsDisplayNamespace * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Walk the namespace an display information about each node * in the tree. Information is written to the optional * namespace output file. * ******************************************************************************/ACPI_STATUSLsDisplayNamespace ( void){ ACPI_STATUS Status; if (!Gbl_NsOutputFlag) { return (AE_OK); } Gbl_NumNamespaceObjects = 0; /* File header */ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n"); FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count Depth Name - Type\n\n"); /* Walk entire namespace from the root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, NULL, NULL); /* Print the full pathname for each namespace node */ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n"); Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, LsDoOnePathname, NULL, NULL); return (Status);}/******************************************************************************* * * FUNCTION: LsCompareOneNamespaceObject * * PARAMETERS: ACPI_WALK_CALLBACK * * RETURN: Status * * DESCRIPTION: Compare name of one object. * ******************************************************************************/static ACPI_STATUSLsCompareOneNamespaceObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue){ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; /* Simply check the name */ if (*((UINT32 *) (Context)) == Node->Name.Integer) { /* Abort walk if we found one instance */ return (AE_CTRL_TRUE); } return (AE_OK);}/******************************************************************************* * * FUNCTION: LkObjectExists * * PARAMETERS: Name - 4 char ACPI name * * RETURN: TRUE if name exists in namespace * * DESCRIPTION: Walk the namespace to find an object * ******************************************************************************/static BOOLEANLkObjectExists ( char *Name){ ACPI_STATUS Status; /* Walk entire namespace from the supplied root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, Name, NULL); if (Status == AE_CTRL_TRUE) { /* At least one instance of the name was found */ return (TRUE); } return (FALSE);}/******************************************************************************* * * FUNCTION: LkGetNameOp * * PARAMETERS: Op - Current Op * * RETURN: NameOp associated with the input op * * DESCRIPTION: Find the name declaration op associated with the operator * ******************************************************************************/ACPI_PARSE_OBJECT *LkGetNameOp ( ACPI_PARSE_OBJECT *Op){ const ACPI_OPCODE_INFO *OpInfo; ACPI_PARSE_OBJECT *NameOp = Op; OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); /* Get the NamePath from the appropriate place */ if (OpInfo->Flags & AML_NAMED) { /* For nearly all NAMED operators, the name reference is the first child */ NameOp = Op->Asl.Child; if (Op->Asl.AmlOpcode == AML_ALIAS_OP) { /* * ALIAS is the only oddball opcode, the name declaration * (alias name) is the second operand */ NameOp = Op->Asl.Child->Asl.Next; } } else if (OpInfo->Flags & AML_CREATE) { /* Name must appear as the last parameter */ NameOp = Op->Asl.Child; while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)) { NameOp = NameOp->Asl.Next; } } return (NameOp);}/******************************************************************************* * * FUNCTION: LkIsObjectUsed * * PARAMETERS: ACPI_WALK_CALLBACK * * RETURN: Status * * DESCRIPTION: Check for an unreferenced namespace object and emit a warning. * We have to be careful, because some types and names are * typically or always unreferenced, we don't want to issue * excessive warnings. * ******************************************************************************/static ACPI_STATUSLkIsObjectUsed ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue){ ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); /* Referenced flag is set during the namespace xref */ if (Node->Flags & ANOBJ_IS_REFERENCED) { return (AE_OK); } /* * Ignore names that start with an underscore, * these are the reserved ACPI names and are typically not referenced, * they are called by the host OS. */ if (Node->Name.Ascii[0] == '_') { return (AE_OK); } /* There are some types that are typically not referenced, ignore them */ switch (Node->Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: case ACPI_TYPE_LOCAL_RESOURCE: return (AE_OK); default: break; } /* All others are valid unreferenced namespace objects */ if (Node->Op) { AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL); } return (AE_OK);}/******************************************************************************* * * FUNCTION: LkFindUnreferencedObjects * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Namespace walk to find objects that are not referenced in any * way. Must be called after the namespace has been cross * referenced. * ******************************************************************************/voidLkFindUnreferencedObjects ( void){ /* Walk entire namespace from the supplied root */ (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL, NULL);}/******************************************************************************* * * FUNCTION: LkCrossReferenceNamespace * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Perform a cross reference check of the parse tree against the * namespace. Every named referenced within the parse tree * should be get resolved with a namespace lookup. If not, the * original reference in the ASL code is invalid -- i.e., refers * to a non-existent object. * * NOTE: The ASL "External" operator causes the name to be inserted into the * namespace so that references to the external name will be resolved * correctly here. * ******************************************************************************/ACPI_STATUSLkCrossReferenceNamespace ( void){ ACPI_WALK_STATE *WalkState; DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n"); /* * Create a new walk state for use when looking up names * within the namespace (Passed as context to the callbacks) */ WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); if (!WalkState) { return AE_NO_MEMORY; } /* Walk the entire parse tree */ TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, LkNamespaceLocateBegin, LkNamespaceLocateEnd, WalkState); return AE_OK;}/******************************************************************************* * * FUNCTION: LkCheckFieldRange * * PARAMETERS: RegionBitLength - Length of entire parent region * FieldBitOffset - Start of the field unit (within region) * FieldBitLength - Entire length of field unit * AccessBitWidth - Access width of the field unit * * RETURN: None * * DESCRIPTION: Check one field unit to make sure it fits in the parent * op region. * * Note: AccessBitWidth must be either 8,16,32, or 64 * ******************************************************************************/static voidLkCheckFieldRange ( ACPI_PARSE_OBJECT *Op, UINT32 RegionBitLength, UINT32 FieldBitOffset, UINT32 FieldBitLength, UINT32 AccessBitWidth){ UINT32 FieldEndBitOffset; /* * Check each field unit against the region size. The entire * field unit (start offset plus length) must fit within the * region. */ FieldEndBitOffset = FieldBitOffset + FieldBitLength; if (FieldEndBitOffset > RegionBitLength) { /* Field definition itself is beyond the end-of-region */ AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL); return; } /* * Now check that the field plus AccessWidth doesn't go beyond * the end-of-region. Assumes AccessBitWidth is a power of 2 */ FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth); if (FieldEndBitOffset > RegionBitLength) { /* Field definition combined with the access is beyond EOR */ AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL); }}/******************************************************************************* * * FUNCTION: LkNamespaceLocateBegin * * PARAMETERS: ASL_WALK_CALLBACK * * RETURN: Status * * DESCRIPTION: Descending callback used during cross-reference. For named * object references, attempt to locate the name in the * namespace. * * NOTE: ASL references to named fields within resource descriptors are * resolved to integer values here. Therefore, this step is an * important part of the code generation. We don't know that the * name refers to a resource descriptor until now. * ******************************************************************************/static ACPI_STATUSLkNamespaceLocateBegin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context){ ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; char *Path; UINT8 PassedArgs; ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *OwningOp; ACPI_PARSE_OBJECT *SpaceIdOp; UINT32 MinimumLength; UINT32 Temp; const ACPI_OPCODE_INFO *OpInfo; UINT32 Flags; ACPI_FUNCTION_TRACE_PTR (LkNamespaceLocateBegin, Op); /* * If this node is the actual declaration of a name * [such as the XXXX name in "Method (XXXX)"], * we are not interested in it here. We only care about names that are * references to other objects within the namespace and the parent objects * of name declarations */ if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) { return (AE_OK); } /* We are only interested in opcodes that have an associated name */ OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); if ((!(OpInfo->Flags & AML_NAMED)) && (!(OpInfo->Flags & AML_CREATE)) && (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) { return (AE_OK); } /* * We must enable the "search-to-root" for single NameSegs, but * we have to be very careful about opening up scopes */ Flags = ACPI_NS_SEARCH_PARENT; if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { /* * These are name references, do not push the scope stack * for them. */ Flags |= ACPI_NS_DONT_OPEN_SCOPE; } /* Get the NamePath from the appropriate place */ if (OpInfo->Flags & AML_NAMED) { /* For nearly all NAMED operators, the name reference is the first child */ Path = Op->Asl.Child->Asl.Value.String; if (Op->Asl.AmlOpcode == AML_ALIAS_OP) { /* * ALIAS is the only oddball opcode, the name declaration * (alias name) is the second operand */ Path = Op->Asl.Child->Asl.Next->Asl.Value.String; } } else if (OpInfo->Flags & AML_CREATE) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -