ReactOS 0.4.17-dev-1281-g065abb3
EndpointMachine Class Reference

#include <epsm.h>

Inheritance diagram for EndpointMachine:
Collaboration diagram for EndpointMachine:

Public Member Functions

VOID Initialize (_In_ UcxEndpoint *Endpoint)
 
UcxEndpoint * Endpoint () const
 
- Public Member Functions inherited from SmMachine< EndpointMachine, EpEvent >
VOID SmInitialize (_In_ const State *Initial)
 
BOOLEAN SmPost (_In_ EpEvent Ev)
 
VOID SmContinueOnPassive ()
 
const State * SmCurrent () const
 
ULONG SmDepth () const
 
const State * SmFrame (_In_ ULONG Index) const
 
BOOLEAN SmIsIn (_In_ const State *Ancestor) const
 
BOOLEAN SmIsPaused () const
 
BOOLEAN SmIsWaitingForTimer () const
 
ULONG SmUnexpectedCount () const
 

Static Public Attributes

static const SM_EVENT_INFO EventInfo []
 

Private Types

enum  PURGE_FOLLOW_UP { PurgeFollowUpNone , PurgeFollowUpHubOperation , PurgeFollowUpTreePurge }
 

Private Member Functions

BOOLEAN SmAccepts (_In_ EpEvent Event)
 Abort URB is only taken while running; the caller fails the URB on FALSE.
 
VOID SmReference ()
 
VOID SmDereference ()
 
SM_RESULT OnInactive (_In_ EpEvent Event)
 
SM_RESULT OnCreated (_In_ EpEvent Event)
 
SM_RESULT OnDisabled (_In_ EpEvent Event)
 
SM_RESULT OnRetired (_In_ EpEvent Event)
 
SM_RESULT OnStale (_In_ EpEvent Event)
 
SM_RESULT OnEnabled (_In_ EpEvent Event)
 
SM_RESULT OnBusy (_In_ EpEvent Event)
 
SM_RESULT OnPurging (_In_ EpEvent Event)
 
SM_RESULT OnOperation (_In_ EpEvent Event)
 
SM_RESULT OnAwaitingAbortUrb (_In_ EpEvent Event)
 
SM_RESULT OnAborting (_In_ EpEvent Event)
 
SM_RESULT OnEnablingStreams (_In_ EpEvent Event)
 
SM_RESULT OnDisablingStreams (_In_ EpEvent Event)
 
SM_RESULT OnResettingPipe (_In_ EpEvent Event)
 
SM_RESULT OnOperationHeld (_In_ EpEvent Event)
 
SM_RESULT OnOperationUnwinding (_In_ EpEvent Event)
 Reset under an outstanding operation: finish it, then purge.
 
SM_RESULT EnterPurging ()
 
SM_RESULT EnterAborting ()
 
SM_RESULT EnterEnablingStreams ()
 
SM_RESULT EnterDisablingStreams ()
 
SM_RESULT EnterResettingPipe ()
 
SM_RESULT EnterOperationHeld ()
 
SM_RESULT PauseForControllerReset ()
 Pause before the ack; nothing may touch the machine after it.
 
SM_RESULT StartPurge (_In_ PURGE_FOLLOW_UP FollowUp)
 
SM_RESULT BeginOperation (_In_ const State *Target, _In_ const State *ReturnTo)
 
SM_RESULT TryStart ()
 
SM_RESULT Retire ()
 An endpoint the client still has a handle to stays around as stale.
 
BOOLEAN CanStart ()
 
VOID ReferenceEndpoint ()
 
VOID DereferenceEndpoint ()
 
VOID StartEndpoint ()
 
VOID PurgeEndpoint ()
 
VOID AbortEndpoint ()
 
VOID ForwardResetRequest ()
 
VOID FailResetRequest ()
 
VOID FinishEndpointResetRequest ()
 
VOID ForwardStreamsEnableRequest ()
 
VOID RejectStreamsEnableRequest ()
 
VOID FinishStreamsOpenRequest (_In_ BOOLEAN ForceFailure)
 
VOID ForwardStreamsDisableRequest ()
 
VOID ParkStreamsDisableRequest ()
 
VOID FinishStreamsCloseRequest ()
 
VOID CompleteAbortUrb ()
 
VOID CompleteHubOperation ()
 
VOID CompleteTreePurge ()
 
VOID AckControllerReset ()
 
VOID DeleteEndpoint ()
 
BOOLEAN ParkAsStale ()
 
VOID DeleteStaleEndpoint ()
 
BOOLEAN DeviceAllowsStart ()
 
BOOLEAN DeviceDeprogrammed ()
 
BOOLEAN DeviceDisconnected ()
 
BOOLEAN ClientHoldsHandle ()
 

Private Attributes

UcxEndpoint * m_Endpoint
 
const State * m_ReturnTo
 
const State * m_HeldOperation
 
PURGE_FOLLOW_UP m_AfterPurge
 
BOOLEAN m_Enabled
 
BOOLEAN m_AbortForHub
 
BOOLEAN m_PauseAfterPurge
 

Static Private Attributes

static const State Inactive
 
static const State Created
 
static const State Disabled
 
static const State Retired
 
static const State Stale
 
static const State AwaitingDestroy
 
static const State Enabled
 
static const State Busy
 
static const State Purging
 
static const State Operation
 
static const State AwaitingAbortUrb
 
static const State Aborting
 
static const State EnablingStreams
 
static const State DisablingStreams
 
static const State ResettingPipe
 
static const State OperationHeld
 
static const State OperationUnwinding
 

Friends

class SmMachine< EndpointMachine, EpEvent >
 

Additional Inherited Members

- Public Types inherited from SmMachine< EndpointMachine, EpEvent >
typedef SmState< EndpointMachine, EpEvent > State
 
- Protected Member Functions inherited from SmMachine< EndpointMachine, EpEvent >
VOID SmBeginPause ()
 
