亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sspwr.c

?? WINDDK開發代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2000 Microsoft Corporation

Module Name:

    sSPwr.c

Abstract:

    The power management related processing.

    The Power Manager uses IRPs to direct drivers to change system
    and device power levels, to respond to system wake-up events,
    and to query drivers about their devices. All power IRPs have
    the major function code IRP_MJ_POWER.

    Most function and filter drivers perform some processing for
    each power IRP, then pass the IRP down to the next lower driver
    without completing it. Eventually the IRP reaches the bus driver,
    which physically changes the power state of the device and completes
    the IRP.

    When the IRP has been completed, the I/O Manager calls any
    IoCompletion routines set by drivers as the IRP traveled
    down the device stack. Whether a driver needs to set a completion
    routine depends upon the type of IRP and the driver's individual
    requirements.

    This code is not USB specific. It is essential for every WDM driver
    to handle power irps.

Environment:

    Kernel mode

Notes:

    Copyright (c) 2000 Microsoft Corporation.  
    All Rights Reserved.

--*/

#include "selSusp.h"
#include "sSPwr.h"
#include "sSPnP.h"
#include "sSDevCtr.h"
#include "sSUsr.h"
#include "sSWmi.h"

NTSTATUS
SS_DispatchPower(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
/*++
 
Routine Description:

    The power dispatch routine.

Arguments:

    DeviceObject - pointer to a device object.

    Irp - pointer to an I/O Request Packet.

Return Value:

    NT status code

--*/
{
    NTSTATUS           ntStatus;
    PIO_STACK_LOCATION irpStack;
    PUNICODE_STRING    tagString;
    PDEVICE_EXTENSION  deviceExtension;
	
    //
    // initialize the variables
    //
	
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;

    //
    // We don't queue power Irps, we'll only check if the
    // device was removed, otherwise we'll take appropriate
    // action and send it to the next lower driver. In general
    // drivers should not cause long delays while handling power
    // IRPs. If a driver cannot handle a power IRP in a brief time,
    // it should return STATUS_PENDING and queue all incoming
    // IRPs until the IRP completes.
    //

    if(Removed == deviceExtension->DeviceState) {

        //
        // Even if a driver fails the IRP, it must nevertheless call
        // PoStartNextPowerIrp to inform the Power Manager that it
        // is ready to handle another power IRP.
        //

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_DELETE_PENDING;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        return ntStatus;
    }

    if(NotStarted == deviceExtension->DeviceState) {

        //
        // if the device is not started yet, pass it down
        //

        PoStartNextPowerIrp(Irp);

        IoSkipCurrentIrpStackLocation(Irp);

        return PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);
    }

    SSDbgPrint(3, ("SS_DispatchPower::"));
    SSIoIncrement(deviceExtension);
    
    switch(irpStack->MinorFunction) {
    
    case IRP_MN_SET_POWER:

        //
        // The Power Manager sends this IRP for one of the
        // following reasons:
        // 1) To notify drivers of a change to the system power state.
        // 2) To change the power state of a device for which
        //    the Power Manager is performing idle detection.
        // A driver sends IRP_MN_SET_POWER to change the power
        // state of its device if it's a power policy owner for the
        // device.
        //

        //
        // Mark the Irp as pending and return STATUS_PENDING if we change the 
        // nature of the irp in the completion routine (asynchroniticity).
        // In such cases, do not return the status returned by the lower driver.
        // returning STATUS_MORE_PROCESSING_REQUIRED in the completion routine 
        // transforms the nature of the irp to asynchronous irp.
        //

        IoMarkIrpPending(Irp);

        switch(irpStack->Parameters.Power.Type) {

        case SystemPowerState:

            HandleSystemSetPower(DeviceObject, Irp);

            ntStatus = STATUS_PENDING;

            break;

        case DevicePowerState:

            HandleDeviceSetPower(DeviceObject, Irp);

            ntStatus = STATUS_PENDING;

            break;
        }

        break;

    case IRP_MN_QUERY_POWER:

        //
        // The Power Manager sends a power IRP with the minor
        // IRP code IRP_MN_QUERY_POWER to determine whether it
        // can safely change to the specified system power state
        // (S1-S5) and to allow drivers to prepare for such a change.
        // If a driver can put its device in the requested state,
        // it sets status to STATUS_SUCCESS and passes the IRP down.
        //

        IoMarkIrpPending(Irp);
    
        switch(irpStack->Parameters.Power.Type) {

        case SystemPowerState:
            
            HandleSystemQueryPower(DeviceObject, Irp);

            ntStatus = STATUS_PENDING;

            break;

        case DevicePowerState:

            HandleDeviceQueryPower(DeviceObject, Irp);

            ntStatus = STATUS_PENDING;

            break;
        }

        break;

    case IRP_MN_WAIT_WAKE:

        //
        // The minor power IRP code IRP_MN_WAIT_WAKE provides
        // for waking a device or waking the system. Drivers
        // of devices that can wake themselves or the system
        // send IRP_MN_WAIT_WAKE. The system sends IRP_MN_WAIT_WAKE
        // only to devices that always wake the system, such as
        // the power-on switch.
        //

        IoMarkIrpPending(Irp);

        IoCopyCurrentIrpStackLocationToNext(Irp);

        IoSetCompletionRoutine(
                        Irp,
                        (PIO_COMPLETION_ROUTINE)WaitWakeCompletionRoutine,
                        deviceExtension, 
                        TRUE, 
                        TRUE, 
                        TRUE);

        PoStartNextPowerIrp(Irp);

        ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

        if(!NT_SUCCESS(ntStatus)) {

            SSDbgPrint(1, ("Lower drivers failed the IRP_MN_WAIT_WAKE Irp"));
        }

        //
        // since we marked the Irp as pending; we should return STATUS_PENDING
        //
        ntStatus = STATUS_PENDING;

        //
        // push back the count HERE and NOT in completion routine
        // a pending Wait Wake Irp should not impede stopping the device
        //

        SSDbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
        SSIoDecrement(deviceExtension);

        break;

    case IRP_MN_POWER_SEQUENCE:

        //
        // A driver sends this IRP as an optimization to determine
        // whether its device actually entered a specific power state.
        // This IRP is optional. Power Manager cannot send this IRP.
        //

    default:

        PoStartNextPowerIrp(Irp);

        IoSkipCurrentIrpStackLocation(Irp);

        ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

        if(!NT_SUCCESS(ntStatus)) {

            SSDbgPrint(1, ("Lower drivers failed this Irp"));
        }
        
        SSDbgPrint(3, ("SS_DispatchPower::"));
        SSIoDecrement(deviceExtension);

        break;
    }

    return ntStatus;
}

