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

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

?? usblspwr.c

?? 來自微軟的usb2.0開發包,加速USB驅動開發
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 1999  Microsoft Corporation

Module Name:

    usblspwr.c 

Abstract:

    USB LS-120 Mass Storage Device Sample Driver
    Power Management module


Environment:

    kernel mode only

Notes:

  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  PURPOSE.

  Copyright (c) 1999 Microsoft Corporation.  All Rights Reserved.


Revision History:

    1/13/99: MRB	Adapted from the BULKUSB DDK sample.

--*/


#include "wdm.h"
#include "stdarg.h"
#include "stdio.h"

#include "usbdi.h"
#include "usbdlib.h"
#include "usbls120.h"


NTSTATUS
USBLS120_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;

    USBLS120_KdPrint( DBGLVL_DEFAULT,(" USBLS120_ProcessPowerIrp() IRP_MJ_POWER\n"));

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

    switch (irpStack->MinorFunction) {

        case IRP_MN_WAIT_WAKE:

            USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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 );
                USBLS120_KdPrint( DBGLVL_HIGH, ( "Exit USBLS120_ProcessPowerIrp(), ntStatus STATUS_INVALID_DEVICE_STATE\n" ) );
                USBLS120_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,
                USBLS120_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
                                          );

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

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

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

            USBLS120_DecrementIoCount(DeviceObject);
      
            USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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.

        USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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;

                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPowerIrp() Set Power, type SystemPowerState = %s\n",
                    USBLS120_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;

                    USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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 USBLS120_PnPAddDevice() )
                        desiredDevicePowerState.DeviceState =
                            deviceExtension->DeviceCapabilities.DeviceState[ sysPowerState.SystemState ];

                        USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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;

                        USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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?
                //

                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPowerIrp() Set Power, desiredDevicePowerState = %s\n",
                    USBLS120_StringForDevState( desiredDevicePowerState.DeviceState ) ));

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

                    // USBLS120_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
                                   USBLS120_PoRequestCompletion, 
                                   DeviceObject,
                                   NULL
                                   );

                } else {
                    // Yes, just pass it on to PDO (Physical Device Object)
                    IoCopyCurrentIrpStackLocationToNext(Irp);

                    PoStartNextPowerIrp(Irp);

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

                    USBLS120_DecrementIoCount(DeviceObject);
                    USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPowerIrp() Exit IRP_MN_SET_POWER\n"));

                }
                break;


            case DevicePowerState:

                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPowerIrp() Set Power, type DevicePowerState = %s\n",
                    USBLS120_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 = USBLS120_SetDevicePowerState(
                                 DeviceObject,
                                 irpStack->Parameters.Power.State.DeviceState
                                 ); // returns TRUE for D0

                IoCopyCurrentIrpStackLocationToNext(Irp);

                if (fGoingToD0) {
                    USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPowerIrp() Set PowerIrp Completion Routine, fGoingToD0 =%d\n", fGoingToD0));
                    IoSetCompletionRoutine(
                        Irp,
                        USBLS120_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
                    USBLS120_DecrementIoCount(DeviceObject);

                USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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.
        //

        USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_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
                       );

        USBLS120_DecrementIoCount(DeviceObject);

        break; /* IRP_MN_QUERY_POWER */


    default:
        USBLS120_KdPrint( DBGLVL_MEDIUM,("USBLS120_ProcessPowerIrp() UNKNOWN POWER MESSAGE (%x)\n", irpStack->MinorFunction));

        //
        // All unhandled power messages are passed on to the PDO
        //

        IoCopyCurrentIrpStackLocationToNext(Irp);

        PoStartNextPowerIrp(Irp);

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

        USBLS120_DecrementIoCount(DeviceObject);

    } /* irpStack->MinorFunction */

    USBLS120_KdPrint( DBGLVL_MEDIUM,  ( "Exit USBLS120_ProcessPowerIrp()  ntStatus = 0x%x\n", ntStatus ) );
    return ntStatus;
}


NTSTATUS
USBLS120_PoRequestCompletion(
    IN PDEVICE_OBJECT       DeviceObject,
    IN UCHAR                MinorFunction,
    IN POWER_STATE          PowerState,
    IN PVOID                Context,
    IN PIO_STATUS_BLOCK     IoStatus
    )
