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

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

?? bulkpwr.c

?? C8051F320 SOURCE CODE 內容有: * USB Bulk Driver Example * USB Bulk Firmware Example * Host Ap
?? 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自拍| 欧美性一区二区| 国产精品福利影院| 国产一区二区精品久久| 911精品产国品一二三产区| 中文字幕在线一区| 国产在线精品一区在线观看麻豆| 欧美日韩一区不卡| 一区二区三区免费| fc2成人免费人成在线观看播放 | 久久久久国产精品厨房| 亚洲国产精品久久久久秋霞影院 | 国产综合一区二区| 欧美日韩国产系列| 一区二区三区精品久久久| 成人网页在线观看| 国产无人区一区二区三区| 蜜桃av噜噜一区| 欧美一区二区精美| 五月婷婷激情综合网| 在线精品视频一区二区三四| 日韩一区在线看| 97久久久精品综合88久久| 欧美国产一区视频在线观看| 国产精品888| 日本一区二区免费在线观看视频| 精品一区二区三区不卡| 欧美大片拔萝卜| 久久精品国产成人一区二区三区| 欧美一卡2卡三卡4卡5免费| 日韩电影在线免费观看| 欧美另类高清zo欧美| 亚洲电影视频在线| 91精品久久久久久久91蜜桃| 日日欢夜夜爽一区| 日韩精品最新网址| 国产精品99久久不卡二区| 国产欧美日韩另类视频免费观看| 国产精品中文欧美| 国产精品久久久久aaaa樱花| 成人h动漫精品一区二| 亚洲欧洲精品一区二区精品久久久 | 亚洲午夜久久久久| 欧美精品在线一区二区| 免费欧美在线视频| 国产目拍亚洲精品99久久精品| 欧美videos大乳护士334| 麻豆精品在线播放| 国产三级一区二区三区| 97久久人人超碰| 午夜久久久久久久久| 精品捆绑美女sm三区| 高清不卡一区二区在线| 亚洲日本乱码在线观看| 欧美日本国产一区| 国产一区二区不卡在线 | 久久精品夜色噜噜亚洲aⅴ| 成人精品一区二区三区中文字幕| 亚洲女人****多毛耸耸8| 欧美二区三区的天堂| 国产在线视频一区二区| 亚洲柠檬福利资源导航| 91精品国产综合久久福利软件| 国产精品一区二区在线播放| 亚洲女人的天堂| 久久一二三国产| 91国偷自产一区二区三区成为亚洲经典 | 制服丝袜激情欧洲亚洲| 国产精品99久久久久久久女警| 亚洲男人天堂一区| 久久久久97国产精华液好用吗| 91福利在线看| 国产精品一区一区三区| 婷婷久久综合九色国产成人| 中文字幕av一区二区三区高| 6080国产精品一区二区| 99精品欧美一区| 韩国视频一区二区| 性久久久久久久久久久久| 国产免费久久精品| 精品粉嫩超白一线天av| 欧美日韩在线免费视频| 成人性生交大片免费看中文网站| 日韩国产高清在线| 亚洲欧美日韩中文字幕一区二区三区| 欧美一区二区三区免费| 日本道色综合久久| 成人精品小蝌蚪| 国产九九视频一区二区三区| 三级影片在线观看欧美日韩一区二区| 国产精品黄色在线观看| 久久精品人人做人人综合 | 欧美色倩网站大全免费| 99天天综合性| 粗大黑人巨茎大战欧美成人| 久久99精品久久久| 日本一区中文字幕| 亚洲成人免费看| 亚洲成人久久影院| 亚洲高清免费在线| 亚瑟在线精品视频| 香蕉av福利精品导航| 一区二区三区四区在线播放| 国产精品超碰97尤物18| 中文字幕的久久| 亚洲国产经典视频| 欧美国产精品一区二区三区| 久久综合九色综合97婷婷女人| 欧美大肚乱孕交hd孕妇| 一区二区三区中文字幕精品精品| 国产精品久久久久久久久免费丝袜 | 欧美日韩精品一区二区三区蜜桃 | 亚洲线精品一区二区三区八戒| 亚洲色图清纯唯美| 亚洲欧美日韩国产综合| 成人免费在线视频观看| 亚洲精品自拍动漫在线| 一区二区三区中文免费| 亚洲自拍偷拍九九九| 亚洲成人av中文| 首页国产欧美久久| 美女一区二区视频| 国产一区二区精品在线观看| 国产成人精品免费视频网站| 国产.欧美.日韩| 色狠狠av一区二区三区| 欧美美女一区二区三区| 欧美一区二区三区白人| 久久久不卡影院| 亚洲人快播电影网| 视频一区在线视频| 国产精品一区二区久久精品爱涩| 丁香婷婷深情五月亚洲| 91在线你懂得| 欧美日韩不卡视频| 久久人人超碰精品| 亚洲人成亚洲人成在线观看图片| 亚洲一区二区三区免费视频| 欧美aaa在线| 成人91在线观看| 欧美三级蜜桃2在线观看| 日韩欧美高清在线| 亚洲欧美一区二区视频| 日韩精彩视频在线观看| 国产麻豆精品在线观看| 91浏览器在线视频| 欧美成人a视频| 成人欧美一区二区三区在线播放| 亚洲成国产人片在线观看| 精品在线播放免费| 色综合久久综合网欧美综合网| 欧美一级免费观看| 成人免费在线视频观看| 久久国产欧美日韩精品| 91浏览器打开| 国产色一区二区| 青青草国产精品亚洲专区无| 成人av网站免费| 欧美α欧美αv大片| 亚洲人成人一区二区在线观看| 久久99国产精品免费网站| 91视频www| 国产三级欧美三级日产三级99| 午夜日韩在线观看| 91视频一区二区三区| 久久精品在这里| 久久9热精品视频| 欧美午夜一区二区三区免费大片| 久久九九99视频| 久久99精品网久久| 制服丝袜中文字幕亚洲| 一级做a爱片久久| 成人精品免费看| 欧美精品一区二区三区在线播放| 亚洲夂夂婷婷色拍ww47 | 国内精品在线播放| 欧美蜜桃一区二区三区| 亚洲黄色片在线观看| 成人激情免费视频| 久久人人超碰精品| 国产综合色产在线精品| 日韩一区二区三区四区| 五月天婷婷综合| 欧美日本韩国一区二区三区视频| 亚洲精品日产精品乱码不卡| 成人免费观看视频| 国产拍揄自揄精品视频麻豆| 国产一区二区三区日韩 | 国产成人高清视频| 国产日韩av一区二区| 国产麻豆精品在线| 国产校园另类小说区| 国产精品1区2区| 国产欧美一区二区三区在线看蜜臀 | 久久精品国产精品青草| 欧美成人精品高清在线播放 | 亚洲午夜久久久久久久久电影院| 色哟哟精品一区|