VOID SmDiscardQueued (_In_ EpEvent Ev)
 
BOOLEAN SmAccepts (_In_ EpEvent Ev)
 
VOID SmReference ()
 
VOID SmDereference ()
 
VOID SmQueuePassive ()
 
VOID SmOnDequeue (_In_ EpEvent Ev)
 
VOID SmStateChanged ()
 
BOOLEAN SmCancelTimer ()
 
- Static Protected Member Functions inherited from SmMachine< EndpointMachine, EpEvent >
static SM_RESULT SmMakeResult (_In_ SM_RESULT_KIND Kind, _In_ USHORT Ev, _In_opt_ const VOID *Target)
 
static SM_RESULT SmHandled ()
 
static SM_RESULT SmUnhandled ()
 
static SM_RESULT SmTransition (_In_ const State *Target)
 
static SM_RESULT SmPaused ()
 
static SM_RESULT SmCall (_In_ const State *Start)
 
static SM_RESULT SmReturn (_In_ EpEvent Ev)
 
- Static Protected Attributes inherited from SmMachine< EndpointMachine, EpEvent >
static const BOOLEAN SmCompletionsFirst
 
static const USHORT SmTimerEventId
 

Detailed Description

Definition at line 48 of file epsm.h.

Member Enumeration Documentation

◆ PURGE_FOLLOW_UP

Enumerator
PurgeFollowUpNone 
PurgeFollowUpHubOperation 
PurgeFollowUpTreePurge 

Definition at line 66 of file epsm.h.

Member Function Documentation

◆ AbortEndpoint()

VOID EndpointMachine::AbortEndpoint ( )
private

Definition at line 676 of file pipe.cpp.

677{
679}
UcxEndpoint * m_Endpoint
Definition: epsm.h:212
UCXCONTROLLER m_Handle
Definition: hostctl.h:287
UcxController * m_Controller
Definition: pipe.h:282
UcxEndpointCallbacks m_Callbacks
Definition: pipe.h:289
UCXENDPOINT m_Handle
Definition: pipe.h:281
PFN_UCX_ENDPOINT_ABORT Abort
Definition: pipe.h:79

Referenced by EnterAborting().

◆ AckControllerReset()

VOID EndpointMachine::AckControllerReset ( )
private

Definition at line 816 of file pipe.cpp.

Referenced by OnRetired(), and PauseForControllerReset().

◆ BeginOperation()

SM_RESULT EndpointMachine::BeginOperation ( _In_ const State *  Target,
_In_ const State *  ReturnTo 
)
private

Definition at line 563 of file epsm.cpp.

566{
567 m_ReturnTo = ReturnTo;
568 return SmTransition(Target);
569}
const State * m_ReturnTo
Definition: epsm.h:213
static SM_RESULT SmTransition(_In_ const State *Target)
Definition: smengine.h:194
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by OnDisabled(), and OnEnabled().

◆ CanStart()

BOOLEAN EndpointMachine::CanStart ( )
private

Definition at line 606 of file epsm.cpp.

607{
608 return m_Enabled && DeviceAllowsStart();
609}
BOOLEAN DeviceAllowsStart()
Definition: pipe.cpp:925
BOOLEAN m_Enabled
Definition: epsm.h:216

Referenced by OnCreated(), and TryStart().

◆ ClientHoldsHandle()

BOOLEAN EndpointMachine::ClientHoldsHandle ( )
private

Definition at line 943 of file pipe.cpp.

944{
946}
BOOLEAN m_ClientHoldsHandle
Definition: pipe.h:313

Referenced by Retire().

◆ CompleteAbortUrb()

VOID EndpointMachine::CompleteAbortUrb ( )
private

Definition at line 783 of file pipe.cpp.

784{
786 PURB Urb;
787
788 if (Irp == NULL)
789 return;
790
793}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
IO_CSQ m_AbortPipeCsq
Definition: hostctl.h:306
IO_CSQ_IRP_CONTEXT m_AbortCsqContext
Definition: pipe.h:308
VOID NTAPI UcxCompleteUrbAtDispatch(_In_ PIRP Irp, _In_ PURB Urb, _In_ NTSTATUS Status, _In_ USBD_STATUS UsbdStatus)
Definition: clientxrb.cpp:42
NTKERNELAPI PIRP NTAPI IoCsqRemoveIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIO_CSQ_IRP_CONTEXT Context)
Remove anb IRP from the queue.
Definition: csq.c:326
#define NULL
Definition: types.h:112
_In_ PIRP Irp
Definition: kse.h:79
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _IO_STACK_LOCATION::@5100::@5139 Others
union _IO_STACK_LOCATION::@1823 Parameters
Definition: usb.h:565
struct _URB * PURB
#define USBD_STATUS_SUCCESS
Definition: usb.h:177
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333

Referenced by OnAborting(), and OnOperationUnwinding().

◆ CompleteHubOperation()

VOID EndpointMachine::CompleteHubOperation ( )
private

Definition at line 796 of file pipe.cpp.

797{
799}
UcxUsbDevice * m_Device
Definition: pipe.h:283
VOID CompleteHubOperation()
Definition: devicemgmt.cpp:358

Referenced by OnAborting(), OnCreated(), OnDisabled(), OnInactive(), OnOperationUnwinding(), OnPurging(), and TryStart().

◆ CompleteTreePurge()

VOID EndpointMachine::CompleteTreePurge ( )
private

Definition at line 803 of file pipe.cpp.

804{
806
807 if (InterlockedDecrement(&Controller->m_PendingTreePurgeEndpoints) != 0)
808 return;
809
810 WdfRequestComplete(Controller->m_PendingTreePurge, STATUS_SUCCESS);
811 Controller->m_PendingTreePurge = NULL;
812 WdfIoQueueStart(Controller->m_TreePurgeQueue);
813}
#define InterlockedDecrement
Definition: armddk.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller

Referenced by OnInactive(), and OnPurging().

◆ DeleteEndpoint()

VOID EndpointMachine::DeleteEndpoint ( )
private

Definition at line 844 of file pipe.cpp.

845{
847 UCXENDPOINT Handle = m_Endpoint->m_Handle;
848
849 DPRINT("Endpoint %p deleted\n", Handle);
850
852
853 {
854 SpinLockGuard Guard(&Controller->m_TopologyLock);
855
856 Controller->m_ChildEndpointCount--;
859 }
860
863}
LIST_ENTRY m_DeviceLink
Definition: pipe.h:293
static VOID NTAPI UcxUntrackEndpoint(_In_ UcxEndpoint *Endpoint)
Definition: pipe.cpp:825
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
ULONG Handle
Definition: gdb_input.c:15
#define DPRINT
Definition: sndvol32.h:73
FORCEINLINE VOID NTAPI UcxClearListEntry(_Out_ PLIST_ENTRY Entry)
Definition: ucxutil.h:84
WdfObjectDelete(String)
#define WdfObjectDereference(Handle)
Definition: wdfobject.h:826

Referenced by Retire().

◆ DeleteStaleEndpoint()

VOID EndpointMachine::DeleteStaleEndpoint ( )
private

Definition at line 914 of file pipe.cpp.

915{
916 UCXENDPOINT Handle = m_Endpoint->m_Handle;
917
918 DPRINT("Stale endpoint %p deleted\n", Handle);
919
922}

Referenced by OnStale(), and Retire().

◆ DereferenceEndpoint()

VOID EndpointMachine::DereferenceEndpoint ( )
private

Definition at line 657 of file pipe.cpp.

Referenced by SmDereference().

◆ DeviceAllowsStart()

BOOLEAN EndpointMachine::DeviceAllowsStart ( )
private

Definition at line 925 of file pipe.cpp.

926{
928}
BOOLEAN AllowsEndpointStart() const
Definition: devobj.h:130

Referenced by CanStart().

◆ DeviceDeprogrammed()

BOOLEAN EndpointMachine::DeviceDeprogrammed ( )
private

Definition at line 931 of file pipe.cpp.

932{
934}
BOOLEAN m_DeprogrammedByControllerReset
Definition: devobj.h:244

Referenced by EnterDisablingStreams(), and EnterResettingPipe().

◆ DeviceDisconnected()

BOOLEAN EndpointMachine::DeviceDisconnected ( )
private

Definition at line 937 of file pipe.cpp.

938{
940}
BOOLEAN m_Disconnected
Definition: devobj.h:231

Referenced by EnterResettingPipe().

◆ Endpoint()

UcxEndpoint * EndpointMachine::Endpoint ( ) const
inline

Definition at line 58 of file epsm.h.

59 {
60 return m_Endpoint;
61 }

Referenced by Initialize().

◆ EnterAborting()

SM_RESULT EndpointMachine::EnterAborting ( )
private

Definition at line 385 of file epsm.cpp.

386{
388 return SmHandled();
389}
VOID AbortEndpoint()
Definition: pipe.cpp:676

◆ EnterDisablingStreams()

SM_RESULT EndpointMachine::EnterDisablingStreams ( )
private

Definition at line 435 of file epsm.cpp.

436{
437 /* A deprogrammed device has no streams on the controller to tear down */
440 else
442
443 return SmHandled();
444}
VOID ParkStreamsDisableRequest()
Definition: pipe.cpp:750
VOID ForwardStreamsDisableRequest()
Definition: pipe.cpp:741
BOOLEAN DeviceDeprogrammed()
Definition: pipe.cpp:931
static const State Disabled
Definition: epsm.h:76

◆ EnterEnablingStreams()

SM_RESULT EndpointMachine::EnterEnablingStreams ( )
private

Definition at line 413 of file epsm.cpp.

414{
415 if (m_ReturnTo == &Enabled)
417 else
419
420 return SmHandled();
421}
VOID RejectStreamsEnableRequest()
Definition: pipe.cpp:713
static const State Enabled
Definition: epsm.h:80
VOID ForwardStreamsEnableRequest()
Definition: pipe.cpp:704

◆ EnterOperationHeld()

SM_RESULT EndpointMachine::EnterOperationHeld ( )
private

Definition at line 480 of file epsm.cpp.

481{
483}
SM_RESULT PauseForControllerReset()
Pause before the ack; nothing may touch the machine after it.
Definition: epsm.cpp:547

◆ EnterPurging()

SM_RESULT EndpointMachine::EnterPurging ( )
private

Definition at line 331 of file epsm.cpp.

332{
334
336 {
339 }
340
341 return SmHandled();
342}
BOOLEAN m_PauseAfterPurge
Definition: epsm.h:218
VOID PurgeEndpoint()
Definition: pipe.cpp:670
#define FALSE
Definition: types.h:117

◆ EnterResettingPipe()

SM_RESULT EndpointMachine::EnterResettingPipe ( )
private

Definition at line 458 of file epsm.cpp.

459{
462 else
464
465 return SmHandled();
466}
VOID FailResetRequest()
Definition: pipe.cpp:691
VOID ForwardResetRequest()
Definition: pipe.cpp:682
BOOLEAN DeviceDisconnected()
Definition: pipe.cpp:937

◆ FailResetRequest()

VOID EndpointMachine::FailResetRequest ( )
private

Definition at line 691 of file pipe.cpp.

692{
693 DPRINT1("Endpoint %p reset failed, device is gone or reset\n", m_Endpoint->m_Handle);
694 WdfRequestComplete((WDFREQUEST)m_Endpoint->TakePending(), STATUS_NO_SUCH_DEVICE);
695}
#define DPRINT1
Definition: precomp.h:8
PVOID TakePending()
Definition: pipe.h:264
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

Referenced by EnterResettingPipe().

◆ FinishEndpointResetRequest()

