FreeBSD/sys/contrib/dev/acpica/components/parser/psobject.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiPsCreateOp
 *
 * PARAMETERS:  WalkState           - Current state
 *              AmlOpStart          - Op start in AML
 *              NewOp               - Returned Op
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Get Op from AML
 *
 ******************************************************************************/
AcpiPsCreateOp
PARAMETERS:  WalkState           - Current state
AmlOpStart          - Op start in AML
NewOp               - Returned Op

Status

Get Op from AML
AcpiPsCreateOp PARAMETERS : WalkState - Current state AmlOpStart - Op start in AML NewOp - Returned Op Status Get Op from AML
ACPI_STATUS
AcpiPsCreateOp (
    ACPI_WALK_STATE         *WalkState,
    UINT8                   *AmlOpStart,
    ACPI_PARSE_OBJECT       **NewOp)
{
    ACPI_STATUS             Status = AE_OK;
    ACPI_PARSE_OBJECT       *Op;
    ACPI_PARSE_OBJECT       *NamedOp = NULL;
    ACPI_PARSE_OBJECT       *ParentScope;
    UINT8                   ArgumentCount;
    const ACPI_OPCODE_INFO  *OpInfo;
    ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
    Status = AcpiPsGetAmlOpcode (WalkState);
    if (Status == AE_CTRL_PARSE_CONTINUE)
    {
        return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
    }
    WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
    Op = AcpiPsAllocOp (WalkState->Opcode, AmlOpStart);
    if (!Op)
    {
        return_ACPI_STATUS (AE_NO_MEMORY);
    }
    if (WalkState->OpInfo->Flags & AML_NAMED)
    {
        Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
        AcpiPsFreeOp (Op);
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
        }
        *NewOp = NamedOp;
        return_ACPI_STATUS (AE_OK);
    }
    if (WalkState->OpInfo->Flags & AML_CREATE)
    {
        Op->Named.Data = AmlOpStart;
        Op->Named.Length = 0;
    }
    if (WalkState->Opcode == AML_BANK_FIELD_OP)
    {
        Op->Named.Data = AmlOpStart;
        Op->Named.Length = 0;
    }
    ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
    AcpiPsAppendArg (ParentScope, Op);
    if (ParentScope)
    {
        OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
        if (OpInfo->Flags & AML_HAS_TARGET)
        {
            ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
            if (ParentScope->Common.ArgListLength > ArgumentCount)
            {
                Op->Common.Flags |= ACPI_PARSEOP_TARGET;
            }
        }
        else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP)
        {
            Op->Common.Flags |= ACPI_PARSEOP_TARGET;
        }
    }
    if (WalkState->DescendingCallback != NULL)
    {
        WalkState->Op = *NewOp = Op;
        Status = WalkState->DescendingCallback (WalkState, &Op);
        Status = AcpiPsNextParseState (WalkState, Op, Status);
        if (Status == AE_CTRL_PENDING)
        {
            Status = AE_CTRL_PARSE_PENDING;
        }
    }
    return_ACPI_STATUS (Status);
}
ACPI_STATUS AcpiPsCreateOp ( ACPI_WALK_STATE * WalkState , UINT8 * AmlOpStart , ACPI_PARSE_OBJECT * * NewOp ) { ACPI_STATUS Status = AE_OK ; ACPI_PARSE_OBJECT * Op ; ACPI_PARSE_OBJECT * NamedOp = NULL ; ACPI_PARSE_OBJECT * ParentScope ; UINT8 ArgumentCount ; const ACPI_OPCODE_INFO * OpInfo ; ACPI_FUNCTION_TRACE_PTR ( PsCreateOp , WalkState ) ; Status = AcpiPsGetAmlOpcode ( WalkState ) ; if ( Status == AE_CTRL_PARSE_CONTINUE ) { return_ACPI_STATUS ( AE_CTRL_PARSE_CONTINUE ) ; } WalkState -> OpInfo = AcpiPsGetOpcodeInfo ( WalkState -> Opcode ) ; Op = AcpiPsAllocOp ( WalkState -> Opcode , AmlOpStart ) ; if ( ! Op ) { return_ACPI_STATUS ( AE_NO_MEMORY ) ; } if ( WalkState -> OpInfo -> Flags & AML_NAMED ) { Status = AcpiPsBuildNamedOp ( WalkState , AmlOpStart , Op , & NamedOp ) ; AcpiPsFreeOp ( Op ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } * NewOp = NamedOp ; return_ACPI_STATUS ( AE_OK ) ; } if ( WalkState -> OpInfo -> Flags & AML_CREATE ) { Op -> Named . Data = AmlOpStart ; Op -> Named . Length = 0 ; } if ( WalkState -> Opcode == AML_BANK_FIELD_OP ) { Op -> Named . Data = AmlOpStart ; Op -> Named . Length = 0 ; } ParentScope = AcpiPsGetParentScope ( & ( WalkState -> ParserState ) ) ; AcpiPsAppendArg ( ParentScope , Op ) ; if ( ParentScope ) { OpInfo = AcpiPsGetOpcodeInfo ( ParentScope -> Common . AmlOpcode ) ; if ( OpInfo -> Flags & AML_HAS_TARGET ) { ArgumentCount = AcpiPsGetArgumentCount ( OpInfo -> Type ) ; if ( ParentScope -> Common . ArgListLength > ArgumentCount ) { Op -> Common . Flags |= ACPI_PARSEOP_TARGET ; } } else if ( ParentScope -> Common . AmlOpcode == AML_INCREMENT_OP ) { Op -> Common . Flags |= ACPI_PARSEOP_TARGET ; } } if ( WalkState -> DescendingCallback != NULL ) { WalkState -> Op = * NewOp = Op ; Status = WalkState -> DescendingCallback ( WalkState , & Op ) ; Status = AcpiPsNextParseState ( WalkState , Op , Status ) ; if ( Status == AE_CTRL_PENDING ) { Status = AE_CTRL_PARSE_PENDING ; } } return_ACPI_STATUS ( Status ) ; }
FUNCTION:    AcpiPsCreateOp
 PARAMETERS:  WalkState           - Current state
              AmlOpStart          - Op start in AML
              NewOp               - Returned Op
FUNCTION : AcpiPsCreateOp PARAMETERS : WalkState - Current state AmlOpStart - Op start in AML NewOp - Returned Op
/* Create Op structure and append to parent's argument list */ /* Not a named opcode, just allocate Op and append to parent */ /*
         * Backup to beginning of CreateXXXfield declaration
         * BodyLength is unknown until we parse the body
         */ /*
         * Backup to beginning of BankField declaration
         * BodyLength is unknown until we parse the body
         */ /*
         * Find the object. This will either insert the object into
         * the namespace or simply look it up
         */