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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? power.c

?? usb to rs232 虛擬RS232串口驅(qū)動(dòng)程序
?? C
?? 第 1 頁 / 共 3 頁
字號(hào):
/*++

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));

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品免费丝袜| 亚洲国产成人av网| 欧美喷水一区二区| 福利电影一区二区三区| 天堂蜜桃91精品| 国产精品美女久久久久久久网站| 欧美三级午夜理伦三级中视频| 国产一区二区在线观看视频| 亚洲444eee在线观看| 亚洲视频综合在线| 精品久久久久久久人人人人传媒 | 91在线观看高清| 久久99久久久久| 日韩专区中文字幕一区二区| 国产精品不卡一区二区三区| 久久先锋影音av| 欧美一区二区黄色| 欧美日韩一卡二卡三卡| 一本大道久久a久久综合| 国产成人亚洲综合a∨猫咪| 日韩精品免费专区| 亚洲.国产.中文慕字在线| 国产精品久久久久永久免费观看 | 夜夜嗨av一区二区三区中文字幕| 国产亚洲人成网站| 日韩午夜三级在线| 51精品秘密在线观看| 欧美日韩和欧美的一区二区| 91丨国产丨九色丨pron| 99r精品视频| a亚洲天堂av| 成人av在线看| 成人高清免费观看| 成人精品视频一区| 成人午夜av电影| 成人免费av在线| 成人听书哪个软件好| 国产酒店精品激情| 国产精品一区在线观看乱码| 狠狠色丁香久久婷婷综| 精品一区二区三区免费视频| 久久精品国产999大香线蕉| 免费人成黄页网站在线一区二区| 日韩中文字幕不卡| 日本网站在线观看一区二区三区 | 欧美一区二区三区四区五区 | 夜夜嗨av一区二区三区网页| 亚洲一区二区三区四区不卡| 久久成人精品无人区| 日产国产欧美视频一区精品| 人妖欧美一区二区| 精品一区二区免费视频| 国产精品自拍av| 国产91精品精华液一区二区三区| 国产成人午夜视频| 99re亚洲国产精品| 欧美无人高清视频在线观看| 欧美日韩一区不卡| 日韩手机在线导航| 日本一区二区成人在线| 椎名由奈av一区二区三区| 亚洲精品免费看| 日韩成人dvd| 国产美女一区二区三区| av成人动漫在线观看| 在线观看日韩av先锋影音电影院| 在线成人免费视频| 欧美精品一区二区三区蜜桃| 国产精品污www在线观看| 亚洲精品国产一区二区三区四区在线 | 免费人成黄页网站在线一区二区| 亚洲主播在线播放| 久久精品国产一区二区| 懂色av一区二区夜夜嗨| 欧美伊人久久久久久久久影院 | 久久se精品一区二区| 国产精品一品视频| 欧洲一区在线电影| 精品欧美一区二区三区精品久久| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产一区 二区 三区一级| av网站免费线看精品| 欧美日韩在线不卡| 国产日产欧产精品推荐色| 亚洲精品国产第一综合99久久| 香蕉成人啪国产精品视频综合网 | 日韩视频免费直播| 国产精品网站一区| 青草av.久久免费一区| av一区二区三区在线| 日韩手机在线导航| 一级做a爱片久久| 激情成人午夜视频| 欧美日韩国产综合草草| 欧美国产国产综合| 免费视频最近日韩| 色狠狠桃花综合| 久久精品视频在线看| 午夜精品一区在线观看| 成人黄色在线视频| 欧美xxxxxxxxx| 亚洲h在线观看| 91麻豆精品在线观看| 久久综合精品国产一区二区三区 | 蜜桃视频在线观看一区二区| 色婷婷综合久久久中文字幕| 精品久久久久久久久久久久久久久| 亚洲免费观看在线观看| 国产福利精品一区二区| 欧美一区二区三区爱爱| 亚洲综合色网站| 成人av网站免费观看| 久久综合色鬼综合色| 视频一区二区三区入口| 在线免费观看视频一区| 国产精品久久久久久久久快鸭 | 国产美女视频一区| 欧美一级黄色录像| 亚洲国产精品一区二区久久恐怖片 | 欧美高清视频一二三区 | 中文字幕成人av| 国内精品在线播放| 91精品国产91久久久久久一区二区 | 在线观看一区不卡| 欧美国产日本韩| 国产原创一区二区| 精品欧美一区二区在线观看| 视频一区二区三区中文字幕| 欧美视频日韩视频| 亚洲二区视频在线| 在线免费一区三区| 亚洲影视在线播放| 欧美日韩一级黄| 亚洲国产精品一区二区尤物区| 在线精品视频小说1| 一区二区三区日韩欧美精品| 一本久久精品一区二区| 亚洲女人小视频在线观看| 色婷婷精品大视频在线蜜桃视频| 中文字幕一区在线| 91福利在线播放| 亚洲综合视频在线| 91精品久久久久久久99蜜桃| 三级成人在线视频| 日韩欧美中文一区| 国产乱子伦视频一区二区三区| 久久久激情视频| 99久久免费国产| 亚洲一区av在线| 欧美日韩在线观看一区二区 | 国产乱码精品一区二区三| 久久久久久久久伊人| 成人午夜精品在线| 亚洲人成在线播放网站岛国| 色乱码一区二区三区88| 婷婷综合另类小说色区| 欧美不卡在线视频| 处破女av一区二区| 亚洲乱码日产精品bd| 欧洲亚洲精品在线| 日本va欧美va瓶| 国产免费成人在线视频| 91精品国产综合久久香蕉麻豆| 丝袜诱惑亚洲看片| 久久九九影视网| 色噜噜偷拍精品综合在线| 日日夜夜一区二区| 久久精品欧美日韩精品 | 成人av网站在线| 午夜久久电影网| 久久久国产精品午夜一区ai换脸| 91原创在线视频| 日本一区中文字幕| 国产精品视频在线看| 精品视频免费在线| 国产不卡在线视频| 亚洲国产日韩a在线播放| 精品国产91亚洲一区二区三区婷婷| 丰满岳乱妇一区二区三区| 亚洲综合色丁香婷婷六月图片| 日韩欧美不卡一区| 91免费在线播放| 蜜桃视频第一区免费观看| 国产精品美女www爽爽爽| 欧美精品vⅰdeose4hd| 成人午夜电影小说| 日韩综合小视频| 亚洲丝袜精品丝袜在线| 日韩精品一区二区三区在线观看 | 欧美在线观看视频在线| 国产一区在线视频| 性感美女久久精品| 中文字幕一区二区三区四区不卡| 欧美一级免费大片| 色悠久久久久综合欧美99| 国产一区二区三区最好精华液| 夜夜爽夜夜爽精品视频| 国产精品污www在线观看| 欧美大片一区二区三区| 在线视频你懂得一区二区三区|