VOID EndpointMachine::FinishEndpointResetRequest ( )
private

Definition at line 698 of file pipe.cpp.

699{
701}
#define IoCompleteRequest
Definition: irp.c:1272
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by OnOperationUnwinding(), and OnResettingPipe().

◆ FinishStreamsCloseRequest()

VOID EndpointMachine::FinishStreamsCloseRequest ( )
private

Definition at line 762 of file pipe.cpp.

763{
765 UcxStaticStreams* Streams;
766
767 {
769
770 Streams = m_Endpoint->m_Streams;
772 }
773
774 if (Streams != NULL)
775 WdfObjectDelete(Streams->m_Handle);
776
779}
struct _IRP * PIRP
KSPIN_LOCK m_TopologyLock
Definition: hostctl.h:310
UcxStaticStreams * m_Streams
Definition: pipe.h:286
LONG m_StreamsOpenCount
Definition: pipe.h:287
UCXSSTREAMS m_Handle
Definition: pipe.h:380
VOID NTAPI UcxCompleteHeldUrbIrp(_In_ PIRP Irp)
Definition: clientxrb.cpp:61

Referenced by OnDisablingStreams(), and OnOperationUnwinding().

◆ FinishStreamsOpenRequest()

VOID EndpointMachine::FinishStreamsOpenRequest ( _In_ BOOLEAN  ForceFailure)
private

Definition at line 720 of file pipe.cpp.

722{
724
725 if (ForceFailure)
726 {
727 DPRINT1("Endpoint %p static streams open failed by endpoint state\n", m_Endpoint->m_Handle);
729 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_STATE;
730 Irp->IoStatus.Information = 0;
731 }
732 else if (!NT_SUCCESS(Irp->IoStatus.Status))
733 {
735 }
736
738}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178

Referenced by OnEnablingStreams(), and OnOperationUnwinding().

◆ ForwardResetRequest()

VOID EndpointMachine::ForwardResetRequest ( )
private

Definition at line 682 of file pipe.cpp.

683{
684 WDFREQUEST Request = (WDFREQUEST)m_Endpoint->TakePending();
685
687}
PFN_UCX_ENDPOINT_RESET Reset
Definition: pipe.h:80
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request

Referenced by EnterResettingPipe().

◆ ForwardStreamsDisableRequest()

VOID EndpointMachine::ForwardStreamsDisableRequest ( )
private

Definition at line 741 of file pipe.cpp.

742{
743 WDFREQUEST Request = (WDFREQUEST)m_Endpoint->TakePending();
744
746}
PFN_UCX_ENDPOINT_STATIC_STREAMS_DISABLE StaticStreamsDisable
Definition: pipe.h:84

Referenced by EnterDisablingStreams().

◆ ForwardStreamsEnableRequest()

VOID EndpointMachine::ForwardStreamsEnableRequest ( )
private

Definition at line 704 of file pipe.cpp.

705{
706 WDFREQUEST Request = (WDFREQUEST)m_Endpoint->TakePending();
707
709}
PFN_UCX_ENDPOINT_STATIC_STREAMS_ENABLE StaticStreamsEnable
Definition: pipe.h:83

Referenced by EnterEnablingStreams().

◆ Initialize()

VOID EndpointMachine::Initialize ( _In_ UcxEndpoint *  Endpoint)

Definition at line 107 of file epsm.cpp.

109{
117
119}
const State * m_HeldOperation
Definition: epsm.h:214
BOOLEAN m_AbortForHub
Definition: epsm.h:217
UcxEndpoint * Endpoint() const
Definition: epsm.h:58
PURGE_FOLLOW_UP m_AfterPurge
Definition: epsm.h:215
static const State Created
Definition: epsm.h:75
VOID SmInitialize(_In_ const State *Initial)
Definition: smengine.h:349

◆ OnAborting()

SM_RESULT EndpointMachine::OnAborting ( _In_ EpEvent  Event)
private

Definition at line 392 of file epsm.cpp.

394{
395 if (Event != EpEvent::AbortDone)
396 return SmUnhandled();
397
398 if (m_AbortForHub)
399 {
402 }
403 else
404 {
407 }
408
409 return SmTransition(&Enabled);
410}
VOID CompleteAbortUrb()
Definition: pipe.cpp:783
VOID StartEndpoint()
Definition: pipe.cpp:663
VOID CompleteHubOperation()
Definition: pipe.cpp:796
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287

◆ OnAwaitingAbortUrb()

SM_RESULT EndpointMachine::OnAwaitingAbortUrb ( _In_ EpEvent  Event)
private

Definition at line 375 of file epsm.cpp.

377{
378 if (Event == EpEvent::AbortUrbParked)
379 return SmTransition(&Aborting);
380
381 return SmUnhandled();
382}
static const State Aborting
Definition: epsm.h:85

◆ OnBusy()

SM_RESULT EndpointMachine::OnBusy ( _In_ EpEvent  Event)
private

Definition at line 314 of file epsm.cpp.

316{
317 switch (Event)
318 {
319 case EpEvent::ControllerResetStarting:
321
322 case EpEvent::ControllerResetDone:
323 return SmHandled();
324
325 default:
326 return SmUnhandled();
327 }
328}

◆ OnCreated()

SM_RESULT EndpointMachine::OnCreated ( _In_ EpEvent  Event)
private

Definition at line 179 of file epsm.cpp.

181{
182 switch (Event)
183 {
184 case EpEvent::Delete:
185 return Retire();
186
187 case EpEvent::ConfigureDone:
188 m_Enabled = TRUE;
189 if (!CanStart())
191
193 return SmTransition(&Enabled);
194
195 case EpEvent::DeviceResetDone:
197 return SmHandled();
198
199 default:
200 return SmUnhandled();
201 }
202}
SM_RESULT StartPurge(_In_ PURGE_FOLLOW_UP FollowUp)
Definition: epsm.cpp:555
BOOLEAN CanStart()
Definition: epsm.cpp:606
SM_RESULT Retire()
An endpoint the client still has a handle to stays around as stale.
Definition: epsm.cpp:590
#define TRUE
Definition: types.h:120

