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

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

?? bulkpwr.c

?? 這個是C51 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一区二区三区免费野_久草精品视频
国产毛片精品国产一区二区三区| 中文字幕不卡在线播放| 午夜伊人狠狠久久| 欧美日韩三级一区二区| 午夜精品久久一牛影视| 欧美老女人第四色| 免费xxxx性欧美18vr| 精品国产精品网麻豆系列| 国产精品123区| 亚洲人成网站在线| 欧美日韩在线播放一区| 蜜臀av一级做a爰片久久| 久久丝袜美腿综合| 91在线观看一区二区| 亚洲午夜羞羞片| 日韩免费福利电影在线观看| 国产成人h网站| 亚洲一区国产视频| 欧美va亚洲va| 色综合久久六月婷婷中文字幕| 性久久久久久久久久久久| 精品国产伦一区二区三区观看方式 | 久久av资源站| 国产三级久久久| 欧美亚洲一区三区| 久久精品国产77777蜜臀| 中文字幕不卡在线| 91精品国产综合久久国产大片| 国产剧情在线观看一区二区| 一区二区三区精品| 亚洲精品一区二区三区香蕉 | 国产精品不卡在线观看| 91精品办公室少妇高潮对白| 蜜乳av一区二区| 亚洲三级电影网站| 欧美一区二区成人6969| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 精品国精品国产| 一本色道亚洲精品aⅴ| 蜜臀av一区二区在线观看| 自拍偷拍欧美精品| 精品国产一区a| 欧美日韩国产乱码电影| 成人中文字幕电影| 欧美a级一区二区| 亚洲自拍另类综合| 国产精品视频yy9299一区| 日韩免费观看高清完整版 | 中文字幕在线不卡| 日韩一级高清毛片| 91成人网在线| 99天天综合性| 国产一区二区精品在线观看| 亚洲国产另类av| 亚洲精品免费电影| 国产精品久久久久久久岛一牛影视| 日韩欧美在线1卡| 欧美日韩在线直播| av一区二区三区四区| 国产精品一二三在| 精品一区二区三区不卡| 奇米色一区二区| 亚洲永久免费视频| 一区二区三区中文字幕精品精品| 国产欧美日韩视频在线观看| 精品国一区二区三区| 欧美一级免费观看| 欧美日韩国产精选| 欧美日韩在线一区二区| 色婷婷综合久久| 91亚洲精品一区二区乱码| 不卡的电影网站| 高清beeg欧美| www.亚洲免费av| 成人av电影在线网| 成人精品视频一区二区三区| 国产91丝袜在线播放0| 国产精品夜夜爽| 国产99久久精品| 99精品视频一区二区| 99久久精品免费| 99re这里都是精品| 日本电影亚洲天堂一区| 色狠狠一区二区| 欧美性高清videossexo| 欧美三级韩国三级日本一级| 欧美美女一区二区在线观看| 欧美日韩免费高清一区色橹橹| 欧美日韩一区二区三区不卡| 欧美人妇做爰xxxⅹ性高电影| 欧美视频一区二| 欧美一区二区私人影院日本| 欧美大片在线观看一区二区| 26uuu成人网一区二区三区| 久久久噜噜噜久久人人看 | 日韩午夜在线观看视频| 日韩精品综合一本久道在线视频| 精品日韩一区二区三区| 久久精品视频网| 亚洲特黄一级片| 亚洲福利一二三区| 免费xxxx性欧美18vr| 精一区二区三区| a美女胸又www黄视频久久| 色婷婷av一区二区三区之一色屋| 欧美剧在线免费观看网站| 日韩视频免费观看高清完整版在线观看 | 粉嫩av一区二区三区| 成人免费看的视频| 在线观看网站黄不卡| 91麻豆精品91久久久久同性| 久久久久综合网| 亚洲人成在线播放网站岛国| 日本伊人精品一区二区三区观看方式| 久久国产精品99精品国产| 成人一区二区三区中文字幕| 欧美亚洲国产一区二区三区va | 国产精品嫩草影院av蜜臀| 亚洲欧美日韩在线| 久久精品国产色蜜蜜麻豆| 不卡区在线中文字幕| 91精品国产欧美一区二区18| 日本一区二区高清| 午夜精品aaa| 成人精品电影在线观看| 欧美久久久一区| 国产精品视频第一区| 日本人妖一区二区| 色网站国产精品| 久久久91精品国产一区二区精品| 一区二区三区中文字幕精品精品 | 日韩高清一级片| 成人精品国产福利| 日韩午夜av电影| 亚洲一区自拍偷拍| 国产成人午夜视频| 日韩欧美一二三四区| 亚洲国产综合色| 不卡av在线免费观看| 日韩欧美一级在线播放| 一级中文字幕一区二区| 国产高清不卡一区二区| 欧美猛男超大videosgay| 亚洲视频小说图片| 国产九色sp调教91| 欧美一区二区三区精品| 夜夜操天天操亚洲| 东方aⅴ免费观看久久av| 日韩欧美国产电影| 亚洲国产中文字幕在线视频综合| av中文字幕在线不卡| 久久亚洲精精品中文字幕早川悠里| 亚洲一区二区三区三| 97精品国产97久久久久久久久久久久 | 岛国精品在线观看| 日韩精品一区二区三区四区 | 国产精品日韩精品欧美在线| 久久精品国产久精国产爱| 欧美视频在线观看一区二区| 亚洲人成人一区二区在线观看 | 久国产精品韩国三级视频| 欧美猛男男办公室激情| 亚洲大片在线观看| 色综合久久88色综合天天 | 艳妇臀荡乳欲伦亚洲一区| eeuss鲁片一区二区三区在线观看| 久久九九久精品国产免费直播| 丝袜美腿亚洲综合| 欧美男生操女生| 日本欧美韩国一区三区| 日韩一级二级三级精品视频| 日韩成人免费在线| 日韩手机在线导航| 奇米影视一区二区三区| 日韩欧美亚洲另类制服综合在线| 日韩精品电影一区亚洲| 这里只有精品视频在线观看| 日本不卡一二三| 欧美xfplay| 国产高清在线观看免费不卡| 国产日韩v精品一区二区| 国产成人精品一区二区三区四区 | 国产一区二区三区视频在线播放| 欧美mv日韩mv| 国产成人鲁色资源国产91色综| 中文字幕乱码亚洲精品一区| 99免费精品视频| 一区二区三区四区在线播放| 欧美日韩一本到| 蜜臀va亚洲va欧美va天堂| 久久精品视频一区二区三区| av在线播放一区二区三区| 亚洲一区二区三区国产| 欧美一区二区日韩| 国产高清精品在线| 亚洲一区在线观看视频| 日韩色视频在线观看| 成人免费不卡视频| 亚洲午夜电影在线| 日韩精品一区二区三区在线播放|