kernel/acpica/components/namespace/nsprepkg.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiNsCheckPackageList
 *
 * PARAMETERS:  Info            - Method execution information block
 *              Package         - Pointer to package-specific info for method
 *              Elements        - Element list of parent package. All elements
 *                                of this list should be of type Package.
 *              Count           - Count of subpackages
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Examine a list of subpackages
 *
 ******************************************************************************/
AcpiNsCheckPackageList
PARAMETERS:  Info            - Method execution information block
Package         - Pointer to package-specific info for method
Elements        - Element list of parent package. All elements
of this list should be of type Package.
Count           - Count of subpackages

Status

Examine a list of subpackages
AcpiNsCheckPackageList PARAMETERS : Info - Method execution information block Package - Pointer to package - specific info for method Elements - Element list of parent package . All elements of this list should be of type Package . Count - Count of subpackages Status Examine a list of subpackages
static ACPI_STATUS
AcpiNsCheckPackageList (
    ACPI_EVALUATE_INFO          *Info,
    const ACPI_PREDEFINED_INFO  *Package,
    ACPI_OPERAND_OBJECT         **Elements,
    UINT32                      Count)
{
    ACPI_OPERAND_OBJECT         *SubPackage;
    ACPI_OPERAND_OBJECT         **SubElements;
    ACPI_STATUS                 Status;
    UINT32                      ExpectedCount;
    UINT32                      i;
    UINT32                      j;
    for (i = 0; i < Count; i++)
    {
        SubPackage = *Elements;
        SubElements = SubPackage->Package.Elements;
        Info->ParentPackage = SubPackage;
        Status = AcpiNsCheckObjectType (Info, &SubPackage,
            ACPI_RTYPE_PACKAGE, i);
        if (ACPI_FAILURE (Status))
        {
            return (Status);
        }
        Info->ParentPackage = SubPackage;
        switch (Package->RetInfo.Type)
        {
        case ACPI_PTYPE2:
        case ACPI_PTYPE2_PKG_COUNT:
        case ACPI_PTYPE2_REV_FIXED:
            ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
            if (SubPackage->Package.Count < ExpectedCount)
            {
                goto PackageTooSmall;
            }
            Status = AcpiNsCheckPackageElements (Info, SubElements,
                Package->RetInfo.ObjectType1,
                Package->RetInfo.Count1,
                Package->RetInfo.ObjectType2,
                Package->RetInfo.Count2, 0);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
            break;
        case ACPI_PTYPE2_FIX_VAR:
            ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
            if (SubPackage->Package.Count < ExpectedCount)
            {
                goto PackageTooSmall;
            }
            Status = AcpiNsCheckPackageElements (Info, SubElements,
                Package->RetInfo.ObjectType1,
                Package->RetInfo.Count1,
                Package->RetInfo.ObjectType2,
                SubPackage->Package.Count - Package->RetInfo.Count1, 0);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
            break;
        case ACPI_PTYPE2_VAR_VAR:
            break;
        case ACPI_PTYPE2_FIXED:
            ExpectedCount = Package->RetInfo2.Count;
            if (SubPackage->Package.Count < ExpectedCount)
            {
                goto PackageTooSmall;
            }
            for (j = 0; j < ExpectedCount; j++)
            {
                Status = AcpiNsCheckObjectType (Info, &SubElements[j],
                    Package->RetInfo2.ObjectType[j], j);
                if (ACPI_FAILURE (Status))
                {
                    return (Status);
                }
            }
            break;
        case ACPI_PTYPE2_MIN:
            ExpectedCount = Package->RetInfo.Count1;
            if (SubPackage->Package.Count < ExpectedCount)
            {
                goto PackageTooSmall;
            }
            Status = AcpiNsCheckPackageElements (Info, SubElements,
                Package->RetInfo.ObjectType1,
                SubPackage->Package.Count, 0, 0, 0);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
            break;
        case ACPI_PTYPE2_COUNT:
            Status = AcpiNsCheckObjectType (Info, SubElements,
                ACPI_RTYPE_INTEGER, 0);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
            ExpectedCount = (UINT32) (*SubElements)->Integer.Value;
            if (SubPackage->Package.Count < ExpectedCount)
            {
                goto PackageTooSmall;
            }
            if (SubPackage->Package.Count < Package->RetInfo.Count1)
            {
                ExpectedCount = Package->RetInfo.Count1;
                goto PackageTooSmall;
            }
            if (ExpectedCount == 0)
            {
                ExpectedCount = SubPackage->Package.Count;
                (*SubElements)->Integer.Value = ExpectedCount;
            }
            Status = AcpiNsCheckPackageElements (Info, (SubElements + 1),
                Package->RetInfo.ObjectType1,
                (ExpectedCount - 1), 0, 0, 1);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
            break;
        default: 
            return (AE_AML_INTERNAL);
        }
        Elements++;
    }
    return (AE_OK);
PackageTooSmall:
    ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
        "Return SubPackage[%u] is too small - found %u elements, expected %u",
        i, SubPackage->Package.Count, ExpectedCount));
    return (AE_AML_OPERAND_VALUE);
}
static ACPI_STATUS AcpiNsCheckPackageList ( ACPI_EVALUATE_INFO * Info , const ACPI_PREDEFINED_INFO * Package , ACPI_OPERAND_OBJECT * * Elements , UINT32 Count ) { ACPI_OPERAND_OBJECT * SubPackage ; ACPI_OPERAND_OBJECT * * SubElements ; ACPI_STATUS Status ; UINT32 ExpectedCount ; UINT32 i ; UINT32 j ; for ( i = 0 ; i < Count ; i ++ ) { SubPackage = * Elements ; SubElements = SubPackage -> Package . Elements ; Info -> ParentPackage = SubPackage ; Status = AcpiNsCheckObjectType ( Info , & SubPackage , ACPI_RTYPE_PACKAGE , i ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } Info -> ParentPackage = SubPackage ; switch ( Package -> RetInfo . Type ) { case ACPI_PTYPE2 : case ACPI_PTYPE2_PKG_COUNT : case ACPI_PTYPE2_REV_FIXED : ExpectedCount = Package -> RetInfo . Count1 + Package -> RetInfo . Count2 ; if ( SubPackage -> Package . Count < ExpectedCount ) { goto PackageTooSmall ; } Status = AcpiNsCheckPackageElements ( Info , SubElements , Package -> RetInfo . ObjectType1 , Package -> RetInfo . Count1 , Package -> RetInfo . ObjectType2 , Package -> RetInfo . Count2 , 0 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } break ; case ACPI_PTYPE2_FIX_VAR : ExpectedCount = Package -> RetInfo . Count1 + Package -> RetInfo . Count2 ; if ( SubPackage -> Package . Count < ExpectedCount ) { goto PackageTooSmall ; } Status = AcpiNsCheckPackageElements ( Info , SubElements , Package -> RetInfo . ObjectType1 , Package -> RetInfo . Count1 , Package -> RetInfo . ObjectType2 , SubPackage -> Package . Count - Package -> RetInfo . Count1 , 0 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } break ; case ACPI_PTYPE2_VAR_VAR : break ; case ACPI_PTYPE2_FIXED : ExpectedCount = Package -> RetInfo2 . Count ; if ( SubPackage -> Package . Count < ExpectedCount ) { goto PackageTooSmall ; } for ( j = 0 ; j < ExpectedCount ; j ++ ) { Status = AcpiNsCheckObjectType ( Info , & SubElements [ j ] , Package -> RetInfo2 . ObjectType [ j ] , j ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } } break ; case ACPI_PTYPE2_MIN : ExpectedCount = Package -> RetInfo . Count1 ; if ( SubPackage -> Package . Count < ExpectedCount ) { goto PackageTooSmall ; } Status = AcpiNsCheckPackageElements ( Info , SubElements , Package -> RetInfo . ObjectType1 , SubPackage -> Package . Count , 0 , 0 , 0 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } break ; case ACPI_PTYPE2_COUNT : Status = AcpiNsCheckObjectType ( Info , SubElements , ACPI_RTYPE_INTEGER , 0 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } ExpectedCount = ( UINT32 ) ( * SubElements ) -> Integer . Value ; if ( SubPackage -> Package . Count < ExpectedCount ) { goto PackageTooSmall ; } if ( SubPackage -> Package . Count < Package -> RetInfo . Count1 ) { ExpectedCount = Package -> RetInfo . Count1 ; goto PackageTooSmall ; } if ( ExpectedCount == 0 ) { ExpectedCount = SubPackage -> Package . Count ; ( * SubElements ) -> Integer . Value = ExpectedCount ; } Status = AcpiNsCheckPackageElements ( Info , ( SubElements + 1 ) , Package -> RetInfo . ObjectType1 , ( ExpectedCount - 1 ) , 0 , 0 , 1 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } break ; default : return ( AE_AML_INTERNAL ) ; } Elements ++ ; } return ( AE_OK ) ; PackageTooSmall : ACPI_WARN_PREDEFINED ( ( AE_INFO , Info -> FullPathname , Info -> NodeFlags , " " , i , SubPackage -> Package . Count , ExpectedCount ) ) ; return ( AE_AML_OPERAND_VALUE ) ; }
FUNCTION:    AcpiNsCheckPackageList
 PARAMETERS:  Info            - Method execution information block
              Package         - Pointer to package-specific info for method
              Elements        - Element list of parent package.
