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

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

?? usbfx2lk_power.cpp

?? VisualC++寫的一個USB的驅動程序。
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
///////////////////////////////////////////////////////////////////////////////
//
//    (C) Copyright 2005 OSR Open Systems Resources, Inc.
//    Copyright (c) 2000  Microsoft Corporation
//    All Rights Reserved
//
//    This sofware is supplied for instructional purposes only.
//
//    OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty
//    for this software.  THIS SOFTWARE IS PROVIDED  "AS IS" WITHOUT WARRANTY
//    OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
//    THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR
//    PURPOSE.  THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS
//    WITH YOU.  OSR's entire liability and your exclusive remedy shall not
//    exceed the price paid for this material.  In no event shall OSR or its
//    suppliers be liable for any damages whatsoever (including, without
//    limitation, damages for loss of business profit, business interruption,
//    loss of business information, or any other pecuniary loss) arising out
//    of the use or inability to use this software, even if OSR has been
//    advised of the possibility of such damages.  Because some states/
//    jurisdictions do not allow the exclusion or limitation of liability for
//    consequential or incidental damages, the above limitation may not apply
//    to you.
//
//    OSR Open Systems Resources, Inc.
//    105 Route 101A Suite 19
//    Amherst, NH 03031  (603) 595-6500 FAX: (603) 595-6503
//    email bugs to: bugs@osr.com
//
//
//    MODULE:
//
//      USBFx2LK_Power.cpp
//
//    ABSTRACT:
//
//      This file contains the routines that handle IRP_MJ_POWER processing for the 
//      OSR USB FX2 Learning Kit Device
//
//    AUTHOR(S):
//
//      OSR Open Systems Resources, Inc.
// 
///////////////////////////////////////////////////////////////////////////////
#include "usbfx2lk.h"

#ifdef WPP_TRACING
//
// Include the necessary tmh file - this is 
//  just a matter of course if you're using WPP tracing.
//
extern "C" {
#include "usbfx2lk_power.tmh"
}
#endif

//
// Forward Declarations 
//
NTSTATUS OsrHandleSystemPowerIrp(PDEVICE_OBJECT DeviceObject,PIRP Irp);

NTSTATUS SystemPowerIoCompletionRoutine(PDEVICE_OBJECT DeviceObject,PIRP Irp,
                                        PVOID Context);

NTSTATUS OsrHandleDevicePowerIrp(PDEVICE_OBJECT DeviceObject,PIRP Irp);

NTSTATUS DevicePowerIoCompletionRoutine(PDEVICE_OBJECT DeviceObject,PIRP Irp,
                                        PVOID Context);

VOID DevicePowerRequestCompletionRoutine(PDEVICE_OBJECT DeviceObject,UCHAR MinorFunction,
                        POWER_STATE PowerState,PVOID Context,PIO_STATUS_BLOCK IoStatus);

VOID WaitWakeIrpCompletionFunc(PDEVICE_OBJECT DeviceObject,UCHAR MinorFunction,
                         POWER_STATE PowerState,PVOID Context,PIO_STATUS_BLOCK IoStatus);
VOID WaitWakeCallback(PDEVICE_OBJECT DeviceObject,UCHAR MinorFunction,POWER_STATE PowerState,
                      PVOID Context,PIO_STATUS_BLOCK IoStatus);
NTSTATUS WaitWakeCompletionRoutine(PDEVICE_OBJECT DeviceObject,PIRP Irp,PUSBFX2LK_EXT DevExt);


