ReactOS  0.4.15-dev-1377-ga59cecd
pnppower.c File Reference
#include "ntddk.h"
#include "wdfcore.h"
#include "cdrom.h"
#include "ioctl.h"
#include "scratch.h"
#include "mmc.h"
Include dependency graph for pnppower.c:

Go to the source code of this file.

Functions

NTSTATUS DeviceScratchSyncCache (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS DeviceScratchPreventMediaRemoval (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN Prevent)
 
NTSTATUS RequestIssueShutdownFlush (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
 
NTSTATUS NTAPI RequestProcessShutdownFlush (WDFDEVICE Device, PIRP Irp)
 
NTSTATUS NTAPI RequestProcessSetPower (WDFDEVICE Device, PIRP Irp)
 
VOID NTAPI RequestUnlockQueueCompletion (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
NTSTATUS NTAPI RequestProcessPowerIrpCompletion (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_reads_opt_(_Inexpressible_("varies")) PVOID Context)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL)
 
 _Function_class_ (POWER_SETTING_CALLBACK)
 

Variables

IO_COMPLETION_ROUTINE RequestProcessPowerIrpCompletion
 
EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestUnlockQueueCompletion
 

Function Documentation

◆ _Function_class_()

_Function_class_ ( POWER_SETTING_CALLBACK  )

Definition at line 609 of file pnppower.c.

642 {
643  PCDROM_DEVICE_EXTENSION DeviceExtension = Context;
644  MONITOR_DISPLAY_STATE DisplayState;
645 
646  PAGED_CODE();
647 
648  if (IsEqualGUID(SettingGuid, &GUID_CONSOLE_DISPLAY_STATE)) {
649 
650  if ((ValueLength == sizeof(ULONG)) && (Value != NULL)) {
651 
652  DisplayState = *((PULONG)Value);
653 
654  _Analysis_assume_(DeviceExtension != NULL);
655 
656  //
657  // Power setting callbacks are asynchronous so make sure the device
658  // is completely initialized before taking any actions.
659  //
660  if (DeviceExtension->IsInitialized) {
661 
662  //
663  // If monitor is off, change media change requests to not keep device active.
664  // This allows the devices to go to sleep if there are no other active requests.
665  //
666 
667  if (DisplayState == PowerMonitorOff) {
668 
669  //
670  // Mark the device inactive so that it can enter a low power state.
671  //
672 
673  DeviceMarkActive(DeviceExtension, FALSE, TRUE);
675  }
676  else
677  {
679  DeviceMarkActive(DeviceExtension, TRUE, TRUE);
680  }
681  }
682  }
683  }
684 
685  return STATUS_SUCCESS;
686 }
BOOLEAN IsInitialized
Definition: cdrom.h:464
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CLEAR_FLAG(Flags, Bit)
Definition: cdrom.h:1494
_In_ LPCGUID SettingGuid
Definition: pofuncs.h:120
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define SRB_FLAGS_NO_KEEP_AWAKE
Definition: srb.h:404
enum _MONITOR_DISPLAY_STATE MONITOR_DISPLAY_STATE
#define _Analysis_assume_
Definition: no_sal2.h:388
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo
Definition: cdrom.h:563
#define STATUS_SUCCESS
Definition: shellext.h:65
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
#define PAGED_CODE()
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:271

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 465 of file pnppower.c.

485 {
487  WDF_REQUEST_REUSE_PARAMS reuseParams;
488  PIRP irp = NULL;
489 
490  RtlZeroMemory(&(DeviceExtension->PowerContext.SenseData), sizeof(DeviceExtension->PowerContext.SenseData));
491  RtlZeroMemory(&(DeviceExtension->PowerContext.Srb), sizeof(DeviceExtension->PowerContext.Srb));
492 
493  irp = WdfRequestWdmGetIrp(DeviceExtension->PowerContext.PowerRequest);
494 
495  // Re-use the previously created PowerRequest object and format it
497  status = WdfRequestReuse(DeviceExtension->PowerContext.PowerRequest, &reuseParams);
498  if (NT_SUCCESS(status))
499  {
500  // This request was preformated during initialization so this call should never fail.
501  status = WdfIoTargetFormatRequestForInternalIoctlOthers(DeviceExtension->IoTarget,
502  DeviceExtension->PowerContext.PowerRequest,
504  NULL, NULL,
505  NULL, NULL,
506  NULL, NULL);
507 
508  if (!NT_SUCCESS(status))
509  {
510  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,
511  "PowerContextReuseRequest: WdfIoTargetFormatRequestForInternalIoctlOthers failed, %!STATUS!\n",
512  status));
513  }
514  }
515 
516  // Do some basic initialization of the PowerRequest, the rest will be done by the caller
517  // of this function
518  if (NT_SUCCESS(status))
519  {
520  PIO_STACK_LOCATION nextStack = NULL;
521 
522  nextStack = IoGetNextIrpStackLocation(irp);
523 
524  nextStack->MajorFunction = IRP_MJ_SCSI;
525  nextStack->Parameters.Scsi.Srb = &(DeviceExtension->PowerContext.Srb);
526 
527  DeviceExtension->PowerContext.Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
528  DeviceExtension->PowerContext.Srb.OriginalRequest = irp;
529 
530  DeviceExtension->PowerContext.Srb.SenseInfoBuffer = &(DeviceExtension->PowerContext.SenseData);
531  DeviceExtension->PowerContext.Srb.SenseInfoBufferLength = SENSE_BUFFER_SIZE;
532  }
533 
534  return status;
535 }
return STATUS_NOT_SUPPORTED
LONG NTSTATUS
Definition: precomp.h:26
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
#define IRP_MJ_SCSI
FORCEINLINE VOID WDF_REQUEST_REUSE_PARAMS_INIT(_Out_ PWDF_REQUEST_REUSE_PARAMS Params, _In_ ULONG Flags, _In_ NTSTATUS Status)
Definition: wdfrequest.h:364
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
#define IOCTL_SCSI_EXECUTE_IN
Definition: cdrw_hw.h:1451
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
Definition: ps.c:97

