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.

1239 lines
31 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. pnp.h
  5. Abstract:
  6. This module contains the internal structure definitions and APIs used by
  7. the kernel-mode Plug and Play manager.
  8. This file is included by including "ntos.h".
  9. Author:
  10. Lonny McMichael (lonnym) 02/09/95
  11. Revision History:
  12. --*/
  13. #ifndef _PNP_
  14. #define _PNP_
  15. //
  16. // The following global variables provide/control access to PnP Manager data.
  17. //
  18. extern ERESOURCE PpRegistryDeviceResource;
  19. extern PDRIVER_OBJECT IoPnpDriverObject;
  20. // begin_ntddk begin_nthal begin_ntifs begin_wdm begin_ntosp
  21. //
  22. // Define PnP Device Property for IoGetDeviceProperty
  23. //
  24. typedef enum {
  25. DevicePropertyDeviceDescription,
  26. DevicePropertyHardwareID,
  27. DevicePropertyCompatibleIDs,
  28. DevicePropertyBootConfiguration,
  29. DevicePropertyBootConfigurationTranslated,
  30. DevicePropertyClassName,
  31. DevicePropertyClassGuid,
  32. DevicePropertyDriverKeyName,
  33. DevicePropertyManufacturer,
  34. DevicePropertyFriendlyName,
  35. DevicePropertyLocationInformation,
  36. DevicePropertyPhysicalDeviceObjectName,
  37. DevicePropertyBusTypeGuid,
  38. DevicePropertyLegacyBusType,
  39. DevicePropertyBusNumber,
  40. DevicePropertyEnumeratorName,
  41. DevicePropertyAddress,
  42. DevicePropertyUINumber,
  43. DevicePropertyInstallState,
  44. DevicePropertyRemovalPolicy
  45. } DEVICE_REGISTRY_PROPERTY;
  46. typedef BOOLEAN (*PTRANSLATE_BUS_ADDRESS)(
  47. IN PVOID Context,
  48. IN PHYSICAL_ADDRESS BusAddress,
  49. IN ULONG Length,
  50. IN OUT PULONG AddressSpace,
  51. OUT PPHYSICAL_ADDRESS TranslatedAddress
  52. );
  53. typedef struct _DMA_ADAPTER *(*PGET_DMA_ADAPTER)(
  54. IN PVOID Context,
  55. IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
  56. OUT PULONG NumberOfMapRegisters
  57. );
  58. typedef ULONG (*PGET_SET_DEVICE_DATA)(
  59. IN PVOID Context,
  60. IN ULONG DataType,
  61. IN PVOID Buffer,
  62. IN ULONG Offset,
  63. IN ULONG Length
  64. );
  65. typedef enum _DEVICE_INSTALL_STATE {
  66. InstallStateInstalled,
  67. InstallStateNeedsReinstall,
  68. InstallStateFailedInstall,
  69. InstallStateFinishInstall
  70. } DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE;
  71. //
  72. // Define structure returned in response to IRP_MN_QUERY_BUS_INFORMATION by a
  73. // PDO indicating the type of bus the device exists on.
  74. //
  75. typedef struct _PNP_BUS_INFORMATION {
  76. GUID BusTypeGuid;
  77. INTERFACE_TYPE LegacyBusType;
  78. ULONG BusNumber;
  79. } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
  80. //
  81. // Define structure returned in response to IRP_MN_QUERY_LEGACY_BUS_INFORMATION
  82. // by an FDO indicating the type of bus it is. This is normally the same bus
  83. // type as the device's children (i.e., as retrieved from the child PDO's via
  84. // IRP_MN_QUERY_BUS_INFORMATION) except for cases like CardBus, which can
  85. // support both 16-bit (PCMCIABus) and 32-bit (PCIBus) cards.
  86. //
  87. typedef struct _LEGACY_BUS_INFORMATION {
  88. GUID BusTypeGuid;
  89. INTERFACE_TYPE LegacyBusType;
  90. ULONG BusNumber;
  91. } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
  92. //
  93. // Defines for IoGetDeviceProperty(DevicePropertyRemovalPolicy).
  94. //
  95. typedef enum _DEVICE_REMOVAL_POLICY {
  96. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  97. RemovalPolicyNotDetermined = 0,
  98. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  99. RemovalPolicyExpectNoRemoval = 1,
  100. RemovalPolicyExpectOrderlyRemoval = 2,
  101. RemovalPolicyExpectSurpriseRemoval = 3
  102. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  103. ,
  104. RemovalPolicySuggestOrderlyRemoval = 4,
  105. RemovalPolicySuggestSurpriseRemoval = 5,
  106. RemovalPolicyUnspecified = 6
  107. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  108. } DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY;
  109. typedef struct _BUS_INTERFACE_STANDARD {
  110. //
  111. // generic interface header
  112. //
  113. USHORT Size;
  114. USHORT Version;
  115. PVOID Context;
  116. PINTERFACE_REFERENCE InterfaceReference;
  117. PINTERFACE_DEREFERENCE InterfaceDereference;
  118. //
  119. // standard bus interfaces
  120. //
  121. PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
  122. PGET_DMA_ADAPTER GetDmaAdapter;
  123. PGET_SET_DEVICE_DATA SetBusData;
  124. PGET_SET_DEVICE_DATA GetBusData;
  125. } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
  126. //
  127. // The following definitions are used in ACPI QueryInterface
  128. //
  129. typedef BOOLEAN (* PGPE_SERVICE_ROUTINE) (
  130. PVOID,
  131. PVOID);
  132. typedef NTSTATUS (* PGPE_CONNECT_VECTOR) (
  133. PDEVICE_OBJECT,
  134. ULONG,
  135. KINTERRUPT_MODE,
  136. BOOLEAN,
  137. PGPE_SERVICE_ROUTINE,
  138. PVOID,
  139. PVOID);
  140. typedef NTSTATUS (* PGPE_DISCONNECT_VECTOR) (
  141. PVOID);
  142. typedef NTSTATUS (* PGPE_ENABLE_EVENT) (
  143. PDEVICE_OBJECT,
  144. PVOID);
  145. typedef NTSTATUS (* PGPE_DISABLE_EVENT) (
  146. PDEVICE_OBJECT,
  147. PVOID);
  148. typedef NTSTATUS (* PGPE_CLEAR_STATUS) (
  149. PDEVICE_OBJECT,
  150. PVOID);
  151. typedef VOID (* PDEVICE_NOTIFY_CALLBACK) (
  152. PVOID,
  153. ULONG);
  154. typedef NTSTATUS (* PREGISTER_FOR_DEVICE_NOTIFICATIONS) (
  155. PDEVICE_OBJECT,
  156. PDEVICE_NOTIFY_CALLBACK,
  157. PVOID);
  158. typedef void (* PUNREGISTER_FOR_DEVICE_NOTIFICATIONS) (
  159. PDEVICE_OBJECT,
  160. PDEVICE_NOTIFY_CALLBACK);
  161. typedef struct _ACPI_INTERFACE_STANDARD {
  162. //
  163. // Generic interface header
  164. //
  165. USHORT Size;
  166. USHORT Version;
  167. PVOID Context;
  168. PINTERFACE_REFERENCE InterfaceReference;
  169. PINTERFACE_DEREFERENCE InterfaceDereference;
  170. //
  171. // ACPI interfaces
  172. //
  173. PGPE_CONNECT_VECTOR GpeConnectVector;
  174. PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
  175. PGPE_ENABLE_EVENT GpeEnableEvent;
  176. PGPE_DISABLE_EVENT GpeDisableEvent;
  177. PGPE_CLEAR_STATUS GpeClearStatus;
  178. PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
  179. PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
  180. } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
  181. // end_wdm end_ntddk
  182. typedef enum _ACPI_REG_TYPE {
  183. PM1a_ENABLE,
  184. PM1b_ENABLE,
  185. PM1a_STATUS,
  186. PM1b_STATUS,
  187. PM1a_CONTROL,
  188. PM1b_CONTROL,
  189. GP_STATUS,
  190. GP_ENABLE,
  191. SMI_CMD,
  192. MaxRegType
  193. } ACPI_REG_TYPE, *PACPI_REG_TYPE;
  194. typedef USHORT (*PREAD_ACPI_REGISTER) (
  195. IN ACPI_REG_TYPE AcpiReg,
  196. IN ULONG Register);
  197. typedef VOID (*PWRITE_ACPI_REGISTER) (
  198. IN ACPI_REG_TYPE AcpiReg,
  199. IN ULONG Register,
  200. IN USHORT Value
  201. );
  202. typedef struct ACPI_REGS_INTERFACE_STANDARD {
  203. //
  204. // generic interface header
  205. //
  206. USHORT Size;
  207. USHORT Version;
  208. PVOID Context;
  209. PINTERFACE_REFERENCE InterfaceReference;
  210. PINTERFACE_DEREFERENCE InterfaceDereference;
  211. //
  212. // READ/WRITE_ACPI_REGISTER functions
  213. //
  214. PREAD_ACPI_REGISTER ReadAcpiRegister;
  215. PWRITE_ACPI_REGISTER WriteAcpiRegister;
  216. } ACPI_REGS_INTERFACE_STANDARD, *PACPI_REGS_INTERFACE_STANDARD;
  217. typedef NTSTATUS (*PHAL_QUERY_ALLOCATE_PORT_RANGE) (
  218. IN BOOLEAN IsSparse,
  219. IN BOOLEAN PrimaryIsMmio,
  220. IN PVOID VirtBaseAddr OPTIONAL,
  221. IN PHYSICAL_ADDRESS PhysBaseAddr, // Only valid if PrimaryIsMmio = TRUE
  222. IN ULONG Length, // Only valid if PrimaryIsMmio = TRUE
  223. OUT PUSHORT NewRangeId
  224. );
  225. typedef VOID (*PHAL_FREE_PORT_RANGE)(
  226. IN USHORT RangeId
  227. );
  228. typedef struct _HAL_PORT_RANGE_INTERFACE {
  229. //
  230. // generic interface header
  231. //
  232. USHORT Size;
  233. USHORT Version;
  234. PVOID Context;
  235. PINTERFACE_REFERENCE InterfaceReference;
  236. PINTERFACE_DEREFERENCE InterfaceDereference;
  237. //
  238. // QueryAllocateRange/FreeRange functions
  239. //
  240. PHAL_QUERY_ALLOCATE_PORT_RANGE QueryAllocateRange;
  241. PHAL_FREE_PORT_RANGE FreeRange;
  242. } HAL_PORT_RANGE_INTERFACE, *PHAL_PORT_RANGE_INTERFACE;
  243. //
  244. // describe the CMOS HAL interface
  245. //
  246. typedef enum _CMOS_DEVICE_TYPE {
  247. CmosTypeStdPCAT,
  248. CmosTypeIntelPIIX4,
  249. CmosTypeDal1501
  250. } CMOS_DEVICE_TYPE;
  251. typedef
  252. ULONG
  253. (*PREAD_ACPI_CMOS) (
  254. IN CMOS_DEVICE_TYPE CmosType,
  255. IN ULONG SourceAddress,
  256. IN PUCHAR DataBuffer,
  257. IN ULONG ByteCount
  258. );
  259. typedef
  260. ULONG
  261. (*PWRITE_ACPI_CMOS) (
  262. IN CMOS_DEVICE_TYPE CmosType,
  263. IN ULONG SourceAddress,
  264. IN PUCHAR DataBuffer,
  265. IN ULONG ByteCount
  266. );
  267. typedef struct _ACPI_CMOS_INTERFACE_STANDARD {
  268. //
  269. // generic interface header
  270. //
  271. USHORT Size;
  272. USHORT Version;
  273. PVOID Context;
  274. PINTERFACE_REFERENCE InterfaceReference;
  275. PINTERFACE_DEREFERENCE InterfaceDereference;
  276. //
  277. // READ/WRITE_ACPI_CMOS functions
  278. //
  279. PREAD_ACPI_CMOS ReadCmos;
  280. PWRITE_ACPI_CMOS WriteCmos;
  281. } ACPI_CMOS_INTERFACE_STANDARD, *PACPI_CMOS_INTERFACE_STANDARD;
  282. //
  283. // These definitions are used for getting PCI Interrupt Routing interfaces
  284. //
  285. typedef struct {
  286. PVOID LinkNode;
  287. ULONG StaticVector;
  288. UCHAR Flags;
  289. } ROUTING_TOKEN, *PROUTING_TOKEN;
  290. //
  291. // Flag indicating that the device supports
  292. // MSI interrupt routing or that the provided token contains
  293. // MSI routing information
  294. //
  295. #define PCI_MSI_ROUTING 0x1
  296. #define PCI_STATIC_ROUTING 0x2
  297. typedef
  298. NTSTATUS
  299. (*PGET_INTERRUPT_ROUTING)(
  300. IN PDEVICE_OBJECT Pdo,
  301. OUT ULONG *Bus,
  302. OUT ULONG *PciSlot,
  303. OUT UCHAR *InterruptLine,
  304. OUT UCHAR *InterruptPin,
  305. OUT UCHAR *ClassCode,
  306. OUT UCHAR *SubClassCode,
  307. OUT PDEVICE_OBJECT *ParentPdo,
  308. OUT ROUTING_TOKEN *RoutingToken,
  309. OUT UCHAR *Flags
  310. );
  311. typedef
  312. NTSTATUS
  313. (*PSET_INTERRUPT_ROUTING_TOKEN)(
  314. IN PDEVICE_OBJECT Pdo,
  315. IN PROUTING_TOKEN RoutingToken
  316. );
  317. typedef
  318. VOID
  319. (*PUPDATE_INTERRUPT_LINE)(
  320. IN PDEVICE_OBJECT Pdo,
  321. IN UCHAR LineRegister
  322. );
  323. typedef struct _INT_ROUTE_INTERFACE_STANDARD {
  324. //
  325. // generic interface header
  326. //
  327. USHORT Size;
  328. USHORT Version;
  329. PVOID Context;
  330. PINTERFACE_REFERENCE InterfaceReference;
  331. PINTERFACE_DEREFERENCE InterfaceDereference;
  332. //
  333. // standard bus interfaces
  334. //
  335. PGET_INTERRUPT_ROUTING GetInterruptRouting;
  336. PSET_INTERRUPT_ROUTING_TOKEN SetInterruptRoutingToken;
  337. PUPDATE_INTERRUPT_LINE UpdateInterruptLine;
  338. } INT_ROUTE_INTERFACE_STANDARD, *PINT_ROUTE_INTERFACE_STANDARD;
  339. // Some well-known interface versions supported by the PCI Bus Driver
  340. #define PCI_INT_ROUTE_INTRF_STANDARD_VER 1
  341. // end_nthal end_ntifs end_ntosp
  342. NTKERNELAPI
  343. BOOLEAN
  344. PpInitSystem (
  345. VOID
  346. );
  347. NTKERNELAPI
  348. NTSTATUS
  349. PpDeviceRegistration(
  350. IN PUNICODE_STRING DeviceInstancePath,
  351. IN BOOLEAN Add,
  352. IN PUNICODE_STRING ServiceKeyName OPTIONAL
  353. );
  354. // begin_ntosp
  355. NTKERNELAPI
  356. NTSTATUS
  357. IoSynchronousInvalidateDeviceRelations(
  358. PDEVICE_OBJECT DeviceObject,
  359. DEVICE_RELATION_TYPE Type
  360. );
  361. // begin_ntddk begin_nthal begin_ntifs
  362. NTKERNELAPI
  363. NTSTATUS
  364. IoReportDetectedDevice(
  365. IN PDRIVER_OBJECT DriverObject,
  366. IN INTERFACE_TYPE LegacyBusType,
  367. IN ULONG BusNumber,
  368. IN ULONG SlotNumber,
  369. IN PCM_RESOURCE_LIST ResourceList,
  370. IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
  371. IN BOOLEAN ResourceAssigned,
  372. IN OUT PDEVICE_OBJECT *DeviceObject
  373. );
  374. // begin_wdm
  375. NTKERNELAPI
  376. VOID
  377. IoInvalidateDeviceRelations(
  378. IN PDEVICE_OBJECT DeviceObject,
  379. IN DEVICE_RELATION_TYPE Type
  380. );
  381. NTKERNELAPI
  382. VOID
  383. IoRequestDeviceEject(
  384. IN PDEVICE_OBJECT PhysicalDeviceObject
  385. );
  386. NTKERNELAPI
  387. NTSTATUS
  388. IoGetDeviceProperty(
  389. IN PDEVICE_OBJECT DeviceObject,
  390. IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
  391. IN ULONG BufferLength,
  392. OUT PVOID PropertyBuffer,
  393. OUT PULONG ResultLength
  394. );
  395. //
  396. // The following definitions are used in IoOpenDeviceRegistryKey
  397. //
  398. #define PLUGPLAY_REGKEY_DEVICE 1
  399. #define PLUGPLAY_REGKEY_DRIVER 2
  400. #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
  401. NTKERNELAPI
  402. NTSTATUS
  403. IoOpenDeviceRegistryKey(
  404. IN PDEVICE_OBJECT DeviceObject,
  405. IN ULONG DevInstKeyType,
  406. IN ACCESS_MASK DesiredAccess,
  407. OUT PHANDLE DevInstRegKey
  408. );
  409. NTKERNELAPI
  410. NTSTATUS
  411. NTAPI
  412. IoRegisterDeviceInterface(
  413. IN PDEVICE_OBJECT PhysicalDeviceObject,
  414. IN CONST GUID *InterfaceClassGuid,
  415. IN PUNICODE_STRING ReferenceString, OPTIONAL
  416. OUT PUNICODE_STRING SymbolicLinkName
  417. );
  418. NTKERNELAPI
  419. NTSTATUS
  420. IoOpenDeviceInterfaceRegistryKey(
  421. IN PUNICODE_STRING SymbolicLinkName,
  422. IN ACCESS_MASK DesiredAccess,
  423. OUT PHANDLE DeviceInterfaceKey
  424. );
  425. NTKERNELAPI
  426. NTSTATUS
  427. IoSetDeviceInterfaceState(
  428. IN PUNICODE_STRING SymbolicLinkName,
  429. IN BOOLEAN Enable
  430. );
  431. NTKERNELAPI
  432. NTSTATUS
  433. NTAPI
  434. IoGetDeviceInterfaces(
  435. IN CONST GUID *InterfaceClassGuid,
  436. IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
  437. IN ULONG Flags,
  438. OUT PWSTR *SymbolicLinkList
  439. );
  440. #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
  441. NTKERNELAPI
  442. NTSTATUS
  443. NTAPI
  444. IoGetDeviceInterfaceAlias(
  445. IN PUNICODE_STRING SymbolicLinkName,
  446. IN CONST GUID *AliasInterfaceClassGuid,
  447. OUT PUNICODE_STRING AliasSymbolicLinkName
  448. );
  449. //
  450. // Define PnP notification event categories
  451. //
  452. typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
  453. EventCategoryReserved,
  454. EventCategoryHardwareProfileChange,
  455. EventCategoryDeviceInterfaceChange,
  456. EventCategoryTargetDeviceChange
  457. } IO_NOTIFICATION_EVENT_CATEGORY;
  458. //
  459. // Define flags that modify the behavior of IoRegisterPlugPlayNotification
  460. // for the various event categories...
  461. //
  462. #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
  463. typedef
  464. NTSTATUS
  465. (*PDRIVER_NOTIFICATION_CALLBACK_ROUTINE) (
  466. IN PVOID NotificationStructure,
  467. IN PVOID Context
  468. );
  469. NTKERNELAPI
  470. NTSTATUS
  471. IoRegisterPlugPlayNotification(
  472. IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
  473. IN ULONG EventCategoryFlags,
  474. IN PVOID EventCategoryData OPTIONAL,
  475. IN PDRIVER_OBJECT DriverObject,
  476. IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
  477. IN PVOID Context,
  478. OUT PVOID *NotificationEntry
  479. );
  480. NTKERNELAPI
  481. NTSTATUS
  482. IoUnregisterPlugPlayNotification(
  483. IN PVOID NotificationEntry
  484. );
  485. NTKERNELAPI
  486. NTSTATUS
  487. IoReportTargetDeviceChange(
  488. IN PDEVICE_OBJECT PhysicalDeviceObject,
  489. IN PVOID NotificationStructure // always begins with a PLUGPLAY_NOTIFICATION_HEADER
  490. );
  491. typedef
  492. VOID
  493. (*PDEVICE_CHANGE_COMPLETE_CALLBACK)(
  494. IN PVOID Context
  495. );
  496. NTKERNELAPI
  497. VOID
  498. IoInvalidateDeviceState(
  499. IN PDEVICE_OBJECT PhysicalDeviceObject
  500. );
  501. #define IoAdjustPagingPathCount(_count_,_paging_) { \
  502. if (_paging_) { \
  503. InterlockedIncrement(_count_); \
  504. } else { \
  505. InterlockedDecrement(_count_); \
  506. } \
  507. }
  508. NTKERNELAPI
  509. NTSTATUS
  510. IoReportTargetDeviceChangeAsynchronous(
  511. IN PDEVICE_OBJECT PhysicalDeviceObject,
  512. IN PVOID NotificationStructure, // always begins with a PLUGPLAY_NOTIFICATION_HEADER
  513. IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback, OPTIONAL
  514. IN PVOID Context OPTIONAL
  515. );
  516. // end_wdm end_ntosp
  517. //
  518. // Resource arbiter declarations
  519. //
  520. typedef enum _ARBITER_ACTION {
  521. ArbiterActionTestAllocation,
  522. ArbiterActionRetestAllocation,
  523. ArbiterActionCommitAllocation,
  524. ArbiterActionRollbackAllocation,
  525. ArbiterActionQueryAllocatedResources,
  526. ArbiterActionWriteReservedResources,
  527. ArbiterActionQueryConflict,
  528. ArbiterActionQueryArbitrate,
  529. ArbiterActionAddReserved,
  530. ArbiterActionBootAllocation
  531. } ARBITER_ACTION, *PARBITER_ACTION;
  532. typedef struct _ARBITER_CONFLICT_INFO {
  533. //
  534. // The device object owning the device that is causing the conflict
  535. //
  536. PDEVICE_OBJECT OwningObject;
  537. //
  538. // The start of the conflicting range
  539. //
  540. ULONGLONG Start;
  541. //
  542. // The end of the conflicting range
  543. //
  544. ULONGLONG End;
  545. } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
  546. //
  547. // The parameters for those actions
  548. //
  549. typedef struct _ARBITER_PARAMETERS {
  550. union {
  551. struct {
  552. //
  553. // Doubly linked list of ARBITER_LIST_ENTRY's
  554. //
  555. IN OUT PLIST_ENTRY ArbitrationList;
  556. //
  557. // The size of the AllocateFrom array
  558. //
  559. IN ULONG AllocateFromCount;
  560. //
  561. // Array of resource descriptors describing the resources available
  562. // to the arbiter for it to arbitrate
  563. //
  564. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
  565. } TestAllocation;
  566. struct {
  567. //
  568. // Doubly linked list of ARBITER_LIST_ENTRY's
  569. //
  570. IN OUT PLIST_ENTRY ArbitrationList;
  571. //
  572. // The size of the AllocateFrom array
  573. //
  574. IN ULONG AllocateFromCount;
  575. //
  576. // Array of resource descriptors describing the resources available
  577. // to the arbiter for it to arbitrate
  578. //
  579. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
  580. } RetestAllocation;
  581. struct {
  582. //
  583. // Doubly linked list of ARBITER_LIST_ENTRY's
  584. //
  585. IN OUT PLIST_ENTRY ArbitrationList;
  586. } BootAllocation;
  587. struct {
  588. //
  589. // The resources that are currently allocated
  590. //
  591. OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
  592. } QueryAllocatedResources;
  593. struct {
  594. //
  595. // This is the device we are trying to find a conflict for
  596. //
  597. IN PDEVICE_OBJECT PhysicalDeviceObject;
  598. //
  599. // This is the resource to find the conflict for
  600. //
  601. IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
  602. //
  603. // Number of devices conflicting on the resource
  604. //
  605. OUT PULONG ConflictCount;
  606. //
  607. // Pointer to array describing the conflicting device objects and ranges
  608. //
  609. OUT PARBITER_CONFLICT_INFO *Conflicts;
  610. } QueryConflict;
  611. struct {
  612. //
  613. // Doubly linked list of ARBITER_LIST_ENTRY's - should have
  614. // only one entry
  615. //
  616. IN PLIST_ENTRY ArbitrationList;
  617. } QueryArbitrate;
  618. struct {
  619. //
  620. // Indicates the device whose resources are to be marked as reserved
  621. //
  622. PDEVICE_OBJECT ReserveDevice;
  623. } AddReserved;
  624. } Parameters;
  625. } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
  626. typedef enum _ARBITER_REQUEST_SOURCE {
  627. ArbiterRequestUndefined = -1,
  628. ArbiterRequestLegacyReported, // IoReportResourceUsage
  629. ArbiterRequestHalReported, // IoReportHalResourceUsage
  630. ArbiterRequestLegacyAssigned, // IoAssignResources
  631. ArbiterRequestPnpDetected, // IoReportResourceForDetection
  632. ArbiterRequestPnpEnumerated // IRP_MN_QUERY_RESOURCE_REQUIREMENTS
  633. } ARBITER_REQUEST_SOURCE;
  634. typedef enum _ARBITER_RESULT {
  635. ArbiterResultUndefined = -1,
  636. ArbiterResultSuccess,
  637. ArbiterResultExternalConflict, // This indicates that the request can never be solved for devices in this list
  638. ArbiterResultNullRequest // The request was for length zero and thus no translation should be attempted
  639. } ARBITER_RESULT;
  640. //
  641. // ARBITER_FLAG_BOOT_CONFIG - this indicates that the request is for the
  642. // resources assigned by the firmware/BIOS. It should be succeeded even if
  643. // it conflicts with another devices boot config.
  644. //
  645. #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
  646. // begin_ntosp
  647. NTKERNELAPI
  648. NTSTATUS
  649. IoReportResourceForDetection(
  650. IN PDRIVER_OBJECT DriverObject,
  651. IN PCM_RESOURCE_LIST DriverList OPTIONAL,
  652. IN ULONG DriverListSize OPTIONAL,
  653. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  654. IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
  655. IN ULONG DeviceListSize OPTIONAL,
  656. OUT PBOOLEAN ConflictDetected
  657. );
  658. // end_ntosp
  659. typedef struct _ARBITER_LIST_ENTRY {
  660. //
  661. // This is a doubly linked list of entries for easy sorting
  662. //
  663. LIST_ENTRY ListEntry;
  664. //
  665. // The number of alternative allocation
  666. //
  667. ULONG AlternativeCount;
  668. //
  669. // Pointer to an array of resource descriptors for the possible allocations
  670. //
  671. PIO_RESOURCE_DESCRIPTOR Alternatives;
  672. //
  673. // The device object of the device requesting these resources.
  674. //
  675. PDEVICE_OBJECT PhysicalDeviceObject;
  676. //
  677. // Indicates where the request came from
  678. //
  679. ARBITER_REQUEST_SOURCE RequestSource;
  680. //
  681. // Flags these indicate a variety of things (use ARBITER_FLAG_*)
  682. //
  683. ULONG Flags;
  684. //
  685. // Space to aid the arbiter in processing the list it is initialized to 0 when
  686. // the entry is created. The system will not attempt to interpret it.
  687. //
  688. LONG_PTR WorkSpace;
  689. //
  690. // Interface Type, Slot Number and Bus Number from Resource Requirements list,
  691. // used only for reverse identification.
  692. //
  693. INTERFACE_TYPE InterfaceType;
  694. ULONG SlotNumber;
  695. ULONG BusNumber;
  696. //
  697. // A pointer to a descriptor to indicate the resource that was allocated.
  698. // This is allocated by the system and filled in by the arbiter in response to an
  699. // ArbiterActionTestAllocation.
  700. //
  701. PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
  702. //
  703. // Pointer to the alternative that was chosen from to provide the assignment.
  704. // This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
  705. //
  706. PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
  707. //
  708. // The result of the operation
  709. // This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
  710. //
  711. ARBITER_RESULT Result;
  712. } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
  713. //
  714. // The arbiter's entry point
  715. //
  716. typedef
  717. NTSTATUS
  718. (*PARBITER_HANDLER) (
  719. IN PVOID Context,
  720. IN ARBITER_ACTION Action,
  721. IN OUT PARBITER_PARAMETERS Parameters
  722. );
  723. //
  724. // Arbiter interface
  725. //
  726. #define ARBITER_PARTIAL 0x00000001
  727. typedef struct _ARBITER_INTERFACE {
  728. //
  729. // Generic interface header
  730. //
  731. USHORT Size;
  732. USHORT Version;
  733. PVOID Context;
  734. PINTERFACE_REFERENCE InterfaceReference;
  735. PINTERFACE_DEREFERENCE InterfaceDereference;
  736. //
  737. // Entry point to the arbiter
  738. //
  739. PARBITER_HANDLER ArbiterHandler;
  740. //
  741. // Other information about the arbiter, use ARBITER_* flags
  742. //
  743. ULONG Flags;
  744. } ARBITER_INTERFACE, *PARBITER_INTERFACE;
  745. //
  746. // The directions translation can take place in
  747. //
  748. typedef enum _RESOURCE_TRANSLATION_DIRECTION { // ntosp
  749. TranslateChildToParent, // ntosp
  750. TranslateParentToChild // ntosp
  751. } RESOURCE_TRANSLATION_DIRECTION; // ntosp
  752. //
  753. // Translation functions
  754. //
  755. // begin_ntosp
  756. typedef
  757. NTSTATUS
  758. (*PTRANSLATE_RESOURCE_HANDLER)(
  759. IN PVOID Context,
  760. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  761. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  762. IN ULONG AlternativesCount, OPTIONAL
  763. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  764. IN PDEVICE_OBJECT PhysicalDeviceObject,
  765. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  766. );
  767. typedef
  768. NTSTATUS
  769. (*PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
  770. IN PVOID Context,
  771. IN PIO_RESOURCE_DESCRIPTOR Source,
  772. IN PDEVICE_OBJECT PhysicalDeviceObject,
  773. OUT PULONG TargetCount,
  774. OUT PIO_RESOURCE_DESCRIPTOR *Target
  775. );
  776. //
  777. // Translator Interface
  778. //
  779. typedef struct _TRANSLATOR_INTERFACE {
  780. USHORT Size;
  781. USHORT Version;
  782. PVOID Context;
  783. PINTERFACE_REFERENCE InterfaceReference;
  784. PINTERFACE_DEREFERENCE InterfaceDereference;
  785. PTRANSLATE_RESOURCE_HANDLER TranslateResources;
  786. PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
  787. } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
  788. // end_ntddk end_ntosp
  789. //
  790. // Legacy Device Detection Handler
  791. //
  792. typedef
  793. NTSTATUS
  794. (*PLEGACY_DEVICE_DETECTION_HANDLER)(
  795. IN PVOID Context,
  796. IN INTERFACE_TYPE LegacyBusType,
  797. IN ULONG BusNumber,
  798. IN ULONG SlotNumber,
  799. OUT PDEVICE_OBJECT *PhysicalDeviceObject
  800. );
  801. //
  802. // Legacy Device Detection Interface
  803. //
  804. typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE {
  805. USHORT Size;
  806. USHORT Version;
  807. PVOID Context;
  808. PINTERFACE_REFERENCE InterfaceReference;
  809. PINTERFACE_DEREFERENCE InterfaceDereference;
  810. PLEGACY_DEVICE_DETECTION_HANDLER LegacyDeviceDetection;
  811. } LEGACY_DEVICE_DETECTION_INTERFACE, *PLEGACY_DEVICE_DETECTION_INTERFACE;
  812. // end_nthal end_ntifs
  813. // begin_wdm begin_ntddk begin_ntifs begin_nthal begin_ntosp
  814. //
  815. // Header structure for all Plug&Play notification events...
  816. //
  817. typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
  818. USHORT Version; // presently at version 1.
  819. USHORT Size; // size (in bytes) of header + event-specific data.
  820. GUID Event;
  821. //
  822. // Event-specific stuff starts here.
  823. //
  824. } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
  825. //
  826. // Notification structure for all EventCategoryHardwareProfileChange events...
  827. //
  828. typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
  829. USHORT Version;
  830. USHORT Size;
  831. GUID Event;
  832. //
  833. // (No event-specific data)
  834. //
  835. } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
  836. //
  837. // Notification structure for all EventCategoryDeviceInterfaceChange events...
  838. //
  839. typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
  840. USHORT Version;
  841. USHORT Size;
  842. GUID Event;
  843. //
  844. // Event-specific data
  845. //
  846. GUID InterfaceClassGuid;
  847. PUNICODE_STRING SymbolicLinkName;
  848. } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
  849. //
  850. // Notification structures for EventCategoryTargetDeviceChange...
  851. //
  852. //
  853. // The following structure is used for TargetDeviceQueryRemove,
  854. // TargetDeviceRemoveCancelled, and TargetDeviceRemoveComplete:
  855. //
  856. typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
  857. USHORT Version;
  858. USHORT Size;
  859. GUID Event;
  860. //
  861. // Event-specific data
  862. //
  863. PFILE_OBJECT FileObject;
  864. } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
  865. //
  866. // The following structure header is used for all other (i.e., 3rd-party)
  867. // target device change events. The structure accommodates both a
  868. // variable-length binary data buffer, and a variable-length unicode text
  869. // buffer. The header must indicate where the text buffer begins, so that
  870. // the data can be delivered in the appropriate format (ANSI or Unicode)
  871. // to user-mode recipients (i.e., that have registered for handle-based
  872. // notification via RegisterDeviceNotification).
  873. //
  874. typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
  875. USHORT Version;
  876. USHORT Size;
  877. GUID Event;
  878. //
  879. // Event-specific data
  880. //
  881. PFILE_OBJECT FileObject; // This field must be set to NULL by callers of
  882. // IoReportTargetDeviceChange. Clients that
  883. // have registered for target device change
  884. // notification on the affected PDO will be
  885. // called with this field set to the file object
  886. // they specified during registration.
  887. //
  888. LONG NameBufferOffset; // offset (in bytes) from beginning of
  889. // CustomDataBuffer where text begins (-1 if none)
  890. //
  891. UCHAR CustomDataBuffer[1]; // variable-length buffer, containing (optionally)
  892. // a binary data at the start of the buffer,
  893. // followed by an optional unicode text buffer
  894. // (word-aligned).
  895. //
  896. } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
  897. // end_wdm end_ntddk end_ntifs end_nthal end_ntosp
  898. NTSTATUS
  899. PpSetCustomTargetEvent(
  900. IN PDEVICE_OBJECT DeviceObject,
  901. IN PKEVENT SyncEvent OPTIONAL,
  902. OUT PULONG Result OPTIONAL,
  903. IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL,
  904. IN PVOID Context OPTIONAL,
  905. IN PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure
  906. );
  907. NTSTATUS
  908. PpSetTargetDeviceRemove(
  909. IN PDEVICE_OBJECT DeviceObject,
  910. IN BOOLEAN KernelInitiated,
  911. IN BOOLEAN NoRestart,
  912. IN BOOLEAN DoEject,
  913. IN ULONG Problem,
  914. IN PKEVENT SyncEvent OPTIONAL,
  915. OUT PULONG Result OPTIONAL,
  916. OUT PPNP_VETO_TYPE VetoType OPTIONAL,
  917. OUT PUNICODE_STRING VetoName OPTIONAL
  918. );
  919. NTSTATUS
  920. PpSetDeviceRemovalSafe(
  921. IN PDEVICE_OBJECT DeviceObject,
  922. IN PKEVENT SyncEvent OPTIONAL,
  923. OUT PULONG Result OPTIONAL
  924. );
  925. NTSTATUS
  926. PpNotifyUserModeRemovalSafe(
  927. IN PDEVICE_OBJECT DeviceObject
  928. );
  929. #define TDF_DEVICEEJECTABLE 0x00000001
  930. #define TDF_NO_RESTART 0x00000002
  931. #define TDF_KERNEL_INITIATED 0x00000004
  932. NTSTATUS
  933. PpSetDeviceClassChange(
  934. IN CONST GUID *EventGuid,
  935. IN CONST GUID *ClassGuid,
  936. IN PUNICODE_STRING SymbolicLinkName
  937. );
  938. VOID
  939. PpSetPlugPlayEvent(
  940. IN CONST GUID *EventGuid,
  941. IN PDEVICE_OBJECT DeviceObject
  942. );
  943. NTSTATUS
  944. PpInitializeNotification(
  945. VOID
  946. );
  947. VOID
  948. PpShutdownSystem (
  949. IN BOOLEAN Reboot,
  950. IN ULONG Phase,
  951. IN OUT PVOID *Context
  952. );
  953. NTSTATUS
  954. PpSetPowerEvent(
  955. IN ULONG EventCode,
  956. IN ULONG EventData,
  957. IN PKEVENT CompletionEvent OPTIONAL,
  958. OUT PNTSTATUS CompletionStatus OPTIONAL,
  959. OUT PPNP_VETO_TYPE VetoType OPTIONAL,
  960. OUT PUNICODE_STRING VetoName OPTIONAL
  961. );
  962. NTSTATUS
  963. PpSetHwProfileChangeEvent(
  964. IN CONST GUID *EventGuid,
  965. IN PKEVENT CompletionEvent OPTIONAL,
  966. OUT PNTSTATUS CompletionStatus OPTIONAL,
  967. OUT PPNP_VETO_TYPE VetoType OPTIONAL,
  968. OUT PUNICODE_STRING VetoName OPTIONAL
  969. );
  970. NTSTATUS
  971. PpSetBlockedDriverEvent(
  972. IN GUID CONST *BlockedDriverGuid
  973. );
  974. NTSTATUS
  975. PpSynchronizeDeviceEventQueue(
  976. VOID
  977. );
  978. NTSTATUS
  979. PpSetPowerVetoEvent(
  980. IN POWER_ACTION VetoedPowerOperation,
  981. IN PKEVENT CompletionEvent OPTIONAL,
  982. OUT PNTSTATUS CompletionStatus OPTIONAL,
  983. IN PDEVICE_OBJECT DeviceObject,
  984. IN PNP_VETO_TYPE VetoType,
  985. IN PUNICODE_STRING VetoName OPTIONAL
  986. );
  987. NTSTATUS
  988. PpPagePathAssign(
  989. IN PFILE_OBJECT FileObject
  990. );
  991. NTSTATUS
  992. PpPagePathRelease(
  993. IN PFILE_OBJECT FileObject
  994. );
  995. //
  996. // Entry point for USER to deliver notifications (public)
  997. //
  998. // begin_ntosp
  999. ULONG
  1000. IoPnPDeliverServicePowerNotification(
  1001. IN POWER_ACTION PowerOperation,
  1002. IN ULONG PowerNotificationCode,
  1003. IN ULONG PowerNotificationData,
  1004. IN BOOLEAN Synchronous
  1005. );
  1006. // end_ntosp
  1007. #endif // _PNP_