◆ OnDisabled()

SM_RESULT EndpointMachine::OnDisabled ( _In_ EpEvent  Event)
private

Definition at line 205 of file epsm.cpp.

207{
208 switch (Event)
209 {
210 case EpEvent::Delete:
211 return Retire();
212
213 case EpEvent::HubDisable:
214 case EpEvent::HubDeviceReset:
217 return SmHandled();
218
219 case EpEvent::ConfigureDone:
220 case EpEvent::DeviceResetDone:
221 m_Enabled = TRUE;
222 return TryStart();
223
224 case EpEvent::HubStartRequest:
225 return TryStart();
226
227 case EpEvent::ClientStreamsEnable:
229
230 case EpEvent::ClientStreamsDisable:
232
233 case EpEvent::HubEndpointReset:
235
236 default:
237 return SmUnhandled();
238 }
239}
static const State ResettingPipe
Definition: epsm.h:88
static const State EnablingStreams
Definition: epsm.h:86
SM_RESULT BeginOperation(_In_ const State *Target, _In_ const State *ReturnTo)
Definition: epsm.cpp:563
SM_RESULT TryStart()
Definition: epsm.cpp:572
static const State DisablingStreams
Definition: epsm.h:87

◆ OnDisablingStreams()

SM_RESULT EndpointMachine::OnDisablingStreams ( _In_ EpEvent  Event)
private

Definition at line 447 of file epsm.cpp.

449{
450 if (Event != EpEvent::StreamsClosed)
451 return SmUnhandled();
452
454 return SmTransition(m_ReturnTo);
455}
VOID FinishStreamsCloseRequest()
Definition: pipe.cpp:762

◆ OnEnabled()

SM_RESULT EndpointMachine::OnEnabled ( _In_ EpEvent  Event)
private

Definition at line 268 of file epsm.cpp.

270{
271 switch (Event)
272 {
273 case EpEvent::ClientStreamsEnable:
275
276 case EpEvent::ClientStreamsDisable:
278
279 case EpEvent::HubEndpointReset:
281
282 case EpEvent::ClientAbortUrb:
285
286 case EpEvent::HubAbort:
289
290 case EpEvent::HubDisable:
291 case EpEvent::HubDeviceReset:
294
295 case EpEvent::HubPurge:
297
298 case EpEvent::HubTreePurge:
300
301 case EpEvent::HubDisconnect:
303
304 case EpEvent::ControllerResetStarting:
307
308 default:
309 return SmUnhandled();
310 }
311}
static const State AwaitingAbortUrb
Definition: epsm.h:84

◆ OnEnablingStreams()

SM_RESULT EndpointMachine::OnEnablingStreams ( _In_ EpEvent  Event)
private

Definition at line 424 of file epsm.cpp.

426{
427 if (Event != EpEvent::StreamsOpened)
428 return SmUnhandled();
429
431 return SmTransition(m_ReturnTo);
432}
VOID FinishStreamsOpenRequest(_In_ BOOLEAN ForceFailure)
Definition: pipe.cpp:720

◆ OnInactive()

SM_RESULT EndpointMachine::OnInactive ( _In_ EpEvent  Event)
private

Definition at line 148 of file epsm.cpp.

150{
151 switch (Event)
152 {
153 case EpEvent::HubStartRequest:
154 case EpEvent::HubPurge:
155 case EpEvent::HubAbort:
156 case EpEvent::HubDeviceReset:
158 return SmHandled();
159
160 case EpEvent::HubTreePurge:
162 return SmHandled();
163
164 case EpEvent::HubDisconnect:
165 return SmHandled();
166
167 case EpEvent::ControllerResetStarting:
169
170 case EpEvent::ControllerResetDone:
171 return SmHandled();
172
173 default:
174 return SmUnhandled();
175 }
176}
VOID CompleteTreePurge()
Definition: pipe.cpp:803

◆ OnOperation()

SM_RESULT EndpointMachine::OnOperation ( _In_ EpEvent  Event)
private

Definition at line 360 of file epsm.cpp.

362{
363 if (Event != EpEvent::ControllerResetStarting)
364 return SmUnhandled();
365
366 /* Endpoint is already purged, Busy pauses in place */
367 if (m_ReturnTo == &Disabled)
368 return SmUnhandled();
369
372}
static const State OperationHeld
Definition: epsm.h:89
const State * SmCurrent() const
Definition: smengine.h:130

◆ OnOperationHeld()

SM_RESULT EndpointMachine::OnOperationHeld ( _In_ EpEvent  Event)
private

Definition at line 486 of file epsm.cpp.

488{
489 if (Event == EpEvent::ControllerResetDone)
491
492 return SmUnhandled();
493}
static const State OperationUnwinding
Definition: epsm.h:90

◆ OnOperationUnwinding()

SM_RESULT EndpointMachine::OnOperationUnwinding ( _In_ EpEvent  Event)
private

Reset under an outstanding operation: finish it, then purge.

Definition at line 500 of file epsm.cpp.

502{
503 if (Event == EpEvent::ControllerResetStarting)
505
506 /* A hub abort only ever has the abort itself outstanding */
508 {
509 if (Event != EpEvent::AbortDone)
510 return SmUnhandled();
511
514 }
515
516 switch (Event)
517 {
518 case EpEvent::AbortUrbParked:
519 case EpEvent::AbortDone:
521 break;
522
523 case EpEvent::StreamsOpened:
525 break;
526
527 case EpEvent::StreamsClosed:
529 break;
530
531 case EpEvent::EndpointResetDone:
533 break;
534
535 default:
536 return SmUnhandled();
537 }
538
540}
VOID FinishEndpointResetRequest()
Definition: pipe.cpp:698

