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

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

?? isopwr.c

?? winddk src目錄下的WDM源碼壓縮!
?? 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;
    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;
        }

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

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

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

            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,
            (PIO_COMPLETION_ROUTINE)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,
            (PIO_COMPLETION_ROUTINE)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 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);


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

    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99精品国产麻豆婷婷| 色噜噜狠狠色综合中国| 色综合久久六月婷婷中文字幕| 国产午夜精品久久久久久免费视| 亚洲成人av中文| 欧美日韩亚洲综合一区| 亚洲3atv精品一区二区三区| 色狠狠av一区二区三区| 亚洲不卡在线观看| 91国内精品野花午夜精品| 亚洲成人在线观看视频| 精品蜜桃在线看| 色又黄又爽网站www久久| 天天免费综合色| 色综合久久久久久久| 亚洲一区在线观看网站| 欧美日韩国产首页| 免费观看成人av| 欧美性猛交xxxx乱大交退制版| 秋霞av亚洲一区二区三| 国产精品入口麻豆九色| 91亚洲永久精品| 久久99国产精品久久99果冻传媒| 欧美激情在线看| 欧美精品亚洲一区二区在线播放| 狠狠色丁香久久婷婷综合_中| 国产精品女同一区二区三区| 欧美亚洲综合色| 国产精品影视在线| 亚洲超碰精品一区二区| 国产精品免费免费| 日韩三级视频在线看| 在线观看亚洲精品视频| 国产伦精品一区二区三区免费迷 | 国产精品一级在线| 亚洲综合免费观看高清完整版| 久久精品夜色噜噜亚洲a∨| 欧美日韩精品二区第二页| 成人国产精品免费网站| 免费成人结看片| 日韩极品在线观看| 一区二区在线看| 国产精品第13页| 日本一二三不卡| 国产欧美日韩精品在线| 久久综合色综合88| 日韩一卡二卡三卡国产欧美| 3d动漫精品啪啪1区2区免费| 日本久久一区二区三区| 国产99久久久久久免费看农村| 91成人免费在线视频| av中文字幕在线不卡| 91在线丨porny丨国产| 一本久道久久综合中文字幕| 在线日韩av片| 欧美日韩色一区| 欧美一级二级三级乱码| 精品电影一区二区| 国产亚洲精品中文字幕| 中文字幕免费观看一区| 亚洲男人都懂的| 天堂午夜影视日韩欧美一区二区| 天天综合天天综合色| 久久精品国产**网站演员| 国产在线精品一区二区| 91日韩一区二区三区| 欧美精品日韩一本| 久久综合色一综合色88| 亚洲日本电影在线| 激情综合网av| 在线中文字幕一区二区| 日韩免费视频一区二区| 中文字幕欧美区| 久久99热国产| 色av一区二区| 久久久久久亚洲综合影院红桃| 日韩欧美二区三区| 国产精品你懂的| 男男成人高潮片免费网站| 91在线视频播放| 2019国产精品| 午夜电影网一区| 色天天综合色天天久久| 国产午夜精品一区二区三区嫩草 | 一区二区免费看| 丁香五精品蜜臀久久久久99网站| 欧美日韩不卡在线| 一区二区三区加勒比av| 色香蕉久久蜜桃| 国产精品视频一二三区| 成人激情午夜影院| 欧美极品xxx| 99久久精品免费看国产免费软件| 久久久欧美精品sm网站| 国产在线播放一区三区四| 91精品国产综合久久蜜臀| 亚洲国产一区二区视频| 日本高清不卡视频| 一区二区久久久| 欧美美女黄视频| 六月丁香婷婷色狠狠久久| 日韩欧美123| 国产经典欧美精品| ...av二区三区久久精品| 在线亚洲一区观看| 日本麻豆一区二区三区视频| 久久亚区不卡日本| 国v精品久久久网| 夜夜嗨av一区二区三区网页| 日本一区二区三区久久久久久久久不 | 亚洲一区二区三区四区五区中文| 欧美日本韩国一区| 蜜臀av一区二区| 亚洲乱码国产乱码精品精的特点| 91美女视频网站| 久久99久久99| 一区二区三区鲁丝不卡| 精品国内片67194| 色伊人久久综合中文字幕| 看电影不卡的网站| 亚洲精品老司机| 久久久99精品免费观看不卡| 日本高清无吗v一区| 国产99一区视频免费| 天堂一区二区在线| 国产精品毛片久久久久久久| 91精品视频网| 欧美三级电影在线看| eeuss鲁片一区二区三区在线观看| 免费欧美在线视频| 日韩av在线发布| 亚洲国产视频网站| 亚洲欧美另类小说| 国产精品视频看| 久久久精品tv| 国产视频一区在线播放| 日韩欧美亚洲另类制服综合在线| 色婷婷综合久久久中文一区二区 | 久久婷婷久久一区二区三区| 欧美日韩中文字幕精品| 色天使久久综合网天天| 色婷婷亚洲婷婷| 欧美手机在线视频| 欧美日韩国产成人在线免费| 欧美在线一二三| 欧美日韩精品系列| 欧美剧在线免费观看网站| 欧洲日韩一区二区三区| 精品理论电影在线观看 | 久久精品视频一区二区三区| 欧美精品一区二区三区视频 | 欧美精品日韩一本| 欧美xxxx老人做受| 亚洲国产精品激情在线观看| 亚洲日本中文字幕区| 一区二区三区免费观看| 五月婷婷欧美视频| 韩国三级在线一区| av中文字幕在线不卡| 欧美视频在线一区| 久久夜色精品一区| 亚洲你懂的在线视频| 日本不卡不码高清免费观看| 国产精品亚洲一区二区三区妖精| 成人av集中营| 日韩午夜激情av| 亚洲欧美一区二区三区极速播放| 午夜精品国产更新| 国产91精品一区二区| 欧美亚洲综合久久| 国产日韩欧美电影| 香蕉影视欧美成人| 99久久综合国产精品| 欧美一区二区三区不卡| 久久先锋影音av鲁色资源网| 亚洲第一狼人社区| 99在线热播精品免费| 久久久久久久久蜜桃| 天天av天天翘天天综合网 | 国产一区91精品张津瑜| 欧美日韩精品电影| 亚洲精品一二三四区| 国产91色综合久久免费分享| 日韩一级片网址| 日本欧美加勒比视频| 欧美三级韩国三级日本三斤| 国产清纯美女被跳蛋高潮一区二区久久w| 无吗不卡中文字幕| 欧美精品v日韩精品v韩国精品v| 一区二区久久久久久| 欧美日韩一区二区三区在线| 狠狠色丁香九九婷婷综合五月| 欧美三级乱人伦电影| 亚洲制服丝袜av| 在线观看日产精品| 午夜精品福利视频网站| 欧美日韩免费观看一区三区| 丝袜诱惑制服诱惑色一区在线观看| 色先锋资源久久综合| 亚洲国产美女搞黄色|