/*++

Routine Description:

    This is the completion routine set in a call to PoRequestPowerIrp()
    that was made in USBLS120_ProcessPowerIrp() in response to receiving
    an IRP_MN_SET_POWER of type 'SystemPowerState' when the device was

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区二区三区在线| 国产麻豆精品久久一二三| 久久久久久日产精品| 欧美一区二区福利在线| 欧美久久久久久蜜桃| 欧美久久久久久蜜桃| 这里是久久伊人| 欧美日韩亚洲不卡| 欧美精品黑人性xxxx| 日韩一区二区不卡| 精品处破学生在线二十三| 精品欧美一区二区三区精品久久| 日韩三级高清在线| 欧美国产精品久久| 亚洲一区二区美女| 日韩和欧美一区二区三区| 久久精品久久久精品美女| 久草在线在线精品观看| 国产成人夜色高潮福利影视| www.亚洲色图| 欧美精品在线观看一区二区| 日韩视频免费直播| 国产精品久久毛片a| 亚洲一区免费在线观看| 蜜乳av一区二区三区| 丁香天五香天堂综合| 日本韩国一区二区三区视频| 91精品国产欧美一区二区| 国产欧美一区二区在线观看| 中文字幕不卡在线观看| 亚洲国产日产av| 国产精品正在播放| 欧美网站一区二区| 国产视频一区在线观看 | 国产成人午夜视频| 色偷偷88欧美精品久久久| 欧美日韩黄色影视| 国产欧美日韩一区二区三区在线观看| 日韩美女啊v在线免费观看| 亚洲v中文字幕| 国产一区啦啦啦在线观看| 99国产精品久久久久久久久久久| 欧美精品色综合| 综合久久久久久| 免费在线观看一区| 国产精品一卡二| 911国产精品| 亚洲视频一区在线| 国产一区二区三区综合| 欧美日本国产一区| 亚洲精品成人a在线观看| 在线不卡中文字幕播放| 欧美日韩综合在线| 国产精品拍天天在线| 免费在线观看精品| 欧美视频三区在线播放| 国产精品大尺度| 国产一二精品视频| 欧美videos大乳护士334| 亚洲成人激情自拍| 91高清视频免费看| 亚洲欧美日韩小说| av在线不卡免费看| 国产精品入口麻豆九色| 国产综合一区二区| 精品国产乱码久久久久久1区2区| 水野朝阳av一区二区三区| 欧美性受xxxx黑人xyx性爽| 亚洲欧美视频在线观看| 99在线热播精品免费| 欧美经典三级视频一区二区三区| 蓝色福利精品导航| 日韩一区二区电影| 911国产精品| 国产精品久久久久婷婷二区次| 日本美女一区二区三区| 欧美美女一区二区三区| 天堂va蜜桃一区二区三区| 在线免费观看日韩欧美| 亚洲网友自拍偷拍| 在线播放一区二区三区| 免费高清在线一区| 日韩免费看的电影| 国产精品亚洲第一| 久久久青草青青国产亚洲免观| 国产原创一区二区| 久久精品亚洲精品国产欧美kt∨| 国产精品一线二线三线精华| 国产婷婷色一区二区三区| 国产精品综合av一区二区国产馆| 精品国产一区二区三区四区四| 黄色日韩网站视频| 亚洲欧美自拍偷拍色图| 在线免费观看日韩欧美| 日韩电影在线观看电影| 精品对白一区国产伦| 国产成人免费视| 亚洲美女偷拍久久| 在线成人免费视频| 国产精品1024久久| 亚洲欧美另类小说| 91麻豆精品国产自产在线观看一区 | av爱爱亚洲一区| 丝袜美腿亚洲色图| 国产精品青草久久| 欧美一区二区三区视频| 懂色一区二区三区免费观看| 亚洲午夜一区二区三区| 亚洲精品在线观| 91啪亚洲精品| 国内精品国产成人| 亚洲国产三级在线| 欧美极品美女视频| 56国语精品自产拍在线观看| 成人开心网精品视频| 喷水一区二区三区| 亚洲黄色性网站| 亚洲国产精华液网站w| 在线观看91av| 色狠狠一区二区三区香蕉| 精品中文字幕一区二区小辣椒| 亚洲日本成人在线观看| 精品国产乱码久久久久久浪潮 | 久久精品噜噜噜成人av农村| 亚洲精品日日夜夜| 国产婷婷精品av在线| 欧美一区二区视频在线观看2020| 蜜桃精品视频在线| 综合色中文字幕| 欧美不卡一区二区三区四区| 色婷婷av一区二区三区之一色屋| 国产综合成人久久大片91| 婷婷综合在线观看| 亚洲人精品午夜| 亚洲国产高清在线观看视频| 欧美一区永久视频免费观看| 不卡av在线免费观看| 精品夜夜嗨av一区二区三区| 亚洲18色成人| 亚洲一级二级在线| 亚洲乱码日产精品bd| 国产精品美女久久福利网站| 久久香蕉国产线看观看99| 91精品国产入口| 欧美精品 国产精品| 欧美中文字幕不卡| 91亚洲精品乱码久久久久久蜜桃| 国产99久久久久| 国产精品996| 国产成人精品一区二区三区四区 | 成人av网站免费观看| 久久er精品视频| 麻豆精品久久久| 久久99精品视频| 国产精品1024| av激情综合网| 色噜噜狠狠成人中文综合| 色狠狠色狠狠综合| 欧美精品久久久久久久久老牛影院| 欧美日韩激情一区二区| 91精品一区二区三区在线观看| 日韩亚洲国产中文字幕欧美| 欧美videos中文字幕| 国产日产欧美一区二区三区| 国产精品久久毛片| 亚洲最大成人综合| 琪琪久久久久日韩精品| 久久国内精品视频| 国产精品538一区二区在线| 国产aⅴ综合色| 在线精品国精品国产尤物884a| 欧美日韩精品专区| 久久久久久亚洲综合影院红桃 | 91高清在线观看| 91精品国产色综合久久不卡电影 | 成人免费小视频| 一区二区在线观看免费| 午夜国产精品一区| 国产精品资源在线观看| 99在线精品观看| 6080亚洲精品一区二区| 国产亚洲欧洲一区高清在线观看| 国产精品欧美精品| 五月婷婷激情综合网| 国产精品综合在线视频| 99在线精品免费| 精品国产制服丝袜高跟| 综合在线观看色| 国产一区二区精品久久99| 91国产丝袜在线播放| 久久先锋影音av| 视频一区视频二区中文| 成人在线综合网| 日韩一区和二区| 一区二区三区在线免费| 国产精品538一区二区在线| 欧美精品 日韩| 一区二区成人在线视频| 国产成人无遮挡在线视频| 宅男噜噜噜66一区二区66|