www.pudn.com > driver.zip > PowerManagement.c


/****************************************************************************** 
 * 
 * File Name: 
 * 
 *      PowerManagement.c 
 * 
 * Description: 
 * 
 *      Power Management functions 
 * 
 * Revision History: 
 * 
 *      10-11-07 : Silicon Image 1.00 
 * 
 ******************************************************************************/ 
 
#define INITGUID		// initialize GUID_INTERFACE_HighPoint1520 in this module 
 
#include "Sil3124.h" 
#pragma code_seg("PAGE") // start PAGE section 
/****************************************************************************** 
 * 
 * Function   :  DispatchPower 
 * 
 * Description:  Handles power requests 
 * 
 ******************************************************************************/ 
NTSTATUS DispatchPower(IN PDEVICE_OBJECT fdo, 
					   IN PIRP pIrp) 
{												//DispatchPower	 
	 
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)fdo->DeviceExtension; 
 
	NTSTATUS           status; 
	PIO_STACK_LOCATION pIrpStack; 
 
     
    pIrpStack = IoGetCurrentIrpStackLocation(pIrp); 
 
 
    DebugPrint("Sil3124: Power Start."); 
 
   status = STATUS_SUCCESS; 
    switch (pIrpStack->MinorFunction) 
    {   
    case IRP_MN_SET_POWER: 
        DebugPrint("IRP_MN_SET_POWER."); 
        if (pIrpStack->Parameters.Power.Type == SystemPowerState) 
        { 
            DebugPrint("Sil3124: SystemContext = 0x%x  SystemPowerState = 0x%x.", 
                     pIrpStack->Parameters.Power.SystemContext, 
                     pIrpStack->Parameters.Power.State.SystemState); 
        } 
        else 
        { 
            DebugPrint("Sil3124: SystemContext = 0x%x  DevicePowerState = 0x%x.", 
                     pIrpStack->Parameters.Power.SystemContext, 
                     pIrpStack->Parameters.Power.State.DeviceState); 
        } 
		 
        status = DefaultPowerHandler(fdo,pIrp); 
        break; 
 
    case IRP_MN_QUERY_POWER: 
        DebugPrint("Sil3124: IRP_MN_QUERY_POWER"); 
		 
		status = DefaultPowerHandler(fdo,pIrp); 
        break; 
	case IRP_MN_WAIT_WAKE: 
        DebugPrint("IRP_MN_WAIT_WAKE."); 
        status = DefaultPowerHandler(fdo,pIrp); 
        break; 
 
    case IRP_MN_POWER_SEQUENCE: 
        DebugPrint("IRP_MN_POWER_SEQUENCE."); 
        status = DefaultPowerHandler(fdo,pIrp); 
        break; 
    default: 
        DebugPrint("Unsupported IRP_MN_Xxx (0x%x)\n", pIrpStack->MinorFunction); 
        status = DefaultPowerHandler(fdo,pIrp); 
        break; 
    } 
 
    return status; 
	 
}											//DispatchPower 
 
/****************************************************************************** 
 * 
 * Function   :  DefaultPowerHandler 
 * 
 * Description:  Handle defaults power requests 
 * 
 ******************************************************************************/ 
 
NTSTATUS DefaultPowerHandler(IN PDEVICE_OBJECT fdo, 
							 IN PIRP pIrp) 
{											//DefaultPowerHandler 
    NTSTATUS status; 
	PoStartNextPowerIrp(pIrp);		// Must be done while we own the IRP 
         
    IoSkipCurrentIrpStackLocation(pIrp); 
	status = PoCallDriver( 
			((DEVICE_EXTENSION *)fdo->DeviceExtension)->pLowerDeviceObject,pIrp); 
	if (status == STATUS_SUCCESS) 
		DebugPrint("QueryPower Irp is success,the bus driver complete this require successfully"); 
	else if (status == STATUS_PENDING) 
		DebugPrint("QueryPower Irp has been queued.."); 
    return status; 
}											//DefaultPowerHandler 
#pragma code_seg()	// end PAGE section