◆ OnPurging()

SM_RESULT EndpointMachine::OnPurging ( _In_ EpEvent  Event)
private

Definition at line 345 of file epsm.cpp.

347{
348 if (Event != EpEvent::PurgeDone)
349 return SmUnhandled();
350
355
356 return SmTransition(&Disabled);
357}

◆ OnResettingPipe()

SM_RESULT EndpointMachine::OnResettingPipe ( _In_ EpEvent  Event)
private

Definition at line 469 of file epsm.cpp.

471{
472 if (Event != EpEvent::EndpointResetDone)
473 return SmUnhandled();
474
476 return SmTransition(m_ReturnTo);
477}

◆ OnRetired()

SM_RESULT EndpointMachine::OnRetired ( _In_ EpEvent  Event)
private

Definition at line 242 of file epsm.cpp.

244{
245 if (Event == EpEvent::ControllerResetStarting)
246 {
248 return SmHandled();
249 }
250
251 return SmUnhandled();
252}
VOID AckControllerReset()
Definition: pipe.cpp:816

◆ OnStale()

SM_RESULT EndpointMachine::OnStale ( _In_ EpEvent  Event)
private

Definition at line 255 of file epsm.cpp.

257{
258 if (Event == EpEvent::StaleReplaced)
259 {
262 }
263
264 return SmUnhandled();
265}
static const State AwaitingDestroy
Definition: epsm.h:79
VOID DeleteStaleEndpoint()
Definition: pipe.cpp:914

◆ ParkAsStale()

BOOLEAN EndpointMachine::ParkAsStale ( )
private

Keeps one stale endpoint per address readable for clients still holding it.

Definition at line 867 of file pipe.cpp.

868{
871 UcxEndpoint* Replaced = NULL;
872 UcxEndpoint* Candidate;
874 BOOLEAN Parked;
875
877
878 {
879 SpinLockGuard Guard(&Controller->m_TopologyLock);
880
881 for (Entry = Device->m_StaleEndpointList.Flink; Entry != &Device->m_StaleEndpointList; Entry = Entry->Flink)
882 {
883 Candidate = CONTAINING_RECORD(Entry, UcxEndpoint, m_DeviceLink);
884
886 {
889 Replaced = Candidate;
890 break;
891 }
892 }
893
894 Controller->m_ChildEndpointCount--;
898
899 Parked = !Device->m_PendingDelete;
900 if (Parked)
901 InsertTailList(&Device->m_StaleEndpointList, &m_Endpoint->m_DeviceLink);
902 }
903
904 if (Replaced != NULL)
905 Replaced->Post(EpEvent::StaleReplaced);
906
907 DPRINT("Endpoint %p parked as stale %u, replaced %p\n", m_Endpoint->m_Handle, Parked, Replaced);
908
909 return Parked;
910}
unsigned char BOOLEAN
Definition: actypes.h:127
USB_ENDPOINT_DESCRIPTOR m_Descriptor
Definition: pipe.h:290
BOOLEAN Post(_In_ EpEvent Event)
Definition: pipe.h:255
UcxPipe m_Pipe
Definition: pipe.h:284
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
UcxPipe * Self
Definition: pipe.h:40
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by Retire().

◆ ParkStreamsDisableRequest()

VOID EndpointMachine::ParkStreamsDisableRequest ( )
private

Definition at line 750 of file pipe.cpp.

751{
752 WDFREQUEST Request = (WDFREQUEST)m_Endpoint->TakePending();
754
755 Status = WdfRequestForwardToIoQueue(Request, m_Endpoint->m_Controller->m_PendDuringResetQueue);
756 if (!NT_SUCCESS(Status))
757 DPRINT1("Endpoint %p could not park streams close %p 0x%lx\n", m_Endpoint->m_Handle, Request, Status);
758}
LONG NTSTATUS
Definition: precomp.h:26
WDFQUEUE m_PendDuringResetQueue
Definition: hostctl.h:296
Status
Definition: gdiplustypes.h:24

Referenced by EnterDisablingStreams().

◆ PauseForControllerReset()

SM_RESULT EndpointMachine::PauseForControllerReset ( )
private

Pause before the ack; nothing may touch the machine after it.

Definition at line 547 of file epsm.cpp.

548{
549 SmBeginPause();
551 return SmPaused();
552}

Referenced by EnterOperationHeld(), EnterPurging(), OnBusy(), and OnInactive().

◆ PurgeEndpoint()

VOID EndpointMachine::PurgeEndpoint ( )
private

Definition at line 670 of file pipe.cpp.

Referenced by EnterPurging().

◆ ReferenceEndpoint()

VOID EndpointMachine::ReferenceEndpoint ( )
private

Definition at line 651 of file pipe.cpp.

652{
654}
#define WdfObjectReference(Handle)
Definition: wdfobject.h:803

Referenced by SmReference().

◆ RejectStreamsEnableRequest()

VOID EndpointMachine::RejectStreamsEnableRequest ( )
private

Definition at line 713 of file pipe.cpp.

714{
715 DPRINT1("Endpoint %p static streams enable rejected in this state\n", m_Endpoint->m_Handle);
716 WdfRequestComplete((WDFREQUEST)m_Endpoint->TakePending(), STATUS_INVALID_DEVICE_STATE);
717}

Referenced by EnterEnablingStreams().

◆ Retire()

SM_RESULT EndpointMachine::Retire ( )
private

An endpoint the client still has a handle to stays around as stale.

Definition at line 590 of file epsm.cpp.

591{
592 if (!ClientHoldsHandle())
593 {
596 }
597
598 if (ParkAsStale())
599 return SmTransition(&Stale);
600
603}
static const State Stale
Definition: epsm.h:78
VOID DeleteEndpoint()
Definition: pipe.cpp:844
BOOLEAN ClientHoldsHandle()
Definition: pipe.cpp:943
BOOLEAN ParkAsStale()
Definition: pipe.cpp:867

