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

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

?? bulkpwr.c

?? usb范例代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2000 Microsoft Corporation

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:

    Copyright (c) 2000 Microsoft Corporation.  
    All Rights Reserved.

--*/

#include "bulkusb.h"
#include "bulkpwr.h"
#include "bulkpnp.h"
#include "bulkdev.h"
#include "bulkrwr.h"
#include "bulkwmi.h"
#include "bulkusr.h"

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

    BulkUsb_DbgPrint(3, ("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;
        }

        return STATUS_PENDING;

    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;
        }
        return STATUS_PENDING;

    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.
        //

        (PIRP) InterlockedExchangePointer(&deviceExtension->WaitWakeIrp,
                                          Irp);

        if(InterlockedExchange(&deviceExtension->FlagWWDispatched, 1)){
            //
            // CancelWaitWake ran before we could store the IRP.  We must
            // cancel the IRP here.
            //

            if(InterlockedExchangePointer(&deviceExtension->WaitWakeIrp,
                                          NULL)){
                //
                // CancelWaitWake cannot touch this irp now and we will complete it
                //
                PoStartNextPowerIrp(Irp);
                Irp->IoStatus.Status = STATUS_CANCELLED;
                Irp->IoStatus.Information = 0;

                IoCompleteRequest(Irp, IO_NO_INCREMENT);
                ntStatus = STATUS_CANCELLED;

                BulkUsb_DbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
                BulkUsb_IoDecrement(deviceExtension);
                break;
            }
        }

        IoMarkIrpPending(Irp);

        IoCopyCurrentIrpStackLocationToNext(Irp);

        IoSetCompletionRoutine(
                        Irp,
                        WaitWakeCompletionRoutine,
                        deviceExtension, 
                        TRUE, 
                        TRUE, 
                        TRUE);

        PoStartNextPowerIrp(Irp);

        ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

        if(!NT_SUCCESS(ntStatus)) {

            BulkUsb_DbgPrint(1, ("Lower drivers failed the wait-wake Irp\n"));
        }