///////////////////////////////////////////////////////////////////////////////
//
// UsbFx2LkPower
//
//  This routine is called by the IO Manager to process a IRP_MJ_POWER
//  Irp.
//
//
//  INPUTS:
//
//      DeviceObject  -  One of our Device Objects.
//      Irp  -  The Irp to process.
//
//  OUTPUTS:
//
//      None
//
//  RETURNS:
//
//      None
//
//  IRQL:
//
//      IRQL == PASSIVE_LEVEL
//
//  CONTEXT:
//
//      User Context
//
//  NOTES:
//
///////////////////////////////////////////////////////////////////////////////
NTSTATUS UsbFx2LkPower(PDEVICE_OBJECT DeviceObject,PIRP Irp)
{
    PUSBFX2LK_EXT       devExt  = (PUSBFX2LK_EXT)DeviceObject->DeviceExtension;
    PIO_STACK_LOCATION  ioStack = IoGetCurrentIrpStackLocation(Irp);
    POWER_STATE_TYPE    powerType;
    NTSTATUS            status;
    KIRQL               oldIrql;

    //
    // We're guaranteed to be called here at IRQL PASSIVE_LEVEL
    //
    ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

    //
    // Increment the count of Outstanding IOs
    //
    OsrIncrementOutstandingIoCount(devExt,__FILE__,__LINE__);


    if (ioStack->MinorFunction <= IRP_MN_QUERY_POWER) {

        OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_POWER_INFO, 
                      ("OsrPower: Entered with Minor Function %s\n", 
                        OsrMinorFunctionToString(ioStack->MajorFunction,
                                                 ioStack->MinorFunction)));

    } else {

        OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_POWER_INFO, 
                      ("OsrPower: Entered with unusual Minor Function 0x%x\n", 
                        ioStack->MinorFunction));

    }

    //
    // See what sort of state we're in. For our power policy, we have 
    //  decided that we will not accept any power requests if we are not
    //  in STATE_STARTED. 
    //
    // Why? Because as far as we can tell, it doesn't make any SENSE to handle
    //  them in any other state. If we're in REMOVE_PENDING and we process
    //  a power down, what do we do if we get a IRP_MN_CANCEL_REMOVE? Or, if
    //  we're in STOPPED we've already given up our resources so how 
    //  do we tell our device to power down? In SURPRISE_REMOVED, what
    //  hardware are we going to power down?? 
    //
    KeAcquireSpinLock(&devExt->IoStateLock,&oldIrql);
    if (devExt->DevicePnPState != STATE_STARTED &&
        devExt->DevicePnPState != STATE_POWER_PROCESSING) {

        KeReleaseSpinLock(&devExt->IoStateLock,oldIrql);

        //
        // We ALWAYS need to tell the system to start the next
        // power IRP before we exit.  Yes, even if we're failing
        // the current request.
        //
        PoStartNextPowerIrp(Irp);
        
        Irp->IoStatus.Status      = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        //
        // Complete the request here, without passing it down...
        //
        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        OsrTracePrint(TRACE_LEVEL_INFORMATION,OSRDBG_POWER_INFO, 
                ("OsrPower: Failing Power request due to Pnp State! Current PnP state - %s\n",
                  OsrPrintState(devExt)));


        //
        // We're done with this request
        //
        OsrDecrementOutstandingIoCount(devExt,__FILE__,__LINE__);

        OsrTracePrint(TRACE_LEVEL_INFORMATION,OSRDBG_POWER_INFO, ("OsrPower: Exiting...\n"));

        return STATUS_INVALID_DEVICE_STATE;

    }
    KeReleaseSpinLock(&devExt->IoStateLock,oldIrql);

    //
    // Is this a system power Irp or a device power Irp?
    //
    powerType  = ioStack->Parameters.Power.Type;

    switch (powerType) {

        case SystemPowerState:

            //
            // Transfer control to our SYSTEM power IRP routine...
            //
            status = OsrHandleSystemPowerIrp(DeviceObject, Irp);

            //
            // Don't release our remove lock!
            //
            break;

        case DevicePowerState:

            //
            // Transfer control to our DEVICE power IRP routine...
            //
            status = OsrHandleDevicePowerIrp(DeviceObject, Irp);

            //
            // Don't release our remove lock!
            //
            break;

        default:

            OsrTracePrint(TRACE_LEVEL_INFORMATION,OSRDBG_POWER_INFO,
                    ("OsrPower: Not a device or system power request!?! Pass it along...\n"));

            //
            // Call PoStartNextPowerIrp to indicate that we're done
            //  processing this power IRP
            //
            PoStartNextPowerIrp(Irp);
            
            IoSkipCurrentIrpStackLocation(Irp);
            
            //
            // Pass the IRP down using PoCallDriver
            //
            status = PoCallDriver(devExt->DeviceToSendIrpsTo, Irp);
            
            //
            // We're done with this request
            //
            OsrDecrementOutstandingIoCount(devExt,__FILE__,__LINE__);

            break;
            
    }

    OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_POWER_INFO, ("OsrPower: Exiting...\n"));

    return status;

}

