AcpiGetInteger

NTSTATUS
AcpiGetInteger(
    IN PDEVICE_OBJECT pAcpiPdo,
    IN ULONG MethodName,
    IN ULONG * pValue
    )
/*++

Routine Description:

   This routine sends a request to ACPI, the parent driver, to get a
   value from the DSDT entry for the device.  The ACPI driver executes
   the specified method and this routine returns the value specified
   in the Return() statement of the method.

Arguments:

    pAcpiPdo - PDO address for the ACPI device

    MethodName - Name of the method to execute.  Note that the method
        name is specified backwards because of the use of ULONG.  Example:
        if the DSDT entry specifies Method (ICID, ...) then the ULONG value
        is L'DICI'.

    pValue - Buffer to receive the value returned by ACPI

Return Value:

    NTSTATUS code

--*/
{
    KEVENT CompletionEvent;
    IO_STATUS_BLOCK Iosb;
    PIRP pIRP;
    ACPI_EVAL_INPUT_BUFFER Request;
    ACPI_EVAL_OUTPUT_BUFFER Response;
    NTSTATUS Status;

    //
    //  Build the ACPI request to execute the specified method
    //  See: http://msdn.microsoft.com/en-us/library/ff536115(v=VS.85).aspx
    //

    Request.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE;
    Request.MethodNameAsUlong = MethodName;

    //
    //  Build the ACPI response to receive the method's value
    //  See http://msdn.microsoft.com/en-us/library/ff536123(v=VS.85).aspx
    //  and http://msdn.microsoft.com/en-us/library/ff536125(v=VS.85).aspx
    //

    Response.Signature = ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE;
    Response.Length = sizeof ( Response );
    Response.Count = DIM ( Response.Argument );

    //
    //  Initialize the completion event
    //

    KeInitializeEvent ( & CompletionEvent, SynchronizationEvent, FALSE );

    //
    //  Assume failure
    //

    Status = STATUS_INSUFFICIENT_RESOURCES;

    //
    //  Build the IRP for the ACPI driver
    //  See http://msdn.microsoft.com/en-us/library/ff536148(VS.85).aspx
    //

    pIRP = IoBuildDeviceIoControlRequest ( IOCTL_ACPI_EVAL_METHOD,
                                           pAcpiPdo,
                                           & Request,
                                           sizeof ( Request ),
                                           & Response,
                                           sizeof ( Response ),
                                           FALSE,
                                           & CompletionEvent,
                                           & Iosb );
    if ( pIRP )
    {
        //
        //  Issue the IRP to ACPI for processing
        //

        Status = IoCallDriver ( pAcpiPdo, pIRP );
        if ( STATUS_PENDING == Status )
        {
            //
            //  Wait for ACPI to finish processing the request
            //

            KeWaitForSingleObject ( & CompletionEvent,
                                    Executive,
                                    KernelMode,
                                    FALSE,
                                    NULL );
            Status = Iosb.Status;
        }

        //
        //  Verify that the operation completed successfully
        //

        if ( NT_SUCCESS ( Status ))
        {
            //
            //  Validate the return type
            //

            if (( Response.Argument [0].Type != ACPI_METHOD_ARGUMENT_INTEGER )
                || ( 4 != Response.Argument [0].DataLength ))
            {
                //
                //  Flag the bad response
                //

                Status = STATUS_INVALID_MEMBER;
            }
            else
            {
                //
                //  Return the ACPI method return value
                //

                * pValue = Response.Argument [0].Argument;
            }
        }
    }

    //
    //  Return the operation status
    //

    return Status;
}

转载于:https://www.cnblogs.com/fanzi2009/archive/2011/01/31/1948395.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值