Referenced by OnCreated(), and OnDisabled().

◆ SmAccepts()

BOOLEAN EndpointMachine::SmAccepts ( _In_ EpEvent  Event)
private

Abort URB is only taken while running; the caller fails the URB on FALSE.

Definition at line 126 of file epsm.cpp.

128{
129 if (Event == EpEvent::ClientAbortUrb)
130 return SmCurrent() == &Enabled;
131
132 return TRUE;
133}

◆ SmDereference()

VOID EndpointMachine::SmDereference ( )
private

Definition at line 142 of file epsm.cpp.

143{
145}
VOID DereferenceEndpoint()
Definition: pipe.cpp:657

◆ SmReference()

VOID EndpointMachine::SmReference ( )
private

Definition at line 136 of file epsm.cpp.

137{
139}
VOID ReferenceEndpoint()
Definition: pipe.cpp:651

◆ StartEndpoint()

VOID EndpointMachine::StartEndpoint ( )
private

Definition at line 663 of file pipe.cpp.

Referenced by OnAborting(), and TryStart().

◆ StartPurge()

SM_RESULT EndpointMachine::StartPurge ( _In_ PURGE_FOLLOW_UP  FollowUp)
private

Definition at line 555 of file epsm.cpp.

557{
558 m_AfterPurge = FollowUp;
559 return SmTransition(&Purging);
560}
static const State Purging
Definition: epsm.h:82

Referenced by OnCreated(), OnEnabled(), and OnOperationUnwinding().

◆ TryStart()

SM_RESULT EndpointMachine::TryStart ( )
private

Definition at line 572 of file epsm.cpp.

573{
574 if (!CanStart())
575 {
577 return SmHandled();
578 }
579
582 return SmTransition(&Enabled);
583}

Referenced by OnDisabled().

Friends And Related Function Documentation

◆ SmMachine< EndpointMachine, EpEvent >

Definition at line 1 of file epsm.h.

Member Data Documentation

◆ Aborting

const EndpointMachine::State EndpointMachine::Aborting
staticprivate
Initial value:
=
SM_RESULT OnAborting(_In_ EpEvent Event)
Definition: epsm.cpp:392
SM_RESULT EnterAborting()
Definition: epsm.cpp:385
static const State Operation
Definition: epsm.h:83

Definition at line 85 of file epsm.h.

Referenced by OnAwaitingAbortUrb(), OnEnabled(), and OnOperationUnwinding().

◆ AwaitingAbortUrb

const EndpointMachine::State EndpointMachine::AwaitingAbortUrb
staticprivate
Initial value:
=
{ &Operation, "AwaitingAbortUrb", 0, &EndpointMachine::OnAwaitingAbortUrb, NULL }
SM_RESULT OnAwaitingAbortUrb(_In_ EpEvent Event)
Definition: epsm.cpp:375

Definition at line 84 of file epsm.h.

Referenced by OnEnabled().

◆ AwaitingDestroy

const EndpointMachine::State EndpointMachine::AwaitingDestroy
staticprivate
Initial value:
=
{ &Retired, "AwaitingDestroy", 0, NULL, NULL }
static const State Retired
Definition: epsm.h:77

Definition at line 79 of file epsm.h.

Referenced by OnStale(), and Retire().

◆ Busy

const EndpointMachine::State EndpointMachine::Busy
staticprivate
Initial value:
=
{ NULL, "Busy", 0, &EndpointMachine::OnBusy, NULL }
SM_RESULT OnBusy(_In_ EpEvent Event)
Definition: epsm.cpp:314

Definition at line 81 of file epsm.h.

◆ Created

const EndpointMachine::State EndpointMachine::Created
staticprivate
Initial value:
=
static const State Inactive
Definition: epsm.h:74
SM_RESULT OnCreated(_In_ EpEvent Event)
Definition: epsm.cpp:179

Definition at line 75 of file epsm.h.

Referenced by Initialize().

◆ Disabled

const EndpointMachine::State EndpointMachine::Disabled
staticprivate
Initial value:
=
{ &Inactive, "Disabled", 0, &EndpointMachine::OnDisabled, NULL }
SM_RESULT OnDisabled(_In_ EpEvent Event)
Definition: epsm.cpp:205

Definition at line 76 of file epsm.h.

Referenced by EnterDisablingStreams(), EnterResettingPipe(), OnDisabled(), OnOperation(), and OnPurging().

◆ DisablingStreams

