reactos/drivers/wdm/audio/backpln/portcls/power.cpp
Hermès Bélusca-Maïto e1ef078741 Create this branch to work on loading of different Kernel-Debugger DLL providers, and see whether it is possible to move KDBG from ntoskrnl to a new DLL called, say, KDROSDBG.DLL.
The idea then would be to have the following behaviour (when specifying the following options in the kernel command line):

/DEBUGPORT=COMi --> load KDCOM.DLL and use COMi port (i == 1,2,3,4) if possible.
/DEBUGPORT=FOO  --> load KDFOO.DLL (useful for KDUSB.DLL, KD1394.DLL, KDBAZIS.DLL for VirtualKD, etc...)
/DEBUGPORT=ROSDBG:[COMi|SCREEN|FILE|GDB|...] --> load KDROSDBG.DLL which contains the ROS kernel debugger, and use COMi or SCREEN or... as output port.

svn path=/branches/kd++/; revision=58883
2013-04-28 13:26:45 +00:00

91 lines
2.4 KiB
C++

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel Streaming
* FILE: drivers/wdm/audio/backpln/portcls/power.cpp
* PURPOSE: Power support functions
* PROGRAMMER: Johannes Anderwald
*/
#include "private.hpp"
NTSTATUS
NTAPI
PcRegisterAdapterPowerManagement(
IN PUNKNOWN pUnknown,
IN PVOID pvContext)
{
NTSTATUS Status;
PDEVICE_OBJECT pDeviceObject;
PPCLASS_DEVICE_EXTENSION DeviceExt;
IAdapterPowerManagement * pPower;
DPRINT("PcRegisterAdapterPowerManagement pUnknown %p pvContext %p\n", pUnknown, pvContext);
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
if (!pUnknown || !pvContext)
return STATUS_INVALID_PARAMETER;
pDeviceObject = (PDEVICE_OBJECT)pvContext;
DeviceExt = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
Status = pUnknown->QueryInterface(IID_IAdapterPowerManagement, (PVOID*)&pPower);
if (!NT_SUCCESS(Status))
{
DPRINT1("PcRegisterAdapterPowerManagement no IAdapterPowerManagement interface %x\n", Status);
DeviceExt->AdapterPowerManagement = NULL;
return STATUS_SUCCESS;
}
DeviceExt->AdapterPowerManagement = pPower;
DPRINT("PcRegisterAdapterPowerManagement success %x\n", Status);
return STATUS_SUCCESS;
}
static
VOID
NTAPI
PwrCompletionCallback(
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PVOID Context,
IN PIO_STATUS_BLOCK IoStatus)
{
KeSetEvent((PRKEVENT)Context, IO_NO_INCREMENT, FALSE);
}
NTSTATUS
NTAPI
PcRequestNewPowerState(
IN PDEVICE_OBJECT DeviceObject,
IN DEVICE_POWER_STATE RequestedNewState)
{
KEVENT Event;
NTSTATUS Status;
POWER_STATE PowerState;
PPCLASS_DEVICE_EXTENSION DeviceExt;
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
if (!DeviceObject || !RequestedNewState)
return STATUS_INVALID_PARAMETER;
DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
PowerState.DeviceState = RequestedNewState;
PowerState.SystemState = PowerSystemUnspecified;
Status = PoRequestPowerIrp(DeviceExt->PhysicalDeviceObject, IRP_MN_SET_POWER, PowerState, PwrCompletionCallback, (PVOID)&Event, NULL);
if (NT_SUCCESS(Status))
{
KeWaitForSingleObject((PVOID)&Event, Executive, KernelMode, FALSE, NULL);
}
return Status;
}