◆ DeviceScratchPreventMediaRemoval()

NTSTATUS DeviceScratchPreventMediaRemoval ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ BOOLEAN  Prevent 
)

Definition at line 259 of file pnppower.c.

279 {
281  ULONG transferSize = 0;
282  CDB cdb;
283 
284  ScratchBuffer_BeginUse(DeviceExtension);
285 
286  RtlZeroMemory(&cdb, sizeof(CDB));
287  // Set up the CDB
288  cdb.MEDIA_REMOVAL.OperationCode = SCSIOP_MEDIUM_REMOVAL;
289  cdb.MEDIA_REMOVAL.Prevent = Prevent;
290  //srb->QueueTag = SP_UNTAGGED;
291  //srb->QueueAction = SRB_SIMPLE_TAG_REQUEST;
292 
293  status = ScratchBuffer_ExecuteCdb(DeviceExtension, NULL, transferSize, FALSE, &cdb, 6);
294 
295  ScratchBuffer_EndUse(DeviceExtension);
296 
297  return status;
298 }
struct _CDB::_MEDIA_REMOVAL MEDIA_REMOVAL
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
__inline VOID ScratchBuffer_EndUse(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension)
Definition: scratch.h:104
#define ScratchBuffer_BeginUse(context)
Definition: scratch.h:87
#define FALSE
Definition: types.h:117
#define SCSIOP_MEDIUM_REMOVAL
Definition: cdrw_hw.h:902
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestProcessShutdownFlush().

◆ DeviceScratchSyncCache()

NTSTATUS DeviceScratchSyncCache ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension)

Definition at line 220 of file pnppower.c.

