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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? intpwr.c

?? C8051F320單片機(jī)int傳輸形式的usb驅(qū)動(dòng)程序
?? C
?? 第 1 頁 / 共 3 頁
字號(hào):
/*++

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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品久久久久久久多人混战| 这里是久久伊人| 国产传媒一区在线| 久草这里只有精品视频| 五月天网站亚洲| 亚洲影院在线观看| 亚洲成人免费影院| 天天av天天翘天天综合网色鬼国产| 一区二区三区在线免费观看| 一区二区三区在线视频观看 | 欧美亚洲动漫制服丝袜| 91在线看国产| 91视频在线看| 在线观看国产一区二区| 欧美日韩精品久久久| 欧美精品在线视频| 欧美一区二区三区婷婷月色| 日韩三级视频中文字幕| 精品裸体舞一区二区三区| 久久蜜臀中文字幕| 亚洲国产精品成人综合| 亚洲日韩欧美一区二区在线| 亚洲免费伊人电影| 亚洲国产日产av| 奇米影视在线99精品| 色哟哟国产精品免费观看| 欧美视频三区在线播放| 欧美一区二区福利在线| 亚洲精品一线二线三线| 国产精品丝袜一区| 亚洲精品少妇30p| 亚洲高清免费视频| 捆绑变态av一区二区三区| 国内外精品视频| 成人免费不卡视频| 欧美日韩精品一二三区| 精品欧美久久久| 国产精品成人在线观看| 日日摸夜夜添夜夜添精品视频| 激情综合色综合久久| av中文字幕亚洲| 精品1区2区3区| 久久久久久99精品| 一区二区三区中文字幕| 久久av中文字幕片| 99精品热视频| 欧美一区二区三区成人| 国产精品久久久久影院老司| 午夜精品aaa| 成人网页在线观看| 91.com视频| 综合在线观看色| 日本aⅴ免费视频一区二区三区 | 欧美综合视频在线观看| 欧美成人精精品一区二区频| 日韩女优电影在线观看| 亚洲欧美一区二区在线观看| 午夜精品123| 成人国产精品免费观看视频| 欧美日韩国产首页| 精品国产3级a| 亚洲品质自拍视频| 极品销魂美女一区二区三区| 色婷婷av一区二区| 久久久久久久久久久久久女国产乱| 国产不卡免费视频| 欧美日本韩国一区二区三区视频| 国产女主播在线一区二区| 日韩精品乱码免费| 色偷偷88欧美精品久久久| 久久嫩草精品久久久久| 午夜精品成人在线视频| 91在线一区二区三区| 国产日韩影视精品| 麻豆精品国产传媒mv男同| 在线观看成人小视频| 国产日产精品一区| 黄色成人免费在线| 欧美一区二区三区日韩视频| 一区二区欧美国产| 91亚洲国产成人精品一区二区三| 久久综合色之久久综合| 日本一不卡视频| 欧美色综合网站| 一区二区高清在线| 99久久精品国产一区二区三区| 久久久综合网站| 久久精品99久久久| 日韩一级黄色大片| 全国精品久久少妇| 91精品国产美女浴室洗澡无遮挡| 一区二区三区中文字幕电影| 91在线一区二区| 综合激情网...| k8久久久一区二区三区 | 一区二区三区在线观看欧美| 成人免费精品视频| 国产精品免费免费| 国产精品 欧美精品| 久久久亚洲高清| 国产毛片精品视频| 久久亚洲精华国产精华液| 一本色道久久加勒比精品| 国产精品成人网| caoporm超碰国产精品| 国产精品天干天干在观线| 国产精品99久久久| 国产色婷婷亚洲99精品小说| 国产麻豆成人精品| 欧美国产丝袜视频| av在线不卡免费看| 亚洲欧美精品午睡沙发| 一本色道久久综合狠狠躁的推荐| 国产精品毛片久久久久久久| 盗摄精品av一区二区三区| 国产精品久久久久久久久久免费看| 成人激情午夜影院| 亚洲免费视频成人| 欧美日本在线看| 美女视频黄频大全不卡视频在线播放| 日韩欧美一二三四区| 久久99国产精品成人| 久久精品一区八戒影视| 成人精品亚洲人成在线| 亚洲欧美日韩综合aⅴ视频| 欧美吻胸吃奶大尺度电影 | 国产东北露脸精品视频| 中文av一区特黄| 色婷婷综合五月| 青青草97国产精品免费观看| 26uuu国产一区二区三区| 成人教育av在线| 亚洲午夜羞羞片| 精品国产污污免费网站入口 | 99久久精品国产观看| 亚洲激情图片一区| 制服丝袜中文字幕亚洲| 国产一区二区三区黄视频 | 极品少妇xxxx偷拍精品少妇| 中文子幕无线码一区tr| 在线欧美日韩精品| 久久精品99久久久| 亚洲色图制服诱惑| 日韩三级在线免费观看| youjizz国产精品| 日韩激情一二三区| 中文av一区特黄| 欧美另类videos死尸| 国产高清不卡一区| 一区二区三区精品视频在线| 精品国产成人系列| 色8久久人人97超碰香蕉987| 免费成人在线观看| 一区二区中文视频| 欧美一级精品大片| 91丨九色porny丨蝌蚪| 美国欧美日韩国产在线播放 | 国产黄色91视频| 亚洲一区二区成人在线观看| 精品久久人人做人人爱| 一本久久a久久免费精品不卡| 免费成人结看片| 亚洲欧美偷拍三级| 久久精品亚洲国产奇米99| 欧美少妇一区二区| 成人激情免费电影网址| 日韩中文字幕不卡| 综合婷婷亚洲小说| 久久无码av三级| 欧美高清一级片在线| 91在线观看视频| 国产精品99久久久久久有的能看| 99视频精品全部免费在线| 喷水一区二区三区| 亚洲美女视频在线| 国产日本欧美一区二区| 91精品国产综合久久久蜜臀粉嫩 | 99re6这里只有精品视频在线观看| 日本不卡视频一二三区| 亚洲综合在线电影| 国产精品久久久久久久久晋中| 欧美第一区第二区| 4438x亚洲最大成人网| 欧日韩精品视频| 99国产精品一区| 高清beeg欧美| 韩国av一区二区三区在线观看| 午夜精品一区二区三区电影天堂| 亚洲婷婷综合色高清在线| 欧美高清在线精品一区| 精品久久五月天| 欧美不卡一二三| 欧美一区二区三区在线观看视频 | 日韩美女一区二区三区四区| 欧美中文字幕一二三区视频| 91浏览器在线视频| 97国产精品videossex| 不卡视频一二三四| 成人免费三级在线| 成人美女视频在线观看18|