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

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

?? bulkpwr.c

?? winddk src目錄下的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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品一区二区三区四区| 色悠悠久久综合| 国产欧美中文在线| 99天天综合性| 韩国视频一区二区| 亚洲精品乱码久久久久久| 日韩一区二区在线看片| 99国产精品久久久| 美女脱光内衣内裤视频久久网站| 亚洲视频一区二区在线观看| 精品久久人人做人人爰| 日韩一区二区三区三四区视频在线观看 | 91玉足脚交白嫩脚丫在线播放| 欧美aaaaa成人免费观看视频| 久久影音资源网| 欧美丰满嫩嫩电影| 久国产精品韩国三级视频| 日韩精品高清不卡| 亚洲电影一区二区| 国产精品水嫩水嫩| 中文字幕欧美激情一区| 亚洲国产精品99久久久久久久久| 日韩午夜电影av| 日韩一区国产二区欧美三区| 欧美亚洲综合色| 色综合色狠狠天天综合色| 日本道色综合久久| 色素色在线综合| 欧美日韩精品一区二区三区| 一本大道综合伊人精品热热| 97精品超碰一区二区三区| 成人动漫视频在线| 91小视频在线免费看| 色哟哟国产精品| av亚洲精华国产精华精| 色综合久久久久综合99| 欧美日韩中文一区| 久久久久久毛片| 国产欧美日本一区视频| 亚洲欧洲99久久| 一区二区三区不卡在线观看| 日韩—二三区免费观看av| 国产不卡在线播放| 色哦色哦哦色天天综合| 欧美一级在线观看| 国产精品少妇自拍| 亚洲精品视频自拍| 国产一区视频在线看| 日本精品视频一区二区三区| 欧美变态tickle挠乳网站| 亚洲国产精品精华液ab| 日韩av电影一区| 国产91精品在线观看| 欧美日韩综合在线| 国产精品视频免费| 久久国产麻豆精品| 欧美视频一区在线| 国产三级欧美三级| 亚洲一卡二卡三卡四卡无卡久久| 国产一区二三区| 在线成人高清不卡| 午夜久久久久久久久久一区二区| 国产白丝网站精品污在线入口| 欧美日韩二区三区| 一区二区三区国产| aaa国产一区| 中文字幕亚洲欧美在线不卡| 精品亚洲porn| 久久久另类综合| 精品一区二区在线免费观看| 欧美一区二区女人| 美女视频一区在线观看| 欧美人与禽zozo性伦| 视频一区二区国产| 日韩欧美一级二级三级| 免费在线看成人av| 精品国产青草久久久久福利| 久久99精品久久久久| 久久精品男人天堂av| 国产99精品视频| 亚洲乱码国产乱码精品精小说| 91亚洲男人天堂| 一区二区视频免费在线观看| 成人午夜av电影| 亚洲精品国产品国语在线app| 91免费版在线| 久久99久久99| 久久综合色8888| 99久久免费视频.com| 亚洲另类中文字| 日韩一二三区不卡| 成人国产一区二区三区精品| 一区二区三区国产豹纹内裤在线| 欧美日韩电影在线| 成人精品国产免费网站| 亚洲成人综合在线| 国产日韩欧美不卡在线| 色综合av在线| 蜜桃视频一区二区三区| 亚洲精品成人天堂一二三| 精品精品国产高清一毛片一天堂| 一本一道波多野结衣一区二区 | 国产在线精品一区二区三区不卡 | 日韩电影一区二区三区四区| 欧美激情一区二区三区在线| 欧美在线free| 国产寡妇亲子伦一区二区| 天天爽夜夜爽夜夜爽精品视频| 国产亚洲欧美日韩俺去了| 欧美精选在线播放| 国产精品亚洲第一| 奇米色一区二区| 亚洲五码中文字幕| 国产精品久久久99| 久久久天堂av| 欧美一区二区免费观在线| 日本韩国视频一区二区| 91免费观看视频| 97久久久精品综合88久久| 粗大黑人巨茎大战欧美成人| 国产综合色精品一区二区三区| 日韩国产精品大片| 亚洲国产wwwccc36天堂| 亚洲成人综合在线| 五月激情综合色| 男人的天堂亚洲一区| 美腿丝袜亚洲色图| 久久精品噜噜噜成人88aⅴ| 麻豆国产精品一区二区三区| 免费国产亚洲视频| 国产伦精品一区二区三区在线观看| 国产一区二区三区精品视频| 另类的小说在线视频另类成人小视频在线 | 97精品电影院| 欧美日韩一区成人| 欧美日韩一区二区不卡| 91超碰这里只有精品国产| 欧美电视剧在线看免费| 久久一区二区三区四区| 亚洲精品视频免费观看| 天使萌一区二区三区免费观看| 麻豆专区一区二区三区四区五区| 国产精品一卡二卡在线观看| 99热精品一区二区| 日韩美女天天操| 亚洲视频综合在线| 国模大尺度一区二区三区| 99精品视频在线播放观看| 欧美精品高清视频| 国产日韩欧美精品一区| 天堂蜜桃91精品| 成人h动漫精品| 精品美女一区二区三区| 夜夜精品浪潮av一区二区三区| 九色|91porny| 日韩欧美亚洲国产另类| 一区二区三区国产精华| 成人av动漫在线| 精品欧美久久久| 天天综合色天天综合色h| 高清成人免费视频| xf在线a精品一区二区视频网站| 亚洲成人动漫在线免费观看| 91免费精品国自产拍在线不卡| 国产亚洲欧美一级| 风间由美一区二区三区在线观看| 日韩免费观看2025年上映的电影| 亚洲专区一二三| 波多野结衣亚洲一区| 中文字幕不卡三区| 国产白丝精品91爽爽久久| 欧美成人三级在线| 狠狠色丁香婷综合久久| 精品国产百合女同互慰| 精品一区二区在线观看| 国产日产欧美一区二区三区| 国产精品一区2区| 国产婷婷一区二区| 97se亚洲国产综合自在线不卡| 国产精品毛片大码女人| 91在线免费看| 日韩激情一二三区| 日韩一区二区三区视频在线| 日韩二区三区在线观看| 久久综合色综合88| 99久久精品久久久久久清纯| 亚洲色图丝袜美腿| 日韩美女在线视频| 成人av电影在线观看| 成人欧美一区二区三区| 精品视频一区 二区 三区| 九九精品视频在线看| 欧美国产日韩亚洲一区| 色噜噜久久综合| 国模娜娜一区二区三区| 国产精品久久久久影院色老大 | av网站一区二区三区| 青椒成人免费视频| 亚洲色图19p| 久久嫩草精品久久久久|