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

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

?? intpwr.c

?? Silicon Laboratories C8051F320/1單片機例子
?? 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一区二区三区免费野_久草精品视频
在线成人免费视频| 欧美老人xxxx18| 热久久免费视频| 欧美极品aⅴ影院| 欧美三级电影网| 成人性生交大片免费看中文网站| 亚洲大尺度视频在线观看| 欧美mv和日韩mv的网站| 欧美主播一区二区三区| 国内不卡的二区三区中文字幕 | 久久夜色精品一区| 欧美日韩免费在线视频| 丁香婷婷综合激情五月色| 性做久久久久久久久| 亚洲美女电影在线| 国产亚洲成年网址在线观看| 欧美电影免费观看完整版| 色琪琪一区二区三区亚洲区| 免费成人美女在线观看| 亚洲图片一区二区| 一区二区视频免费在线观看| 国产欧美一区二区三区在线看蜜臀 | 91女厕偷拍女厕偷拍高清| 麻豆精品视频在线观看视频| 日韩综合在线视频| 五月天激情综合网| 五月天久久比比资源色| 日韩成人伦理电影在线观看| 婷婷六月综合网| 免费看黄色91| 韩国欧美国产1区| 国产999精品久久久久久| 成人夜色视频网站在线观看| 成人亚洲精品久久久久软件| 在线一区二区视频| 欧美综合视频在线观看| 日韩三级在线观看| 国产三级精品在线| 亚洲黄色免费电影| 另类小说一区二区三区| 26uuu久久综合| 亚洲婷婷国产精品电影人久久| 国产精品久久久久永久免费观看| voyeur盗摄精品| 欧美videos大乳护士334| 精品国内二区三区| **欧美大码日韩| 国产毛片精品国产一区二区三区| 欧美日产国产精品| 久久久久久久久伊人| 麻豆成人久久精品二区三区红| 欧美理论在线播放| 一区二区成人在线视频| 色狠狠桃花综合| 亚洲欧美一区二区三区久本道91| 国产美女精品人人做人人爽| 欧美日韩高清影院| 午夜在线成人av| 在线看国产日韩| 亚洲乱码中文字幕| 91精品福利在线| 日韩av不卡一区二区| 91精品久久久久久蜜臀| 免费观看成人av| xnxx国产精品| 丁香啪啪综合成人亚洲小说 | 99国内精品久久| 亚洲女同一区二区| 欧美三级电影在线看| 天天综合色天天| 久久久午夜精品| 不卡一区二区在线| 亚洲午夜精品17c| 日韩三级在线免费观看| 国产一区二区三区四区五区入口 | 色婷婷精品久久二区二区蜜臀av| 亚洲午夜国产一区99re久久| 91精品国产综合久久精品麻豆 | 亚洲一区二三区| 91麻豆精品久久久久蜜臀 | 中文成人av在线| 欧美亚洲综合色| 中文字幕一区二区三区不卡 | 欧美日韩视频在线第一区| 日韩中文字幕一区二区三区| 久久综合九色综合久久久精品综合| 岛国av在线一区| 亚洲国产视频直播| 精品国产一区二区三区四区四| zzijzzij亚洲日本少妇熟睡| 亚洲va韩国va欧美va| 精品国精品国产| 日韩免费观看高清完整版| 国产精品系列在线播放| 一级日本不卡的影视| 精品国产乱码久久久久久闺蜜| 99久久国产综合精品麻豆| 日韩黄色一级片| 国产精品天天摸av网| 欧美老肥妇做.爰bbww视频| 国产精品亚洲成人| 亚洲电影你懂得| 国产精品久久久久9999吃药| 欧美一卡在线观看| 91在线视频网址| 麻豆高清免费国产一区| 亚洲人精品午夜| www久久久久| 欧美人与z0zoxxxx视频| 丁香网亚洲国际| 免费人成精品欧美精品| 国产精品传媒在线| 日韩美女视频一区二区在线观看| 色呦呦国产精品| 国产乱对白刺激视频不卡| 亚洲成人免费影院| 国产精品素人视频| 91精品国产综合久久久久| 处破女av一区二区| 人人狠狠综合久久亚洲| 一区二区在线观看视频在线观看| 欧美精品一区二区三| 欧美日韩国产中文| 99国产精品99久久久久久| 精品一区二区免费看| 偷拍日韩校园综合在线| 亚洲男人的天堂av| 国产欧美精品一区二区色综合朱莉 | 欧美丰满美乳xxx高潮www| 99久久久久久| 国产大片一区二区| 麻豆国产精品视频| 婷婷激情综合网| 亚洲影视资源网| 亚洲日本乱码在线观看| 欧美国产一区二区| 久久婷婷成人综合色| 欧美一区二区三区视频免费| 在线一区二区观看| 99麻豆久久久国产精品免费优播| 国产精品自拍毛片| 九九精品一区二区| 美女mm1313爽爽久久久蜜臀| 亚洲国产精品人人做人人爽| 一区二区免费看| 亚洲日穴在线视频| 成人免费一区二区三区视频| 日本一二三不卡| 国产欧美精品区一区二区三区| www欧美成人18+| 亚洲精品一区二区三区在线观看| 欧美电视剧在线观看完整版| 欧美一区二区三区免费大片| 欧美精品日韩综合在线| 欧美日韩精品福利| 欧美日韩免费在线视频| 欧美性三三影院| 欧美在线制服丝袜| 欧美视频在线播放| 欧美亚洲综合在线| 欧美午夜寂寞影院| 欧美日韩久久不卡| 欧美精品精品一区| 在线综合亚洲欧美在线视频| 日韩一区二区三区视频| 日韩午夜在线观看| 欧美sm美女调教| 久久久噜噜噜久久中文字幕色伊伊| 欧美精品一区二| 国产欧美日韩另类一区| 国产精品蜜臀av| 国产suv精品一区二区883| 国产一区二区三区久久久 | 亚洲一区在线观看网站| 亚洲一区视频在线| 三级亚洲高清视频| 久久精品国产精品青草| 韩国女主播成人在线观看| 国产成人一区二区精品非洲| 成人av网站免费| 色偷偷久久人人79超碰人人澡| 欧美午夜不卡在线观看免费| 在线播放国产精品二区一二区四区| 日韩一区二区三区视频在线观看| 精品国产伦一区二区三区观看方式| 久久九九久精品国产免费直播| 国产精品美女久久久久av爽李琼| 亚洲免费av观看| 日韩精品视频网| 国产一区二区伦理| www.日韩大片| 欧美日韩一区二区三区视频| 日韩欧美中文字幕精品| 国产午夜久久久久| 亚洲黄色片在线观看| 日韩av中文在线观看| 国产乱码精品一区二区三区五月婷| 97久久超碰精品国产| 欧美妇女性影城| 国产日韩视频一区二区三区|