Leaked source code of windows server 2003
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.

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