ReactOS  0.4.15-dev-4917-g934e521
po.h File Reference
#include <guiddef.h>
#include <poclass.h>
Include dependency graph for po.h:

Go to the source code of this file.

Classes

struct  _PO_HIBER_PERF
 
struct  _PO_MEMORY_IMAGE
 
struct  _PO_MEMORY_RANGE_ARRAY_RANGE
 
struct  _PO_MEMORY_RANGE_ARRAY_LINK
 
struct  _PO_MEMORY_RANGE_ARRAY
 
struct  _POP_HIBER_CONTEXT
 
struct  _PO_NOTIFY_ORDER_LEVEL
 
struct  _POP_SHUTDOWN_BUG_CHECK
 
struct  _POP_DEVICE_POWER_IRP
 
struct  _PO_DEVICE_NOTIFY_ORDER
 
struct  _POP_DEVICE_SYS_STATE
 
struct  _POP_POWER_ACTION
 
struct  _POWER_CHANNEL_SUMMARY
 
struct  _DEVICE_OBJECT_POWER_EXTENSION
 
struct  _POP_SHUTDOWN_WAIT_ENTRY
 

Macros

#define _PO_DEBUG_   0x00
 
#define PO_STATE_DEBUG   0x01
 
#define POTRACE(x, fmt, ...)   DPRINT(fmt, ##__VA_ARGS__)
 

Typedefs

typedef struct _PO_HIBER_PERF PO_HIBER_PERF
 
typedef struct _PO_HIBER_PERFPPO_HIBER_PERF
 
typedef struct _PO_MEMORY_IMAGE PO_MEMORY_IMAGE
 
typedef struct _PO_MEMORY_IMAGEPPO_MEMORY_IMAGE
 
typedef struct _PO_MEMORY_RANGE_ARRAY_RANGE PO_MEMORY_RANGE_ARRAY_RANGE
 
typedef struct _PO_MEMORY_RANGE_ARRAY_LINK PO_MEMORY_RANGE_ARRAY_LINK
 
typedef struct _PO_MEMORY_RANGE_ARRAY PO_MEMORY_RANGE_ARRAY
 
typedef struct _PO_MEMORY_RANGE_ARRAYPPO_MEMORY_RANGE_ARRAY
 
typedef struct _POP_HIBER_CONTEXT POP_HIBER_CONTEXT
 
typedef struct _POP_HIBER_CONTEXTPPOP_HIBER_CONTEXT
 
typedef struct _PO_NOTIFY_ORDER_LEVEL PO_NOTIFY_ORDER_LEVEL
 
typedef struct _PO_NOTIFY_ORDER_LEVELPPO_NOTIFY_ORDER_LEVEL
 
typedef struct _POP_SHUTDOWN_BUG_CHECK POP_SHUTDOWN_BUG_CHECK
 
typedef struct _POP_SHUTDOWN_BUG_CHECKPPOP_SHUTDOWN_BUG_CHECK
 
typedef struct _POP_DEVICE_POWER_IRP POP_DEVICE_POWER_IRP
 
typedef struct _POP_DEVICE_POWER_IRPPPOP_DEVICE_POWER_IRP
 
typedef struct _PO_DEVICE_NOTIFY_ORDER PO_DEVICE_NOTIFY_ORDER
 
typedef struct _PO_DEVICE_NOTIFY_ORDERPPO_DEVICE_NOTIFY_ORDER
 
typedef struct _POP_DEVICE_SYS_STATE POP_DEVICE_SYS_STATE
 
typedef struct _POP_DEVICE_SYS_STATEPPOP_DEVICE_SYS_STATE
 
typedef struct _POP_POWER_ACTION POP_POWER_ACTION
 
typedef struct _POP_POWER_ACTIONPPOP_POWER_ACTION
 
typedef enum _POP_DEVICE_IDLE_TYPE POP_DEVICE_IDLE_TYPE
 
typedef enum _POP_DEVICE_IDLE_TYPEPPOP_DEVICE_IDLE_TYPE
 
typedef struct _POWER_CHANNEL_SUMMARY POWER_CHANNEL_SUMMARY
 
typedef struct _POWER_CHANNEL_SUMMARYPPOWER_CHANNEL_SUMMARY
 
typedef struct _DEVICE_OBJECT_POWER_EXTENSION DEVICE_OBJECT_POWER_EXTENSION
 
typedef struct _DEVICE_OBJECT_POWER_EXTENSIONPDEVICE_OBJECT_POWER_EXTENSION
 
typedef struct _POP_SHUTDOWN_WAIT_ENTRY POP_SHUTDOWN_WAIT_ENTRY
 
