FreeBSD/sys/contrib/dev/acpica/compiler/asloperands.c
/*******************************************************************************
 *
 * FUNCTION:    OpnDoBuffer
 *
 * PARAMETERS:  Op        - The parent parse node
 *
 * RETURN:      None
 *
 * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
 *              build a single raw byte buffer from the initialization nodes,
 *              each parse node contains a buffer byte.
 *
 ******************************************************************************/
OpnDoBuffer
PARAMETERS:  Op        - The parent parse node

None

Construct the AML operands for the BUFFER ASL keyword. We
build a single raw byte buffer from the initialization nodes,
each parse node contains a buffer byte.
OpnDoBuffer PARAMETERS : Op - The parent parse node None Construct the AML operands for the BUFFER ASL keyword . We build a single raw byte buffer from the initialization nodes each parse node contains a buffer byte .
static void
OpnDoBuffer (
    ACPI_PARSE_OBJECT       *Op)
{
    ACPI_PARSE_OBJECT       *InitializerOp;
    ACPI_PARSE_OBJECT       *BufferLengthOp;
    UINT32                  BufferLength = 0;
    BufferLengthOp = Op->Asl.Child;
    InitializerOp = BufferLengthOp->Asl.Next;
    if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
        (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
    {
        return;
    }
    switch (InitializerOp->Asl.ParseOpcode)
    {
    case PARSEOP_INTEGER:
    case PARSEOP_BYTECONST:
    case PARSEOP_WORDCONST:
    case PARSEOP_DWORDCONST:
        while (InitializerOp)
        {
            InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
            InitializerOp->Asl.AmlLength = 1;
            InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
            BufferLength++;
            InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
        }
        break;
    case PARSEOP_STRING_LITERAL:
        BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
        InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
        InitializerOp->Asl.AmlLength = BufferLength;
        InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
        break;
    case PARSEOP_RAW_DATA:
        return;
    case PARSEOP_DEFAULT_ARG:
        break;
    default:
        AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
            "Unknown buffer initializer opcode");
        printf ("Unknown buffer initializer opcode [%s]\n",
            UtGetOpName (InitializerOp->Asl.ParseOpcode));
        return;
    }
    if (BufferLengthOp->Asl.Value.Integer > BufferLength)
    {
        BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
    }
    if (!BufferLength)
    {
        AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
    }
    BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
    BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
    BufferLengthOp->Asl.Value.Integer = BufferLength;
    (void) OpcSetOptimalIntegerSize (BufferLengthOp);
}
static void OpnDoBuffer ( ACPI_PARSE_OBJECT * Op ) { ACPI_PARSE_OBJECT * InitializerOp ; ACPI_PARSE_OBJECT * BufferLengthOp ; UINT32 BufferLength = 0 ; BufferLengthOp = Op -> Asl . Child ; InitializerOp = BufferLengthOp -> Asl . Next ; if ( ( BufferLengthOp -> Asl . ParseOpcode != PARSEOP_INTEGER ) && ( BufferLengthOp -> Asl . ParseOpcode != PARSEOP_DEFAULT_ARG ) ) { return ; } switch ( InitializerOp -> Asl . ParseOpcode ) { case PARSEOP_INTEGER : case PARSEOP_BYTECONST : case PARSEOP_WORDCONST : case PARSEOP_DWORDCONST : while ( InitializerOp ) { InitializerOp -> Asl . AmlOpcode = AML_RAW_DATA_BYTE ; InitializerOp -> Asl . AmlLength = 1 ; InitializerOp -> Asl . ParseOpcode = PARSEOP_RAW_DATA ; BufferLength ++ ; InitializerOp = ASL_GET_PEER_NODE ( InitializerOp ) ; } break ; case PARSEOP_STRING_LITERAL : BufferLength = strlen ( InitializerOp -> Asl . Value . String ) + 1 ; InitializerOp -> Asl . AmlOpcode = AML_RAW_DATA_BUFFER ; InitializerOp -> Asl . AmlLength = BufferLength ; InitializerOp -> Asl . ParseOpcode = PARSEOP_RAW_DATA ; break ; case PARSEOP_RAW_DATA : return ; case PARSEOP_DEFAULT_ARG : break ; default : AslError ( ASL_ERROR , ASL_MSG_INVALID_OPERAND , InitializerOp , " " ) ; printf ( " \n " , UtGetOpName ( InitializerOp -> Asl . ParseOpcode ) ) ; return ; } if ( BufferLengthOp -> Asl . Value . Integer > BufferLength ) { BufferLength = ( UINT32 ) BufferLengthOp -> Asl . Value . Integer ; } if ( ! BufferLength ) { AslError ( ASL_REMARK , ASL_MSG_BUFFER_LENGTH , BufferLengthOp , NULL ) ; } BufferLengthOp -> Asl . ParseOpcode = PARSEOP_INTEGER ; BufferLengthOp -> Asl . AmlOpcode = AML_DWORD_OP ; BufferLengthOp -> Asl . Value . Integer = BufferLength ; ( void ) OpcSetOptimalIntegerSize ( BufferLengthOp ) ; }
FUNCTION:    OpnDoBuffer
 PARAMETERS:  Op        - The parent parse node
FUNCTION : OpnDoBuffer PARAMETERS : Op - The parent parse node
/* Optional arguments for this opcode with defaults */ /* Opcode and package length first */ /* Buffer Length is next, followed by the initializer list */ /*
     * If the BufferLength is not an INTEGER or was not specified in the ASL
     * (DEFAULT_ARG), it is a TermArg that is
     * evaluated at run-time, and we are therefore finished.
     */ /*
     * We want to count the number of items in the initializer list, because if
     * it is larger than the buffer length, we will define the buffer size
     * to be the size of the initializer list (as per the ACPI Specification)
     */ /* The peer list contains the byte list (if any...) */ /* For buffers, this is a list of raw bytes */ /*
         * Only one initializer, the string. Buffer must be big enough to hold
         * the string plus the null termination byte
         */ /* Buffer nodes are already initialized (e.g. Unicode operator) */ /* Check if initializer list is longer than the buffer length */ /* No length AND no items -- issue notice */ /* But go ahead and put the buffer length of zero into the AML */ /*
     * Just set the buffer size node to be the buffer length, regardless
     * of whether it was previously an integer or a default_arg placeholder
     */ /* Remaining nodes are handled via the tree walk */