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

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

?? intpwr.c

?? 用SDK寫的USB通訊的源碼,可實現PC與單板機的通訊
?? 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一区二区三区免费野_久草精品视频
欧美一区二区成人6969| 国产一区欧美日韩| 欧美日韩免费观看一区三区| 亚洲精品高清视频在线观看| 日本韩国欧美三级| 亚洲综合色在线| 欧美日韩国产综合视频在线观看| 午夜亚洲国产au精品一区二区| 欧美喷潮久久久xxxxx| 丝袜诱惑制服诱惑色一区在线观看| 7777精品伊人久久久大香线蕉超级流畅| 精品少妇一区二区三区日产乱码| 精品一区免费av| 国产视频911| 日本韩国一区二区三区| 日韩中文欧美在线| 久久精品水蜜桃av综合天堂| 99久久久久久99| 偷窥少妇高潮呻吟av久久免费| 日韩欧美一区二区免费| 成人午夜av电影| 亚洲成人动漫在线免费观看| 日韩欧美一区在线| 99久久综合精品| 日本视频在线一区| 国产精品网站导航| 欧美另类videos死尸| 国产乱子伦视频一区二区三区 | 91精品国产综合久久精品app | 国产又黄又大久久| 亚洲三级电影网站| 日韩欧美中文字幕制服| av成人免费在线| 欧美96一区二区免费视频| 国产精品久久一卡二卡| 3d动漫精品啪啪1区2区免费| 成人app网站| 美女一区二区三区在线观看| 中文字幕亚洲视频| 日韩欧美国产午夜精品| 色婷婷激情久久| 国产精品 日产精品 欧美精品| 亚洲国产一二三| 国产欧美视频一区二区三区| 91麻豆精品国产自产在线| 99re这里只有精品6| 国产曰批免费观看久久久| 亚洲午夜在线电影| 亚洲日本青草视频在线怡红院| 日韩精品一区二区三区老鸭窝| 91国产视频在线观看| 成人一区二区三区在线观看| 久久国产精品99久久人人澡| 亚洲韩国精品一区| 亚洲同性同志一二三专区| 久久亚洲精品小早川怜子| 91精品国模一区二区三区| 色香色香欲天天天影视综合网| 国产成人精品一区二| 美女视频一区在线观看| 亚洲成av人片www| 亚洲人成7777| 亚洲日本一区二区三区| 国产精品久久久一本精品| 久久精品在线观看| 精品少妇一区二区| 精品国产伦一区二区三区观看体验 | 亚洲色图清纯唯美| 亚洲少妇30p| 日本强好片久久久久久aaa| 亚洲色图20p| 日本一区二区免费在线观看视频 | 国产亚洲欧美在线| 欧美va亚洲va| 欧美一级爆毛片| 日韩欧美在线网站| 日韩美一区二区三区| 欧美电影免费观看高清完整版在 | 欧美性大战久久| 色偷偷久久人人79超碰人人澡| 成人性色生活片| 成人黄色大片在线观看| 成人午夜av在线| 99久久婷婷国产综合精品电影| 成人国产精品免费观看视频| 成人午夜电影网站| av亚洲产国偷v产偷v自拍| 国产成人免费视频精品含羞草妖精| 国产在线日韩欧美| 国产91丝袜在线播放九色| 成人av网站在线观看免费| 成人黄色av电影| 色婷婷综合激情| 欧美三级电影网| 欧美一卡2卡3卡4卡| 亚洲精品一线二线三线无人区| 国产午夜精品理论片a级大结局| 国产午夜三级一区二区三| 亚洲色图欧美偷拍| 日韩精品电影一区亚洲| 精品一区二区三区久久| 高潮精品一区videoshd| 色综合久久综合网欧美综合网| 欧美日韩一卡二卡三卡| 日韩你懂的在线观看| 中文乱码免费一区二区| 亚洲第一激情av| 国产在线精品免费| 91亚洲精华国产精华精华液| 欧美精品在线视频| 久久亚洲一级片| 亚洲欧美视频在线观看视频| 视频在线观看一区| 国产凹凸在线观看一区二区| 色av一区二区| 日韩欧美国产综合一区| 亚洲欧洲av一区二区三区久久| 亚洲成av人在线观看| 国产福利精品一区| 欧美日韩激情一区二区三区| 久久久久久久久久电影| 亚洲综合男人的天堂| 久久国产精品72免费观看| 91在线视频官网| 精品久久一二三区| 一区二区成人在线观看| 激情综合色综合久久综合| 色婷婷精品久久二区二区蜜臀av| 欧美精品一区二区三区高清aⅴ| 亚洲欧美偷拍卡通变态| 国产激情偷乱视频一区二区三区 | 日本美女一区二区三区视频| 国产精品综合在线视频| 精品视频一区二区三区免费| 国产免费成人在线视频| 免费观看一级特黄欧美大片| 色综合天天综合色综合av | 国产91精品精华液一区二区三区| 欧美三级视频在线观看| 久久精品亚洲麻豆av一区二区| 午夜精品福利一区二区三区av | 一区二区理论电影在线观看| 国产精品资源在线看| 日韩一区二区在线看| 伊人色综合久久天天| 国产成人精品免费在线| 日韩一区二区免费电影| 亚洲成人免费电影| 972aa.com艺术欧美| 国产精品青草久久| 国产一区二区三区久久久| 欧美群妇大交群的观看方式| 亚洲人精品午夜| 国产凹凸在线观看一区二区| 2022国产精品视频| 青青青伊人色综合久久| 7777精品伊人久久久大香线蕉完整版 | 亚洲精品你懂的| 成人午夜视频网站| 久久精品一区二区三区四区 | 国产成人免费视频网站| 欧美大胆一级视频| 青青草国产成人av片免费| 欧美日高清视频| 亚洲福利电影网| 欧美日韩一二三区| 亚洲成av人在线观看| 欧美日韩亚洲不卡| 午夜精品成人在线视频| 制服丝袜亚洲播放| 秋霞国产午夜精品免费视频| 欧美一区二区三区日韩| 蜜臀91精品一区二区三区 | 成人精品视频.| 亚洲欧美一区二区在线观看| aa级大片欧美| 一区二区三区加勒比av| 在线免费亚洲电影| 亚洲v中文字幕| 5858s免费视频成人| 韩国欧美国产一区| 日本一区二区在线不卡| 99久久99久久精品免费看蜜桃| 亚洲精品免费看| 在线不卡免费欧美| 久久爱另类一区二区小说| 亚洲精品在线三区| 97超碰欧美中文字幕| 亚洲成人激情综合网| 日韩久久精品一区| 懂色av一区二区在线播放| 亚洲日本成人在线观看| 欧美三级视频在线观看| 久久狠狠亚洲综合| 中文字幕一区二区三| 欧美日韩久久一区| 国产一区二区三区四区五区入口| 国产精品欧美久久久久无广告 | 日韩欧美国产午夜精品| 国产成人精品综合在线观看 |