- Add some UNIMPLEMENTED macros to highlight API's being called

- Reformat the code, no other changes

svn path=/trunk/; revision=27382
This commit is contained in:
Ged Murphy 2007-07-04 08:26:47 +00:00
parent 8db103104e
commit d090403690

View file

@ -17,9 +17,9 @@ extern ULONG ExpInitialiationPhase;
typedef struct _REQUEST_POWER_ITEM
{
PREQUEST_POWER_COMPLETE CompletionRoutine;
POWER_STATE PowerState;
PVOID Context;
PREQUEST_POWER_COMPLETE CompletionRoutine;
POWER_STATE PowerState;
PVOID Context;
} REQUEST_POWER_ITEM, *PREQUEST_POWER_ITEM;
PDEVICE_NODE PopSystemPowerDeviceNode = NULL;
@ -30,15 +30,14 @@ BOOLEAN PopAcpiPresent = FALSE;
*/
NTSTATUS
STDCALL
PoCallDriver(
IN PDEVICE_OBJECT DeviceObject,
IN OUT PIRP Irp)
PoCallDriver(IN PDEVICE_OBJECT DeviceObject,
IN OUT PIRP Irp)
{
NTSTATUS Status;
NTSTATUS Status;
Status = IoCallDriver(DeviceObject, Irp);
Status = IoCallDriver(DeviceObject, Irp);
return Status;
return Status;
}
/*
@ -46,13 +45,13 @@ PoCallDriver(
*/
PULONG
STDCALL
PoRegisterDeviceForIdleDetection(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG ConservationIdleTime,
IN ULONG PerformanceIdleTime,
IN DEVICE_POWER_STATE State)
PoRegisterDeviceForIdleDetection(IN PDEVICE_OBJECT DeviceObject,
IN ULONG ConservationIdleTime,
IN ULONG PerformanceIdleTime,
IN DEVICE_POWER_STATE State)
{
return NULL;
UNIMPLEMENTED;
return NULL;
}
/*
@ -60,36 +59,36 @@ PoRegisterDeviceForIdleDetection(
*/
PVOID
STDCALL
PoRegisterSystemState(
IN PVOID StateHandle,
IN EXECUTION_STATE Flags)
PoRegisterSystemState(IN PVOID StateHandle,
IN EXECUTION_STATE Flags)
{
return NULL;
UNIMPLEMENTED;
return NULL;
}
static
NTSTATUS STDCALL
PopRequestPowerIrpCompletion(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context)
NTSTATUS
STDCALL
PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context)
{
PIO_STACK_LOCATION Stack;
PREQUEST_POWER_ITEM RequestPowerItem;
PIO_STACK_LOCATION Stack;
PREQUEST_POWER_ITEM RequestPowerItem;
Stack = IoGetNextIrpStackLocation(Irp);
RequestPowerItem = (PREQUEST_POWER_ITEM)Context;
Stack = IoGetNextIrpStackLocation(Irp);
RequestPowerItem = (PREQUEST_POWER_ITEM)Context;
RequestPowerItem->CompletionRoutine(
DeviceObject,
Stack->MinorFunction,
RequestPowerItem->PowerState,
RequestPowerItem->Context,
&Irp->IoStatus);
RequestPowerItem->CompletionRoutine(DeviceObject,
Stack->MinorFunction,
RequestPowerItem->PowerState,
RequestPowerItem->Context,
&Irp->IoStatus);
ExFreePool(&Irp->IoStatus);
ExFreePool(Context);
return STATUS_SUCCESS;
ExFreePool(&Irp->IoStatus);
ExFreePool(Context);
return STATUS_SUCCESS;
}
/*
@ -97,80 +96,78 @@ PopRequestPowerIrpCompletion(
*/
NTSTATUS
STDCALL
PoRequestPowerIrp(
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PREQUEST_POWER_COMPLETE CompletionFunction,
IN PVOID Context,
OUT PIRP *pIrp OPTIONAL)
PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PREQUEST_POWER_COMPLETE CompletionFunction,
IN PVOID Context,
OUT PIRP *pIrp OPTIONAL)
{
PDEVICE_OBJECT TopDeviceObject;
PIO_STACK_LOCATION Stack;
PIRP Irp;
PIO_STATUS_BLOCK IoStatusBlock;
PREQUEST_POWER_ITEM RequestPowerItem;
NTSTATUS Status;
PDEVICE_OBJECT TopDeviceObject;
PIO_STACK_LOCATION Stack;
PIRP Irp;
PIO_STATUS_BLOCK IoStatusBlock;
PREQUEST_POWER_ITEM RequestPowerItem;
NTSTATUS Status;
if (MinorFunction != IRP_MN_QUERY_POWER
&& MinorFunction != IRP_MN_SET_POWER
&& MinorFunction != IRP_MN_WAIT_WAKE)
return STATUS_INVALID_PARAMETER_2;
if (MinorFunction != IRP_MN_QUERY_POWER
&& MinorFunction != IRP_MN_SET_POWER
&& MinorFunction != IRP_MN_WAIT_WAKE)
return STATUS_INVALID_PARAMETER_2;
RequestPowerItem = ExAllocatePool(NonPagedPool, sizeof(REQUEST_POWER_ITEM));
if (!RequestPowerItem)
return STATUS_INSUFFICIENT_RESOURCES;
IoStatusBlock = ExAllocatePool(NonPagedPool, sizeof(IO_STATUS_BLOCK));
if (!IoStatusBlock)
{
ExFreePool(RequestPowerItem);
return STATUS_INSUFFICIENT_RESOURCES;
}
RequestPowerItem = ExAllocatePool(NonPagedPool, sizeof(REQUEST_POWER_ITEM));
if (!RequestPowerItem)
return STATUS_INSUFFICIENT_RESOURCES;
IoStatusBlock = ExAllocatePool(NonPagedPool, sizeof(IO_STATUS_BLOCK));
if (!IoStatusBlock)
{
ExFreePool(RequestPowerItem);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Always call the top of the device stack */
TopDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
/* Always call the top of the device stack */
TopDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_PNP,
TopDeviceObject,
NULL,
0,
NULL,
NULL,
IoStatusBlock);
if (!Irp)
{
ExFreePool(RequestPowerItem);
ExFreePool(IoStatusBlock);
return STATUS_INSUFFICIENT_RESOURCES;
}
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP,
TopDeviceObject,
NULL,
0,
NULL,
NULL,
IoStatusBlock);
if (!Irp)
{
ExFreePool(RequestPowerItem);
ExFreePool(IoStatusBlock);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* POWER IRPs are always initialized with a status code of
STATUS_NOT_IMPLEMENTED */
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
/* POWER IRPs are always initialized with a status code of
STATUS_NOT_IMPLEMENTED */
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
Stack = IoGetNextIrpStackLocation(Irp);
Stack->MinorFunction = MinorFunction;
if (MinorFunction == IRP_MN_WAIT_WAKE)
Stack->Parameters.WaitWake.PowerState = PowerState.SystemState;
else
Stack->Parameters.WaitWake.PowerState = PowerState.DeviceState;
Stack = IoGetNextIrpStackLocation(Irp);
Stack->MinorFunction = MinorFunction;
if (MinorFunction == IRP_MN_WAIT_WAKE)
Stack->Parameters.WaitWake.PowerState = PowerState.SystemState;
else
Stack->Parameters.WaitWake.PowerState = PowerState.DeviceState;
RequestPowerItem->CompletionRoutine = CompletionFunction;
RequestPowerItem->PowerState = PowerState;
RequestPowerItem->Context = Context;
RequestPowerItem->CompletionRoutine = CompletionFunction;
RequestPowerItem->PowerState = PowerState;
RequestPowerItem->Context = Context;
if (pIrp != NULL)
*pIrp = Irp;
if (pIrp != NULL)
*pIrp = Irp;
IoSetCompletionRoutine(Irp, PopRequestPowerIrpCompletion, RequestPowerItem, TRUE, TRUE, TRUE);
Status = IoCallDriver(TopDeviceObject, Irp);
IoSetCompletionRoutine(Irp, PopRequestPowerIrpCompletion, RequestPowerItem, TRUE, TRUE, TRUE);
Status = IoCallDriver(TopDeviceObject, Irp);
/* Always return STATUS_PENDING. The completion routine
* will call CompletionFunction and complete the Irp.
*/
return STATUS_PENDING;
/* Always return STATUS_PENDING. The completion routine
* will call CompletionFunction and complete the Irp.
*/
return STATUS_PENDING;
}
#undef PoSetDeviceBusy
@ -178,6 +175,7 @@ VOID
NTAPI
PoSetDeviceBusy(IN PULONG IdlePointer)
{
UNIMPLEMENTED;
*IdlePointer = 0;
}
@ -185,7 +183,7 @@ VOID
NTAPI
PopCleanupPowerState(IN PPOWER_STATE PowerState)
{
/* FIXME */
//UNIMPLEMENTED;
}
/*
@ -193,19 +191,18 @@ PopCleanupPowerState(IN PPOWER_STATE PowerState)
*/
POWER_STATE
STDCALL
PoSetPowerState(
IN PDEVICE_OBJECT DeviceObject,
IN POWER_STATE_TYPE Type,
IN POWER_STATE State)
PoSetPowerState(IN PDEVICE_OBJECT DeviceObject,
IN POWER_STATE_TYPE Type,
IN POWER_STATE State)
{
POWER_STATE ps;
POWER_STATE ps;
ASSERT_IRQL(DISPATCH_LEVEL);
ASSERT_IRQL(DISPATCH_LEVEL);
ps.SystemState = PowerSystemWorking; // Fully on
ps.DeviceState = PowerDeviceD0; // Fully on
ps.SystemState = PowerSystemWorking; // Fully on
ps.DeviceState = PowerDeviceD0; // Fully on
return ps;
return ps;
}
/*
@ -213,9 +210,9 @@ PoSetPowerState(
*/
VOID
STDCALL
PoSetSystemState(
IN EXECUTION_STATE Flags)
PoSetSystemState(IN EXECUTION_STATE Flags)
{
UNIMPLEMENTED;
}
/*
@ -223,9 +220,9 @@ PoSetSystemState(
*/
VOID
STDCALL
PoStartNextPowerIrp(
IN PIRP Irp)
PoStartNextPowerIrp(IN PIRP Irp)
{
UNIMPLEMENTED;
}
/*
@ -233,71 +230,72 @@ PoStartNextPowerIrp(
*/
VOID
STDCALL
PoUnregisterSystemState(
IN PVOID StateHandle)
PoUnregisterSystemState(IN PVOID StateHandle)
{
UNIMPLEMENTED;
}
NTSTATUS
NTAPI
PopSetSystemPowerState(
SYSTEM_POWER_STATE PowerState)
PopSetSystemPowerState(SYSTEM_POWER_STATE PowerState)
{
IO_STATUS_BLOCK IoStatusBlock;
PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION IrpSp;
PDEVICE_OBJECT Fdo;
NTSTATUS Status;
KEVENT Event;
PIRP Irp;
IO_STATUS_BLOCK IoStatusBlock;
PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION IrpSp;
PDEVICE_OBJECT Fdo;
NTSTATUS Status;
KEVENT Event;
PIRP Irp;
if (!PopAcpiPresent) return STATUS_NOT_IMPLEMENTED;
if (!PopAcpiPresent) return STATUS_NOT_IMPLEMENTED;
Status = IopGetSystemPowerDeviceObject(&DeviceObject);
if (!NT_SUCCESS(Status)) {
CPRINT("No system power driver available\n");
return STATUS_UNSUCCESSFUL;
}
Fdo = IoGetAttachedDeviceReference(DeviceObject);
if (Fdo == DeviceObject)
Status = IopGetSystemPowerDeviceObject(&DeviceObject);
if (!NT_SUCCESS(Status))
{
DPRINT("An FDO was not attached\n");
return STATUS_UNSUCCESSFUL;
CPRINT("No system power driver available\n");
return STATUS_UNSUCCESSFUL;
}
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Fdo = IoGetAttachedDeviceReference(DeviceObject);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
Fdo,
NULL,
0,
NULL,
&Event,
&IoStatusBlock);
if (Fdo == DeviceObject)
{
DPRINT("An FDO was not attached\n");
return STATUS_UNSUCCESSFUL;
}
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_SET_POWER;
IrpSp->Parameters.Power.Type = SystemPowerState;
IrpSp->Parameters.Power.State.SystemState = PowerState;
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Status = PoCallDriver(Fdo, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
Fdo,
NULL,
0,
NULL,
&Event,
&IoStatusBlock);
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_SET_POWER;
IrpSp->Parameters.Power.Type = SystemPowerState;
IrpSp->Parameters.Power.State.SystemState = PowerState;
DPRINT("Calling ACPI driver");
Status = PoCallDriver(Fdo, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
ObDereferenceObject(Fdo);
ObDereferenceObject(Fdo);
return Status;
return Status;
}
BOOLEAN
@ -395,14 +393,13 @@ PoInitializePrcb(IN PKPRCB Prcb)
*/
NTSTATUS
STDCALL
NtInitiatePowerAction (
IN POWER_ACTION SystemAction,
IN SYSTEM_POWER_STATE MinSystemState,
IN ULONG Flags,
IN BOOLEAN Asynchronous)
NtInitiatePowerAction (IN POWER_ACTION SystemAction,
IN SYSTEM_POWER_STATE MinSystemState,
IN ULONG Flags,
IN BOOLEAN Asynchronous)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*
@ -410,64 +407,61 @@ NtInitiatePowerAction (
*/
NTSTATUS
STDCALL
NtPowerInformation(
IN POWER_INFORMATION_LEVEL PowerInformationLevel,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength
)
NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength)
{
NTSTATUS Status;
NTSTATUS Status;
PAGED_CODE();
PAGED_CODE();
DPRINT("NtPowerInformation(PowerInformationLevel 0x%x, InputBuffer 0x%x, "
"InputBufferLength 0x%x, OutputBuffer 0x%x, OutputBufferLength 0x%x)\n",
PowerInformationLevel,
InputBuffer, InputBufferLength,
OutputBuffer, OutputBufferLength);
switch (PowerInformationLevel)
{
case SystemBatteryState:
{
PSYSTEM_BATTERY_STATE BatteryState = (PSYSTEM_BATTERY_STATE)OutputBuffer;
DPRINT("NtPowerInformation(PowerInformationLevel 0x%x, InputBuffer 0x%x, "
"InputBufferLength 0x%x, OutputBuffer 0x%x, OutputBufferLength 0x%x)\n",
PowerInformationLevel,
InputBuffer, InputBufferLength,
OutputBuffer, OutputBufferLength);
switch (PowerInformationLevel)
{
case SystemBatteryState:
{
PSYSTEM_BATTERY_STATE BatteryState = (PSYSTEM_BATTERY_STATE)OutputBuffer;
if (InputBuffer != NULL)
return STATUS_INVALID_PARAMETER;
if (OutputBufferLength < sizeof(SYSTEM_BATTERY_STATE))
return STATUS_BUFFER_TOO_SMALL;
if (InputBuffer != NULL)
return STATUS_INVALID_PARAMETER;
if (OutputBufferLength < sizeof(SYSTEM_BATTERY_STATE))
return STATUS_BUFFER_TOO_SMALL;
/* Just zero the struct (and thus set BatteryState->BatteryPresent = FALSE) */
RtlZeroMemory(BatteryState, sizeof(SYSTEM_BATTERY_STATE));
BatteryState->EstimatedTime = (ULONG)-1;
/* Just zero the struct (and thus set BatteryState->BatteryPresent = FALSE) */
RtlZeroMemory(BatteryState, sizeof(SYSTEM_BATTERY_STATE));
BatteryState->EstimatedTime = (ULONG)-1;
Status = STATUS_SUCCESS;
break;
}
Status = STATUS_SUCCESS;
break;
}
default:
Status = STATUS_NOT_IMPLEMENTED;
DPRINT1("PowerInformationLevel 0x%x is UNIMPLEMENTED! Have a nice day.\n",
PowerInformationLevel);
break;
}
default:
Status = STATUS_NOT_IMPLEMENTED;
DPRINT1("PowerInformationLevel 0x%x is UNIMPLEMENTED! Have a nice day.\n",
PowerInformationLevel);
break;
}
return Status;
return Status;
}
NTSTATUS
STDCALL
PoQueueShutdownWorkItem(
IN PWORK_QUEUE_ITEM WorkItem
)
PoQueueShutdownWorkItem(IN PWORK_QUEUE_ITEM WorkItem)
{
PAGED_CODE();
PAGED_CODE();
DPRINT1("PoQueueShutdownWorkItem(%p)\n", WorkItem);
DPRINT1("PoQueueShutdownWorkItem(%p)\n", WorkItem);
return STATUS_NOT_IMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS