FreeBSD/sys/contrib/dev/acpica/compiler/asloperands.c
/*******************************************************************************
 *
 * FUNCTION:    OpnDoPackage
 *
 * PARAMETERS:  Op        - The parent parse node
 *
 * RETURN:      None
 *
 * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
 *              can only be called after constants have been folded, to ensure
 *              that the PackageLength operand has been fully reduced.
 *
 ******************************************************************************/
OpnDoPackage
PARAMETERS:  Op        - The parent parse node

None

Construct the AML operands for the PACKAGE ASL keyword. NOTE:
can only be called after constants have been folded, to ensure
that the PackageLength operand has been fully reduced.
OpnDoPackage PARAMETERS : Op - The parent parse node None Construct the AML operands for the PACKAGE ASL keyword . NOTE : can only be called after constants have been folded to ensure that the PackageLength operand has been fully reduced .
void
OpnDoPackage (
    ACPI_PARSE_OBJECT       *Op)
{
    ACPI_PARSE_OBJECT       *InitializerOp;
    ACPI_PARSE_OBJECT       *PackageLengthOp;
    UINT32                  PackageLength = 0;
    PackageLengthOp = Op->Asl.Child;
    InitializerOp = PackageLengthOp->Asl.Next;
    if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
    {
        while (InitializerOp)
        {
            PackageLength++;
            InitializerOp = InitializerOp->Asl.Next;
        }
    }
    if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)      ||
        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST))
    {
        if (PackageLengthOp->Asl.Value.Integer > PackageLength)
        {
            if (PackageLength > 0)
            {
                AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT,
                    PackageLengthOp, NULL);
            }
            PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer;
        }
        else if (PackageLengthOp->Asl.Value.Integer < PackageLength)
        {
            AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG,
                PackageLengthOp, NULL);
        }
    }
    if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
    {
        Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
        Op->Asl.Child->Asl.Value.Integer = PackageLength;
        (void) OpcSetOptimalIntegerSize (Op->Asl.Child);
    }
    if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)      ||
        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)   ||
        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_ZERO)         ||
        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
    {
        if (!PackageLength)
        {
            AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH,
                PackageLengthOp, NULL);
        }
    }
    if (((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
            (Op->Asl.Child->Asl.Value.Integer <= 255))  ||
        (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONE) ||
        (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONES)||
        (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ZERO))
    {
        Op->Asl.AmlOpcode = AML_PACKAGE_OP;
        Op->Asl.ParseOpcode = PARSEOP_PACKAGE;
        PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
        PackageLengthOp->Asl.AmlLength = 1;
        PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
        PackageLengthOp->Asl.Value.Integer = PackageLength;
    }
}
void OpnDoPackage ( ACPI_PARSE_OBJECT * Op ) { ACPI_PARSE_OBJECT * InitializerOp ; ACPI_PARSE_OBJECT * PackageLengthOp ; UINT32 PackageLength = 0 ; PackageLengthOp = Op -> Asl . Child ; InitializerOp = PackageLengthOp -> Asl . Next ; if ( InitializerOp -> Asl . ParseOpcode != PARSEOP_DEFAULT_ARG ) { while ( InitializerOp ) { PackageLength ++ ; InitializerOp = InitializerOp -> Asl . Next ; } } if ( ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_INTEGER ) || ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_QWORDCONST ) ) { if ( PackageLengthOp -> Asl . Value . Integer > PackageLength ) { if ( PackageLength > 0 ) { AslError ( ASL_REMARK , ASL_MSG_LIST_LENGTH_SHORT , PackageLengthOp , NULL ) ; } PackageLength = ( UINT32 ) PackageLengthOp -> Asl . Value . Integer ; } else if ( PackageLengthOp -> Asl . Value . Integer < PackageLength ) { AslError ( ASL_ERROR , ASL_MSG_LIST_LENGTH_LONG , PackageLengthOp , NULL ) ; } } if ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_DEFAULT_ARG ) { Op -> Asl . Child -> Asl . ParseOpcode = PARSEOP_INTEGER ; Op -> Asl . Child -> Asl . Value . Integer = PackageLength ; ( void ) OpcSetOptimalIntegerSize ( Op -> Asl . Child ) ; } if ( ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_INTEGER ) || ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_QWORDCONST ) || ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_ZERO ) || ( PackageLengthOp -> Asl . ParseOpcode == PARSEOP_DEFAULT_ARG ) ) { if ( ! PackageLength ) { AslError ( ASL_REMARK , ASL_MSG_PACKAGE_LENGTH , PackageLengthOp , NULL ) ; } } if ( ( ( Op -> Asl . Child -> Asl . ParseOpcode == PARSEOP_INTEGER ) && ( Op -> Asl . Child -> Asl . Value . Integer <= 255 ) ) || ( Op -> Asl . Child -> Asl . ParseOpcode == PARSEOP_ONE ) || ( Op -> Asl . Child -> Asl . ParseOpcode == PARSEOP_ONES ) || ( Op -> Asl . Child -> Asl . ParseOpcode == PARSEOP_ZERO ) ) { Op -> Asl . AmlOpcode = AML_PACKAGE_OP ; Op -> Asl . ParseOpcode = PARSEOP_PACKAGE ; PackageLengthOp -> Asl . AmlOpcode = AML_RAW_DATA_BYTE ; PackageLengthOp -> Asl . AmlLength = 1 ; PackageLengthOp -> Asl . ParseOpcode = PARSEOP_RAW_DATA ; PackageLengthOp -> Asl . Value . Integer = PackageLength ; } }
FUNCTION:    OpnDoPackage
 PARAMETERS:  Op        - The parent parse node
FUNCTION : OpnDoPackage PARAMETERS : Op - The parent parse node
/* Opcode and package length first, followed by the initializer list */ /* Count the number of items in the initializer list */ /* The peer list contains the byte list (if any...) */ /* If package length is a constant, compare to the initializer list */ /*
             * Allow package length to be longer than the initializer
             * list -- but if the length of initializer list is nonzero,
             * issue a message since this is probably a coding error,
             * even though technically legal.
             */ /*
             * The package length is smaller than the length of the
             * initializer list. This is an error as per the ACPI spec.
             */ /*
         * This is the case if the PackageLength was left empty - Package()
         * The package length becomes the length of the initializer list
         */ /* Set the AML opcode */ /* If not a variable-length package, check for a zero package length */ /* No length AND no initializer list -- issue a remark */ /* But go ahead and put the buffer length of zero into the AML */ /*
     * If the PackageLength is a constant <= 255, we can change the
     * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
     */ /*
         * Just set the package size node to be the package length, regardless
         * of whether it was previously an integer or a default_arg placeholder
         */ /* Remaining nodes are handled via the tree walk */