const EndpointMachine::State EndpointMachine::DisablingStreams
staticprivate
Initial value:
=
{ &Operation, "DisablingStreams", 0,
SM_RESULT EnterDisablingStreams()
Definition: epsm.cpp:435
SM_RESULT OnDisablingStreams(_In_ EpEvent Event)
Definition: epsm.cpp:447

Definition at line 87 of file epsm.h.

Referenced by OnDisabled(), and OnEnabled().

◆ Enabled

const EndpointMachine::State EndpointMachine::Enabled
staticprivate
Initial value:
=
SM_RESULT OnEnabled(_In_ EpEvent Event)
Definition: epsm.cpp:268
#define SM_STATE_TAKES_REQUESTS
Definition: smengine.h:39

Definition at line 80 of file epsm.h.

Referenced by EnterEnablingStreams(), OnAborting(), OnCreated(), OnEnabled(), SmAccepts(), and TryStart().

◆ EnablingStreams

const EndpointMachine::State EndpointMachine::EnablingStreams
staticprivate
Initial value:
=
{ &Operation, "EnablingStreams", 0,
SM_RESULT OnEnablingStreams(_In_ EpEvent Event)
Definition: epsm.cpp:424
SM_RESULT EnterEnablingStreams()
Definition: epsm.cpp:413

Definition at line 86 of file epsm.h.

Referenced by OnDisabled(), and OnEnabled().

◆ EventInfo

const SM_EVENT_INFO EndpointMachine::EventInfo
static
Initial value:
=
{
{ "HubStartRequest", SmEventRequest, FALSE },
{ "HubPurge", SmEventRequest, FALSE },
{ "HubTreePurge", SmEventRequest, FALSE },
{ "HubAbort", SmEventRequest, FALSE },
{ "HubDisconnect", SmEventRequest, FALSE },
{ "HubDisable", SmEventRequest, FALSE },
{ "HubDeviceReset", SmEventRequest, FALSE },
{ "DeviceResetDone", SmEventRequest, FALSE },
{ "ConfigureDone", SmEventRequest, FALSE },
{ "HubEndpointReset", SmEventRequest, FALSE },
{ "Delete", SmEventRequest, FALSE },
{ "ClientAbortUrb", SmEventRequest, FALSE },
{ "ClientStreamsEnable", SmEventRequest, FALSE },
{ "ClientStreamsDisable", SmEventRequest, FALSE },
{ "AbortUrbParked", SmEventCompletion, FALSE },
{ "AbortDone", SmEventCompletion, FALSE },
{ "PurgeDone", SmEventCompletion, FALSE },
{ "EndpointResetDone", SmEventCompletion, FALSE },
{ "StreamsOpened", SmEventCompletion, FALSE },
{ "StreamsClosed", SmEventCompletion, FALSE },
{ "ControllerResetStarting", SmEventCompletion, FALSE },
{ "StaleReplaced", SmEventCompletion, FALSE },
{ "ControllerResetDone", SmEventResume, FALSE },
}
@ SmEventRequest
Definition: smengine.h:25
@ SmEventResume
Definition: smengine.h:26
@ SmEventCompletion
Definition: smengine.h:24

Definition at line 63 of file epsm.h.

◆ Inactive

const EndpointMachine::State EndpointMachine::Inactive
staticprivate
Initial value:
=
SM_RESULT OnInactive(_In_ EpEvent Event)
Definition: epsm.cpp:148

Definition at line 74 of file epsm.h.

◆ m_AbortForHub

BOOLEAN EndpointMachine::m_AbortForHub
private

Definition at line 217 of file epsm.h.

Referenced by Initialize(), OnAborting(), OnEnabled(), and OnOperationUnwinding().

◆ m_AfterPurge

PURGE_FOLLOW_UP EndpointMachine::m_AfterPurge
private

Definition at line 215 of file epsm.h.

Referenced by Initialize(), OnPurging(), and StartPurge().

◆ m_Enabled

BOOLEAN EndpointMachine::m_Enabled
private

Definition at line 216 of file epsm.h.

Referenced by CanStart(), Initialize(), OnCreated(), OnDisabled(), and OnEnabled().

◆ m_Endpoint

◆ m_HeldOperation

const State* EndpointMachine::m_HeldOperation
private

Definition at line 214 of file epsm.h.

Referenced by Initialize(), OnOperation(), and OnOperationUnwinding().

◆ m_PauseAfterPurge

BOOLEAN EndpointMachine::m_PauseAfterPurge
private

Definition at line 218 of file epsm.h.

Referenced by EnterPurging(), Initialize(), and OnEnabled().

◆ m_ReturnTo

◆ Operation

const EndpointMachine::State EndpointMachine::Operation
staticprivate
Initial value:
=
{ &Busy, "Operation", 0, &EndpointMachine::OnOperation, NULL }
SM_RESULT OnOperation(_In_ EpEvent Event)
Definition: epsm.cpp:360
static const State Busy
Definition: epsm.h:81

Definition at line 83 of file epsm.h.

◆ OperationHeld

const EndpointMachine::State EndpointMachine::OperationHeld
staticprivate
Initial value:
=
{ NULL, "OperationHeld", 0,
SM_RESULT EnterOperationHeld()
Definition: epsm.cpp:480
SM_RESULT OnOperationHeld(_In_ EpEvent Event)
Definition: epsm.cpp:486

Definition at line 89 of file epsm.h.

Referenced by OnOperation(), and OnOperationUnwinding().

◆ OperationUnwinding

const EndpointMachine::State EndpointMachine::OperationUnwinding
staticprivate
Initial value:
=
{ NULL, "OperationUnwinding", 0, &EndpointMachine::OnOperationUnwinding, NULL }
SM_RESULT OnOperationUnwinding(_In_ EpEvent Event)
Reset under an outstanding operation: finish it, then purge.
Definition: epsm.cpp:500

Definition at line 90 of file epsm.h.

Referenced by OnOperationHeld().

◆ Purging

const EndpointMachine::State EndpointMachine::Purging
staticprivate
Initial value:
=
SM_RESULT EnterPurging()
Definition: epsm.cpp:331
SM_RESULT OnPurging(_In_ EpEvent Event)
Definition: epsm.cpp:345

Definition at line 82 of file epsm.h.

Referenced by StartPurge().

◆ ResettingPipe

const EndpointMachine::State EndpointMachine::ResettingPipe
staticprivate
Initial value:
=
{ &Operation, "ResettingPipe", 0,
SM_RESULT OnResettingPipe(_In_ EpEvent Event)
Definition: epsm.cpp:469
SM_RESULT EnterResettingPipe()
Definition: epsm.cpp:458

Definition at line 88 of file epsm.h.

Referenced by OnDisabled(), and OnEnabled().

◆ Retired

const EndpointMachine::State EndpointMachine::Retired
staticprivate
Initial value:
=
SM_RESULT OnRetired(_In_ EpEvent Event)
Definition: epsm.cpp:242

Definition at line 77 of file epsm.h.

◆ Stale

const EndpointMachine::State EndpointMachine::Stale
staticprivate
Initial value:
=
SM_RESULT OnStale(_In_ EpEvent Event)
Definition: epsm.cpp:255

Definition at line 78 of file epsm.h.

Referenced by Retire().


The documentation for this class was generated from the following files: