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

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

?? bulkpwr.c

?? 一個非常全面usb例子
?? 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一区二区三区免费野_久草精品视频
日韩三级免费观看| 国产美女主播视频一区| 久久蜜臀精品av| 日韩一级二级三级精品视频| 在线观看欧美精品| 色综合久久久久久久| 一本色道久久综合精品竹菊 | 91麻豆免费看| 粗大黑人巨茎大战欧美成人| 国产精品一区二区三区乱码| 美女久久久精品| 久久99国产精品免费网站| 老司机精品视频在线| 激情五月婷婷综合| 国产精品一卡二| 国产成人h网站| 91女人视频在线观看| 欧美日韩电影在线播放| 宅男在线国产精品| 精品成人一区二区| 国产精品护士白丝一区av| 亚洲精品菠萝久久久久久久| 亚洲一区二区3| 日本大胆欧美人术艺术动态| 国产综合色产在线精品| 粉嫩绯色av一区二区在线观看| 国产精品一级二级三级| 99久久国产综合精品女不卡| 色一情一乱一乱一91av| 日韩三级在线免费观看| 国产片一区二区| 亚洲尤物视频在线| 国产成人av自拍| 欧美日韩精品综合在线| 久久精品亚洲乱码伦伦中文| 亚洲色图制服诱惑| 九一九一国产精品| 日本精品一区二区三区高清| 日韩免费高清av| 中文字幕免费观看一区| 午夜视频一区二区| 国产成人午夜99999| 欧美在线观看禁18| 久久久久久久久久久久久久久99 | 国产视频一区二区在线观看| 中文字幕一区二区5566日韩| 五月综合激情日本mⅴ| 国内外成人在线| 91片黄在线观看| 精品毛片乱码1区2区3区| 亚洲品质自拍视频网站| 国内精品免费**视频| 欧洲精品视频在线观看| 久久尤物电影视频在线观看| 亚洲高清免费观看| 91亚洲永久精品| 国产日韩综合av| 美女www一区二区| 欧美在线free| 国产精品乱人伦| 国产在线日韩欧美| 欧美一区二区精品在线| 自拍偷拍国产亚洲| 日韩av中文字幕一区二区三区 | 91浏览器打开| 国产精品久久一级| 国产精品影视网| 欧美α欧美αv大片| 日韩专区在线视频| 欧美日韩高清一区| 午夜视频一区在线观看| 欧美日韩一本到| 亚洲一区二区三区爽爽爽爽爽| zzijzzij亚洲日本少妇熟睡| 久久精品亚洲乱码伦伦中文| 国产在线一区二区| 久久一二三国产| 韩国精品免费视频| 久久精品亚洲精品国产欧美kt∨| 麻豆国产精品视频| 日韩欧美自拍偷拍| 韩国理伦片一区二区三区在线播放| 精品少妇一区二区三区视频免付费| 日韩精品乱码免费| 日韩免费视频一区二区| 久久综合综合久久综合| 精品国产一区二区三区av性色| 美女被吸乳得到大胸91| 欧美电影免费提供在线观看| 久久国产精品99精品国产 | 99精品国产99久久久久久白柏| 国产欧美一区二区三区在线老狼| 成人三级伦理片| 国产精品狼人久久影院观看方式| 成人精品国产一区二区4080| 国产偷v国产偷v亚洲高清| 波多野结衣精品在线| 亚洲免费资源在线播放| 色就色 综合激情| 日韩精品一卡二卡三卡四卡无卡| 欧美一区二区精品| 国产91清纯白嫩初高中在线观看| 成人免费在线视频观看| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 久久综合色鬼综合色| 高清不卡在线观看av| 国产精品成人在线观看| 91精品福利在线| 精品一区二区免费看| 亚洲天堂中文字幕| 日韩精品综合一本久道在线视频| 成人综合婷婷国产精品久久蜜臀| 亚洲综合色自拍一区| 久久久久国产精品厨房| 色狠狠色噜噜噜综合网| 狠狠色狠狠色综合| 亚洲午夜成aⅴ人片| 亚洲国产精品黑人久久久| 在线观看精品一区| 成人午夜伦理影院| 久久国产视频网| 亚洲综合视频网| 中文字幕欧美三区| 日韩欧美国产午夜精品| 欧美性色综合网| 国产1区2区3区精品美女| 日本亚洲电影天堂| 亚洲在线观看免费| 国产精品美女久久久久久久久| 日韩一区二区三| 欧美精品自拍偷拍| 日本久久电影网| 91在线一区二区三区| 国产黄色成人av| 狠狠色丁香婷综合久久| 日韩国产在线观看一区| 亚洲伦理在线精品| 日韩美女视频19| 国产亚洲欧美色| 久久免费电影网| 2021中文字幕一区亚洲| 日韩午夜av一区| 337p亚洲精品色噜噜噜| 欧美在线观看视频一区二区三区| 99国产精品99久久久久久| 成av人片一区二区| 91精品办公室少妇高潮对白| 99国产精品久久久| 99久久99久久免费精品蜜臀| 懂色av一区二区夜夜嗨| 国产成人av一区二区三区在线观看| 九九九精品视频| 国产一区视频网站| 国产伦精品一区二区三区在线观看 | www.久久精品| 久久综合综合久久综合| 精品一区二区三区免费| 国产乱子轮精品视频| 国产乱国产乱300精品| 国产福利视频一区二区三区| 国产乱对白刺激视频不卡| 国产成人精品三级| 91网页版在线| 欧美亚洲精品一区| 91精品久久久久久蜜臀| 日韩一级片在线播放| 久久久精品天堂| 国产精品美女久久久久aⅴ| 亚洲色图视频免费播放| 亚洲一区成人在线| 另类的小说在线视频另类成人小视频在线| 日韩不卡手机在线v区| 紧缚捆绑精品一区二区| 成人深夜视频在线观看| 在线观看亚洲一区| 日韩欧美一区二区不卡| 国产校园另类小说区| 国产精品免费视频观看| 一区二区三区久久| 久久av中文字幕片| 99久久er热在这里只有精品15 | 欧美a级理论片| 国产91精品露脸国语对白| 色老汉一区二区三区| 日韩亚洲欧美在线| 国产精品嫩草影院com| 午夜久久久久久电影| 国产酒店精品激情| 欧美日韩一级片网站| 久久蜜桃一区二区| 亚洲国产毛片aaaaa无费看| 国产一区二区导航在线播放| 色999日韩国产欧美一区二区| 欧美成人一区二区三区片免费| 国产欧美一区二区精品婷婷 | 久久电影国产免费久久电影| 白白色 亚洲乱淫| 精品国产污污免费网站入口| 一区二区三区四区不卡在线| 国产一区二区在线视频|