ReactOS  0.4.15-dev-3303-g1ade494
_FX_DRIVER_TRACKER_CACHE_AWARE Struct Reference

#include <fxglobalskm.h>

Collaboration diagram for _FX_DRIVER_TRACKER_CACHE_AWARE:

Classes

struct  _FX_DRIVER_TRACKER_ENTRY
 

Public Member Functions

_Must_inspect_result_ NTSTATUS Initialize ()
 
VOID Uninitialize ()
 
_Must_inspect_result_ NTSTATUS Register (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID Deregister (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
__inline VOID TrackDriver (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
_Must_inspect_result_ __inline PFX_DRIVER_GLOBALS GetCurrentTrackedDriver ()
 

Private Types

typedef struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRY FX_DRIVER_TRACKER_ENTRY
 
typedef struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRYPFX_DRIVER_TRACKER_ENTRY
 

Private Member Functions

__inline PFX_DRIVER_TRACKER_ENTRY GetProcessorDriverEntryRef (__in ULONG Index)
 

Private Attributes

PFX_DRIVER_TRACKER_ENTRY m_DriverUsage
 
PVOID m_PoolToFree
 
ULONG m_EntrySize
 
ULONG m_Number
 

Detailed Description

Definition at line 348 of file fxglobalskm.h.

Member Typedef Documentation

◆ FX_DRIVER_TRACKER_ENTRY

◆ PFX_DRIVER_TRACKER_ENTRY

Member Function Documentation

◆ Deregister()

VOID FX_DRIVER_TRACKER_CACHE_AWARE::Deregister ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)

Definition at line 1183 of file fxbugcheckcallback.cpp.

1186 {
1187  ULONG index = 0;
1188  PFX_DRIVER_TRACKER_ENTRY driverUsage = NULL;
1189 
1190  //
1191  // Cleanup any refs to this driver's globals.
1192  //
1193  if (m_PoolToFree != NULL) {
1194 
1195  ASSERT(m_DriverUsage != NULL && m_Number != 0);
1196 
1197  for (index = 0; index < m_Number; ++index) {
1198  driverUsage = GetProcessorDriverEntryRef(index);
1199  if (driverUsage->FxDriverGlobals == FxDriverGlobals) {
1200  driverUsage->FxDriverGlobals = NULL;
1201  }
1202  }
1203  }
1204 }
PFX_DRIVER_TRACKER_ENTRY m_DriverUsage
Definition: fxglobalskm.h:442
__inline PFX_DRIVER_TRACKER_ENTRY GetProcessorDriverEntryRef(__in ULONG Index)
Definition: fxglobalskm.h:427
GLuint index
Definition: glext.h:6031
#define ASSERT(a)
Definition: mode.c:44
#define index(s, c)
Definition: various.h:29
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRY * PFX_DRIVER_TRACKER_ENTRY

Referenced by FxUnregisterBugCheckCallback().

◆ GetCurrentTrackedDriver()

_Must_inspect_result_ __inline PFX_DRIVER_GLOBALS _FX_DRIVER_TRACKER_CACHE_AWARE::GetCurrentTrackedDriver ( )
inline

Definition at line 405 of file fxglobalskm.h.

406  {
408 
410 
413 
414  return fxDriverGlobals;
415  }
volatile PFX_DRIVER_GLOBALS FxDriverGlobals
Definition: fxglobalskm.h:354
__inline PFX_DRIVER_TRACKER_ENTRY GetProcessorDriverEntryRef(__in ULONG Index)
Definition: fxglobalskm.h:427
FORCEINLINE ULONG KeGetCurrentProcessorIndex(VOID)
Definition: ke.h:158
#define ASSERT(a)
Definition: mode.c:44
PFX_DRIVER_GLOBALS fxDriverGlobals
#define NULL
Definition: types.h:112

Referenced by FxpBugCheckCallback().

◆ GetProcessorDriverEntryRef()

__inline PFX_DRIVER_TRACKER_ENTRY _FX_DRIVER_TRACKER_CACHE_AWARE::GetProcessorDriverEntryRef ( __in ULONG  Index)
inlineprivate

Definition at line 427 of file fxglobalskm.h.

430  {
432  Index * m_EntrySize));
433  }
PFX_DRIVER_TRACKER_ENTRY m_DriverUsage
Definition: fxglobalskm.h:442
unsigned char * PUCHAR
Definition: retypes.h:3
_In_ WDFCOLLECTION _In_ ULONG Index
struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRY * PFX_DRIVER_TRACKER_ENTRY