typedef struct _POP_SHUTDOWN_WAIT_ENTRYPPOP_SHUTDOWN_WAIT_ENTRY
 

Enumerations

enum  _POP_DEVICE_IDLE_TYPE { DeviceIdleNormal, DeviceIdleDisk }
 

Functions

BOOLEAN NTAPI PoInitSystem (IN ULONG BootPhase)
 
VOID NTAPI PoInitializePrcb (IN PKPRCB Prcb)
 
VOID NTAPI PopInitShutdownList (VOID)
 
VOID NTAPI PoInitializeDeviceObject (IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension)
 
VOID NTAPI PoVolumeDevice (IN PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI PoRemoveVolumeDevice (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI PopSetSystemPowerState (SYSTEM_POWER_STATE PowerState, POWER_ACTION PowerAction)
 
VOID NTAPI PopCleanupPowerState (IN PPOWER_STATE PowerState)
 
NTSTATUS NTAPI PopAddRemoveSysCapsCallback (IN PVOID NotificationStructure, IN PVOID Context)
 
VOID NTAPI PoNotifySystemTimeSet (VOID)
 
VOID NTAPI PopReadShutdownPolicy (VOID)
 
VOID NTAPI PopGracefulShutdown (IN PVOID Context)
 
VOID NTAPI PopFlushVolumes (IN BOOLEAN ShuttingDown)
 

Variables

PDEVICE_NODE PopSystemPowerDeviceNode
 
KGUARDED_MUTEX PopVolumeLock
 
LIST_ENTRY PopVolumeDevices
 
KSPIN_LOCK PopDopeGlobalLock
 
POP_POWER_ACTION PopAction
 
SYSTEM_POWER_CAPABILITIES PopCapabilities
 

Macro Definition Documentation

◆ _PO_DEBUG_

#define _PO_DEBUG_   0x00

Definition at line 15 of file po.h.

◆ PO_STATE_DEBUG

#define PO_STATE_DEBUG   0x01

Definition at line 20 of file po.h.

◆ POTRACE

#define POTRACE (   x,
  fmt,
  ... 
)    DPRINT(fmt, ##__VA_ARGS__)

Definition at line 33 of file po.h.

Typedef Documentation

◆ DEVICE_OBJECT_POWER_EXTENSION

◆ PDEVICE_OBJECT_POWER_EXTENSION

◆ PO_DEVICE_NOTIFY_ORDER

◆ PO_HIBER_PERF

◆ PO_MEMORY_IMAGE

◆ PO_MEMORY_RANGE_ARRAY

◆ PO_MEMORY_RANGE_ARRAY_LINK

◆ PO_MEMORY_RANGE_ARRAY_RANGE

◆ PO_NOTIFY_ORDER_LEVEL

◆ POP_DEVICE_IDLE_TYPE

◆ POP_DEVICE_POWER_IRP

◆ POP_DEVICE_SYS_STATE

◆ POP_HIBER_CONTEXT

◆ POP_POWER_ACTION

◆ POP_SHUTDOWN_BUG_CHECK

◆ POP_SHUTDOWN_WAIT_ENTRY

◆ POWER_CHANNEL_SUMMARY

◆ PPO_DEVICE_NOTIFY_ORDER

◆ PPO_HIBER_PERF

◆ PPO_MEMORY_IMAGE

◆ PPO_MEMORY_RANGE_ARRAY

◆ PPO_NOTIFY_ORDER_LEVEL

◆ PPOP_DEVICE_IDLE_TYPE

◆ PPOP_DEVICE_POWER_IRP

◆ PPOP_DEVICE_SYS_STATE

◆ PPOP_HIBER_CONTEXT

◆ PPOP_POWER_ACTION

◆ PPOP_SHUTDOWN_BUG_CHECK

◆ PPOP_SHUTDOWN_WAIT_ENTRY

◆ PPOWER_CHANNEL_SUMMARY

Enumeration Type Documentation

◆ _POP_DEVICE_IDLE_TYPE

Enumerator
DeviceIdleNormal 
DeviceIdleDisk 

Definition at line 230 of file po.h.

231 {
enum _POP_DEVICE_IDLE_TYPE POP_DEVICE_IDLE_TYPE
enum _POP_DEVICE_IDLE_TYPE * PPOP_DEVICE_IDLE_TYPE

Function Documentation

◆ PoInitializeDeviceObject()

VOID NTAPI PoInitializeDeviceObject ( IN OUT PDEVOBJ_EXTENSION  DeviceObjectExtension)

Definition at line 361 of file povolume.c.

362 {
363  PEXTENDED_DEVOBJ_EXTENSION DeviceExtension = (PVOID)DeviceObjectExtension;
364  PAGED_CODE();
365 
366  /* Initialize the power flags */
367  DeviceExtension->PowerFlags = PowerSystemUnspecified & 0xF;
368  DeviceExtension->PowerFlags |= ((PowerDeviceUnspecified << 4) & 0xF0);
369 
370  /* The device object is not on drugs yet */
371  DeviceExtension->Dope = NULL;
372 }
void * PVOID
Definition: retypes.h:9
struct _DEVICE_OBJECT_POWER_EXTENSION * Dope
Definition: iotypes.h:933
#define NULL
Definition: types.h:112
#define PAGED_CODE()

Referenced by IoCreateDevice().

◆ PoInitializePrcb()

VOID NTAPI PoInitializePrcb ( IN PKPRCB  Prcb)

Definition at line 498 of file power.c.

499 {
500  /* Initialize the Power State */
501  RtlZeroMemory(&Prcb->PowerState, sizeof(Prcb->PowerState));
502  Prcb->PowerState.Idle0KernelTimeLimit = 0xFFFFFFFF;
503  Prcb->PowerState.CurrentThrottle = 100;
504  Prcb->PowerState.CurrentThrottleIndex = 0;
505  Prcb->PowerState.IdleFunction = PopIdle0;
506 
507  /* Initialize the Perf DPC and Timer */
508  KeInitializeDpc(&Prcb->PowerState.PerfDpc, PopPerfIdleDpc, Prcb);
509  KeSetTargetProcessorDpc(&Prcb->PowerState.PerfDpc, Prcb->Number);
510  KeInitializeTimerEx(&Prcb->PowerState.PerfTimer, SynchronizationTimer);
511 }
VOID NTAPI PopPerfIdleDpc(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: power.c:478
VOID FASTCALL PopIdle0(IN PPROCESSOR_POWER_STATE PowerState)
Definition: power.c:489
VOID NTAPI KeSetTargetProcessorDpc(IN PKDPC Dpc, IN CCHAR Number)
Definition: dpc.c:971
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244

Referenced by KiInitializeKernel(), and KiSystemStartupBootStack().

◆ PoInitSystem()

BOOLEAN NTAPI PoInitSystem ( IN ULONG  BootPhase)

Definition at line 397 of file power.c.

398 {
400  PCHAR CommandLine;
401  BOOLEAN ForceAcpiDisable = FALSE;
402 
403  /* Check if this is phase 1 init */
404  if (BootPhase == 1)
405  {
407  /* Register power button notification */
410  (PVOID)&GUID_DEVICE_SYS_BUTTON,
413  NULL,
415  if (!NT_SUCCESS(Status))
416  return FALSE;
417 
418  /* Register lid notification */
421  (PVOID)&GUID_DEVICE_LID,
424  NULL,
426  return NT_SUCCESS(Status);
427  }
428 
429  /* Initialize the power capabilities */
431 
432  /* Get the Command Line */
433  CommandLine = KeLoaderBlock->LoadOptions;
434 
435  /* Upcase it */
436  _strupr(CommandLine);
437 
438  /* Check for ACPI disable */
439  if (strstr(CommandLine, "NOACPI")) ForceAcpiDisable = TRUE;
440 
441  if (ForceAcpiDisable)
442  {
443  /* Set the ACPI State to False if it's been forced that way */
445  }
446  else
447  {
448  /* Otherwise check if the LoaderBlock has a ACPI Table */
450  }
451 
452  /* Enable shutdown by power button */
453  if (PopAcpiPresent)
455 
456  /* Initialize volume support */
459 
460  /* Initialize support for dope */
462 
463  /* Initialize support for shutdown waits and work-items */
465 
466  return TRUE;
467 }
signed char * PCHAR
Definition: retypes.h:7
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:855
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
#define TRUE
Definition: types.h:120
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
LONG NTSTATUS
Definition: precomp.h:26
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1239
BOOLEAN PopAcpiPresent
Definition: power.c:26
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry
LIST_ENTRY PopVolumeDevices
Definition: povolume.c:27
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:240
unsigned char BOOLEAN
VOID NTAPI PopInitShutdownList(VOID)
Definition: poshtdwn.c:35
KGUARDED_MUTEX PopVolumeLock
Definition: povolume.c:26
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
SYSTEM_POWER_CAPABILITIES PopCapabilities
Definition: power.c:29
#define NULL
Definition: types.h:112
NTSTATUS NTAPI PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure, IN PVOID Context)
Definition: events.c:147
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:345
KSPIN_LOCK PopDopeGlobalLock
Definition: povolume.c:28

Referenced by Phase1InitializationDiscard().

◆ PoNotifySystemTimeSet()

VOID NTAPI PoNotifySystemTimeSet ( VOID  )

Definition at line 39 of file events.c.

40 {
41  KIRQL OldIrql;
42 
43  /* Check if Win32k registered a notification callback */
44  if (PopEventCallout)
45  {
46  /* Raise to dispatch */
48 
49  /* Notify the callback */
51 
52  /* Lower IRQL back */
54  }
55 }
PCALLBACK_OBJECT SetSystemTimeCallback
Definition: callback.c:27
UCHAR KIRQL
Definition: env_spec_w32.h:591
PKWIN32_POWEREVENT_CALLOUT PopEventCallout
Definition: events.c:32
VOID NTAPI ExNotifyCallback(IN PCALLBACK_OBJECT CallbackObject, IN PVOID Argument1, IN PVOID Argument2)
Definition: callback.c:467
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NULL
Definition: types.h:112
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

Referenced by Phase1InitializationDiscard().

◆ PopAddRemoveSysCapsCallback()

NTSTATUS NTAPI PopAddRemoveSysCapsCallback ( IN PVOID  NotificationStructure,
IN PVOID  Context 
)

Definition at line 147 of file events.c.

149 {
151  PSYS_BUTTON_CONTEXT SysButtonContext;
156  PIRP Irp;
158  KEVENT Event;
159  BOOLEAN Arrival;
160  ULONG Caps;
162 
163  DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n",
165 
167  if (Notification->Version != 1)
171  if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL, sizeof(GUID)) == sizeof(GUID))
172  Arrival = TRUE;
173  else if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL, sizeof(GUID)) == sizeof(GUID))
174  Arrival = FALSE;
175  else
177 
178  if (Arrival)
179  {
180  DPRINT("Arrival of %wZ\n", Notification->SymbolicLinkName);
181 
182  /* Open the device */
184  Notification->SymbolicLinkName,
186  NULL,
187  NULL);
191  &IoStatusBlock,
193  0);
194  if (!NT_SUCCESS(Status))
195  {
196  DPRINT1("ZwOpenFile() failed with status 0x%08lx\n", Status);
197  return Status;
198  }
202  KernelMode,
203  (PVOID*)&FileObject,
204  NULL);
205  if (!NT_SUCCESS(Status))
206  {
207  DPRINT1("ObReferenceObjectByHandle() failed with status 0x%08lx\n", Status);
209  return Status;
210  }
213 
214  /* Get capabilities (IOCTL_GET_SYS_BUTTON_CAPS) */
217  DeviceObject,
218  NULL,
219  0,
220  &Caps,
221  sizeof(Caps),
222  FALSE,
223  &Event,
224  &IoStatusBlock);
225  if (!Irp)
226  {
227  DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
230  }
232  if (Status == STATUS_PENDING)
233  {
234  DPRINT("IOCTL_GET_SYS_BUTTON_CAPS pending\n");
237  }
238  if (!NT_SUCCESS(Status))
239  {
240  DPRINT1("Sending IOCTL_GET_SYS_BUTTON_CAPS failed with status 0x%08x\n", Status);
243  }
244 
245  DPRINT("Device capabilities: 0x%x\n", Caps);
246  if (Caps & SYS_BUTTON_POWER)
247  {
248  DPRINT("POWER button present\n");
250  }
251 
252  if (Caps & SYS_BUTTON_SLEEP)
253  {
254  DPRINT("SLEEP button present\n");
256  }
257 
258  if (Caps & SYS_BUTTON_LID)
259  {
260  DPRINT("LID present\n");
262  }
263 
264  SysButtonContext = ExAllocatePoolWithTag(NonPagedPool,
265  sizeof(SYS_BUTTON_CONTEXT),
266  'IWOP');
267  if (!SysButtonContext)
268  {
269  DPRINT1("ExAllocatePoolWithTag() failed\n");
272  }
273 
274  /* Queue a work item to get sys button event */
275  SysButtonContext->WorkItem = IoAllocateWorkItem(DeviceObject);
276  SysButtonContext->DeviceObject = DeviceObject;
277  if (!SysButtonContext->WorkItem)
278  {
279  DPRINT1("IoAllocateWorkItem() failed\n");
281  ExFreePoolWithTag(SysButtonContext, 'IWOP');
283  }
284  IoQueueWorkItem(SysButtonContext->WorkItem,
287  SysButtonContext);
288 
290  return STATUS_SUCCESS;
291  }
292  else
293  {
294  DPRINT1("Removal of a power capable device not implemented\n");
295  return STATUS_NOT_IMPLEMENTED;
296  }
297 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
#define IOCTL_GET_SYS_BUTTON_CAPS
Definition: poclass.h:57
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION * PDEVICE_INTERFACE_CHANGE_NOTIFICATION
const GUID GUID_DEVICE_INTERFACE_ARRIVAL
Definition: deviface.c:14
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define SYS_BUTTON_SLEEP
Definition: poclass.h:82
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define FILE_SHARE_READ
Definition: compat.h:136
#define SYS_BUTTON_LID
Definition: poclass.h:83
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define FILE_READ_DATA
Definition: nt_native.h:628
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
unsigned char BOOLEAN
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ObDereferenceObject
Definition: obfuncs.h:203
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
static VOID NTAPI PopGetSysButton(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
Definition: events.c:107
#define SYS_BUTTON_POWER
Definition: poclass.h:81
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:113
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1230
struct _GUID GUID
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_OBJECT DeviceObject
Definition: events.c:19
const GUID GUID_DEVICE_INTERFACE_REMOVAL
Definition: deviface.c:15
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
SYSTEM_POWER_CAPABILITIES PopCapabilities
Definition: power.c:29
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
PIO_WORKITEM WorkItem
Definition: events.c:20

Referenced by PoInitSystem().

◆ PopCleanupPowerState()

VOID NTAPI PopCleanupPowerState ( IN PPOWER_STATE  PowerState)

Definition at line 164 of file power.c.

165 {
166  //UNIMPLEMENTED;
167 }

Referenced by PspExitProcess(), and PspExitThread().

◆ PopFlushVolumes()

VOID NTAPI PopFlushVolumes ( IN BOOLEAN  ShuttingDown)

Definition at line 227 of file povolume.c.

228 {
229  POP_FLUSH_VOLUME FlushContext = {{0}};
230  ULONG FlushPolicy;
231  UNICODE_STRING RegistryName = RTL_CONSTANT_STRING(L"\\Registry");
233  HANDLE RegistryHandle;
234  PLIST_ENTRY NextEntry;
236  ULONG VolumeCount = 0;
238  HANDLE ThreadHandle;
239  ULONG ThreadCount;
240 
241  /* Setup the flush context */
242  InitializeListHead(&FlushContext.List);
244 
245  /* What to flush */
246  FlushPolicy = ShuttingDown ? 1 | 2 : PopFlushPolicy;
247  if ((FlushPolicy & 1))
248  {
249  /* Registry flush requested, so open it */
250  DPRINT("Opening registry\n");
252  &RegistryName,
254  NULL,
255  NULL);
256  Status = ZwOpenKey(&RegistryHandle, KEY_READ, &ObjectAttributes);
257  if (NT_SUCCESS(Status))
258  {
259  /* Flush the registry */
260  DPRINT("Flushing registry\n");
261  ZwFlushKey(RegistryHandle);
262  ZwClose(RegistryHandle);
263  }
264  }
265 
266  /* Serialize with other flushes */
268 
269  /* Scan the volume list */
270  NextEntry = PopVolumeDevices.Flink;
271  while (NextEntry != &PopVolumeDevices)
272  {
273  /* Get the dope from the link */
275 
276  /* Grab the next entry now, since we'll be modifying the list */
277  NextEntry = NextEntry->Flink;
278 
279  /* Make sure the object is mounted, writable, exists, and is not a floppy */
280  if (!(Dope->DeviceObject->Vpb->Flags & VPB_MOUNTED) ||
281  (Dope->DeviceObject->Characteristics & FILE_FLOPPY_DISKETTE) ||
282  (Dope->DeviceObject->Characteristics & FILE_READ_ONLY_DEVICE) ||
283  ((Dope->DeviceObject->Vpb->RealDevice) &&
284  (Dope->DeviceObject->Vpb->RealDevice->Characteristics & FILE_FLOPPY_DISKETTE)))
285  {
286  /* Not flushable */
287  continue;
288  }
289 
290  /* Remove it from the dope and add it to the flush context list */
291  RemoveEntryList(&Dope->Volume);
292  InsertTailList(&FlushContext.List, &Dope->Volume);
293 
294  /* Next */
295  VolumeCount++;
296  }
297 
298  /* Check if we should skip non-removable devices */
299  if (!(FlushPolicy & 2))
300  {
301  /* ReactOS only implements this routine for shutdown, which requires it */
303  }
304 
305  /* Check if there were no volumes at all */
306  if (!VolumeCount)
307  {
308  /* Nothing to do */
310  return;
311  }
312 
313  /* Allocate up to 8 flusher threads */
314  ThreadCount = min(VolumeCount, 8);
316  NULL,
318  NULL,
319  NULL);
320 
321  /* We will ourselves become a flusher thread */
322  FlushContext.Count = 1;
323  ThreadCount--;
324 
325  /* Look for any extra ones we might need */
326  while (ThreadCount > 0)
327  {
328  /* Create a new one */
329  ThreadCount--;
330  DPRINT("Creating flush thread\n");
331  Status = PsCreateSystemThread(&ThreadHandle,
334  0L,
335  NULL,
337  &FlushContext);
338  if (NT_SUCCESS(Status))
339  {
340  /* One more created... */
341  FlushContext.Count++;
342  ZwClose(ThreadHandle);
343  }
344  }
345 
346  /* Allow flushes to go through */
348 
349  /* Enter the flush work */
350  DPRINT("Local flush\n");
351  PopFlushVolumeWorker(&FlushContext);
352 
353  /* Wait for all flushes to be over */
354  DPRINT("Waiting for flushes\n");
356  DPRINT("Flushes have completed\n");
357 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
KGUARDED_MUTEX PopVolumeLock
Definition: povolume.c:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define L(x)
Definition: ntvdm.h:50
LIST_ENTRY PopVolumeDevices
Definition: povolume.c:27
#define FALSE
Definition: types.h:117
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY List
Definition: povolume.c:19
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: typedefs.h:119
ULONG PopFlushPolicy
Definition: povolume.c:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
PDEVICE_OBJECT DeviceObject
Definition: po.h:249
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define VPB_MOUNTED
Definition: iotypes.h:1807
#define FILE_READ_ONLY_DEVICE
Definition: nt_native.h:808
VOID NTAPI PopFlushVolumeWorker(IN PVOID Context)
Definition: povolume.c:148
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by NtSetSystemPowerState().

