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

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

?? intpwr.c

?? CyPress的C8051F32X系列底層驅動(C語言)及上位機demo(vc環境)
?? 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一区二区三区免费野_久草精品视频
欧美丝袜丝交足nylons图片| 国产精品99久久久久久似苏梦涵| 99久久久精品免费观看国产蜜| 国产午夜久久久久| 成人白浆超碰人人人人| 日韩美女视频19| 一本大道综合伊人精品热热| 玉米视频成人免费看| 欧美人伦禁忌dvd放荡欲情| 天天做天天摸天天爽国产一区| 6080日韩午夜伦伦午夜伦| 久久精品国产精品亚洲精品| 欧美激情中文字幕一区二区| 99久久精品免费| 日韩精品色哟哟| 精品国产亚洲在线| 99国产欧美另类久久久精品| 亚洲丶国产丶欧美一区二区三区| 日韩午夜激情免费电影| 国产成人精品网址| 亚洲国产一区二区三区| 国产精品嫩草久久久久| 99久久精品99国产精品 | 欧美性大战久久| 香蕉久久夜色精品国产使用方法| 精品少妇一区二区三区| 91亚洲资源网| 免费成人性网站| 成人欧美一区二区三区小说| 欧美二区乱c少妇| 国产福利91精品一区二区三区| 亚洲美女区一区| 久久免费看少妇高潮| 一本一道波多野结衣一区二区| 美国一区二区三区在线播放| 一色屋精品亚洲香蕉网站| 欧美丰满高潮xxxx喷水动漫| 国产99久久久久| 日本 国产 欧美色综合| 亚洲色图在线播放| xfplay精品久久| 欧美日韩亚洲综合在线 | 午夜激情一区二区| 欧美激情在线看| 777久久久精品| 色综合 综合色| 国产精品一区二区在线播放| 午夜精品在线视频一区| 日韩毛片在线免费观看| 日韩欧美国产综合在线一区二区三区| 97se亚洲国产综合自在线| 久久99精品国产91久久来源| 亚洲成人中文在线| 亚洲精品国产高清久久伦理二区| 国产亚洲婷婷免费| 欧美videossexotv100| 欧美日韩视频在线一区二区| 99久久国产免费看| 国产成人av电影在线播放| 激情综合色播五月| 欧美aaaaaa午夜精品| 亚洲成av人**亚洲成av**| 夜夜嗨av一区二区三区| 中文字幕一区二区三中文字幕| 久久久久久久久岛国免费| 日韩美女视频一区二区在线观看| 欧美性xxxxxx少妇| 欧美日韩中文字幕一区| 欧美亚一区二区| 欧美大白屁股肥臀xxxxxx| 欧美日韩的一区二区| 欧美日韩一区三区四区| 欧美影院一区二区三区| 在线观看精品一区| 色哟哟国产精品| 欧美影院精品一区| 欧美美女视频在线观看| 欧美精品久久99| 欧美一区二区三区四区在线观看 | 国产成人免费视频精品含羞草妖精 | 色一情一伦一子一伦一区| a在线欧美一区| av不卡免费在线观看| av电影在线不卡| 91福利在线看| 欧美高清视频在线高清观看mv色露露十八| 欧美亚一区二区| 欧美一区二区三区在线观看视频| 欧美一个色资源| 精品国产乱码久久久久久久久| 精品伦理精品一区| 久久久精品2019中文字幕之3| 久久久久久亚洲综合影院红桃| 国产精品污污网站在线观看| 国产欧美日韩精品在线| 亚洲色图欧美激情| 日韩黄色小视频| 久久99精品国产| www.日本不卡| 欧美性一区二区| 日韩精品一区二区三区在线观看| 久久精品免费在线观看| 国产精品国产精品国产专区不蜜 | 欧美日韩免费观看一区二区三区| 欧美久久一二区| 日韩小视频在线观看专区| 国产日产欧美一区二区视频| 一区二区三区不卡视频| 麻豆精品视频在线| www.欧美日韩国产在线| 欧美高清一级片在线| 国产午夜精品一区二区三区四区| 亚洲视频一二区| 男女男精品视频网| 国产不卡视频在线观看| 欧美性受极品xxxx喷水| 精品国产不卡一区二区三区| 18涩涩午夜精品.www| 日本成人在线视频网站| 成人av网站在线| 亚洲日本一区二区| 秋霞成人午夜伦在线观看| 国产成人精品影院| 欧美三级午夜理伦三级中视频| 久久综合色8888| 一区二区三区在线免费播放| 精品一区二区三区免费观看| 91蝌蚪porny| 久久免费精品国产久精品久久久久| 亚洲精品综合在线| 国产呦精品一区二区三区网站| 99精品在线观看视频| 日韩精品自拍偷拍| 亚洲一区二区欧美| 成人免费看片app下载| 日韩一区二区三区电影在线观看| 国产精品网站在线观看| 精品影院一区二区久久久| 91极品美女在线| 国产精品乱子久久久久| 老司机一区二区| 日本高清无吗v一区| 国产欧美视频在线观看| 麻豆精品国产91久久久久久| 欧美色区777第一页| 亚洲女同一区二区| 99国内精品久久| 国产欧美一区二区精品秋霞影院 | 欧美日韩在线播放三区四区| 亚洲人妖av一区二区| 国产成人自拍网| 久久亚洲综合色| 精品一区二区三区影院在线午夜| 欧美日韩国产区一| 性做久久久久久| 在线观看视频91| 亚洲综合久久久久| 日本电影欧美片| 自拍偷拍国产亚洲| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 国产精品每日更新在线播放网址| 国内精品伊人久久久久av一坑| 欧美日韩高清一区二区三区| 亚洲午夜在线观看视频在线| 91福利国产精品| 一区二区三区精品在线| 国产精品天干天干在观线| 精品国产91久久久久久久妲己| 亚洲第一成年网| 欧美日韩免费观看一区二区三区| 一区二区三区自拍| 日本韩国一区二区三区| 亚洲女同ⅹxx女同tv| 91福利精品第一导航| 亚洲最大成人综合| 欧美日韩mp4| 日韩成人精品视频| 欧美大胆人体bbbb| 国产一区二区三区综合| 久久精品免视看| av在线综合网| 伊人色综合久久天天| 欧美日韩在线电影| 久久精品国产一区二区| 国产亚洲短视频| hitomi一区二区三区精品| 亚洲欧美激情小说另类| 欧美午夜片在线观看| 日本一不卡视频| 久久久久国色av免费看影院| 不卡视频一二三| 婷婷综合另类小说色区| 亚洲欧洲成人av每日更新| 色偷偷久久人人79超碰人人澡 | 亚洲免费资源在线播放| 欧美日韩精品一二三区| 国产乱人伦偷精品视频免下载| 国产精品天干天干在线综合| 在线精品视频一区二区三四| 蜜桃视频一区二区三区 |