static ACPI_STATUS AcpiNsCheckSortedList ( ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT *ReturnObject, UINT32 ExpectedCount, UINT32 SortIndex, UINT8 SortDirection, char *SortKeyName) { UINT32 OuterElementCount; ACPI_OPERAND_OBJECT **OuterElements; ACPI_OPERAND_OBJECT **Elements; ACPI_OPERAND_OBJECT *ObjDesc; UINT32 i; UINT32 PreviousValue; ACPI_STATUS Status; /* The top-level object must be a package */ if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) { return (AE_AML_OPERAND_TYPE); } /* * Detect any NULL package elements and remove them from the * package. * * TBD: We may want to do this for all predefined names that * return a variable-length package of packages. */ Status = AcpiNsRemoveNullElements (ReturnObject); if (Status == AE_NULL_ENTRY) { ACPI_INFO_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "NULL elements removed from package")); /* Exit if package is now zero length */ if (!ReturnObject->Package.Count) { return (AE_NULL_ENTRY); } } OuterElements = ReturnObject->Package.Elements; OuterElementCount = ReturnObject->Package.Count; if (!OuterElementCount) { return (AE_AML_PACKAGE_LIMIT); } PreviousValue = 0; if (SortDirection == ACPI_SORT_DESCENDING) { PreviousValue = ACPI_UINT32_MAX; } /* Examine each subpackage */ for (i = 0; i < OuterElementCount; i++) { /* Each element of the top-level package must also be a package */ if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE) { return (AE_AML_OPERAND_TYPE); } /* Each sub-package must have the minimum length */ if ((*OuterElements)->Package.Count < ExpectedCount) { return (AE_AML_PACKAGE_LIMIT); } Elements = (*OuterElements)->Package.Elements; ObjDesc = Elements[SortIndex]; if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { return (AE_AML_OPERAND_TYPE); } /* * The list must be sorted in the specified order. If we detect a * discrepancy, issue a warning and sort the entire list */ if (((SortDirection == ACPI_SORT_ASCENDING) && (ObjDesc->Integer.Value < PreviousValue)) || ((SortDirection == ACPI_SORT_DESCENDING) && (ObjDesc->Integer.Value > PreviousValue))) { Status = AcpiNsSortList (ReturnObject->Package.Elements, OuterElementCount, SortIndex, SortDirection); if (ACPI_FAILURE (Status)) { return (Status); } Data->Flags |= ACPI_OBJECT_REPAIRED; ACPI_INFO_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, "Repaired unsorted list - now sorted by %s", SortKeyName)); return (AE_OK); } PreviousValue = (UINT32) ObjDesc->Integer.Value; OuterElements++; } return (AE_OK); }
void AcpiNsCheckArgumentCount ( char *Pathname, ACPI_NAMESPACE_NODE *Node, UINT32 UserParamCount, const ACPI_PREDEFINED_INFO *Predefined) { UINT32 AmlParamCount; UINT32 RequiredParamCount; if (!Predefined) { /* * Not a predefined name. Check the incoming user argument count * against the count that is specified in the method/object. */ if (Node->Type != ACPI_TYPE_METHOD) { if (UserParamCount) { ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, "%u arguments were passed to a non-method ACPI object (%s)", UserParamCount, AcpiUtGetTypeName (Node->Type))); } return; } /* * This is a control method. Check the parameter count. * We can only check the incoming argument count against the * argument count declared for the method in the ASL/AML. * * Emit a message if too few or too many arguments have been passed * by the caller. * * Note: Too many arguments will not cause the method to * fail. However, the method will fail if there are too few * arguments and the method attempts to use one of the missing ones. */ AmlParamCount = Node->Object->Method.ParamCount; if (UserParamCount < AmlParamCount) { ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, "Insufficient arguments - " "Caller passed %u, method requires %u", UserParamCount, AmlParamCount)); } else if (UserParamCount > AmlParamCount) { ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, "Excess arguments - " "Caller passed %u, method requires %u", UserParamCount, AmlParamCount)); } return; } /* * This is a predefined name. Validate the user-supplied parameter * count against the ACPI specification. We don't validate against * the method itself because what is important here is that the * caller is in conformance with the spec. (The arg count for the * method was checked against the ACPI spec earlier.) * * Some methods are allowed to have a "minimum" number of args (_SCP) * because their definition in ACPI has changed over time. */ RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); if (UserParamCount < RequiredParamCount) { ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, "Insufficient arguments - " "Caller passed %u, ACPI requires %u", UserParamCount, RequiredParamCount)); } else if ((UserParamCount > RequiredParamCount) && !(Predefined->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) { ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, "Excess arguments - " "Caller passed %u, ACPI requires %u", UserParamCount, RequiredParamCount)); } }