◆ PopGracefulShutdown()

VOID NTAPI PopGracefulShutdown ( IN PVOID  Context)

Definition at line 247 of file poshtdwn.c.

248 {
250 
251  /* Process the registered waits and work items */
253 
254  /* Loop every process */
256  while (Process)
257  {
258  /* Make sure this isn't the idle or initial process */
260  {
261  /* Print it */
262  DPRINT1("%15s is still RUNNING (%p)\n", Process->ImageFileName, Process->UniqueProcessId);
263  }
264 
265  /* Get the next process */
267  }
268 
269  /* First, the HAL handles any "end of boot" special functionality */
270  DPRINT("HAL shutting down\n");
271  HalEndOfBoot();
272 
273  /* Shut down the Shim cache if enabled */
275 
276  /* In this step, the I/O manager does first-chance shutdown notification */
277  DPRINT("I/O manager shutting down in phase 0\n");
278  IoShutdownSystem(0);
279 
280  /* In this step, all workers are killed and hives are flushed */
281  DPRINT("Configuration Manager shutting down\n");
283 
284  /* Shut down the Executive */
285  DPRINT("Executive shutting down\n");
287 
288  /* Note that modified pages should be written here (MiShutdownSystem) */
289  MmShutdownSystem(0);
290 
291  /* Flush all user files before we start shutting down IO */
292  /* This is where modified pages are written back by the IO manager */
294 
295  /* In this step, the I/O manager does last-chance shutdown notification */
296  DPRINT("I/O manager shutting down in phase 1\n");
297  IoShutdownSystem(1);
299 
300  /* FIXME: Calling Mm shutdown phase 1 here to get page file dereference
301  * but it shouldn't be called here. Only phase 2 should be called.
302  */
303  MmShutdownSystem(1);
304 
305  /* Note that here, we should broadcast the power IRP to devices */
306 
307  /* In this step, the HAL disables any wake timers */
308  DPRINT("Disabling wake timers\n");
310 
311  /* And finally the power request is sent */
312  DPRINT("Taking the system down\n");
314 }
VOID NTAPI IoShutdownSystem(IN ULONG Phase)
Definition: device.c:133
POWER_ACTION Action
Definition: po.h:216
VOID MmShutdownSystem(IN ULONG Phase)
Definition: shutdown.c:77
#define HalSetWakeEnable
Definition: halfuncs.h:39
PEPROCESS PsIdleProcess
Definition: psmgr.c:51
#define FALSE
Definition: types.h:117
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
VOID NTAPI PopShutdownSystem(IN POWER_ACTION SystemAction)
Definition: poshtdwn.c:192
#define HalEndOfBoot
Definition: haltypes.h:307
NTSTATUS NTAPI CcWaitForCurrentLazyWriterActivity(VOID)
Definition: lazyrite.c:30
VOID NTAPI CcShutdownSystem(VOID)
Definition: cachesub.c:299
VOID NTAPI CmShutdownSystem(VOID)
Definition: cmsysini.c:2039
POP_POWER_ACTION PopAction
Definition: power.c:27
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
VOID NTAPI PopProcessShutDownLists(VOID)
Definition: poshtdwn.c:103
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI ExShutdownSystem(VOID)
Definition: shutdown.c:21
#define DPRINT
Definition: sndvol32.h:71
VOID NTAPI ApphelpCacheShutdown(VOID)
Definition: apphelp.c:465

