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

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

?? bulkpwr.c

?? <windows驅(qū)動開發(fā)技術(shù)詳解>源代碼
?? 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"));
        }

        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 this Irp"));
        }
        
        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));

    //
    // Fail a query for a power state incompatible with waking up the system
    //

    if((deviceExtension->WaitWakeEnable) &&
       (systemState > deviceExtension->DeviceCapabilities.SystemWake)) {

        BulkUsb_DbgPrint(1, ("Query for an incompatible system power state\n"));

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

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

        return ntStatus;
    }

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

    if((systemState > deviceExtension->SysPower) &&
       (deviceExtension->WaitWakeEnable)) {

        IssueWaitWake(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(deviceExtension->WaitWakeEnable &&
       deviceState > deviceExtension->DeviceCapabilities.DeviceWake) {

        PoStartNextPowerIrp(Irp);

        Irp->IoStatus.Status = ntStatus = STATUS_INVALID_DEVICE_STATE;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

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

        return ntStatus;
    }

    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;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲色图视频网站| 精品少妇一区二区三区| 亚洲精品视频一区二区| 一本大道久久a久久精品综合| 1024国产精品| 欧美三级在线看| 日韩精品免费专区| 久久免费视频色| 成人激情黄色小说| 自拍偷拍亚洲综合| 欧美二区乱c少妇| 国产一区二区三区四区五区入口| 欧美激情在线看| 欧美在线综合视频| 免费成人在线网站| 国产日韩在线不卡| 色老汉av一区二区三区| 免费成人av在线播放| 中文字幕国产一区| 欧美日韩高清在线| 国产精品18久久久久久vr| 国产精品国产三级国产aⅴ中文 | 国产精品久久久一区麻豆最新章节| 99这里都是精品| 日日摸夜夜添夜夜添国产精品| 欧美岛国在线观看| 色综合久久久久网| 捆绑调教美女网站视频一区| 国产人久久人人人人爽| 欧美日韩国产a| av激情成人网| 蜜臀精品一区二区三区在线观看 | 日韩一卡二卡三卡国产欧美| 床上的激情91.| 水蜜桃久久夜色精品一区的特点 | 国产精品88888| 午夜久久久影院| 欧美激情一区二区三区在线| 91.成人天堂一区| 99久久久久免费精品国产| 免费高清成人在线| 亚洲专区一二三| 中文字幕一区二区三区在线播放 | 一区二区三区在线观看国产 | 国产精品美女久久久久久久网站| 色噜噜偷拍精品综合在线| 国产在线观看一区二区| 亚洲国产一区二区a毛片| 国产精品入口麻豆九色| 欧美大白屁股肥臀xxxxxx| 在线免费观看视频一区| 国产精品一级黄| 久久成人18免费观看| 亚洲aaa精品| 亚洲视频你懂的| 国产午夜精品美女毛片视频| 欧美一卡二卡在线| 欧美日韩免费观看一区三区| 99久久er热在这里只有精品66| 国产在线观看免费一区| 青草国产精品久久久久久| 亚洲国产精品一区二区尤物区| 自拍偷拍亚洲综合| 国产精品久久久久久久浪潮网站 | 久久66热偷产精品| 免费高清成人在线| 日韩成人午夜电影| 日韩精品一卡二卡三卡四卡无卡| 一区二区三区在线免费播放| 亚洲美女在线国产| 亚洲三级在线免费观看| 国产精品国产三级国产aⅴ入口 | 亚洲免费av在线| 日韩一区在线免费观看| 欧美国产欧美综合| 国产欧美一区二区精品性色| 久久综合av免费| 久久这里只有精品首页| 久久久综合九色合综国产精品| 精品剧情v国产在线观看在线| 日韩一区二区免费视频| 精品久久久久香蕉网| 久久蜜桃香蕉精品一区二区三区| 久久久久久久网| 国产精品私人自拍| 中文字幕欧美一| 亚洲午夜影视影院在线观看| 午夜精品久久久久久久久久久| 日韩精品一卡二卡三卡四卡无卡| 美腿丝袜亚洲综合| 国产一区美女在线| www.爱久久.com| 日本久久电影网| 欧美日韩色综合| 欧美精品一区二区在线观看| 亚洲国产激情av| 一区二区三区蜜桃| 奇米亚洲午夜久久精品| 国内久久精品视频| 99热这里都是精品| 欧美乱妇20p| 久久嫩草精品久久久精品一| 日韩毛片精品高清免费| 日韩影院在线观看| 国产激情视频一区二区三区欧美 | 国产欧美va欧美不卡在线| 日韩一区欧美一区| 日韩二区在线观看| 国产成人鲁色资源国产91色综| 色琪琪一区二区三区亚洲区| 91精品国产色综合久久不卡蜜臀| 日韩欧美国产三级| 中文字幕一区在线观看视频| 日韩精品国产精品| 成人app软件下载大全免费| 欧美日韩成人高清| 欧美激情在线免费观看| 亚洲成人自拍一区| 国产成人综合在线| 欧美日韩一区国产| 国产欧美精品在线观看| 亚洲国产毛片aaaaa无费看| 紧缚奴在线一区二区三区| 不卡av在线免费观看| 欧美成人高清电影在线| 亚洲精品成人天堂一二三| 久久www免费人成看片高清| 91麻豆精品一区二区三区| 日韩一区二区三区在线| 亚洲人成网站精品片在线观看| 美日韩一级片在线观看| 91美女福利视频| 久久久91精品国产一区二区三区| 一区二区三区国产| 福利91精品一区二区三区| 欧美丰满少妇xxxxx高潮对白| 中文字幕电影一区| 久久超碰97人人做人人爱| 在线欧美日韩精品| 1024国产精品| 成人免费电影视频| 2023国产精品自拍| 欧美bbbbb| 欧美日韩精品系列| 一区二区三区日韩| www.欧美.com| 国产欧美一区二区精品性色超碰| 久久精品国产一区二区三| 欧美日韩国产大片| 亚洲国产精品人人做人人爽| 成人18视频日本| 欧美国产激情二区三区| 国产美女一区二区三区| 欧美mv和日韩mv的网站| 日本欧美在线看| 欧美日本一区二区三区四区 | 视频一区二区三区入口| 欧美视频在线观看一区| 亚洲欧洲av在线| 国产成人h网站| 国产欧美一区二区三区在线看蜜臀 | 亚洲综合男人的天堂| 成人动漫一区二区三区| 国产午夜精品一区二区三区嫩草| 韩国v欧美v日本v亚洲v| 精品99久久久久久| 久久爱www久久做| www国产成人| 成人综合婷婷国产精品久久免费| 国产欧美一区二区三区在线看蜜臀 | 成人高清av在线| 国产精品久久久久久久久果冻传媒 | 国产精品123| 国产精品婷婷午夜在线观看| 高清不卡一二三区| 综合欧美一区二区三区| 色哟哟国产精品| 亚洲mv大片欧洲mv大片精品| 在线看国产一区二区| 亚洲电影一级黄| 91精品国产综合久久福利软件| 日本vs亚洲vs韩国一区三区二区| 日韩欧美在线不卡| 国产一区二区三区四区五区美女| 欧美激情在线一区二区三区| 99国产一区二区三精品乱码| 亚洲乱码国产乱码精品精可以看| 欧美三级中文字幕| 九色综合国产一区二区三区| 久久午夜国产精品| 一本一道波多野结衣一区二区| 亚洲一区二区中文在线| 日韩午夜av一区| 成人中文字幕在线| 亚洲综合色婷婷| 欧美videossexotv100| 成人午夜短视频| 亚洲国产精品一区二区www| 精品国产网站在线观看| www.亚洲国产|