///////////////////////////////////////////////////////////////////////////////
//
// OsrHandleSystemPowerIrp
//
//      Entry point to handle SYSTEM power IRPs
//
//  INPUTS:
//
//      DeviceObject - Pointer to our device object.
//      Irp          - Address of the system power IRP.
//
//  OUTPUTS:
//
//      None.
//
//  RETURNS:
//
//      STATUS_PENDING if we are going to handle the IRP,
//       otherwise the NTSTATUS value of the driver below us
//
//  IRQL:
//
//      This routine is called at IRQL == PASSIVE_LEVEL
//
//  CONTEXT:
//
//      This routine is called in an arbitrary thread context
//
//  NOTES:
//
//
///////////////////////////////////////////////////////////////////////////////
NTSTATUS OsrHandleSystemPowerIrp(PDEVICE_OBJECT DeviceObject,PIRP Irp) 
{
    PUSBFX2LK_EXT       devExt  = (PUSBFX2LK_EXT)DeviceObject->DeviceExtension;
    PIO_STACK_LOCATION  ioStack = IoGetCurrentIrpStackLocation(Irp);
    POWER_STATE         powerState;
    NTSTATUS            status;

    OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_POWER_INFO, ("OsrHandleSystemPowerIrp: Entered...\n"));


    //
    // Which power state are we talking about?
    //
    powerState = ioStack->Parameters.Power.State;

    //
    // For ALL power IRPs, we are REQUIRED to:
    //
    //  1) call PoStartNextPowerIrp()
    //  2) Pass the IRP down to the next lower driver, unless
    //      we complete the request with an error.
    //

    switch(ioStack->MinorFunction)  {
            
        case IRP_MN_QUERY_POWER:

            // 
            // The code below assumes that this device is the power 
            // policy owner.  This is the norm for most FDO devices.
            //

            //
            // There's a slightly annoying and unexpected side effect
            //  of being suspended while processing the S Query IRP.
            //
            // If we're going to a power state that is lower than
            //  what our device can wake the system from, the bus
            //  driver will allow the system suspend to the lower, 
            //  unwakeable state. This means that the system will
            //  suspend, we'll have a Wait Wake IRP pending, but 
            //  nothing we do will wake the system. However, if
            //  our device is powered up when we handle the S-IRP, 
            //  then the bus driver will "do the right thing" and 
            //  fail the S-IRP query for the power down. This will 
            //  result in a new S-IRP coming in, hopefully with an 
            //  S state that we can suspend from.
            //
            SSPowerDeviceIfSuspended(devExt);


            //
            // if this device is something like an industrial device, 
            // that will typically be used in an industrial or other 
            // fixed setting, then it may be desireable to avoid power 
            // downs while I/O requests are in progress.  In this case 
            // the driver should keep some device state to indicate it is 
            // busy.  For example this could be done by tracking open 
            // handles to the device.  If the device is determined to be 
            // busy, the query to power down should be rejected.  Something
            // like following commented-out code could be used in this case.
            //
            
            //
            //If(deviceBusy) {
            //    PoStartNextPowerIrp(Irp);
            //
            //    Irp->IoStatus.Information = 0;
            //    Irp->IoStatus.Status      = STATUS_DEVICE_BUSY;
            //          
            //    //
            //    // Complete the request here, without passing it down...
            //    //
            //
            //    IoCompleteRequest (Irp, IO_NO_INCREMENT);
            //          
            //    return STATUS_DEVICE_BUSY;
            //}




            //
            // If the system is powering DOWN (numerically higher S-states 
            //  are lower in power) and we support wait wake, submit
            //  a wait wake request
            //
            if((powerState.SystemState > devExt->SystemPowerState) && (devExt->WaitWakeEnable)) {
                IssueWaitWake(devExt);
            }

            //
            // Unless it's absolutely mission critical, you should agree
            // to the request to power down your device. If one device
            // on the system rejects the request, things could get ugly
            // and the system might not properly shutdown in a timely 
            // manner (or even worse, not at all...). 
            //
            
            OsrTracePrint(TRACE_LEVEL_INFORMATION,OSRDBG_POWER_INFO, 
                        ("OsrHandleSystemPowerIrp: Querying for System state transition to %s\n", 
                        OsrPrintSystemPowerState(powerState.SystemState)));
            
           

            //
            // mark the IRP pending 
            //
            IoMarkIrpPending(Irp);
            
            IoCopyCurrentIrpStackLocationToNext(Irp);
            
            //
            // Insert our completion routine into the system power IRP.
            //
            IoSetCompletionRoutine(Irp,
                                   SystemPowerIoCompletionRoutine,
                                   devExt,
                                   TRUE,
                                   TRUE,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产成人国产三级| 欧美综合视频在线观看| 国产成人精品免费网站| 欧美午夜影院一区| 国产精品女同互慰在线看| 日韩成人午夜电影| 91在线观看一区二区| 久久久久久久综合| 免费在线观看视频一区| 欧洲另类一二三四区| 国产精品电影院| 国产成人鲁色资源国产91色综| 欧美精品aⅴ在线视频| 亚洲特黄一级片| 国产成人在线视频网站| 欧美一级片免费看| 性感美女久久精品| 欧美性大战久久久久久久| 亚洲欧美一区二区久久| www.亚洲人| 中文字幕永久在线不卡| 国产成人免费xxxxxxxx| 国产欧美一区二区精品久导航| 久久国产生活片100| 日韩亚洲欧美一区| 麻豆精品视频在线观看视频| 日韩一区二区三区av| 视频一区二区三区在线| 欧美日韩精品电影| 日韩高清不卡一区二区三区| 欧美日韩高清影院| 免费一级欧美片在线观看| 欧美一区二区精美| 激情综合五月天| 久久久亚洲精品石原莉奈| 狠狠色狠狠色合久久伊人| 久久综合久久综合亚洲| 国产成人精品亚洲午夜麻豆| 国产精品午夜久久| 色婷婷综合久久| 图片区日韩欧美亚洲| 这里只有精品视频在线观看| 另类小说综合欧美亚洲| 亚洲精品一区在线观看| 大胆欧美人体老妇| 亚洲资源中文字幕| 正在播放一区二区| 韩国av一区二区| 欧美韩国日本一区| 色婷婷综合在线| 麻豆精品精品国产自在97香蕉| 精品99久久久久久| av在线不卡电影| 亚洲成av人影院| 久久欧美一区二区| 色综合天天综合在线视频| 午夜欧美电影在线观看| 26uuu精品一区二区| 99精品视频在线免费观看| 亚洲第一av色| 国产欧美1区2区3区| 欧美影院精品一区| 国产在线精品一区二区| 亚洲色图在线看| 日韩三级中文字幕| 成人国产精品视频| 日本大胆欧美人术艺术动态| 国产精品乱码人人做人人爱| 91精品一区二区三区久久久久久| 国产成人午夜视频| 午夜av电影一区| 中文字幕色av一区二区三区| 欧美一二三区在线| 日本黄色一区二区| 国产乱妇无码大片在线观看| 亚洲va天堂va国产va久| 中文字幕欧美日韩一区| 欧美乱妇一区二区三区不卡视频| 成人一区二区在线观看| 美国三级日本三级久久99| 一区二区三区在线视频免费观看| 2020国产精品自拍| 欧美一区二区三区视频在线观看| 97成人超碰视| 国产高清亚洲一区| 蜜臀av在线播放一区二区三区| 亚洲黄色av一区| 国产精品视频免费看| 精品99999| 日韩一级完整毛片| 欧美日韩www| 在线观看欧美黄色| 91网站视频在线观看| 国产精品一区2区| 久久69国产一区二区蜜臀| 天天影视色香欲综合网老头| 一区二区三区在线观看网站| 中文字幕永久在线不卡| 欧美国产精品久久| 国产三级精品在线| 久久久精品中文字幕麻豆发布| 欧美一级精品在线| 欧美精品免费视频| 欧美日韩国产首页在线观看| 欧美在线观看禁18| 色屁屁一区二区| 日本乱人伦aⅴ精品| 99re热这里只有精品视频| 成人激情免费视频| av在线播放一区二区三区| jlzzjlzz欧美大全| 91在线看国产| 欧美在线小视频| 欧美另类久久久品| 欧美精品少妇一区二区三区| 制服视频三区第一页精品| 欧美一区二区免费视频| 日韩欧美高清dvd碟片| 欧美成人免费网站| 国产午夜亚洲精品理论片色戒| 亚洲精品在线免费播放| 国产视频一区二区在线| 国产精品久久三区| 夜夜亚洲天天久久| 奇米精品一区二区三区四区 | 99久久婷婷国产综合精品| 高清国产一区二区三区| 99久久久久久| 欧美视频一二三区| 日韩精品最新网址| 国产日韩亚洲欧美综合| 亚洲黄色免费电影| 日本不卡的三区四区五区| 精品亚洲国产成人av制服丝袜| 国产一区二区导航在线播放| 成人av网站免费| 欧美绝品在线观看成人午夜影视| 日韩欧美一级在线播放| 中文字幕av不卡| 亚洲图片欧美色图| 久久精品国产99久久6| 成人久久久精品乱码一区二区三区 | 日本三级亚洲精品| 国产最新精品免费| 91久久国产综合久久| 精品国产电影一区二区| 国产精品国产精品国产专区不片| 亚洲mv大片欧洲mv大片精品| 精品在线一区二区三区| 色综合视频在线观看| 欧美一区二区三区四区高清| 国产精品久久久久精k8| 日韩中文字幕亚洲一区二区va在线| 国产精品亚洲午夜一区二区三区| 色婷婷av一区| 国产清纯白嫩初高生在线观看91| 亚洲综合色丁香婷婷六月图片| 精品夜夜嗨av一区二区三区| 色婷婷av一区二区三区软件 | 欧美v日韩v国产v| 亚洲人成网站影音先锋播放| 久久99国产精品久久99果冻传媒 | 国产成人免费9x9x人网站视频| 在线日韩一区二区| 国产欧美一区二区在线观看| 日韩和欧美一区二区三区| 99久久99久久精品国产片果冻| 日韩三级中文字幕| 亚洲成人免费在线观看| 91在线视频在线| 亚洲国产精品v| 国产制服丝袜一区| 欧美一区二区播放| 亚洲成人一二三| 色欧美片视频在线观看| 国产亚洲自拍一区| 久久精品理论片| 欧美一区二区三区小说| 亚洲第一狼人社区| 色婷婷激情综合| 亚洲日本在线a| av在线一区二区| 国产精品久久久久aaaa樱花| 国产精品亚洲一区二区三区妖精| 欧美成人激情免费网| 日韩高清在线电影| 欧美一区二区三区免费| 亚洲成人av一区二区| 欧美视频在线播放| 一区二区三区在线视频观看58 | 日韩一本二本av| 日韩精品免费视频人成| 欧美片在线播放| 五月婷婷欧美视频| 欧美精品在线一区二区三区| 婷婷丁香久久五月婷婷| 4438x亚洲最大成人网| 蜜臀久久99精品久久久久宅男| 欧美一区二区三区四区五区| 另类小说一区二区三区|