Referenced by NtSetSystemPowerState().

◆ PopInitShutdownList()

VOID NTAPI PopInitShutdownList ( VOID  )

Definition at line 35 of file poshtdwn.c.

36 {
37  PAGED_CODE();
38 
39  /* Initialize the global shutdown event */
41 
42  /* Initialize the shutdown lists */
45 
46  /* Initialize the shutdown list lock */
48 
49  /* The list is available now */
51 }
#define TRUE
Definition: types.h:120
LIST_ENTRY PopShutdownQueue
Definition: poshtdwn.c:26
#define FALSE
Definition: types.h:117
BOOLEAN PopShutdownListAvailable
Definition: poshtdwn.c:28
KEVENT PopShutdownEvent
Definition: poshtdwn.c:24
PPOP_SHUTDOWN_WAIT_ENTRY PopShutdownThreadList
Definition: poshtdwn.c:25
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
KGUARDED_MUTEX PopShutdownListMutex
Definition: poshtdwn.c:27
#define PAGED_CODE()

Referenced by PoInitSystem().

◆ PopReadShutdownPolicy()

VOID NTAPI PopReadShutdownPolicy ( VOID  )

Definition at line 318 of file poshtdwn.c.

319 {
320  UNICODE_STRING KeyString;
324  ULONG Length;
325  UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
327 
328  /* Setup object attributes */
329  RtlInitUnicodeString(&KeyString,
330  L"\\Registry\\Machine\\Software\\Policies\\Microsoft\\Windows NT");
332  &KeyString,
334  NULL,
335  NULL);
336 
337  /* Open the key */
338  Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
339  if (NT_SUCCESS(Status))
340  {
341  /* Open the policy value and query it */
342  RtlInitUnicodeString(&KeyString, L"DontPowerOffAfterShutdown");
343  Status = ZwQueryValueKey(KeyHandle,
344  &KeyString,
346  &Info,
347  sizeof(Info),
348  &Length);
349  if ((NT_SUCCESS(Status)) && (Info->Type == REG_DWORD))
350  {
351  /* Read the policy */
352  PopShutdownPowerOffPolicy = *Info->Data == 1;
353  }
354 
355  /* Close the key */
357  }
358 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG PopShutdownPowerOffPolicy
Definition: poshtdwn.c:23
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define L(x)
Definition: ntvdm.h:50
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by NtSetSystemPowerState().

