ReactOS  0.4.15-dev-3441-g67ad4e7
FxSelfManagedIoMachine Class Reference

#include <fxselfmanagediostatemachine.hpp>

Inheritance diagram for FxSelfManagedIoMachine:
Collaboration diagram for FxSelfManagedIoMachine:

Public Member Functions

 FxSelfManagedIoMachine (__in FxPkgPnp *PkgPnp)
 
VOID InitializeMachine (__in PWDF_PNPPOWER_EVENT_CALLBACKS Callbacks)
 
_Must_inspect_result_ NTSTATUS Start (VOID)
 
_Must_inspect_result_ NTSTATUS Suspend (VOID)
 
VOID Flush (VOID)
 
VOID Cleanup (VOID)
 
- Public Member Functions inherited from FxStump
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType)
 
VOID operator delete (__in PVOID pointer)
 
PVOID operator new[] (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID operator delete[] (__in PVOID pointer)
 

Static Public Member Functions

static NTSTATUS _CreateAndInit (__deref_out FxSelfManagedIoMachine **SelfManagedIoMachine, __in FxPkgPnp *PkgPnp)
 

Public Attributes

FxPnpDeviceSelfManagedIoCleanup m_DeviceSelfManagedIoCleanup
 
FxPnpDeviceSelfManagedIoFlush m_DeviceSelfManagedIoFlush
 
FxPnpDeviceSelfManagedIoInit m_DeviceSelfManagedIoInit
 
FxPnpDeviceSelfManagedIoSuspend m_DeviceSelfManagedIoSuspend
 
FxPnpDeviceSelfManagedIoRestart m_DeviceSelfManagedIoRestart
 

Protected Member Functions

_Must_inspect_result_ NTSTATUS ProcessEvent (__in FxSelfManagedIoEvents Event)
 
WDFDEVICE GetDeviceHandle (VOID)
 
- Protected Member Functions inherited from FxStump
 FxStump (VOID)
 

Static Protected Member Functions

static FxSelfManagedIoStates Init (__in FxSelfManagedIoMachine *This, __out PNTSTATUS Status)
 
static FxSelfManagedIoStates Suspending (__in FxSelfManagedIoMachine *This, __out PNTSTATUS Status)
 
static FxSelfManagedIoStates Restarting (__in FxSelfManagedIoMachine *This, __out PNTSTATUS Status)
 
static FxSelfManagedIoStates Flushing (__in FxSelfManagedIoMachine *This, __out PNTSTATUS Status)
 
static FxSelfManagedIoStates Cleanup (__in FxSelfManagedIoMachine *This, __out PNTSTATUS Status)
 

Protected Attributes

FxWaitLockInternal m_StateMachineLock
 
FxPkgPnpm_PkgPnp
 
BYTE m_CurrentState
 
UCHAR m_EventHistoryIndex
 
UCHAR m_StateHistoryIndex
 
FxSelfManagedIoMachineEventHistory m_Events
 
FxSelfManagedIoMachineStateHistory m_States
 

Static Protected Attributes

static const FxSelfManagedIoStateTable m_StateTable []
 
static const FxSelfManagedIoTargetState m_CreatedStates []
 
static const FxSelfManagedIoTargetState m_InitFailedStates []
 
static const FxSelfManagedIoTargetState m_StartedStates []
 
static const FxSelfManagedIoTargetState m_StoppedStates []
 
static const FxSelfManagedIoTargetState m_FailedStates []
 
static const FxSelfManagedIoTargetState m_FlushedStates []
 

Detailed Description

Definition at line 106 of file fxselfmanagediostatemachine.hpp.

Constructor & Destructor Documentation

◆ FxSelfManagedIoMachine()

FxSelfManagedIoMachine::FxSelfManagedIoMachine ( __in FxPkgPnp PkgPnp)

Definition at line 150 of file selfmanagediostatemachine.cpp.

153 {
154  m_PkgPnp = PkgPnp;
155 
158 
160 
161  RtlZeroMemory(&m_Events, sizeof(m_Events));
162  RtlZeroMemory(&m_States, sizeof(m_States));
163 
164  //
165  // Make sure we can fit the state into a byte
166  //
167  ASSERT(FxSelfManagedIoMax <= 0xFF);
168 }
#define ASSERT(a)
Definition: mode.c:44
FxSelfManagedIoMachineEventHistory m_Events
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
FxSelfManagedIoMachineStateHistory m_States

Referenced by _CreateAndInit().

Member Function Documentation

◆ _CreateAndInit()

NTSTATUS FxSelfManagedIoMachine::_CreateAndInit ( __deref_out FxSelfManagedIoMachine **  SelfManagedIoMachine,
__in FxPkgPnp PkgPnp 
)
static

Definition at line 171 of file selfmanagediostatemachine.cpp.

175 {
177  FxSelfManagedIoMachine * selfManagedIoMachine;
178 
179  *SelfManagedIoMachine = NULL;
180 
181  selfManagedIoMachine = new (PkgPnp->GetDriverGlobals()) FxSelfManagedIoMachine(
182  PkgPnp
183  );
184 
185  if (selfManagedIoMachine == NULL) {
187  PkgPnp->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
188  "Self managed I/O state machine allocation failed for "
189  "WDFDEVICE 0x%p",
190  PkgPnp->GetDevice()->GetHandle());
191 
193  }
194 
195  status = selfManagedIoMachine->m_StateMachineLock.Initialize();
196  if (!NT_SUCCESS(status)) {
198  PkgPnp->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
199  "Self managed I/O state machine lock initialization failed for "
200  "WDFDEVICE 0x%p, %!STATUS!",
201  PkgPnp->GetDevice()->GetHandle(),
202  status);
203 
204  delete selfManagedIoMachine;
205 
206  return status;
207  }
208 
209  *SelfManagedIoMachine = selfManagedIoMachine;
210 
211  return status;
212 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize()
Definition: fxwaitlock.hpp:235
LONG NTSTATUS
Definition: precomp.h:26
FxSelfManagedIoMachine(__in FxPkgPnp *PkgPnp)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxPkgPnp::RegisterCallbacks().

