FreeBSD/sys/contrib/dev/acpica/components/debugger/dbtest.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDbEvaluateOnePredefinedName
 *
 * PARAMETERS:  Callback from WalkNamespace
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Batch execution module. Currently only executes predefined
 *              ACPI names.
 *
 ******************************************************************************/


Status

Batch execution module. Currently only executes predefined
ACPI names.
Status Batch execution module . Currently only executes predefined ACPI names .
static ACPI_STATUS
AcpiDbEvaluateOnePredefinedName (
    ACPI_HANDLE             ObjHandle,
    UINT32                  NestingLevel,
    void                    *Context,
    void                    **ReturnValue)
{
    ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
    ACPI_DB_EXECUTE_WALK        *Info = (ACPI_DB_EXECUTE_WALK *) Context;
    char                        *Pathname;
    const ACPI_PREDEFINED_INFO  *Predefined;
    ACPI_DEVICE_INFO            *ObjInfo;
    ACPI_OBJECT_LIST            ParamObjects;
    ACPI_OBJECT                 Params[ACPI_METHOD_NUM_ARGS];
    ACPI_OBJECT                 *ThisParam;
    ACPI_BUFFER                 ReturnObj;
    ACPI_STATUS                 Status;
    UINT16                      ArgTypeList;
    UINT8                       ArgCount;
    UINT8                       ArgType;
    UINT32                      i;
    Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
    if (!Predefined)
    {
        return (AE_OK);
    }
    if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
    {
        return (AE_OK);
    }
    Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
    if (!Pathname)
    {
        return (AE_OK);
    }
    Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
    if (ACPI_FAILURE (Status))
    {
        ACPI_FREE (Pathname);
        return (Status);
    }
    ParamObjects.Count = 0;
    ParamObjects.Pointer = NULL;
    if (ObjInfo->Type == ACPI_TYPE_METHOD)
    {
        ArgTypeList = Predefined->Info.ArgumentList;
        ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
        ThisParam = Params;
        for (i = 0; i < ArgCount; i++)
        {
            ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
            ThisParam->Type = ArgType;
            switch (ArgType)
            {
            case ACPI_TYPE_INTEGER:
                ThisParam->Integer.Value = 1;
                break;
            case ACPI_TYPE_STRING:
                ThisParam->String.Pointer =
                    "This is the default argument string";
                ThisParam->String.Length =
                    strlen (ThisParam->String.Pointer);
                break;
            case ACPI_TYPE_BUFFER:
                ThisParam->Buffer.Pointer = (UINT8 *) Params; 
                ThisParam->Buffer.Length = 48;
                break;
             case ACPI_TYPE_PACKAGE:
                ThisParam->Package.Elements = NULL;
                ThisParam->Package.Count = 0;
                break;
           default:
                AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
                    Pathname, ArgType);
                break;
            }
            ThisParam++;
        }
        ParamObjects.Count = ArgCount;
        ParamObjects.Pointer = Params;
    }
    ACPI_FREE (ObjInfo);
    ReturnObj.Pointer = NULL;
    ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
    AcpiGbl_MethodExecuting = TRUE;
    Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
    AcpiOsPrintf ("%-32s returned %s\n",
        Pathname, AcpiFormatException (Status));
    AcpiGbl_MethodExecuting = FALSE;
    ACPI_FREE (Pathname);
    Status = AE_OK;
    Info->Count++;
    if (Info->Count >= Info->MaxCount)
    {
        Status = AE_CTRL_TERMINATE;
    }
    return (Status);
}
static ACPI_STATUS AcpiDbEvaluateOnePredefinedName ( ACPI_HANDLE ObjHandle , UINT32 NestingLevel , void * Context , void * * ReturnValue ) { ACPI_NAMESPACE_NODE * Node = ( ACPI_NAMESPACE_NODE * ) ObjHandle ; ACPI_DB_EXECUTE_WALK * Info = ( ACPI_DB_EXECUTE_WALK * ) Context ; char * Pathname ; const ACPI_PREDEFINED_INFO * Predefined ; ACPI_DEVICE_INFO * ObjInfo ; ACPI_OBJECT_LIST ParamObjects ; ACPI_OBJECT Params [ ACPI_METHOD_NUM_ARGS ] ; ACPI_OBJECT * ThisParam ; ACPI_BUFFER ReturnObj ; ACPI_STATUS Status ; UINT16 ArgTypeList ; UINT8 ArgCount ; UINT8 ArgType ; UINT32 i ; Predefined = AcpiUtMatchPredefinedMethod ( Node -> Name . Ascii ) ; if ( ! Predefined ) { return ( AE_OK ) ; } if ( Node -> Type == ACPI_TYPE_LOCAL_SCOPE ) { return ( AE_OK ) ; } Pathname = AcpiNsGetNormalizedPathname ( Node , TRUE ) ; if ( ! Pathname ) { return ( AE_OK ) ; } Status = AcpiGetObjectInfo ( ObjHandle , & ObjInfo ) ; if ( ACPI_FAILURE ( Status ) ) { ACPI_FREE ( Pathname ) ; return ( Status ) ; } ParamObjects . Count = 0 ; ParamObjects . Pointer = NULL ; if ( ObjInfo -> Type == ACPI_TYPE_METHOD ) { ArgTypeList = Predefined -> Info . ArgumentList ; ArgCount = METHOD_GET_ARG_COUNT ( ArgTypeList ) ; ThisParam = Params ; for ( i = 0 ; i < ArgCount ; i ++ ) { ArgType = METHOD_GET_NEXT_TYPE ( ArgTypeList ) ; ThisParam -> Type = ArgType ; switch ( ArgType ) { case ACPI_TYPE_INTEGER : ThisParam -> Integer . Value = 1 ; break ; case ACPI_TYPE_STRING : ThisParam -> String . Pointer = " " ; ThisParam -> String . Length = strlen ( ThisParam -> String . Pointer ) ; break ; case ACPI_TYPE_BUFFER : ThisParam -> Buffer . Pointer = ( UINT8 * ) Params ; ThisParam -> Buffer . Length = 48 ; break ; case ACPI_TYPE_PACKAGE : ThisParam -> Package . Elements = NULL ; ThisParam -> Package . Count = 0 ; break ; default : AcpiOsPrintf ( " \n " , Pathname , ArgType ) ; break ; } ThisParam ++ ; } ParamObjects . Count = ArgCount ; ParamObjects . Pointer = Params ; } ACPI_FREE ( ObjInfo ) ; ReturnObj . Pointer = NULL ; ReturnObj . Length = ACPI_ALLOCATE_BUFFER ; AcpiGbl_MethodExecuting = TRUE ; Status = AcpiEvaluateObject ( Node , NULL , & ParamObjects , & ReturnObj ) ; AcpiOsPrintf ( " \n " , Pathname , AcpiFormatException ( Status ) ) ; AcpiGbl_MethodExecuting = FALSE ; ACPI_FREE ( Pathname ) ; Status = AE_OK ; Info -> Count ++ ; if ( Info -> Count >= Info -> MaxCount ) { Status = AE_CTRL_TERMINATE ; } return ( Status ) ; }
FUNCTION:    AcpiDbEvaluateOnePredefinedName
 PARAMETERS:  Callback from WalkNamespace
FUNCTION : AcpiDbEvaluateOnePredefinedName PARAMETERS : Callback from WalkNamespace
/* The name must be a predefined ACPI name */ /* Get the object info for number of method parameters */ /* Setup default parameters (with proper types) */ /*
         * Setup the ACPI-required number of arguments, regardless of what
         * the actual method defines. If there is a difference, then the
         * method is wrong and a warning will be issued during execution.
         */ /* just a garbage buffer */ /* Do the actual method execution */ /* Ignore status from method execution */ /* Update count, check if we have executed enough methods */