Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

278 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. globals.c
  5. Abstract:
  6. global declarations
  7. Author:
  8. Charlie Wickham (charlwi) 22-Apr-1996
  9. Rajesh Sundaram (rajeshsu) 01-Aug-1998.
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. #include "psched.h"
  15. #pragma hdrstop
  16. #include <ntverp.h>
  17. /* External */
  18. /* Static */
  19. /* Forward */
  20. /* End Forward */
  21. ULONG InitShutdownMask;
  22. ULONG AdapterCount;
  23. ULONG DriverRefCount;
  24. DRIVER_STATE gDriverState;
  25. ULONG gEnableAvgStats = 0;
  26. ULONG gEnableWindowAdjustment = 0;
  27. NDIS_STRING gsEnableWindowAdjustment = NDIS_STRING_CONST("PSCHED");
  28. //
  29. // Lists
  30. //
  31. LIST_ENTRY AdapterList; // List of adapters
  32. LIST_ENTRY PsComponentList; // List of scheduling components.
  33. LIST_ENTRY PsProfileList; // List of scheduling profiles.
  34. //
  35. // Locks
  36. //
  37. PS_SPIN_LOCK AdapterListLock; // Protects AdapterList
  38. PS_SPIN_LOCK PsComponentListLock; // For PsCompoenentList
  39. PS_SPIN_LOCK PsProfileLock; // For PsProfileList
  40. PS_SPIN_LOCK DriverUnloadLock; // to handle unloads, unbinds, etc.
  41. //
  42. // Mutex Implementation
  43. //
  44. ULONG CreateDeviceMutex = 0;
  45. //
  46. // Handles
  47. //
  48. NDIS_HANDLE ClientProtocolHandle; // handle returned by NDIS when registering the Client
  49. NDIS_HANDLE MpWrapperHandle; // Ndis wrapper handle for MP section
  50. NDIS_HANDLE LmDriverHandle; // handle returned by NDIS when MP portion registers as LM
  51. NDIS_HANDLE PsDeviceHandle;
  52. //
  53. // PSDriverObject, PSDeviceObject - pointer to NT driver and device objects
  54. //
  55. PDRIVER_OBJECT PsDriverObject;
  56. PDEVICE_OBJECT PsDeviceObject;
  57. //
  58. // Lookaside Lists
  59. //
  60. NPAGED_LOOKASIDE_LIST NdisRequestLL; // For Ndis requests
  61. NPAGED_LOOKASIDE_LIST GpcClientVcLL; // For GPC Client VCs.
  62. //
  63. // Events
  64. //
  65. NDIS_EVENT DriverUnloadEvent;
  66. NDIS_EVENT gZAWEvent;
  67. ULONG gZAWState = ZAW_STATE_READY;
  68. //
  69. // name constants used during registration/initialization
  70. //
  71. NDIS_STRING PsSymbolicName = NDIS_STRING_CONST("\\DosDevices\\PSched");
  72. NDIS_STRING PsDriverName = NDIS_STRING_CONST("\\Device\\PSched");
  73. NDIS_STRING VcPrefix = NDIS_STRING_CONST( "VC:");
  74. NDIS_STRING WanPrefix = NDIS_STRING_CONST( "WAN:");
  75. NDIS_STRING MachineRegistryKey = NDIS_STRING_CONST( "\\Registry\\Machine\\SOFTWARE\\Policies\\Microsoft\\Windows\\PSched");
  76. NDIS_STRING PsMpName;
  77. //
  78. // Default scheduling component info
  79. //
  80. PSI_INFO TbConformerInfo = {
  81. {0, 0}, TRUE, FALSE,
  82. PS_COMPONENT_CURRENT_VERSION,
  83. NDIS_STRING_CONST( "TokenBucketConformer" ),
  84. 0, 0, 0, 0,
  85. 0, NULL, 0, NULL,
  86. 0,0,0,0,0,0,0,0,0,0
  87. };
  88. PSI_INFO ShaperInfo = {
  89. {0, 0}, TRUE, FALSE,
  90. PS_COMPONENT_CURRENT_VERSION,
  91. NDIS_STRING_CONST( "TrafficShaper" ),
  92. 0, 0, 0, 0,
  93. 0, NULL, 0, NULL,
  94. 0,0,0,0,0,0,0,0,0,0
  95. };
  96. PSI_INFO DrrSequencerInfo = {
  97. {0, 0}, TRUE, FALSE,
  98. PS_COMPONENT_CURRENT_VERSION,
  99. NDIS_STRING_CONST( "DRRSequencer" ),
  100. 0, 0, 0, 0,
  101. 0, NULL, 0, NULL,
  102. 0,0,0,0,0,0,0,0,0,0
  103. };
  104. PSI_INFO TimeStmpInfo = {
  105. {0, 0}, TRUE, FALSE,
  106. PS_COMPONENT_CURRENT_VERSION,
  107. NDIS_STRING_CONST( "TimeStmp" ),
  108. 0, 0, 0, 0,
  109. 0, NULL, 0, NULL,
  110. 0,0,0,0,0,0,0,0,0,0
  111. };
  112. PSI_INFO SchedulerStubInfo = {
  113. {0, 0}, TRUE, FALSE,
  114. PS_COMPONENT_CURRENT_VERSION,
  115. NDIS_STRING_CONST( "SchedulerStub" ),
  116. 0, 0, 0, 0,
  117. 0, NULL, 0, NULL,
  118. 0,0,0,0,0,0,0,0,0,0
  119. };
  120. //
  121. // Known component configurations
  122. //
  123. PS_PROFILE DefaultSchedulerConfig = {
  124. {0, 0},
  125. 0,
  126. NDIS_STRING_CONST( "DefaultSchedulerConfig" ),
  127. 4,
  128. {&TbConformerInfo,
  129. &DrrSequencerInfo,
  130. &TimeStmpInfo,
  131. &SchedulerStubInfo
  132. }
  133. };
  134. //
  135. // PS Procs for scheduler
  136. //
  137. PS_PROCS PsProcs;
  138. //
  139. // For the logging support
  140. //
  141. PVOID SchedTraceThreshContext;
  142. NDIS_SPIN_LOCK GlobalLoggingLock;
  143. ULONG SchedTraceIndex = 0;
  144. ULONG SchedBufferSize = 0;
  145. ULONG SchedTraced = 0;
  146. UCHAR *SchedTraceBuffer = 0;
  147. ULONG SchedTraceBytesUnread = 0;
  148. ULONG SchedTraceThreshold = 0xffffffff;
  149. SCHEDTRACE_THRESH_PROC SchedTraceThreshProc = NULL;
  150. BOOLEAN TraceBufferAllocated = FALSE;
  151. BOOLEAN WMIInitialized = FALSE;
  152. // Timer
  153. ULONG gTimerResolutionActualTime = 0;
  154. ULONG gTimerSet = 0;
  155. // GPC VC state machine
  156. #if DBG
  157. PUCHAR GpcVcState[] = {
  158. "ERROR_STATE",
  159. "CL_VC_INITIALIZED",
  160. "CL_CALL_PENDING",
  161. "CL_INTERNAL_CALL_COMPLETE",
  162. "CL_CALL_COMPLETE",
  163. "CL_MODIFY_PENDING",
  164. "CL_GPC_CLOSE_PENDING",
  165. "CL_NDIS_CLOSE_PENDING",
  166. "CL_WAITING_FOR_PENDING_PACKETS"
  167. };
  168. #endif
  169. //
  170. // GPC Interface
  171. //
  172. GPC_EXPORTED_CALLS GpcEntries;
  173. GPC_HANDLE GpcQosClientHandle;
  174. #if CBQ
  175. GPC_HANDLE GpcClassMapClientHandle;
  176. #endif
  177. PS_DEVICE_STATE DeviceState = PS_DEVICE_STATE_READY;
  178. //
  179. // TAGS
  180. //
  181. ULONG NdisRequestTag = '0CSP';
  182. ULONG GpcClientVcTag = '1CSP';
  183. ULONG WanLinkTag = '2CSP';
  184. ULONG PsMiscTag = '3CSP';
  185. ULONG WanTableTag = '4CSP';
  186. ULONG WMITag = 'hCSP';
  187. ULONG AdapterTag = 'aCSP';
  188. ULONG CmParamsTag = 'bCSP';
  189. ULONG PipeContextTag = 'cCSP';
  190. ULONG FlowContextTag = 'dCSP';
  191. ULONG ClassMapContextTag = 'eCSP';
  192. ULONG ProfileTag = 'fCSP';
  193. ULONG ComponentTag = 'gCSP';
  194. ULONG TimerTag = 'zCSP';
  195. ULONG TsTag = 'tCSP';
  196. #if DBG
  197. CHAR VersionNumber[] = "0.300";
  198. CHAR VersionHerald[] = "PSched: Packet Scheduler Version %s built on %s\n";
  199. CHAR VersionTimestamp[] = __DATE__ " " __TIME__;
  200. ULONG DbgTraceLevel;
  201. ULONG DbgTraceMask;
  202. ULONG LogTraceLevel;
  203. ULONG LogTraceMask;
  204. ULONG LogId = LAST_LOG_ID;
  205. #endif
  206. //
  207. // NULL Component hacks for now [ShreeM]
  208. //
  209. PS_RECEIVE_PACKET TimeStmpRecvPacket = NULL;
  210. PS_RECEIVE_INDICATION TimeStmpRecvIndication = NULL;
  211. PULONG_PTR g_WanLinkTable;
  212. USHORT g_NextWanIndex;
  213. USHORT g_WanTableSize;
  214. /* end globals.c */