238 {
240  ULONG transferSize = 0;
241  CDB cdb;
242 
243  ScratchBuffer_BeginUse(DeviceExtension);
244 
245  RtlZeroMemory(&cdb, sizeof(CDB));
246  // Set up the CDB
247  cdb.SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
248  //srb->QueueTag = SP_UNTAGGED;
249  //srb->QueueAction = SRB_SIMPLE_TAG_REQUEST;
250 
251  status = ScratchBuffer_ExecuteCdbEx(DeviceExtension, NULL, transferSize, FALSE, &cdb, 10, TimeOutValueGetCapValue(DeviceExtension->TimeOutValue, 4));
252 
253  ScratchBuffer_EndUse(DeviceExtension);
254 
255  return status;
256 }
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
__inline VOID ScratchBuffer_EndUse(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension)
Definition: scratch.h:104
#define ScratchBuffer_BeginUse(context)
Definition: scratch.h:87
#define FALSE
Definition: types.h:117
__inline ULONG TimeOutValueGetCapValue(_In_ ULONG TimeOutValue, _In_ ULONG Times)
Definition: cdrom.h:1569
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestProcessShutdownFlush().

◆ RequestIssueShutdownFlush()

NTSTATUS RequestIssueShutdownFlush ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ PIRP  Irp 
)

Definition at line 301 of file pnppower.c.

321 {
323  PSCSI_REQUEST_BLOCK srb = DeviceExtension->ScratchContext.ScratchSrb;
324  PIO_STACK_LOCATION currentStack = NULL;
325 
326  ULONG transferSize = 0;
327  BOOLEAN shouldRetry = TRUE;
328  ULONG timesAlreadyRetried = 0;
329  LONGLONG retryIn100nsUnits = 0;
330 
331 
332  currentStack = IoGetCurrentIrpStackLocation(Irp);
333 
334 
335  ScratchBuffer_BeginUse(DeviceExtension);
336 
337  // no retry needed.
338  {
339  ScratchBuffer_SetupSrb(DeviceExtension, NULL, transferSize, FALSE);
340 
341  // Set up the SRB/CDB
342  srb->QueueTag = SP_UNTAGGED;
344  srb->TimeOutValue = TimeOutValueGetCapValue(DeviceExtension->TimeOutValue, 4);
345  srb->CdbLength = 0;
346 
347  if (currentStack->MajorFunction == IRP_MJ_SHUTDOWN)
348  {
350  }
351  else
352  {
354  }
355 
356  ScratchBuffer_SendSrb(DeviceExtension, TRUE, NULL);
357 
358  shouldRetry = RequestSenseInfoInterpretForScratchBuffer(DeviceExtension,
359  timesAlreadyRetried,
360  &status,
361  &retryIn100nsUnits);
362  UNREFERENCED_PARAMETER(shouldRetry); //defensive coding, avoid PREFAST warning.
363  UNREFERENCED_PARAMETER(status); //defensive coding, avoid PREFAST warning.
364 
365  // retrieve the real status from the request.
366  status = WdfRequestGetStatus(DeviceExtension->ScratchContext.ScratchRequest);
367  }
368 
369  ScratchBuffer_EndUse(DeviceExtension);
370 
371 
372  return status;
373 }
#define IRP_MJ_SHUTDOWN
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
UCHAR CdbLength
Definition: srb.h:250
__inline VOID ScratchBuffer_EndUse(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension)
Definition: scratch.h:104
UCHAR QueueAction
Definition: srb.h:249
ULONG TimeOutValue
Definition: srb.h:254
#define SP_UNTAGGED
Definition: srb.h:225
#define ScratchBuffer_BeginUse(context)
Definition: scratch.h:87
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
unsigned char BOOLEAN
UCHAR QueueTag
Definition: srb.h:248
__inline ULONG TimeOutValueGetCapValue(_In_ ULONG TimeOutValue, _In_ ULONG Times)
Definition: cdrom.h:1569
#define SRB_FUNCTION_FLUSH
Definition: srb.h:315
int64_t LONGLONG
Definition: typedefs.h:68
UCHAR Function
Definition: srb.h:242
BOOLEAN RequestSenseInfoInterpretForScratchBuffer(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2564
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define SRB_FUNCTION_SHUTDOWN
Definition: srb.h:314
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
NTSTATUS ScratchBuffer_SendSrb(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN SynchronousSrb, _When_(SynchronousSrb, _Pre_null_) _When_(!SynchronousSrb, _In_opt_) PSRB_HISTORY_ITEM *SrbHistoryItem)
Definition: scratch.c:906
Definition: ps.c:97

Referenced by RequestProcessShutdownFlush().

◆ RequestProcessPowerIrpCompletion()

NTSTATUS NTAPI RequestProcessPowerIrpCompletion ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_reads_opt_(_Inexpressible_("varies")) PVOID  Context 
)