◆ PopSetSystemPowerState()

NTSTATUS NTAPI PopSetSystemPowerState ( SYSTEM_POWER_STATE  PowerState,
POWER_ACTION  PowerAction 
)

Definition at line 332 of file power.c.

333 {
338  POWER_STATE_TRAVERSE_CONTEXT PowerContext;
339 
341  if (!NT_SUCCESS(Status))
342  {
343  DPRINT1("No system power driver available\n");
344  Fdo = NULL;
345  }
346  else
347  {
349  if (Fdo == DeviceObject)
350  {
351  DPRINT("An FDO was not attached\n");
352  return STATUS_UNSUCCESSFUL;
353  }
354  }
355 
356  /* Set up context */
357  PowerContext.PowerAction = PowerAction;
358  PowerContext.SystemPowerState = PowerState;
359  PowerContext.PowerDevice = Fdo;
360 
361  /* Query for system power change */
365  &PowerContext);
366 
368  if (!NT_SUCCESS(Status))
369  {
370  DPRINT1("Query system power state failed; changing state anyway\n");
371  }
372 
373  /* Set system power change */
377  &PowerContext);
378 
380 
382 
383  if (Fdo != NULL)
384  {
385  if (PowerAction != PowerActionShutdownReset)
387 
389  }
390 
391  return Status;
392 }
NTSTATUS PopQuerySystemPowerStateTraverse(PDEVICE_NODE DeviceNode, PVOID Context)
Definition: power.c:254
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
NTSTATUS IopTraverseDeviceTree(PDEVICETREE_TRAVERSE_CONTEXT Context)
LONG NTSTATUS
Definition: precomp.h:26
POWER_ACTION PowerAction
Definition: power.c:21
BOOLEAN PopAcpiPresent
Definition: power.c:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
NTSTATUS IopGetSystemPowerDeviceObject(IN PDEVICE_OBJECT *DeviceObject)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
NTSTATUS PopSendSetSystemPowerState(PDEVICE_OBJECT DeviceObject, SYSTEM_POWER_STATE SystemState, POWER_ACTION PowerAction)
Definition: power.c:212
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3032
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
struct tagContext Context
Definition: acpixf.h:1034
#define IopInitDeviceTreeTraverseContext( _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context)
Definition: io.h:229
#define DPRINT
Definition: sndvol32.h:71
PDEVICE_OBJECT PowerDevice
Definition: power.c:22
SYSTEM_POWER_STATE SystemPowerState
Definition: power.c:20
NTSTATUS PopSetSystemPowerStateTraverse(PDEVICE_NODE DeviceNode, PVOID Context)
Definition: power.c:288

