static ACPI_STATUS AcpiDbWalkForPredefinedNames ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; UINT32 *Count = (UINT32 *) Context; const ACPI_PREDEFINED_INFO *Predefined; const ACPI_PREDEFINED_INFO *Package = NULL; char *Pathname; char StringBuffer[48]; Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); if (!Predefined) { return (AE_OK); } Pathname = AcpiNsGetExternalPathname (Node); if (!Pathname) { return (AE_OK); } /* If method returns a package, the info is in the next table entry */ if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) { Package = Predefined + 1; } AcpiUtGetExpectedReturnTypes (StringBuffer, Predefined->Info.ExpectedBtypes); AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname, METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList), StringBuffer); if (Package) { AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)", Package->RetInfo.Type, Package->RetInfo.ObjectType1, Package->RetInfo.Count1); } AcpiOsPrintf("\n"); /* Check that the declared argument count matches the ACPI spec */ AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined); ACPI_FREE (Pathname); (*Count)++; return (AE_OK); }
void AcpiUtDisplayPredefinedMethod ( char *Buffer, const ACPI_PREDEFINED_INFO *ThisName, BOOLEAN MultiLine) { UINT32 ArgCount; /* * Get the argument count and the string buffer * containing all argument types */ ArgCount = AcpiUtGetArgumentTypes (Buffer, ThisName->Info.ArgumentList); if (MultiLine) { printf (" "); } printf ("%4.4s Requires %s%u argument%s", ThisName->Info.Name, (ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM) ? "(at least) " : "", ArgCount, ArgCount != 1 ? "s" : ""); /* Display the types for any arguments */ if (ArgCount > 0) { printf (" (%s)", Buffer); } if (MultiLine) { printf ("\n "); } /* Get the return value type(s) allowed */ if (ThisName->Info.ExpectedBtypes) { AcpiUtGetExpectedReturnTypes (Buffer, ThisName->Info.ExpectedBtypes); printf (" Return value types: %s\n", Buffer); } else { printf (" No return value\n"); } }
BOOLEAN ApCheckForPredefinedMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo) { UINT32 Index; UINT32 RequiredArgCount; const ACPI_PREDEFINED_INFO *ThisName; /* Check for a match against the predefined name list */ Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); switch (Index) { case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ /* Just return, nothing to do */ return (FALSE); case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ Gbl_ReservedMethods++; /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */ if (MethodInfo->NumArguments != 0) { sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, 0); AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); } break; default: /* * Matched a predefined method name - validate the ASL-defined * argument count against the ACPI specification. * * Some methods are allowed to have a "minimum" number of args * (_SCP) because their definition in ACPI has changed over time. */ Gbl_ReservedMethods++; ThisName = &AcpiGbl_PredefinedMethods[Index]; RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList); if (MethodInfo->NumArguments != RequiredArgCount) { sprintf (MsgBuffer, "%4.4s requires %u", ThisName->Info.Name, RequiredArgCount); if (MethodInfo->NumArguments < RequiredArgCount) { AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, MsgBuffer); } else if ((MethodInfo->NumArguments > RequiredArgCount) && !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) { AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); } } /* * Check if method returns no value, but the predefined name is * required to return a value */ if (MethodInfo->NumReturnNoValue && ThisName->Info.ExpectedBtypes) { AcpiUtGetExpectedReturnTypes (StringBuffer, ThisName->Info.ExpectedBtypes); sprintf (MsgBuffer, "%s required for %4.4s", StringBuffer, ThisName->Info.Name); AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, MsgBuffer); } break; } return (TRUE); }
ACPI_STATUS ApCheckObjectType ( const char *PredefinedName, ACPI_PARSE_OBJECT *Op, UINT32 ExpectedBtypes, UINT32 PackageIndex) { UINT32 ReturnBtype; char *TypeName; if (!Op) { return (AE_TYPE); } /* Map the parse opcode to a bitmapped return type (RTYPE) */ switch (Op->Asl.ParseOpcode) { case PARSEOP_ZERO: case PARSEOP_ONE: case PARSEOP_ONES: case PARSEOP_INTEGER: ReturnBtype = ACPI_RTYPE_INTEGER; TypeName = "Integer"; break; case PARSEOP_STRING_LITERAL: ReturnBtype = ACPI_RTYPE_STRING; TypeName = "String"; break; case PARSEOP_BUFFER: ReturnBtype = ACPI_RTYPE_BUFFER; TypeName = "Buffer"; break; case PARSEOP_PACKAGE: case PARSEOP_VAR_PACKAGE: ReturnBtype = ACPI_RTYPE_PACKAGE; TypeName = "Package"; break; case PARSEOP_NAMESEG: case PARSEOP_NAMESTRING: /* * Ignore any named references within a package object. * * For Package objects, references are allowed instead of any of the * standard data types (Integer/String/Buffer/Package). These * references are resolved at runtime. NAMESEG and NAMESTRING are * impossible to typecheck at compile time because the type of * any named object can be changed at runtime (for example, * CopyObject will change the type of the target object). */ if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) { return (AE_OK); } ReturnBtype = ACPI_RTYPE_REFERENCE; TypeName = "Reference"; break; default: /* Not one of the supported object types */ TypeName = UtGetOpName (Op->Asl.ParseOpcode); goto TypeErrorExit; } /* Exit if the object is one of the expected types */ if (ReturnBtype & ExpectedBtypes) { return (AE_OK); } TypeErrorExit: /* Format the expected types and emit an error message */ AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { sprintf (MsgBuffer, "%4.4s: found %s, %s required", PredefinedName, TypeName, StringBuffer); } else { sprintf (MsgBuffer, "%4.4s: found %s at index %u, %s required", PredefinedName, TypeName, PackageIndex, StringBuffer); } AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer); return (AE_TYPE); }
ACPI_STATUS AcpiNsCheckObjectType ( ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex) { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; ACPI_STATUS Status = AE_OK; char TypeBuffer[48]; /* Room for 5 types */ /* A Namespace node should not get here, but make sure */ if (ReturnObject && ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Invalid return type - Found a Namespace node [%4.4s] type %s", ReturnObject->Node.Name.Ascii, AcpiUtGetTypeName (ReturnObject->Node.Type))); return (AE_AML_OPERAND_TYPE); } /* * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. * The bitmapped type allows multiple possible return types. * * Note, the cases below must handle all of the possible types returned * from all of the predefined names (including elements of returned * packages) */ Data->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject); if (Data->ReturnBtype == ACPI_RTYPE_ANY) { /* Not one of the supported objects, must be incorrect */ goto TypeErrorExit; } /* For reference objects, check that the reference type is correct */ if ((Data->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE) { Status = AcpiNsCheckReference (Data, ReturnObject); return (Status); } /* Attempt simple repair of the returned object if necessary */ Status = AcpiNsSimpleRepair (Data, ExpectedBtypes, PackageIndex, ReturnObjectPtr); return (Status); TypeErrorExit: /* Create a string with all expected types for this predefined object */ AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Return type mismatch - found %s, expected %s", AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } else { ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Return Package type mismatch at index %u - " "found %s, expected %s", PackageIndex, AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } return (AE_AML_OPERAND_TYPE); }
ACPI_STATUS ApCheckObjectType ( const char *PredefinedName, ACPI_PARSE_OBJECT *Op, UINT32 ExpectedBtypes, UINT32 PackageIndex) { UINT32 ReturnBtype; char *TypeName; if (!Op) { return (AE_TYPE); } /* Map the parse opcode to a bitmapped return type (RTYPE) */ switch (Op->Asl.ParseOpcode) { case PARSEOP_ZERO: case PARSEOP_ONE: case PARSEOP_ONES: case PARSEOP_INTEGER: ReturnBtype = ACPI_RTYPE_INTEGER; TypeName = "Integer"; break; case PARSEOP_STRING_LITERAL: ReturnBtype = ACPI_RTYPE_STRING; TypeName = "String"; break; case PARSEOP_BUFFER: ReturnBtype = ACPI_RTYPE_BUFFER; TypeName = "Buffer"; break; case PARSEOP_PACKAGE: case PARSEOP_VAR_PACKAGE: ReturnBtype = ACPI_RTYPE_PACKAGE; TypeName = "Package"; break; case PARSEOP_NAMESEG: case PARSEOP_NAMESTRING: ReturnBtype = ACPI_RTYPE_REFERENCE; TypeName = "Reference"; break; default: /* Not one of the supported object types */ TypeName = UtGetOpName (Op->Asl.ParseOpcode); goto TypeErrorExit; } /* Exit if the object is one of the expected types */ if (ReturnBtype & ExpectedBtypes) { return (AE_OK); } TypeErrorExit: /* Format the expected types and emit an error message */ AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { sprintf (MsgBuffer, "%s: found %s, %s required", PredefinedName, TypeName, StringBuffer); } else { sprintf (MsgBuffer, "%s: found %s at index %u, %s required", PredefinedName, TypeName, PackageIndex, StringBuffer); } AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer); return (AE_TYPE); }