Definition at line 401 of file pnppower.c.

424 {
425  PCDROM_DEVICE_EXTENSION deviceExtension = Context;
426  PIO_STACK_LOCATION currentStack;
427 
429 
430  if (Irp->PendingReturned)
431  {
433  }
434 
435  currentStack = IoGetCurrentIrpStackLocation(Irp);
436 
437  NT_ASSERT(currentStack->Parameters.Power.Type == DevicePowerState);
438  NT_ASSERT(currentStack->Parameters.Power.State.DeviceState != PowerDeviceD0);
439 
440  _Analysis_assume_(deviceExtension != NULL);
441 
442  deviceExtension->PowerContext.PowerChangeState.PowerDown++;
443 
444  // Step 5. UNLOCK QUEUE
445  if (deviceExtension->PowerContext.Options.LockQueue)
446  {
447  (VOID)DeviceSendPowerDownProcessRequest(deviceExtension,
449  Irp);
450 
451  // Let the completion routine complete the Irp
453  }
454 
455  // Release the power context if it wasn't already done as part of D0Exit handling
456  if (deviceExtension->PowerContext.InUse)
457  {
458  PowerContextEndUse(deviceExtension);
459  }
460 
462 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_CONTINUE_COMPLETION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
union _CDROM_POWER_CONTEXT::@1027 PowerChangeState
_In_ PIRP Irp
Definition: csq.h:116
#define VOID
Definition: acefi.h:82
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
CDROM_POWER_DOWN_STATE PowerDown
Definition: cdrom.h:438
#define _Analysis_assume_
Definition: no_sal2.h:388
#define NULL
Definition: types.h:112
EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestUnlockQueueCompletion
Definition: pnppower.c:59
CDROM_POWER_OPTIONS Options
Definition: cdrom.h:442
struct tagContext Context
Definition: acpixf.h:1034
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
IoMarkIrpPending(Irp)
CDROM_POWER_CONTEXT PowerContext
Definition: cdrom.h:586
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ RequestProcessSetPower()

NTSTATUS NTAPI RequestProcessSetPower ( WDFDEVICE  Device,
PIRP  Irp 
)

Definition at line 149 of file pnppower.c.

169 {
170  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
171  PIO_STACK_LOCATION currentStack;
173  BOOLEAN IrpMarkedPending = FALSE;
174 
175  currentStack = IoGetCurrentIrpStackLocation(Irp);
176 
177  if ((currentStack->Parameters.Power.Type == DevicePowerState) &&
178  (currentStack->Parameters.Power.State.DeviceState != PowerDeviceD0))
179  {
180  // We need to unlock the device queue in D3 postprocessing.
184  deviceExtension,
185  TRUE,
186  TRUE,
187  TRUE);
188 
189  // Mark the Irp pending as we'll defer the I/O completion.
191  IrpMarkedPending = TRUE;
192  }
193  else {
194 
196  }
197 
198 #pragma warning(push)
199 #pragma warning(disable: 28193) // OACR will complain that the status variable is not examined.
200 
201  //
202  // Deliver the IRP back to the framework.
203  //
204 
205  status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
206 
207  if (IrpMarkedPending)
208  {
210  return STATUS_PENDING;
211  }
212 
213 #pragma warning(pop)
214 
215  return status;
216 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
unsigned char BOOLEAN
#define STATUS_PENDING
Definition: ntstatus.h:82
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
IO_COMPLETION_ROUTINE RequestProcessPowerIrpCompletion
Definition: pnppower.c:57
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
IoMarkIrpPending(Irp)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ RequestProcessShutdownFlush()

NTSTATUS NTAPI RequestProcessShutdownFlush ( WDFDEVICE  Device,
PIRP  Irp 
)

Definition at line 76 of file pnppower.c.

96 {
98  PIO_STACK_LOCATION currentStack = NULL;
99  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
100 
101  //add trace info
102 
103  // acquire the shutdown/flush lock
104  WdfWaitLockAcquire(deviceExtension->ShutdownFlushWaitLock, NULL);
105 
106  currentStack = IoGetCurrentIrpStackLocation(Irp);
107 
108  // finish all current requests
109  WdfIoQueueStopSynchronously(deviceExtension->SerialIOQueue);
110 
111  // sync cache
112  if (NT_SUCCESS(status))
113  {
114  // safe to use scratch srb to send the request.
115  status = DeviceScratchSyncCache(deviceExtension);
116  }
117 
118  // For SHUTDOWN, allow media removal.
119  if (NT_SUCCESS(status))
120  {
121  if (currentStack->MajorFunction == IRP_MJ_SHUTDOWN)
122  {
123  // safe to use scratch srb to send the request.
124  status = DeviceScratchPreventMediaRemoval(deviceExtension, FALSE);
125  }
126  }
127 
128  // Use original IRP, send SRB_FUNCTION_SHUTDOWN or SRB_FUNCTION_FLUSH (no retry)
129  if (NT_SUCCESS(status))
130  {
131  status = RequestIssueShutdownFlush(deviceExtension, Irp);
132  }
133 
134  // restart queue to allow processing further requests.
135  WdfIoQueueStart(deviceExtension->SerialIOQueue);
136 
137  // release the shutdown/flush lock
138  WdfWaitLockRelease(deviceExtension->ShutdownFlushWaitLock);
139 
140  // 6. complete the irp
141  Irp->IoStatus.Status = status;
143 
144  return status;
145 }
#define IRP_MJ_SHUTDOWN
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS DeviceScratchSyncCache(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
Definition: pnppower.c:220
#define IoCompleteRequest
Definition: irp.c:1240
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
NTSTATUS DeviceScratchPreventMediaRemoval(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN Prevent)
Definition: pnppower.c:259
WDFWAITLOCK ShutdownFlushWaitLock
Definition: cdrom.h:595
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
WDFQUEUE SerialIOQueue
Definition: cdrom.h:479
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
NTSTATUS RequestIssueShutdownFlush(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
Definition: pnppower.c:301
_Must_inspect_result_ FORCEINLINE NTSTATUS WdfWaitLockAcquire(_In_ _Requires_lock_not_held_(_Curr_) WDFWAITLOCK Lock, _In_opt_ PLONGLONG Timeout)
Definition: wdfsync.h:173
Definition: ps.c:97

◆ RequestUnlockQueueCompletion()

VOID NTAPI RequestUnlockQueueCompletion ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)

Definition at line 377 of file pnppower.c.

383 {
384  PIRP Irp = Context;
385  WDFDEVICE device = WdfIoTargetGetDevice(Target);
386  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(device);
387 
390 
391  deviceExtension->PowerContext.Options.LockQueue = FALSE;
392 
393  PowerContextEndUse(deviceExtension);
394 
395  // Complete the original power irp
397 }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
Definition: devices.h:37
#define IoCompleteRequest
Definition: irp.c:1240
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
CDROM_POWER_OPTIONS Options
Definition: cdrom.h:442
struct tagContext Context
Definition: acpixf.h:1034
#define IO_NO_INCREMENT
Definition: iotypes.h:581
CDROM_POWER_CONTEXT PowerContext
Definition: cdrom.h:586

Variable Documentation

◆ RequestProcessPowerIrpCompletion

IO_COMPLETION_ROUTINE RequestProcessPowerIrpCompletion

Definition at line 57 of file pnppower.c.

Referenced by RequestProcessSetPower().

◆ RequestUnlockQueueCompletion

EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestUnlockQueueCompletion

Definition at line 59 of file pnppower.c.

Referenced by RequestProcessPowerIrpCompletion().