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

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

?? power.c

?? usb to rs232 虛擬RS232串口驅動程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2005-2006  E0 Technology,Inc.

Module Name:

	power.c

Abstract:

	Virtual Com Port Driver for USB to RS232 Converter of E0 Technology,Inc.

Environment:

	Kernel mode

Notes:

Revision History:

    2006/3/1 : 	Adapted from the BulkUsb DDK sample.
--*/


#include "usb2com.h"


NTSTATUS
USB2COM_ProcessPowerIrp(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++

Routine Description:

    This is our FDO's dispatch table function for IRP_MJ_POWER.
    It processes the Power IRPs sent to the PDO for this device.

    For every power IRP, drivers must call PoStartNextPowerIrp and use PoCallDriver
    to pass the IRP all the way down the driver stack to the underlying PDO.


Arguments:

    DeviceObject - pointer to our device object (FDO)

    Irp          - pointer to an I/O Request Packet

Return Value:

    NT status code

--*/
{

    PIO_STACK_LOCATION irpStack;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PDEVICE_EXTENSION deviceExtension;
    BOOLEAN fGoingToD0 = FALSE;
    POWER_STATE sysPowerState, desiredDevicePowerState;
    KEVENT event;

    USB2COM_KdPrint( DBGLVL_MEDIUM,(" USB2COM_ProcessPowerIrp() IRP_MJ_POWER\n"));

    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation (Irp);
    USB2COM_IncrementIoCount(DeviceObject);

    switch (irpStack->MinorFunction) {
    case IRP_MN_WAIT_WAKE:
        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Enter IRP_MN_WAIT_WAKE\n"));

                // A driver sends IRP_MN_WAIT_WAKE to indicate that the system should
                // wait for its device to signal a wake event. The exact nature of the event
                // is device-dependent.
                // Drivers send this IRP for two reasons:
                // 1) To allow a device to wake the system
                // 2) To wake a device that has been put into a sleep state to save power
                //    but still must be able to communicate with its driver under certain circumstances.
                // When a wake event occurs, the driver completes the IRP and returns
                // STATUS_SUCCESS. If the device is sleeping when the event occurs,
                // the driver must first wake up the device before completing the IRP.
                // In a completion routine, the driver calls PoRequestPowerIrp to send a
                // PowerDeviceD0 request. When the device has powered up, the driver can
                //  handle the IRP_MN_WAIT_WAKE request.

        // deviceExtension->DeviceCapabilities.DeviceWake specifies the lowest device power state (least powered)
        // from which the device can signal a wake event
        deviceExtension->PowerDownLevel = deviceExtension->DeviceCapabilities.DeviceWake;


        if  ( ( PowerDeviceD0 == deviceExtension->CurrentDevicePowerState )  ||
              ( deviceExtension->DeviceCapabilities.DeviceWake > deviceExtension->CurrentDevicePowerState ) ) {
                        //
                        //    STATUS_INVALID_DEVICE_STATE is returned if the device in the PowerD0 state
                        //    or a state below which it can support waking, or if the SystemWake state
                        //    is below a state which can be supported. A pending IRP_MN_WAIT_WAKE will complete
                        //    with this error if the device's state is changed to be incompatible with the wake
                        //    request.

            //  If a driver fails this IRP, it should complete the IRP immediately without
            //  passing the IRP to the next-lower driver.
            ntStatus = STATUS_INVALID_DEVICE_STATE;
            Irp->IoStatus.Status = ntStatus;
            IoCompleteRequest (Irp,IO_NO_INCREMENT );
            USB2COM_KdPrint( DBGLVL_HIGH, ( "Exit USB2COM_ProcessPowerIrp(), ntStatus STATUS_INVALID_DEVICE_STATE\n" ) );
            USB2COM_DecrementIoCount(DeviceObject);
            return ntStatus;
        }

        // flag we're enabled for wakeup
        deviceExtension->EnabledForWakeup = TRUE;

        // init an event for our completion routine to signal when PDO is done with this Irp
        KeInitializeEvent(&event, NotificationEvent, FALSE);

       // If not failing outright, pass this on to our PDO for further handling
        IoCopyCurrentIrpStackLocationToNext(Irp);

        // Set a completion routine so it can signal our event when
        //  the PDO is done with the Irp
        IoSetCompletionRoutine(Irp,
                               USB2COM_IrpCompletionRoutine,
                               &event,  // pass the event to the completion routine as the Context
                               TRUE,    // invoke on success
                               TRUE,    // invoke on error
                               TRUE);   // invoke on cancellation

        PoStartNextPowerIrp(Irp);
        ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject,
                                Irp);

         // if PDO is not done yet, wait for the event to be set in our completion routine
        if (ntStatus == STATUS_PENDING) {
             // wait for irp to complete

            NTSTATUS waitStatus = KeWaitForSingleObject(
                &event,
                Suspended,
                KernelMode,
                FALSE,
                NULL);

            USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() done waiting for PDO to finish IRP_MN_WAIT_WAKE\n"));
        }

                // now tell the device to actually wake up
                USB2COM_SelfSuspendOrActivate( DeviceObject, FALSE );

        // flag we're done with wakeup irp
        deviceExtension->EnabledForWakeup = FALSE;

        USB2COM_DecrementIoCount(DeviceObject);

        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Exit IRP_MN_WAIT_WAKE\n"));
        break;

    case IRP_MN_SET_POWER:
        {

                // The system power policy manager sends this IRP to set the system power state.
                // A device power policy manager sends this IRP to set the device power state for a device.

        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Enter IRP_MN_SET_POWER\n"));

        // Set Irp->IoStatus.Status to STATUS_SUCCESS to indicate that the device
        // has entered the requested state. Drivers cannot fail this IRP.

        switch (irpStack->Parameters.Power.Type) {
            case SystemPowerState:

                // Get input system power state
                sysPowerState.SystemState = irpStack->Parameters.Power.State.SystemState;

                USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Set Power, type SystemPowerState = %s\n",
                    USB2COM_StringForSysState( sysPowerState.SystemState ) ));

                // If system is in working state always set our device to D0
                //  regardless of the wait state or system-to-device state power map
                if ( sysPowerState.SystemState ==  PowerSystemWorking) {
                    desiredDevicePowerState.DeviceState = PowerDeviceD0;

                     USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() PowerSystemWorking, will set D0, not use state map\n"));


                } else {
                     // set to corresponding system state if IRP_MN_WAIT_WAKE pending
                    if ( deviceExtension->EnabledForWakeup ) { // got a WAIT_WAKE IRP pending?

                        // Find the device power state equivalent to the given system state.
                        // We get this info from the DEVICE_CAPABILITIES struct in our device
                        // extension (initialized in USB2COM_PnPAddDevice() )
                        desiredDevicePowerState.DeviceState =
                            deviceExtension->DeviceCapabilities.DeviceState[ sysPowerState.SystemState ];

                        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() IRP_MN_WAIT_WAKE pending, will use state map\n"));

                    } else {
                        // if no wait pending and the system's not in working state, just turn off
                        desiredDevicePowerState.DeviceState = PowerDeviceD3;

                        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Not EnabledForWakeup and the system's not in working state,\n  settting PowerDeviceD3 (off )\n"));
                    }
                }

                //
                // We've determined the desired device state; are we already in this state?
                //

                USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Set Power, desiredDevicePowerState = %s\n",
                    USB2COM_StringForDevState( desiredDevicePowerState.DeviceState ) ));

                if (desiredDevicePowerState.DeviceState !=
                    deviceExtension->CurrentDevicePowerState) {

                    // USB2COM_IncrementIoCount(DeviceObject);

                    // No, request that we be put into this state
                                        // by requesting a new Power Irp from the Pnp manager
                    deviceExtension->PowerIrp = Irp;
                    ntStatus = PoRequestPowerIrp(deviceExtension->PhysicalDeviceObject,
                                               IRP_MN_SET_POWER,
                                               desiredDevicePowerState,
                                                                                           // completion routine will pass the Irp down to the PDO
                                               USB2COM_PoRequestCompletion,
                                               DeviceObject,
                                               NULL);

                } else {
                    // Yes, just pass it on to PDO (Physical Device Object)
                    IoCopyCurrentIrpStackLocationToNext(Irp);
                    PoStartNextPowerIrp(Irp);
                    ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject,
                                            Irp);

                    USB2COM_DecrementIoCount(DeviceObject);
                    USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Exit IRP_MN_SET_POWER\n"));

                }
                break;

            case DevicePowerState:

                USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Set Power, type DevicePowerState = %s\n",
                    USB2COM_StringForDevState( irpStack->Parameters.Power.State.DeviceState ) ));

                // For requests to D1, D2, or D3 ( sleep or off states ),
                                // sets deviceExtension->CurrentDevicePowerState to DeviceState immediately.
                                // This enables any code checking state to consider us as sleeping or off
                                // already, as this will imminently become our state.

                // For requests to DeviceState D0 ( fully on ), sets fGoingToD0 flag TRUE
                // to flag that we must set a completion routine and update
                                // deviceExtension->CurrentDevicePowerState there.
                                // In the case of powering up to fully on, we really want to make sure
                                // the process is completed before updating our CurrentDevicePowerState,
                                // so no IO will be attempted or accepted before we're really ready.

                fGoingToD0 = USB2COM_SetDevicePowerState(DeviceObject,
                                                      irpStack->Parameters.Power.State.DeviceState
                                                      ); // returns TRUE for D0

                IoCopyCurrentIrpStackLocationToNext(Irp);

                if (fGoingToD0) {
                    USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Set PowerIrp Completion Routine, fGoingToD0 =%d\n", fGoingToD0));
                    IoSetCompletionRoutine(Irp,
                           USB2COM_PowerIrp_Complete,
                           // Always pass FDO to completion routine as its Context;
                           // This is because the DriverObject passed by the system to the routine
                           // is the Physical Device Object ( PDO ) not the Functional Device Object ( FDO )
                           DeviceObject,
                           TRUE,            // invoke on success
                           TRUE,            // invoke on error
                           TRUE);           // invoke on cancellation of the Irp
                }

                PoStartNextPowerIrp(Irp);
                ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject,
                                        Irp);

                if ( !fGoingToD0 ) // completion routine will decrement
                    USB2COM_DecrementIoCount(DeviceObject);

                USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() Exit IRP_MN_SET_POWER\n"));
                break;
            } /* case irpStack->Parameters.Power.Type */

        }
        break; /* IRP_MN_SET_POWER */

    case IRP_MN_QUERY_POWER:
                //
                // A power policy manager sends this IRP to determine whether it can change
                // the system or device power state, typically to go to sleep.
                //

        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() IRP_MN_QUERY_POWER\n"));

        // We do nothing special here, just let the PDO handle it
        IoCopyCurrentIrpStackLocationToNext(Irp);
        PoStartNextPowerIrp(Irp);
        ntStatus = PoCallDriver(deviceExtension->TopOfStackDeviceObject,
                                Irp);


        USB2COM_DecrementIoCount(DeviceObject);

        break; /* IRP_MN_QUERY_POWER */

    default:

        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPowerIrp() UNKNOWN POWER MESSAGE (%x)\n", irpStack->MinorFunction));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产乱码电影| 东方欧美亚洲色图在线| 欧美肥妇bbw| 午夜av区久久| 日韩亚洲欧美综合| 久久狠狠亚洲综合| 精品国产乱码91久久久久久网站| 极品少妇xxxx精品少妇偷拍| 2020国产精品久久精品美国| 国产麻豆视频一区二区| 国产精品国产三级国产有无不卡 | 亚洲第一成年网| 欧美日韩国产在线播放网站| 美女一区二区三区| 国产欧美一区二区三区在线看蜜臀 | 91精品国产高清一区二区三区蜜臀| 日日夜夜精品视频天天综合网| 日韩视频在线观看一区二区| 国产高清在线观看免费不卡| 1区2区3区国产精品| 欧美日韩一区二区三区不卡| 久久精品国产久精国产爱| 久久奇米777| 91行情网站电视在线观看高清版| 天堂影院一区二区| 久久精品人人做人人综合 | 久久精品欧美日韩精品| 91丝袜美女网| 日本免费在线视频不卡一不卡二| 欧美精品一区视频| 色噜噜狠狠成人中文综合 | 国产精品456| 亚洲永久免费视频| 久久午夜色播影院免费高清| 色婷婷综合激情| 国内精品国产成人国产三级粉色| 日韩伦理av电影| 欧美成人aa大片| 色婷婷av一区二区三区大白胸| 久久精品国产免费| 一区二区三区精品久久久| 2021中文字幕一区亚洲| 欧美日韩一区在线| 成人午夜看片网址| 久久99精品久久久久久| 亚洲综合自拍偷拍| 欧美激情自拍偷拍| 日韩女优视频免费观看| 欧美亚洲动漫制服丝袜| 成人激情黄色小说| 久久精品99国产精品日本| 亚洲黄色av一区| 国产免费成人在线视频| 欧美一区二区在线免费观看| 91色乱码一区二区三区| 国产高清亚洲一区| 久久精品国产99国产| 午夜欧美视频在线观看 | 在线看一区二区| 丁香婷婷深情五月亚洲| 久久不见久久见免费视频1| 午夜视频在线观看一区二区三区| 亚洲视频一区二区在线观看| 欧美激情在线一区二区| 精品国产乱码久久久久久牛牛| 欧美一区二区视频免费观看| 欧美人与z0zoxxxx视频| 欧美性猛交xxxxxx富婆| 色狠狠一区二区三区香蕉| www.一区二区| 成人午夜av电影| 成人午夜免费视频| 成人免费视频国产在线观看| 国产乱子伦一区二区三区国色天香| 日本不卡一区二区三区| 视频一区二区三区在线| 亚洲国产精品人人做人人爽| 亚洲综合免费观看高清在线观看| 亚洲精品视频观看| 亚洲精品亚洲人成人网在线播放| 中文字幕一区日韩精品欧美| 国产精品成人免费在线| 日韩一区有码在线| 一个色妞综合视频在线观看| 伊人一区二区三区| 亚洲美女视频在线观看| 一区二区三区在线免费观看| 亚洲精品视频一区二区| 亚洲综合一区二区三区| 五月激情综合网| 日本视频免费一区| 国精产品一区一区三区mba桃花| 国产在线精品一区二区不卡了 | 天天综合天天做天天综合| 天天影视网天天综合色在线播放| 奇米色777欧美一区二区| 久久国产精品99精品国产| 国产精品一区二区91| www.日韩av| 欧美午夜一区二区三区| 911精品国产一区二区在线| 日韩亚洲电影在线| 日本一二三四高清不卡| 亚洲综合av网| 日本欧美肥老太交大片| 国产精品456| 在线视频你懂得一区| 欧美电影免费观看高清完整版在| 久久久久亚洲蜜桃| 亚洲一区自拍偷拍| 国产在线观看免费一区| 91麻豆国产福利精品| 欧美一二三区精品| 国产精品理论片在线观看| 亚洲高清三级视频| 国产suv一区二区三区88区| 在线视频一区二区三| 337p粉嫩大胆色噜噜噜噜亚洲| 国产精品国模大尺度视频| 天天色天天操综合| 成人av小说网| 91精品国产综合久久久久久漫画 | av成人动漫在线观看| 91.com视频| 1024国产精品| 欧美日韩精品欧美日韩精品| 2024国产精品| 亚洲一区二区三区四区五区黄 | 午夜国产不卡在线观看视频| 国产日本亚洲高清| 亚洲国产精品久久久男人的天堂| 菠萝蜜视频在线观看一区| 91猫先生在线| 欧美日韩精品专区| 欧美一区二区三区白人| 久久综合九色综合97_久久久 | 91丝袜呻吟高潮美腿白嫩在线观看| 99国产精品久久久久久久久久久| 波多野结衣在线aⅴ中文字幕不卡| av亚洲精华国产精华精华| 色综合天天综合色综合av | 91年精品国产| 制服丝袜激情欧洲亚洲| 久久久久久久久久久电影| 亚洲欧美经典视频| 日韩制服丝袜av| 国产**成人网毛片九色| 一本一道波多野结衣一区二区| 欧美日韩不卡一区二区| 国产视频一区在线播放| 亚洲精品欧美在线| 精品中文av资源站在线观看| 91丨九色丨蝌蚪丨老版| 欧美一区二区三区视频免费| 国产精品三级电影| 日韩精品欧美精品| 国产91高潮流白浆在线麻豆 | 不卡的电影网站| 7777女厕盗摄久久久| 欧美激情在线免费观看| 日韩av一级片| 99久久99久久精品免费观看| 日韩限制级电影在线观看| 椎名由奈av一区二区三区| 精品一区二区综合| 在线视频你懂得一区| 欧美极品美女视频| 蜜臀a∨国产成人精品| 91影视在线播放| 久久香蕉国产线看观看99| 亚洲国产日日夜夜| 91在线视频免费观看| 久久精品一区二区三区不卡牛牛| 亚洲高清免费在线| 91蜜桃传媒精品久久久一区二区| 欧美www视频| 调教+趴+乳夹+国产+精品| 97精品久久久午夜一区二区三区| 久久综合精品国产一区二区三区 | 亚洲视频1区2区| 国产福利一区二区三区视频| 欧美一区二区三区喷汁尤物| 一区二区三国产精华液| 99久久久久久| 亚洲国产精品精华液ab| 国产麻豆视频精品| 精品国产乱码久久久久久久| 日本aⅴ免费视频一区二区三区| 91视频在线观看| 综合久久一区二区三区| 国产精品一区专区| 久久精品视频网| 国产激情一区二区三区四区 | 欧美亚洲高清一区| 一区二区三区不卡视频| 在线观看亚洲a| 亚洲一级在线观看| 日本电影欧美片| 亚洲高清三级视频| 91精品国产乱|