FreeBSD/sys/contrib/dev/acpica/components/parser/psxface.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiPsExecuteMethod
 *
 * PARAMETERS:  Info            - Method info block, contains:
 *                  Node            - Method Node to execute
 *                  ObjDesc         - Method object
 *                  Parameters      - List of parameters to pass to the method,
 *                                    terminated by NULL. Params itself may be
 *                                    NULL if no parameters are being passed.
 *                  ReturnObject    - Where to put method's return value (if
 *                                    any). If NULL, no value is returned.
 *                  ParameterType   - Type of Parameter list
 *                  ReturnObject    - Where to put method's return value (if
 *                                    any). If NULL, no value is returned.
 *                  PassNumber      - Parse or execute pass
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Execute a control method
 *
 ******************************************************************************/
AcpiPsExecuteMethod
PARAMETERS:  Info            - Method info block, contains:
Node            - Method Node to execute
ObjDesc         - Method object
Parameters      - List of parameters to pass to the method,
terminated by NULL. Params itself may be
NULL if no parameters are being passed.
ReturnObject    - Where to put method's return value (if
any). If NULL, no value is returned.
ParameterType   - Type of Parameter list
ReturnObject    - Where to put method's return value (if
any). If NULL, no value is returned.
PassNumber      - Parse or execute pass

Status

