FreeBSD/sys/contrib/dev/acpica/components/parser/psobject.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiPsCompleteOp
 *
 * PARAMETERS:  WalkState           - Current state
 *              Op                  - Returned Op
 *              Status              - Parse status before complete Op
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Complete Op
 *
 ******************************************************************************/
AcpiPsCompleteOp
PARAMETERS:  WalkState           - Current state
Op                  - Returned Op
Status              - Parse status before complete Op

Status

Complete Op
AcpiPsCompleteOp PARAMETERS : WalkState - Current state Op - Returned Op Status - Parse status before complete Op Status Complete Op
ACPI_STATUS
AcpiPsCompleteOp (
    ACPI_WALK_STATE         *WalkState,
    ACPI_PARSE_OBJECT       **Op,
    ACPI_STATUS             Status)
{
    ACPI_STATUS             Status2;
    ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
    WalkState->ParserState.Scope->ParseScope.ArgCount--;
    Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
    if (ACPI_FAILURE (Status2))
    {
        return_ACPI_STATUS (Status2);
    }
    *Op = NULL;
    switch (Status)
    {
    case AE_OK:
        break;
    case AE_CTRL_TRANSFER:
        WalkState->PrevOp = NULL;
        WalkState->PrevArgTypes = WalkState->ArgTypes;
        return_ACPI_STATUS (Status);
    case AE_CTRL_END:
        AcpiPsPopScope (&(WalkState->ParserState), Op,
            &WalkState->ArgTypes, &WalkState->ArgCount);
        if (*Op)
        {
            WalkState->Op = *Op;
            WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
            WalkState->Opcode = (*Op)->Common.AmlOpcode;
            Status = WalkState->AscendingCallback (WalkState);
            Status = AcpiPsNextParseState (WalkState, *Op, Status);
            Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
            if (ACPI_FAILURE (Status2))
            {
                return_ACPI_STATUS (Status2);
            }
        }
        Status = AE_OK;
        break;
    case AE_CTRL_BREAK:
    case AE_CTRL_CONTINUE:
        while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
        {
            AcpiPsPopScope (&(WalkState->ParserState), Op,
                &WalkState->ArgTypes, &WalkState->ArgCount);
        }
        WalkState->Op = *Op;
        WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
        WalkState->Opcode = (*Op)->Common.AmlOpcode;
        Status = WalkState->AscendingCallback (WalkState);
        Status = AcpiPsNextParseState (WalkState, *Op, Status);
        Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
        if (ACPI_FAILURE (Status2))
        {
            return_ACPI_STATUS (Status2);
        }
        Status = AE_OK;
        break;
    case AE_CTRL_TERMINATE:
        do
        {
            if (*Op)
            {
                Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
                if (ACPI_FAILURE (Status2))
                {
                    return_ACPI_STATUS (Status2);
                }
                AcpiUtDeleteGenericState (
                    AcpiUtPopGenericState (&WalkState->ControlState));
            }
            AcpiPsPopScope (&(WalkState->ParserState), Op,
                &WalkState->ArgTypes, &WalkState->ArgCount);
        } while (*Op);
        return_ACPI_STATUS (AE_OK);
    default:  
        do
        {
            if (*Op)
            {
                Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
                if (ACPI_FAILURE (Status2))
                {
                    return_ACPI_STATUS (Status2);
                }
            }
            AcpiPsPopScope (&(WalkState->ParserState), Op,
                &WalkState->ArgTypes, &WalkState->ArgCount);
        } while (*Op);
#if 0
        if (*Op == NULL)
        {
            AcpiPsPopScope (ParserState, Op,
                &WalkState->ArgTypes, &WalkState->ArgCount);
        }
#endif
        WalkState->PrevOp = NULL;
        WalkState->PrevArgTypes = WalkState->ArgTypes;
        return_ACPI_STATUS (Status);
    }
    if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
    {
        AcpiPsPopScope (&(WalkState->ParserState), Op,
            &WalkState->ArgTypes, &WalkState->ArgCount);
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
    }
    else
    {
        *Op = NULL;
    }
    return_ACPI_STATUS (AE_OK);
}
ACPI_STATUS AcpiPsCompleteOp ( ACPI_WALK_STATE * WalkState , ACPI_PARSE_OBJECT * * Op , ACPI_STATUS Status ) { ACPI_STATUS Status2 ; ACPI_FUNCTION_TRACE_PTR ( PsCompleteOp , WalkState ) ; WalkState -> ParserState . Scope -> ParseScope . ArgCount -- ; Status2 = AcpiPsCompleteThisOp ( WalkState , * Op ) ; if ( ACPI_FAILURE ( Status2 ) ) { return_ACPI_STATUS ( Status2 ) ; } * Op = NULL ; switch ( Status ) { case AE_OK : break ; case AE_CTRL_TRANSFER : WalkState -> PrevOp = NULL ; WalkState -> PrevArgTypes = WalkState -> ArgTypes ; return_ACPI_STATUS ( Status ) ; case AE_CTRL_END : AcpiPsPopScope ( & ( WalkState -> ParserState ) , Op , & WalkState -> ArgTypes , & WalkState -> ArgCount ) ; if ( * Op ) { WalkState -> Op = * Op ; WalkState -> OpInfo = AcpiPsGetOpcodeInfo ( ( * Op ) -> Common . AmlOpcode ) ; WalkState -> Opcode = ( * Op ) -> Common . AmlOpcode ; Status = WalkState -> AscendingCallback ( WalkState ) ; Status = AcpiPsNextParseState ( WalkState , * Op , Status ) ; Status2 = AcpiPsCompleteThisOp ( WalkState , * Op ) ; if ( ACPI_FAILURE ( Status2 ) ) { return_ACPI_STATUS ( Status2 ) ; } } Status = AE_OK ; break ; case AE_CTRL_BREAK : case AE_CTRL_CONTINUE : while ( ! ( * Op ) || ( ( * Op ) -> Common . AmlOpcode != AML_WHILE_OP ) ) { AcpiPsPopScope ( & ( WalkState -> ParserState ) , Op , & WalkState -> ArgTypes , & WalkState -> ArgCount ) ; } WalkState -> Op = * Op ; WalkState -> OpInfo = AcpiPsGetOpcodeInfo ( ( * Op ) -> Common . AmlOpcode ) ; WalkState -> Opcode = ( * Op ) -> Common . AmlOpcode ; Status = WalkState -> AscendingCallback ( WalkState ) ; Status = AcpiPsNextParseState ( WalkState , * Op , Status ) ; Status2 = AcpiPsCompleteThisOp ( WalkState , * Op ) ; if ( ACPI_FAILURE ( Status2 ) ) { return_ACPI_STATUS ( Status2 ) ; } Status = AE_OK ; break ; case AE_CTRL_TERMINATE : do { if ( * Op ) { Status2 = AcpiPsCompleteThisOp ( WalkState , * Op ) ; if ( ACPI_FAILURE ( Status2 ) ) { return_ACPI_STATUS ( Status2 ) ; } AcpiUtDeleteGenericState ( AcpiUtPopGenericState ( & WalkState -> ControlState ) ) ; } AcpiPsPopScope ( & ( WalkState -> ParserState ) , Op , & WalkState -> ArgTypes , & WalkState -> ArgCount ) ; } while ( * Op ) ; return_ACPI_STATUS ( AE_OK ) ; default : do { if ( * Op ) { Status2 = AcpiPsCompleteThisOp ( WalkState , * Op ) ; if ( ACPI_FAILURE ( Status2 ) ) { return_ACPI_STATUS ( Status2 ) ; } } AcpiPsPopScope ( & ( WalkState -> ParserState ) , Op , & WalkState -> ArgTypes , & WalkState -> ArgCount ) ; } while ( * Op ) ; #if 0 if ( * Op == NULL ) { AcpiPsPopScope ( ParserState , Op , & WalkState -> ArgTypes , & WalkState -> ArgCount ) ; } #endif WalkState -> PrevOp = NULL ; WalkState -> PrevArgTypes = WalkState -> ArgTypes ; return_ACPI_STATUS ( Status ) ; } if ( AcpiPsHasCompletedScope ( & ( WalkState -> ParserState ) ) ) { AcpiPsPopScope ( & ( WalkState -> ParserState ) , Op , & WalkState -> ArgTypes , & WalkState -> ArgCount ) ; ACPI_DEBUG_PRINT ( ( ACPI_DB_PARSE , " \n " , * Op ) ) ; } else { * Op = NULL ; } return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiPsCompleteOp
 PARAMETERS:  WalkState           - Current state
              Op                  - Returned Op
              Status              - Parse status before complete Op
FUNCTION : AcpiPsCompleteOp PARAMETERS : WalkState - Current state Op - Returned Op Status - Parse status before complete Op
/*
     * Finished one argument of the containing scope
     */ /* Close this Op (will result in parse subtree deletion) */ /* We are about to transfer to a called method */ /* Pop off scopes until we find the While */ /* Close this iteration of the While loop */ /* Clean up */ /* All other non-AE_OK status */ /*
         * TBD: Cleanup parse ops on error
         */ /* This scope complete? */