NTSTATUS
HandleSystemQueryPower(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
/*++
 
Routine Description:

    This routine handles the irp with minor function of type IRP_MN_QUERY_POWER
    for the system power states.

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet sent by the power manager.

Return Value:

    NT status value

--*/
{
    NTSTATUS           ntStatus;
    PDEVICE_EXTENSION  deviceExtension;
    SYSTEM_POWER_STATE systemState;
    PIO_STACK_LOCATION irpStack;
    
    SSDbgPrint(3, ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    systemState = irpStack->Parameters.Power.State.SystemState;

    //
    // Fail a query for a power state incompatible with waking up the system
    //

    SSDbgPrint(3, ("Query for a system power state S%X\n"
                   "Current system power state S%X\n",
                   systemState - 1,
                   deviceExtension->SysPower - 1));

    if((deviceExtension->WaitWakeEnable) &&
       (systemState > deviceExtension->DeviceCapabilities.SystemWake)) {

        SSDbgPrint(3, ("query for an incompatible power state\n"));

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        SSDbgPrint(3, ("HandleSystemQueryPower::"));
        SSIoDecrement(deviceExtension);

        return ntStatus;
    }

    //
    // if querying for a lower S-state, issue a wait-wake
    // also, it is mandatory to have this Irp pending below
    // before we send any of the low power irps.
    //

    if((systemState > deviceExtension->SysPower) &&
       (deviceExtension->WaitWakeEnable)) {

        IssueWaitWake(deviceExtension);
    }

    IoCopyCurrentIrpStackLocationToNext(Irp);

    IoSetCompletionRoutine(
            Irp, 
            (PIO_COMPLETION_ROUTINE)SysPoCompletionRoutine,
            deviceExtension, 
            TRUE, 
            TRUE, 
            TRUE);

    ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

    SSDbgPrint(3, ("HandleSystemQueryPower - ends\n"));

    return STATUS_PENDING;
}

NTSTATUS
HandleSystemSetPower(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
/*++
 
Routine Description:

    This routine services irps of minor type IRP_MN_SET_POWER
    for the system power state

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet sent by the power manager

Return Value:

    NT status value

--*/
{
    NTSTATUS           ntStatus;
    PDEVICE_EXTENSION  deviceExtension;
    SYSTEM_POWER_STATE systemState;
    PIO_STACK_LOCATION irpStack;
    
    SSDbgPrint(3, ("HandleSystemSetPower - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    systemState = irpStack->Parameters.Power.State.SystemState;

    SSDbgPrint(3, ("Set request for a system power state S%X\n"
                   "Current system power state S%X\n", 
                   systemState - 1,
                   deviceExtension->SysPower - 1));

    //
    // pass the irp down the stack
    //
    IoCopyCurrentIrpStackLocationToNext(Irp);

    IoSetCompletionRoutine(
            Irp, 
            (PIO_COMPLETION_ROUTINE)SysPoCompletionRoutine,
            deviceExtension, 
            TRUE, 
            TRUE, 
            TRUE);

    ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

    SSDbgPrint(3, ("HandleSystemSetPower - ends\n"));

    return STATUS_PENDING;
}

NTSTATUS
HandleDeviceQueryPower(
    PDEVICE_OBJECT DeviceObject,
    PIRP           Irp
    )
/*++

Routine Description:

    This routine services irps of minor type IRP_MN_QUERY_POWER
    for the device power state

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet sent by the power manager

Return Value:

    NT status value

--*/
{
    NTSTATUS           ntStatus;
    PDEVICE_EXTENSION  deviceExtension;
    PIO_STACK_LOCATION irpStack;
    DEVICE_POWER_STATE deviceState;

    SSDbgPrint(3, ("HandleDeviceQueryPower - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    deviceState = irpStack->Parameters.Power.State.DeviceState;

    SSDbgPrint(3, ("Query for a device power state D%X\n"
                   "Current device power state D%X\n", 
                   deviceState - 1,
                   deviceExtension->DevPower - 1));

    if(deviceExtension->WaitWakeEnable &&
       deviceState > deviceExtension->DeviceCapabilities.DeviceWake) {

        SSDbgPrint(3, ("query for an incompatible power state\n"));

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        SSDbgPrint(3, ("HandleDeviceQueryPower::"));
        SSIoDecrement(deviceExtension);

        return ntStatus;
    }

    if(deviceState < deviceExtension->DevPower) {

        ntStatus = STATUS_SUCCESS;
    }
    else {

        ntStatus = HoldIoRequests(DeviceObject, Irp);

        if(STATUS_PENDING == ntStatus) {

            return ntStatus;
        }
    }

    //
    // on error complete the Irp.
    // on success pass it to the lower layers
    //

    PoStartNextPowerIrp(Irp);

    Irp->IoStatus.Status = ntStatus;
    Irp->IoStatus.Information = 0;

    if(!NT_SUCCESS(ntStatus)) {

        IoCompleteRequest(Irp, IO_NO_INCREMENT);
    }
    else {

        IoSkipCurrentIrpStackLocation(Irp);

        ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);
    }

    SSDbgPrint(3, ("HandleDeviceQueryPower::"));
    SSIoDecrement(deviceExtension);

    SSDbgPrint(3, ("HandleDeviceQueryPower - ends\n"));

    return ntStatus;
}


NTSTATUS
SysPoCompletionRoutine(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp,
    IN PDEVICE_EXTENSION DeviceExtension
    )
/*++
 
Routine Description:

    This is the completion routine for the system power irps of minor
    function types IRP_MN_QUERY_POWER and IRP_MN_SET_POWER.
    This completion routine sends the corresponding device power irp and
    returns STATUS_MORE_PROCESSING_REQUIRED. The system irp is passed as a
    context to the device power irp completion routine and is completed in
    the device power irp completion routine.

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区电影| 91久久国产最好的精华液| 青青草原综合久久大伊人精品| 亚洲国产日韩精品| 亚洲一区二区综合| 麻豆国产精品一区二区三区| 国产一本一道久久香蕉| 99国产精品一区| 欧美精品99久久久**| 2020国产精品久久精品美国| 久久日韩精品一区二区五区| 国产精品久久久久9999吃药| 亚洲午夜久久久久久久久电影院 | 久99久精品视频免费观看| 91丨九色丨蝌蚪富婆spa| 日韩女同互慰一区二区| 国产精品久久午夜| 久久97超碰色| 在线不卡一区二区| 亚洲视频在线观看三级| 久久99精品久久只有精品| 91免费观看视频| 精品国产乱码久久| 亚洲18色成人| 欧美在线播放高清精品| 亚洲国产精品ⅴa在线观看| 石原莉奈在线亚洲二区| 91高清视频免费看| 1区2区3区国产精品| 99久久综合精品| 亚洲女人****多毛耸耸8| 91免费视频网| 亚洲欧美日韩在线| caoporen国产精品视频| 亚洲国产电影在线观看| 国产一区啦啦啦在线观看| 欧美日韩黄色一区二区| 亚洲h动漫在线| 欧美日韩日日骚| 老司机免费视频一区二区| 日韩精品一区二区三区老鸭窝| 青青草原综合久久大伊人精品优势| 欧美一区二区精品| 免费在线一区观看| 欧美成人video| 成人小视频在线| 国产乱色国产精品免费视频| 久久久不卡网国产精品二区| 97久久精品人人做人人爽50路| 又紧又大又爽精品一区二区| 欧美一区午夜精品| 精品写真视频在线观看| 国产精品国产三级国产三级人妇| 日本福利一区二区| 午夜精品久久久久久久久久久 | 老司机午夜精品99久久| 国产亚洲欧美色| 欧美亚洲日本一区| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲综合av网| 日韩视频不卡中文| 风流少妇一区二区| 日本亚洲欧美天堂免费| 一区二区三区四区国产精品| 精品国产精品一区二区夜夜嗨| av不卡免费电影| 国产一区二区三区免费观看| 午夜在线成人av| 尤物在线观看一区| 国产精品传媒在线| 国产日产欧美一区| 精品女同一区二区| 欧美一区二区在线观看| 欧美日本乱大交xxxxx| 99精品视频中文字幕| 国内精品第一页| 日本亚洲欧美天堂免费| 青青青伊人色综合久久| 一区二区三区加勒比av| 亚洲女人****多毛耸耸8| 国产精品美女久久福利网站| 国产女主播视频一区二区| 久久网站最新地址| 久久看人人爽人人| 欧美高清在线一区| 国产精品女同互慰在线看| 国产精品第五页| 日韩精品一级中文字幕精品视频免费观看 | 欧美xxxxx牲另类人与| 欧美mv日韩mv国产| 国产三级精品视频| 中文字幕一区免费在线观看 | 粉嫩一区二区三区在线看| 91首页免费视频| 欧美一区二区视频在线观看2022| 91麻豆精品91久久久久同性| 久久九九全国免费| 亚洲精品久久7777| 理论电影国产精品| 94色蜜桃网一区二区三区| 欧美日韩夫妻久久| 国产日产精品一区| 久久精品免费观看| 国产成人精品1024| 欧美视频精品在线| 久久久久国产精品人| 亚洲综合一区二区三区| 久久99精品一区二区三区| 色综合久久六月婷婷中文字幕| 91麻豆精品国产91久久久| 国产精品视频你懂的| 日韩av电影天堂| 色欧美日韩亚洲| 欧美国产欧美综合| 麻豆视频观看网址久久| 精品视频免费在线| 亚洲码国产岛国毛片在线| 麻豆91小视频| 91精品免费在线观看| 亚洲自拍偷拍综合| 91尤物视频在线观看| 日本一区二区三区在线不卡| 国产在线精品一区二区不卡了| 欧美精品日韩精品| 亚洲精品一卡二卡| 91色porny在线视频| 亚洲乱码日产精品bd| 欧美在线播放高清精品| 国产精品久线在线观看| 成人精品视频一区二区三区 | 久久成人免费网| 精品国产三级a在线观看| 国产伦理精品不卡| 国产精品视频免费看| 成人福利视频网站| 亚洲私人影院在线观看| 欧美在线免费播放| 欧美a级一区二区| 欧美岛国在线观看| 91在线观看污| 久久99精品国产.久久久久| 国产精品美女久久久久高潮| 欧美伊人久久久久久久久影院| 奇米四色…亚洲| 国产精品视频一二三| 色猫猫国产区一区二在线视频| 日韩高清不卡一区二区三区| 2020国产成人综合网| 精品视频一区二区不卡| 丁香婷婷综合色啪| 男女男精品视频| 亚洲第一在线综合网站| 日本一区二区电影| 日韩小视频在线观看专区| 不卡的电视剧免费网站有什么| 美女视频一区二区| 亚洲一区二区三区四区的| 中文字幕一区二区三区精华液 | 色哟哟日韩精品| 欧美在线free| 色婷婷综合五月| 成人一区二区三区视频在线观看| 麻豆精品一区二区| 丝袜a∨在线一区二区三区不卡| 国产精品久久久久影院| 久久久久久久国产精品影院| 欧美一区二区三区婷婷月色| 欧美三区在线观看| 欧美伊人久久久久久久久影院 | 国产精品久久久久久久久久免费看 | 国产亚洲视频系列| 欧美电影免费观看高清完整版在| 欧美一区二区精品在线| 欧美丝袜丝交足nylons| 欧美无砖砖区免费| 欧美日韩卡一卡二| 91麻豆精品国产91久久久久久| 欧美日本国产一区| 欧美一级二级三级蜜桃| 久久综合久久鬼色中文字| 久久综合久久久久88| 久久久久国产精品人| 136国产福利精品导航| 一区二区三区电影在线播| 亚洲一区在线免费观看| 日本网站在线观看一区二区三区 | 精品成人a区在线观看| 日本一区二区成人在线| 日韩码欧中文字| 日本强好片久久久久久aaa| 久久97超碰色| 91网站最新地址| 精品日韩成人av| 亚洲一区二区三区不卡国产欧美| 日韩制服丝袜av| 国产成人综合网站| 欧美日韩精品福利| 国产精品色一区二区三区| 天堂久久一区二区三区| 99久久婷婷国产综合精品电影|