Referenced by Deregister(), GetCurrentTrackedDriver(), Register(), TrackDriver(), and Uninitialize().

◆ Initialize()

NTSTATUS FX_DRIVER_TRACKER_CACHE_AWARE::Initialize ( )

Definition at line 972 of file fxbugcheckcallback.cpp.

973 {
974  //
975  // Global initialization. It balances the global Uninitialize function.
976  // The real init is actually done by the Register function the first time
977  // a driver registers with the device tracker.
978  //
980  m_PoolToFree = NULL;
981  m_EntrySize = 0;
982  m_Number = 0;
983 
984  return STATUS_SUCCESS;
985 }
PFX_DRIVER_TRACKER_ENTRY m_DriverUsage
Definition: fxglobalskm.h:442
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by FxLibraryGlobalsCommission().

◆ Register()

NTSTATUS FX_DRIVER_TRACKER_CACHE_AWARE::Register ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)

Definition at line 1008 of file fxbugcheckcallback.cpp.

1011 {
1013  ULONG paddedSize = 0;
1014  ULONG index = 0;
1016  PFX_DRIVER_TRACKER_ENTRY driverUsage = NULL;
1017  UNICODE_STRING funcName;
1018  PVOID funcPtr = NULL;
1019 
1020  //
1021  // Nothing to do if tracker is already initialized. No need for a lock
1022  // here since PnP already serializes driver initialization.
1023  //
1024  if (m_PoolToFree != NULL) {
1025  ASSERT(m_DriverUsage != NULL && m_Number != 0);
1027  goto Done;
1028  }
1029 
1030  //
1031  // Intialize the procgrp down level library.
1032  //
1033  // WdmlibProcgrpInitialize(); __REACTOS__ : haha we don't support ProcGrp
1034 
1035  //
1036  // Capture maximum number of processors.
1037  //
1038  RtlInitUnicodeString(&funcName, L"KeQueryMaximumProcessorCountEx");
1039  funcPtr = MmGetSystemRoutineAddress(&funcName);
1040  if (funcPtr != NULL) {
1041  //
1042  // Win 7 and forward.
1043  //
1046  }
1047  else {
1048  RtlInitUnicodeString(&funcName, L"KeQueryMaximumProcessorCount");
1049  funcPtr = MmGetSystemRoutineAddress(&funcName);
1050  if (funcPtr != NULL) {
1051  //
1052  // Windows Server 2008.
1053  //
1055  }
1056  else {
1061  //
1062  // XP (Major=5, Minor>0) and Vista (Major=6, Minor=0).
1063  //
1064  m_Number = (ULONG)(*((CCHAR *)&KeNumberProcessors));
1065  }
1066  else {
1067  //
1068  // This feature is not supported for Windows 2000.
1069  //
1070  ASSERT(FALSE);
1072  goto Done;
1073  }
1074  }
1075  }
1076 
1077  //
1078  // Validate upper bound.
1079  //
1082  goto Done;
1083  }
1084 
1085  //
1086  // Determine padded size of each tracking entry structure.
1087  //
1088  if (m_Number > 1 ) {
1089  RtlInitUnicodeString(&funcName, L"KeGetRecommendedSharedDataAlignment");
1090  funcPtr = MmGetSystemRoutineAddress(&funcName);
1091 
1092  if (funcPtr != NULL) {
1093  //
1094  //XP and forward
1095  //
1096  paddedSize = ((PFN_KE_GET_RECOMMENDED_SHARED_DATA_ALIGNMENT)funcPtr)();
1097  ASSERT ((paddedSize & (paddedSize - 1)) == 0);
1098  }
1099  else {
1100  //
1101  // This feature is not supported for Windows 2000.
1102  //
1104  goto Done;
1105  }
1106  }
1107  else {
1108  paddedSize = sizeof(FX_DRIVER_TRACKER_ENTRY);
1109  }
1110 
1111  ASSERT(sizeof(FX_DRIVER_TRACKER_ENTRY) <= paddedSize);
1112 
1113  //
1114  // Remember the size.
1115  //
1116  m_EntrySize = paddedSize;
1117 
1119  NonPagedPool,
1120  paddedSize * m_Number,
1121  FX_TAG);
1122  if (NULL == pool) {
1124  goto Done;
1125  }
1126 
1127  //
1128  // Check if pool is aligned if this is a multi-proc.
1129  //
1130  if ((m_Number > 1) && !EXP_IS_PTR_ALIGNED_ON_BOUNDARY(pool, paddedSize)) {
1131  //
1132  // We will allocate a padded size, free the old pool.
1133  //
1134  ExFreePool(pool);
1135 
1136  //
1137  // Allocate enough padding so we can start the refs on an aligned boundary
1138  //
1140  NonPagedPool,
1141  paddedSize * m_Number + paddedSize,
1142  FX_TAG);
1143  if (NULL == pool) {
1145  goto Done;
1146  }
1147 
1148  driverUsage = (PFX_DRIVER_TRACKER_ENTRY)
1149  EXP_ALIGN_UP_PTR_ON_BOUNDARY(pool, paddedSize);
1150 
1151  }
1152  else {
1153  //
1154  // Already aligned pool.
1155  //
1156  driverUsage = pool;
1157  }
1158 
1159  //
1160  // Remember the pool block to free.
1161  //
1162  m_PoolToFree = pool;
1163  m_DriverUsage = driverUsage;
1164 
1165  //
1166  // Init driver usage entries.
1167  //
1168  for (index = 0; index < m_Number; ++index) {
1169  driverUsage = GetProcessorDriverEntryRef(index);
1170  driverUsage->FxDriverGlobals = NULL;
1171  }
1172 
1173  //
1174  // All done.
1175  //
1177 
1178 Done:
1179  return status;
1180 }
return STATUS_NOT_SUPPORTED
PFX_DRIVER_TRACKER_ENTRY m_DriverUsage
Definition: fxglobalskm.h:442
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG(STDCALL * PFN_KE_QUERY_MAXIMUM_PROCESSOR_COUNT)(VOID)
Definition: fxglobalskm.h:210
ULONG dwMinorVersion
Definition: rtltypes.h:271
LONG NTSTATUS
Definition: precomp.h:26
RTL_OSVERSIONINFOEXW OsVersionInfo
Definition: fxglobals.h:770
ULONG(STDCALL * PFN_KE_GET_RECOMMENDED_SHARED_DATA_ALIGNMENT)(VOID)
Definition: fxglobalskm.h:222
__inline PFX_DRIVER_TRACKER_ENTRY GetProcessorDriverEntryRef(__in ULONG Index)
Definition: fxglobalskm.h:427
ULONG dwMajorVersion
Definition: rtltypes.h:270
#define FALSE
Definition: types.h:117
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3514
static __inline PVOID MxAllocatePoolWithTag(__in POOL_TYPE PoolType, __in SIZE_T NumberOfBytes, __in ULONG Tag)
Definition: mxmemorykm.h:30
#define FX_DRIVER_TRACKER_MAX_CPUS
Definition: fxbugcheck.h:62
#define FX_TAG
Definition: fxmacros.hpp:155
GLuint index
Definition: glext.h:6031
#define ASSERT(a)
Definition: mode.c:44
char CCHAR
Definition: typedefs.h:51
ULONG(STDCALL * PFN_KE_QUERY_MAXIMUM_PROCESSOR_COUNT_EX)(__in USHORT GroupNumber)
Definition: fxglobalskm.h:204
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1250
FxLibraryGlobalsType FxLibraryGlobals
Definition: globals.cpp:95
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define EXP_IS_PTR_ALIGNED_ON_BOUNDARY(_pointer, _alignment)
Definition: fxbugcheck.h:38
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRY * PFX_DRIVER_TRACKER_ENTRY
struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRY FX_DRIVER_TRACKER_ENTRY
static SERVICE_STATUS status
Definition: service.c:31
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ALL_PROCESSOR_GROUPS
Definition: ntbasedef.h:644
#define EXP_ALIGN_UP_PTR_ON_BOUNDARY(_length, _alignment)
Definition: fxbugcheck.h:30
Definition: ps.c:97

