test: pnp.h Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# pnp.h

Go to the documentation of this file.

    00001 /*++ BUILD Version: 0001    // Increment this if a change has global effects
    00002
    00003 Copyright (c) 1995  Microsoft Corporation
    00004
    00005 Module Name:
    00006
    00007     pnp.h
    00008
    00009 Abstract:
    00010
    00011     This module contains the internal structure definitions and APIs used by
    00012     the kernel-mode Plug and Play manager.
    00013
    00014     This file is included by including "ntos.h".
    00015
    00016 Author:
    00017
    00018     Lonny McMichael (lonnym) 02/09/95
    00019
    00020
    00021 Revision History:
    00022
    00023
    00024 --*/
    00025
    00026 #ifndef _PNP_
    00027 #define _PNP_
    00028
    00029 //
    00030 // The following global variables provide/control access to PnP Manager data.
    00031 //
    00032 // NOTE: If both registry AND bus list resources are required, then the
    00033 // bus list resource (PpBusResource) must be acquired FIRST.
    00034 //
    00035
    00036 extern ERESOURCE  PpRegistryDeviceResource;
    00037 extern PDRIVER_OBJECT IoPnpDriverObject;
    00038
    00039 // begin_ntddk begin_nthal begin_ntifs begin_wdm
    00040
    00041 //
    00042 // Define PnP Device Property for IoGetDeviceProperty
    00043 //
    00044
    00045 typedef enum {
    00046     DevicePropertyDeviceDescription,
    00047     DevicePropertyHardwareID,
    00048     DevicePropertyCompatibleIDs,
    00049     DevicePropertyBootConfiguration,
    00050     DevicePropertyBootConfigurationTranslated,
    00051     DevicePropertyClassName,
    00052     DevicePropertyClassGuid,
    00053     DevicePropertyDriverKeyName,
    00054     DevicePropertyManufacturer,
    00055     DevicePropertyFriendlyName,
    00056     DevicePropertyLocationInformation,
    00057     DevicePropertyPhysicalDeviceObjectName,
    00058     DevicePropertyBusTypeGuid,
    00059     DevicePropertyLegacyBusType,
    00060     DevicePropertyBusNumber,
    00061     DevicePropertyEnumeratorName,
    00062     DevicePropertyAddress,
    00063     DevicePropertyUINumber
    00064 } DEVICE_REGISTRY_PROPERTY;
    00065
    00066 typedef BOOLEAN (*PTRANSLATE_BUS_ADDRESS)(
    00067     IN PVOID Context,
    00068     IN PHYSICAL_ADDRESS BusAddress,
    00069     IN ULONG Length,
    00070     IN OUT PULONG AddressSpace,
    00071     OUT PPHYSICAL_ADDRESS TranslatedAddress
    00072     );
    00073
    00074 typedef struct _DMA_ADAPTER *(*PGET_DMA_ADAPTER)(
    00075     IN PVOID Context,
    00076     IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
    00077     OUT PULONG NumberOfMapRegisters
    00078     );
    00079
    00080 typedef ULONG (*PGET_SET_DEVICE_DATA)(
    00081     IN PVOID Context,
    00082     IN ULONG DataType,
    00083     IN PVOID Buffer,
    00084     IN ULONG Offset,
    00085     IN ULONG Length
    00086     );
    00087
    00088 //
    00089 // Define structure returned in response to IRP_MN_QUERY_BUS_INFORMATION by a
    00090 // PDO indicating the type of bus the device exists on.
    00091 //
    00092
    00093 typedef struct _PNP_BUS_INFORMATION {
    00094     GUID BusTypeGuid;
    00095     INTERFACE_TYPE LegacyBusType;
    00096     ULONG BusNumber;
    00097 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
    00098
    00099 //
    00100 // Define structure returned in response to IRP_MN_QUERY_LEGACY_BUS_INFORMATION
    00101 // by an FDO indicating the type of bus it is.  This is normally the same bus
    00102 // type as the device's children (i.e., as retrieved from the child PDO's via
    00103 // IRP_MN_QUERY_BUS_INFORMATION) except for cases like CardBus, which can
    00104 // support both 16-bit (PCMCIABus) and 32-bit (PCIBus) cards.
    00105 //
    00106
    00107 typedef struct _LEGACY_BUS_INFORMATION {
    00108     GUID BusTypeGuid;
    00109     INTERFACE_TYPE LegacyBusType;
    00110     ULONG BusNumber;
    00111 } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
    00112
    00113 typedef struct _BUS_INTERFACE_STANDARD {
    00114     //
    00115     // generic interface header
    00116     //
    00117     USHORT Size;
    00118     USHORT Version;
    00119     PVOID Context;
    00120     PINTERFACE_REFERENCE InterfaceReference;
    00121     PINTERFACE_DEREFERENCE InterfaceDereference;
    00122     //
    00123     // standard bus interfaces
    00124     //
    00125     PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
    00126     PGET_DMA_ADAPTER GetDmaAdapter;
    00127     PGET_SET_DEVICE_DATA SetBusData;
    00128     PGET_SET_DEVICE_DATA GetBusData;
    00129
    00130 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
    00131
    00132 //
    00133 // The following definitions are used in ACPI QueryInterface
    00134 //
    00135 typedef BOOLEAN (* PGPE_SERVICE_ROUTINE) (
    00136                             PVOID,
    00137                             PVOID);
    00138
    00139 typedef NTSTATUS (* PGPE_CONNECT_VECTOR) (
    00140                             PDEVICE_OBJECT,
    00141                             ULONG,
    00142                             KINTERRUPT_MODE,
    00143                             BOOLEAN,
    00144                             PGPE_SERVICE_ROUTINE,
    00145                             PVOID,
    00146                             PVOID);
    00147
    00148 typedef NTSTATUS (* PGPE_DISCONNECT_VECTOR) (
    00149                             PVOID);
    00150
    00151 typedef NTSTATUS (* PGPE_ENABLE_EVENT) (
    00152                             PDEVICE_OBJECT,
    00153                             PVOID);
    00154
    00155 typedef NTSTATUS (* PGPE_DISABLE_EVENT) (
    00156                             PDEVICE_OBJECT,
    00157                             PVOID);
    00158
    00159 typedef NTSTATUS (* PGPE_CLEAR_STATUS) (
    00160                             PDEVICE_OBJECT,
    00161                             PVOID);
    00162
    00163 typedef VOID (* PDEVICE_NOTIFY_CALLBACK) (
    00164                             PVOID,
    00165                             ULONG);
    00166
    00167 typedef NTSTATUS (* PREGISTER_FOR_DEVICE_NOTIFICATIONS) (
    00168                             PDEVICE_OBJECT,
    00169                             PDEVICE_NOTIFY_CALLBACK,
    00170                             PVOID);
    00171
    00172 typedef void (* PUNREGISTER_FOR_DEVICE_NOTIFICATIONS) (
    00173                             PDEVICE_OBJECT,
    00174                             PDEVICE_NOTIFY_CALLBACK);
    00175
    00176 typedef struct _ACPI_INTERFACE_STANDARD {
    00177     //
    00178     // Generic interface header
    00179     //
    00180     USHORT                  Size;
    00181     USHORT                  Version;
    00182     PVOID                   Context;
    00183     PINTERFACE_REFERENCE    InterfaceReference;
    00184     PINTERFACE_DEREFERENCE  InterfaceDereference;
    00185     //
    00186     // ACPI interfaces
    00187     //
    00188     PGPE_CONNECT_VECTOR                     GpeConnectVector;
    00189     PGPE_DISCONNECT_VECTOR                  GpeDisconnectVector;
    00190     PGPE_ENABLE_EVENT                       GpeEnableEvent;
    00191     PGPE_DISABLE_EVENT                      GpeDisableEvent;
    00192     PGPE_CLEAR_STATUS                       GpeClearStatus;
    00193     PREGISTER_FOR_DEVICE_NOTIFICATIONS      RegisterForDeviceNotifications;
    00194     PUNREGISTER_FOR_DEVICE_NOTIFICATIONS    UnregisterForDeviceNotifications;
    00195
    00196 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
    00197
    00198 // end_wdm
    00199
    00200 typedef enum _ACPI_REG_TYPE {
    00201     PM1a_ENABLE,
    00202     PM1b_ENABLE,
    00203     PM1a_STATUS,
    00204     PM1b_STATUS,
    00205     PM1a_CONTROL,
    00206     PM1b_CONTROL,
    00207     GP_STATUS,
    00208     GP_ENABLE,
    00209     SMI_CMD,
    00210     MaxRegType
    00211 } ACPI_REG_TYPE, *PACPI_REG_TYPE;
    00212
    00213 typedef USHORT (*PREAD_ACPI_REGISTER) (
    00214   IN ACPI_REG_TYPE AcpiReg,
    00215   IN ULONG         Register);
    00216
    00217 typedef VOID (*PWRITE_ACPI_REGISTER) (
    00218   IN ACPI_REG_TYPE AcpiReg,
    00219   IN ULONG         Register,
    00220   IN USHORT        Value
    00221   );
    00222
    00223 typedef struct ACPI_REGS_INTERFACE_STANDARD {
    00224     //
    00225     // generic interface header
    00226     //
    00227     USHORT Size;
    00228     USHORT Version;
    00229     PVOID  Context;
    00230     PINTERFACE_REFERENCE   InterfaceReference;
    00231     PINTERFACE_DEREFERENCE InterfaceDereference;
    00232
    00233     //
    00234     // READ/WRITE_ACPI_REGISTER functions
    00235     //
    00236     PREAD_ACPI_REGISTER  ReadAcpiRegister;
    00237     PWRITE_ACPI_REGISTER WriteAcpiRegister;
    00238
    00239 } ACPI_REGS_INTERFACE_STANDARD, *PACPI_REGS_INTERFACE_STANDARD;
    00240
    00241 //
    00242 // These definitions are used for getting PCI Interrupt Routing interfaces
    00243 //
    00244
    00245 typedef struct {
    00246     PVOID   LinkNode;
    00247     ULONG   StaticVector;
    00248     UCHAR   Flags;
    00249 } ROUTING_TOKEN, *PROUTING_TOKEN;
    00250
    00251 //
    00252 // Flag indicating that the device supports
    00253 // MSI interrupt routing or that the provided token contains
    00254 // MSI routing information
    00255 //
    00256
    00257 #define PCI_MSI_ROUTING 0x1
    00258
    00259 typedef
    00260 NTSTATUS
    00261 (*PGET_INTERRUPT_ROUTING)(
    00262     IN  PDEVICE_OBJECT  Pdo,
    00263     OUT ULONG           *Bus,
    00264     OUT ULONG           *PciSlot,
    00265     OUT UCHAR           *InterruptLine,
    00266     OUT UCHAR           *InterruptPin,
    00267     OUT UCHAR           *ClassCode,
    00268     OUT UCHAR           *SubClassCode,
    00269     OUT PDEVICE_OBJECT  *ParentPdo,
    00270     OUT ROUTING_TOKEN   *RoutingToken,
    00271     OUT UCHAR           *Flags
    00272     );
    00273
    00274 typedef
    00275 NTSTATUS
    00276 (*PSET_INTERRUPT_ROUTING_TOKEN)(
    00277     IN  PDEVICE_OBJECT  Pdo,
    00278     IN  PROUTING_TOKEN  RoutingToken
    00279     );
    00280
    00281 typedef
    00282 VOID
    00283 (*PUPDATE_INTERRUPT_LINE)(
    00284     IN PDEVICE_OBJECT Pdo,
    00285     IN UCHAR LineRegister
    00286     );
    00287
    00288 typedef struct _INT_ROUTE_INTERFACE_STANDARD {
    00289     //
    00290     // generic interface header
    00291     //
    00292     USHORT Size;
    00293     USHORT Version;
    00294     PVOID Context;
    00295     PINTERFACE_REFERENCE InterfaceReference;
    00296     PINTERFACE_DEREFERENCE InterfaceDereference;
    00297     //
    00298     // standard bus interfaces
    00299     //
    00300     PGET_INTERRUPT_ROUTING GetInterruptRouting;
    00301     PSET_INTERRUPT_ROUTING_TOKEN SetInterruptRoutingToken;
    00302     PUPDATE_INTERRUPT_LINE UpdateInterruptLine;
    00303
    00304 } INT_ROUTE_INTERFACE_STANDARD, *PINT_ROUTE_INTERFACE_STANDARD;
    00305
    00306 // Some well-known interface versions supported by the PCI Bus Driver
    00307
    00308 #define PCI_INT_ROUTE_INTRF_STANDARD_VER 1
    00309
    00310 // end_ntddk end_nthal end_ntifs
    00311
    00312 NTKERNELAPI
    00313 BOOLEAN
    00314 PpInitSystem (
    00315     VOID
    00316     );
    00317
    00318 NTKERNELAPI
    00319 NTSTATUS
    00320 PpDeviceRegistration(
    00321     IN PUNICODE_STRING DeviceInstancePath,
    00322     IN BOOLEAN Add,
    00323     IN PUNICODE_STRING ServiceKeyName OPTIONAL
    00324     );
    00325
    00326 NTKERNELAPI
    00327 NTSTATUS
    00328 IoSynchronousInvalidateDeviceRelations(
    00329     PDEVICE_OBJECT DeviceObject,
    00330     DEVICE_RELATION_TYPE Type
    00331     );
    00332
    00333 // begin_ntddk begin_nthal begin_ntifs
    00334
    00335 typedef struct _IO_ASSIGNED_RESOURCES {
    00336     ULONG Count;
    00337     PASSIGNED_RESOURCE AssignedResources[1];
    00338 } IO_ASSIGNED_RESOURCES, *PIO_ASSIGNED_RESOURCES;
    00339
    00340 NTKERNELAPI
    00341 NTSTATUS
    00342 IoGetAssignedResourcesForSuballocation (
    00343     IN INTERFACE_TYPE InterfaceType,
    00344     IN ULONG BusNumber,
    00345     IN ULONG SlotNumber,
    00346     IN PIO_RESOURCE_DESCRIPTOR ResourceDescriptor,
    00347     OUT PIO_ASSIGNED_RESOURCES *List
    00348     );
    00349
    00350 NTKERNELAPI
    00351 NTSTATUS
    00352 IoReportDetectedDevice(
    00353     IN PDRIVER_OBJECT DriverObject,
    00354     IN INTERFACE_TYPE LegacyBusType,
    00355     IN ULONG BusNumber,
    00356     IN ULONG SlotNumber,
    00357     IN PCM_RESOURCE_LIST ResourceList,
    00358     IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
    00359     IN BOOLEAN ResourceAssigned,
    00360     IN OUT PDEVICE_OBJECT *DeviceObject
    00361     );
    00362
    00363 //  begin_wdm
    00364
    00365 NTKERNELAPI
    00366 VOID
    00367 IoInvalidateDeviceRelations(
    00368     IN PDEVICE_OBJECT DeviceObject,
    00369     IN DEVICE_RELATION_TYPE Type
    00370     );
    00371
    00372 NTKERNELAPI
    00373 VOID
    00374 IoRequestDeviceEject(
    00375     IN PDEVICE_OBJECT PhysicalDeviceObject
    00376     );
    00377
    00378 NTKERNELAPI
    00379 NTSTATUS
    00380 IoGetDeviceProperty(
    00381     IN PDEVICE_OBJECT DeviceObject,
    00382     IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
    00383     IN ULONG BufferLength,
    00384     OUT PVOID PropertyBuffer,
    00385     OUT PULONG ResultLength
    00386     );
    00387
    00388 //
    00389 // The following definitions are used in IoOpenDeviceRegistryKey
    00390 //
    00391
    00392 #define PLUGPLAY_REGKEY_DEVICE  1
    00393 #define PLUGPLAY_REGKEY_DRIVER  2
    00394 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
    00395
    00396 NTKERNELAPI
    00397 NTSTATUS
    00398 IoOpenDeviceRegistryKey(
    00399     IN PDEVICE_OBJECT DeviceObject,
    00400     IN ULONG DevInstKeyType,
    00401     IN ACCESS_MASK DesiredAccess,
    00402     OUT PHANDLE DevInstRegKey
    00403     );
    00404
    00405 NTKERNELAPI
    00406 NTSTATUS
    00407 NTAPI
    00408 IoRegisterDeviceInterface(
    00409     IN PDEVICE_OBJECT PhysicalDeviceObject,
    00410     IN CONST GUID *InterfaceClassGuid,
    00411     IN PUNICODE_STRING ReferenceString,     OPTIONAL
    00412     OUT PUNICODE_STRING SymbolicLinkName
    00413     );
    00414
    00415 NTKERNELAPI
    00416 NTSTATUS
    00417 IoOpenDeviceInterfaceRegistryKey(
    00418     IN PUNICODE_STRING SymbolicLinkName,
    00419     IN ACCESS_MASK DesiredAccess,
    00420     OUT PHANDLE DeviceInterfaceKey
    00421     );
    00422
    00423 // begin_ntsrv
    00424
    00425 NTKERNELAPI
    00426 NTSTATUS
    00427 IoSetDeviceInterfaceState(
    00428     IN PUNICODE_STRING SymbolicLinkName,
    00429     IN BOOLEAN Enable
    00430     );
    00431
    00432 // end_ntsrv
    00433
    00434 NTKERNELAPI
    00435 NTSTATUS
    00436 NTAPI
    00437 IoGetDeviceInterfaces(
    00438     IN CONST GUID *InterfaceClassGuid,
    00439     IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
    00440     IN ULONG Flags,
    00441     OUT PWSTR *SymbolicLinkList
    00442     );
    00443
    00444 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE   0x00000001
    00445
    00446 NTKERNELAPI
    00447 NTSTATUS
    00448 NTAPI
    00449 IoGetDeviceInterfaceAlias(
    00450     IN PUNICODE_STRING SymbolicLinkName,
    00451     IN CONST GUID *AliasInterfaceClassGuid,
    00452     OUT PUNICODE_STRING AliasSymbolicLinkName
    00453     );
    00454
    00455 //
    00456 // Define PnP notification event categories
    00457 //
    00458
    00459 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
    00460     EventCategoryReserved,
    00461     EventCategoryHardwareProfileChange,
    00462     EventCategoryDeviceInterfaceChange,
    00463     EventCategoryTargetDeviceChange
    00464 } IO_NOTIFICATION_EVENT_CATEGORY;
    00465
    00466 //
    00467 // Define flags that modify the behavior of IoRegisterPlugPlayNotification
    00468 // for the various event categories...
    00469 //
    00470
    00471 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES    0x00000001
    00472
    00473 typedef
    00474 NTSTATUS
    00475 (*PDRIVER_NOTIFICATION_CALLBACK_ROUTINE) (
    00476     IN PVOID NotificationStructure,
    00477     IN PVOID Context
    00478 );
    00479
    00480
    00481 NTKERNELAPI
    00482 NTSTATUS
    00483 IoRegisterPlugPlayNotification(
    00484     IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
    00485     IN ULONG EventCategoryFlags,
    00486     IN PVOID EventCategoryData OPTIONAL,
    00487     IN PDRIVER_OBJECT DriverObject,
    00488     IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
    00489     IN PVOID Context,
    00490     OUT PVOID *NotificationEntry
    00491     );
    00492
    00493 NTKERNELAPI
    00494 NTSTATUS
    00495 IoUnregisterPlugPlayNotification(
    00496     IN PVOID NotificationEntry
    00497     );
    00498
    00499 NTKERNELAPI
    00500 NTSTATUS
    00501 IoReportTargetDeviceChange(
    00502     IN PDEVICE_OBJECT PhysicalDeviceObject,
    00503     IN PVOID NotificationStructure  // always begins with a PLUGPLAY_NOTIFICATION_HEADER
    00504     );
    00505
    00506 typedef
    00507 VOID
    00508 (*PDEVICE_CHANGE_COMPLETE_CALLBACK)(
    00509     IN PVOID Context
    00510     );
    00511
    00512 NTKERNELAPI
    00513 VOID
    00514 IoInvalidateDeviceState(
    00515     IN PDEVICE_OBJECT PhysicalDeviceObject
    00516     );
    00517
    00518 #define IoAdjustPagingPathCount(_count_,_paging_) {     \
    00519     if (_paging_) {                                     \
    00520         InterlockedIncrement(_count_);                  \
    00521     } else {                                            \
    00522         InterlockedDecrement(_count_);                  \
    00523     }                                                   \
    00524 }
    00525
    00526 // end_wdm
    00527
    00528 NTKERNELAPI
    00529 NTSTATUS
    00530 IoReportTargetDeviceChangeAsynchronous(
    00531     IN PDEVICE_OBJECT PhysicalDeviceObject,
    00532     IN PVOID NotificationStructure,  // always begins with a PLUGPLAY_NOTIFICATION_HEADER
    00533     IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback,       OPTIONAL
    00534     IN PVOID Context    OPTIONAL
    00535     );
    00536
    00537 // end_ntddk end_nthal end_ntifs
    00538
    00539
    00540 // begin_ntddk begin_nthal begin_ntifs
    00541
    00542 //
    00543 // Resource arbiter declarations
    00544 //
    00545
    00546 typedef enum _ARBITER_ACTION {
    00547     ArbiterActionTestAllocation,
    00548     ArbiterActionRetestAllocation,
    00549     ArbiterActionCommitAllocation,
    00550     ArbiterActionRollbackAllocation,
    00551     ArbiterActionQueryAllocatedResources,
    00552     ArbiterActionWriteReservedResources,
    00553     ArbiterActionQueryConflict,
    00554     ArbiterActionQueryArbitrate,
    00555     ArbiterActionAddReserved,
    00556     ArbiterActionBootAllocation
    00557 } ARBITER_ACTION, *PARBITER_ACTION;
    00558
    00559 typedef struct _ARBITER_CONFLICT_INFO {
    00560     //
    00561     // The device object owning the device that is causing the conflict
    00562     //
    00563     PDEVICE_OBJECT OwningObject;
    00564
    00565     //
    00566     // The start of the conflicting range
    00567     //
    00568     ULONGLONG Start;
    00569
    00570     //
    00571     // The end of the conflicting range
    00572     //
    00573     ULONGLONG End;
    00574
    00575 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
    00576
    00577 //
    00578 // The parameters for those actions
    00579 //
    00580
    00581 typedef struct _ARBITER_PARAMETERS {
    00582
    00583     union {
    00584
    00585         struct {
    00586
    00587             //
    00588             // Doubly linked list of ARBITER_LIST_ENTRY's
    00589             //
    00590             IN OUT PLIST_ENTRY ArbitrationList;
    00591
    00592             //
    00593             // The size of the AllocateFrom array
    00594             //
    00595             IN ULONG AllocateFromCount;
    00596
    00597             //
    00598             // Array of resource descriptors describing the resources available
    00599             // to the arbiter for it to arbitrate
    00600             //
    00601             IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
    00602
    00603         } TestAllocation;
    00604
    00605         struct {
    00606
    00607             //
    00608             // Doubly linked list of ARBITER_LIST_ENTRY's
    00609             //
    00610             IN OUT PLIST_ENTRY ArbitrationList;
    00611
    00612             //
    00613             // The size of the AllocateFrom array
    00614             //
    00615             IN ULONG AllocateFromCount;
    00616
    00617             //
    00618             // Array of resource descriptors describing the resources available
    00619             // to the arbiter for it to arbitrate
    00620             //
    00621             IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
    00622
    00623         } RetestAllocation;
    00624
    00625         struct {
    00626
    00627             //
    00628             // Doubly linked list of ARBITER_LIST_ENTRY's
    00629             //
    00630             IN OUT PLIST_ENTRY ArbitrationList;
    00631
    00632         } BootAllocation;
    00633
    00634         struct {
    00635
    00636             //
    00637             // The resources that are currently allocated
    00638             //
    00639             OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
    00640
    00641         } QueryAllocatedResources;
    00642
    00643         struct {
    00644
    00645             //
    00646             // This is the device we are trying to find a conflict for
    00647             //
    00648             IN PDEVICE_OBJECT PhysicalDeviceObject;
    00649
    00650             //
    00651             // This is the resource to find the conflict for
    00652             //
    00653             IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
    00654
    00655             //
    00656             // Number of devices conflicting on the resource
    00657             //
    00658             OUT PULONG ConflictCount;
    00659
    00660             //
    00661             // Pointer to array describing the conflicting device objects and ranges
    00662             //
    00663             OUT PARBITER_CONFLICT_INFO *Conflicts;
    00664
    00665         } QueryConflict;
    00666
    00667         struct {
    00668
    00669             //
    00670             // Doubly linked list of ARBITER_LIST_ENTRY's - should have
    00671             // only one entry
    00672             //
    00673             IN PLIST_ENTRY ArbitrationList;
    00674
    00675         } QueryArbitrate;
    00676
    00677         struct {
    00678
    00679             //
    00680             // Indicates the device whose resources are to be marked as reserved
    00681             //
    00682             PDEVICE_OBJECT ReserveDevice;
    00683
    00684         } AddReserved;
    00685
    00686     } Parameters;
    00687
    00688 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
    00689
    00690
    00691
    00692 typedef enum _ARBITER_REQUEST_SOURCE {
    00693
    00694     ArbiterRequestUndefined = -1,
    00695     ArbiterRequestLegacyReported,   // IoReportResourceUsage
    00696     ArbiterRequestHalReported,      // IoReportHalResourceUsage
    00697     ArbiterRequestLegacyAssigned,   // IoAssignResources
    00698     ArbiterRequestPnpDetected,      // IoReportResourceForDetection
    00699     ArbiterRequestPnpEnumerated     // IRP_MN_QUERY_RESOURCE_REQUIREMENTS
    00700
    00701 } ARBITER_REQUEST_SOURCE;
    00702
    00703
    00704 typedef enum _ARBITER_RESULT {
    00705
    00706     ArbiterResultUndefined = -1,
    00707     ArbiterResultSuccess,
    00708     ArbiterResultExternalConflict, // This indicates that the request can never be solved for devices in this list
    00709     ArbiterResultNullRequest       // The request was for length zero and thus no translation should be attempted
    00710
    00711 } ARBITER_RESULT;
    00712
    00713 //
    00714 // ARBITER_FLAG_BOOT_CONFIG - this indicates that the request is for the
    00715 // resources assigned by the firmware/BIOS.  It should be succeeded even if
    00716 // it conflicts with another devices boot config.
    00717 //
    00718
    00719 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
    00720
    00721 NTKERNELAPI
    00722 NTSTATUS
    00723 IoReportResourceForDetection(
    00724     IN PDRIVER_OBJECT DriverObject,
    00725     IN PCM_RESOURCE_LIST DriverList OPTIONAL,
    00726     IN ULONG DriverListSize OPTIONAL,
    00727     IN PDEVICE_OBJECT DeviceObject OPTIONAL,
    00728     IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
    00729     IN ULONG DeviceListSize OPTIONAL,
    00730     OUT PBOOLEAN ConflictDetected
    00731     );
    00732
    00733
    00734 typedef struct _ARBITER_LIST_ENTRY {
    00735
    00736     //
    00737     // This is a doubly linked list of entries for easy sorting
    00738     //
    00739     LIST_ENTRY ListEntry;
    00740
    00741     //
    00742     // The number of alternative allocation
    00743     //
    00744     ULONG AlternativeCount;
    00745
    00746     //
    00747     // Pointer to an array of resource descriptors for the possible allocations
    00748     //
    00749     PIO_RESOURCE_DESCRIPTOR Alternatives;
    00750
    00751     //
    00752     // The device object of the device requesting these resources.
    00753     //
    00754     PDEVICE_OBJECT PhysicalDeviceObject;
    00755
    00756     //
    00757     // Indicates where the request came from
    00758     //
    00759     ARBITER_REQUEST_SOURCE RequestSource;
    00760
    00761     //
    00762     // Flags these indicate a variety of things (use ARBITER_FLAG_*)
    00763     //
    00764     ULONG Flags;
    00765
    00766     //
    00767     // Space to aid the arbiter in processing the list it is initialized to 0 when
    00768     // the entry is created.  The system will not attempt to interpret it.
    00769     //
    00770     LONG_PTR WorkSpace;
    00771
    00772     //
    00773     // Interface Type, Slot Number and Bus Number from Resource Requirements list,
    00774     // used only for reverse identification.
    00775     //
    00776     INTERFACE_TYPE InterfaceType;
    00777     ULONG SlotNumber;
    00778     ULONG BusNumber;
    00779
    00780     //
    00781     // A pointer to a descriptor to indicate the resource that was allocated.
    00782     // This is allocated by the system and filled in by the arbiter in response to an
    00783     // ArbiterActionTestAllocation.
    00784     //
    00785     PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
    00786
    00787     //
    00788     // Pointer to the alternative that was chosen from to provide the assignment.
    00789     // This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
    00790     //
    00791     PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
    00792
    00793     //
    00794     // The result of the operation
    00795     // This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
    00796     //
    00797     ARBITER_RESULT Result;
    00798
    00799 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
    00800
    00801 //
    00802 // The arbiter's entry point
    00803 //
    00804
    00805 typedef
    00806 NTSTATUS
    00807 (*PARBITER_HANDLER) (
    00808     IN PVOID Context,
    00809     IN ARBITER_ACTION Action,
    00810     IN OUT PARBITER_PARAMETERS Parameters
    00811     );
    00812
    00813 //
    00814 // Arbiter interface
    00815 //
    00816
    00817 //
    00818 // A partial arbiter is one which may not arbitrate all the resources for
    00819 // its children but may defer to the next arbiter in the chain by returning
    00820 // STATUS_ARBITRATION_UNHANDLED.
    00821 //
    00822
    00823 #define ARBITER_PARTIAL   0x00000001
    00824
    00825
    00826 typedef struct _ARBITER_INTERFACE {
    00827
    00828     //
    00829     // Generic interface header
    00830     //
    00831     USHORT Size;
    00832     USHORT Version;
    00833     PVOID Context;
    00834     PINTERFACE_REFERENCE InterfaceReference;
    00835     PINTERFACE_DEREFERENCE InterfaceDereference;
    00836
    00837     //
    00838     // Entry point to the arbiter
    00839     //
    00840     PARBITER_HANDLER ArbiterHandler;
    00841
    00842     //
    00843     // Other information about the arbiter, use ARBITER_* flags
    00844     //
    00845     ULONG Flags;
    00846
    00847 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
    00848
    00849 //
    00850 // The directions translation can take place in
    00851 //
    00852
    00853 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
    00854     TranslateChildToParent,
    00855     TranslateParentToChild
    00856 } RESOURCE_TRANSLATION_DIRECTION;
    00857
    00858 //
    00859 // Translation functions
    00860 //
    00861
    00862 typedef
    00863 NTSTATUS
    00864 (*PTRANSLATE_RESOURCE_HANDLER)(
    00865     IN PVOID Context,
    00866     IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
    00867     IN RESOURCE_TRANSLATION_DIRECTION Direction,
    00868     IN ULONG AlternativesCount, OPTIONAL
    00869     IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
    00870     IN PDEVICE_OBJECT PhysicalDeviceObject,
    00871     OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
    00872 );
    00873
    00874 typedef
    00875 NTSTATUS
    00876 (*PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
    00877     IN PVOID Context,
    00878     IN PIO_RESOURCE_DESCRIPTOR Source,
    00879     IN PDEVICE_OBJECT PhysicalDeviceObject,
    00880     OUT PULONG TargetCount,
    00881     OUT PIO_RESOURCE_DESCRIPTOR *Target
    00882 );
    00883
    00884 //
    00885 // Translator Interface
    00886 //
    00887
    00888 typedef struct _TRANSLATOR_INTERFACE {
    00889     USHORT Size;
    00890     USHORT Version;
    00891     PVOID Context;
    00892     PINTERFACE_REFERENCE InterfaceReference;
    00893     PINTERFACE_DEREFERENCE InterfaceDereference;
    00894     PTRANSLATE_RESOURCE_HANDLER TranslateResources;
    00895     PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
    00896 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
    00897
    00898 // end_wdm
    00899
    00900 //
    00901 // Legacy Device Detection Handler
    00902 //
    00903
    00904 typedef
    00905 NTSTATUS
    00906 (*PLEGACY_DEVICE_DETECTION_HANDLER)(
    00907     IN PVOID Context,
    00908     IN INTERFACE_TYPE LegacyBusType,
    00909     IN ULONG BusNumber,
    00910     IN ULONG SlotNumber,
    00911     OUT PDEVICE_OBJECT *PhysicalDeviceObject
    00912 );
    00913
    00914 //
    00915 // Legacy Device Detection Interface
    00916 //
    00917
    00918 typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE {
    00919     USHORT Size;
    00920     USHORT Version;
    00921     PVOID Context;
    00922     PINTERFACE_REFERENCE InterfaceReference;
    00923     PINTERFACE_DEREFERENCE InterfaceDereference;
    00924     PLEGACY_DEVICE_DETECTION_HANDLER LegacyDeviceDetection;
    00925 } LEGACY_DEVICE_DETECTION_INTERFACE, *PLEGACY_DEVICE_DETECTION_INTERFACE;
    00926
    00927 // end_ntddk end_nthal end_ntifs
    00928
    00929 // begin_wdm begin_ntddk begin_ntifs begin_nthal
    00930
    00931 //
    00932 // Header structure for all Plug&Play notification events...
    00933 //
    00934
    00935 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
    00936     USHORT Version; // presently at version 1.
    00937     USHORT Size;    // size (in bytes) of header + event-specific data.
    00938     GUID Event;
    00939     //
    00940     // Event-specific stuff starts here.
    00941     //
    00942 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
    00943
    00944 //
    00945 // Notification structure for all EventCategoryHardwareProfileChange events...
    00946 //
    00947
    00948 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
    00949     USHORT Version;
    00950     USHORT Size;
    00951     GUID Event;
    00952     //
    00953     // (No event-specific data)
    00954     //
    00955 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
    00956
    00957
    00958 //
    00959 // Notification structure for all EventCategoryDeviceInterfaceChange events...
    00960 //
    00961
    00962 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
    00963     USHORT Version;
    00964     USHORT Size;
    00965     GUID Event;
    00966     //
    00967     // Event-specific data
    00968     //
    00969     GUID InterfaceClassGuid;
    00970     PUNICODE_STRING SymbolicLinkName;
    00971 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
    00972
    00973
    00974 //
    00975 // Notification structures for EventCategoryTargetDeviceChange...
    00976 //
    00977
    00978 //
    00979 // The following structure is used for TargetDeviceQueryRemove,
    00980 // TargetDeviceRemoveCancelled, and TargetDeviceRemoveComplete:
    00981 //
    00982 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
    00983     USHORT Version;
    00984     USHORT Size;
    00985     GUID Event;
    00986     //
    00987     // Event-specific data
    00988     //
    00989     PFILE_OBJECT FileObject;
    00990 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
    00991
    00992 //
    00993 // The following structure header is used for all other (i.e., 3rd-party)
    00994 // target device change events.  The structure accommodates both a
    00995 // variable-length binary data buffer, and a variable-length unicode text
    00996 // buffer.  The header must indicate where the text buffer begins, so that
    00997 // the data can be delivered in the appropriate format (ANSI or Unicode)
    00998 // to user-mode recipients (i.e., that have registered for handle-based
    00999 // notification via RegisterDeviceNotification).
    01000 //
    01001
    01002 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
    01003     USHORT Version;
    01004     USHORT Size;
    01005     GUID Event;
    01006     //
    01007     // Event-specific data
    01008     //
    01009     PFILE_OBJECT FileObject;    // This field must be set to NULL by callers of
    01010                                 // IoReportTargetDeviceChange.  Clients that
    01011                                 // have registered for target device change
    01012                                 // notification on the affected PDO will be
    01013                                 // called with this field set to the file object
    01014                                 // they specified during registration.
    01015                                 //
    01016     LONG NameBufferOffset;      // offset (in bytes) from beginning of
    01017                                 // CustomDataBuffer where text begins (-1 if none)
    01018                                 //
    01019     UCHAR CustomDataBuffer[1];  // variable-length buffer, containing (optionally)
    01020                                 // a binary data at the start of the buffer,
    01021                                 // followed by an optional unicode text buffer
    01022                                 // (word-aligned).
    01023                                 //
    01024 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
    01025
    01026 // end_wdm end_ntddk end_ntifs end_nthal
    01027
    01028 NTSTATUS
    01029 PpSetCustomTargetEvent(
    01030     IN  PDEVICE_OBJECT DeviceObject,
    01031     IN  PKEVENT SyncEvent                           OPTIONAL,
    01032     OUT PULONG Result                               OPTIONAL,
    01033     IN  PDEVICE_CHANGE_COMPLETE_CALLBACK Callback   OPTIONAL,
    01034     IN  PVOID Context                               OPTIONAL,
    01035     IN  PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure
    01036     );
    01037
    01038 NTSTATUS
    01039 PpSetTargetDeviceRemove(
    01040     IN  PDEVICE_OBJECT DeviceObject,
    01041     IN  BOOLEAN KernelInitiated,
    01042     IN  BOOLEAN NoRestart,
    01043     IN  BOOLEAN DoEject,
    01044     IN  ULONG Problem,
    01045     IN  PKEVENT SyncEvent        OPTIONAL,
    01046     OUT PULONG Result            OPTIONAL,
    01047     OUT PPNP_VETO_TYPE VetoType  OPTIONAL,
    01048     OUT PUNICODE_STRING VetoName OPTIONAL
    01049     );
    01050
    01051 NTSTATUS
    01052 PpSetDeviceRemovalSafe(
    01053     IN  PDEVICE_OBJECT DeviceObject,
    01054     IN  PKEVENT SyncEvent           OPTIONAL,
    01055     OUT PULONG Result               OPTIONAL
    01056     );
    01057
    01058 NTSTATUS
    01059 PpNotifyUserModeRemovalSafe(
    01060     IN  PDEVICE_OBJECT DeviceObject
    01061     );
    01062
    01063 #define TDF_DEVICEEJECTABLE     0x00000001
    01064 #define TDF_NO_RESTART          0x00000002
    01065 #define TDF_KERNEL_INITIATED    0x00000004
    01066
    01067 NTSTATUS
    01068 PpSetDeviceClassChange(
    01069     IN CONST GUID *EventGuid,
    01070     IN CONST GUID *ClassGuid,
    01071     IN PUNICODE_STRING SymbolicLinkName
    01072     );
    01073
    01074 VOID
    01075 PpSetPlugPlayEvent(
    01076     IN CONST GUID *EventGuid,
    01077     IN PDEVICE_OBJECT DeviceObject
    01078     );
    01079
    01080 NTSTATUS
    01081 PpInitializeNotification(
    01082     VOID
    01083     );
    01084
    01085 VOID
    01086 PpShutdownSystem (
    01087     IN BOOLEAN Reboot,
    01088     IN ULONG Phase,
    01089     IN OUT PVOID *Context
    01090     );
    01091
    01092 NTSTATUS
    01093 PpSetPowerEvent(
    01094     IN   ULONG EventCode,
    01095     IN   PKEVENT CompletionEvent    OPTIONAL,
    01096     OUT  PNTSTATUS CompletionStatus OPTIONAL,
    01097     OUT  PPNP_VETO_TYPE VetoType    OPTIONAL,
    01098     OUT  PUNICODE_STRING VetoName   OPTIONAL
    01099     );
    01100
    01101 NTSTATUS
    01102 PpSetHwProfileChangeEvent(
    01103     IN   CONST GUID *EventGuid,
    01104     IN   PKEVENT CompletionEvent    OPTIONAL,
    01105     OUT  PNTSTATUS CompletionStatus OPTIONAL,
    01106     OUT  PPNP_VETO_TYPE VetoType    OPTIONAL,
    01107     OUT  PUNICODE_STRING VetoName   OPTIONAL
    01108     );
    01109
    01110 NTSTATUS
    01111 PpSynchronizeDeviceEventQueue(
    01112     VOID
    01113     );
    01114
    01115 NTSTATUS
    01116 PpSetPowerVetoEvent(
    01117     IN  POWER_ACTION    VetoedPowerOperation,
    01118     IN  PKEVENT         CompletionEvent         OPTIONAL,
    01119     OUT PNTSTATUS       CompletionStatus        OPTIONAL,
    01120     IN  PDEVICE_OBJECT  DeviceObject,
    01121     IN  PNP_VETO_TYPE   VetoType,
    01122     IN  PUNICODE_STRING VetoName                OPTIONAL
    01123     );
    01124
    01125 //
    01126 // Entry point for USER to deliver notifications (public)
    01127 //
    01128
    01129 ULONG
    01130 IoPnPDeliverServicePowerNotification(
    01131     ULONG   PwrNotification,
    01132     BOOLEAN Synchronous
    01133     );
    01134
    01135 #endif // _PNP_