Execute a control method
AcpiPsExecuteMethod PARAMETERS : Info - Method info block contains : Node - Method Node to execute ObjDesc - Method object Parameters - List of parameters to pass to the method terminated by NULL . Params itself may be NULL if no parameters are being passed . ReturnObject - Where to put method ' s return value ( if any ) . If NULL no value is returned . ParameterType - Type of Parameter list ReturnObject - Where to put method ' s return value ( if any ) . If NULL no value is returned . PassNumber - Parse or execute pass Status Execute a control method
ACPI_STATUS
AcpiPsExecuteMethod (
    ACPI_EVALUATE_INFO      *Info)
{
    ACPI_STATUS             Status;
    ACPI_PARSE_OBJECT       *Op;
    ACPI_WALK_STATE         *WalkState;
    ACPI_FUNCTION_TRACE (PsExecuteMethod);
    AcpiTbCheckDsdtHeader ();
    if (!Info || !Info->Node)
    {
        return_ACPI_STATUS (AE_NULL_ENTRY);
    }
    Status = AcpiDsBeginMethodExecution (Info->Node, Info->ObjDesc, NULL);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    AcpiPsUpdateParameterList (Info, REF_INCREMENT);
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
        "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
        Info->Node->Name.Ascii, Info->Node, Info->ObjDesc));
    Op = AcpiPsCreateScopeOp (Info->ObjDesc->Method.AmlStart);
    if (!Op)
    {
        Status = AE_NO_MEMORY;
        goto Cleanup;
    }
    Info->PassNumber = ACPI_IMODE_EXECUTE;
    WalkState = AcpiDsCreateWalkState (
        Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
    if (!WalkState)
    {
        Status = AE_NO_MEMORY;
        goto Cleanup;
    }
    Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
        Info->ObjDesc->Method.AmlStart,
        Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
    if (ACPI_FAILURE (Status))
    {
        AcpiDsDeleteWalkState (WalkState);
        goto Cleanup;
    }
    if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
    {
        WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
    }
    if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
    {
        Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
        Info->ReturnObject = WalkState->ReturnDesc;
        AcpiDsScopeStackClear (WalkState);
        AcpiPsCleanupScope (&WalkState->ParserState);
        AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
        AcpiDsDeleteWalkState (WalkState);
        goto Cleanup;
    }
    if (AcpiGbl_EnableInterpreterSlack)
    {
        WalkState->ImplicitReturnObj =
            AcpiUtCreateIntegerObject ((UINT64) 0);
        if (!WalkState->ImplicitReturnObj)
        {
            Status = AE_NO_MEMORY;
            AcpiDsDeleteWalkState (WalkState);
            goto Cleanup;
        }
    }
    Status = AcpiPsParseAml (WalkState);
Cleanup:
    AcpiPsDeleteParseTree (Op);
    AcpiPsUpdateParameterList (Info, REF_DECREMENT);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    if (Info->ReturnObject)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
            Info->ReturnObject));
        ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
        Status = AE_CTRL_RETURN_VALUE;
    }
    return_ACPI_STATUS (Status);
}
ACPI_STATUS AcpiPsExecuteMethod ( ACPI_EVALUATE_INFO * Info ) { ACPI_STATUS Status ; ACPI_PARSE_OBJECT * Op ; ACPI_WALK_STATE * WalkState ; ACPI_FUNCTION_TRACE ( PsExecuteMethod ) ; AcpiTbCheckDsdtHeader ( ) ; if ( ! Info || ! Info -> Node ) { return_ACPI_STATUS ( AE_NULL_ENTRY ) ; } Status = AcpiDsBeginMethodExecution ( Info -> Node , Info -> ObjDesc , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } AcpiPsUpdateParameterList ( Info , REF_INCREMENT ) ; ACPI_DEBUG_PRINT ( ( ACPI_DB_PARSE , " \n " , Info -> Node -> Name . Ascii , Info -> Node , Info -> ObjDesc ) ) ; Op = AcpiPsCreateScopeOp ( Info -> ObjDesc -> Method . AmlStart ) ; if ( ! Op ) { Status = AE_NO_MEMORY ; goto Cleanup ; } Info -> PassNumber = ACPI_IMODE_EXECUTE ; WalkState = AcpiDsCreateWalkState ( Info -> ObjDesc -> Method . OwnerId , NULL , NULL , NULL ) ; if ( ! WalkState ) { Status = AE_NO_MEMORY ; goto Cleanup ; } Status = AcpiDsInitAmlWalk ( WalkState , Op , Info -> Node , Info -> ObjDesc -> Method . AmlStart , Info -> ObjDesc -> Method . AmlLength , Info , Info -> PassNumber ) ; if ( ACPI_FAILURE ( Status ) ) { AcpiDsDeleteWalkState ( WalkState ) ; goto Cleanup ; } if ( Info -> ObjDesc -> Method . InfoFlags & ACPI_METHOD_MODULE_LEVEL ) { WalkState -> ParseFlags |= ACPI_PARSE_MODULE_LEVEL ; } if ( Info -> ObjDesc -> Method . InfoFlags & ACPI_METHOD_INTERNAL_ONLY ) { Status = Info -> ObjDesc -> Method . Dispatch . Implementation ( WalkState ) ; Info -> ReturnObject = WalkState -> ReturnDesc ; AcpiDsScopeStackClear ( WalkState ) ; AcpiPsCleanupScope ( & WalkState -> ParserState ) ; AcpiDsTerminateControlMethod ( WalkState -> MethodDesc , WalkState ) ; AcpiDsDeleteWalkState ( WalkState ) ; goto Cleanup ; } if ( AcpiGbl_EnableInterpreterSlack ) { WalkState -> ImplicitReturnObj = AcpiUtCreateIntegerObject ( ( UINT64 ) 0 ) ; if ( ! WalkState -> ImplicitReturnObj ) { Status = AE_NO_MEMORY ; AcpiDsDeleteWalkState ( WalkState ) ; goto Cleanup ; } } Status = AcpiPsParseAml ( WalkState ) ; Cleanup : AcpiPsDeleteParseTree ( Op ) ; AcpiPsUpdateParameterList ( Info , REF_DECREMENT ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } if ( Info -> ReturnObject ) { ACPI_DEBUG_PRINT ( ( ACPI_DB_PARSE , " \n " , Info -> ReturnObject ) ) ; ACPI_DUMP_STACK_ENTRY ( Info -> ReturnObject ) ; Status = AE_CTRL_RETURN_VALUE ; } return_ACPI_STATUS ( Status ) ; }
FUNCTION:    AcpiPsExecuteMethod
 PARAMETERS:  Info            - Method info block, contains:
                  Node            - Method Node to execute
                  ObjDesc         - Method object
                  Parameters      - List of parameters to pass to the method,
                                    terminated by NULL.
FUNCTION : AcpiPsExecuteMethod PARAMETERS : Info - Method info block contains : Node - Method Node to execute ObjDesc - Method object Parameters - List of parameters to pass to the method terminated by NULL .
/* Quick validation of DSDT header */ /* Validate the Info and method Node */ /* Init for new method, wait on concurrency semaphore */ /*
     * The caller "owns" the parameters, so give each one an extra reference
     */ /*
     * Execute the method. Performs parse simultaneously
     */ /* Create and init a Root Node */ /* Create and initialize a new walk state */ /* Invoke an internal method if necessary */ /* Cleanup states */ /*
     * Start method evaluation with an implicit return of zero.
     * This is done for Windows compatibility.
     */ /* Parse the AML */ /* WalkState was deleted by ParseAml */ /* Take away the extra reference that we gave the parameters above */ /* Exit now if error above */ /*
     * If the method has returned an object, signal this to the caller with
     * a control exception code
     */