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

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

?? intpwr.c

?? c8051f340的詳細程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Module Name:

    intpwr.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 "intusb.h"
#include "intpwr.h"
#include "intpnp.h"
#include "intdev.h"
#include "intrwr.h"
#include "intwmi.h"
#include "intusr.h"
#ifdef WIN98DRIVER
#include "intwdm98.h"
#endif


NTSTATUS
IntUsb_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( ("IntUsb_DispatchPower::"));
    IntUsb_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::"));
        IntUsb_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( ("IntUsb_DispatchPower::"));
        IntUsb_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));

    //
    // Fail a query for a power state incompatible with waking up the system
    //

    if((deviceExtension->WaitWakeEnable) &&
       (systemState > deviceExtension->DeviceCapabilities.SystemWake)) {

        KdPrint( ("Query for an incompatible system power state\n"));

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        KdPrint( ("HandleSystemQueryPower::"));
        IntUsb_IoDecrement(deviceExtension);

        return ntStatus;
    }

    //
    // 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(deviceExtension->WaitWakeEnable &&
       deviceState > deviceExtension->DeviceCapabilities.DeviceWake) {

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        KdPrint( ("HandleDeviceQueryPower::"));
        IntUsb_IoDecrement(deviceExtension);

        return ntStatus;
    }

    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::"));
    IntUsb_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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国理伦片一区二区三区在线播放| 日韩电影免费在线| 亚洲va欧美va人人爽午夜| 久久精品二区亚洲w码| 99久久婷婷国产| 欧美一区二区三区四区高清| 国产精品国产三级国产三级人妇| 日韩一区精品字幕| 91麻豆视频网站| 久久蜜桃av一区二区天堂| 日韩精品电影在线| 色天天综合色天天久久| 国产婷婷精品av在线| 日本午夜精品视频在线观看| 欧洲国产伦久久久久久久| 欧美国产日本韩| 国产精品一区二区在线观看网站| 337p亚洲精品色噜噜噜| 亚洲一二三四在线观看| 北岛玲一区二区三区四区| www久久精品| 日韩高清不卡一区| 91在线观看污| 国产精品天干天干在观线| 久久精品72免费观看| 91精品婷婷国产综合久久竹菊| 一区二区三区精品在线观看| 91麻豆国产福利精品| 中文字幕一区二区三区在线播放| 国产麻豆成人传媒免费观看| 精品嫩草影院久久| 久久精品国产免费| 日韩免费观看2025年上映的电影| 视频在线观看91| 欧美精品日日鲁夜夜添| 亚洲成人av一区二区| 欧美日韩久久不卡| 日韩成人伦理电影在线观看| 欧美一级爆毛片| 久久精品国产亚洲a| 欧美电影免费观看高清完整版在线 | 激情丁香综合五月| 91精品国产综合久久久久久久久久 | 久久精品一区二区三区不卡牛牛| 捆绑变态av一区二区三区| 日韩无一区二区| 51久久夜色精品国产麻豆| 麻豆精品国产传媒mv男同| 欧美日本高清视频在线观看| 五月激情丁香一区二区三区| 欧美一卡在线观看| 精品综合免费视频观看| 欧美激情综合在线| 色综合天天综合网天天看片| 亚洲福利视频一区二区| 91精品国产麻豆| 国产精品一二三区| 亚洲手机成人高清视频| 精品视频123区在线观看| 久久精品国产亚洲a| 日本一区二区成人| 欧美亚洲另类激情小说| 久久国产精品99久久久久久老狼| 欧美国产一区二区在线观看 | 欧美精品久久久久久久多人混战| 日产国产高清一区二区三区| 国产午夜精品美女毛片视频| 91视频www| 美女国产一区二区三区| 亚洲国产高清在线观看视频| 欧美视频三区在线播放| 国产资源精品在线观看| 亚洲美女屁股眼交3| 日韩免费视频线观看| 91在线观看污| 久久狠狠亚洲综合| 亚洲日韩欧美一区二区在线| 欧美成人vr18sexvr| 91网址在线看| 国模套图日韩精品一区二区| 一区二区三区欧美视频| 久久久久久免费网| 欧美女孩性生活视频| 丁香婷婷综合五月| 男女男精品视频| 一区二区三区免费看视频| 国产偷v国产偷v亚洲高清| 欧美日韩精品高清| 成人成人成人在线视频| 另类综合日韩欧美亚洲| 亚洲乱码国产乱码精品精98午夜 | 日韩一区二区三区免费看 | 国产91露脸合集magnet | 日韩精品一区二区三区在线播放 | 93久久精品日日躁夜夜躁欧美| 六月婷婷色综合| 丝袜诱惑制服诱惑色一区在线观看 | 日韩欧美123| 欧美日韩国产电影| 一本久道中文字幕精品亚洲嫩| 国产在线精品一区在线观看麻豆| 亚洲va欧美va人人爽午夜| 亚洲免费在线观看| 国产精品乱人伦| 久久久久久久电影| 欧美成人精品高清在线播放| 3d动漫精品啪啪1区2区免费| 欧美日韩第一区日日骚| 色吊一区二区三区| 99久久婷婷国产精品综合| 丰满亚洲少妇av| 国产suv精品一区二区883| 精油按摩中文字幕久久| 激情成人午夜视频| 久久99精品一区二区三区 | 久久婷婷国产综合国色天香| 日韩一区二区三区视频在线| 日韩精品一区二区三区老鸭窝| 9191国产精品| 在线综合亚洲欧美在线视频| 91精品蜜臀在线一区尤物| 91麻豆精品国产91久久久使用方法| 欧美性一二三区| 欧美日本韩国一区二区三区视频| 欧美日韩精品欧美日韩精品| 欧美一区二区三区在线电影| 欧美一级片在线看| 久久天天做天天爱综合色| 欧美激情中文字幕| 亚洲精品国产一区二区精华液| 亚洲精品日产精品乱码不卡| 亚洲国产欧美在线人成| 偷拍日韩校园综合在线| 日本伊人色综合网| 国产伦精品一区二区三区免费| 国产成人午夜99999| 99久久精品国产一区二区三区| 色综合天天综合网国产成人综合天| 色哟哟国产精品免费观看| 欧美日韩精品一区二区三区四区| 337p亚洲精品色噜噜| 久久久美女毛片| 亚洲免费观看在线视频| 午夜精品免费在线| 国精产品一区一区三区mba桃花| 粉嫩蜜臀av国产精品网站| 色偷偷久久一区二区三区| 91精品久久久久久久91蜜桃| 精品国产伦一区二区三区观看方式| 国产亚洲婷婷免费| 亚洲欧美色一区| 免费一级欧美片在线观看| 国产精品一区二区在线播放| 欧美视频在线一区| 国产午夜精品一区二区| 亚洲资源中文字幕| 国内成+人亚洲+欧美+综合在线| 91女神在线视频| 日韩欧美另类在线| 中文字幕中文在线不卡住| 天天色天天爱天天射综合| 国产成人在线视频网站| 欧美日韩精品欧美日韩精品一| 国产三级一区二区三区| 亚洲成人自拍偷拍| av电影一区二区| 精品美女被调教视频大全网站| 亚洲精品视频自拍| 国产精品88av| 欧美福利视频导航| 综合av第一页| 国产高清亚洲一区| 欧美一区二区三区公司| 亚洲日本在线视频观看| 国产精品77777| 日韩欧美中文字幕一区| 亚洲成av人综合在线观看| 成人av免费在线播放| 精品免费视频一区二区| 日韩精品一卡二卡三卡四卡无卡| 成+人+亚洲+综合天堂| 精品成人在线观看| 日韩电影在线看| 欧美日韩另类国产亚洲欧美一级| 最好看的中文字幕久久| 国产成人精品影视| 欧美精品一区二区三区在线| 日本不卡视频在线| 欧美日本视频在线| 伊人一区二区三区| 99国内精品久久| 中文字幕一区二区在线播放| 成人午夜免费av| 日本一区二区三区国色天香 | 精品国产电影一区二区| 麻豆91小视频| 日韩一区二区三区视频| 免费xxxx性欧美18vr| 欧美变态tickling挠脚心| 免费久久99精品国产|