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

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

?? intpwr.c

?? 這是C8051F320的USB程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Module Name:

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

    
--*/

#include "intusb.h"
#include "intpwr.h"
#include "intpnp.h"
#include "intdev.h"
#include "intrwr.h"
#include "intwmi.h"
#include "intusr.h"
#ifdef WIN98DRIVER
#include "intwdm98.h"
#endif


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

    KdPrint( ("IntUsb_DispatchPower::"));
    IntUsb_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)) {

            KdPrint( ("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
        //

        KdPrint( ("IRP_MN_WAIT_WAKE::"));
        IntUsb_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)) {

            KdPrint( ("Lower drivers failed this Irp"));
        }
        
        KdPrint( ("IntUsb_DispatchPower::"));
        IntUsb_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;
    
    KdPrint( ("HandleSystemQueryPower - begins\n"));

    //
    // initialize variables
    //

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

    KdPrint( ("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)) {

        KdPrint( ("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);

        KdPrint( ("HandleSystemQueryPower::"));
        IntUsb_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);

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

    //
    // initialize variables
    //

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

    KdPrint( ("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);

    KdPrint( ("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;

    KdPrint( ("HandleDeviceQueryPower - begins\n"));

    //
    // initialize variables
    //

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

    KdPrint( ("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);

        KdPrint( ("HandleDeviceQueryPower::"));
        IntUsb_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);
    }

    KdPrint( ("HandleDeviceQueryPower::"));
    IntUsb_IoDecrement(deviceExtension);

    KdPrint( ("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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产不卡视频在线观看| 久久精品日韩一区二区三区| 亚洲三级电影网站| 91在线看国产| 亚洲精品成人精品456| 99久久综合狠狠综合久久| 亚洲欧美日韩综合aⅴ视频| 91美女福利视频| 亚洲sss视频在线视频| 91精品国产91久久久久久一区二区 | 亚洲视频免费看| 色素色在线综合| 丝袜美腿成人在线| 久久伊99综合婷婷久久伊| 成人禁用看黄a在线| 亚洲精品成人少妇| 69av一区二区三区| 国产麻豆91精品| 亚洲免费观看在线观看| 8x福利精品第一导航| 国产老妇另类xxxxx| 18成人在线观看| 91.麻豆视频| 成人永久看片免费视频天堂| 亚洲人快播电影网| 欧美一区二区视频观看视频| 国产原创一区二区三区| 亚洲欧美在线观看| 欧美一区日本一区韩国一区| 国产高清一区日本| 亚洲制服丝袜av| 精品捆绑美女sm三区| 91麻豆自制传媒国产之光| 美女网站色91| 一区在线中文字幕| 日韩一区二区三区四区| 99精品久久免费看蜜臀剧情介绍| 午夜欧美视频在线观看| 国产欧美日韩视频在线观看| 欧美日本在线一区| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 国模无码大尺度一区二区三区| 国产精品视频一二三区 | 日韩欧美在线影院| 色呦呦日韩精品| 国产精品1024| 日本aⅴ精品一区二区三区| 国产精品全国免费观看高清 | 久久久久久一级片| 欧美日韩精品是欧美日韩精品| 国产传媒一区在线| 日本不卡一区二区三区| 一区二区三区91| 国产精品私房写真福利视频| 精品国产亚洲一区二区三区在线观看| 在线观看国产日韩| 99精品视频在线播放观看| 国产美女娇喘av呻吟久久| 日韩精品一二区| 一区二区三区在线不卡| 国产精品久久久久桃色tv| 26uuu久久综合| 在线电影国产精品| 91麻豆精品视频| 成人国产在线观看| 国产成人午夜视频| 精久久久久久久久久久| 日韩精品一二区| 香蕉久久夜色精品国产使用方法| 亚洲靠逼com| 亚洲图片欧美激情| 国产精品成人免费精品自在线观看| 久久精品一区二区三区四区| 日韩精品一区在线| 日韩欧美一级在线播放| 欧美一二三区在线| 3d成人h动漫网站入口| 在线播放中文一区| 欧美三级日本三级少妇99| 在线观看国产一区二区| 欧美日韩亚洲综合一区二区三区| 91福利社在线观看| 欧美最新大片在线看| 欧美在线观看禁18| 欧美日韩国产欧美日美国产精品| 欧美性色黄大片手机版| 欧美日本乱大交xxxxx| 欧美日韩国产高清一区二区 | 亚洲综合色成人| 一区二区三区加勒比av| 亚洲免费视频中文字幕| 亚洲一区二区影院| 天天色图综合网| 免费人成网站在线观看欧美高清| 麻豆精品一区二区| 国模娜娜一区二区三区| 成人精品视频.| 色综合久久天天综合网| 欧美羞羞免费网站| 日韩欧美电影一区| 国产精品你懂的| 一区二区三区四区五区视频在线观看 | 中文字幕一区二区三区在线不卡 | 国产精品电影院| 一区二区三区视频在线观看| 亚洲国产欧美日韩另类综合 | 久久国产人妖系列| 国产91丝袜在线18| 91成人免费电影| 日韩一区二区三区在线| 欧美国产综合色视频| 一区二区三区四区中文字幕| 青草av.久久免费一区| 国产一区二区在线电影| 一本色道久久综合精品竹菊| 欧美一区二区三区啪啪| 国产亚洲成年网址在线观看| 亚洲精品成人天堂一二三| 久草中文综合在线| 91免费版在线| 日韩欧美中文字幕精品| 综合激情网...| 蜜臀va亚洲va欧美va天堂| av在线不卡免费看| 日韩欧美成人一区| 亚洲三级在线看| 蜜乳av一区二区三区| 91丝袜呻吟高潮美腿白嫩在线观看| 91精品国产综合久久小美女| 国产精品久久久久久久久果冻传媒| 亚洲一区二区欧美激情| 国产成人综合亚洲91猫咪| 欧美私人免费视频| 国产欧美精品一区二区色综合| 婷婷综合五月天| 不卡一卡二卡三乱码免费网站| 91精品国产美女浴室洗澡无遮挡| 中文字幕一区日韩精品欧美| 日本亚洲天堂网| 色综合天天综合| 久久久精品免费网站| 日日夜夜免费精品| 色婷婷av一区二区三区大白胸| 2023国产精品自拍| 日韩电影免费在线| 欧美日韩性生活| **性色生活片久久毛片| 国产福利91精品一区二区三区| 91麻豆精品国产自产在线观看一区 | 综合久久给合久久狠狠狠97色| 极品美女销魂一区二区三区免费| 欧美亚洲国产一区二区三区 | 亚洲高清一区二区三区| 99久久久精品| 中文天堂在线一区| 国产一区激情在线| 精品av久久707| 欧美a级理论片| 3d动漫精品啪啪| 日本欧美在线看| 欧美日韩成人在线一区| 夜夜精品浪潮av一区二区三区| 99视频超级精品| 国产精品久久久久一区二区三区共| 久草中文综合在线| 精品国产伦一区二区三区观看体验| 三级一区在线视频先锋| 欧美日韩激情一区二区三区| 亚洲va欧美va国产va天堂影院| 欧美亚洲日本国产| 三级亚洲高清视频| 日韩丝袜情趣美女图片| 日韩高清国产一区在线| 日韩西西人体444www| 美国精品在线观看| 久久综合九色综合久久久精品综合 | 日韩免费观看2025年上映的电影| 日韩av一级片| 日韩精品影音先锋| 国产精品中文有码| 国产精品五月天| 99久久综合国产精品| 亚洲最大成人综合| 欧美亚洲国产一区二区三区va| 午夜精品久久久久久久久| 91精品国产综合久久香蕉麻豆 | 日韩美女视频在线| 国产一本一道久久香蕉| 国产精品伦理在线| 一本久久a久久精品亚洲| 亚洲午夜久久久久久久久电影院| 欧美日韩mp4| 精品在线一区二区| 国产精品久久久久久户外露出| 9i在线看片成人免费| 天天色综合天天| 国产午夜精品久久| 91成人网在线| 老司机精品视频导航| 欧美激情综合五月色丁香小说|