Referenced by FxRegisterBugCheckCallback().

◆ TrackDriver()

__inline VOID _FX_DRIVER_TRACKER_CACHE_AWARE::TrackDriver ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)
inline

Definition at line 386 of file fxglobalskm.h.

389  {
391 
394  FxDriverGlobals;
395  }
volatile PFX_DRIVER_GLOBALS FxDriverGlobals
Definition: fxglobalskm.h:354
__inline PFX_DRIVER_TRACKER_ENTRY GetProcessorDriverEntryRef(__in ULONG Index)
Definition: fxglobalskm.h:427
FORCEINLINE ULONG KeGetCurrentProcessorIndex(VOID)
Definition: ke.h:158
#define ASSERT(a)
Definition: mode.c:44
#define NULL
Definition: types.h:112

Referenced by FX_TRACK_DRIVER().

◆ Uninitialize()

VOID FX_DRIVER_TRACKER_CACHE_AWARE::Uninitialize ( void  )

Definition at line 988 of file fxbugcheckcallback.cpp.

989 {
990  if (m_PoolToFree != NULL) {
991 
992 #ifdef DBG
993  for (ULONG index = 0; index < m_Number; ++index) {
994  PFX_DRIVER_TRACKER_ENTRY driverUsage = NULL;
995  driverUsage = GetProcessorDriverEntryRef(index);
996  ASSERT(NULL == driverUsage->FxDriverGlobals);
997  }
998 #endif
1000  m_PoolToFree = NULL;
1001  }
1002 
1003  m_DriverUsage = NULL;
1004  m_Number = 0;
1005 }
PFX_DRIVER_TRACKER_ENTRY m_DriverUsage
Definition: fxglobalskm.h:442
__inline PFX_DRIVER_TRACKER_ENTRY GetProcessorDriverEntryRef(__in ULONG Index)
Definition: fxglobalskm.h:427
static __inline VOID MxFreePool(__in PVOID Ptr)
Definition: mxmemorykm.h:41
GLuint index
Definition: glext.h:6031
#define ASSERT(a)
Definition: mode.c:44
#define index(s, c)
Definition: various.h:29
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
struct _FX_DRIVER_TRACKER_CACHE_AWARE::_FX_DRIVER_TRACKER_ENTRY * PFX_DRIVER_TRACKER_ENTRY

Referenced by FxLibraryGlobalsDecommission().

Member Data Documentation

◆ m_DriverUsage

PFX_DRIVER_TRACKER_ENTRY _FX_DRIVER_TRACKER_CACHE_AWARE::m_DriverUsage
private

◆ m_EntrySize

ULONG _FX_DRIVER_TRACKER_CACHE_AWARE::m_EntrySize
private

Definition at line 452 of file fxglobalskm.h.

Referenced by GetProcessorDriverEntryRef(), Initialize(), and Register().

◆ m_Number

ULONG _FX_DRIVER_TRACKER_CACHE_AWARE::m_Number
private

Definition at line 457 of file fxglobalskm.h.

Referenced by Deregister(), Initialize(), Register(), and Uninitialize().

◆ m_PoolToFree

PVOID _FX_DRIVER_TRACKER_CACHE_AWARE::m_PoolToFree
private

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