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