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

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

?? bulkpwr.c

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

Copyright (c) 2000 Microsoft Corporation

Module Name:

    bulkpwr.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 "bulkusb.h"
#include "bulkpwr.h"
#include "bulkpnp.h"
#include "bulkdev.h"
#include "bulkrwr.h"
#include "bulkwmi.h"
#include "bulkusr.h"

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

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPower::"));
    BulkUsb_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.
        //

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

            BulkUsb_DbgPrint(1, ("Lower drivers failed the wait-wake Irp"));
        }

        ntStatus = STATUS_PENDING;

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

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

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

    //
    // initialize variables
    //

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

    BulkUsb_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)) {

        BulkUsb_DbgPrint(1, ("Query for an incompatible system power state\n"));

        PoStartNextPowerIrp(Irp);

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

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        BulkUsb_DbgPrint(3, ("HandleSystemQueryPower::"));
        BulkUsb_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);

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

    //
    // initialize variables
    //

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

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

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

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

    //
    // initialize variables
    //

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

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

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

    BulkUsb_DbgPrint(3, ("HandleDeviceQueryPower::"));
    BulkUsb_IoDecrement(deviceExtension);

    BulkUsb_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

--*/
{
    NTSTATUS           ntStatus;
 	PIO_STACK_LOCATION irpStack;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品福利在线导航| 91一区二区在线| 国产成人精品一区二区三区网站观看| 国产成人免费在线观看| 日本久久电影网| 3d动漫精品啪啪一区二区竹菊| 欧美一级一区二区| 中文一区二区在线观看| 亚洲一区二区三区自拍| 久久99久久精品| 91丨porny丨国产入口| 91精品国产综合久久久蜜臀图片| 久久久久久久久久看片| 亚洲综合视频在线| 精品一区二区三区免费播放| 91首页免费视频| 欧美一二三四在线| 亚洲视频在线一区| 美女mm1313爽爽久久久蜜臀| 99精品视频在线免费观看| 777欧美精品| 国产精品水嫩水嫩| 日本成人超碰在线观看| 成人国产在线观看| 日韩精品一区二区三区三区免费 | 全国精品久久少妇| 成人听书哪个软件好| 欧美老肥妇做.爰bbww视频| 国产免费成人在线视频| 午夜精品一区二区三区免费视频| 国产高清精品网站| 制服丝袜av成人在线看| 中文字幕一区二区三区在线观看| 免费在线观看精品| 色综合天天狠狠| 国产午夜精品久久久久久免费视 | 91美女片黄在线观看| 精品国产在天天线2019| 一区二区三区**美女毛片| 国内精品国产三级国产a久久| 欧美主播一区二区三区| 中日韩av电影| 狠狠色丁香久久婷婷综合_中| 91激情五月电影| 中文字幕视频一区二区三区久| 久久精品国产77777蜜臀| 欧美日韩一区二区三区视频| 国产精品色在线| 国内精品嫩模私拍在线| 欧美人与z0zoxxxx视频| 樱花影视一区二区| av在线不卡观看免费观看| 国产亚洲欧美日韩日本| 裸体歌舞表演一区二区| 欧美精品欧美精品系列| 亚洲永久精品大片| 99久久精品国产一区二区三区| 国产日韩高清在线| 韩国三级电影一区二区| 日韩欧美综合在线| 视频一区二区三区在线| 欧美日韩中文字幕一区| 国产精品亚洲第一区在线暖暖韩国| 欧美日韩三级在线| 亚洲一区在线电影| 欧美综合一区二区| 亚洲午夜私人影院| 91九色最新地址| 一区二区三区在线视频播放| 99精品一区二区三区| 中文字幕一区不卡| 99精品视频在线免费观看| 日韩毛片精品高清免费| 91丨九色丨蝌蚪富婆spa| 中文字幕日韩精品一区| av一二三不卡影片| 亚洲人成网站在线| 色婷婷av一区二区三区gif| 樱花草国产18久久久久| 欧美日韩一区小说| 午夜精品久久久| 欧美一区永久视频免费观看| 麻豆视频一区二区| 精品久久人人做人人爱| 国产精品18久久久久久久久| 久久久久国产成人精品亚洲午夜| 国产高清精品在线| 亚洲同性gay激情无套| 色婷婷av久久久久久久| 偷拍日韩校园综合在线| 日韩欧美久久久| 国产精品影视在线观看| 亚洲国产高清在线| 91丨九色丨黑人外教| 亚洲亚洲人成综合网络| 在线成人高清不卡| 精品一区二区三区在线播放| 国产日韩欧美不卡| 91麻豆福利精品推荐| 亚洲一区免费视频| 欧美一区二区国产| 国产一区二区三区四区五区美女 | 国产成人激情av| 国产精品不卡一区| 欧美日韩激情一区二区| 免费人成网站在线观看欧美高清| 久久久亚洲国产美女国产盗摄| 成人av电影在线播放| 亚洲小说欧美激情另类| 日韩视频免费观看高清完整版在线观看| 国产一区二区三区日韩| 综合久久综合久久| 在线不卡免费欧美| 国产盗摄一区二区| 一区二区三区欧美视频| 日韩欧美自拍偷拍| 91在线视频播放地址| 日韩电影在线免费| 中文字幕久久午夜不卡| 欧美日韩精品一区二区| 国产精品一区二区不卡| 亚洲图片自拍偷拍| 国产午夜精品久久久久久免费视| 欧亚一区二区三区| 经典三级在线一区| 国产传媒日韩欧美成人| 亚洲女女做受ⅹxx高潮| 日韩一区二区三免费高清| 高清视频一区二区| 天天av天天翘天天综合网色鬼国产| 国产网红主播福利一区二区| 色屁屁一区二区| 国产一二精品视频| 午夜精品爽啪视频| 中文欧美字幕免费| 欧美一区二区三区四区久久| 成人性生交大片免费| 日韩—二三区免费观看av| 中文字幕+乱码+中文字幕一区| 日韩午夜激情免费电影| 99久久婷婷国产综合精品电影| 狂野欧美性猛交blacked| 亚洲一区二区三区不卡国产欧美| 久久久久久一级片| 欧美日韩国产综合视频在线观看| 国产91精品一区二区麻豆亚洲| 丝袜诱惑制服诱惑色一区在线观看 | 久久一二三国产| 欧美绝品在线观看成人午夜影视| 成人综合婷婷国产精品久久| 日韩av在线播放中文字幕| 亚洲三级在线免费| 久久久精品中文字幕麻豆发布| 欧美日韩国产一级| 91在线你懂得| 丁香六月综合激情| 国产一区二区日韩精品| 日韩福利视频网| 亚洲成av人片在线| 亚洲视频在线一区二区| 中文字幕成人在线观看| 精品国产电影一区二区| 制服视频三区第一页精品| 在线免费不卡视频| 91在线视频观看| www.亚洲精品| 成人精品免费看| 国产麻豆精品一区二区| 蜜臀久久久久久久| 午夜影院久久久| 亚洲黄网站在线观看| 国产精品家庭影院| 国产精品久久免费看| 国产精品色哟哟网站| 欧美国产丝袜视频| 国产人成一区二区三区影院| 2021国产精品久久精品| 精品精品国产高清a毛片牛牛| 欧美日韩国产经典色站一区二区三区| 国产精品电影院| 国产精品欧美久久久久一区二区| 国产日韩精品久久久| 欧美国产一区在线| 国产精品无码永久免费888| 国产区在线观看成人精品| 久久精品人人做人人爽97| 久久久久久久性| 国产午夜精品久久久久久免费视| 国产喷白浆一区二区三区| 日本一区二区电影| ...av二区三区久久精品| 亚洲三级理论片| 夜夜嗨av一区二区三区中文字幕| 亚洲一卡二卡三卡四卡| 亚洲国产欧美在线| 日韩精品成人一区二区在线| 日本vs亚洲vs韩国一区三区二区 | 91精品国产综合久久香蕉的特点 | 亚洲v中文字幕| 日韩国产一区二|