FUNCTION : AcpiNsCheckPackageList PARAMETERS : Info - Method execution information block Package - Pointer to package - specific info for method Elements - Element list of parent package .
/*
     * Validate each subpackage in the parent Package
     *
     * NOTE: assumes list of subpackages contains no NULL elements.
     * Any NULL elements should have been removed by earlier call
     * to AcpiNsRemoveNullElements.
     */ /* Each sub-object must be of type Package */ /* Examine the different types of expected subpackages */ /* Each subpackage has a fixed number of elements */ /*
             * Each subpackage has a fixed number of elements and an
             * optional element
             */ /*
             * Each subpackage has a fixed or variable number of elements
             */ /* Each subpackage has a fixed length */ /* Check the type of each subpackage element */ /* Each subpackage has a variable but minimum length */ /* Check the type of each subpackage element */ /*
             * First element is the (Integer) count of elements, including
             * the count field (the ACPI name is NumElements)
             */ /*
             * Make sure package is large enough for the Count and is
             * is as large as the minimum size
             */ /*
                 * Either the NumEntries element was originally zero or it was
                 * a NULL element and repaired to an Integer of value zero.
                 * In either case, repair it by setting NumEntries to be the
                 * actual size of the subpackage.
                 */ /* Check the type of each subpackage element */ /* Should not get here, type was validated by caller */ /* The subpackage count was smaller than required */