Referenced by PopShutdownSystem().

◆ PoRemoveVolumeDevice()

VOID NTAPI PoRemoveVolumeDevice ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 103 of file povolume.c.

104 {
106  PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
107  KIRQL OldIrql;
108  PAGED_CODE();
109 
110  /* If the device already has the dope, return it */
111  DeviceExtension = IoGetDevObjExtension(DeviceObject);
112  if (!DeviceExtension->Dope)
113  {
114  /* no dope */
115  return;
116  }
117 
118  /* Make sure we can flush safely */
120 
121  /* Get dope from device */
122  Dope = (PDEVICE_OBJECT_POWER_EXTENSION)DeviceExtension->Dope;
123 
124  if (Dope->Volume.Flink)
125  {
126  /* Remove from volume from list */
127  RemoveEntryList(&Dope->Volume);
128  }
129 
130  /* Allow flushes to go through */
132 
133  /* Now remove dope from device object */
135 
136  /* remove from dev obj */
137  DeviceExtension->Dope = NULL;
138 
139  /* Release lock */
141 
142  /* Free dope */
144 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
if(dx==0 &&dy==0)
Definition: linetemp.h:174
KGUARDED_MUTEX PopVolumeLock
Definition: povolume.c:26
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _DEVICE_OBJECT_POWER_EXTENSION * Dope
Definition: iotypes.h:933
#define TAG_PO_DOPE
Definition: tag.h:126
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
struct _DEVICE_OBJECT_POWER_EXTENSION * PDEVICE_OBJECT_POWER_EXTENSION
KSPIN_LOCK PopDopeGlobalLock
Definition: povolume.c:28
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
#define IoGetDevObjExtension(DeviceObject)
Definition: io.h:129
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define PAGED_CODE()

Referenced by IoDeleteDevice().

◆ PoVolumeDevice()

VOID NTAPI PoVolumeDevice ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 81 of file povolume.c.

82 {
84  PAGED_CODE();
85 
86  /* Get dope from the device (if the device has no dope, it will receive some) */
87  Dope = PopGetDope(DeviceObject);
88  if (Dope)
89  {
90  /* Make sure we can flush safely */
92 
93  /* Add this volume into the list of power-manager volumes */
94  if (!Dope->Volume.Flink) InsertTailList(&PopVolumeDevices, &Dope->Volume);
95 
96  /* Allow flushes to go through */
98  }
99 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define InsertTailList(ListHead, Entry)
KGUARDED_MUTEX PopVolumeLock
Definition: povolume.c:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
LIST_ENTRY PopVolumeDevices
Definition: povolume.c:27
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
PDEVICE_OBJECT_POWER_EXTENSION NTAPI PopGetDope(IN PDEVICE_OBJECT DeviceObject)
Definition: povolume.c:34
#define PAGED_CODE()

Referenced by IoCreateDevice(), and IoVerifyVolume().

Variable Documentation

◆ PopAction

POP_POWER_ACTION PopAction

Definition at line 27 of file power.c.

Referenced by NtSetSystemPowerState(), and PopGracefulShutdown().

◆ PopCapabilities

SYSTEM_POWER_CAPABILITIES PopCapabilities

Definition at line 29 of file power.c.

Referenced by NtPowerInformation(), PoInitSystem(), and PopAddRemoveSysCapsCallback().

◆ PopDopeGlobalLock

KSPIN_LOCK PopDopeGlobalLock

Definition at line 28 of file povolume.c.

Referenced by PoInitSystem(), PopGetDope(), and PoRemoveVolumeDevice().

◆ PopSystemPowerDeviceNode

PDEVICE_NODE PopSystemPowerDeviceNode

Definition at line 25 of file power.c.

Referenced by IopGetSystemPowerDeviceObject(), and PiCallDriverAddDevice().

◆ PopVolumeDevices

LIST_ENTRY PopVolumeDevices

Definition at line 27 of file povolume.c.

Referenced by PoInitSystem(), PopFlushVolumes(), PopFlushVolumeWorker(), and PoVolumeDevice().

◆ PopVolumeLock