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

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

?? isopwr.c

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

Copyright (c) 2000 Microsoft Corporation

Module Name:

    isopwr.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 "isousb.h"
#include "isopnp.h"
#include "isopwr.h"
#include "isodev.h"
#include "isowmi.h"
#include "isousr.h"
#include "isorwr.h"
#include "isostrm.h"

NTSTATUS
IsoUsb_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);
    }

    IsoUsb_DbgPrint(3, ("IsoUsb_DispatchPower::"));
    IsoUsb_IoIncrement(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)) {

            IsoUsb_DbgPrint(1, ("Lower drivers failed this Irp\n"));
        }

        ntStatus = STATUS_PENDING;

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

        IsoUsb_DbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
        IsoUsb_IoDecrement(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)) {

            IsoUsb_DbgPrint(1, ("Lower drivers failed this Irp\n"));
        }
        
        IsoUsb_DbgPrint(3, ("IsoUsb_DispatchPower::"));
        IsoUsb_IoDecrement(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;
    
    IsoUsb_DbgPrint(3, ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

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

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

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

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

        PoStartNextPowerIrp(Irp);

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

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        IsoUsb_DbgPrint(3, ("HandleSystemQueryPower::"));
        IsoUsb_IoDecrement(deviceExtension);

        return ntStatus;
    }

    //
    // if querying for a lower S-state, issue a wait-wake
    //

    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);

    IsoUsb_DbgPrint(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;
    
    IsoUsb_DbgPrint(3, ("HandleSystemSetPower - begins\n"));

    //
    // initialize variables
    //

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

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

    IoCopyCurrentIrpStackLocationToNext(Irp);

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

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

    IsoUsb_DbgPrint(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;

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

    //
    // initialize variables
    //

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

    IsoUsb_DbgPrint(3, ("Query for 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) {

        PoStartNextPowerIrp(Irp);

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

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        IsoUsb_DbgPrint(3, ("HandleDeviceQueryPower::"));
        IsoUsb_IoDecrement(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);
    }

    IsoUsb_DbgPrint(3, ("HandleDeviceQueryPower::"));
    IsoUsb_IoDecrement(deviceExtension);

    IsoUsb_DbgPrint(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
    DeviceExtension - pointer to device extension

Return Value:

    NT status value

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲色图综合| 欧美精品一卡二卡| 国产三级精品三级在线专区| 九九视频精品免费| 欧美草草影院在线视频| 激情文学综合丁香| 国产亚洲一本大道中文在线| 成人精品鲁一区一区二区| 欧美经典一区二区| 色综合久久久网| 午夜久久久久久久久| 日韩视频123| 高清成人在线观看| 一区二区理论电影在线观看| 欧美日韩一区二区不卡| 午夜影视日本亚洲欧洲精品| 欧美一区二视频| 国产精品 欧美精品| 亚洲丝袜制服诱惑| 欧美情侣在线播放| 国产乱码精品一区二区三| 综合欧美亚洲日本| 欧美一区二区三区在线观看| 国产成人亚洲综合色影视| 亚洲精品欧美专区| 3atv一区二区三区| 成人一区二区三区| 亚洲成人高清在线| 久久亚洲精精品中文字幕早川悠里 | 亚洲五码中文字幕| 欧美成人伊人久久综合网| 成人a区在线观看| 日韩激情av在线| 国产精品久久久一本精品| 欧美久久久久久久久| 国产69精品久久久久777| 午夜成人免费视频| 国产精品电影一区二区| 日韩三级高清在线| 色狠狠综合天天综合综合| 国内精品伊人久久久久av影院| 亚洲男人天堂av| 国产亚洲精品bt天堂精选| 欧美亚洲一区二区在线| 国产成人精品亚洲日本在线桃色| 亚洲国产精品一区二区www在线| 久久精品免视看| 欧美一三区三区四区免费在线看| 91免费视频观看| 国产美女在线观看一区| 日产国产高清一区二区三区| 亚洲精品写真福利| 国产精品麻豆视频| 精品精品欲导航| 欧美久久久久久久久中文字幕| 92精品国产成人观看免费| 国产美女娇喘av呻吟久久| 日韩国产在线观看| 亚洲午夜精品在线| 日韩美女久久久| 中文一区在线播放| 久久久一区二区| 精品动漫一区二区三区在线观看| 欧美老肥妇做.爰bbww| 欧美在线不卡视频| 91小视频在线免费看| 成人ar影院免费观看视频| 国产一区二区视频在线| 美腿丝袜亚洲一区| 免费人成在线不卡| 午夜精品aaa| 三级一区在线视频先锋| 午夜欧美在线一二页| 亚洲国产另类精品专区| 亚洲国产美国国产综合一区二区| 亚洲一区二区在线视频| 亚洲精选一二三| 亚洲精品国产一区二区三区四区在线 | 欧美三级韩国三级日本一级| 99久久综合狠狠综合久久| 福利视频网站一区二区三区| 国产传媒欧美日韩成人| 成人精品鲁一区一区二区| 成人动漫一区二区三区| youjizz久久| k8久久久一区二区三区 | 97久久精品人人澡人人爽| 成人网在线播放| a4yy欧美一区二区三区| 91浏览器打开| 欧美亚洲综合一区| 欧美一区二区国产| 欧美电视剧免费全集观看| 亚洲精品一线二线三线无人区| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 一区二区三区成人| 亚洲国产aⅴ成人精品无吗| 日本午夜精品视频在线观看| 激情偷乱视频一区二区三区| 懂色一区二区三区免费观看| 99久久婷婷国产综合精品电影| 一本久久精品一区二区| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲成a人片在线观看中文| 午夜精品视频一区| 国精产品一区一区三区mba视频 | 精品视频免费看| 日韩午夜av电影| 国产精品无码永久免费888| 亚洲免费在线视频一区 二区| 午夜精品福利在线| 国产福利一区二区| 91黄色激情网站| 欧美成人三级在线| 国产精品久久久久婷婷| 亚洲444eee在线观看| 国产精品一区二区x88av| 在线视频亚洲一区| xvideos.蜜桃一区二区| 亚洲色图欧洲色图| 日本不卡视频在线观看| 成人黄色综合网站| 欧美精品乱码久久久久久按摩| 欧美激情中文不卡| 日本va欧美va精品| 97久久精品人人做人人爽| 欧美va亚洲va香蕉在线| 亚洲激情图片小说视频| 国产河南妇女毛片精品久久久| 欧美日韩一卡二卡| 中文字幕免费观看一区| 美女视频免费一区| 在线免费观看日本欧美| 久久久99精品免费观看不卡| 午夜影视日本亚洲欧洲精品| www.亚洲免费av| 日韩欧美国产系列| 亚洲最新视频在线播放| 国产成人高清视频| 欧美一区二区视频免费观看| 亚洲自拍偷拍麻豆| zzijzzij亚洲日本少妇熟睡| 欧美v国产在线一区二区三区| 亚洲成人动漫在线观看| 99国产欧美另类久久久精品| 国产视频一区二区在线| 青草国产精品久久久久久| 日本韩国精品在线| 国产精品三级av在线播放| 精品一区免费av| 69堂国产成人免费视频| 一区二区国产盗摄色噜噜| 不卡高清视频专区| 国产人伦精品一区二区| 激情成人午夜视频| 69av一区二区三区| 亚洲成人免费在线观看| 91行情网站电视在线观看高清版| 中文字幕亚洲区| 国产福利一区二区| 久久婷婷国产综合精品青草| 久久99国内精品| 日韩美一区二区三区| 秋霞影院一区二区| 91精品国产手机| 蜜桃av一区二区三区电影| 欧美一级日韩不卡播放免费| 日本在线不卡视频| 欧美一卡二卡三卡四卡| 日韩av电影免费观看高清完整版 | 91色porny蝌蚪| 亚洲色大成网站www久久九九| 成人av电影在线观看| 亚洲人成小说网站色在线 | 国产精品欧美极品| 成人性生交大片免费看视频在线| 欧美国产丝袜视频| 99热精品一区二区| 亚洲高清免费观看高清完整版在线观看| 在线一区二区视频| 亚洲高清一区二区三区| 日韩一级在线观看| 国内精品不卡在线| 国产精品入口麻豆九色| 色综合久久天天综合网| 午夜不卡av在线| 久久婷婷色综合| 99在线精品视频| 亚洲国产成人av好男人在线观看| 欧美无砖砖区免费| 蜜桃视频一区二区三区 | 亚洲欧洲成人精品av97| 日本韩国精品在线| 免费日本视频一区| 国产精品久久久久久久久图文区 | 91精选在线观看| 国产一区日韩二区欧美三区| 自拍偷自拍亚洲精品播放| 欧美日韩免费观看一区二区三区| 美女网站一区二区|