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

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

?? isopwr.c

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

Copyright (c) 2004 Microsoft Corporation

Module Name:

    isopwr.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) 2004 Microsoft Corporation.
    All Rights Reserved.

--*/

#include "isousb.h"
#include "isopnp.h"
#include "isopwr.h"
#include "isodev.h"
#include "isowmi.h"
#include "isousr.h"
#include "isorwr.h"
#include "isostrm.h"

NTSTATUS
IsoUsb_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);
    }

    IsoUsb_DbgPrint(3, ("IsoUsb_DispatchPower::"));
    IsoUsb_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.
        //
        // Mark the Irp as pending and return STATUS_PENDING if we change the
        // nature of the irp in the completion routine (asynchroniticity).
        // In such cases, do not return the status returned by the lower driver.
        // returning STATUS_MORE_PROCESSING_REQUIRED in the completion routine
        // transforms the nature of the irp to asynchronous irp.
        //

        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;

                IsoUsb_DbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
                IsoUsb_IoDecrement(deviceExtension);
                break;
            }
        }

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

            IsoUsb_DbgPrint(1, ("Lower drivers failed this 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
        //

        IsoUsb_DbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
        IsoUsb_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)) {

            IsoUsb_DbgPrint(1, ("Lower drivers failed this Irp\n"));
        }

        IsoUsb_DbgPrint(3, ("IsoUsb_DispatchPower::"));
        IsoUsb_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;

    IsoUsb_DbgPrint(3, ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

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

    IsoUsb_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);

    IsoUsb_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;

    IsoUsb_DbgPrint(3, ("HandleSystemSetPower - begins\n"));

    //
    // initialize variables
    //

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

    IsoUsb_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);

    IsoUsb_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;

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

    //
    // initialize variables
    //

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

    IsoUsb_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);
    }

    IsoUsb_DbgPrint(3, ("HandleDeviceQueryPower::"));
    IsoUsb_IoDecrement(deviceExtension);

    IsoUsb_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;

    //
    // initialize variables
    //
    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION) Context;
    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久一| 国产精品综合在线视频| 99精品视频一区二区三区| 国产欧美日韩在线视频| 高清免费成人av| 亚洲人吸女人奶水| 色综合久久综合网| 亚洲高清免费一级二级三级| 欧美日韩aaaaaa| 玖玖九九国产精品| 国产无人区一区二区三区| 福利一区二区在线观看| 国产精品久久久久精k8 | 青草av.久久免费一区| 欧美欧美欧美欧美首页| 美日韩黄色大片| 欧美激情一区二区在线| 99re这里只有精品6| 一区二区三区蜜桃| 日韩欧美中文字幕一区| 国产乱码精品一品二品| 亚洲视频精选在线| 欧美一区永久视频免费观看| 久久成人麻豆午夜电影| 国产日韩欧美精品在线| 日本国产一区二区| 青青青爽久久午夜综合久久午夜| 精品久久久久久久久久久久久久久久久 | 在线电影国产精品| 国产永久精品大片wwwapp| 国产精品网曝门| 亚洲线精品一区二区三区八戒| 成人av免费观看| 亚洲国产一区二区a毛片| 日韩免费一区二区三区在线播放| 韩国女主播成人在线观看| 1000部国产精品成人观看| 国产日韩欧美精品一区| 国产成人亚洲综合a∨婷婷图片| 国产精品国产馆在线真实露脸 | 蜜桃视频一区二区三区| 国产日韩精品一区二区三区 | 久99久精品视频免费观看| 国产精品萝li| 91精品国产一区二区三区蜜臀 | 欧美视频在线播放| 国产精品中文字幕日韩精品 | 国内欧美视频一区二区| 一区二区中文视频| 日韩欧美国产小视频| 色网综合在线观看| 国产精品综合一区二区| 婷婷综合另类小说色区| 国产精品福利一区二区三区| 日韩女优制服丝袜电影| 在线亚洲一区观看| 成人免费高清视频在线观看| 美国十次了思思久久精品导航| 一区二区中文字幕在线| 久久久久久久网| 日韩一区二区在线播放| 色女孩综合影院| 成人精品免费看| 国产一区二区三区四区五区美女| 亚洲五码中文字幕| 亚洲欧美欧美一区二区三区| 久久久久久久久久久久久女国产乱| 欧美日韩在线播| 日韩欧美美女一区二区三区| 欧美伊人久久大香线蕉综合69 | 国产乱人伦偷精品视频免下载| 亚洲第一久久影院| 亚洲人一二三区| 成人欧美一区二区三区小说| 国产香蕉久久精品综合网| 日韩一区二区免费视频| 欧美一级在线观看| 欧美一区二区三区视频免费播放| 色拍拍在线精品视频8848| 亚洲欧美偷拍另类a∨色屁股| 日韩av网站免费在线| 亚洲日本va在线观看| 亚洲欧洲性图库| 国产精品视频一区二区三区不卡| 久久久国产一区二区三区四区小说 | 美女在线视频一区| 男人的天堂久久精品| 人人超碰91尤物精品国产| 日韩成人免费在线| 免费成人在线播放| 精品一区在线看| 国产综合成人久久大片91| 国产一区在线视频| 国产91精品欧美| av电影天堂一区二区在线| 91丝袜呻吟高潮美腿白嫩在线观看| voyeur盗摄精品| 色噜噜夜夜夜综合网| 欧美日韩一区二区三区不卡| 欧美高清视频在线高清观看mv色露露十八| 欧美国产日本视频| 精品国产亚洲在线| 久久久精品黄色| 久久久久久综合| 国产精品福利一区二区| 亚洲精品亚洲人成人网在线播放| 久久国产麻豆精品| 韩国v欧美v亚洲v日本v| 国产精品一区在线观看你懂的| 高清国产一区二区| 欧美艳星brazzers| 日韩欧美高清一区| 国产精品国产自产拍高清av| 一区二区三区蜜桃网| 免费成人在线网站| 北条麻妃一区二区三区| 欧美少妇bbb| 精品国内二区三区| 亚洲人成网站在线| 久热成人在线视频| 成人v精品蜜桃久久一区| 欧美在线观看视频一区二区| 日韩欧美美女一区二区三区| 国产精品亲子伦对白| 日韩在线一区二区| 成人小视频在线观看| 欧美日韩精品久久久| 久久久777精品电影网影网| 日韩毛片视频在线看| 另类小说视频一区二区| 91视频精品在这里| 亚洲精品一区二区三区福利| 亚洲欧洲性图库| 激情欧美日韩一区二区| 在线区一区二视频| 久久这里只有精品6| 亚洲一区中文在线| 国产iv一区二区三区| 欧美高清dvd| 中文字幕第一页久久| 日本麻豆一区二区三区视频| 99在线热播精品免费| 欧美成人vps| 三级影片在线观看欧美日韩一区二区| 福利一区在线观看| 久久综合狠狠综合久久综合88| 亚洲一区二区三区四区在线| 成人黄色网址在线观看| 欧美大片拔萝卜| 亚洲一区二区三区四区的| 成人理论电影网| 久久久久久久电影| 久久97超碰色| 欧美一区二区黄色| 亚洲成a人在线观看| 91丨porny丨最新| 国产精品剧情在线亚洲| 国产麻豆日韩欧美久久| 日韩免费看的电影| 日韩av不卡在线观看| 欧美午夜免费电影| 一区二区三区四区乱视频| 99久久99久久综合| 中文字幕免费不卡| 国产91丝袜在线播放0| 久久精品在线免费观看| 老司机精品视频在线| 日韩欧美中文字幕精品| 美腿丝袜在线亚洲一区| 制服丝袜国产精品| 日本不卡一区二区三区| 91麻豆精品国产| 日韩精品电影在线观看| 91精品婷婷国产综合久久竹菊| 亚洲成人av在线电影| 欧美日韩你懂得| 亚洲主播在线播放| 欧美性猛交xxxx黑人交| 亚洲第一综合色| 欧美乱妇23p| 日韩高清欧美激情| 欧美videossexotv100| 国产在线观看一区二区| 久久综合久色欧美综合狠狠| 久久av资源站| 国产偷v国产偷v亚洲高清| 国产成人免费xxxxxxxx| 国产精品久久综合| 91麻豆国产精品久久| 亚洲大片免费看| 欧美一卡2卡三卡4卡5免费| 精品一区二区三区影院在线午夜| 欧美zozo另类异族| 成人午夜电影网站| 一区二区三区欧美日| 欧美日本高清视频在线观看| 久久成人免费网| 国产精品麻豆网站| 欧美吻胸吃奶大尺度电影| 日韩不卡一区二区|