//        ntStatus = STATUS_PENDING;

        //
        // push back the count HERE and NOT in completion routine
        // a pending Wait Wake Irp should not impede stopping the device
        //

        BulkUsb_DbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
        BulkUsb_IoDecrement(deviceExtension);
        
        return STATUS_PENDING;

    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)) {

            BulkUsb_DbgPrint(1, ("Lower drivers failed default power Irp\n"));
        }
        
        BulkUsb_DbgPrint(3, ("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;
    
    BulkUsb_DbgPrint(3, ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

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

    BulkUsb_DbgPrint(3, ("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)
    {
        if (systemState <= deviceExtension->DeviceCapabilities.SystemWake)
        {
            // OK, our device can wake system from requested state.
            // Ensure wake IRP is pending.
            //
            IssueWaitWake(deviceExtension);
        }
        else
        {
            // Our device cannot wake system from requested state.
            // Cancel pending wake IRP, if any, because it prevents
            // requested power state.
            //
            CancelWaitWake(deviceExtension);
        }
    }

    IoCopyCurrentIrpStackLocationToNext(Irp);

    IoSetCompletionRoutine(
            Irp, 
            SysPoCompletionRoutine,
            deviceExtension, 
            TRUE, 
            TRUE, 
            TRUE);

    ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

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

    //
    // initialize variables
    //

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

    BulkUsb_DbgPrint(3, ("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, 
            SysPoCompletionRoutine,
            deviceExtension, 
            TRUE, 
            TRUE, 
            TRUE);

    ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

    BulkUsb_DbgPrint(3, ("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;

    BulkUsb_DbgPrint(3, ("HandleDeviceQueryPower - begins\n"));

    //
    // initialize variables
    //

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

    BulkUsb_DbgPrint(3, ("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);
    }

    BulkUsb_DbgPrint(3, ("HandleDeviceQueryPower::"));
    BulkUsb_IoDecrement(deviceExtension);

    BulkUsb_DbgPrint(3, ("HandleDeviceQueryPower - ends\n"));

    return ntStatus;
}


NTSTATUS
SysPoCompletionRoutine(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp,
    IN PVOID Context
    )
/*++
 
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;
    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)Context;

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


    BulkUsb_DbgPrint(3, ("SysPoCompletionRoutine - begins\n"));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区国产| 亚洲蜜臀av乱码久久精品| 欧美猛男超大videosgay| 成人av资源在线观看| 欧美变态tickle挠乳网站| 欧美精品一卡二卡| 久久综合久久久久88| 久久久午夜精品理论片中文字幕| 精品国产一区二区在线观看| 国产欧美一区二区三区在线老狼 | 91精品国产综合久久久蜜臀图片 | 青青青伊人色综合久久| 一区二区三区欧美视频| 蜜臀av一区二区在线观看| 精品一区精品二区高清| 99re这里只有精品视频首页| 欧美日韩在线播放一区| 日韩精品中文字幕一区二区三区| 亚洲国产成人在线| 亚洲精品国产一区二区精华液| 天天综合色天天综合| 激情欧美一区二区三区在线观看| 99re热这里只有精品免费视频| 在线影院国内精品| 欧美日韩久久一区| 国产清纯白嫩初高生在线观看91 | 亚洲成人午夜影院| 国产成人亚洲综合色影视| 一本色道亚洲精品aⅴ| 欧美精品一区二区三区久久久 | 国产色产综合色产在线视频| 亚洲精品视频免费看| 麻豆久久久久久久| 欧美影片第一页| 中文字幕乱码日本亚洲一区二区| 爽爽淫人综合网网站| 国产成人精品www牛牛影视| 在线一区二区视频| 中文字幕精品三区| 蜜桃视频在线一区| 国产精品夜夜爽| 久久久亚洲综合| 一区二区三区.www| 粉嫩在线一区二区三区视频| 国产福利91精品| 成人黄色在线看| 欧美精品一区二区三区视频| 亚洲午夜激情网站| 欧洲视频一区二区| 国产精品无遮挡| 国产精品一色哟哟哟| 日韩你懂的在线观看| 天堂成人免费av电影一区| 日韩免费高清av| 亚洲高清一区二区三区| 一本一道波多野结衣一区二区| 国产欧美精品一区二区三区四区| 久久精品国内一区二区三区| 欧美日韩卡一卡二| 国产精品午夜电影| 亚洲在线视频免费观看| 99re视频这里只有精品| 国产精品久久久久久久久果冻传媒| 国产露脸91国语对白| 在线91免费看| 一级女性全黄久久生活片免费| 久久se这里有精品| 波多野结衣在线一区| 国产精品国产自产拍在线| 懂色av噜噜一区二区三区av| 国产日韩欧美精品电影三级在线| 国产一区不卡精品| 久久毛片高清国产| 成人免费视频国产在线观看| 国产精品久久久久婷婷| 成a人片亚洲日本久久| 一区二区三区四区视频精品免费| 椎名由奈av一区二区三区| 99久久国产综合精品女不卡| 色婷婷狠狠综合| 首页国产丝袜综合| 欧美理论电影在线| 久久99最新地址| 久久久久99精品国产片| 播五月开心婷婷综合| 亚洲精品美腿丝袜| 欧美日韩在线播放三区| 国产乱对白刺激视频不卡| 中文字幕亚洲综合久久菠萝蜜| 色激情天天射综合网| 午夜精品成人在线视频| 国产亚洲欧美日韩俺去了| 99国产麻豆精品| 毛片不卡一区二区| 国产亚洲精品资源在线26u| 午夜精品在线看| 日本一区二区三区高清不卡| 欧美日韩一级二级三级| 国产高清不卡一区| 亚洲国产一区视频| 日本一区二区视频在线观看| 91蝌蚪porny成人天涯| 亚洲日本在线视频观看| 4438x亚洲最大成人网| 国产成人在线免费观看| 亚洲综合男人的天堂| 久久久久久久久蜜桃| 日本黄色一区二区| 国产麻豆成人传媒免费观看| 亚洲美女免费在线| 久久影院视频免费| 99久久久久免费精品国产| 蜜臀av亚洲一区中文字幕| 国产精品对白交换视频| 欧美网站大全在线观看| 国产永久精品大片wwwapp | 99久久久国产精品| 丝袜亚洲另类欧美综合| 久久精品视频在线看| 欧美电影一区二区| av资源站一区| 亚洲午夜在线视频| 国产精品美女久久福利网站| 亚洲欧美在线另类| 亚洲综合一区在线| 日韩av一区二区三区| 国产一区日韩二区欧美三区| 懂色中文一区二区在线播放| 成人黄色av网站在线| 91免费版在线| 欧美一级视频精品观看| 精品粉嫩aⅴ一区二区三区四区 | 色狠狠色狠狠综合| 91超碰这里只有精品国产| 欧美成人性战久久| 国产欧美视频一区二区三区| 国产精品不卡在线| 亚洲bdsm女犯bdsm网站| 美国毛片一区二区| 国产91清纯白嫩初高中在线观看 | 亚洲一区二区在线免费看| 午夜精品久久久久久久99水蜜桃| 经典三级一区二区| 色域天天综合网| 欧美电影精品一区二区| 亚洲欧美日韩一区二区| 久久精品国产亚洲aⅴ| 99国产精品久| 日韩视频在线一区二区| 国产欧美综合在线| 日本中文在线一区| av电影一区二区| 日韩亚洲欧美在线| 亚洲精品视频免费看| 国产一区二三区好的| 欧美日韩在线三区| 国产精品视频一二三区| 日韩电影在线观看电影| 91在线观看高清| 日韩久久久久久| 亚洲福利一二三区| 国产精品一区二区黑丝| 欧美亚洲综合色| 国产精品久久久久久久久果冻传媒| 一区二区在线电影| 成人永久免费视频| 日韩精品在线一区| 午夜精品久久久久久久久久久| 成人免费视频播放| 久久视频一区二区| 污片在线观看一区二区| 成人免费不卡视频| 欧美日韩大陆在线| 中文字幕在线观看一区二区| 免费不卡在线观看| 欧美少妇bbb| 一区二区视频在线| 99久久亚洲一区二区三区青草| 欧美精品一区二区三区四区| 日精品一区二区| 欧美日韩一区视频| 亚洲妇熟xx妇色黄| 在线观看一区二区视频| 亚洲人成精品久久久久| 成人h精品动漫一区二区三区| 日韩精品中文字幕一区| 蜜臀av一区二区三区| 欧美一区二区观看视频| 国产精品亲子乱子伦xxxx裸| 日韩三区在线观看| 日韩一区二区免费在线观看| 国产精品理论片在线观看| 久久福利视频一区二区| 91精选在线观看| 香蕉成人啪国产精品视频综合网| 91成人国产精品| 亚洲成人资源网| 91精品午夜视频| 美女在线观看视频一区二区| 91麻豆精品91久久久久同性|