◆ Cleanup() [1/2]

VOID FxSelfManagedIoMachine::Cleanup ( VOID  )
inline

Definition at line 156 of file fxselfmanagediostatemachine.hpp.

159  {
161  }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_Must_inspect_result_ NTSTATUS ProcessEvent(__in FxSelfManagedIoEvents Event)

Referenced by FxPkgPnp::PnpEventRemovedCommonCode().

◆ Cleanup() [2/2]

FxSelfManagedIoStates FxSelfManagedIoMachine::Cleanup ( __in FxSelfManagedIoMachine This,
__out PNTSTATUS  Status 
)
staticprotected

Definition at line 446 of file selfmanagediostatemachine.cpp.

464 {
466 
467  This->m_DeviceSelfManagedIoCleanup.Invoke(This->GetDeviceHandle());
468  return FxSelfManagedIoFinal;
469 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
Status
Definition: gdiplustypes.h:24

◆ Flush()

VOID FxSelfManagedIoMachine::Flush ( VOID  )
inline

Definition at line 148 of file fxselfmanagediostatemachine.hpp.

151  {
153  }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_Must_inspect_result_ NTSTATUS ProcessEvent(__in FxSelfManagedIoEvents Event)

Referenced by FxPkgPnp::PnpCleanupForRemove().

◆ Flushing()

FxSelfManagedIoStates FxSelfManagedIoMachine::Flushing ( __in FxSelfManagedIoMachine This,
__out PNTSTATUS  Status 
)
staticprotected

Definition at line 421 of file selfmanagediostatemachine.cpp.

439 {
441  This->m_DeviceSelfManagedIoFlush.Invoke(This->GetDeviceHandle());
442  return FxSelfManagedIoFlushed;
443 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
Status
Definition: gdiplustypes.h:24

◆ GetDeviceHandle()

WDFDEVICE FxSelfManagedIoMachine::GetDeviceHandle ( VOID  )
protected

Definition at line 240 of file selfmanagediostatemachine.cpp.

243 {
244  return m_PkgPnp->GetDevice()->GetHandle();
245 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237

◆ Init()

FxSelfManagedIoStates FxSelfManagedIoMachine::Init ( __in FxSelfManagedIoMachine This,
__out PNTSTATUS  Status 
)
staticprotected

Definition at line 329 of file selfmanagediostatemachine.cpp.

347 {
348  *Status = This->m_DeviceSelfManagedIoInit.Invoke(This->GetDeviceHandle());
349 
350  if (NT_SUCCESS(*Status)) {
351  return FxSelfManagedIoStarted;
352  }
353  else {
355  }
356 }
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32

◆ InitializeMachine()

VOID FxSelfManagedIoMachine::InitializeMachine ( __in PWDF_PNPPOWER_EVENT_CALLBACKS  Callbacks)

Definition at line 216 of file selfmanagediostatemachine.cpp.

231 {
232  m_DeviceSelfManagedIoCleanup.m_Method = Callbacks->EvtDeviceSelfManagedIoCleanup;
233  m_DeviceSelfManagedIoFlush.m_Method = Callbacks->EvtDeviceSelfManagedIoFlush;
234  m_DeviceSelfManagedIoInit.m_Method = Callbacks->EvtDeviceSelfManagedIoInit;
235  m_DeviceSelfManagedIoSuspend.m_Method = Callbacks->EvtDeviceSelfManagedIoSuspend;
236  m_DeviceSelfManagedIoRestart.m_Method = Callbacks->EvtDeviceSelfManagedIoRestart;
237 }
PFN_WDF_DEVICE_SELF_MANAGED_IO_RESTART m_Method
FxPnpDeviceSelfManagedIoFlush m_DeviceSelfManagedIoFlush
FxPnpDeviceSelfManagedIoCleanup m_DeviceSelfManagedIoCleanup
PFN_WDF_DEVICE_SELF_MANAGED_IO_INIT m_Method
FxPnpDeviceSelfManagedIoInit m_DeviceSelfManagedIoInit
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
PFN_WDF_DEVICE_SELF_MANAGED_IO_FLUSH m_Method
FxPnpDeviceSelfManagedIoRestart m_DeviceSelfManagedIoRestart
FxPnpDeviceSelfManagedIoSuspend m_DeviceSelfManagedIoSuspend
PFN_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND m_Method
PFN_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP m_Method

Referenced by FxPkgPnp::RegisterCallbacks().

◆ ProcessEvent()

_Must_inspect_result_ NTSTATUS FxSelfManagedIoMachine::ProcessEvent ( __in FxSelfManagedIoEvents  Event)
protected

Definition at line 249 of file selfmanagediostatemachine.cpp.

266 {
268  FxSelfManagedIoStates newState;
270 
272 
275  (sizeof(m_Events.History)/sizeof(m_Events.History[0]));
276 
278  newState = FxSelfManagedIoMax;
279 
280  for (ULONG i = 0; i < entry->TargetStatesCount; i++) {
281  if (entry->TargetStates[i].SelfManagedIoEvent == Event) {
282  DO_EVENT_TRAP(&entry->TargetStates[i]);
283  newState = entry->TargetStates[i].SelfManagedIoState;
284  break;
285  }
286  }
287 
288  if (newState == FxSelfManagedIoMax) {
289  //
290  // We always can handle io increment/decrement from any state, but we
291  // should not be dropping any other events from this state.
292  //
293 
294  COVERAGE_TRAP();
295  }
296 
298 
299  while (newState != FxSelfManagedIoMax) {
302  "WDFDEVICE 0x%p !devobj 0x%p entering self managed io state "
303  "%!FxSelfManagedIoStates! from %!FxSelfManagedIoStates!",
306  newState, m_CurrentState);
307 
310  (sizeof(m_States.History)/sizeof(m_States.History[0]));
311 
312  m_CurrentState = (BYTE) newState;
314 
315  if (entry->StateFunc != NULL) {
316  newState = entry->StateFunc(this, &status);
317  }
318  else {
319  newState = FxSelfManagedIoMax;
320  }
321  }
322 
324 
325  return status;
326 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
static const FxSelfManagedIoStateTable m_StateTable[]
#define DO_EVENT_TRAP(x)
Definition: fxpkgpnp.hpp:61
#define COVERAGE_TRAP()
Definition: fxmacros.hpp:246
UCHAR History[FxSelfManagedIoEventQueueDepth]
unsigned char UCHAR
Definition: xmlstorage.h:181
uint32_t entry
Definition: isohybrid.c:63
unsigned char BYTE
Definition: xxhash.c:193
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
UCHAR History[FxSelfManagedIoEventQueueDepth]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
FxSelfManagedIoMachineEventHistory m_Events
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
FxSelfManagedIoMachineStateHistory m_States
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Cleanup(), Flush(), Start(), and Suspend().

◆ Restarting()

FxSelfManagedIoStates FxSelfManagedIoMachine::Restarting ( __in FxSelfManagedIoMachine This,
__out PNTSTATUS  Status 
)
staticprotected

Definition at line 390 of file selfmanagediostatemachine.cpp.

409 {
410  *Status = This->m_DeviceSelfManagedIoRestart.Invoke(This->GetDeviceHandle());
411 
412  if (NT_SUCCESS(*Status)) {
413  return FxSelfManagedIoStarted;
414  }
415  else {
416  return FxSelfManagedIoFailed;
417  }
418 }
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32

◆ Start()

_Must_inspect_result_ NTSTATUS FxSelfManagedIoMachine::Start ( VOID  )
inline

Definition at line 131 of file fxselfmanagediostatemachine.hpp.

134  {
136  }
_Must_inspect_result_ NTSTATUS ProcessEvent(__in FxSelfManagedIoEvents Event)

◆ Suspend()

_Must_inspect_result_ NTSTATUS FxSelfManagedIoMachine::Suspend ( VOID  )
inline

Definition at line 140 of file fxselfmanagediostatemachine.hpp.

143  {
145  }
_Must_inspect_result_ NTSTATUS ProcessEvent(__in FxSelfManagedIoEvents Event)

Referenced by FxPkgPnp::PowerGotoDx().

◆ Suspending()

FxSelfManagedIoStates FxSelfManagedIoMachine::Suspending ( __in FxSelfManagedIoMachine This,
__out PNTSTATUS  Status 
)
staticprotected

Definition at line 359 of file selfmanagediostatemachine.cpp.

378 {
379  *Status = This->m_DeviceSelfManagedIoSuspend.Invoke(This->GetDeviceHandle());
380 
381  if (NT_SUCCESS(*Status)) {
382  return FxSelfManagedIoStopped;
383  }
384  else {
385  return FxSelfManagedIoFailed;
386  }
387 }
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32

Member Data Documentation

◆ m_CreatedStates

◆ m_CurrentState

BYTE FxSelfManagedIoMachine::m_CurrentState
protected

Definition at line 223 of file fxselfmanagediostatemachine.hpp.

Referenced by FxSelfManagedIoMachine(), and ProcessEvent().

◆ m_DeviceSelfManagedIoCleanup

FxPnpDeviceSelfManagedIoCleanup FxSelfManagedIoMachine::m_DeviceSelfManagedIoCleanup

Definition at line 211 of file fxselfmanagediostatemachine.hpp.

Referenced by InitializeMachine().

◆ m_DeviceSelfManagedIoFlush

FxPnpDeviceSelfManagedIoFlush FxSelfManagedIoMachine::m_DeviceSelfManagedIoFlush

Definition at line 212 of file fxselfmanagediostatemachine.hpp.

Referenced by InitializeMachine().

◆ m_DeviceSelfManagedIoInit

FxPnpDeviceSelfManagedIoInit FxSelfManagedIoMachine::m_DeviceSelfManagedIoInit

Definition at line 213 of file fxselfmanagediostatemachine.hpp.

Referenced by InitializeMachine().

◆ m_DeviceSelfManagedIoRestart

FxPnpDeviceSelfManagedIoRestart FxSelfManagedIoMachine::m_DeviceSelfManagedIoRestart

Definition at line 215 of file fxselfmanagediostatemachine.hpp.

Referenced by InitializeMachine().

◆ m_DeviceSelfManagedIoSuspend

FxPnpDeviceSelfManagedIoSuspend FxSelfManagedIoMachine::m_DeviceSelfManagedIoSuspend

Definition at line 214 of file fxselfmanagediostatemachine.hpp.

Referenced by InitializeMachine().

◆ m_EventHistoryIndex

UCHAR FxSelfManagedIoMachine::m_EventHistoryIndex
protected

Definition at line 225 of file fxselfmanagediostatemachine.hpp.

Referenced by FxSelfManagedIoMachine(), and ProcessEvent().

◆ m_Events

FxSelfManagedIoMachineEventHistory FxSelfManagedIoMachine::m_Events
protected

Definition at line 231 of file fxselfmanagediostatemachine.hpp.

Referenced by FxSelfManagedIoMachine(), and ProcessEvent().

◆ m_FailedStates

const FxSelfManagedIoTargetState FxSelfManagedIoMachine::m_FailedStates
staticprotected

◆ m_FlushedStates

◆ m_InitFailedStates

const FxSelfManagedIoTargetState FxSelfManagedIoMachine::m_InitFailedStates
staticprotected

◆ m_PkgPnp

FxPkgPnp* FxSelfManagedIoMachine::m_PkgPnp
protected

◆ m_StartedStates

const FxSelfManagedIoTargetState FxSelfManagedIoMachine::m_StartedStates
staticprotected

◆ m_StateHistoryIndex

UCHAR FxSelfManagedIoMachine::m_StateHistoryIndex
protected

Definition at line 227 of file fxselfmanagediostatemachine.hpp.

Referenced by FxSelfManagedIoMachine(), and ProcessEvent().

◆ m_StateMachineLock

FxWaitLockInternal FxSelfManagedIoMachine::m_StateMachineLock
protected

Definition at line 218 of file fxselfmanagediostatemachine.hpp.

Referenced by _CreateAndInit(), and ProcessEvent().

◆ m_States

FxSelfManagedIoMachineStateHistory FxSelfManagedIoMachine::m_States
protected

Definition at line 233 of file fxselfmanagediostatemachine.hpp.

Referenced by FxSelfManagedIoMachine(), and ProcessEvent().

◆ m_StateTable

const FxSelfManagedIoStateTable FxSelfManagedIoMachine::m_StateTable
staticprotected

Definition at line 235 of file fxselfmanagediostatemachine.hpp.

Referenced by ProcessEvent().

◆ m_StoppedStates


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