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

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

?? intpwr.c

?? 在PC上通過USB與C8051通信
?? 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一区二区三区免费野_久草精品视频
夜夜亚洲天天久久| av网站免费线看精品| 天堂一区二区在线| 精品一区二区在线播放| 91麻豆免费视频| 精品卡一卡二卡三卡四在线| 夜色激情一区二区| 国产69精品久久久久777| 欧美日韩精品欧美日韩精品一综合| 精品国产一区二区三区不卡| 午夜欧美在线一二页| 99在线精品一区二区三区| 欧美va亚洲va| 日本少妇一区二区| 欧美在线小视频| 亚洲欧洲日本在线| 成人av在线网站| 久久久国际精品| 九色|91porny| 日韩一区和二区| 亚洲一区自拍偷拍| 色香蕉久久蜜桃| 国产精品久久久久久久浪潮网站 | 国产精品2024| 日韩欧美精品在线视频| 亚洲大片免费看| 欧美三级日韩三级国产三级| 悠悠色在线精品| 在线亚洲欧美专区二区| 综合色中文字幕| 成av人片一区二区| 中文字幕亚洲一区二区av在线| 国产99一区视频免费| 国产欧美一区二区三区网站| 精品一区二区三区的国产在线播放| 欧美麻豆精品久久久久久| 一区二区三区欧美日韩| 欧美丝袜丝交足nylons图片| 亚洲一级二级三级在线免费观看| 欧美视频在线一区| 日韩av不卡一区二区| 日韩免费福利电影在线观看| 久久99国产精品免费网站| 日韩欧美亚洲一区二区| 国产综合色视频| 中文字幕一区二区三区在线观看 | 日韩av网站在线观看| 欧美日韩一级二级三级| 麻豆免费精品视频| 久久久久久免费网| av高清不卡在线| 一区二区三区鲁丝不卡| 正在播放亚洲一区| 国产成人在线免费观看| 国产精品久久久一本精品| 日本久久一区二区三区| 婷婷久久综合九色综合绿巨人| 日韩视频中午一区| 另类综合日韩欧美亚洲| 国产农村妇女毛片精品久久麻豆| 成人精品视频一区二区三区| 亚洲激情图片qvod| 日韩视频不卡中文| 风间由美一区二区三区在线观看 | 97se亚洲国产综合自在线观| 亚洲高清久久久| ww亚洲ww在线观看国产| 色呦呦一区二区三区| 美日韩一区二区| 亚洲色欲色欲www| 精品嫩草影院久久| 91国偷自产一区二区使用方法| 秋霞电影网一区二区| 国产农村妇女毛片精品久久麻豆| 欧美系列日韩一区| 国产美女视频91| 亚洲亚洲人成综合网络| 国产亚洲一本大道中文在线| 欧美亚洲日本一区| 国产馆精品极品| 日本欧美一区二区在线观看| 国产精品日日摸夜夜摸av| 欧美肥妇bbw| 99久久久久久99| 精品一区二区影视| 五月综合激情婷婷六月色窝| 亚洲国产成人一区二区三区| 日韩一二三区不卡| 在线一区二区三区做爰视频网站| 国精品**一区二区三区在线蜜桃| 亚洲午夜激情网页| 国产精品久久久久久久久免费相片 | 国内精品久久久久影院薰衣草| 亚洲日本护士毛茸茸| 久久久久9999亚洲精品| 欧美精品在线一区二区三区| 日本道在线观看一区二区| 韩国v欧美v日本v亚洲v| 亚洲一二三四区不卡| 国产精品三级在线观看| 欧美成人高清电影在线| 欧美日韩精品欧美日韩精品一| 99re66热这里只有精品3直播 | 精品成人a区在线观看| 欧美日韩中文字幕一区| 91偷拍与自偷拍精品| 国产在线播放一区| 麻豆精品视频在线观看视频| 日韩二区在线观看| 天天影视涩香欲综合网| 一区二区高清在线| 亚洲欧洲av色图| 国产精品成人一区二区艾草| 久久久久久久久久久久久女国产乱| 日韩视频中午一区| 日韩免费看的电影| 日韩一二三区不卡| 日韩一级完整毛片| 日韩亚洲欧美在线观看| 欧美精品九九99久久| 欧美综合亚洲图片综合区| 在线一区二区三区| 欧美三级三级三级爽爽爽| 欧洲亚洲精品在线| 欧美视频三区在线播放| 欧美日韩免费观看一区二区三区 | 亚洲一区二区在线视频| 亚洲综合男人的天堂| 亚洲午夜激情网站| 日本大胆欧美人术艺术动态| 日韩电影一二三区| 精品一区二区三区在线播放视频| 韩国三级在线一区| eeuss影院一区二区三区| 91亚洲男人天堂| 欧美日韩国产系列| 精品福利一二区| 国产午夜亚洲精品理论片色戒| 久久五月婷婷丁香社区| 国产精品无码永久免费888| 最近日韩中文字幕| 午夜伊人狠狠久久| 麻豆91精品视频| 丁香婷婷综合网| 欧日韩精品视频| 精品少妇一区二区三区在线播放| 久久久久久久久一| 亚洲精品国产无天堂网2021| 日韩在线一区二区三区| 精品一区二区国语对白| 99r精品视频| 日韩视频一区二区在线观看| 国产人成亚洲第一网站在线播放 | 国产精品视频你懂的| 午夜精品久久久久久久蜜桃app| 久久精品av麻豆的观看方式| 成人av在线播放网址| 欧美三级视频在线| 国产欧美日韩卡一| 亚洲一区二区高清| 国产乱妇无码大片在线观看| 日本精品一区二区三区高清| 欧美精品 日韩| 国产精品免费免费| 日本亚洲天堂网| 91小视频在线免费看| 日韩欧美电影一二三| 国产精品高清亚洲| 麻豆免费精品视频| 欧美视频一区二区三区在线观看| 欧美激情一区二区在线| 日本中文在线一区| 99久久精品国产导航| 久久久久久久综合色一本| 午夜久久久影院| 色偷偷88欧美精品久久久| 久久久久久电影| 免费不卡在线观看| 欧美日韩免费视频| 亚洲精品视频一区二区| 国产福利精品一区二区| 日韩视频中午一区| 天天影视涩香欲综合网| 一本一道波多野结衣一区二区| 国产嫩草影院久久久久| 精品无人码麻豆乱码1区2区| 91精品国产91热久久久做人人| 亚洲你懂的在线视频| 波多野结衣精品在线| 久久新电视剧免费观看| 蜜桃在线一区二区三区| 精品视频在线看| 亚洲国产视频一区二区| 波多野结衣中文字幕一区| 日本一区二区三级电影在线观看| 日本成人在线一区| 欧美日本在线播放| 亚洲成人精品一区二区| 欧美日韩黄色影视| 天天色天天操综合|