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.

2327 lines
53 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. pnpiop.h
  5. Abstract:
  6. This module contains the plug-and-play macros and constants.
  7. Author:
  8. Shie-Lin Tzong (shielint) 29-Jan-1995
  9. Andrew Thornton (andrewth) 5-Sept-1996
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. //
  15. // Pool tags
  16. //
  17. #define IOP_DNOD_TAG 'donD'
  18. #define IOP_DNDT_TAG 'tdnD'
  19. #define IOP_DPWR_TAG 'rwPD'
  20. //
  21. // The DEVICE_NODE is really just some extra stuff that we'd like to keep around
  22. // for each physical device object.
  23. // It is seperated from DEVOBJ_EXTENSION because these fields only apply to
  24. // PDO.
  25. //
  26. typedef enum {
  27. DOCK_NOTDOCKDEVICE,
  28. DOCK_QUIESCENT,
  29. DOCK_ARRIVING,
  30. DOCK_DEPARTING,
  31. DOCK_EJECTIRP_COMPLETED
  32. } PROFILE_STATUS;
  33. typedef enum {
  34. PROFILE_IN_PNPEVENT,
  35. PROFILE_NOT_IN_PNPEVENT,
  36. PROFILE_PERHAPS_IN_PNPEVENT
  37. } PROFILE_NOTIFICATION_TIME;
  38. typedef struct _PENDING_SET_INTERFACE_STATE {
  39. LIST_ENTRY List;
  40. UNICODE_STRING LinkName;
  41. } PENDING_SET_INTERFACE_STATE, *PPENDING_SET_INTERFACE_STATE;
  42. typedef enum _UNLOCK_UNLINK_ACTION {
  43. UnlinkRemovedDeviceNodes,
  44. UnlinkAllDeviceNodesPendingClose,
  45. UnlinkOnlyChildDeviceNodesPendingClose
  46. } UNLOCK_UNLINK_ACTION, *PUNLOCK_UNLINK_ACTION;
  47. typedef enum _PNP_DEVNODE_STATE {
  48. DeviceNodeUnspecified = 0x300, // 768
  49. DeviceNodeUninitialized, // 769
  50. DeviceNodeInitialized, // 770
  51. DeviceNodeDriversAdded, // 771
  52. DeviceNodeResourcesAssigned, // 772 - Operational state for Added
  53. DeviceNodeStartPending, // 773 - Operational state for Added
  54. DeviceNodeStartCompletion, // 774 - Operational state for Added
  55. DeviceNodeStartPostWork, // 775 - Operational state for Added
  56. DeviceNodeStarted, // 776
  57. DeviceNodeQueryStopped, // 777
  58. DeviceNodeStopped, // 778
  59. DeviceNodeRestartCompletion, // 779 - Operational state for Stopped
  60. DeviceNodeEnumeratePending, // 780 - Operational state for Started
  61. DeviceNodeEnumerateCompletion, // 781 - Operational state for Started
  62. DeviceNodeAwaitingQueuedDeletion, // 782
  63. DeviceNodeAwaitingQueuedRemoval, // 783
  64. DeviceNodeQueryRemoved, // 784
  65. DeviceNodeRemovePendingCloses, // 785
  66. DeviceNodeRemoved, // 786
  67. DeviceNodeDeletePendingCloses, // 787
  68. DeviceNodeDeleted // 788
  69. } PNP_DEVNODE_STATE, *PPNP_DEVNODE_STATE;
  70. #define STATE_HISTORY_SIZE 20
  71. typedef struct _DEVICE_NODE *PDEVICE_NODE;
  72. typedef struct _DEVICE_NODE {
  73. //
  74. // Pointer to another DEVICE_NODE with the same parent as this one.
  75. //
  76. PDEVICE_NODE Sibling;
  77. //
  78. // Pointer to the first child of this DEVICE_NODE.
  79. //
  80. PDEVICE_NODE Child;
  81. //
  82. // Pointer to this DEVICE_NODE's parent.
  83. //
  84. PDEVICE_NODE Parent;
  85. //
  86. // Pointer to the last child of the device node
  87. //
  88. PDEVICE_NODE LastChild;
  89. //
  90. // Depth of DEVICE_NODE in the tree, root is 0
  91. //
  92. ULONG Level;
  93. //
  94. // Power notification order list entry for this device node
  95. //
  96. PPO_DEVICE_NOTIFY Notify;
  97. //
  98. // State
  99. //
  100. PNP_DEVNODE_STATE State;
  101. //
  102. // Previous State
  103. //
  104. PNP_DEVNODE_STATE PreviousState;
  105. //
  106. // Previous State
  107. //
  108. PNP_DEVNODE_STATE StateHistory[STATE_HISTORY_SIZE];
  109. ULONG StateHistoryEntry;
  110. //
  111. // Completion status
  112. //
  113. NTSTATUS CompletionStatus;
  114. //
  115. // Completion status
  116. //
  117. PIRP PendingIrp;
  118. //
  119. // General flags.
  120. //
  121. ULONG Flags;
  122. //
  123. // Flags used by user-mode for volatile state which should go away on a
  124. // reboot or when the device is removed.
  125. //
  126. ULONG UserFlags;
  127. //
  128. // Problem. This is set if DNF_HAS_PROBLEM is set in Flags. Indicates
  129. // which problem exists and uses the same values as the config manager
  130. // CM_PROB_*
  131. //
  132. ULONG Problem;
  133. //
  134. // Pointer to the physical device object that this DEVICE_NODE is associated
  135. // with.
  136. //
  137. PDEVICE_OBJECT PhysicalDeviceObject;
  138. //
  139. // Pointer to the list of resources assigned to the PhysicalDeviceObject.
  140. // This is the Resource list which is passed to driver's start routine.
  141. //
  142. PCM_RESOURCE_LIST ResourceList;
  143. PCM_RESOURCE_LIST ResourceListTranslated;
  144. //
  145. // InstancePath is the path of the instance node in the registry,
  146. // i.e. <EnumBus>\<DeviceId>\<uniqueid>
  147. //
  148. UNICODE_STRING InstancePath;
  149. //
  150. // ServiceName is the name of the driver who controls the device. (Not the
  151. // driver who enumerates/creates the PDO.) This field is mainly for
  152. // convenience.
  153. //
  154. UNICODE_STRING ServiceName;
  155. //
  156. // DuplicatePDO - if the flags have DNF_DUPLICATE set then this fields indicates
  157. // the duplicate PDO which is enumerated by a bus driver. N.B. It is possible
  158. // that DNF_DUPLICATE is set but this field is NULL. In this case, it means that
  159. // we know the device is a duplicate of another device and we have not enumerated
  160. // the DuplicatePDO yet.
  161. //
  162. PDEVICE_OBJECT DuplicatePDO;
  163. //
  164. // ResourceRequirements
  165. //
  166. PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements;
  167. //
  168. // Information queried from the LEGACY_BUS_INFORMATION irp.
  169. //
  170. INTERFACE_TYPE InterfaceType;
  171. ULONG BusNumber;
  172. //
  173. // Information queried from the BUS_INFORMATION irp.
  174. //
  175. INTERFACE_TYPE ChildInterfaceType;
  176. ULONG ChildBusNumber;
  177. USHORT ChildBusTypeIndex;
  178. //
  179. // Describes the current removal policy for the device node. This is
  180. // actually type DEVICE_REMOVAL_POLICY.
  181. //
  182. UCHAR RemovalPolicy;
  183. //
  184. // Similar to above, but doesn't reflect any registry overrides.
  185. //
  186. UCHAR HardwareRemovalPolicy;
  187. //
  188. // Linked list of entries that represent each driver that has registered
  189. // for notification on this devnode. Note: drivers (and user-mode) actually
  190. // register based on a FILE_OBJECT handle, which is translated into a PDO
  191. // by sending an IRP_MN_QUERY_DEVICE_RELATIONS for TargetDeviceRelation.
  192. //
  193. LIST_ENTRY TargetDeviceNotify;
  194. //
  195. // DeviceArbiterList - A list of arbiters registered for this physical device object
  196. // Note: The Arbiters must be dereferenced when the device node is going away.
  197. //
  198. LIST_ENTRY DeviceArbiterList;
  199. //
  200. // DeviceTranslatorList - A list of translator for this physical device object
  201. // NOTE: the Translator must be dereferenced when the devic node is going away.
  202. //
  203. LIST_ENTRY DeviceTranslatorList;
  204. //
  205. // NoTranslatorMask - the bit position corresponds to resource type
  206. // if bit is set, there is no translator for the resource type in this devnode
  207. //
  208. USHORT NoTranslatorMask;
  209. //
  210. // QueryTranslatorMask - The bit position corresponds to resource type.
  211. // if bit is set, the translator for the resource type is queried.
  212. //
  213. USHORT QueryTranslatorMask;
  214. //
  215. // NoArbiterMask - the bit position corresponds to resource type
  216. // if bit is set, there is no arbiter for the resource type in this devnode
  217. //
  218. USHORT NoArbiterMask;
  219. //
  220. // QueryArbiterMask - The bit position corresponds to resource type.
  221. // if bit is set, the arbiter for the resource type is queried.
  222. //
  223. USHORT QueryArbiterMask;
  224. //
  225. // The following fields are used to track legacy resource allocation
  226. // LegacyDeviceNode - The real legacy device node.
  227. // NextResourceDeviceNode - link all the made-up device nodes which own part of
  228. // the resources from LegacyDeviceNode.
  229. //
  230. union {
  231. PDEVICE_NODE LegacyDeviceNode;
  232. PDEVICE_RELATIONS PendingDeviceRelations;
  233. } OverUsed1;
  234. union {
  235. PDEVICE_NODE NextResourceDeviceNode;
  236. } OverUsed2;
  237. //
  238. // Remember the BootResources for the device
  239. //
  240. PCM_RESOURCE_LIST BootResources;
  241. //
  242. // When Capabilities have been queried for a device (twice, once before
  243. // start and once after start) the flags are stored here in the same format
  244. // as the query capabilities IRP - use IopDeviceNodeFlagsToCapabilities to
  245. // access.
  246. //
  247. ULONG CapabilityFlags;
  248. //
  249. // Maintain a list of current dock devices and their SerialNumbers
  250. //
  251. struct {
  252. PROFILE_STATUS DockStatus;
  253. LIST_ENTRY ListEntry;
  254. PWCHAR SerialNumber;
  255. } DockInfo;
  256. //
  257. // Maintain a count to determine if either ourselves or any of
  258. // our children are stopping us from being disableable
  259. // count = myself (DNUF_NOT_DISABLEABLE) + 1 for each immediate
  260. // child that has DisableableDepends > 0
  261. //
  262. ULONG DisableableDepends;
  263. //
  264. // List of pended IoSetDeviceInterfaceState calls.
  265. // IoSetDeviceInterfaceState adds an entry to this list whenever it is
  266. // called and we haven't been started yet. Once we do the start we'll
  267. // run down the list.
  268. //
  269. LIST_ENTRY PendedSetInterfaceState;
  270. //
  271. // List of device nodes with same interface type and different bus numbers.
  272. //
  273. LIST_ENTRY LegacyBusListEntry;
  274. #if DBG_SCOPE
  275. ULONG FailureStatus;
  276. PCM_RESOURCE_LIST PreviousResourceList;
  277. PIO_RESOURCE_REQUIREMENTS_LIST PreviousResourceRequirements;
  278. #endif
  279. } DEVICE_NODE;
  280. //
  281. // A device Object is a PDO iff it has a non NULL device node (aka set by
  282. // plug and play during a query device relations.
  283. //
  284. #define IS_PDO(d) \
  285. ((NULL != (d)->DeviceObjectExtension->DeviceNode) && \
  286. (!(((PDEVICE_NODE)(d)->DeviceObjectExtension->DeviceNode)->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)))
  287. #define ASSERT_PDO(d) \
  288. do { \
  289. if ( NULL == (d)->DeviceObjectExtension->DeviceNode || \
  290. (((PDEVICE_NODE)(d)->DeviceObjectExtension->DeviceNode)->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) { \
  291. KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, PNP_ERR_INVALID_PDO, (ULONG_PTR)d, 0, 0); \
  292. } \
  293. } \
  294. while (0)
  295. //
  296. // DNF_MAKEUP - this devnode's device is created and owned by PnP manager
  297. //
  298. #define DNF_MADEUP 0x00000001
  299. //
  300. // DNF_DUPLICATE - this devnode's device is a duplicate of another enumerate PDO
  301. //
  302. #define DNF_DUPLICATE 0x00000002
  303. //
  304. // DNF_HAL_NODE - a flag to indicate which device node is the root node created by
  305. // the hal
  306. //
  307. #define DNF_HAL_NODE 0x00000004
  308. //
  309. // DNF_REENUMERATE - needs to be reenumerated
  310. //
  311. #define DNF_REENUMERATE 0x00000008
  312. //
  313. // DNF_ENUMERATED - used to track enumeration in IopEnumerateDevice()
  314. //
  315. #define DNF_ENUMERATED 0x00000010
  316. //
  317. // Singal that we need to send driver query id irps
  318. //
  319. #define DNF_IDS_QUERIED 0x00000020
  320. //
  321. // DNF_HAS_BOOT_CONFIG - the device has resource assigned by BIOS. It is considered
  322. // pseudo-started and need to participate in rebalance.
  323. //
  324. #define DNF_HAS_BOOT_CONFIG 0x00000040
  325. //
  326. // DNF_BOOT_CONFIG_RESERVED - Indicates the BOOT resources of the device are reserved.
  327. //
  328. #define DNF_BOOT_CONFIG_RESERVED 0x00000080
  329. //
  330. // DNF_NO_RESOURCE_REQUIRED - this devnode's device does not require resource.
  331. //
  332. #define DNF_NO_RESOURCE_REQUIRED 0x00000100
  333. //
  334. // DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED - to distinguished the
  335. // DeviceNode->ResourceRequirements is a filtered list or not.
  336. //
  337. #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00000200
  338. //
  339. // DNF_RESOURCE_REQUIREMENTS_CHANGED - Indicates the device's resource
  340. // requirements list has been changed.
  341. //
  342. #define DNF_RESOURCE_REQUIREMENTS_CHANGED 0x00000400
  343. //
  344. // DNF_NON_STOPPED_REBALANC - indicates the device can be restarted with new
  345. // resources without being stopped.
  346. //
  347. #define DNF_NON_STOPPED_REBALANCE 0x00000800
  348. //
  349. // The device's controlling driver is a legacy driver
  350. //
  351. #define DNF_LEGACY_DRIVER 0x00001000
  352. //
  353. // This corresponds to the user-mode CM_PROB_WILL_BE_REMOVED problem value and
  354. // the DN_WILL_BE_REMOVED status flag.
  355. //
  356. #define DNF_HAS_PROBLEM 0x00002000
  357. //
  358. // DNF_HAS_PRIVATE_PROBLEM - indicates this device reported PNP_DEVICE_FAILED
  359. // to a IRP_MN_QUERY_PNP_DEVICE_STATE without also reporting
  360. // PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED.
  361. //
  362. #define DNF_HAS_PRIVATE_PROBLEM 0x00004000
  363. //
  364. // DNF_HARDWARE_VERIFICATION is set on device nodes that have hardware
  365. // verification (probably via WHQL applet).
  366. //
  367. #define DNF_HARDWARE_VERIFICATION 0x00008000
  368. //
  369. // DNF_DEVICE_GONE is set when a pdo is no longer returned in a query bus
  370. // relations. It will then be processed as a surprise remove if started.
  371. // This flag is used to better detect when a device is resurrected, and when
  372. // processing surprise remove, to determine if the devnode should be removed
  373. // from the tree.
  374. //
  375. #define DNF_DEVICE_GONE 0x00010000
  376. //
  377. // DNF_LEGACY_RESOURCE_DEVICENODE is set for device nodes created for legacy
  378. // resource allocation.
  379. //
  380. #define DNF_LEGACY_RESOURCE_DEVICENODE 0x00020000
  381. //
  382. // DNF_NEEDS_REBALANCE is set for device nodes that trigger rebalance.
  383. //
  384. #define DNF_NEEDS_REBALANCE 0x00040000
  385. //
  386. // DNF_LOCKED_FOR_EJECT is set on device nodes that are being ejected or are
  387. // related to a device being ejected.
  388. //
  389. #define DNF_LOCKED_FOR_EJECT 0x00080000
  390. //
  391. // DNF_DRIVER_BLOCKED is set on device nodes that use one or more drivers that
  392. // have been blocked from loading.
  393. //
  394. #define DNF_DRIVER_BLOCKED 0x00100000
  395. //
  396. // DNF_CHILD_WITH_INVALID_ID is set on device nodes that has one or more children
  397. // that have invalid id(s).
  398. //
  399. #define DNF_CHILD_WITH_INVALID_ID 0x00200000
  400. //
  401. // This corresponds to the user-mode the DN_WILL_BE_REMOVED status flag.
  402. //
  403. #define DNUF_WILL_BE_REMOVED 0x00000001
  404. //
  405. // This corresponds to the user-mode DN_NO_SHOW_IN_DM status flag.
  406. //
  407. #define DNUF_DONT_SHOW_IN_UI 0x00000002
  408. //
  409. // This flag is set when user-mode lets us know that a reboot is required
  410. // for this device.
  411. //
  412. #define DNUF_NEED_RESTART 0x00000004
  413. //
  414. // This flag is set to let the user-mode know when a device can be disabled
  415. // it is still possible for this to be TRUE, yet disable to fail, as it's
  416. // a polled flag (see also PNP_DEVICE_NOT_DISABLEABLE)
  417. //
  418. #define DNUF_NOT_DISABLEABLE 0x00000008
  419. //
  420. // Flags used during shutdown when the IO Verifier is trying to remove all
  421. // PNP devices.
  422. //
  423. // DNUF_SHUTDOWN_QUERIED is set when we issue the QueryRemove to a devnode.
  424. //
  425. // DNUF_SHUTDOWN_SUBTREE_DONE is set once we've issued the QueryRemove to all
  426. // a Devnodes descendants.
  427. //
  428. #define DNUF_SHUTDOWN_QUERIED 0x00000010
  429. #define DNUF_SHUTDOWN_SUBTREE_DONE 0x00000020
  430. //
  431. // PNP Bugcheck Subcodes
  432. //
  433. #define PNP_ERR_DUPLICATE_PDO 1
  434. #define PNP_ERR_INVALID_PDO 2
  435. #define PNP_ERR_BOGUS_ID 3
  436. #define PNP_ERR_PDO_ENUMERATED_AFTER_DELETION 4
  437. #define PNP_ERR_ACTIVE_PDO_FREED 5
  438. #define PNP_ERR_DEVICE_MISSING_FROM_EJECT_LIST 6
  439. #define PNP_ERR_UNEXPECTED_ADD_RELATION_ERR 7
  440. #define MAX_INSTANCE_PATH_LENGTH 260
  441. typedef NTSTATUS (*PENUM_CALLBACK)(
  442. IN PDEVICE_NODE DeviceNode,
  443. IN PVOID Context
  444. );
  445. //
  446. // Define callback routine for PipApplyFunctionToSubKeys &
  447. // PipApplyFunctionToServiceInstances
  448. //
  449. typedef BOOLEAN (*PIOP_SUBKEY_CALLBACK_ROUTINE) (
  450. IN HANDLE,
  451. IN PUNICODE_STRING,
  452. IN OUT PVOID
  453. );
  454. //
  455. // Define context structures for Start and Add device services
  456. //
  457. #define NO_MORE_GROUP ((USHORT) -1)
  458. #define SETUP_RESERVED_GROUP 0
  459. #define BUS_DRIVER_GROUP 1
  460. typedef struct _ADD_CONTEXT {
  461. ULONG DriverStartType;
  462. } ADD_CONTEXT, *PADD_CONTEXT;
  463. typedef struct _START_CONTEXT {
  464. BOOLEAN LoadDriver;
  465. BOOLEAN NewDevice;
  466. ADD_CONTEXT AddContext;
  467. } START_CONTEXT, *PSTART_CONTEXT;
  468. //
  469. // Resource translation and allocation related structures
  470. //
  471. typedef enum _RESOURCE_HANDLER_TYPE {
  472. ResourceHandlerNull,
  473. ResourceTranslator,
  474. ResourceArbiter,
  475. ResourceLegacyDeviceDetection
  476. } RESOURCE_HANDLER_TYPE;
  477. #define PI_MAXIMUM_RESOURCE_TYPE_TRACKED 15
  478. //
  479. // Internal Arbiters tracking structures
  480. // Note the first three fields of PI_RESOURCE_ARBITER_ENTRY and PI_RESOURCE_TRANSLATOR_ENTRY
  481. // must be the same.
  482. //
  483. typedef struct _PI_RESOURCE_ARBITER_ENTRY {
  484. LIST_ENTRY DeviceArbiterList; // Link all the arbiters of a PDO.
  485. UCHAR ResourceType;
  486. PARBITER_INTERFACE ArbiterInterface;
  487. ULONG Level; // Level of the owning device.
  488. LIST_ENTRY ResourceList;
  489. LIST_ENTRY BestResourceList;
  490. LIST_ENTRY BestConfig; // Link all the arbiters which produces the best logconf
  491. LIST_ENTRY ActiveArbiterList; // Link all the arbiters under testing
  492. UCHAR State;
  493. BOOLEAN ResourcesChanged;
  494. } PI_RESOURCE_ARBITER_ENTRY, *PPI_RESOURCE_ARBITER_ENTRY;
  495. //
  496. // Define PI_RESOURCE_ARBITER_ENTRY state
  497. //
  498. #define PI_ARBITER_HAS_SOMETHING 1
  499. #define PI_ARBITER_TEST_FAILED 2
  500. //
  501. // Internal Translator tracking structures
  502. //
  503. typedef struct _PI_RESOURCE_TRANSLATOR_ENTRY {
  504. LIST_ENTRY DeviceTranslatorList;
  505. UCHAR ResourceType;
  506. PTRANSLATOR_INTERFACE TranslatorInterface;
  507. PDEVICE_NODE DeviceNode;
  508. } PI_RESOURCE_TRANSLATOR_ENTRY, *PPI_RESOURCE_TRANSLATOR_ENTRY;
  509. //
  510. // IOP_RESOURCE_REQUEST
  511. //
  512. #define QUERY_RESOURCE_LIST 0
  513. #define QUERY_RESOURCE_REQUIREMENTS 1
  514. #define REGISTRY_ALLOC_CONFIG 1
  515. #define REGISTRY_FORCED_CONFIG 2
  516. #define REGISTRY_BOOT_CONFIG 4
  517. #define REGISTRY_OVERRIDE_CONFIGVECTOR 1
  518. #define REGISTRY_BASIC_CONFIGVECTOR 2
  519. //
  520. // An array of IOP_RESOURCE_REQUEST structures is used to anchor all the
  521. // devices for which resource rerquirement is being attempted.
  522. //
  523. #define IOP_ASSIGN_RETRY 0x00000008 // Retry resource allocation later
  524. #define IOP_ASSIGN_EXCLUDE 0x00000010 // internal IopAssign flag
  525. #define IOP_ASSIGN_IGNORE 0x00000020 // ignore this request
  526. #define IOP_ASSIGN_NO_REBALANCE 0x00000080 // no rebal if assign fails
  527. #define IOP_ASSIGN_RESOURCES_RELEASED 0x00000100 // resources are released for rebalancing
  528. #define IOP_ASSIGN_KEEP_CURRENT_CONFIG 0x00000200 // Indicate non-stopped rebalance. We need to
  529. // preserved the current config.
  530. #define IOP_ASSIGN_CLEAR_RESOURCE_REQUIREMENTS_CHANGE_FLAG \
  531. 0x00000400
  532. typedef struct _IOP_RESOURCE_REQUEST {
  533. PDEVICE_OBJECT PhysicalDevice;
  534. ULONG Flags;
  535. ARBITER_REQUEST_SOURCE AllocationType;
  536. ULONG Priority; // 0 is highest priority
  537. ULONG Position; // used for sorting of entries with same priority
  538. PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements;
  539. PVOID ReqList; // PREQ_LIST
  540. PCM_RESOURCE_LIST ResourceAssignment;
  541. PCM_RESOURCE_LIST TranslatedResourceAssignment;
  542. NTSTATUS Status;
  543. } IOP_RESOURCE_REQUEST, *PIOP_RESOURCE_REQUEST;
  544. //
  545. // Misc
  546. //
  547. //
  548. // Enumeration request type
  549. //
  550. typedef enum _DEVICE_REQUEST_TYPE {
  551. AddBootDevices,
  552. AssignResources,
  553. ClearDeviceProblem,
  554. ClearEjectProblem,
  555. HaltDevice,
  556. ReenumerateBootDevices,
  557. ReenumerateDeviceOnly,
  558. ReenumerateDeviceTree,
  559. ReenumerateRootDevices,
  560. RequeryDeviceState,
  561. ResetDevice,
  562. ResourceRequirementsChanged,
  563. RestartEnumeration,
  564. SetDeviceProblem,
  565. ShutdownPnpDevices,
  566. StartDevice,
  567. StartSystemDevices
  568. } DEVICE_REQUEST_TYPE;
  569. #define CmResourceTypeReserved 0xf0
  570. //
  571. // This macro returns the pointer to the beginning of the data
  572. // area of KEY_VALUE_FULL_INFORMATION structure.
  573. // In the macro, k is a pointer to KEY_VALUE_FULL_INFORMATION structure.
  574. //
  575. #define KEY_VALUE_DATA(k) ((PCHAR)(k) + (k)->DataOffset)
  576. //
  577. // Save failure status info.
  578. //
  579. #if DBG_SCOPE
  580. #define SAVE_FAILURE_INFO(DeviceNode, Status) (DeviceNode)->FailureStatus = (Status)
  581. #else
  582. #define SAVE_FAILURE_INFO(DeviceNode, Status)
  583. #endif
  584. BOOLEAN
  585. PipAreDriversLoaded(
  586. IN PDEVICE_NODE DeviceNode
  587. );
  588. BOOLEAN
  589. PipIsDevNodeDNStarted(
  590. IN PDEVICE_NODE DeviceNode
  591. );
  592. VOID
  593. PipClearDevNodeProblem(
  594. IN PDEVICE_NODE DeviceNode
  595. );
  596. VOID
  597. PipSetDevNodeProblem(
  598. IN PDEVICE_NODE DeviceNode,
  599. IN ULONG Problem
  600. );
  601. #define PipIsRequestPending(devnode) FALSE
  602. #define PipDoesDevNodeHaveResources(devnode) \
  603. ((devnode)->ResourceList != NULL || (devnode)->BootResources != NULL || \
  604. ((devnode)->Flags & DNF_HAS_BOOT_CONFIG) != 0)
  605. #define PipDoesDevNodeHaveProblem(devnode) \
  606. ((devnode)->Flags & (DNF_HAS_PROBLEM | DNF_HAS_PRIVATE_PROBLEM))
  607. #define PipIsDevNodeProblem(devnode, problem) \
  608. (((devnode)->Flags & DNF_HAS_PROBLEM) && (devnode)->Problem == (problem))
  609. #define PipIsDevNodeDeleted(d) \
  610. ((d)->State == DeviceNodeDeletePendingCloses ||(d)->State == DeviceNodeDeleted)
  611. VOID
  612. PipSetDevNodeState(
  613. IN PDEVICE_NODE DeviceNode,
  614. IN PNP_DEVNODE_STATE State,
  615. OUT PNP_DEVNODE_STATE *OldState OPTIONAL
  616. );
  617. VOID
  618. PipRestoreDevNodeState(
  619. IN PDEVICE_NODE DeviceNode
  620. );
  621. BOOLEAN
  622. PipIsProblemReadonly(
  623. IN ULONG Problem
  624. );
  625. //++
  626. //
  627. // VOID
  628. // IopRegistryDataToUnicodeString(
  629. // OUT PUNICODE_STRING u,
  630. // IN PWCHAR p,
  631. // IN ULONG l
  632. // )
  633. //
  634. //--
  635. #define IopRegistryDataToUnicodeString(u, p, l) \
  636. { \
  637. ULONG len; \
  638. \
  639. PiRegSzToString((p), (l), &len, NULL); \
  640. (u)->Length = (USHORT)len; \
  641. (u)->MaximumLength = (USHORT)(l); \
  642. (u)->Buffer = (p); \
  643. }
  644. //
  645. // Size of scratch buffer used in this module.
  646. //
  647. #define PNP_SCRATCH_BUFFER_SIZE 512
  648. #define PNP_LARGE_SCRATCH_BUFFER_SIZE (PNP_SCRATCH_BUFFER_SIZE * 8)
  649. //
  650. // Define Device Instance Flags (used by IoQueryDeviceConfiguration apis)
  651. //
  652. #define DEVINSTANCE_FLAG_HWPROFILE_DISABLED 0x1
  653. #define DEVINSTANCE_FLAG_PNP_ENUMERATED 0x2
  654. //
  655. // Define Enumeration Control Flags (used by PipApplyFunctionToSubKeys)
  656. //
  657. #define FUNCTIONSUBKEY_FLAG_IGNORE_NON_CRITICAL_ERRORS 0x1
  658. #define FUNCTIONSUBKEY_FLAG_DELETE_SUBKEYS 0x2
  659. //
  660. // The following definitions are used in IoOpenDeviceInstanceKey
  661. //
  662. #define PLUGPLAY_REGKEY_DEVICE 1
  663. #define PLUGPLAY_REGKEY_DRIVER 2
  664. #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
  665. //
  666. // Define device extension for devices reported with IoReportDetectedDevice.
  667. //
  668. typedef struct _IOPNP_DEVICE_EXTENSION {
  669. PWCHAR CompatibleIdList;
  670. ULONG CompatibleIdListSize;
  671. } IOPNP_DEVICE_EXTENSION, *PIOPNP_DEVICE_EXTENSION;
  672. //
  673. // Reserve Boot Resources
  674. //
  675. typedef struct _IOP_RESERVED_RESOURCES_RECORD IOP_RESERVED_RESOURCES_RECORD, *PIOP_RESERVED_RESOURCES_RECORD;
  676. struct _IOP_RESERVED_RESOURCES_RECORD {
  677. PIOP_RESERVED_RESOURCES_RECORD Next;
  678. PDEVICE_OBJECT DeviceObject;
  679. PCM_RESOURCE_LIST ReservedResources;
  680. };
  681. //
  682. // External References
  683. //
  684. //
  685. // Init data
  686. //
  687. extern PVOID IopPnpScratchBuffer1;
  688. extern PVOID IopPnpScratchBuffer2;
  689. extern PCM_RESOURCE_LIST IopInitHalResources;
  690. extern PDEVICE_NODE IopInitHalDeviceNode;
  691. extern PIOP_RESERVED_RESOURCES_RECORD IopInitReservedResourceList;
  692. //
  693. // Regular data
  694. //
  695. //
  696. // IopRootDeviceNode - the head of the PnP manager's device node tree.
  697. //
  698. extern PDEVICE_NODE IopRootDeviceNode;
  699. //
  700. // IopPnPDriverObject - the madeup driver object for pnp manager
  701. //
  702. extern PDRIVER_OBJECT IopPnPDriverObject;
  703. //
  704. // IopPnPSpinLock - spinlock for Pnp code.
  705. //
  706. extern KSPIN_LOCK IopPnPSpinLock;
  707. //
  708. // IopPnpEnumerationRequestList - a link list of device enumeration requests to worker thread.
  709. //
  710. extern LIST_ENTRY IopPnpEnumerationRequestList;
  711. //
  712. // PiEngineLock - Synchronizes the start/enum and remove engines.
  713. // (Note that this is a resource as certain acquisition paths are reentrant,
  714. // specifically those that call IopNotifyPnpWhenChainDereferenced.)
  715. //
  716. extern ERESOURCE PiEngineLock;
  717. //
  718. // IopDeviceTreeLock - performs syncronization on the whole device node tree.
  719. // IopAcquireEnumerationLock acquires this lock shared then optionally
  720. // acquires an exclusive lock on a devnode.
  721. // IopAcquireDeviceTreeLock acquires this lock exclusive
  722. //
  723. extern ERESOURCE IopDeviceTreeLock;
  724. //
  725. // IopSurpriseRemoveListLock - synchronizes access to the surprise remove list.
  726. //
  727. extern ERESOURCE IopSurpriseRemoveListLock;
  728. //
  729. // PiEventQueueEmpty - Manual reset event which is set when the queue is empty
  730. //
  731. extern KEVENT PiEventQueueEmpty;
  732. //
  733. // PiEnumerationLock - to synchronize IoInvalidateDeviceRelations in boot phase.
  734. //
  735. extern KEVENT PiEnumerationLock;
  736. //
  737. // IopNumberDeviceNodes - Number of outstanding device nodes in the system
  738. //
  739. extern ULONG IopNumberDeviceNodes;
  740. //
  741. // PnPInitialized - A flag to indicate if PnP initialization is completed.
  742. //
  743. extern BOOLEAN PnPInitialized;
  744. //
  745. // PnPBootDriverInitialied
  746. //
  747. extern BOOLEAN PnPBootDriversInitialized;
  748. //
  749. // PnPBootDriverLoaded
  750. //
  751. extern BOOLEAN PnPBootDriversLoaded;
  752. //
  753. // IopBootConfigsReserved - Indicates whether we have reserved BOOT configs or not.
  754. //
  755. extern BOOLEAN IopBootConfigsReserved;
  756. //
  757. // PnpDefaultInterfaceTYpe - Use this if the interface type of resource list is unknown.
  758. //
  759. extern INTERFACE_TYPE PnpDefaultInterfaceType;
  760. //
  761. // PnpStartAsynOk - control how start irp should be handled. Synchronously or Asynchronously?
  762. //
  763. extern BOOLEAN PnpAsyncOk;
  764. //
  765. // IopPendingEjects - List of pending eject requests
  766. //
  767. extern LIST_ENTRY IopPendingEjects;
  768. //
  769. // IopPendingSurpriseRemovals - List of pending surprise removal requests
  770. //
  771. extern LIST_ENTRY IopPendingSurpriseRemovals;
  772. extern KSEMAPHORE PpRegistrySemaphore;
  773. extern BOOLEAN PpPnpShuttingDown;
  774. BOOLEAN
  775. PipIsDuplicatedDevices(
  776. IN PCM_RESOURCE_LIST Configuration1,
  777. IN PCM_RESOURCE_LIST Configuration2,
  778. IN PHAL_BUS_INFORMATION BusInfo1 OPTIONAL,
  779. IN PHAL_BUS_INFORMATION BusInfo2 OPTIONAL
  780. );
  781. BOOLEAN
  782. PipConcatenateUnicodeStrings(
  783. OUT PUNICODE_STRING Destination,
  784. IN PUNICODE_STRING String1,
  785. IN PUNICODE_STRING String2 OPTIONAL
  786. );
  787. NTSTATUS
  788. PipServiceInstanceToDeviceInstance(
  789. IN HANDLE ServiceKeyHandle OPTIONAL,
  790. IN PUNICODE_STRING ServiceKeyName OPTIONAL,
  791. IN ULONG ServiceInstanceOrdinal,
  792. OUT PUNICODE_STRING DeviceInstanceRegistryPath OPTIONAL,
  793. OUT PHANDLE DeviceInstanceHandle OPTIONAL,
  794. IN ACCESS_MASK DesiredAccess
  795. );
  796. NTSTATUS
  797. PipCreateMadeupNode(
  798. IN PUNICODE_STRING ServiceKeyName,
  799. OUT PHANDLE ReturnedHandle,
  800. OUT PUNICODE_STRING KeyName,
  801. OUT PULONG InstanceOrdinal,
  802. IN BOOLEAN ResourceOwned
  803. );
  804. NTSTATUS
  805. PipOpenServiceEnumKeys(
  806. IN PUNICODE_STRING ServiceKeyName,
  807. IN ACCESS_MASK DesiredAccess,
  808. OUT PHANDLE ServiceHandle OPTIONAL,
  809. OUT PHANDLE ServiceEnumHandle OPTIONAL,
  810. IN BOOLEAN CreateEnum
  811. );
  812. NTSTATUS
  813. IopOpenCurrentHwProfileDeviceInstanceKey(
  814. OUT PHANDLE Handle,
  815. IN PUNICODE_STRING ServiceKeyName,
  816. IN ULONG Instance,
  817. IN ACCESS_MASK DesiredAccess,
  818. IN BOOLEAN Create
  819. );
  820. NTSTATUS
  821. IopGetDeviceInstanceCsConfigFlags(
  822. IN PUNICODE_STRING DeviceInstance,
  823. OUT PULONG CsConfigFlags
  824. );
  825. NTSTATUS
  826. PipGetServiceInstanceCsConfigFlags(
  827. IN PUNICODE_STRING ServiceKeyName,
  828. IN ULONG Instance,
  829. OUT PULONG CsConfigFlags
  830. );
  831. NTSTATUS
  832. PipApplyFunctionToSubKeys(
  833. IN HANDLE BaseHandle OPTIONAL,
  834. IN PUNICODE_STRING KeyName,
  835. IN ACCESS_MASK DesiredAccess,
  836. IN ULONG Flags,
  837. IN PIOP_SUBKEY_CALLBACK_ROUTINE SubKeyCallbackRoutine,
  838. IN OUT PVOID Context
  839. );
  840. NTSTATUS
  841. PipRegMultiSzToUnicodeStrings(
  842. IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation,
  843. IN PUNICODE_STRING *UnicodeStringList,
  844. OUT PULONG UnicodeStringCount
  845. );
  846. NTSTATUS
  847. PipApplyFunctionToServiceInstances(
  848. IN HANDLE ServiceKeyHandle OPTIONAL,
  849. IN PUNICODE_STRING ServiceKeyName OPTIONAL,
  850. IN ACCESS_MASK DesiredAccess,
  851. IN BOOLEAN IgnoreNonCriticalErrors,
  852. IN PIOP_SUBKEY_CALLBACK_ROUTINE DevInstCallbackRoutine,
  853. IN OUT PVOID Context,
  854. OUT PULONG ServiceInstanceOrdinal OPTIONAL
  855. );
  856. VOID
  857. PipFreeUnicodeStringList(
  858. IN PUNICODE_STRING UnicodeStringList,
  859. IN ULONG StringCount
  860. );
  861. NTSTATUS
  862. PipReadDeviceConfiguration(
  863. IN HANDLE Handle,
  864. IN ULONG Flags,
  865. OUT PCM_RESOURCE_LIST *CmResource,
  866. OUT PULONG Length
  867. );
  868. BOOLEAN
  869. PipIsFirmwareMapperDevicePresent(
  870. IN HANDLE KeyHandle
  871. );
  872. #define PiInitializeEngineLock() \
  873. ExInitializeResourceLite(&PiEngineLock)
  874. typedef enum {
  875. PPL_SIMPLE_READ,
  876. PPL_TREEOP_ALLOW_READS,
  877. PPL_TREEOP_BLOCK_READS,
  878. PPL_TREEOP_BLOCK_READS_FROM_ALLOW
  879. } PNP_LOCK_LEVEL;
  880. VOID
  881. PpDevNodeLockTree(
  882. IN PNP_LOCK_LEVEL LockLevel
  883. );
  884. VOID
  885. PpDevNodeUnlockTree(
  886. IN PNP_LOCK_LEVEL LockLevel
  887. );
  888. #if DBG
  889. VOID
  890. PpDevNodeAssertLockLevel(
  891. IN PNP_LOCK_LEVEL LockLevel,
  892. IN PCSTR File,
  893. IN ULONG Line
  894. );
  895. #define PPDEVNODE_ASSERT_LOCK_HELD(Level) \
  896. PpDevNodeAssertLockLevel(Level, __FILE__, __LINE__)
  897. #else
  898. #define PPDEVNODE_ASSERT_LOCK_HELD(Level)
  899. #endif
  900. VOID
  901. PpDevNodeInsertIntoTree(
  902. IN PDEVICE_NODE ParentNode,
  903. IN PDEVICE_NODE DeviceNode
  904. );
  905. VOID
  906. PpDevNodeRemoveFromTree(
  907. IN PDEVICE_NODE DeviceNode
  908. );
  909. NTSTATUS
  910. PipAllocateDeviceNode(
  911. IN PDEVICE_OBJECT PhysicalDeviceObject,
  912. OUT PDEVICE_NODE *DeviceNode
  913. );
  914. NTSTATUS
  915. PipForAllDeviceNodes(
  916. IN PENUM_CALLBACK Callback,
  917. IN PVOID Context
  918. );
  919. NTSTATUS
  920. PipForDeviceNodeSubtree(
  921. IN PDEVICE_NODE DeviceNode,
  922. IN PENUM_CALLBACK Callback,
  923. IN PVOID Context
  924. );
  925. ULONG
  926. IopDetermineResourceListSize(
  927. IN PCM_RESOURCE_LIST ResourceList
  928. );
  929. PDEVICE_OBJECT
  930. IopDeviceObjectFromDeviceInstance(
  931. IN PUNICODE_STRING DeviceInstance
  932. );
  933. NTSTATUS
  934. IopMapDeviceObjectToDeviceInstance(
  935. IN PDEVICE_OBJECT DeviceObject,
  936. IN PUNICODE_STRING DeviceInstance
  937. );
  938. NTSTATUS
  939. IopDeviceObjectToDeviceInstance(
  940. IN PDEVICE_OBJECT DeviceObject,
  941. IN PHANDLE DeviceInstanceHandle,
  942. IN ACCESS_MASK DesiredAccess
  943. );
  944. BOOLEAN
  945. IopIsDeviceInstanceEnabled(
  946. IN HANDLE DeviceInstanceHandle,
  947. IN PUNICODE_STRING DeviceInstance,
  948. IN BOOLEAN DisableIfEnabled
  949. );
  950. BOOLEAN
  951. IopProcessAssignResources(
  952. IN PDEVICE_NODE DeviceNode,
  953. IN BOOLEAN Reallocation,
  954. OUT PBOOLEAN RebalancePerformed
  955. );
  956. NTSTATUS
  957. IopStartDevice (
  958. IN PDEVICE_OBJECT TargetDevice
  959. );
  960. NTSTATUS
  961. IopEjectDevice(
  962. IN PDEVICE_OBJECT DeviceObject,
  963. PPENDING_RELATIONS_LIST_ENTRY PendingEntry
  964. );
  965. NTSTATUS
  966. IopRemoveDevice(
  967. IN PDEVICE_OBJECT TargetDevice,
  968. IN ULONG IrpMinorCode
  969. );
  970. NTSTATUS
  971. IopQueryDeviceRelations(
  972. IN DEVICE_RELATION_TYPE Relations,
  973. IN PDEVICE_OBJECT DeviceObject,
  974. IN BOOLEAN Synchronous,
  975. OUT PDEVICE_RELATIONS *DeviceRelations
  976. );
  977. NTSTATUS
  978. IopQueryDeviceState(
  979. IN PDEVICE_OBJECT DeviceObject,
  980. OUT PPNP_DEVICE_STATE DeviceState
  981. );
  982. NTSTATUS
  983. PipForAllChildDeviceNodes(
  984. IN PDEVICE_NODE Parent,
  985. IN PENUM_CALLBACK Callback,
  986. IN PVOID Context
  987. );
  988. NTSTATUS
  989. IopCleanupDeviceRegistryValues(
  990. IN PUNICODE_STRING InstancePath
  991. );
  992. NTSTATUS
  993. IopQueryDeviceResources(
  994. IN PDEVICE_OBJECT DeviceObject,
  995. IN ULONG ResourceType,
  996. OUT PVOID *Resource,
  997. OUT ULONG *Length
  998. );
  999. NTSTATUS
  1000. IopGetDeviceResourcesFromRegistry (
  1001. IN PDEVICE_OBJECT DeviceObject,
  1002. IN ULONG ResourceType,
  1003. IN ULONG Preference,
  1004. OUT PVOID *Resource,
  1005. OUT PULONG Length
  1006. );
  1007. VOID
  1008. IopResourceRequirementsChanged(
  1009. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1010. IN BOOLEAN StopRequired
  1011. );
  1012. NTSTATUS
  1013. IopReleaseDeviceResources(
  1014. IN PDEVICE_NODE DeviceNode,
  1015. IN BOOLEAN ReserveResources
  1016. );
  1017. NTSTATUS
  1018. IopPnPAddDevice(
  1019. IN PDRIVER_OBJECT DriverObject,
  1020. IN PDEVICE_OBJECT DeviceObject
  1021. );
  1022. BOOLEAN
  1023. PipProcessCriticalDevice(
  1024. IN PDEVICE_NODE DeviceNode
  1025. );
  1026. NTSTATUS
  1027. IopPnPDispatch(
  1028. IN PDEVICE_OBJECT DeviceObject,
  1029. IN OUT PIRP Irp
  1030. );
  1031. NTSTATUS
  1032. IopPowerDispatch(
  1033. IN PDEVICE_OBJECT DeviceObject,
  1034. IN OUT PIRP Irp
  1035. );
  1036. VOID
  1037. IopNewDevice(
  1038. IN PDEVICE_OBJECT DeviceObject
  1039. );
  1040. NTSTATUS
  1041. IopFilterResourceRequirementsList (
  1042. IN PIO_RESOURCE_REQUIREMENTS_LIST IoList,
  1043. IN PCM_RESOURCE_LIST CmList,
  1044. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *FilteredList,
  1045. OUT PBOOLEAN ExactMatch
  1046. );
  1047. NTSTATUS
  1048. IopMergeFilteredResourceRequirementsList (
  1049. IN PIO_RESOURCE_REQUIREMENTS_LIST IoList1,
  1050. IN PIO_RESOURCE_REQUIREMENTS_LIST IoList2,
  1051. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *MergedList
  1052. );
  1053. NTSTATUS
  1054. IopMergeCmResourceLists (
  1055. IN PCM_RESOURCE_LIST List1,
  1056. IN PCM_RESOURCE_LIST List2,
  1057. IN OUT PCM_RESOURCE_LIST *MergedList
  1058. );
  1059. PIO_RESOURCE_REQUIREMENTS_LIST
  1060. IopCmResourcesToIoResources (
  1061. IN ULONG SlotNumber,
  1062. IN PCM_RESOURCE_LIST CmResourceList,
  1063. IN ULONG Priority
  1064. );
  1065. NTSTATUS
  1066. IopReportResourceListToPnp(
  1067. IN PDRIVER_OBJECT DriverObject OPTIONAL,
  1068. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  1069. IN PCM_RESOURCE_LIST ResourceList,
  1070. IN ULONG ListSize,
  1071. IN BOOLEAN Translated
  1072. );
  1073. NTSTATUS
  1074. IopAllocateResources(
  1075. IN PULONG DeviceCountP,
  1076. IN OUT PIOP_RESOURCE_REQUEST *AssignTablePP,
  1077. IN BOOLEAN Locked,
  1078. IN BOOLEAN DoBootConfigs,
  1079. OUT PBOOLEAN RebalancePerformed
  1080. );
  1081. VOID
  1082. IopInitializeResourceMap (
  1083. PLOADER_PARAMETER_BLOCK LoaderBlock
  1084. );
  1085. VOID
  1086. IopReallocateResources(
  1087. IN PDEVICE_NODE DeviceNode
  1088. );
  1089. NTSTATUS
  1090. IopWriteResourceList(
  1091. IN HANDLE ResourceMapKey,
  1092. IN PUNICODE_STRING ClassName,
  1093. IN PUNICODE_STRING DriverName,
  1094. IN PUNICODE_STRING DeviceName,
  1095. IN PCM_RESOURCE_LIST ResourceList,
  1096. IN ULONG ResourceListSize
  1097. );
  1098. VOID
  1099. IopRemoveResourceListFromPnp(
  1100. IN PLIST_ENTRY ResourceList
  1101. );
  1102. NTSTATUS
  1103. IopWriteAllocatedResourcesToRegistry (
  1104. IN PDEVICE_NODE DeviceNode,
  1105. IN PCM_RESOURCE_LIST ResourceList,
  1106. IN ULONG Length
  1107. );
  1108. USHORT
  1109. PpInitGetGroupOrderIndex(
  1110. IN HANDLE ServiceHandle
  1111. );
  1112. VOID
  1113. IopDeleteLegacyKey(
  1114. IN PDRIVER_OBJECT DriverObject
  1115. );
  1116. NTSTATUS
  1117. IopOpenDeviceParametersSubkey(
  1118. OUT HANDLE *ParamKeyHandle,
  1119. IN HANDLE ParentKeyHandle,
  1120. IN PUNICODE_STRING SubKeyString,
  1121. IN ACCESS_MASK DesiredAccess
  1122. );
  1123. NTSTATUS
  1124. PipRequestDeviceAction(
  1125. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  1126. IN DEVICE_REQUEST_TYPE RequestType,
  1127. IN BOOLEAN ReorderingBarrier,
  1128. IN ULONG_PTR Argument,
  1129. IN PKEVENT CompletionEvent OPTIONAL,
  1130. IN PNTSTATUS CompletionStatus OPTIONAL
  1131. );
  1132. VOID
  1133. PipRequestDeviceRemoval(
  1134. IN PDEVICE_NODE DeviceNode,
  1135. IN BOOLEAN TreeDeletion,
  1136. IN ULONG Problem
  1137. );
  1138. BOOLEAN
  1139. PipIsBeingRemovedSafely(
  1140. IN PDEVICE_NODE DeviceNode
  1141. );
  1142. NTSTATUS
  1143. IopRestartDeviceNode(
  1144. IN PDEVICE_NODE DeviceNode
  1145. );
  1146. VOID
  1147. PpResetProblemDevices(
  1148. IN PDEVICE_NODE DeviceNode,
  1149. IN ULONG Problem
  1150. );
  1151. NTSTATUS
  1152. IopDeleteKeyRecursive(
  1153. IN HANDLE SubKeyHandle,
  1154. IN PWCHAR SubKeyName
  1155. );
  1156. NTSTATUS
  1157. IopQueryPnpBusInformation (
  1158. IN PDEVICE_OBJECT DeviceObject,
  1159. OUT LPGUID InterfaceGuid OPTIONAL,
  1160. OUT INTERFACE_TYPE *InterfaceType OPTIONAL,
  1161. OUT ULONG *BusNumber OPTIONAL
  1162. );
  1163. NTSTATUS
  1164. IopQueryLegacyBusInformation (
  1165. IN PDEVICE_OBJECT DeviceObject,
  1166. OUT LPGUID InterfaceGuid OPTIONAL,
  1167. OUT INTERFACE_TYPE *InterfaceType OPTIONAL,
  1168. OUT ULONG *BusNumber OPTIONAL
  1169. );
  1170. NTSTATUS
  1171. IopGetRootDevices (
  1172. PDEVICE_RELATIONS *DeviceRelations
  1173. );
  1174. NTSTATUS
  1175. IopBuildRemovalRelationList(
  1176. IN PDEVICE_OBJECT DeviceObject,
  1177. IN PLUGPLAY_DEVICE_DELETE_TYPE OperationCode,
  1178. OUT PNP_VETO_TYPE *VetoType,
  1179. OUT PUNICODE_STRING VetoName,
  1180. OUT PRELATION_LIST *RelationsList
  1181. );
  1182. NTSTATUS
  1183. IopDeleteLockedDeviceNodes(
  1184. IN PDEVICE_OBJECT DeviceObject,
  1185. IN PRELATION_LIST RelationsList,
  1186. IN PLUGPLAY_DEVICE_DELETE_TYPE OperationCode,
  1187. IN BOOLEAN ProcessIndirectDescendants,
  1188. IN ULONG Problem,
  1189. OUT PNP_VETO_TYPE *VetoType OPTIONAL,
  1190. OUT PUNICODE_STRING VetoName OPTIONAL
  1191. );
  1192. VOID
  1193. IopUnlinkDeviceRemovalRelations(
  1194. IN PDEVICE_OBJECT RemovedDeviceObject,
  1195. IN OUT PRELATION_LIST RelationsList,
  1196. IN UNLOCK_UNLINK_ACTION UnlinkAction
  1197. );
  1198. NTSTATUS
  1199. IopInvalidateRelationsInList(
  1200. IN PRELATION_LIST RelationsList,
  1201. IN PLUGPLAY_DEVICE_DELETE_TYPE OperationCode,
  1202. IN BOOLEAN OnlyIndirectDescendants,
  1203. IN BOOLEAN RestartDevNode
  1204. );
  1205. BOOLEAN
  1206. IopQueuePendingEject(
  1207. PPENDING_RELATIONS_LIST_ENTRY Entry
  1208. );
  1209. VOID
  1210. IopProcessCompletedEject(
  1211. IN PVOID Context
  1212. );
  1213. VOID
  1214. IopQueuePendingSurpriseRemoval(
  1215. IN PDEVICE_OBJECT DeviceObject,
  1216. IN PRELATION_LIST List,
  1217. IN ULONG Problem
  1218. );
  1219. NTSTATUS
  1220. IopUnloadAttachedDriver(
  1221. IN PDRIVER_OBJECT DriverObject
  1222. );
  1223. BOOLEAN
  1224. IopIsAnyDeviceInstanceEnabled(
  1225. IN PUNICODE_STRING ServiceKeyName,
  1226. IN HANDLE ServiceHandle,
  1227. IN BOOLEAN LegacyIncluded
  1228. );
  1229. NTSTATUS
  1230. IopQueryResourceHandlerInterface(
  1231. IN RESOURCE_HANDLER_TYPE HandlerType,
  1232. IN PDEVICE_OBJECT DeviceObject,
  1233. IN UCHAR ResourceType,
  1234. IN OUT PVOID *Interface
  1235. );
  1236. NTSTATUS
  1237. IopQueryReconfiguration(
  1238. IN UCHAR Request,
  1239. IN PDEVICE_OBJECT DeviceObject
  1240. );
  1241. NTSTATUS
  1242. IopLegacyResourceAllocation (
  1243. IN ARBITER_REQUEST_SOURCE AllocationType,
  1244. IN PDRIVER_OBJECT DriverObject,
  1245. IN PDEVICE_OBJECT DeviceObject,
  1246. IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements,
  1247. IN OUT PCM_RESOURCE_LIST *AllocatedResources OPTIONAL
  1248. );
  1249. NTSTATUS
  1250. IoReportResourceUsageInternal(
  1251. IN ARBITER_REQUEST_SOURCE AllocationType,
  1252. IN PUNICODE_STRING DriverClassName OPTIONAL,
  1253. IN PDRIVER_OBJECT DriverObject,
  1254. IN PCM_RESOURCE_LIST DriverList OPTIONAL,
  1255. IN ULONG DriverListSize OPTIONAL,
  1256. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  1257. IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
  1258. IN ULONG DeviceListSize OPTIONAL,
  1259. IN BOOLEAN OverrideConflict,
  1260. OUT PBOOLEAN ConflictDetected
  1261. );
  1262. NTSTATUS
  1263. IopDuplicateDetection (
  1264. IN INTERFACE_TYPE LegacyBusType,
  1265. IN ULONG BusNumber,
  1266. IN ULONG SlotNumber,
  1267. OUT PDEVICE_NODE *DeviceNode
  1268. );
  1269. #if 0
  1270. NTSTATUS
  1271. IopTranslateResourceList(
  1272. IN PDEVICE_NODE DeviceNode OPTIONAL,
  1273. IN PCM_RESOURCE_LIST ResourceList,
  1274. OUT PCM_RESOURCE_LIST *TranslatedList
  1275. );
  1276. #endif
  1277. NTSTATUS
  1278. PipLoadBootFilterDriver(
  1279. IN PUNICODE_STRING DriverName,
  1280. IN ULONG GroupIndex,
  1281. OUT PDRIVER_OBJECT *LoadedFilter
  1282. );
  1283. NTSTATUS
  1284. IopQueryAndSaveDeviceNodeCapabilities (
  1285. IN PDEVICE_NODE DeviceNode
  1286. );
  1287. NTSTATUS
  1288. IopSaveDeviceCapabilities (
  1289. IN PDEVICE_NODE DeviceNode,
  1290. IN PDEVICE_CAPABILITIES Capabilities
  1291. );
  1292. NTSTATUS
  1293. PipQueryDeviceCapabilities(
  1294. IN PDEVICE_NODE DeviceNode,
  1295. OUT PDEVICE_CAPABILITIES Capabilities
  1296. );
  1297. VOID
  1298. IopIncDisableableDepends(
  1299. IN OUT PDEVICE_NODE DeviceNode
  1300. );
  1301. VOID
  1302. IopDecDisableableDepends(
  1303. IN OUT PDEVICE_NODE DeviceNode
  1304. );
  1305. NTSTATUS
  1306. IopQueryDockRemovalInterface(
  1307. IN PDEVICE_OBJECT DeviceObject,
  1308. IN OUT PDOCK_INTERFACE *DockInterface
  1309. );
  1310. #ifndef FIELD_SIZE
  1311. #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  1312. #endif
  1313. #define IopDeviceNodeFlagsToCapabilities(DeviceNode) \
  1314. ((PDEVICE_CAPABILITIES) (((PUCHAR) (&(DeviceNode)->CapabilityFlags)) - \
  1315. FIELD_OFFSET(DEVICE_CAPABILITIES, Version) - \
  1316. FIELD_SIZE(DEVICE_CAPABILITIES, Version)))
  1317. //
  1318. // BOOT allocation related declarations.
  1319. //
  1320. typedef
  1321. NTSTATUS
  1322. (*PIO_ALLOCATE_BOOT_RESOURCES_ROUTINE) (
  1323. IN ARBITER_REQUEST_SOURCE ArbiterRequestSource,
  1324. IN PDEVICE_OBJECT DeviceObject,
  1325. IN PCM_RESOURCE_LIST BootResources
  1326. );
  1327. NTSTATUS
  1328. IopAllocateBootResources (
  1329. IN ARBITER_REQUEST_SOURCE ArbiterRequestSource,
  1330. IN PDEVICE_OBJECT DeviceObject,
  1331. IN PCM_RESOURCE_LIST BootResources
  1332. );
  1333. NTSTATUS
  1334. IopReportBootResources (
  1335. IN ARBITER_REQUEST_SOURCE ArbiterRequestSource,
  1336. IN PDEVICE_OBJECT DeviceObject,
  1337. IN PCM_RESOURCE_LIST BootResources
  1338. );
  1339. NTSTATUS
  1340. IopAllocateLegacyBootResources (
  1341. IN INTERFACE_TYPE InterfaceType,
  1342. IN ULONG BusNumber
  1343. );
  1344. extern PIO_ALLOCATE_BOOT_RESOURCES_ROUTINE IopAllocateBootResourcesRoutine;
  1345. //
  1346. // Legacy Bus information related declarations.
  1347. //
  1348. extern LIST_ENTRY IopLegacyBusInformationTable[];
  1349. VOID
  1350. IopInsertLegacyBusDeviceNode (
  1351. IN PDEVICE_NODE BusDeviceNode,
  1352. IN INTERFACE_TYPE InterfaceType,
  1353. IN ULONG BusNumber
  1354. );
  1355. #define IopRemoveLegacyBusDeviceNode(d) RemoveEntryList(&((PDEVICE_NODE)d)->LegacyBusListEntry)
  1356. //
  1357. // Conflict detection declarations
  1358. //
  1359. NTSTATUS
  1360. IopQueryConflictList(
  1361. PDEVICE_OBJECT PhysicalDeviceObject,
  1362. IN PCM_RESOURCE_LIST ResourceList,
  1363. IN ULONG ResourceListSize,
  1364. OUT PPLUGPLAY_CONTROL_CONFLICT_LIST ConflictList,
  1365. IN ULONG ConflictListSize,
  1366. IN ULONG Flags
  1367. );
  1368. //
  1369. // Firmware mapper external declarations.
  1370. //
  1371. VOID
  1372. MapperProcessFirmwareTree(
  1373. IN BOOLEAN OnlyProcessSerialPorts
  1374. );
  1375. VOID
  1376. MapperConstructRootEnumTree(
  1377. IN BOOLEAN CreatePhantomDevices
  1378. );
  1379. VOID
  1380. MapperFreeList(
  1381. VOID
  1382. );
  1383. NTSTATUS
  1384. EisaBuildEisaDeviceNode(
  1385. VOID
  1386. );
  1387. VOID
  1388. MapperPhantomizeDetectedComPorts(
  1389. VOID
  1390. );
  1391. //
  1392. // General utility macros
  1393. //
  1394. //
  1395. // This macros calculates the size in bytes of a constant string
  1396. //
  1397. // ULONG
  1398. // IopConstStringSize(
  1399. // IN CONST PWSTR String
  1400. // );
  1401. //
  1402. #define IopConstStringSize(String) ( sizeof(String) - sizeof(UNICODE_NULL) )
  1403. //
  1404. // This macros calculates the number of characters of a constant string
  1405. //
  1406. // ULONG
  1407. // IopConstStringLength(
  1408. // IN CONST PWSTR String
  1409. // );
  1410. //
  1411. #define IopConstStringLength(String) ( ( sizeof(String) - sizeof(UNICODE_NULL) ) / sizeof(WCHAR) )
  1412. //
  1413. // Kernel mode notification
  1414. //
  1415. //
  1416. // This macros maps a guid to a hash value based on the number of hash
  1417. // buckets we are using. It does this by treating the guid as an array of
  1418. // 4 ULONGs, suming them and MOD by the number of hash buckets we are using.
  1419. //
  1420. // ULONG
  1421. // IopHashGuid(
  1422. // LPGUID Guid
  1423. // );
  1424. //
  1425. #define IopHashGuid(_Guid) \
  1426. ( ( ((PULONG)_Guid)[0] + ((PULONG)_Guid)[1] + ((PULONG)_Guid)[2] \
  1427. + ((PULONG)_Guid)[3]) % NOTIFY_DEVICE_CLASS_HASH_BUCKETS)
  1428. // This macros abstracts
  1429. //
  1430. // VOID
  1431. // IopAcquireNotifyLock(
  1432. // PFAST_MUTEX Lock
  1433. // )
  1434. #define IopAcquireNotifyLock(Lock) ExAcquireFastMutex(Lock);
  1435. /*
  1436. VOID
  1437. IopReleaseNotifyLock(
  1438. PFAST_MUTEX Lock
  1439. )
  1440. */
  1441. #define IopReleaseNotifyLock(Lock) ExReleaseFastMutex(Lock);
  1442. // BOOLEAN
  1443. // IopCompareGuid(
  1444. // IN LPGUID guid1,
  1445. // IN LPGUID guid2
  1446. // );
  1447. #define IopCompareGuid(g1, g2) ( (g1) == (g2) \
  1448. ? TRUE \
  1449. : RtlCompareMemory( (g1), (g2), sizeof(GUID) ) == sizeof(GUID) \
  1450. )
  1451. VOID
  1452. IopInitializePlugPlayNotification(
  1453. VOID
  1454. );
  1455. NTSTATUS
  1456. IopNotifySetupDeviceArrival(
  1457. PDEVICE_OBJECT PhysicalDeviceObject, // PDO of the device
  1458. HANDLE EnumEntryKey, // Handle into the enum branch of the registry for this device
  1459. BOOLEAN InstallDriver // Should setup attempt to install a driver
  1460. );
  1461. NTSTATUS
  1462. IopRequestHwProfileChangeNotification(
  1463. IN LPGUID EventGuid,
  1464. IN PROFILE_NOTIFICATION_TIME NotificationTime,
  1465. OUT PPNP_VETO_TYPE VetoType OPTIONAL,
  1466. OUT PUNICODE_STRING VetoName OPTIONAL
  1467. );
  1468. NTSTATUS
  1469. IopNotifyTargetDeviceChange(
  1470. IN LPCGUID EventGuid,
  1471. IN PDEVICE_OBJECT DeviceObject,
  1472. IN PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure OPTIONAL,
  1473. OUT PDRIVER_OBJECT *VetoingDriver
  1474. );
  1475. NTSTATUS
  1476. IopGetRelatedTargetDevice(
  1477. IN PFILE_OBJECT FileObject,
  1478. OUT PDEVICE_NODE *DeviceNode
  1479. );
  1480. NTSTATUS
  1481. IopNotifyDeviceClassChange(
  1482. LPGUID EventGuid,
  1483. LPGUID ClassGuid,
  1484. PUNICODE_STRING SymbolicLinkName
  1485. );
  1486. NTSTATUS
  1487. IopRegisterDeviceInterface(
  1488. IN PUNICODE_STRING DeviceInstanceName,
  1489. IN CONST GUID *InterfaceClassGuid,
  1490. IN PUNICODE_STRING ReferenceString OPTIONAL,
  1491. IN BOOLEAN UserModeFormat,
  1492. OUT PUNICODE_STRING SymbolicLinkName
  1493. );
  1494. NTSTATUS
  1495. IopUnregisterDeviceInterface(
  1496. IN PUNICODE_STRING SymbolicLinkName
  1497. );
  1498. NTSTATUS
  1499. IopRemoveDeviceInterfaces(
  1500. IN PUNICODE_STRING DeviceInstancePath
  1501. );
  1502. NTSTATUS
  1503. IopDisableDeviceInterfaces(
  1504. IN PUNICODE_STRING DeviceInstancePath
  1505. );
  1506. NTSTATUS
  1507. IopGetDeviceInterfaces(
  1508. IN CONST GUID *InterfaceClassGuid,
  1509. IN PUNICODE_STRING DevicePath OPTIONAL,
  1510. IN ULONG Flags,
  1511. IN BOOLEAN UserModeFormat,
  1512. OUT PWSTR *SymbolicLinkList,
  1513. OUT PULONG SymbolicLinkListSize OPTIONAL
  1514. );
  1515. NTSTATUS
  1516. IopDoDeferredSetInterfaceState(
  1517. IN PDEVICE_NODE DeviceNode
  1518. );
  1519. NTSTATUS
  1520. IopProcessSetInterfaceState(
  1521. IN PUNICODE_STRING SymbolicLinkName,
  1522. IN BOOLEAN Enable,
  1523. IN BOOLEAN DeferNotStarted
  1524. );
  1525. NTSTATUS
  1526. IopReplaceSeperatorWithPound(
  1527. OUT PUNICODE_STRING OutString,
  1528. IN PUNICODE_STRING InString
  1529. );
  1530. NTSTATUS
  1531. IopNotifyHwProfileChange(
  1532. IN LPGUID EventGuid,
  1533. OUT PPNP_VETO_TYPE VetoType OPTIONAL,
  1534. OUT PUNICODE_STRING VetoName OPTIONAL
  1535. );
  1536. VOID
  1537. IopUncacheInterfaceInformation(
  1538. IN PDEVICE_OBJECT DeviceObject
  1539. );
  1540. //
  1541. // Notify entry header - all notify entries have these
  1542. //
  1543. typedef struct _NOTIFY_ENTRY_HEADER {
  1544. //
  1545. // List Entry structure
  1546. //
  1547. LIST_ENTRY ListEntry;
  1548. //
  1549. // Notification event category for this notification entry.
  1550. //
  1551. IO_NOTIFICATION_EVENT_CATEGORY EventCategory;
  1552. //
  1553. // SessionId.
  1554. //
  1555. ULONG SessionId;
  1556. //
  1557. // Session space object to attach to for sending notification.
  1558. //
  1559. PVOID OpaqueSession;
  1560. //
  1561. // Callback routine passed in at registration
  1562. //
  1563. PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine;
  1564. //
  1565. // Context passed in at registration
  1566. //
  1567. PVOID Context;
  1568. //
  1569. // Driver object of the driver that registered for notifications. Required
  1570. // so we can dereference it when it unregisters
  1571. //
  1572. PDRIVER_OBJECT DriverObject;
  1573. //
  1574. // RefCount is the number of outstanding pointers to the node and avoids
  1575. // deletion while another notification is taking place
  1576. //
  1577. USHORT RefCount;
  1578. //
  1579. // Unregistered is set if this notification has been unregistered but cannot
  1580. // be removed from the list because other entities are using it
  1581. //
  1582. BOOLEAN Unregistered;
  1583. //
  1584. // Lock is a pointer to the fast mutex which is used to synchronise access
  1585. // to the list this node is a member of and is required so that the correct
  1586. // list can be locked during IoUnregisterPlugPlayNotification. If no locking
  1587. // is required it is NULL
  1588. //
  1589. PFAST_MUTEX Lock;
  1590. } NOTIFY_ENTRY_HEADER, *PNOTIFY_ENTRY_HEADER;
  1591. //
  1592. // Data to store for each target device registration
  1593. //
  1594. typedef struct _TARGET_DEVICE_NOTIFY_ENTRY {
  1595. //
  1596. // Header entries
  1597. //
  1598. LIST_ENTRY ListEntry;
  1599. IO_NOTIFICATION_EVENT_CATEGORY EventCategory;
  1600. ULONG SessionId;
  1601. PVOID OpaqueSession;
  1602. PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine;
  1603. PVOID Context;
  1604. PDRIVER_OBJECT DriverObject;
  1605. USHORT RefCount;
  1606. BOOLEAN Unregistered;
  1607. PFAST_MUTEX Lock;
  1608. //
  1609. // FileObject - the file object of the target device we are interested in
  1610. //
  1611. PFILE_OBJECT FileObject;
  1612. //
  1613. // PhysicalDeviceObject -- the PDO upon which this notification is hooked.
  1614. // We need to keep this here, so we can dereference it when the refcount
  1615. // on this notification entry drops to zero.
  1616. //
  1617. PDEVICE_OBJECT PhysicalDeviceObject;
  1618. } TARGET_DEVICE_NOTIFY_ENTRY, *PTARGET_DEVICE_NOTIFY_ENTRY;
  1619. //
  1620. // Data to store for each device class registration
  1621. //
  1622. typedef struct _DEVICE_CLASS_NOTIFY_ENTRY {
  1623. //
  1624. // Header entries
  1625. //
  1626. LIST_ENTRY ListEntry;
  1627. IO_NOTIFICATION_EVENT_CATEGORY EventCategory;
  1628. ULONG SessionId;
  1629. PVOID OpaqueSession;
  1630. PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine;
  1631. PVOID Context;
  1632. PDRIVER_OBJECT DriverObject;
  1633. USHORT RefCount;
  1634. BOOLEAN Unregistered;
  1635. PFAST_MUTEX Lock;
  1636. //
  1637. // ClassGuid - the guid of the device class we are interested in
  1638. //
  1639. GUID ClassGuid;
  1640. } DEVICE_CLASS_NOTIFY_ENTRY, *PDEVICE_CLASS_NOTIFY_ENTRY;
  1641. //
  1642. // Data to store for registration of the Reserved (ie setupdd.sys) variety
  1643. //
  1644. typedef struct _SETUP_NOTIFY_DATA {
  1645. //
  1646. // Header entries
  1647. //
  1648. LIST_ENTRY ListEntry;
  1649. IO_NOTIFICATION_EVENT_CATEGORY EventCategory;
  1650. ULONG SessionId;
  1651. PVOID OpaqueSession;
  1652. PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine;
  1653. PVOID Context;
  1654. PDRIVER_OBJECT DriverObject;
  1655. USHORT RefCount;
  1656. BOOLEAN Unregistered;
  1657. PFAST_MUTEX Lock;
  1658. } SETUP_NOTIFY_DATA, *PSETUP_NOTIFY_DATA;
  1659. //
  1660. // Data to store for registration for HardwareProfileChange Events
  1661. //
  1662. typedef struct _HWPROFILE_NOTIFY_ENTRY {
  1663. //
  1664. // Header entries
  1665. //
  1666. LIST_ENTRY ListEntry;
  1667. IO_NOTIFICATION_EVENT_CATEGORY EventCategory;
  1668. ULONG SessionId;
  1669. PVOID OpaqueSession;
  1670. PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine;
  1671. PVOID Context;
  1672. PDRIVER_OBJECT DriverObject;
  1673. USHORT RefCount;
  1674. BOOLEAN Unregistered;
  1675. PFAST_MUTEX Lock;
  1676. } HWPROFILE_NOTIFY_ENTRY, *PHWPROFILE_NOTIFY_ENTRY;
  1677. #define PNP_NOTIFICATION_VERSION 1
  1678. #define NOTIFY_DEVICE_CLASS_HASH_BUCKETS 13
  1679. //
  1680. // IopMaxDeviceNodeLevel - Level number of the DeviceNode deepest in the tree
  1681. //
  1682. extern ULONG IopMaxDeviceNodeLevel;
  1683. extern ULONG IoDeviceNodeTreeSequence;
  1684. //
  1685. // Global notification data
  1686. //
  1687. extern FAST_MUTEX IopDeviceClassNotifyLock;
  1688. extern LIST_ENTRY IopDeviceClassNotifyList[];
  1689. extern PSETUP_NOTIFY_DATA IopSetupNotifyData;
  1690. extern FAST_MUTEX IopTargetDeviceNotifyLock;
  1691. extern LIST_ENTRY IopProfileNotifyList;
  1692. extern FAST_MUTEX IopHwProfileNotifyLock;
  1693. VOID
  1694. IopProcessDeferredRegistrations(
  1695. VOID
  1696. );
  1697. //
  1698. // Generic buffer management
  1699. //
  1700. typedef struct _BUFFER_INFO {
  1701. //
  1702. // Buffer - pointer to the start of the buffer
  1703. //
  1704. PCHAR Buffer;
  1705. //
  1706. // Current - Pointer to the current position in the buffer
  1707. //
  1708. PCHAR Current;
  1709. //
  1710. // MaxSize - Maximum size of the buffer in bytes
  1711. //
  1712. ULONG MaxSize;
  1713. } BUFFER_INFO, *PBUFFER_INFO;
  1714. typedef struct _BUS_TYPE_GUID_LIST {
  1715. //
  1716. // Number of allocated guid slots in the table.
  1717. //
  1718. ULONG Count;
  1719. //
  1720. // Number of entries used so far.
  1721. //
  1722. FAST_MUTEX Lock;
  1723. //
  1724. // Array of bus type guids
  1725. //
  1726. GUID Guid[1];
  1727. } BUS_TYPE_GUID_LIST, *PBUS_TYPE_GUID_LIST;
  1728. //
  1729. // Arbiter entry points
  1730. //
  1731. NTSTATUS
  1732. IopPortInitialize(
  1733. VOID
  1734. );
  1735. NTSTATUS
  1736. IopMemInitialize(
  1737. VOID
  1738. );
  1739. NTSTATUS
  1740. IopIrqInitialize(
  1741. VOID
  1742. );
  1743. NTSTATUS
  1744. IopDmaInitialize(
  1745. VOID
  1746. );
  1747. NTSTATUS
  1748. IopBusNumberInitialize(
  1749. VOID
  1750. );
  1751. //
  1752. // Arbiter state
  1753. //
  1754. extern ARBITER_INSTANCE IopRootPortArbiter;
  1755. extern ARBITER_INSTANCE IopRootMemArbiter;
  1756. extern ARBITER_INSTANCE IopRootIrqArbiter;
  1757. extern ARBITER_INSTANCE IopRootDmaArbiter;
  1758. extern ARBITER_INSTANCE IopRootBusNumberArbiter;
  1759. //
  1760. // Buffer management routines.
  1761. //
  1762. NTSTATUS
  1763. IopAllocateBuffer(
  1764. IN PBUFFER_INFO Info,
  1765. IN ULONG Size
  1766. );
  1767. NTSTATUS
  1768. IopResizeBuffer(
  1769. IN PBUFFER_INFO Info,
  1770. IN ULONG NewSize,
  1771. IN BOOLEAN CopyContents
  1772. );
  1773. VOID
  1774. IopFreeBuffer(
  1775. IN PBUFFER_INFO Info
  1776. );
  1777. //
  1778. // UnicodeString management routines.
  1779. //
  1780. NTSTATUS
  1781. IopAllocateUnicodeString(
  1782. IN OUT PUNICODE_STRING String,
  1783. IN USHORT Length
  1784. );
  1785. VOID
  1786. IopFreeAllocatedUnicodeString(
  1787. PUNICODE_STRING String
  1788. );
  1789. //
  1790. // Misc.
  1791. //
  1792. NTSTATUS
  1793. PnPBiosGetBiosInfo(
  1794. OUT PVOID *BiosInfo,
  1795. OUT ULONG *BiosInfoLength
  1796. );
  1797. VOID
  1798. IopOrphanNotification (
  1799. PDEVICE_NODE DeviceNode
  1800. );
  1801. PVOID
  1802. PiAllocateCriticalMemory(
  1803. IN PLUGPLAY_DEVICE_DELETE_TYPE DeleteType,
  1804. IN POOL_TYPE PoolType,
  1805. IN SIZE_T Size,
  1806. IN ULONG Tag
  1807. );
  1808. //
  1809. // Warm eject externs and function prototypes
  1810. //
  1811. extern KEVENT IopWarmEjectLock;
  1812. extern PDEVICE_OBJECT IopWarmEjectPdo;
  1813. NTSTATUS
  1814. IopWarmEjectDevice(
  1815. IN PDEVICE_OBJECT DeviceToEject,
  1816. IN SYSTEM_POWER_STATE LightestSleepState
  1817. );
  1818. NTSTATUS
  1819. IopSystemControlDispatch(
  1820. IN PDEVICE_OBJECT DeviceObject,
  1821. IN OUT PIRP Irp
  1822. );
  1823. VOID
  1824. PiLockDeviceActionQueue(
  1825. VOID
  1826. );
  1827. VOID
  1828. PiUnlockDeviceActionQueue(
  1829. VOID
  1830. );