亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
在线精品视频免费观看| 久久这里只有精品首页| 亚洲电影中文字幕在线观看| 欧美日韩一区久久| 奇米在线7777在线精品| 精品av久久707| 国产69精品久久久久毛片| 亚洲欧洲日韩av| 在线视频国内自拍亚洲视频| 性久久久久久久久| 精品人在线二区三区| 国产成人免费视频精品含羞草妖精 | 91成人免费电影| 亚洲成av人片一区二区梦乃| 精品成人免费观看| 99re8在线精品视频免费播放| 亚洲综合一区二区精品导航| 欧美一区二区三区小说| 国产成人99久久亚洲综合精品| 亚洲色图在线视频| 9191久久久久久久久久久| 久久国产尿小便嘘嘘| 国产精品乱码久久久久久| 欧美自拍丝袜亚洲| 精品影视av免费| 国产精品国产三级国产aⅴ入口| 欧美视频一区二区| 国模少妇一区二区三区| 亚洲免费三区一区二区| 91精品国产品国语在线不卡| 国产成人综合在线观看| 亚洲自拍另类综合| 久久伊99综合婷婷久久伊| 91视视频在线直接观看在线看网页在线看 | 亚洲一二三专区| 精品国产伦一区二区三区免费| av日韩在线网站| 日韩高清欧美激情| 国产精品久久久久影院亚瑟 | 国产精品午夜在线观看| 欧美日韩一区视频| 国产精华液一区二区三区| 亚洲综合免费观看高清完整版在线 | 国产精品美女久久久久av爽李琼| 一本大道久久a久久综合| 老司机午夜精品| 综合久久久久综合| 久久嫩草精品久久久久| 欧美亚洲一区三区| 成人深夜在线观看| 毛片av一区二区| 亚洲人被黑人高潮完整版| 精品成人一区二区三区四区| 欧美性生活久久| 国产99久久久精品| 老司机精品视频导航| 亚洲精品你懂的| 久久婷婷色综合| 欧美另类一区二区三区| 99精品国产热久久91蜜凸| 极品瑜伽女神91| 亚洲国产精品尤物yw在线观看| 欧美激情一区二区三区四区| 欧美一区二区免费观在线| 色伊人久久综合中文字幕| 国产剧情一区二区| 日本强好片久久久久久aaa| 亚洲精品乱码久久久久久| 国产欧美日韩另类一区| 日韩一区国产二区欧美三区| 欧美专区在线观看一区| 不卡一卡二卡三乱码免费网站| 久久国产精品区| 午夜国产精品一区| 亚洲男人的天堂一区二区 | 久久久.com| 欧美一区二区三区性视频| 欧美视频在线播放| 色婷婷国产精品| 成人h版在线观看| 国产精品亚洲专一区二区三区| 蜜桃视频一区二区| 午夜精品福利一区二区蜜股av| 亚洲激情一二三区| 中文字幕一区二区三区视频| 久久九九99视频| 精品乱码亚洲一区二区不卡| 欧美一级二级在线观看| 欧美日韩卡一卡二| 在线精品观看国产| 色网综合在线观看| 99re这里只有精品6| 国产.欧美.日韩| 国产精品亚洲综合一区在线观看| 久久99久久99小草精品免视看| 日韩va亚洲va欧美va久久| 亚洲国产一区在线观看| 亚洲国产日韩一级| 午夜精品视频一区| 亚洲第一激情av| 五月天亚洲婷婷| 天天av天天翘天天综合网| 亚洲一区二区视频| 亚洲综合免费观看高清完整版在线 | 激情综合色综合久久综合| 久久99国产精品久久| 麻豆91在线观看| 久久国产精品一区二区| 精品一区二区免费在线观看| 久久91精品国产91久久小草| 老司机精品视频在线| 国内精品伊人久久久久av影院| 国产精品一区二区久久精品爱涩| 国产精品一区二区在线观看不卡 | 欧美精品在线观看一区二区| 欧美放荡的少妇| 欧美一区二区三区小说| 精品欧美乱码久久久久久| 欧美精品一区二区蜜臀亚洲| 久久精品视频在线免费观看 | 久久香蕉国产线看观看99| 久久久久成人黄色影片| 国产精品视频线看| 综合色中文字幕| 亚洲一区二区在线视频| 日本色综合中文字幕| 精品综合久久久久久8888| 国产精品资源在线观看| 成人永久免费视频| 色综合久久天天| 欧美日韩一区二区在线观看视频| 91精品国产综合久久香蕉的特点| 日韩欧美一区在线| 久久久电影一区二区三区| 中文字幕一区视频| 亚洲第四色夜色| 激情图区综合网| 99精品一区二区三区| 欧美色网站导航| 欧美va亚洲va| 国产精品免费网站在线观看| 亚洲精品欧美激情| 免费成人性网站| 国产成人精品综合在线观看 | 亚洲日本一区二区三区| 亚洲最大成人综合| 麻豆精品视频在线观看免费| 国产成人在线视频网址| 日本精品一区二区三区高清 | 中文字幕中文乱码欧美一区二区| 一区二区免费在线播放| 欧美肥妇毛茸茸| 欧美精品一区二区三区视频| 亚洲日本免费电影| 日日摸夜夜添夜夜添精品视频 | 国产91在线看| 欧美午夜在线一二页| 日韩精品一区在线| 国产精品国产三级国产aⅴ原创| 午夜久久久久久电影| 国产一区二区精品久久91| 91丝袜高跟美女视频| 日韩免费高清视频| 亚洲欧美自拍偷拍色图| 日韩在线一区二区三区| 成人avav影音| 日韩一区二区在线观看视频播放| 欧美国产国产综合| 日韩电影免费在线看| 暴力调教一区二区三区| 91精品在线免费| 国产精品成人网| 蜜臀91精品一区二区三区| 99国产精品久久| 精品入口麻豆88视频| 亚洲精品欧美激情| 国产麻豆欧美日韩一区| 欧美天堂一区二区三区| 国产亚洲综合性久久久影院| 午夜精品久久久久久久99水蜜桃| 福利91精品一区二区三区| 91精品在线观看入口| 综合色中文字幕| 激情综合色综合久久| 欧美日韩国产精品成人| 中文字幕在线不卡一区二区三区| 裸体一区二区三区| 欧美怡红院视频| 一区在线播放视频| 激情综合网最新| 3atv在线一区二区三区| 自拍视频在线观看一区二区| 国内成人精品2018免费看| 在线电影一区二区三区| 亚洲男女一区二区三区| 高清beeg欧美| 精品日韩在线观看| 午夜在线电影亚洲一区| 色欧美片视频在线观看| 国产精品乱人伦一区二区|