29#if defined(EVENT_TRACING)
30#include "FxIoQueue.tmh"
42 m_CallbackSpinLock(FxDriverGlobals),
43 m_CallbackMutexLock(FxDriverGlobals),
184 "Memory allocation failed: %!STATUS!",
status);
195 InitialPowerStateOn);
198 "Could not configure queue: %!STATUS!",
status);
254#if (FX_CORE_MODE==FX_CORE_USER_MODE)
278 "Invalid dispatch type "
279 "specified %d, Queue 0x%p %!STATUS!",
280 pConfig->DispatchType,
291 (pConfig->EvtIoDefault ==
NULL)) {
293 if ((pConfig->EvtIoDefault ==
NULL) &&
294 (pConfig->EvtIoRead ==
NULL) &&
295 (pConfig->EvtIoWrite ==
NULL) &&
296 (pConfig->EvtIoDeviceControl ==
NULL) &&
297 (pConfig->EvtIoInternalDeviceControl ==
NULL)) {
300 "At least one of EvtIoDefault|EvtIoRead|EvtIoWrite|"
301 "EvtIoDeviceControl|EvtIoInternalDeviceControl "
313 if ((pConfig->EvtIoDefault !=
NULL) ||
314 (pConfig->EvtIoRead !=
NULL) ||
315 (pConfig->EvtIoWrite !=
NULL) ||
316 (pConfig->EvtIoDeviceControl !=
NULL) ||
317 (pConfig->EvtIoInternalDeviceControl !=
NULL)) {
320 "Cannot set io callback events "
321 "on a manual WDFQUEUE 0x%p %!STATUS!",
335 if (pConfig->Settings.Parallel.NumberOfPresentedRequests != 0 &&
340 "Cannot have NumberOfPresentedRequests other "
341 "than 0 on a Sequential or manual WDFQUEUE 0x%p."
342 "Make Sure you set NumberOfPresentedRequests"
352 pConfig->Settings.Parallel.NumberOfPresentedRequests;
368 "Could not allocate workitem: %!STATUS!",
Status);
373 m_Type = pConfig->DispatchType;
375 switch(pConfig->PowerManaged) {
393 ASSERTMSG(
"Invalid value in WDF_IO_QUEUE_CONFIG PowerManaged field\n",
FALSE);
409 if (InitialPowerStateOn) {
422 "EvtIoDefault 0x%p, EvtIoRead 0x%p, EvtIoWrite 0x%p, "
423 "EvtIoDeviceControl 0x%p for WDFQUEUE 0x%p",
424 pConfig->EvtIoDefault,
509 DispatchEvents(
irql);
517 "waiting for the queue to be deleted, WDFQUEUE",
GetHandle(),
595 BOOLEAN AutomaticLockingRequired;
597 AutomaticLockingRequired =
FALSE;
674 "WDFQUEUE 0x%p Synchronization scope is set to "
675 "device; WDF extension drivers are not allowed "
676 "to use this type of synchronization, %!STATUS!",
691 "WDFQUEUE 0x%p Synchronization scope is set to device"
692 " but the Device ExecutionLevel: 0x%x"
693 " doesn't match Queue ExecutionLevel: 0x%x, %!STATUS!",
702 AutomaticLockingRequired =
TRUE;
713 AutomaticLockingRequired =
TRUE;
719 if (AutomaticLockingRequired) {
824 if ((
int)NewStatus & ~AllowedBits) {
826 "Invalid WDFQUEUE 0x%p state",
853 "WDFQUEUE 0x%p is shut down, preventing queue "
854 "from accepting requests",
899 if (FxDriverGlobals->IsVersionGreaterThanOrEqualTo(1,11)) {
904 "WdfIoQueueRetrieveFoundRequest is allowed "
905 "only on a manual queue 0x%p, %!STATUS!",
928 "Driver called WdfIoQueueRetrieveNextRequest on a sequential WDFQUEUE 0x%p with no "
929 "outstanding requests. This can cause a race with automatically dispatched "
930 "requests. Call WdfIoQueueRetrieveNextRequest before completing the current request(s)",
1005 "Cannot be called on a parallel WDFQUEUE 0x%p, %!STATUS!",
1019 "WDFQUEUE 0x%p is powered off, %!STATUS!",
1031 "WDFQUEUE 0x%p is stopped, %!STATUS!",
1037 #pragma warning(disable:4127)
1040 #pragma warning(default:4127)
1095 "Zero length WDFREQUEST 0x%p completed automatically by WDFQUEUE 0x%p",
1110 "Zero length WDFREQUEST 0x%p completed automatically by WDFQUEUE 0x%p",
1245 "FindRequest is allowed only on a manaul queue 0x%p, %!STATUS!",
1427 oldState =
Request->SetCompletionState(oldState);
1461 DispatchInternalEvents(
irql);
1485 if (m_Device->m_ParentDevice ==
NULL) {
1488 "No parent device for WDFQUEUE 0x%p Device, %!STATUS!",
1496 status =
Request->VerifyRequestIsDriverOwned(FxDriverGlobals);
1499 status =
Request->VerifyRequestIsNotCancelable(FxDriverGlobals);
1511 "Cannot forward a request to the same WDFQUEUE 0x%p"
1520 "Cannot forward a request to "
1521 "a different WDFDEVICE 0x%p which is not the "
1522 "parent, %!STATUS!",
1532 "Cannot forward reserved WDFREQUEST 0x%p to a "
1533 "parent WDFDEVICE 0x%p, %!STATUS!",
1551 if (m_Device->IsPnp()
1553 m_Device->GetPdoPkg()->m_AllowForwardRequestToParent ==
FALSE) {
1556 "WdfPdoInitSetForwardRequestToParent not called on "
1557 "WDFDEVICE 0x%p, %!STATUS!", m_Device->GetHandle(),
1608 BOOLEAN forwardRequestToParent;
1615 forwardRequestToParent =
Request->m_ForwardRequestToParent;
1657 Request->m_ForwardRequestToParent = forwardRequestToParent;
1680 status =
pRequest->VerifyRequestIsNotCancelable(FxDriverGlobals);
1691 "Cannot forward a request to the same WDFQUEUE 0x%p"
1701 "Cannot forward a request to a different WDFDEVICE 0x%p",
1778 status =
Request->VerifyRequestIsNotCancelable(FxDriverGlobals);
1881 Request->SetDeviceBase(origDeviceBase);
1884 Request->SetVerifierFlags(oldFlags);
1895 Request->m_Irp.ClearNextStack();
1918 status =
pRequest->VerifyRequestIsNotCancelable(FxDriverGlobals);
1953 "Requeue is allowed only for "
1954 "a manual queue, WDFREQUEST 0x%p "
2039 DispatchEvents(
irql);
2070 status =
pRequest->VerifyRequestIsNotCancelable(FxDriverGlobals);
2170 else if (FailIfIrpIsCancelled ==
FALSE) {
2295 "WDFQUEUE 0x%p is not accepting requests, "
2296 "state is %!WDF_IO_QUEUE_STATE!, %s"
2297 "completing WDFREQUEST 0x%p %!STATUS!",
2300 "power stopping (Drain) in progress," :
"",
2319 "Queuing WDFREQUEST 0x%p on WDFQUEUE 0x%p",
2389 "WDFQUEUE 0x%p is not accepting requests "
2390 "state is %!WDF_IO_QUEUE_STATE!, %s"
2391 "WDFREQUEST 0x%p %!STATUS!",
2394 "power stopping (Drain) in progress," :
"",
2403 "Queuing WDFREQUEST 0x%p on WDFQUEUE 0x%p",
2468 DispatchEvents(
irql);
2500 DispatchEvents(
irql);
2545 DispatchEvents(
irql);
2609 (*Request)->CompleteWithInformation(
status, 0);
2616 (*Request)->SetCurrentQueue(
this);
2662 "Current thread 0x%p is not at the passive-level"
2663 " %!irql!, posting to worker thread for WDFQUEUE"
2696 "Presentation lock for WDFQUEUE 0x%p is "
2697 "already held, deferring to dpc or workitem",
2800 if (CanThreadDispatchEventsLocked(PreviousIrql) ==
FALSE) {
2809 m_RequeueDeferredDispatcher =
TRUE;
2814 InsertNewRequest(&NewRequest, PreviousIrql);
2827 "Thread %p is processing WDFQUEUE 0x%p",
2839 #pragma warning(disable:4127)
2841 #pragma warning(default:4127)
2846 totalIoCount = m_Queue.GetRequestCount() + m_DriverIoCount;
2851 totalIoCount += ((NewRequest !=
NULL) ? 1 : 0);
2854 status = InsertNewRequest(&NewRequest, PreviousIrql);
2864 if(ProcessCancelledRequests(&PreviousIrql)) {
2870 status = InsertNewRequest(&NewRequest, PreviousIrql);
2880 if (ProcessCancelledRequestsOnQueue(&PreviousIrql)) {
2885 if (m_IdleComplete.Method !=
NULL &&
2886 m_Dispatching == 1L &&
2887 m_DriverIoCount == 0
L) {
2889 InsertNewRequest(&NewRequest, PreviousIrql);
2892 m_CancelDispatchedRequests =
FALSE;
2895 ProcessIdleComplete(&PreviousIrql);
2899 if (m_PurgeComplete.Method !=
NULL &&
2900 totalIoCount == 0
L &&
2901 m_Dispatching == 1L) {
2903 InsertNewRequest(&NewRequest, PreviousIrql);
2906 m_CancelDispatchedRequests =
FALSE;
2909 ProcessPurgeComplete(&PreviousIrql);
2913 if (m_IsDevicePowerPolicyOwner &&
2915 m_PowerReferenced &&
2916 totalIoCount == 0
L &&
2917 m_Dispatching == 1L) {
2923 m_Device->m_PkgPnp->PowerDereference();
2924 m_PowerReferenced =
FALSE;
2935 "WDFQUEUE 0x%p Power Transition State "
2939 status = InsertNewRequest(&NewRequest, PreviousIrql);
2946 if (ProcessPowerEvents(&PreviousIrql)) {
2967 totalIoCount == 0
L &&
2968 m_Dispatching == 1L) {
2981 m_FinishDisposing.Set();
2991 status = InsertNewRequest(&NewRequest, PreviousIrql);
3005 "WDFQUEUE 0x%p not in dispatching state, "
3006 "current state is %!WDF_IO_QUEUE_STATE!",
3009 status = InsertNewRequest(&NewRequest, PreviousIrql);
3022 status = InsertNewRequest(&NewRequest, PreviousIrql);
3027 if (m_ReadyNotify.Method !=
NULL && m_TransitionFromEmpty) {
3030 ProcessReadyNotify(&PreviousIrql);
3038 status = InsertNewRequest(&NewRequest, PreviousIrql);
3051 (
ULONG)m_DriverIoCount >= m_MaxParallelQueuePresentedRequests) {
3052 status = InsertNewRequest(&NewRequest, PreviousIrql);
3064 if (m_Queue.GetRequestCount() > 0
L) {
3073 InsertNewRequest(&NewRequest, PreviousIrql);
3083 SetTransitionFromEmpty();
3100 Lock(&PreviousIrql);
3137 WDFREQUEST hRequest;
3151#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
3222 if ((readLength == 0) &&
3227 "Zero length WDFREQUEST 0x%p completed automatically "
3244 "Calling driver EvtIoRead for WDFREQUEST 0x%p",
3260 if ((writeLength == 0) &&
3265 "Zero length WDFREQUEST 0x%p completed automatically "
3283 "Calling driver EvtIoWrite for WDFREQUEST 0x%p",
3297 "Calling driver EvtIoDeviceControl for "
3298 "WDFREQUEST 0x%p", hRequest);
3315 "Calling driver EvtIoInternalDeviceControl for WDFREQUEST 0x%p",
3335 "Calling driver EvtIoDefault for WDFREQUEST 0x%p", hRequest);
3350 "Zero length WDFREQUEST 0x%p completed automatically "
3372 "Zero length WDFREQUEST 0x%p completed automatically "
3395 "Driver has no event callback "
3396 "for %!WDF_REQUEST_TYPE!, completing WDFREQUEST 0x%p with "
3469 "not a Manual queue, ReadyNotify is only valid "
3470 "on a manual Queue, %!STATUS!",
3493 "already has a ReadyNotify callback 0x%p"
3515 "does not have a ReadyNotify to cancel, %!STATUS!",
3530 "should be stopped before clearing ReadyNotify callback "
3546 DispatchEvents(
irql);
3577 DispatchEvents(
irql);
3623 "WDFQUEUE 0x%p is already deleted, %!STATUS!",
3634 if (IdleComplete !=
NULL) {
3643 "WDFQUEUE 0x%p already has a "
3644 "IdleComplete callback registered 0x%p, "
3665 if (CancelRequests) {
3680 #pragma warning(disable:4127)
3682 #pragma warning(default:4127)
3698#pragma prefast(suppress:__WARNING_PASSING_FUNCTION_UNEXPECTED_NULL, "This is the tag value used in the ADDREF of Peek()")
3715 if (CancelRequests) {
3716 #pragma warning(disable:4127)
3718 #pragma warning(default:4127)
3727 "All WDFQUEUE 0x%p requests cancelled",
3751 "Cancelling WDFREQUEST 0x%p, WDFQUEUE 0x%p",
3770 #pragma warning(disable:4127)
3772 #pragma warning(default:4127)
3781 "All driver cancellable requests cancelled "
3782 " in WDFQUEUE 0x%p",
3826 DispatchEvents(
irql);
3856#if (FX_CORE_MODE==FX_CORE_USER_MODE)
3872 "Waiting for %d requests to complete "
3877 Mx::MxEnterCriticalRegion();
3880 "waiting for queue to stop, WDFQUEUE",
GetHandle(),
3885 Mx::MxLeaveCriticalRegion();
3943 "WDFQUEUE 0x%p is already deleted %!STATUS!",
3963 "WDFQUEUE 0x%p already has a "
3964 "PurgeComplete callback registered 0x%p "
3979 if (CancelQueueRequests && CancelDriverRequests &&
3998 if (CancelQueueRequests) {
3999 #pragma warning(disable:4127)
4001 #pragma warning(default:4127)
4009 "All WDFQUEUE 0x%p requests cancelled",
4018 "Cancelling WDFREQUEST 0x%p, WDFQUEUE 0x%p",
4035 if (CancelDriverRequests) {
4041 #pragma warning(disable:4127)
4043 #pragma warning(default:4127)
4051 "All driver cancellable requests cancelled "
4052 " in WDFQUEUE 0x%p",
4094 DispatchEvents(
irql);
4121#if (FX_CORE_MODE==FX_CORE_USER_MODE)
4137 "Waiting for %d requests to complete "
4142 Mx::MxEnterCriticalRegion();
4145 "waiting for queue to purge, WDFQUEUE",
GetHandle(),
4149 Mx::MxLeaveCriticalRegion();
4190#if (FX_CORE_MODE==FX_CORE_USER_MODE)
4206 "Waiting for %d requests to complete "
4211 Mx::MxEnterCriticalRegion();
4214 "waiting for queue to drain, WDFQUEUE",
GetHandle(),
4218 Mx::MxLeaveCriticalRegion();
4244 if (pQueuedRequests !=
NULL) {
4248 if (pDriverPendingRequests !=
NULL) {
4286 #pragma warning(disable:4127)
4288 #pragma warning(default:4127)
4321 DispatchEvents(
irql);
4357 "was cancelled while on WDFQUEUE 0x%p",
4363 pRequest->MarkRemovedFromIrpQueue();
4376 if(m_IoCanceledOnQueue.Method &&
pRequest->m_Presented) {
4413 Lock(&PreviousIrql);
4417 DispatchInternalEvents(PreviousIrql);
4459 ioQueue->ADDREF(
Irp);
4471 ioQueue->RELEASE(
Irp);
4501 "WDFREQUEST 0x%p is on a cancellation list for WDFQUEUE 0x%p",
4519 "was cancelled in driver for WDFQUEUE 0x%p",
4526 "WDFREQUEST 0x%p is "
4527 "already on list, FxRequest::m_ListEntry is busy!, "
4560 VerifyCancelForDriver(FxDriverGlobals,
pRequest);
4608 DispatchInternalEvents(
irql);
4653 ioQueue->ADDREF(
Irp);
4664 ioQueue->RELEASE(
Irp);
4669FxIoQueue::ProcessIdleComplete(
4707 "WDFQUEUE 0x%p is idle, calling driver callback",
4722FxIoQueue::ProcessPurgeComplete(
4758 "WDFQUEUE 0x%p is purged, calling driver callback",
4773FxIoQueue::ProcessReadyNotify(
4822 "ReadyNotify notify method is NULL "
4835FxIoQueue::ProcessCancelledRequests(
4879 "Calling CancelRoutine routine "
4880 "for WDFREQUEST 0x%p on WDFQUEUE 0x%p",
4919FxIoQueue::ProcessCancelledRequestsOnQueue(
4963 "Calling CanceledOnQueue routine "
4964 "for WDFREQUEST 0x%p on WDFQUEUE 0x%p",
4992FxIoQueue::ProcessPowerEvents(