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.

264 lines
5.6 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. pnpdata.c
  5. Abstract:
  6. This module contains the plug-and-play data
  7. Author:
  8. Shie-Lin Tzong (shielint) 30-Jan-1995
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #include "pnpmgrp.h"
  14. #pragma hdrstop
  15. #include <initguid.h>
  16. //
  17. // INIT data segment
  18. //
  19. #ifdef ALLOC_DATA_PRAGMA
  20. #pragma data_seg("INIT")
  21. #endif
  22. PVOID IopPnpScratchBuffer1 = NULL;
  23. PCM_RESOURCE_LIST IopInitHalResources;
  24. PDEVICE_NODE IopInitHalDeviceNode;
  25. PIOP_RESERVED_RESOURCES_RECORD IopInitReservedResourceList;
  26. //
  27. // Regular data segment
  28. //
  29. #ifdef ALLOC_DATA_PRAGMA
  30. #pragma data_seg()
  31. #endif
  32. //
  33. // IopRootDeviceNode - the head of the PnP manager's device node tree.
  34. //
  35. PDEVICE_NODE IopRootDeviceNode;
  36. //
  37. // IoPnPDriverObject - the madeup driver object for pnp manager
  38. //
  39. PDRIVER_OBJECT IoPnpDriverObject;
  40. //
  41. // IopPnPSpinLock - spinlock for Pnp code.
  42. //
  43. KSPIN_LOCK IopPnPSpinLock;
  44. //
  45. // IopDeviceTreeLock - performs synchronization around the whole device node tree.
  46. //
  47. ERESOURCE IopDeviceTreeLock;
  48. //
  49. // IopSurpriseRemoveListLock - synchronizes access to the surprise remove list.
  50. //
  51. ERESOURCE IopSurpriseRemoveListLock;
  52. //
  53. // PiEngineLock - Synchronizes the start/enum and remove engines.
  54. //
  55. ERESOURCE PiEngineLock;
  56. //
  57. // PiEventQueueEmpty - Manual reset event which is set when the queue is empty
  58. //
  59. KEVENT PiEventQueueEmpty;
  60. //
  61. // PiEnumerationLock - to synchronize boot phase device enumeration
  62. //
  63. KEVENT PiEnumerationLock;
  64. //
  65. // IopNumberDeviceNodes - Number of outstanding device nodes in the system.
  66. //
  67. ULONG IopNumberDeviceNodes;
  68. //
  69. // IopPnpEnumerationRequestList - a link list of device enumeration requests to worker thread.
  70. //
  71. LIST_ENTRY IopPnpEnumerationRequestList;
  72. //
  73. // PnPInitComplete - A flag to indicate if PnP initialization is completed.
  74. //
  75. BOOLEAN PnPInitialized;
  76. //
  77. // PnPBootDriverInitialied
  78. //
  79. BOOLEAN PnPBootDriversInitialized;
  80. //
  81. // PnPBootDriverLoaded
  82. //
  83. BOOLEAN PnPBootDriversLoaded;
  84. //
  85. // IopBootConfigsReserved - Indicates whether we have reserved BOOT configs or not.
  86. //
  87. BOOLEAN IopBootConfigsReserved;
  88. //
  89. // Variable to hold boot allocation routine.
  90. //
  91. PIO_ALLOCATE_BOOT_RESOURCES_ROUTINE IopAllocateBootResourcesRoutine;
  92. //
  93. // Device node tree sequence. Is bumped every time the tree is modified or a warm
  94. // eject is queued.
  95. //
  96. ULONG IoDeviceNodeTreeSequence;
  97. //
  98. // PnpDefaultInterfaceTYpe - Use this if the interface type of resource list is unknown.
  99. //
  100. INTERFACE_TYPE PnpDefaultInterfaceType;
  101. //
  102. // IopMaxDeviceNodeLevel - Level number of the DeviceNode deepest in the tree
  103. //
  104. ULONG IopMaxDeviceNodeLevel;
  105. //
  106. // IopPendingEjects - List of pending eject requests
  107. //
  108. LIST_ENTRY IopPendingEjects;
  109. //
  110. // IopPendingSurpriseRemovals - List of pending surprise removal requests
  111. //
  112. LIST_ENTRY IopPendingSurpriseRemovals;
  113. //
  114. // Warm eject lock - only one warm eject is allowed to occur at a time
  115. //
  116. KEVENT IopWarmEjectLock;
  117. //
  118. // This field contains a devobj if a warm eject is in progress.
  119. //
  120. PDEVICE_OBJECT IopWarmEjectPdo;
  121. //
  122. // Arbiter data
  123. //
  124. ARBITER_INSTANCE IopRootPortArbiter;
  125. ARBITER_INSTANCE IopRootMemArbiter;
  126. ARBITER_INSTANCE IopRootDmaArbiter;
  127. ARBITER_INSTANCE IopRootIrqArbiter;
  128. ARBITER_INSTANCE IopRootBusNumberArbiter;
  129. //
  130. // The following resource is used to control access to device-related, Plug and Play-specific
  131. // portions of the registry. These portions are:
  132. //
  133. // HKLM\System\Enum
  134. // HKLM\System\CurrentControlSet\Hardware Profiles
  135. // HKLM\System\CurrentControlSet\Services\<service>\Enum
  136. //
  137. // It allows exclusive access for writing, as well as shared access for reading.
  138. // The resource is initialized by the PnP manager initialization code during phase 0
  139. // initialization.
  140. //
  141. ERESOURCE PpRegistryDeviceResource;
  142. //
  143. // Table for Legacy Bus information
  144. //
  145. LIST_ENTRY IopLegacyBusInformationTable[MaximumInterfaceType];
  146. //
  147. // Set to TRUE in the shutdown process. This prevents us from starting any
  148. // PNP operations once there is no longer a reasonable expectation they will
  149. // succeed.
  150. //
  151. BOOLEAN PpPnpShuttingDown;
  152. //
  153. // The following semaphore is used by the IO system when it reports resource
  154. // usage to the configuration registry on behalf of a driver. This semaphore
  155. // is initialized by the I/O system initialization code when the system is
  156. // started.
  157. //
  158. KSEMAPHORE PpRegistrySemaphore;
  159. //DEFINE_GUID(REGSTR_VALUE_LEGACY_DRIVER_CLASS_GUID, 0x8ECC055D, 0x047F, 0x11D1, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1);
  160. SYSTEM_HIVE_LIMITS PpSystemHiveLimits = {0};
  161. BOOLEAN PpSystemHiveTooLarge = FALSE;
  162. //
  163. // This is really gross.
  164. // HACK for MATROX G100 because it was too late to make this change for XP.
  165. //
  166. BOOLEAN PpCallerInitializesRequestTable = FALSE;
  167. #if DBG
  168. char *PpStateToNameTable[] = {
  169. "DeviceNodeUnspecified",
  170. "DeviceNodeUninitialized",
  171. "DeviceNodeInitialized",
  172. "DeviceNodeDriversAdded",
  173. "DeviceNodeResourcesAssigned",
  174. "DeviceNodeStartPending",
  175. "DeviceNodeStartCompletion",
  176. "DeviceNodeStartPostWork",
  177. "DeviceNodeStarted",
  178. "DeviceNodeQueryStopped",
  179. "DeviceNodeStopped",
  180. "DeviceNodeRestartCompletion",
  181. "DeviceNodeEnumeratePending",
  182. "DeviceNodeEnumerateCompletion",
  183. "DeviceNodeAwaitingQueuedDeletion",
  184. "DeviceNodeAwaitingQueuedRemoval",
  185. "DeviceNodeQueryRemoved",
  186. "DeviceNodeRemovePendingCloses",
  187. "DeviceNodeRemoved",
  188. "DeviceNodeDeletePendingCloses",
  189. "DeviceNodeDeleted"
  190. };
  191. #endif