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