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

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

?? bulkpwr.c

?? Windows2000/xp下的usb WDM驅動程序源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2000 Microsoft Corporation

Module Name:

    bulkpwr.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:

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

--*/

#include "bulkusb.h"
#include "bulkpwr.h"
#include "bulkpnp.h"
#include "bulkdev.h"
#include "bulkrwr.h"
#include "bulkwmi.h"
#include "bulkusr.h"

NTSTATUS
BulkUsb_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);
    }

    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPower::"));
    BulkUsb_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)) {

            BulkUsb_DbgPrint(1, ("Lower drivers failed the wait-wake Irp\n"));
        }

        ntStatus = STATUS_PENDING;

        //
        // push back the count HERE and NOT in completion routine
        // a pending Wait Wake Irp should not impede stopping the device
        //

        BulkUsb_DbgPrint(3, ("IRP_MN_WAIT_WAKE::"));
        BulkUsb_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)) {

            BulkUsb_DbgPrint(1, ("Lower drivers failed default power Irp\n"));
        }
        
        BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPower::"));
        BulkUsb_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;
    
    BulkUsb_DbgPrint(3, ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    systemState = irpStack->Parameters.Power.State.SystemState;

    BulkUsb_DbgPrint(3, ("Query for system power state S%X\n"
                         "Current system power state S%X\n",
                         systemState - 1,
                         deviceExtension->SysPower - 1));

    //
    // if querying for a lower S-state, issue a wait-wake
    //

    if ((systemState > deviceExtension->SysPower) &&
        deviceExtension->WaitWakeEnable)
    {
        if (systemState <= deviceExtension->DeviceCapabilities.SystemWake)
        {
            // OK, our device can wake system from requested state.
            // Ensure wake IRP is pending.
            //
            IssueWaitWake(deviceExtension);
        }
        else
        {
            // Our device cannot wake system from requested state.
            // Cancel pending wake IRP, if any, because it prevents
            // requested power state.
            //
            CancelWaitWake(deviceExtension);
        }
    }

    IoCopyCurrentIrpStackLocationToNext(Irp);

    IoSetCompletionRoutine(
            Irp, 
            (PIO_COMPLETION_ROUTINE)SysPoCompletionRoutine,
            deviceExtension, 
            TRUE, 
            TRUE, 
            TRUE);

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

    BulkUsb_DbgPrint(3, ("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;
    
    BulkUsb_DbgPrint(3, ("HandleSystemSetPower - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    systemState = irpStack->Parameters.Power.State.SystemState;

    BulkUsb_DbgPrint(3, ("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);

    BulkUsb_DbgPrint(3, ("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;

    BulkUsb_DbgPrint(3, ("HandleDeviceQueryPower - begins\n"));

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    deviceState = irpStack->Parameters.Power.State.DeviceState;

    BulkUsb_DbgPrint(3, ("Query for device power state D%X\n"
                         "Current device power state D%X\n",
                         deviceState - 1,
                         deviceExtension->DevPower - 1));

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

    BulkUsb_DbgPrint(3, ("HandleDeviceQueryPower::"));
    BulkUsb_IoDecrement(deviceExtension);

    BulkUsb_DbgPrint(3, ("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);


    BulkUsb_DbgPrint(3, ("SysPoCompletionRoutine - begins\n"));

    //
    // lower drivers failed this Irp
    //

    if(!NT_SUCCESS(ntStatus)) {

        PoStartNextPowerIrp(Irp);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区高清不卡| 欧美色国产精品| 久久久久青草大香线综合精品| 男男成人高潮片免费网站| 欧美精品在欧美一区二区少妇| 亚洲综合视频网| 欧美精品在欧美一区二区少妇| 日韩在线一二三区| 欧美精品一区二区久久婷婷| 国产在线国偷精品产拍免费yy| 久久久精品黄色| 99riav一区二区三区| 一区二区三区四区在线| 欧美精品久久久久久久多人混战| 爽好久久久欧美精品| 精品国产电影一区二区| 粉嫩aⅴ一区二区三区四区 | 欧美一区二区精品久久911| 免费在线观看精品| 久久久国产一区二区三区四区小说 | 这里只有精品视频在线观看| 美国欧美日韩国产在线播放| 国产女人aaa级久久久级| 一本久久综合亚洲鲁鲁五月天| 视频在线观看一区| 亚洲精品一区二区三区香蕉| 成人午夜精品在线| 天天综合天天做天天综合| 久久久久久综合| 欧美日韩一卡二卡三卡| 国产精品主播直播| 亚洲成a人在线观看| 日韩av电影免费观看高清完整版 | 韩国av一区二区三区| 亚洲精品福利视频网站| 精品日韩在线一区| 一本一本大道香蕉久在线精品| 麻豆久久久久久久| 综合久久国产九一剧情麻豆| 日韩精品中文字幕一区二区三区| av在线不卡观看免费观看| 免费亚洲电影在线| 一区二区三区在线看| 久久精品日产第一区二区三区高清版| 色偷偷88欧美精品久久久| 国产精品资源网| 欧美aaaaaa午夜精品| 亚洲欧美偷拍另类a∨色屁股| 欧美电影免费观看高清完整版在线| 99久久久久久| 国产精品1区二区.| 九色|91porny| 三级久久三级久久久| 亚洲精品视频在线看| 欧美国产精品v| www亚洲一区| 91麻豆精品国产91久久久使用方法 | 欧美老肥妇做.爰bbww| aaa亚洲精品一二三区| 精品一区二区日韩| 日韩电影免费一区| 五月天久久比比资源色| 日韩毛片精品高清免费| 国产精品每日更新在线播放网址| 精品欧美一区二区久久| 91精品福利在线一区二区三区| 日本精品视频一区二区| 99久久婷婷国产综合精品电影| 国产大陆精品国产| 国产又黄又大久久| 精品中文字幕一区二区| 麻豆视频一区二区| 欧美96一区二区免费视频| 日韩av一区二区三区四区| 午夜视频一区二区| 视频一区国产视频| 天涯成人国产亚洲精品一区av| 亚洲国产日产av| 天天做天天摸天天爽国产一区| 亚洲自拍偷拍欧美| 亚洲国产视频一区二区| 无码av免费一区二区三区试看| 亚洲va韩国va欧美va| 天涯成人国产亚洲精品一区av| 亚洲国产成人porn| 蜜臀av一级做a爰片久久| 蜜桃视频一区二区| 国产在线视视频有精品| 国产91精品入口| av不卡在线播放| 欧美性大战久久| 欧美一区二区视频免费观看| 日韩小视频在线观看专区| 日韩欧美国产1| 久久精品日产第一区二区三区高清版| 国产欧美一区视频| 亚洲人吸女人奶水| 亚洲成人中文在线| 精品在线播放午夜| 波多野结衣精品在线| 欧美在线观看一区二区| 欧美一级黄色录像| 美女精品一区二区| 国产福利电影一区二区三区| a在线播放不卡| 欧美猛男男办公室激情| 欧美成人三级在线| 中文字幕国产精品一区二区| 中文字幕在线观看一区二区| 亚洲福利一二三区| 狠狠久久亚洲欧美| 99久久国产免费看| 欧美一区二区三区视频在线| 久久久久国产精品免费免费搜索 | 亚洲色大成网站www久久九九| 亚洲高清中文字幕| 国产伦精一区二区三区| 色噜噜久久综合| 精品国产乱子伦一区| 亚洲蜜臀av乱码久久精品蜜桃| 日韩不卡免费视频| 99久免费精品视频在线观看 | 成人精品一区二区三区中文字幕| 在线亚洲免费视频| 337p日本欧洲亚洲大胆精品| 亚洲裸体在线观看| 狠狠色综合播放一区二区| 在线欧美小视频| 久久蜜桃一区二区| 亚洲成a人v欧美综合天堂下载| 国产福利视频一区二区三区| 欧美妇女性影城| 亚洲欧美经典视频| 国产福利精品导航| 日韩女优毛片在线| 亚洲影视在线播放| 成人免费黄色在线| 欧美sm美女调教| 亚洲va国产va欧美va观看| 97se亚洲国产综合自在线观| 欧美xxxxx裸体时装秀| 成人精品一区二区三区四区 | 亚洲成人三级小说| av不卡免费在线观看| 久久蜜臀中文字幕| 久久精品国产99国产| 欧美丝袜丝nylons| 亚洲精品自拍动漫在线| 成人动漫在线一区| 久久久www成人免费无遮挡大片| 首页国产欧美久久| 欧美无人高清视频在线观看| 中文字幕亚洲电影| 国产 日韩 欧美大片| 久久午夜色播影院免费高清| 日本成人在线不卡视频| 欧美日韩成人综合在线一区二区| 中文字幕一区二区三区在线不卡| 国产成人亚洲综合a∨猫咪| 日韩欧美在线综合网| 青青草91视频| 欧美一区二区三区的| 日韩精品视频网| 91精品久久久久久久99蜜桃 | 国产精品一卡二卡| 精品国产91久久久久久久妲己| 日韩国产欧美在线播放| 欧美日本一区二区三区四区| 亚洲第一激情av| 欧美精品一二三| 92国产精品观看| 亚洲美女视频一区| 91免费版pro下载短视频| 国产精品第四页| 97久久超碰国产精品电影| 亚洲另类春色校园小说| 91福利视频久久久久| 亚洲第一搞黄网站| 日韩一区二区电影在线| 久久99国产精品免费| 久久综合九色综合97婷婷| 国产v综合v亚洲欧| 亚洲色图另类专区| 欧美日韩一区国产| 男人的j进女人的j一区| 亚洲精品一区二区三区在线观看| 国产一区91精品张津瑜| 自拍偷拍欧美激情| 欧美日韩在线免费视频| 麻豆精品一区二区av白丝在线| 精品久久久久香蕉网| 不卡视频在线观看| 亚洲一区自拍偷拍| 日韩一级视频免费观看在线| 国产精品一区二区x88av| 亚洲伦在线观看| 日韩一二三区视频| 成人av在线播放网站| 亚洲第一电影网| 久久综合成人精品亚洲另类欧美|