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

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

?? sspwr.c

?? winddk src目錄下的WDM源碼壓縮!
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2000 Microsoft Corporation

Module Name:

    sSPwr.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 "selSusp.h"
#include "sSPwr.h"
#include "sSPnP.h"
#include "sSDevCtr.h"
#include "sSUsr.h"
#include "sSWmi.h"

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

    SSDbgPrint(3, ("SS_DispatchPower::"));
    SSIoIncrement(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.
        //

        //
        // Mark the Irp as pending and return STATUS_PENDING if we change the 
        // nature of the irp in the completion routine (asynchroniticity).
        // In such cases, do not return the status returned by the lower driver.
        // returning STATUS_MORE_PROCESSING_REQUIRED in the completion routine 
        // transforms the nature of the irp to asynchronous irp.
        //

        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)) {

            SSDbgPrint(1, ("Lower drivers failed the IRP_MN_WAIT_WAKE Irp\n"));
        }

        //
        // since we marked the Irp as pending; we should return STATUS_PENDING
        //
        ntStatus = STATUS_PENDING;

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

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

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

    //
    // initialize variables
    //

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

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

    SSDbgPrint(3, ("Query for a 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
    // also, it is mandatory to have this Irp pending below
    // before we send any of the low power irps.
    //

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

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

    //
    // initialize variables
    //

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

    SSDbgPrint(3, ("Set request for a system power state S%X\n"
                   "Current system power state S%X\n", 
                   systemState - 1,
                   deviceExtension->SysPower - 1));

    //
    // pass the irp down the stack
    //
    IoCopyCurrentIrpStackLocationToNext(Irp);

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

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

    SSDbgPrint(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;

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

    //
    // initialize variables
    //

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

    SSDbgPrint(3, ("Query for a 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);
    }

    SSDbgPrint(3, ("HandleDeviceQueryPower::"));
    SSIoDecrement(deviceExtension);

    SSDbgPrint(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);


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

    //
    // lower drivers failed this Irp
    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产精品久久| 欧美mv日韩mv国产网站| 91传媒视频在线播放| 欧美日韩激情一区二区三区| 99热精品国产| 91视频在线观看| 欧美日韩国产首页在线观看| 欧美日韩精品一区二区三区蜜桃| 91精品国产色综合久久ai换脸| 中文字幕不卡的av| 国产婷婷色一区二区三区四区 | 欧美激情一区在线观看| 五月天亚洲婷婷| 色综合一区二区三区| 日韩午夜中文字幕| 亚洲欧美另类综合偷拍| 九九视频精品免费| 欧美区视频在线观看| 久久久一区二区三区| 日本麻豆一区二区三区视频| av电影天堂一区二区在线| 日韩一级成人av| 性久久久久久久久| 国产精品伦理在线| 精品一区二区三区免费观看 | 蓝色福利精品导航| 欧美午夜一区二区| 亚洲永久精品国产| 91搞黄在线观看| 一区二区三区精品视频| 成人自拍视频在线| 国产精品黄色在线观看| 国产一区二区三区在线观看免费| 欧美三级蜜桃2在线观看| 亚洲精品亚洲人成人网在线播放| 国产精品一二三区| 国产目拍亚洲精品99久久精品| 狠狠色丁香久久婷婷综合_中 | 欧美在线观看视频一区二区三区| 中文字幕中文在线不卡住| 91在线视频免费观看| 一区二区三区免费| 欧美日韩精品电影| 韩日精品视频一区| 亚洲乱码国产乱码精品精可以看 | 亚洲精品成人悠悠色影视| 91精品1区2区| 91丨九色丨黑人外教| 亚洲精品国产a久久久久久| 91福利资源站| 久久国产精品色| 亚洲欧美日韩系列| 日韩欧美高清一区| www.亚洲免费av| 日韩制服丝袜先锋影音| 国产精品卡一卡二卡三| 国产拍揄自揄精品视频麻豆| 91欧美一区二区| 麻豆91免费看| 亚洲自拍偷拍网站| 久久亚洲影视婷婷| 911精品国产一区二区在线| 风间由美中文字幕在线看视频国产欧美| 亚洲精品国产精华液| 久久久午夜精品理论片中文字幕| 色婷婷久久久亚洲一区二区三区| 日韩av一区二区在线影视| 久久夜色精品国产噜噜av| 欧美日韩中文精品| 91农村精品一区二区在线| 国产在线不卡视频| 激情久久五月天| 日韩精品高清不卡| 夜夜精品视频一区二区| 亚洲狠狠丁香婷婷综合久久久| 国产日产亚洲精品系列| 26uuu久久天堂性欧美| 日韩欧美国产综合| 日本一区二区免费在线观看视频| 91精品国产综合久久精品性色| 欧美在线视频你懂得| 久久久99精品久久| 中文幕一区二区三区久久蜜桃| 国产欧美日韩综合精品一区二区 | 亚洲国产精品一区二区www| 亚洲日本青草视频在线怡红院| 日韩av在线免费观看不卡| 麻豆精品一区二区三区| 国产福利一区二区| 99久久久久免费精品国产| 天天综合色天天综合色h| 中文字幕成人网| 午夜精品久久久久影视| 99在线热播精品免费| 久久久夜色精品亚洲| 国产资源在线一区| 色婷婷av一区二区三区之一色屋| 欧美日韩一二三| 国产精品视频第一区| 亚洲国产欧美在线| 国产综合成人久久大片91| 99久久精品情趣| 久久一区二区三区四区| 亚洲综合在线免费观看| 成人黄色a**站在线观看| 欧美日韩高清在线| 中文字幕中文乱码欧美一区二区| 美日韩一区二区| 91首页免费视频| 久久女同性恋中文字幕| 性做久久久久久久久| 日本道免费精品一区二区三区| 中文字幕中文字幕中文字幕亚洲无线| 亚洲乱码国产乱码精品精98午夜| 国产精品自在在线| 91精品国产综合久久精品| 亚洲一区二区三区视频在线| 99re这里都是精品| 欧美激情综合在线| 国产黄色91视频| 国产精品久久久久久妇女6080 | 色综合久久久久久久| 国产欧美一区二区精品性色| 国产一区在线看| 精品国产乱码久久久久久免费| 亚洲大片精品永久免费| 91久久人澡人人添人人爽欧美| 中文字幕在线不卡国产视频| 欧美在线不卡视频| 欧美高清在线视频| 91一区在线观看| 亚洲成av人影院| 久久久久久久久免费| 成人免费精品视频| 日韩一区精品字幕| 国产欧美日韩亚州综合| 欧美乱妇23p| 日本高清不卡视频| 国产乱子伦视频一区二区三区| 亚洲欧洲制服丝袜| 精品欧美久久久| 久久激情五月激情| 一区在线播放视频| 91精品国产全国免费观看| 国产精品正在播放| 亚洲久草在线视频| 91精品国产综合久久久久久久| 国产一区二区看久久| 亚洲欧洲精品一区二区精品久久久 | 久久99国产精品免费网站| 日韩一区中文字幕| 精品国产人成亚洲区| 欧美色国产精品| 99国产精品国产精品毛片| 麻豆精品久久久| 午夜精品久久一牛影视| 国产精品久久夜| 久久久美女艺术照精彩视频福利播放| 91视频在线观看免费| 国产成人精品免费一区二区| 日韩va欧美va亚洲va久久| 亚洲综合在线第一页| 国产精品动漫网站| 中文字幕av在线一区二区三区| 欧美熟乱第一页| 91在线国产观看| 99在线热播精品免费| 国产99久久久久| 丁香六月久久综合狠狠色| 国产一区二区精品久久91| 日本欧美加勒比视频| 秋霞电影网一区二区| 日本中文字幕一区二区视频| 国产一区二区三区美女| 国产精品白丝jk白祙喷水网站| 另类成人小视频在线| 国产主播一区二区三区| 久久99精品久久久久| 9l国产精品久久久久麻豆| 国产91精品一区二区麻豆网站| 国内一区二区在线| 床上的激情91.| 在线观看国产91| 欧美一区二区私人影院日本| 日韩欧美精品在线视频| 久久久午夜精品| 一区二区三区四区高清精品免费观看 | 日本麻豆一区二区三区视频| 国产一区二区主播在线| 一本一道久久a久久精品| 欧美男生操女生| 国产精品三级av在线播放| 亚洲一区二区三区不卡国产欧美| 日韩精品视频网| 99久久精品免费观看| 日韩一区二区中文字幕| 国产精品第13页| 国产精品综合视频| 欧洲一区二区av| 欧美疯狂性受xxxxx喷水图片|