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

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

?? intpwr.c

?? CyPress的C8051F32X系列底層驅動(C語言)及上位機demo(vc環境)
?? 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一区二区三区免费野_久草精品视频
国产一区欧美二区| 蜜臀99久久精品久久久久久软件 | 国产精品家庭影院| 亚洲婷婷综合久久一本伊一区| 一区二区三区四区在线播放| 国产精品短视频| 狠狠色狠狠色综合系列| 国产经典欧美精品| 日本韩国欧美国产| 精品国产亚洲一区二区三区在线观看 | 欧美一区二区三区四区高清| 精品日产卡一卡二卡麻豆| 欧美激情一区二区三区蜜桃视频 | 亚洲国产精品久久人人爱蜜臀| 青青草91视频| 日韩av午夜在线观看| 久久精品av麻豆的观看方式| 6080yy午夜一二三区久久| 高清在线观看日韩| 欧美精品vⅰdeose4hd| 日韩免费观看高清完整版| 久久久久久久久久看片| 亚洲欧美在线aaa| 蜜臀va亚洲va欧美va天堂| 色综合天天综合网天天狠天天| 欧美亚洲免费在线一区| 亚洲欧美日韩综合aⅴ视频| 国内精品视频一区二区三区八戒| 欧美在线|欧美| 国产精品久久久久桃色tv| 日韩综合在线视频| 制服丝袜国产精品| 一区二区三区在线免费视频 | 亚洲精品一区二区三区四区高清| 一区二区三区91| 色综合天天视频在线观看| 国产精品网站在线观看| 国产精品88av| 欧美精品一区二区三区在线 | 国产美女娇喘av呻吟久久| 91精品免费观看| 三级在线观看一区二区| 色婷婷久久99综合精品jk白丝| 国产日产欧美一区二区视频| 国产成人综合亚洲91猫咪| 精品国产自在久精品国产| 日韩福利视频网| 69堂亚洲精品首页| 国产亚洲综合av| 国产黄色精品网站| 国产精品毛片久久久久久| 丰满亚洲少妇av| 国产精品视频线看| 国产精品99久| 久久精品亚洲麻豆av一区二区| 国产成人免费网站| 国产精品五月天| 91丨porny丨最新| 亚洲免费av高清| 欧美性猛交xxxx黑人交| 久久超碰97中文字幕| 国产精品萝li| 欧美剧情电影在线观看完整版免费励志电影| 日韩电影在线看| 国产女人aaa级久久久级| 在线免费不卡电影| 美女一区二区三区| 国产精品国产自产拍在线| 欧美日韩精品一区二区三区蜜桃 | 色婷婷综合久久久中文一区二区| 亚洲国产精品影院| 国产日本欧洲亚洲| 欧美日韩视频专区在线播放| 国产乱码精品一区二区三区五月婷| 中文字幕一区免费在线观看| 欧美蜜桃一区二区三区| 成人美女视频在线观看| 香蕉久久夜色精品国产使用方法| 久久久亚洲欧洲日产国码αv| 色综合中文字幕| 国产精品一二二区| 午夜不卡av在线| 中文字幕视频一区| 亚洲精品在线三区| 91精品在线观看入口| 99精品视频在线播放观看| 久久69国产一区二区蜜臀| 亚洲综合自拍偷拍| 国产精品国产馆在线真实露脸| 日韩精品一区二区三区中文精品| 成人91在线观看| 国产精品99久久久久久宅男| 日韩不卡一二三区| 尤物在线观看一区| 国产精品乱人伦| 国产亚洲女人久久久久毛片| 日韩三级电影网址| 欧美日韩成人激情| 欧美伊人久久久久久久久影院| 成熟亚洲日本毛茸茸凸凹| 国产九九视频一区二区三区| av色综合久久天堂av综合| 最新中文字幕一区二区三区 | 精品日韩一区二区三区| 久久国产麻豆精品| 日韩精品色哟哟| 午夜a成v人精品| 首页国产丝袜综合| 亚洲国产色一区| 亚洲精品国产第一综合99久久| 国产精品高潮呻吟| 欧美国产成人精品| yourporn久久国产精品| 国产成人啪免费观看软件| 久久久久久久久蜜桃| 91香蕉视频在线| 成人精品免费看| 成人三级伦理片| 成熟亚洲日本毛茸茸凸凹| 成人美女在线观看| 99久久综合国产精品| 91在线精品一区二区三区| youjizz国产精品| 国产精品无码永久免费888| 国产女同互慰高潮91漫画| 一色屋精品亚洲香蕉网站| 亚洲精品国产无天堂网2021| 亚洲国产视频网站| 免费看精品久久片| 国产麻豆精品一区二区| 成人性生交大片免费看中文| 97久久超碰精品国产| 欧美视频中文一区二区三区在线观看| 91黄色免费版| 欧美成人官网二区| 欧美韩日一区二区三区| 亚洲欧美日韩在线不卡| 爽好久久久欧美精品| 久久99国产精品尤物| 成人黄色小视频| 欧美视频一二三区| 精品免费国产一区二区三区四区| 欧美国产日韩a欧美在线观看| 国产精品美女久久福利网站| 午夜精品久久一牛影视| 国产在线观看一区二区| 91丨porny丨首页| 欧美一级夜夜爽| 国产精品第13页| 亚洲a一区二区| 国产999精品久久| 欧美日韩一区二区三区在线| 精品处破学生在线二十三| 亚洲欧美成人一区二区三区| 青青草国产精品亚洲专区无| 成人av网址在线观看| 这里只有精品电影| 最新国产精品久久精品| 免费成人av在线播放| 91网址在线看| 久久综合一区二区| 性欧美疯狂xxxxbbbb| 不卡的av中国片| 欧美大片免费久久精品三p| 亚洲人成网站精品片在线观看| 麻豆精品在线视频| 91国模大尺度私拍在线视频| 久久久综合视频| 美女精品一区二区| 欧美亚洲一区三区| 国产精品美女久久久久av爽李琼 | 国产精品二区一区二区aⅴ污介绍| 丝袜美腿亚洲一区二区图片| av成人免费在线| 久久综合久久综合久久| 日韩主播视频在线| 色老综合老女人久久久| 国产精品视频一二| 国产精品一区二区不卡| 欧美r级在线观看| 亚洲成人一区二区| 色综合久久久网| 中文字幕中文字幕一区| 国产·精品毛片| 国产日韩av一区二区| 国内久久精品视频| 精品第一国产综合精品aⅴ| 蜜桃一区二区三区在线| 日韩一区二区三区在线| 午夜电影网一区| 欧美二区三区的天堂| 一区二区成人在线观看| 91麻豆精东视频| 亚洲视频一二三| 色综合久久中文综合久久97| 亚洲欧美日韩在线| 日本福利一区二区| 一区二区三国产精华液| 91国产福利在线| 一区二区三区蜜桃|