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

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

?? bulkpwr.c

?? 利用C8051F320的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一区二区三区免费野_久草精品视频
欧美一级一区二区| 99久久伊人网影院| 日韩精品一区二区三区视频播放| 无码av免费一区二区三区试看 | 日本不卡的三区四区五区| 欧美伊人久久久久久久久影院| 亚洲综合久久av| 欧美少妇bbb| 日本不卡一二三| 久久嫩草精品久久久久| 北岛玲一区二区三区四区| 亚洲人吸女人奶水| 欧美日韩精品福利| 久国产精品韩国三级视频| 国产亚洲精品精华液| 91理论电影在线观看| 日韩主播视频在线| 久久毛片高清国产| 91麻豆.com| 久久成人18免费观看| 中文字幕综合网| 3d动漫精品啪啪一区二区竹菊| 精品一区二区三区在线观看国产 | 99精品热视频| 五月婷婷另类国产| 久久久777精品电影网影网| 成人aa视频在线观看| 日韩高清不卡一区二区三区| 国产欧美一区二区精品婷婷| 在线精品视频一区二区| 麻豆精品一区二区综合av| 国产肉丝袜一区二区| 在线观看精品一区| 韩国毛片一区二区三区| 亚洲天堂精品在线观看| 欧美一区二区在线播放| 91色视频在线| 久久99久久精品| 亚洲一区二区av在线| 久久久久久久久久久电影| 欧美性猛交一区二区三区精品| 国产一区二区三区在线看麻豆| 洋洋av久久久久久久一区| 久久久亚洲午夜电影| 欧美精品v日韩精品v韩国精品v| 国产v综合v亚洲欧| 日本不卡1234视频| 亚洲综合色区另类av| 国产精品久久三区| 日韩欧美国产1| 欧美系列日韩一区| 成人h版在线观看| 精品亚洲porn| 青青草精品视频| 亚洲成人激情av| 日韩伦理av电影| 国产色婷婷亚洲99精品小说| 91麻豆精品国产无毒不卡在线观看| 国产精品123| 激情都市一区二区| 美女视频免费一区| 亚洲成va人在线观看| 国产精品欧美精品| 久久一区二区三区国产精品| 欧美一激情一区二区三区| 在线一区二区三区四区五区 | ww亚洲ww在线观看国产| 欧美三级韩国三级日本三斤| 91免费看片在线观看| 高清不卡一区二区在线| 国模娜娜一区二区三区| 美女网站色91| 另类欧美日韩国产在线| 毛片av一区二区| 美女看a上一区| 日韩黄色小视频| 男男成人高潮片免费网站| 日本亚洲三级在线| 免费久久精品视频| 久久成人精品无人区| 精品无人区卡一卡二卡三乱码免费卡 | 久久er99精品| 黄色日韩网站视频| 国产中文字幕一区| 国产精品综合一区二区| 国产精品一区二区在线播放| 国产另类ts人妖一区二区| 国产麻豆日韩欧美久久| 国产宾馆实践打屁股91| 成人国产精品免费观看| 一本久道中文字幕精品亚洲嫩| 91蜜桃免费观看视频| 欧美在线观看一区二区| 欧美精品久久一区| 精品欧美一区二区在线观看| 337p粉嫩大胆色噜噜噜噜亚洲| 国产校园另类小说区| 国产精品传媒在线| 夜夜爽夜夜爽精品视频| 免费不卡在线视频| 国产高清精品久久久久| aaa欧美日韩| 欧美精品v国产精品v日韩精品| 欧美α欧美αv大片| 国产午夜亚洲精品不卡| 日韩美女视频一区| 欧美aⅴ一区二区三区视频| 激情综合色综合久久综合| 成人一区二区视频| 欧美性生活久久| 精品欧美乱码久久久久久| 亚洲天堂a在线| 日韩一区欧美二区| 国产成人aaa| 在线欧美小视频| 在线播放日韩导航| 国产精品色婷婷久久58| 亚洲香蕉伊在人在线观| 狠狠色综合播放一区二区| 91在线精品一区二区| 日韩欧美成人激情| 亚洲精品综合在线| 黄色日韩网站视频| 欧美三日本三级三级在线播放| 337p日本欧洲亚洲大胆色噜噜| 一区二区三区在线观看视频| 国模冰冰炮一区二区| 在线这里只有精品| 久久精品视频一区二区| 亚洲成人久久影院| 成av人片一区二区| 日韩片之四级片| 一区二区在线观看不卡| 国产一区亚洲一区| 欧美精品久久99久久在免费线| 国产精品精品国产色婷婷| 免费在线观看精品| 在线观看视频一区二区欧美日韩| 久久久99精品免费观看不卡| 人禽交欧美网站| 日本韩国精品一区二区在线观看| 久久久亚洲高清| 轻轻草成人在线| 欧美午夜精品久久久久久孕妇| 国产欧美视频一区二区| 蜜桃av噜噜一区二区三区小说| 欧美天堂一区二区三区| 亚洲人被黑人高潮完整版| 国产成人综合网| 久久久综合精品| 国产一区二区三区蝌蚪| 欧美一区二区三区男人的天堂| 亚洲欧美色图小说| 不卡的av在线播放| 亚洲国产成人一区二区三区| 极品少妇xxxx偷拍精品少妇| 91精品婷婷国产综合久久竹菊| 一区二区三区在线视频播放| 成人av资源在线观看| 欧美国产精品一区| 国产精品伊人色| 久久精品这里都是精品| 国产专区欧美精品| 久久嫩草精品久久久精品一| 国产曰批免费观看久久久| 精品国精品国产| 国产美女久久久久| 久久久精品国产99久久精品芒果| 久久超碰97中文字幕| 欧美精品一区二区精品网| 激情欧美一区二区| 国产喷白浆一区二区三区| 国产精品自拍av| 国产精品午夜在线观看| 丁香啪啪综合成人亚洲小说| 亚洲国产精品国自产拍av| 国产成人8x视频一区二区 | 日本乱人伦一区| 亚洲精品一二三| 欧美日韩在线三级| 日欧美一区二区| 欧美精品一区二区三区高清aⅴ| 久草精品在线观看| 久久久久99精品一区| 粉嫩在线一区二区三区视频| 国产精品超碰97尤物18| 色94色欧美sute亚洲13| 亚洲国产精品人人做人人爽| 欧美一区二区播放| 国产自产2019最新不卡| 中文字幕在线不卡国产视频| 欧美影视一区在线| 久久成人免费日本黄色| 欧美国产日本韩| 欧美日韩一本到| 精品亚洲国产成人av制服丝袜| 国产精品美女视频| 欧美视频一区二区在线观看| 九九在线精品视频| 国产精品美女视频|