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

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

?? bulkpwr.c

?? 支持USB2.0 BULK傳輸范例
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

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:

    
--*/

#include "bulkusb.h"
#include "bulkpwr.h"
#include "bulkpnp.h"
#include "bulkdev.h"
#include "bulkrwr.h"
#include "bulkwmi.h"
#include "bulkusr.h"
#ifdef WIN98DRIVER
#include "bulkwdm98.h"
#endif


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

    KdPrint( ("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)) {

            KdPrint( ("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
        //

        KdPrint( ("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)) {

            KdPrint( ("Lower drivers failed this Irp"));
        }
        
        KdPrint( ("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;
    
    KdPrint( ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

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

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

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

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

    //
    // initialize variables
    //

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

    KdPrint( ("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);

    KdPrint( ("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;

    KdPrint( ("HandleDeviceQueryPower - begins\n"));

    //
    // initialize variables
    //

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

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

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

    KdPrint( ("HandleDeviceQueryPower::"));
    BulkUsb_IoDecrement(deviceExtension);

    KdPrint( ("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;

    //
    // initialize variables
    //
    ntStatus = Irp->IoStatus.Status;
    irpStack = IoGetCurrentIrpStackLocation(Irp);


    KdPrint( ("SysPoCompletionRoutine - begins\n"));

    //
    // lower drivers failed this Irp
    //

    if(!NT_SUCCESS(ntStatus)) {

        PoStartNextPowerIrp(Irp);

        KdPrint( ("SysPoCompletionRoutine::"));
        BulkUsb_IoDecrement(DeviceExtension);

        return STATUS_SUCCESS;
    }

    //
    // ..otherwise update the cached system power state (IRP_MN_SET_POWER)
    //

    if(irpStack->MinorFunction == IRP_MN_SET_POWER) {

        DeviceExtension->SysPower = irpStack->Parameters.Power.State.SystemState;
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品写真福利| 国产精品99久久久久久宅男| 亚洲欧洲国产专区| 中文字幕成人av| 亚洲国产一区二区三区| 一区二区三区视频在线观看| 亚洲综合丝袜美腿| 理论片日本一区| 国产精品18久久久久| 不卡一区在线观看| 欧美乱妇23p| 久久精品人人做人人爽人人| 亚洲精品国产精华液| 日本中文字幕一区| 91原创在线视频| 日韩亚洲欧美在线| 精品久久国产字幕高潮| 欧美三级韩国三级日本一级| 日韩亚洲欧美综合| 亚洲欧美另类图片小说| 狠狠色丁香久久婷婷综合丁香| 国产精品原创巨作av| 欧美精品日韩一区| 亚洲品质自拍视频| 成人午夜电影久久影院| 91精品国产色综合久久ai换脸| 中文字幕高清一区| 国产精品99久久久| 精品国产三级a在线观看| 亚洲制服丝袜av| 99国产精品国产精品毛片| 精品99999| 高清在线观看日韩| 日韩欧美一区电影| 日本视频免费一区| 欧美一区二区日韩一区二区| 国产精品日韩精品欧美在线| 亚洲午夜视频在线观看| 91麻豆免费看| 午夜av一区二区三区| 欧美一区二视频| 成人性视频网站| 国产精品久久网站| 色激情天天射综合网| 亚洲精品视频一区| 777久久久精品| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 欧美激情中文字幕| av一区二区三区黑人| 亚洲成在人线免费| 久久精品一区蜜桃臀影院| 色呦呦日韩精品| 久久69国产一区二区蜜臀| 欧美日韩在线观看一区二区 | 色哟哟亚洲精品| 亚欧色一区w666天堂| 久久午夜羞羞影院免费观看| 91免费国产在线| 成人免费视频播放| 亚洲高清视频中文字幕| 国产一区在线看| 亚洲国产成人在线| 91精品在线免费观看| fc2成人免费人成在线观看播放| 亚洲高清不卡在线| 亚洲欧美日韩人成在线播放| wwwwxxxxx欧美| 日韩欧美在线网站| 丁香激情综合国产| 精品一区二区三区久久| 日韩精品每日更新| 亚洲高清一区二区三区| 一区二区三区欧美日韩| 亚洲黄色尤物视频| 亚洲综合久久av| 午夜精品久久久久久久| 五月婷婷久久综合| 日韩精品一级中文字幕精品视频免费观看| 中文字幕制服丝袜一区二区三区 | 久久精品视频一区二区| 精品国产麻豆免费人成网站| 精品剧情在线观看| 国产精品成人在线观看| 一区二区三区在线看| 亚洲成人免费视频| 国产日本欧洲亚洲| 亚洲色图另类专区| 日韩极品在线观看| 成人黄色小视频| 欧美揉bbbbb揉bbbbb| 久久综合给合久久狠狠狠97色69| 中文字幕一区二区三区色视频| 亚洲人精品一区| 国产九色精品成人porny| 一本一本大道香蕉久在线精品 | 国产精品一品视频| 色婷婷精品大在线视频| 欧美精品一卡两卡| 亚洲色图欧美激情| 国产一区二区三区精品欧美日韩一区二区三区 | 午夜欧美视频在线观看| 成人av网址在线观看| 欧美mv和日韩mv的网站| 日本欧美在线观看| 欧美日韩成人一区| 亚洲午夜免费电影| 顶级嫩模精品视频在线看| 日韩一区二区三区在线观看| 亚洲欧美日韩小说| 91福利精品视频| 国产精品入口麻豆九色| 成人永久看片免费视频天堂| 日韩美女视频一区二区在线观看| 三级精品在线观看| 日韩一区二区在线播放| 日韩精品91亚洲二区在线观看| 欧美剧情片在线观看| 日本中文字幕一区二区有限公司| 欧美人伦禁忌dvd放荡欲情| 亚洲成人免费av| 欧美v国产在线一区二区三区| 日韩高清欧美激情| 欧美午夜精品理论片a级按摩| 亚洲风情在线资源站| 欧美一区二区精美| 波多野结衣中文字幕一区| 自拍av一区二区三区| 4438x亚洲最大成人网| 精品无人码麻豆乱码1区2区| 国产精品精品国产色婷婷| 欧洲视频一区二区| 国产精品自拍在线| 日韩激情视频在线观看| 久久久久久综合| 欧美色中文字幕| 成人av小说网| 国产在线精品一区二区夜色| 亚洲主播在线播放| 国产精品欧美久久久久一区二区 | 国产精品自在在线| 亚洲成人av免费| 国产精品乱人伦| 久久久不卡网国产精品二区| 在线成人午夜影院| 欧美在线制服丝袜| 色哟哟一区二区在线观看| 国产91丝袜在线观看| 午夜成人免费视频| 亚洲国产一区二区三区青草影视| 国产精品毛片久久久久久| 精品国产免费人成电影在线观看四季| 欧美日韩一区三区| 91国在线观看| 欧美日韩一区二区三区四区五区 | 一本久道久久综合中文字幕| caoporm超碰国产精品| 91香蕉视频在线| 欧美一区二区视频在线观看| 日韩一二三区不卡| 久久日韩粉嫩一区二区三区| 久久久久亚洲综合| ...av二区三区久久精品| 洋洋成人永久网站入口| 婷婷丁香久久五月婷婷| 精品亚洲免费视频| 91在线视频免费91| 日韩欧美另类在线| 夜色激情一区二区| 国产99久久精品| 欧美精品色综合| 一色桃子久久精品亚洲| 国产精品女上位| 亚洲国产精品一区二区www在线| 日韩中文字幕1| 色噜噜狠狠一区二区三区果冻| 69精品人人人人| 亚洲日本va午夜在线影院| 奇米综合一区二区三区精品视频| av在线不卡观看免费观看| 日韩欧美的一区二区| 性欧美疯狂xxxxbbbb| 91看片淫黄大片一级| 国产精品美女久久福利网站| 久久成人久久爱| 91精品国产麻豆| 美日韩一级片在线观看| 欧美视频中文字幕| 一区二区三区精品视频在线| 成年人网站91| 亚洲一区二区三区不卡国产欧美| 懂色av中文字幕一区二区三区| 国产亚洲精品福利| 懂色av一区二区在线播放| 中文字幕精品—区二区四季| thepron国产精品| 一区二区日韩av| 日韩一区二区中文字幕| 国产真实精品久久二三区| 中文字幕av一区 二区| 91欧美一区二区|