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

pnpiop.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1995 Microsoft Corporation 00004 00005 Module Name: 00006 00007 pnpsubs.c 00008 00009 Abstract: 00010 00011 This module contains the plug-and-play macros and constants. 00012 00013 Author: 00014 00015 Shie-Lin Tzong (shielint) 29-Jan-1995 00016 Andrew Thornton (andrewth) 5-Sept-1996 00017 00018 Environment: 00019 00020 Kernel mode 00021 00022 00023 Revision History: 00024 00025 00026 --*/ 00027 00028 #include "..\pnp\pnpi.h" 00029 #include "arbiter.h" 00030 #include "dockintf.h" 00031 #include "pnprlist.h" 00032 00033 // 00034 // Pool tags 00035 // 00036 00037 #define IOP_DNOD_TAG 'donD' 00038 #define IOP_DNDT_TAG 'tdnD' 00039 #define IOP_DPWR_TAG 'rwPD' 00040 00041 // 00042 // Dbg scope 00043 // 00044 00045 #define DBG_SCOPE 1 // Enable SOME DBG stuff on ALL builds 00046 //#define DBG_SCOPE DBG // Enable only on DBG build 00047 00048 // 00049 // The DEVICE_NODE is really just some extra stuff that we'd like to keep around 00050 // for each physical device object. 00051 // It is seperated from DEVOBJ_EXTENSION because these fields only apply to 00052 // PDO. 00053 // 00054 00055 typedef enum { 00056 00057 DOCK_NOTDOCKDEVICE, 00058 DOCK_QUIESCENT, 00059 DOCK_ARRIVING, 00060 DOCK_DEPARTING, 00061 DOCK_EJECTIRP_COMPLETED 00062 00063 } PROFILE_STATUS; 00064 00065 typedef enum { 00066 00067 PROFILE_IN_PNPEVENT, 00068 PROFILE_NOT_IN_PNPEVENT, 00069 PROFILE_PERHAPS_IN_PNPEVENT 00070 00071 } PROFILE_NOTIFICATION_TIME; 00072 00073 typedef struct _PENDING_SET_INTERFACE_STATE 00074 { 00075 LIST_ENTRY List; 00076 UNICODE_STRING LinkName; 00077 } PENDING_SET_INTERFACE_STATE, *PPENDING_SET_INTERFACE_STATE; 00078 00079 00080 typedef enum _UNLOCK_UNLINK_ACTION { 00081 UnlinkRemovedDeviceNodes, 00082 UnlinkAllDeviceNodesPendingClose, 00083 UnlinkOnlyChildDeviceNodesPendingClose 00084 } UNLOCK_UNLINK_ACTION, *PUNLOCK_UNLINK_ACTION; 00085 00086 typedef struct _DEVICE_NODE *PDEVICE_NODE; 00087 typedef struct _DEVICE_NODE { 00088 00089 // 00090 // Pointer to another DEVICE_NODE with the same parent as this one. 00091 // 00092 00093 PDEVICE_NODE Sibling; 00094 00095 // 00096 // Pointer to the first child of this DEVICE_NODE. 00097 // 00098 00099 PDEVICE_NODE Child; 00100 00101 // 00102 // Pointer to this DEVICE_NODE's parent. 00103 // 00104 00105 PDEVICE_NODE Parent; 00106 00107 // 00108 // Pointer to the last child of the device node 00109 // 00110 00111 PDEVICE_NODE LastChild; 00112 00113 // 00114 // Depth of DEVICE_NODE in the tree, root is 0 00115 // 00116 00117 ULONG Level; 00118 00119 // 00120 // Power notification order list entry for this device node 00121 // 00122 00123 PPO_DEVICE_NOTIFY Notify; 00124 00125 // 00126 // General flags. 00127 // 00128 00129 ULONG Flags; 00130 00131 // 00132 // Flags used by user-mode for volatile state which should go away on a 00133 // reboot or when the device is removed. 00134 // 00135 00136 ULONG UserFlags; 00137 00138 // 00139 // Problem. This is set if DNF_HAS_PROBLEM is set in Flags. Indicates 00140 // which problem exists and uses the same values as the config manager 00141 // CM_PROB_* 00142 // 00143 00144 ULONG Problem; 00145 00146 // 00147 // Pointer to the physical device object that this DEVICE_NODE is associated 00148 // with. 00149 // 00150 00151 PDEVICE_OBJECT PhysicalDeviceObject; 00152 00153 // 00154 // Pointer to the list of resources assigned to the PhysicalDeviceObject. 00155 // This is the Resource list which is passed to driver's start routine. 00156 // Note, PDO contains ListOfAssignedResources which described the resources 00157 // owned by the PDO. But, it is not in the format we will pass to driver or 00158 // write to registry. 00159 // 00160 00161 PCM_RESOURCE_LIST ResourceList; 00162 00163 PCM_RESOURCE_LIST ResourceListTranslated; 00164 00165 // 00166 // EnumerationMutex ensures that a given DEVICE_NODE doesn't get enumerated 00167 // on multiple threads at the same time. 00168 // 00169 00170 KEVENT EnumerationMutex; 00171 00172 // 00173 // InstancePath is the path of the instance node in the registry, 00174 // i.e. <EnumBus><DeviceId><uniqueid> 00175 // 00176 00177 UNICODE_STRING InstancePath; 00178 00179 // 00180 // ServiceName is the name of the driver who controls the device. (Not the 00181 // driver who enumerates/creates the PDO.) This field is mainly for 00182 // convenience. 00183 // 00184 00185 UNICODE_STRING ServiceName; 00186 00187 // 00188 // DuplicatePDO - if the flags have DNF_DUPLICATE set then this fields indicates 00189 // the duplicate PDO which is enumerated by a bus driver. N.B. It is possible 00190 // that DNF_DUPLICATE is set but this field is NULL. In this case, it means that 00191 // we know the device is a duplicate of another device and we have not enumerated 00192 // the DuplicatePDO yet. 00193 // 00194 00195 PDEVICE_OBJECT DuplicatePDO; 00196 00197 // 00198 // ResourceRequirements 00199 // 00200 00201 PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements; 00202 00203 // 00204 // Information queried from the LEGACY_BUS_INFORMATION irp. 00205 // 00206 00207 INTERFACE_TYPE InterfaceType; 00208 ULONG BusNumber; 00209 00210 // 00211 // Information queried from the BUS_INFORMATION irp. 00212 // 00213 00214 INTERFACE_TYPE ChildInterfaceType; 00215 ULONG ChildBusNumber; 00216 USHORT ChildBusTypeIndex; 00217 00218 // 00219 // Information queried from the PNP_BUS_INFORMATION irp. The BusTypeIndex 00220 // value is actually an index into a global table of known bus type guids. 00221 // 00222 00223 USHORT Reserved; // padding, someone else can use this field 00224 00225 // 00226 // Linked list of entries that represent each driver that has registered 00227 // for notification on this devnode. Note: drivers (and user-mode) actually 00228 // register based on a FILE_OBJECT handle, which is translated into a PDO 00229 // by sending an IRP_MN_QUERY_DEVICE_RELATIONS for TargetDeviceRelation. 00230 // 00231 00232 LIST_ENTRY TargetDeviceNotify; 00233 00234 // 00235 // DeviceArbiterList - A list of arbiters registered for this physical device object 00236 // Note: The Arbiters must be dereferenced when the device node is going away. 00237 // 00238 00239 LIST_ENTRY DeviceArbiterList; 00240 00241 // 00242 // DeviceTranslatorList - A list of translator for this physical device object 00243 // NOTE: the Translator must be dereferenced when the devic node is going away. 00244 // 00245 00246 LIST_ENTRY DeviceTranslatorList; 00247 00248 // 00249 // NoTranslatorMask - the bit position corresponds to resource type 00250 // if bit is set, there is no translator for the resource type in this devnode 00251 // 00252 00253 USHORT NoTranslatorMask; 00254 00255 // 00256 // QueryTranslatorMask - The bit position corresponds to resource type. 00257 // if bit is set, the translator for the resource type is queried. 00258 // 00259 00260 USHORT QueryTranslatorMask; 00261 00262 // 00263 // NoArbiterMask - the bit position corresponds to resource type 00264 // if bit is set, there is no arbiter for the resource type in this devnode 00265 // 00266 00267 USHORT NoArbiterMask; 00268 00269 // 00270 // QueryArbiterMask - The bit position corresponds to resource type. 00271 // if bit is set, the arbiter for the resource type is queried. 00272 // 00273 00274 USHORT QueryArbiterMask; 00275 00276 // 00277 // The following fields are used to track legacy resource allocation 00278 // LegacyDeviceNode - The real legacy device node. 00279 // NextResourceDeviceNode - link all the made-up device nodes which own part of 00280 // the resources from LegacyDeviceNode. 00281 // 00282 00283 union { 00284 PDEVICE_NODE LegacyDeviceNode; 00285 PDEVICE_RELATIONS PendingDeviceRelations; 00286 } OverUsed1; 00287 00288 union { 00289 PDEVICE_NODE NextResourceDeviceNode; 00290 } OverUsed2; 00291 00292 // 00293 // Remember the BootResources for the device 00294 // 00295 00296 PCM_RESOURCE_LIST BootResources; 00297 00298 // 00299 // Lock Count used to keep track of multiple ejects 00300 // 00301 ULONG LockCount; 00302 00303 // 00304 // If this devnode has been QueryRemoved but the original target of the 00305 // QueryRemove is still physically present then this will point to the 00306 // relation list used to process the original QueryRemove. 00307 // 00308 PRELATION_LIST RelationList; 00309 00310 // 00311 // When Capabilities have been queried for a device (twice, once before 00312 // start and once after start) the flags are stored here in the same format 00313 // as the query capabilities IRP - use IopDeviceNodeFlagsToCapabilities to 00314 // access. 00315 // 00316 ULONG CapabilityFlags; 00317 00318 // 00319 // Maintain a list of current dock devices and their SerialNumbers 00320 // 00321 struct { 00322 PROFILE_STATUS DockStatus; 00323 LIST_ENTRY ListEntry; 00324 PWCHAR SerialNumber; 00325 } DockInfo; 00326 00327 // 00328 // Maintain a count to determine if either ourselves or any of 00329 // our children are stopping us from being disableable 00330 // count = myself (DNUF_NOT_DISABLEABLE) + 1 for each immediate 00331 // child that has DisableableDepends > 0 00332 // 00333 ULONG DisableableDepends; 00334 00335 // 00336 // List of pended IoSetDeviceInterfaceState calls. 00337 // IoSetDeviceInterfaceState adds an entry to this list whenever it is 00338 // called and we haven't been started yet. Once we do the start we'll 00339 // run down the list. 00340 // 00341 LIST_ENTRY PendedSetInterfaceState; 00342 00343 #if DBG_SCOPE 00344 ULONG FailureStatus; 00345 PCM_RESOURCE_LIST PreviousResourceList; 00346 PIO_RESOURCE_REQUIREMENTS_LIST PreviousResourceRequirements; 00347 #endif 00348 00349 } DEVICE_NODE; 00350 00351 00352 // 00353 // A device Object is a PDO iff it has a non NULL device node (aka set by 00354 // plug and play during a query device relations. 00355 // 00356 00357 #define ASSERT_PDO(d) \ 00358 do { \ 00359 if ( NULL == (d)->DeviceObjectExtension->DeviceNode || \ 00360 (((PDEVICE_NODE)(d)->DeviceObjectExtension->DeviceNode)->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) { \ 00361 KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, PNP_ERR_INVALID_PDO, (ULONG_PTR)d, 0, 0); \ 00362 } \ 00363 } \ 00364 while (0) 00365 00366 // 00367 // DNF_MAKEUP - this devnode's device is created and owned by PnP manager 00368 // 00369 00370 #define DNF_MADEUP 0x00000001 00371 00372 // 00373 // DNF_DUPLICATE - this devnode's device is a duplicate of another enumerate PDO 00374 // 00375 00376 #define DNF_DUPLICATE 0x00000002 00377 00378 // 00379 // DNF_HAL_NODE - a flag to indicate which device node is the root node created by 00380 // the hal 00381 // 00382 00383 #define DNF_HAL_NODE 0x00000004 00384 00385 // 00386 // DNF_PROCESSED - indicates if the registry instance key of the device node 00387 // was created. 00388 // 00389 00390 #define DNF_PROCESSED 0x00000008 00391 00392 // 00393 // DNF_ENUMERATED - used to track enumeration in IopEnumerateDevice() 00394 // 00395 00396 #define DNF_ENUMERATED 0x00000010 00397 00398 // 00399 // Singal that we need to send driver query id irps 00400 // 00401 00402 #define DNF_NEED_QUERY_IDS 0x00000020 00403 00404 // 00405 // THis device has been added to its controlling driver 00406 // 00407 00408 #define DNF_ADDED 0x00000040 00409 00410 // 00411 // DNF_HAS_BOOT_CONFIG - the device has resource assigned by BIOS. It is considered 00412 // pseudo-started and need to participate in rebalance. 00413 // 00414 00415 #define DNF_HAS_BOOT_CONFIG 0x00000080 00416 00417 // 00418 // DNF_BOOT_CONFIG_RESERVED - Indicates the BOOT resources of the device are reserved. 00419 // 00420 00421 #define DNF_BOOT_CONFIG_RESERVED 0x00000100 00422 00423 // 00424 // DNF_START_REQUEST_PENDING - Indicates the device is being started. 00425 // 00426 00427 #define DNF_START_REQUEST_PENDING 0x00000200 00428 00429 // 00430 // DNF_NO_RESOURCE_REQUIRED - this devnode's device does not require resource. 00431 // 00432 00433 #define DNF_NO_RESOURCE_REQUIRED 0x00000400 00434 00435 // 00436 // DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED - to distinguished the 00437 // DeviceNode->ResourceRequirements is a filtered list or not. 00438 // 00439 00440 #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00000800 00441 00442 // 00443 // Indicates the device's resources are bing assigned (but is not done yet.) 00444 // So don't try assign resource to this device. 00445 // 00446 00447 #define DNF_ASSIGNING_RESOURCES 0x00001000 00448 00449 // 00450 // DNF_RESOURCE_ASSIGNED - this devnode's resources are assigned by PnP 00451 // 00452 00453 #define DNF_RESOURCE_ASSIGNED 0x00002000 00454 00455 // 00456 // DNF_RESOURCE_REPORTED - this devnode's resources are reported by PnP 00457 // 00458 00459 #define DNF_RESOURCE_REPORTED 0x00004000 00460 00461 // 00462 // DNF_RESOURCE_REQUIREMENTS_CHANGED - Indicates the device's resource 00463 // requirements list has been changed. 00464 // 00465 00466 #define DNF_RESOURCE_REQUIREMENTS_CHANGED 0x00008000 00467 00468 // 00469 // DNF_NON_STOPPED_REBALANC - indicates the device can be restarted with new 00470 // resources without being stopped. 00471 // 00472 00473 #define DNF_NON_STOPPED_REBALANCE 0x00010000 00474 00475 // 00476 // DNF_STOPPED - indicates this device is currently stopped for reconfiguration of 00477 // its resources. 00478 // 00479 00480 #define DNF_STOPPED 0x00020000 00481 00482 // 00483 // DNF_STARTED - indicates if the device was started, i.e., its StartDevice 00484 // irp is processed. 00485 // 00486 00487 #define DNF_STARTED 0x00040000 00488 00489 // 00490 // The device's controlling driver is a legacy driver 00491 // 00492 00493 #define DNF_LEGACY_DRIVER 0x00080000 00494 00495 // 00496 // For the reported detected devices, they are considered started. We still 00497 // need a flag to indicate we need to enumerate the device. 00498 // 00499 00500 #define DNF_NEED_ENUMERATION_ONLY 0x00100000 00501 00502 // 00503 // DNF_IO_INVALIDATE_DEVICE_RELATIONS_PENDING - indicate the 00504 // IoInvalidateDeviceRelations request is pending and therequest needs to 00505 // be queued after the Query_Device_relation irp is completed. 00506 // 00507 00508 #define DNF_IO_INVALIDATE_DEVICE_RELATIONS_PENDING 0x00200000 00509 00510 // 00511 // Indicates the device is being sent a query device relations irp. So no more 00512 // q-d-r irp at the same time. 00513 // 00514 00515 #define DNF_BEING_ENUMERATED 0x00400000 00516 00517 // 00518 // DNF_ENUMERATION_REQUEST_QUEUED - indicate the IoInvalidateDeviceRelations 00519 // request is queued. So, new IoInvalidateDeviceRelations can be ignored. 00520 // 00521 00522 #define DNF_ENUMERATION_REQUEST_QUEUED 0x00800000 00523 00524 // 00525 // DNF_ENUMERATION_REQUEST_PENDING - Indicates the QUERY_DEVICE_RELATIONS irp 00526 // returns pending. 00527 // 00528 00529 #define DNF_ENUMERATION_REQUEST_PENDING 0x01000000 00530 00531 // 00532 // This corresponds to the user-mode CM_PROB_WILL_BE_REMOVED problem value and 00533 // the DN_WILL_BE_REMOVED status flag. 00534 // 00535 00536 #define DNF_HAS_PROBLEM 0x02000000 00537 00538 // 00539 // DNF_HAS_PRIVATE_PROBLEM - indicates this device reported PNP_DEVICE_FAILED 00540 // to a IRP_MN_QUERY_PNP_DEVICE_STATE without also reporting 00541 // PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED. 00542 // 00543 00544 #define DNF_HAS_PRIVATE_PROBLEM 0x04000000 00545 00546 // 00547 // DNF_REMOVE_PENDING_CLOSES is set after a IRP_MN_SURPRISE_REMOVE is sent 00548 // to a device object. It is an indicator that IRP_MN_REMOVE_DEVICE should 00549 // be sent to the device object as soon as all of the file objects have gone 00550 // away. 00551 // 00552 00553 #define DNF_REMOVE_PENDING_CLOSES 0x08000000 00554 00555 // 00556 // DNF_DEVICE_GONE is set when a pdo is no longer returned in a query bus 00557 // relations. It will then be processed as a surprise remove if started. 00558 // This flag is used to better detect when a device is resurrected, and when 00559 // processing surprise remove, to determine if the devnode should be removed 00560 // from the tree. 00561 // 00562 00563 #define DNF_DEVICE_GONE 0x10000000 00564 00565 // 00566 // DNF_LEGACY_RESOURCE_DEVICENODE is set for device nodes created for legacy 00567 // resource allocation. 00568 // 00569 00570 #define DNF_LEGACY_RESOURCE_DEVICENODE 0x20000000 00571 00572 // 00573 // DNF_NEEDS_REBALANCE is set for device nodes that trigger rebalance. 00574 // 00575 00576 #define DNF_NEEDS_REBALANCE 0x40000000 00577 00578 // 00579 // DNF_LOCKED_FOR_EJECT is set on device nodes that are being ejected or are 00580 // related to a device being ejected. 00581 // 00582 00583 #define DNF_LOCKED_FOR_EJECT 0x80000000 00584 00585 // 00586 // This corresponds to the user-mode the DN_WILL_BE_REMOVED status flag. 00587 // 00588 00589 #define DNUF_WILL_BE_REMOVED 0x00000001 00590 00591 // 00592 // This corresponds to the user-mode DN_NO_SHOW_IN_DM status flag. 00593 // 00594 00595 #define DNUF_DONT_SHOW_IN_UI 0x00000002 00596 00597 // 00598 // This flag is set when user-mode lets us know that a reboot is required 00599 // for this device. 00600 // 00601 00602 #define DNUF_NEED_RESTART 0x00000004 00603 00604 // 00605 // This flag is set to let the user-mode know when a device can be disabled 00606 // it is still possible for this to be TRUE, yet disable to fail, as it's 00607 // a polled flag (see also PNP_DEVICE_NOT_DISABLEABLE) 00608 // 00609 00610 #define DNUF_NOT_DISABLEABLE 0x00000008 00611 00612 00613 #define DNF_ADD_PHASE (DNF_HAS_PROBLEM | DNF_HAS_PRIVATE_PROBLEM | DNF_DEVICE_GONE | DNF_REMOVE_PENDING_CLOSES | DNF_ADDED) 00614 00615 #define OK_TO_ADD_DEVICE(_devnode_) \ 00616 ( (_devnode_)->Flags & DNF_PROCESSED && \ 00617 !((_devnode_)->Flags & DNF_ADD_PHASE) ) 00618 00619 #define DNF_START_PHASE (DNF_HAS_PROBLEM | DNF_HAS_PRIVATE_PROBLEM | DNF_DEVICE_GONE | DNF_REMOVE_PENDING_CLOSES | DNF_STARTED | DNF_START_REQUEST_PENDING) 00620 00621 #define DNF_ASYNC_REQUEST_PENDING (DNF_START_REQUEST_PENDING | DNF_ENUMERATION_REQUEST_PENDING) 00622 00623 #define DNF_ASSIGN_RESOURCE_PHASE (DNF_HAS_PROBLEM | DNF_HAS_PRIVATE_PROBLEM | DNF_DEVICE_GONE | DNF_REMOVE_PENDING_CLOSES | DNF_RESOURCE_ASSIGNED | DNF_RESOURCE_REPORTED | \ 00624 DNF_ASSIGNING_RESOURCES | DNF_NO_RESOURCE_REQUIRED) 00625 #define DNF_HAS_RESOURCE (DNF_RESOURCE_ASSIGNED | DNF_RESOURCE_REPORTED | \ 00626 DNF_NO_RESOURCE_REQUIRED) 00627 00628 // 00629 // PNP Bugcheck Subcodes 00630 // 00631 #define PNP_ERR_DUPLICATE_PDO 1 00632 #define PNP_ERR_INVALID_PDO 2 00633 #define PNP_ERR_BOGUS_ID 3 00634 #define PNP_ERR_PDO_ENUMERATED_AFTER_DELETION 4 00635 #define PNP_ERR_ACTIVE_PDO_FREED 5 00636 00637 #define PNP_ERR_DEVICE_MISSING_FROM_EJECT_LIST 6 00638 #define PNP_ERR_UNEXPECTED_ADD_RELATION_ERR 7 00639 00640 00641 00642 typedef NTSTATUS (*PENUM_CALLBACK)( 00643 IN PDEVICE_NODE DeviceNode, 00644 IN PVOID Context 00645 ); 00646 00647 // 00648 // Define workitem for add/start new device 00649 // 00650 00651 typedef struct _NEW_DEVICE_WORK_ITEM { 00652 WORK_QUEUE_ITEM WorkItem; 00653 PDEVICE_OBJECT DeviceObject; 00654 PDRIVER_OBJECT DriverObject; 00655 } NEW_DEVICE_WORK_ITEM, *PNEW_DEVICE_WORK_ITEM; 00656 00657 // 00658 // Define callback routine for IopApplyFunctionToSubKeys & 00659 // IopApplyFunctionToServiceInstances 00660 // 00661 typedef BOOLEAN (*PIOP_SUBKEY_CALLBACK_ROUTINE) ( 00662 IN HANDLE, 00663 IN PUNICODE_STRING, 00664 IN OUT PVOID 00665 ); 00666 00667 // 00668 // Define context structures for Start and Add device services 00669 // 00670 00671 #define NO_MORE_GROUP ((USHORT) -1) 00672 #define SETUP_RESERVED_GROUP 0 00673 #define BUS_DRIVER_GROUP 1 00674 00675 typedef struct _ADD_CONTEXT { 00676 USHORT GroupsToStart; 00677 USHORT GroupToStartNext; 00678 ULONG DriverStartType; 00679 } ADD_CONTEXT, *PADD_CONTEXT; 00680 00681 typedef struct _START_CONTEXT { 00682 BOOLEAN LoadDriver; 00683 BOOLEAN NewDevice; 00684 ADD_CONTEXT AddContext; 00685 } START_CONTEXT, *PSTART_CONTEXT; 00686 00687 // 00688 // Resource translation and allocation related structures 00689 // 00690 00691 typedef enum _RESOURCE_HANDLER_TYPE { 00692 ResourceHandlerNull, 00693 ResourceTranslator, 00694 ResourceArbiter, 00695 ResourceLegacyDeviceDetection 00696 } RESOURCE_HANDLER_TYPE; 00697 00698 #define PI_MAXIMUM_RESOURCE_TYPE_TRACKED 15 00699 00700 // 00701 // Internal Arbiters tracking structures 00702 // Note the first three fields of PI_RESOURCE_ARBITER_ENTRY and PI_RESOURCE_TRANSLATOR_ENTRY 00703 // must be the same. 00704 // 00705 00706 typedef struct _PI_RESOURCE_ARBITER_ENTRY { 00707 LIST_ENTRY DeviceArbiterList; // Link all the arbiters of a PDO. 00708 UCHAR ResourceType; 00709 PARBITER_INTERFACE ArbiterInterface; 00710 LIST_ENTRY ResourceList; 00711 LIST_ENTRY BestResourceList; 00712 LIST_ENTRY BestConfig; // Link all the arbiters which produces the best logconf 00713 LIST_ENTRY ActiveArbiterList; // Link all the arbiters under testing 00714 UCHAR State; 00715 BOOLEAN ResourcesChanged; 00716 } PI_RESOURCE_ARBITER_ENTRY, *PPI_RESOURCE_ARBITER_ENTRY; 00717 00718 // 00719 // Define PI_RESOURCE_ARBITER_ENTRY state 00720 // 00721 00722 #define PI_ARBITER_HAS_SOMETHING 1 00723 #define PI_ARBITER_TEST_FAILED 2 00724 00725 // 00726 // Internal Translator tracking structures 00727 // 00728 00729 typedef struct _PI_RESOURCE_TRANSLATOR_ENTRY { 00730 LIST_ENTRY DeviceTranslatorList; 00731 UCHAR ResourceType; 00732 PTRANSLATOR_INTERFACE TranslatorInterface; 00733 PDEVICE_NODE DeviceNode; 00734 } PI_RESOURCE_TRANSLATOR_ENTRY, *PPI_RESOURCE_TRANSLATOR_ENTRY; 00735 00736 // 00737 // IOP_RESOURCE_REQUEST 00738 // 00739 00740 #define QUERY_RESOURCE_LIST 0 00741 #define QUERY_RESOURCE_REQUIREMENTS 1 00742 00743 #define REGISTRY_ALLOC_CONFIG 1 00744 #define REGISTRY_FORCED_CONFIG 2 00745 #define REGISTRY_BOOT_CONFIG 4 00746 #define REGISTRY_OVERRIDE_CONFIGVECTOR 1 00747 #define REGISTRY_BASIC_CONFIGVECTOR 2 00748 00749 // 00750 // An array of IOP_RESOURCE_REQUEST structures is used to anchor all the 00751 // devices for which resource rerquirement is being attempted. 00752 // 00753 00754 #define IOP_ASSIGN_RETRY 0x00000008 // Retry resource allocation later 00755 #define IOP_ASSIGN_EXCLUDE 0x00000010 // internal IopAssign flag 00756 #define IOP_ASSIGN_IGNORE 0x00000020 // ignore this request 00757 #define IOP_ASSIGN_NO_REBALANCE 0x00000080 // no rebal if assign fails 00758 #define IOP_ASSIGN_RESOURCES_RELEASED 0x00000100 // resources are released for rebalancing 00759 #define IOP_ASSIGN_KEEP_CURRENT_CONFIG 0x00000200 // Indicate non-stopped rebalance. We need to 00760 // preserved the current config. 00761 #define IOP_ASSIGN_CLEAR_RESOURCE_REQUIREMENTS_CHANGE_FLAG \ 00762 0x00000400 00763 00764 typedef struct _IOP_RESOURCE_REQUEST { 00765 PDEVICE_OBJECT PhysicalDevice; 00766 ULONG Flags; 00767 ARBITER_REQUEST_SOURCE AllocationType; 00768 ULONG Priority; // 0 is highest priority 00769 PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements; 00770 PVOID ReqList; // PREQ_LIST 00771 PCM_RESOURCE_LIST ResourceAssignment; 00772 PCM_RESOURCE_LIST TranslatedResourceAssignment; 00773 NTSTATUS Status; 00774 } IOP_RESOURCE_REQUEST, *PIOP_RESOURCE_REQUEST; 00775 00776 // 00777 // Misc 00778 // 00779 00780 // 00781 // Enumeration request type 00782 // 00783 00784 typedef enum _DEVICE_REQUEST_TYPE { 00785 ReenumerateDeviceTree, 00786 ReenumerateDeviceOnly, 00787 ReenumerateBootDevices, 00788 RestartEnumeration, 00789 AssignResources, 00790 ResourceRequirementsChanged, 00791 StartDevice, 00792 ReenumerateRootDevices 00793 } DEVICE_REQUEST_TYPE; 00794 00795 typedef struct _PI_DEVICE_REQUEST { 00796 LIST_ENTRY ListEntry; 00797 PDEVICE_OBJECT DeviceObject; 00798 DEVICE_REQUEST_TYPE RequestType; 00799 PKEVENT CompletionEvent; 00800 PNTSTATUS CompletionStatus; 00801 } PI_DEVICE_REQUEST, *PPI_DEVICE_REQUEST; 00802 00803 #define CmResourceTypeReserved 0xf0 00804 00805 00806 00807 // 00808 // This macro returns the pointer to the beginning of the data 00809 // area of KEY_VALUE_FULL_INFORMATION structure. 00810 // In the macro, k is a pointer to KEY_VALUE_FULL_INFORMATION structure. 00811 // 00812 00813 #define KEY_VALUE_DATA(k) ((PCHAR)(k) + (k)->DataOffset) 00814 00815 // 00816 // Save failure status info. 00817 // 00818 00819 #if DBG_SCOPE 00820 #define SAVE_FAILURE_INFO(DeviceNode, Status) (DeviceNode)->FailureStatus = (Status) 00821 #else 00822 #define SAVE_FAILURE_INFO(DeviceNode, Status) 00823 #endif 00824 00825 #define IopDoesDevNodeHaveProblem(devnode) \ 00826 ((devnode)->Flags & (DNF_HAS_PROBLEM | DNF_HAS_PRIVATE_PROBLEM)) 00827 00828 #define IopIsDevNodeProblem(devnode, problem) \ 00829 (((devnode)->Flags & DNF_HAS_PROBLEM) && (devnode)->Problem == (problem)) 00830 00831 #define IopClearDevNodeProblem(devnode) \ 00832 (devnode)->Flags &= ~DNF_HAS_PROBLEM; \ 00833 (devnode)->Problem = 0; 00834 00835 #define IopSetDevNodeProblem(devnode, problem) \ 00836 ASSERT(((devnode)->Flags & DNF_PROCESSED) || !((devnode)->Flags & DNF_ENUMERATED)); \ 00837 ASSERT(!((devnode)->Flags & (DNF_STARTED | DNF_HAS_PROBLEM | DNF_HAS_PRIVATE_PROBLEM))); \ 00838 ASSERT(problem != 0); \ 00839 (devnode)->Flags |= DNF_HAS_PROBLEM; \ 00840 (devnode)->Problem = (problem); 00841 00842 #define IopIsProblemReadonly(problem) \ 00843 ((problem) != CM_PROB_FAILED_INSTALL && \ 00844 (problem) != CM_PROB_FAILED_ADD && \ 00845 (problem) != CM_PROB_FAILED_START && \ 00846 (problem) != CM_PROB_NOT_CONFIGURED && \ 00847 (problem) != CM_PROB_NEED_RESTART && \ 00848 (problem) != CM_PROB_REINSTALL && \ 00849 (problem) != CM_PROB_REGISTRY && \ 00850 (problem) != CM_PROB_DISABLED) 00851 00852 //++ 00853 // 00854 // VOID 00855 // IopRegistryDataToUnicodeString( 00856 // OUT PUNICODE_STRING u, 00857 // IN PWCHAR p, 00858 // IN ULONG l 00859 // ) 00860 // 00861 //-- 00862 #define IopRegistryDataToUnicodeString(u, p, l) \ 00863 { \ 00864 ULONG len; \ 00865 \ 00866 PiRegSzToString((p), (l), &len, NULL); \ 00867 (u)->Length = (USHORT)len; \ 00868 (u)->MaximumLength = (USHORT)(l); \ 00869 (u)->Buffer = (p); \ 00870 } 00871 00872 // 00873 // Title Index to set registry key value 00874 // 00875 00876 #define TITLE_INDEX_VALUE 0 00877 00878 #if DBG 00879 #define PNP_ASSERT(condition, message) \ 00880 if (!(condition)) { \ 00881 DbgPrint((message)); \ 00882 DbgBreakPoint(); \ 00883 } 00884 #else 00885 #define PNP_ASSERT(condition, message) 00886 #endif 00887 00888 // 00889 // Default value of PnpDetectionEnabled 00890 // Only used if the CCS\Control\Pnp key is absent or garbled 00891 // 00892 00893 #define PNP_DETECTION_ENABLED_DEFAULT TRUE 00894 00895 // 00896 // Size of scratch buffer used in this module. 00897 // 00898 00899 #define PNP_SCRATCH_BUFFER_SIZE 512 00900 #define PNP_LARGE_SCRATCH_BUFFER_SIZE (PNP_SCRATCH_BUFFER_SIZE * 8) 00901 00902 // 00903 // Define Device Instance Flags (used by IoQueryDeviceConfiguration apis) 00904 // 00905 00906 #define DEVINSTANCE_FLAG_HWPROFILE_DISABLED 0x1 00907 #define DEVINSTANCE_FLAG_PNP_ENUMERATED 0x2 00908 00909 // 00910 // Define Enumeration Control Flags (used by IopApplyFunctionToSubKeys) 00911 // 00912 00913 #define FUNCTIONSUBKEY_FLAG_IGNORE_NON_CRITICAL_ERRORS 0x1 00914 #define FUNCTIONSUBKEY_FLAG_DELETE_SUBKEYS 0x2 00915 00916 // 00917 // The following definitions are used in IoOpenDeviceInstanceKey 00918 // 00919 00920 #define PLUGPLAY_REGKEY_DEVICE 1 00921 #define PLUGPLAY_REGKEY_DRIVER 2 00922 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4 00923 00924 // 00925 // Define device extension for devices reported with IoReportDetectedDevice. 00926 // 00927 00928 typedef struct _IOPNP_DEVICE_EXTENSION { 00929 PWCHAR CompatibleIdList; 00930 ULONG CompatibleIdListSize; 00931 } IOPNP_DEVICE_EXTENSION, *PIOPNP_DEVICE_EXTENSION; 00932 00933 // 00934 // Reserve Boot Resources 00935 // 00936 00937 typedef struct _IOP_RESERVED_RESOURCES_RECORD IOP_RESERVED_RESOURCES_RECORD, *PIOP_RESERVED_RESOURCES_RECORD; 00938 00939 struct _IOP_RESERVED_RESOURCES_RECORD { 00940 PIOP_RESERVED_RESOURCES_RECORD Next; 00941 PDEVICE_OBJECT DeviceObject; 00942 PCM_RESOURCE_LIST ReservedResources; 00943 }; 00944 00945 // 00946 // External References 00947 // 00948 00949 // 00950 // Init data 00951 // 00952 extern PVOID IopPnpScratchBuffer1; 00953 extern PVOID IopPnpScratchBuffer2; 00954 extern PCM_RESOURCE_LIST IopInitHalResources; 00955 extern PDEVICE_NODE IopInitHalDeviceNode; 00956 extern PIOP_RESERVED_RESOURCES_RECORD IopInitReservedResourceList; 00957 00958 // 00959 // Regular data 00960 // 00961 00962 // 00963 // IopRootDeviceNode - the head of the PnP manager's device node tree. 00964 // 00965 00966 extern PDEVICE_NODE IopRootDeviceNode; 00967 00968 // 00969 // IopPnPDriverObject - the madeup driver object for pnp manager 00970 // 00971 00972 extern PDRIVER_OBJECT IopPnPDriverObject; 00973 00974 // 00975 // IopPnPSpinLock - spinlock for Pnp code. 00976 // 00977 00978 extern KSPIN_LOCK IopPnPSpinLock; 00979 00980 // 00981 // IopPnpDeleteRequestList - a link list of device removal requests to worker thread. 00982 // 00983 00984 extern LIST_ENTRY IopPnpDeleteRequestList; 00985 00986 // 00987 // IopPnpEnumerationRequestList - a link list of device enumeration requests to worker thread. 00988 // 00989 00990 extern LIST_ENTRY IopPnpEnumerationRequestList; 00991 00992 // 00993 // IopDeviceTreeLock - performs syncronization on the whole device node tree. 00994 // IopAcquireEnumerationLock acquires this lock shared then optionally 00995 // acquires an exclusive lock on a devnode. 00996 // IopAcquireDeviceTreeLock acquires this lock exclusive 00997 // 00998 00999 extern ERESOURCE IopDeviceTreeLock; 01000 01001 // 01002 // PiEventQueueEmpty - Manual reset event which is set when the queue is empty 01003 // 01004 01005 extern KEVENT PiEventQueueEmpty; 01006 01007 // 01008 // PiEnumerationLock - to synchronize IoInvalidateDeviceRelations in boot phase. 01009 // 01010 01011 extern KEVENT PiEnumerationLock; 01012 01013 // 01014 // iopEnumerationCount - indicates how many devices are being enumerated. 01015 // 01016 01017 extern LONG IopEnumerationCount; 01018 01019 // 01020 // IopNumberDeviceNodes - Number of outstanding device nodes in the system 01021 // 01022 01023 extern ULONG IopNumberDeviceNodes; 01024 01025 // 01026 // PnPInitialized - A flag to indicate if PnP initialization is completed. 01027 // 01028 01029 extern BOOLEAN PnPInitialized; 01030 01031 // 01032 // PnPBootDriverInitialied 01033 // 01034 01035 extern BOOLEAN PnPBootDriversInitialized; 01036 01037 // 01038 // PnPBootDriverLoaded 01039 // 01040 01041 extern BOOLEAN PnPBootDriversLoaded; 01042 01043 // 01044 // IopBootConfigsReserved - Indicates whether we have reserved BOOT configs or not. 01045 // 01046 01047 extern BOOLEAN IopBootConfigsReserved; 01048 01049 // 01050 // IopResourcesReleased - a flag to indicate if a device is removed and its resources 01051 // are freed. This is for reallocating resources for DNF_INSUFFICIENT_RESOURCES 01052 // devices. 01053 // 01054 01055 extern BOOLEAN IopResourcesReleased; 01056 01057 // 01058 // PnPDetectionEnabled - A flag to indicate if detection code can be executed 01059 // 01060 01061 extern BOOLEAN PnPDetectionEnabled; 01062 01063 // 01064 // PnpDefaultInterfaceTYpe - Use this if the interface type of resource list is unknown. 01065 // 01066 01067 extern INTERFACE_TYPE PnpDefaultInterfaceType; 01068 01069 // 01070 // PnpStartAsynOk - control how start irp should be handled. Synchronously or Asynchronously? 01071 // 01072 01073 extern BOOLEAN PnpAsyncOk; 01074 01075 // 01076 // IopPendingEjects - List of pending eject requests 01077 // 01078 extern LIST_ENTRY IopPendingEjects; 01079 01080 // 01081 // IopPendingSurpriseRemovals - List of pending surprise removal requests 01082 // 01083 extern LIST_ENTRY IopPendingSurpriseRemovals; 01084 01085 01086 NTSTATUS 01087 IopAppendStringToValueKey ( 01088 IN HANDLE Handle, 01089 IN PWSTR ValueName, 01090 IN PUNICODE_STRING String, 01091 IN BOOLEAN Create 01092 ); 01093 01094 NTSTATUS 01095 IopPrepareDriverLoading ( 01096 IN PUNICODE_STRING KeyName, 01097 IN HANDLE KeyHandle, 01098 IN PIMAGE_NT_HEADERS Header 01099 ); 01100 01101 NTSTATUS 01102 IopRemoveStringFromValueKey ( 01103 IN HANDLE Handle, 01104 IN PWSTR ValueName, 01105 IN PUNICODE_STRING String 01106 ); 01107 01108 BOOLEAN 01109 IopIsDuplicatedDevices( 01110 IN PCM_RESOURCE_LIST Configuration1, 01111 IN PCM_RESOURCE_LIST Configuration2, 01112 IN PHAL_BUS_INFORMATION BusInfo1 OPTIONAL, 01113 IN PHAL_BUS_INFORMATION BusInfo2 OPTIONAL 01114 ); 01115 01116 NTSTATUS 01117 IopMarkDuplicateDevice( 01118 IN PUNICODE_STRING TargetKeyName, 01119 IN ULONG TargetInstance, 01120 IN PUNICODE_STRING SourceKeyName, 01121 IN ULONG SourceInstance 01122 ); 01123 01124 BOOLEAN 01125 IopConcatenateUnicodeStrings ( 01126 OUT PUNICODE_STRING Destination, 01127 IN PUNICODE_STRING String1, 01128 IN PUNICODE_STRING String2 OPTIONAL 01129 ); 01130 01131 NTSTATUS 01132 IopServiceInstanceToDeviceInstance ( 01133 IN HANDLE ServiceKeyHandle OPTIONAL, 01134 IN PUNICODE_STRING ServiceKeyName OPTIONAL, 01135 IN ULONG ServiceInstanceOrdinal, 01136 OUT PUNICODE_STRING DeviceInstanceRegistryPath OPTIONAL, 01137 OUT PHANDLE DeviceInstanceHandle OPTIONAL, 01138 IN ACCESS_MASK DesiredAccess 01139 ); 01140 01141 NTSTATUS 01142 IopCreateRegistryKeyEx( 01143 OUT PHANDLE Handle, 01144 IN HANDLE BaseHandle OPTIONAL, 01145 IN PUNICODE_STRING KeyName, 01146 IN ACCESS_MASK DesiredAccess, 01147 IN ULONG CreateOptions, 01148 OUT PULONG Disposition OPTIONAL 01149 ); 01150 01151 NTSTATUS 01152 IopOpenRegistryKeyEx( 01153 OUT PHANDLE Handle, 01154 IN HANDLE BaseHandle OPTIONAL, 01155 IN PUNICODE_STRING KeyName, 01156 IN ACCESS_MASK DesiredAccess 01157 ); 01158 01159 NTSTATUS 01160 IopCreateMadeupNode( 01161 IN PUNICODE_STRING ServiceKeyName, 01162 OUT PHANDLE ReturnedHandle, 01163 OUT PUNICODE_STRING KeyName, 01164 OUT PULONG InstanceOrdinal, 01165 IN BOOLEAN ResourceOwned 01166 ); 01167 01168 NTSTATUS 01169 IopInitializePlugPlayServices( 01170 IN PLOADER_PARAMETER_BLOCK LoaderBlock, 01171 IN ULONG Phase 01172 ); 01173 01174 NTSTATUS 01175 IopOpenServiceEnumKeys ( 01176 IN PUNICODE_STRING ServiceKeyName, 01177 IN ACCESS_MASK DesiredAccess, 01178 OUT PHANDLE ServiceHandle OPTIONAL, 01179 OUT PHANDLE ServiceEnumHandle OPTIONAL, 01180 IN BOOLEAN CreateEnum 01181 ); 01182 01183 NTSTATUS 01184 IopOpenCurrentHwProfileDeviceInstanceKey( 01185 OUT PHANDLE Handle, 01186 IN PUNICODE_STRING ServiceKeyName, 01187 IN ULONG Instance, 01188 IN ACCESS_MASK DesiredAccess, 01189 IN BOOLEAN Create 01190 ); 01191 01192 NTSTATUS 01193 IopGetDeviceInstanceCsConfigFlags( 01194 IN PUNICODE_STRING DeviceInstance, 01195 OUT PULONG CsConfigFlags 01196 ); 01197 01198 NTSTATUS 01199 IopGetServiceInstanceCsConfigFlags( 01200 IN PUNICODE_STRING ServiceKeyName, 01201 IN ULONG Instance, 01202 OUT PULONG CsConfigFlags 01203 ); 01204 01205 NTSTATUS 01206 IopSetServiceInstanceCsConfigFlags( 01207 IN PUNICODE_STRING ServiceKeyName, 01208 IN ULONG Instance, 01209 IN ULONG CsConfigFlags 01210 ); 01211 01212 NTSTATUS 01213 IopApplyFunctionToSubKeys( 01214 IN HANDLE BaseHandle OPTIONAL, 01215 IN PUNICODE_STRING KeyName, 01216 IN ACCESS_MASK DesiredAccess, 01217 IN ULONG Flags, 01218 IN PIOP_SUBKEY_CALLBACK_ROUTINE SubKeyCallbackRoutine, 01219 IN OUT PVOID Context 01220 ); 01221 01222 NTSTATUS 01223 IopRegMultiSzToUnicodeStrings( 01224 IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation, 01225 IN PUNICODE_STRING *UnicodeStringList, 01226 OUT PULONG UnicodeStringCount 01227 ); 01228 01229 01230 NTSTATUS 01231 IopApplyFunctionToServiceInstances( 01232 IN HANDLE ServiceKeyHandle OPTIONAL, 01233 IN PUNICODE_STRING ServiceKeyName OPTIONAL, 01234 IN ACCESS_MASK DesiredAccess, 01235 IN BOOLEAN IgnoreNonCriticalErrors, 01236 IN PIOP_SUBKEY_CALLBACK_ROUTINE DevInstCallbackRoutine, 01237 IN OUT PVOID Context, 01238 OUT PULONG ServiceInstanceOrdinal OPTIONAL 01239 ); 01240 01241 VOID 01242 IopFreeUnicodeStringList( 01243 IN PUNICODE_STRING UnicodeStringList, 01244 IN ULONG StringCount 01245 ); 01246 01247 NTSTATUS 01248 IopDriverLoadingFailed( 01249 IN HANDLE KeyHandle OPTIONAL, 01250 IN PUNICODE_STRING KeyName OPTIONAL 01251 ); 01252 01253 NTSTATUS 01254 IopReadDeviceConfiguration ( 01255 IN HANDLE Handle, 01256 IN ULONG Flags, 01257 OUT PCM_RESOURCE_LIST *CmResource, 01258 OUT PULONG Length 01259 ); 01260 01261 BOOLEAN 01262 IopIsFirmwareMapperDevicePresent ( 01263 IN HANDLE KeyHandle 01264 ); 01265 01266 #define IopAcquireEnumerationLock(_devnode_) \ 01267 ExAcquireResourceShared(&IopDeviceTreeLock, TRUE); \ 01268 if ((_devnode_)) { \ 01269 KeWaitForSingleObject( &((PDEVICE_NODE)(_devnode_))->EnumerationMutex, \ 01270 Executive, \ 01271 KernelMode, \ 01272 FALSE, \ 01273 NULL ); \ 01274 } 01275 01276 #define IopReleaseEnumerationLock(_devnode_) \ 01277 if ((_devnode_)) { \ 01278 KeSetEvent( &((PDEVICE_NODE)(_devnode_))->EnumerationMutex, \ 01279 0, \ 01280 FALSE ); \ 01281 } \ 01282 ExReleaseResource(&IopDeviceTreeLock); 01283 01284 01285 #define IopReleaseEnumerationLockForThread(_devnode_, _thread_) \ 01286 if ((_devnode_)) { \ 01287 KeSetEvent( &((PDEVICE_NODE)(_devnode_))->EnumerationMutex, \ 01288 0, \ 01289 FALSE ); \ 01290 } \ 01291 ExReleaseResourceForThreadLite(&IopDeviceTreeLock, _thread_); 01292 01293 #define IopAcquireDeviceTreeLock() ExAcquireResourceExclusive(&IopDeviceTreeLock, TRUE) 01294 #define IopReleaseDeviceTreeLock() ExReleaseResource(&IopDeviceTreeLock) 01295 01296 VOID 01297 IopInsertTreeDeviceNode ( 01298 IN PDEVICE_NODE ParentNode, 01299 IN PDEVICE_NODE DeviceNode 01300 ); 01301 01302 VOID 01303 IopRemoveTreeDeviceNode ( 01304 IN PDEVICE_NODE DeviceNode 01305 ); 01306 01307 PDEVICE_NODE 01308 IopAllocateDeviceNode( 01309 IN PDEVICE_OBJECT PhysicalDeviceObject 01310 ); 01311 01312 #if DBG 01313 VOID 01314 IopCheckDeviceNodeTree ( 01315 IN PDEVICE_OBJECT TargetDevice OPTIONAL, 01316 IN PDEVICE_NODE TargetNode OPTIONAL 01317 ); 01318 #endif 01319 01320 NTSTATUS 01321 IopForAllDeviceNodes( 01322 IN PENUM_CALLBACK Callback, 01323 IN PVOID Context 01324 ); 01325 01326 ULONG 01327 IopDetermineResourceListSize( 01328 IN PCM_RESOURCE_LIST ResourceList 01329 ); 01330 01331 NTSTATUS 01332 IopQueryDeviceConfigurationVector( 01333 IN PUNICODE_STRING ServiceKeyName, 01334 IN ULONG InstanceOrdinal, 01335 OUT PULONG DeviceInstanceFlags, 01336 OUT PIO_RESOURCE_REQUIREMENTS_LIST ConfigurationVector, 01337 IN ULONG BufferSize, 01338 OUT PULONG ActualBufferSize 01339 ); 01340 01341 PDRIVER_OBJECT 01342 IopReferenceDriverObjectByName ( 01343 IN PUNICODE_STRING DriverName 01344 ); 01345 01346 PDEVICE_OBJECT 01347 IopDeviceObjectFromDeviceInstance ( 01348 IN HANDLE DeviceInstanceHandle OPTIONAL, 01349 IN PUNICODE_STRING DeviceInstance OPTIONAL 01350 ); 01351 01352 NTSTATUS 01353 IopDeviceObjectToDeviceInstance ( 01354 IN PDEVICE_OBJECT DeviceObject, 01355 IN PHANDLE DeviceInstanceHandle, 01356 IN ACCESS_MASK DesiredAccess 01357 ); 01358 01359 BOOLEAN 01360 IopIsDeviceInstanceEnabled( 01361 IN HANDLE DeviceInstanceHandle, 01362 IN PUNICODE_STRING DeviceInstance, 01363 IN BOOLEAN DisableIfEnabled 01364 ); 01365 01366 NTSTATUS 01367 IopAddDevicesToBootDriver ( 01368 IN PDRIVER_OBJECT DriverObject 01369 ); 01370 01371 USHORT 01372 IopProcessAddDevices ( 01373 IN PDEVICE_NODE DeviceNode, 01374 IN USHORT StartOrder, 01375 IN ULONG DriverStartType 01376 ); 01377 01378 BOOLEAN 01379 IopProcessAssignResources ( 01380 IN PDEVICE_NODE DeviceNode, 01381 IN BOOLEAN Reallocation, 01382 IN BOOLEAN BootConfigsOK 01383 ); 01384 01385 VOID 01386 IopProcessStartDevices ( 01387 IN PDEVICE_NODE DeviceNode, 01388 IN PSTART_CONTEXT StartContext 01389 ); 01390 01391 VOID 01392 IopStartDevice ( 01393 IN PDEVICE_OBJECT TargetDevice 01394 ); 01395 01396 NTSTATUS 01397 IopEjectDevice( 01398 IN PDEVICE_OBJECT DeviceObject, 01399 PPENDING_RELATIONS_LIST_ENTRY PendingEntry 01400 ); 01401 01402 NTSTATUS 01403 IopRemoveDevice ( 01404 IN PDEVICE_OBJECT TargetDevice, 01405 IN ULONG IrpMinorCode 01406 ); 01407 01408 NTSTATUS 01409 IopQueryDeviceRelations( 01410 IN DEVICE_RELATION_TYPE Relations, 01411 IN PDEVICE_OBJECT DeviceObject, 01412 IN BOOLEAN AsyncOk, 01413 OUT PDEVICE_RELATIONS *DeviceRelations 01414 ); 01415 01416 NTSTATUS 01417 IopQueryDeviceState( 01418 IN PDEVICE_OBJECT DeviceObject 01419 ); 01420 01421 NTSTATUS 01422 IopQueryDeviceSerialNumber ( 01423 IN PDEVICE_OBJECT DeviceObject, 01424 OUT PWCHAR *SerialNumber 01425 ); 01426 01427 NTSTATUS 01428 IopForAllChildDeviceNodes( 01429 IN PDEVICE_NODE Parent, 01430 IN PENUM_CALLBACK Callback, 01431 IN PVOID Context 01432 ); 01433 01434 NTSTATUS 01435 IopCleanupDeviceRegistryValues ( 01436 IN PUNICODE_STRING InstancePath, 01437 IN BOOLEAN KeepReference 01438 ); 01439 01440 NTSTATUS 01441 IopQueryDeviceId ( 01442 IN PDEVICE_OBJECT DeviceObject, 01443 OUT PWCHAR *DeviceId 01444 ); 01445 01446 NTSTATUS 01447 IopQueryUniqueId ( 01448 IN PDEVICE_OBJECT DeviceObject, 01449 OUT PWCHAR *UniqueId 01450 ); 01451 01452 NTSTATUS 01453 IopMakeGloballyUniqueId( 01454 IN PDEVICE_OBJECT DeviceObject, 01455 IN PWCHAR UniqueId, 01456 OUT PWCHAR *GloballyUniqueId 01457 ); 01458 01459 01460 NTSTATUS 01461 IopQueryCompatibleIds ( 01462 IN PDEVICE_OBJECT DeviceObject, 01463 IN BUS_QUERY_ID_TYPE IdType, 01464 OUT PWCHAR *CompatibleIds, 01465 OUT ULONG *Length 01466 ); 01467 01468 NTSTATUS 01469 IopQueryDeviceResources ( 01470 IN PDEVICE_OBJECT DeviceObject, 01471 IN ULONG ResourceType, 01472 OUT PVOID *Resource, 01473 OUT ULONG *Length 01474 ); 01475 01476 NTSTATUS 01477 IopGetDeviceResourcesFromRegistry ( 01478 IN PDEVICE_OBJECT DeviceObject, 01479 IN ULONG ResourceType, 01480 IN ULONG Preference, 01481 OUT PVOID *Resource, 01482 OUT PULONG Length 01483 ); 01484 01485 VOID 01486 IopResourceRequirementsChanged( 01487 IN PDEVICE_OBJECT PhysicalDeviceObject, 01488 IN BOOLEAN StopRequired 01489 ); 01490 01491 NTSTATUS 01492 IopReleaseDeviceResources ( 01493 IN PDEVICE_NODE DeviceNode, 01494 IN BOOLEAN ReserveResources 01495 ); 01496 01497 NTSTATUS 01498 IopPnPAddDevice( 01499 IN PDRIVER_OBJECT DriverObject, 01500 IN PDEVICE_OBJECT DeviceObject 01501 ); 01502 01503 BOOLEAN 01504 IopProcessCriticalDevice( 01505 IN PDEVICE_NODE DeviceNode 01506 ); 01507 01508 NTSTATUS 01509 IopPnPDispatch( 01510 IN PDEVICE_OBJECT DeviceObject, 01511 IN OUT PIRP Irp 01512 ); 01513 01514 NTSTATUS 01515 IopPowerDispatch( 01516 IN PDEVICE_OBJECT DeviceObject, 01517 IN OUT PIRP Irp 01518 ); 01519 01520 VOID 01521 IopDestroyDeviceNode ( 01522 PDEVICE_NODE DeviceNode 01523 ); 01524 01525 NTSTATUS 01526 IopStartAndEnumerateDevice( 01527 IN PDEVICE_NODE DeviceNode, 01528 IN PSTART_CONTEXT StartContext 01529 ); 01530 01531 NTSTATUS 01532 IopCallDriverAddDevice ( 01533 IN PDEVICE_NODE DeviceNode, 01534 IN BOOLEAN LoadDriver, 01535 IN PADD_CONTEXT AddContext 01536 ); 01537 01538 NTSTATUS 01539 IopStartDriverDevices( 01540 IN PDRIVER_OBJECT DriverObject 01541 ); 01542 01543 BOOLEAN 01544 IopIsLegacyDriver ( 01545 IN PDRIVER_OBJECT DriverObject 01546 ); 01547 01548 VOID 01549 IopNewDevice( 01550 IN PDEVICE_OBJECT DeviceObject 01551 ); 01552 01553 NTSTATUS 01554 IopProcessNewDeviceNode( 01555 IN OUT PDEVICE_NODE DeviceNode 01556 ); 01557 01558 NTSTATUS 01559 IopSynchronousCall( 01560 IN PDEVICE_OBJECT DeviceObject, 01561 IN PIO_STACK_LOCATION TopStackLocation, 01562 OUT PVOID *Information 01563 ); 01564 01565 NTSTATUS 01566 IopFilterResourceRequirementsList ( 01567 IN PIO_RESOURCE_REQUIREMENTS_LIST IoList, 01568 IN PCM_RESOURCE_LIST CmList, 01569 IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *FilteredList, 01570 OUT PBOOLEAN ExactMatch 01571 ); 01572 01573 NTSTATUS 01574 IopMergeFilteredResourceRequirementsList ( 01575 IN PIO_RESOURCE_REQUIREMENTS_LIST IoList1, 01576 IN PIO_RESOURCE_REQUIREMENTS_LIST IoList2, 01577 IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *MergedList 01578 ); 01579 01580 NTSTATUS 01581 IopMergeCmResourceLists ( 01582 IN PCM_RESOURCE_LIST List1, 01583 IN PCM_RESOURCE_LIST List2, 01584 IN OUT PCM_RESOURCE_LIST *MergedList 01585 ); 01586 01587 PIO_RESOURCE_REQUIREMENTS_LIST 01588 IopCmResourcesToIoResources ( 01589 IN ULONG SlotNumber, 01590 IN PCM_RESOURCE_LIST CmResourceList, 01591 IN ULONG Priority 01592 ); 01593 01594 NTSTATUS 01595 IopReportResourceListToPnp( 01596 IN PDRIVER_OBJECT DriverObject OPTIONAL, 01597 IN PDEVICE_OBJECT DeviceObject OPTIONAL, 01598 IN PCM_RESOURCE_LIST ResourceList, 01599 IN ULONG ListSize, 01600 IN BOOLEAN Translated 01601 ); 01602 01603 NTSTATUS 01604 IopAllocateResources( 01605 IN PULONG DeviceCountP, 01606 IN OUT PIOP_RESOURCE_REQUEST *AssignTablePP, 01607 IN BOOLEAN Locked, 01608 IN BOOLEAN BootConfigsOK 01609 ); 01610 01611 VOID 01612 IopReallocateResources( 01613 IN PDEVICE_OBJECT DeviceObject 01614 ); 01615 01616 NTSTATUS 01617 IopWriteResourceList( 01618 IN HANDLE ResourceMapKey, 01619 IN PUNICODE_STRING ClassName, 01620 IN PUNICODE_STRING DriverName, 01621 IN PUNICODE_STRING DeviceName, 01622 IN PCM_RESOURCE_LIST ResourceList, 01623 IN ULONG ResourceListSize 01624 ); 01625 01626 VOID 01627 IopRemoveResourceListFromPnp( 01628 IN PLIST_ENTRY ResourceList 01629 ); 01630 01631 NTSTATUS 01632 IopWriteAllocatedResourcesToRegistry ( 01633 IN PDEVICE_NODE DeviceNode, 01634 IN PCM_RESOURCE_LIST ResourceList, 01635 IN ULONG Length 01636 ); 01637 01638 USHORT 01639 IopGetGroupOrderIndex ( 01640 IN HANDLE ServiceHandle 01641 ); 01642 01643 VOID 01644 IopDeleteLegacyKey( 01645 IN PDRIVER_OBJECT DriverObject 01646 ); 01647 01648 NTSTATUS 01649 IopOpenDeviceParametersSubkey( 01650 OUT HANDLE *ParamKeyHandle, 01651 IN HANDLE ParentKeyHandle, 01652 IN PUNICODE_STRING SubKeyString, 01653 IN ACCESS_MASK DesiredAccess 01654 ); 01655 01656 NTSTATUS 01657 IopRequestDeviceAction( 01658 IN PDEVICE_OBJECT DeviceObject OPTIONAL, 01659 IN DEVICE_REQUEST_TYPE RequestType, 01660 IN PKEVENT CompletionEvent OPTIONAL, 01661 IN PNTSTATUS CompletionStatus OPTIONAL 01662 ); 01663 01664 NTSTATUS 01665 IopRequestDeviceRemoval( 01666 IN PDEVICE_OBJECT DeviceObject, 01667 IN ULONG Problem 01668 ); 01669 01670 NTSTATUS 01671 IopRestartDeviceNode( 01672 IN PDEVICE_NODE DeviceNode 01673 ); 01674 01675 NTSTATUS 01676 IopDeleteKeyRecursive( 01677 IN HANDLE SubKeyHandle, 01678 IN PWCHAR SubKeyName 01679 ); 01680 01681 NTSTATUS 01682 IopQueryPnpBusInformation ( 01683 IN PDEVICE_OBJECT DeviceObject, 01684 OUT LPGUID InterfaceGuid OPTIONAL, 01685 OUT INTERFACE_TYPE *InterfaceType OPTIONAL, 01686 OUT ULONG *BusNumber OPTIONAL 01687 ); 01688 01689 NTSTATUS 01690 IopQueryLegacyBusInformation ( 01691 IN PDEVICE_OBJECT DeviceObject, 01692 OUT LPGUID InterfaceGuid OPTIONAL, 01693 OUT INTERFACE_TYPE *InterfaceType OPTIONAL, 01694 OUT ULONG *BusNumber OPTIONAL 01695 ); 01696 01697 NTSTATUS 01698 IopGetRootDevices ( 01699 PDEVICE_RELATIONS *DeviceRelations 01700 ); 01701 01702 NTSTATUS 01703 IopLockDeviceRemovalRelations( 01704 IN PDEVICE_OBJECT DeviceObject, 01705 IN PLUGPLAY_DEVICE_DELETE_TYPE OperationCode, 01706 OUT PRELATION_LIST *RelationsList, 01707 IN BOOLEAN IsKernelInitiated 01708 ); 01709 01710 NTSTATUS 01711 IopDeleteLockedDeviceNodes( 01712 IN PDEVICE_OBJECT DeviceObject, 01713 IN PRELATION_LIST RelationsList, 01714 IN PLUGPLAY_DEVICE_DELETE_TYPE OperationCode, 01715 IN BOOLEAN IsKernelInitiated, 01716 IN BOOLEAN ProcessIndirectDescendants, 01717 IN ULONG Problem, 01718 OUT PDEVICE_OBJECT *VetoingDevice OPTIONAL 01719 ); 01720 01721 NTSTATUS 01722 IopUnlockDeviceRemovalRelations( 01723 IN PDEVICE_OBJECT DeviceObject, 01724 IN PRELATION_LIST RelationsList, 01725 IN UNLOCK_UNLINK_ACTION UnlinkAction 01726 ); 01727 01728 NTSTATUS 01729 IopInvalidateRelationsInList( 01730 PRELATION_LIST RelationsList, 01731 BOOLEAN OnlyIndirectDescendants, 01732 BOOLEAN UnlockDevNode, 01733 BOOLEAN RestartDevNode 01734 ); 01735 01736 VOID 01737 IopChainDereferenceComplete( 01738 IN PDEVICE_OBJECT PhysicalDeviceObject 01739 ); 01740 01741 BOOLEAN 01742 IopQueuePendingEject( 01743 PPENDING_RELATIONS_LIST_ENTRY Entry 01744 ); 01745 01746 VOID 01747 IopProcessCompletedEject( 01748 IN PVOID Context 01749 ); 01750 01751 BOOLEAN 01752 IopQueuePendingSurpriseRemoval( 01753 IN PDEVICE_OBJECT DeviceObject, 01754 IN PRELATION_LIST List, 01755 IN ULONG Problem 01756 ); 01757 01758 BOOLEAN 01759 IopIsAnyDeviceInstanceEnabled( 01760 IN PUNICODE_STRING ServiceKeyName, 01761 IN HANDLE ServiceHandle, 01762 IN BOOLEAN LegacyIncluded 01763 ); 01764 01765 NTSTATUS 01766 IopQueryResourceHandlerInterface( 01767 IN RESOURCE_HANDLER_TYPE HandlerType, 01768 IN PDEVICE_OBJECT DeviceObject, 01769 IN UCHAR ResourceType, 01770 IN OUT PVOID *Interface 01771 ); 01772 01773 NTSTATUS 01774 IopQueryReconfiguration( 01775 IN UCHAR Request, 01776 IN PDEVICE_OBJECT DeviceObject 01777 ); 01778 01779 PDEVICE_NODE 01780 IopFindBusDeviceNode ( 01781 IN PDEVICE_NODE DeviceNode, 01782 IN INTERFACE_TYPE InterfaceType, 01783 IN ULONG BusNumber, 01784 IN ULONG SlotNumber 01785 ); 01786 01787 NTSTATUS 01788 IopLegacyResourceAllocation ( 01789 IN ARBITER_REQUEST_SOURCE AllocationType, 01790 IN PDRIVER_OBJECT DriverObject, 01791 IN PDEVICE_OBJECT DeviceObject, 01792 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, 01793 IN OUT PCM_RESOURCE_LIST *AllocatedResources OPTIONAL 01794 ); 01795 01796 NTSTATUS 01797 IoReportResourceUsageInternal( 01798 IN ARBITER_REQUEST_SOURCE AllocationType, 01799 IN PUNICODE_STRING DriverClassName OPTIONAL, 01800 IN PDRIVER_OBJECT DriverObject, 01801 IN PCM_RESOURCE_LIST DriverList OPTIONAL, 01802 IN ULONG DriverListSize OPTIONAL, 01803 IN PDEVICE_OBJECT DeviceObject OPTIONAL, 01804 IN PCM_RESOURCE_LIST DeviceList OPTIONAL, 01805 IN ULONG DeviceListSize OPTIONAL, 01806 IN BOOLEAN OverrideConflict, 01807 OUT PBOOLEAN ConflictDetected 01808 ); 01809 01810 NTSTATUS 01811 IopDuplicateDetection ( 01812 IN INTERFACE_TYPE LegacyBusType, 01813 IN ULONG BusNumber, 01814 IN ULONG SlotNumber, 01815 OUT PDEVICE_NODE *DeviceNode 01816 ); 01817 01818 #if 0 01819 NTSTATUS 01820 IopTranslateResourceList( 01821 IN PDEVICE_NODE DeviceNode OPTIONAL, 01822 IN PCM_RESOURCE_LIST ResourceList, 01823 OUT PCM_RESOURCE_LIST *TranslatedList 01824 ); 01825 #endif 01826 01827 PDRIVER_OBJECT 01828 IopLoadBootFilterDriver ( 01829 IN PUNICODE_STRING DriverName, 01830 IN ULONG GroupIndex 01831 ); 01832 01833 NTSTATUS 01834 IopDeviceNodeCapabilitiesToRegistry ( 01835 IN PDEVICE_NODE DeviceNode 01836 ); 01837 01838 NTSTATUS 01839 IopDeviceCapabilitiesToRegistry ( 01840 IN PDEVICE_NODE DeviceNode, 01841 IN PDEVICE_CAPABILITIES Capabilities 01842 ); 01843 01844 NTSTATUS 01845 IopQueryDeviceCapabilities( 01846 IN PDEVICE_NODE DeviceNode, 01847 OUT PDEVICE_CAPABILITIES Capabilities 01848 ); 01849 01850 VOID 01851 IopIncDisableableDepends( 01852 IN OUT PDEVICE_NODE DeviceNode 01853 ); 01854 01855 VOID 01856 IopDecDisableableDepends( 01857 IN OUT PDEVICE_NODE DeviceNode 01858 ); 01859 01860 NTSTATUS 01861 IopQueryDockRemovalInterface( 01862 IN PDEVICE_OBJECT DeviceObject, 01863 IN OUT PDOCK_INTERFACE *DockInterface 01864 ); 01865 01866 #ifndef FIELD_SIZE 01867 #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) 01868 #endif 01869 01870 #define IopDeviceNodeFlagsToCapabilities(DeviceNode) \ 01871 ((PDEVICE_CAPABILITIES) (((PUCHAR) (&(DeviceNode)->CapabilityFlags)) - \ 01872 FIELD_OFFSET(DEVICE_CAPABILITIES, Version) - \ 01873 FIELD_SIZE(DEVICE_CAPABILITIES, Version))) 01874 01875 typedef 01876 NTSTATUS 01877 (*PIO_RESERVE_RESOURCES_ROUTINE) ( 01878 IN ARBITER_REQUEST_SOURCE ArbiterRequestSource, 01879 IN PDEVICE_OBJECT DeviceObject, 01880 IN PCM_RESOURCE_LIST BootResources 01881 ); 01882 01883 NTSTATUS 01884 IopReserveBootResources ( 01885 IN ARBITER_REQUEST_SOURCE ArbiterRequestSource, 01886 IN PDEVICE_OBJECT DeviceObject, 01887 IN PCM_RESOURCE_LIST BootResources 01888 ); 01889 01890 NTSTATUS 01891 IopAllocateBootResources ( 01892 IN ARBITER_REQUEST_SOURCE ArbiterRequestSource, 01893 IN PDEVICE_OBJECT DeviceObject, 01894 IN PCM_RESOURCE_LIST BootResources 01895 ); 01896 01897 NTSTATUS 01898 IopReserveLegacyBootResources( 01899 IN INTERFACE_TYPE InterfaceType, 01900 IN ULONG BusNumber 01901 ); 01902 01903 extern PIO_RESERVE_RESOURCES_ROUTINE IopReserveResourcesRoutine; 01904 01905 // 01906 // Conflict detection declarations 01907 // 01908 01909 NTSTATUS 01910 IopQueryConflictList( 01911 PDEVICE_OBJECT PhysicalDeviceObject, 01912 IN PCM_RESOURCE_LIST ResourceList, 01913 IN ULONG ResourceListSize, 01914 OUT PPLUGPLAY_CONTROL_CONFLICT_LIST ConflictList, 01915 IN ULONG ConflictListSize, 01916 IN ULONG Flags 01917 ); 01918 01919 // 01920 // Firmware mapper external declarations. 01921 // 01922 01923 VOID 01924 MapperProcessFirmwareTree( 01925 IN BOOLEAN OnlyProcessSerialPorts 01926 ); 01927 01928 VOID 01929 MapperConstructRootEnumTree( 01930 IN BOOLEAN CreatePhantomDevices 01931 ); 01932 01933 VOID 01934 MapperFreeList( 01935 VOID 01936 ); 01937 01938 NTSTATUS 01939 EisaBuildEisaDeviceNode( 01940 VOID 01941 ); 01942 01943 VOID 01944 MapperPhantomizeDetectedComPorts( 01945 VOID 01946 ); 01947 // 01948 // BUGBUG- for now we need the following dbg routines in free build also such 01949 // that we can track resource allocation by enabling a dbg flag. 01950 //#if DBG 01951 01952 VOID 01953 IopDumpCmResourceList ( 01954 IN PCM_RESOURCE_LIST CmList 01955 ); 01956 01957 VOID 01958 IopDumpCmResourceDescriptor ( 01959 IN PUCHAR Indent, 01960 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Desc 01961 ); 01962 01963 VOID 01964 IopDumpAllocatedSystemResources( 01965 IN UCHAR ResourceType 01966 ); 01967 01968 // #endif 01969 01970 // 01971 // General utility macros 01972 // 01973 01974 // 01975 // This macros calculates the size in bytes of a constant string 01976 // 01977 // ULONG 01978 // IopConstStringSize( 01979 // IN CONST PWSTR String 01980 // ); 01981 // 01982 01983 #define IopConstStringSize(String) ( sizeof(String) - sizeof(UNICODE_NULL) ) 01984 01985 // 01986 // This macros calculates the number of characters of a constant string 01987 // 01988 // ULONG 01989 // IopConstStringLength( 01990 // IN CONST PWSTR String 01991 // ); 01992 // 01993 01994 #define IopConstStringLength(String) ( ( sizeof(String) - sizeof(UNICODE_NULL) ) / sizeof(WCHAR) ) 01995 01996 // 01997 // Kernel Mode (KM) to User Mode (UM) SymbolicLinkName Conversion and Vice Versa 01998 // ie. \??\ <-> \\?\ 01999 // 02000 02001 // 02002 // VOID 02003 // IopKMToUMSymbolicLinkName( 02004 // IN UNICODE_STRING String 02005 // ); 02006 // 02007 02008 #define IopKMToUMSymbolicLinkName(String) \ 02009 ASSERT(String) \ 02010 ASSERT(String->Length > 4) \ 02011 String[1] = L'\\' 02012 02013 // 02014 // VOID 02015 // IopUMToKMSymbolicLinkName( 02016 // IN UNICODE_STRING String 02017 // ); 02018 // 02019 02020 #define IopUMToKMSymbolicLinkName(String) \ 02021 ASSERT(String) \ 02022 ASSERT(String->Length > 4) \ 02023 String[1] = L'?' 02024 02025 // 02026 // Kernel mode notification 02027 // 02028 02029 // 02030 // This macros maps a guid to a hash value based on the number of hash 02031 // buckets we are using. It does this by treating the guid as an array of 02032 // 4 ULONGs, suming them and MOD by the number of hash buckets we are using. 02033 // 02034 // ULONG 02035 // IopHashGuid( 02036 // LPGUID Guid 02037 // ); 02038 // 02039 02040 #define IopHashGuid(_Guid) \ 02041 ( ( ((PULONG)_Guid)[0] + ((PULONG)_Guid)[1] + ((PULONG)_Guid)[2] \ 02042 + ((PULONG)_Guid)[3]) % NOTIFY_DEVICE_CLASS_HASH_BUCKETS) 02043 02044 02045 02046 // This macros abstracts 02047 // 02048 // VOID 02049 // IopAcquireNotifyLock( 02050 // PFAST_MUTEX Lock 02051 // ) 02052 02053 #define IopAcquireNotifyLock(Lock) ExAcquireFastMutex(Lock); 02054 02055 /* 02056 VOID 02057 IopReleaseNotifyLock( 02058 PFAST_MUTEX Lock 02059 ) 02060 */ 02061 #define IopReleaseNotifyLock(Lock) ExReleaseFastMutex(Lock); 02062 02063 02064 // BOOLEAN 02065 // IopCompareGuid( 02066 // IN LPGUID guid1, 02067 // IN LPGUID guid2 02068 // ); 02069 02070 #define IopCompareGuid(g1, g2) ( (g1) == (g2) \ 02071 ? TRUE \ 02072 : RtlCompareMemory( (g1), (g2), sizeof(GUID) ) == sizeof(GUID) \ 02073 ) 02074 02075 VOID 02076 IopInitializePlugPlayNotification( 02077 VOID 02078 ); 02079 02080 NTSTATUS 02081 IopNotifySetupDeviceArrival( 02082 PDEVICE_OBJECT PhysicalDeviceObject, // PDO of the device 02083 HANDLE EnumEntryKey, // Handle into the enum branch of the registry for this device 02084 BOOLEAN InstallDriver // Should setup attempt to install a driver 02085 ); 02086 02087 NTSTATUS 02088 IopRequestHwProfileChangeNotification( 02089 IN LPGUID EventGuid, 02090 IN PROFILE_NOTIFICATION_TIME NotificationTime, 02091 OUT PPNP_VETO_TYPE VetoType OPTIONAL, 02092 OUT PUNICODE_STRING VetoName OPTIONAL 02093 ); 02094 02095 NTSTATUS 02096 IopNotifyTargetDeviceChange( 02097 LPCGUID EventGuid, 02098 PDEVICE_OBJECT DeviceObject, 02099 PVOID NotificationStructure, 02100 PDRIVER_OBJECT *VetoingDriver 02101 ); 02102 02103 NTSTATUS 02104 IopGetRelatedTargetDevice( 02105 IN PFILE_OBJECT FileObject, 02106 OUT PDEVICE_NODE *DeviceNode 02107 ); 02108 02109 NTSTATUS 02110 IopNotifyDeviceClassChange( 02111 LPGUID EventGuid, 02112 LPGUID ClassGuid, 02113 PUNICODE_STRING SymbolicLinkName 02114 ); 02115 02116 NTSTATUS 02117 IopRegisterDeviceInterface( 02118 IN PUNICODE_STRING DeviceInstanceName, 02119 IN CONST GUID *InterfaceClassGuid, 02120 IN PUNICODE_STRING ReferenceString OPTIONAL, 02121 IN BOOLEAN UserModeFormat, 02122 OUT PUNICODE_STRING SymbolicLinkName 02123 ); 02124 02125 NTSTATUS 02126 IopUnregisterDeviceInterface( 02127 IN PUNICODE_STRING SymbolicLinkName 02128 ); 02129 02130 NTSTATUS 02131 IopRemoveDeviceInterfaces( 02132 IN PUNICODE_STRING DeviceInstancePath 02133 ); 02134 02135 NTSTATUS 02136 IopGetDeviceInterfaces( 02137 IN CONST GUID *InterfaceClassGuid, 02138 IN PUNICODE_STRING DevicePath OPTIONAL, 02139 IN ULONG Flags, 02140 IN BOOLEAN UserModeFormat, 02141 OUT PWSTR *SymbolicLinkList, 02142 OUT PULONG SymbolicLinkListSize OPTIONAL 02143 ); 02144 02145 NTSTATUS 02146 IopDoDeferredSetInterfaceState( 02147 IN PDEVICE_NODE DeviceNode 02148 ); 02149 02150 NTSTATUS 02151 IopProcessSetInterfaceState( 02152 IN PUNICODE_STRING SymbolicLinkName, 02153 IN BOOLEAN Enable, 02154 IN BOOLEAN DeferNotStarted 02155 ); 02156 02157 NTSTATUS 02158 IopReplaceSeperatorWithPound( 02159 OUT PUNICODE_STRING OutString, 02160 IN PUNICODE_STRING InString 02161 ); 02162 02163 NTSTATUS 02164 IopNotifyHwProfileChange( 02165 IN LPGUID EventGuid, 02166 OUT PPNP_VETO_TYPE VetoType OPTIONAL, 02167 OUT PUNICODE_STRING VetoName OPTIONAL 02168 ); 02169 02170 VOID 02171 IopUncacheInterfaceInformation( 02172 IN PDEVICE_OBJECT DeviceObject 02173 ); 02174 02175 NTSTATUS 02176 IopProcessNewProfile( 02177 VOID 02178 ); 02179 02180 VOID 02181 IopProcessNewProfileWorker( 02182 IN PVOID Context 02183 ); 02184 02185 NTSTATUS 02186 IopProcessNewProfileStateCallback( 02187 IN PDEVICE_NODE DeviceNode, 02188 IN PVOID Context 02189 ); 02190 02191 // 02192 // Notify entry header - all notify entries have these 02193 // 02194 02195 typedef struct _NOTIFY_ENTRY_HEADER { 02196 02197 // 02198 // List Entry structure 02199 // 02200 02201 LIST_ENTRY ListEntry; 02202 02203 // 02204 // Notification event category for this notification entry. 02205 // 02206 02207 IO_NOTIFICATION_EVENT_CATEGORY EventCategory; 02208 02209 // 02210 // Callback routine passed in at registration 02211 // 02212 02213 PDRIVER_NOTIFICATION_CALLBACK_ROUTINE Callback; 02214 02215 // 02216 // Context passed in at registration 02217 // 02218 02219 PVOID Context; 02220 02221 // 02222 // Driver object of the driver that registered for notifications. Required 02223 // so we can dereference it when it unregisters 02224 // 02225 02226 PDRIVER_OBJECT DriverObject; 02227 02228 // 02229 // RefCount is the number of outstanding pointers to the node and avoids 02230 // deletion while another notification is taking place 02231 // 02232 02233 USHORT RefCount; 02234 02235 // 02236 // Unregistered is set if this notification has been unregistered but cannot 02237 // be removed from the list because other entities are using it 02238 // 02239 02240 BOOLEAN Unregistered; 02241 02242 // 02243 // Lock is a pointer to the fast mutex which is used to synchronise access 02244 // to the list this node is a member of and is required so that the correct 02245 // list can be locked during IoUnregisterPlugPlayNotification. If no locking 02246 // is required it is NULL 02247 // 02248 02249 PFAST_MUTEX Lock; 02250 02251 } NOTIFY_ENTRY_HEADER, *PNOTIFY_ENTRY_HEADER; 02252 02253 02254 // 02255 // Data to store for each target device registration 02256 // 02257 02258 typedef struct _TARGET_DEVICE_NOTIFY_ENTRY { 02259 02260 // 02261 // Header entries 02262 // 02263 02264 LIST_ENTRY ListEntry; 02265 IO_NOTIFICATION_EVENT_CATEGORY EventCategory; 02266 PDRIVER_NOTIFICATION_CALLBACK_ROUTINE Callback; 02267 PVOID Context; 02268 PDRIVER_OBJECT DriverObject; 02269 USHORT RefCount; 02270 BOOLEAN Unregistered; 02271 PFAST_MUTEX Lock; 02272 02273 // 02274 // FileObject - the file object of the target device we are interested in 02275 // 02276 02277 PFILE_OBJECT FileObject; 02278 02279 // 02280 // PhysicalDeviceObject -- the PDO upon which this notification is hooked. 02281 // We need to keep this here, so we can dereference it when the refcount 02282 // on this notification entry drops to zero. 02283 // 02284 02285 PDEVICE_OBJECT PhysicalDeviceObject; 02286 02287 } TARGET_DEVICE_NOTIFY_ENTRY, *PTARGET_DEVICE_NOTIFY_ENTRY; 02288 02289 // 02290 // Data to store for each device class registration 02291 // 02292 02293 typedef struct _DEVICE_CLASS_NOTIFY_ENTRY { 02294 02295 // 02296 // Header entries 02297 // 02298 02299 LIST_ENTRY ListEntry; 02300 IO_NOTIFICATION_EVENT_CATEGORY EventCategory; 02301 PDRIVER_NOTIFICATION_CALLBACK_ROUTINE Callback; 02302 PVOID Context; 02303 PDRIVER_OBJECT DriverObject; 02304 USHORT RefCount; 02305 BOOLEAN Unregistered; 02306 PFAST_MUTEX Lock; 02307 02308 // 02309 // ClassGuid - the guid of the device class we are interested in 02310 // 02311 02312 GUID ClassGuid; 02313 02314 } DEVICE_CLASS_NOTIFY_ENTRY, *PDEVICE_CLASS_NOTIFY_ENTRY; 02315 02316 // 02317 // Data to store for registration of the Reserved (ie setupdd.sys) variety 02318 // 02319 02320 typedef struct _SETUP_NOTIFY_DATA { 02321 02322 // 02323 // Header entries 02324 // 02325 02326 LIST_ENTRY ListEntry; 02327 IO_NOTIFICATION_EVENT_CATEGORY EventCategory; 02328 PDRIVER_NOTIFICATION_CALLBACK_ROUTINE Callback; 02329 PVOID Context; 02330 PDRIVER_OBJECT DriverObject; 02331 USHORT RefCount; 02332 BOOLEAN Unregistered; 02333 PFAST_MUTEX Lock; 02334 02335 } SETUP_NOTIFY_DATA, *PSETUP_NOTIFY_DATA; 02336 02337 02338 // 02339 // Data to store for registration for HardwareProfileChange Events 02340 // 02341 02342 typedef struct _HWPROFILE_NOTIFY_ENTRY { 02343 02344 // 02345 // Header entries 02346 // 02347 02348 LIST_ENTRY ListEntry; 02349 IO_NOTIFICATION_EVENT_CATEGORY EventCategory; 02350 PDRIVER_NOTIFICATION_CALLBACK_ROUTINE Callback; 02351 PVOID Context; 02352 PDRIVER_OBJECT DriverObject; 02353 USHORT RefCount; 02354 BOOLEAN Unregistered; 02355 PFAST_MUTEX Lock; 02356 02357 } HWPROFILE_NOTIFY_ENTRY, *PHWPROFILE_NOTIFY_ENTRY; 02358 02359 #define PNP_NOTIFICATION_VERSION 1 02360 #define NOTIFY_DEVICE_CLASS_HASH_BUCKETS 13 02361 02362 // 02363 // IopMaxDeviceNodeLevel - Level number of the DeviceNode deepest in the tree 02364 // 02365 extern ULONG IopMaxDeviceNodeLevel; 02366 extern ULONG IoDeviceNodeTreeSequence; 02367 02368 // 02369 // Global notification data 02370 // 02371 02372 extern FAST_MUTEX IopDeviceClassNotifyLock; 02373 extern LIST_ENTRY IopDeviceClassNotifyList[]; 02374 extern PSETUP_NOTIFY_DATA IopSetupNotifyData; 02375 extern FAST_MUTEX IopTargetDeviceNotifyLock; 02376 extern LIST_ENTRY IopProfileNotifyList; 02377 extern FAST_MUTEX IopHwProfileNotifyLock; 02378 02379 VOID 02380 IopProcessDeferredRegistrations( 02381 VOID 02382 ); 02383 02384 // 02385 // Generic buffer management 02386 // 02387 02388 typedef struct _BUFFER_INFO { 02389 02390 // 02391 // Buffer - pointer to the start of the buffer 02392 // 02393 02394 PCHAR Buffer; 02395 02396 // 02397 // Current - Pointer to the current position in the buffer 02398 // 02399 02400 PCHAR Current; 02401 02402 // 02403 // MaxSize - Maximum size of the buffer in bytes 02404 // 02405 02406 ULONG MaxSize; 02407 02408 } BUFFER_INFO, *PBUFFER_INFO; 02409 02410 typedef struct _BUS_TYPE_GUID_LIST { 02411 02412 // 02413 // Number of allocated guid slots in the table. 02414 // 02415 ULONG Count; 02416 02417 // 02418 // Number of entries used so far. 02419 // 02420 FAST_MUTEX Lock; 02421 02422 // 02423 // Array of bus type guids 02424 // 02425 GUID Guid[1]; 02426 02427 } BUS_TYPE_GUID_LIST, *PBUS_TYPE_GUID_LIST; 02428 02429 // 02430 // List of queried bus type guids 02431 // 02432 extern PBUS_TYPE_GUID_LIST IopBusTypeGuidList; 02433 02434 // 02435 // Arbiter entry points 02436 // 02437 02438 NTSTATUS 02439 IopPortInitialize( 02440 VOID 02441 ); 02442 02443 NTSTATUS 02444 IopMemInitialize( 02445 VOID 02446 ); 02447 02448 NTSTATUS 02449 IopIrqInitialize( 02450 VOID 02451 ); 02452 02453 NTSTATUS 02454 IopDmaInitialize( 02455 VOID 02456 ); 02457 02458 NTSTATUS 02459 IopBusNumberInitialize( 02460 VOID 02461 ); 02462 02463 // 02464 // Arbiter state 02465 // 02466 02467 extern ARBITER_INSTANCE IopRootPortArbiter; 02468 extern ARBITER_INSTANCE IopRootMemArbiter; 02469 extern ARBITER_INSTANCE IopRootIrqArbiter; 02470 extern ARBITER_INSTANCE IopRootDmaArbiter; 02471 extern ARBITER_INSTANCE IopRootBusNumberArbiter; 02472 02473 // 02474 // Buffer management routines. 02475 // 02476 02477 NTSTATUS 02478 IopAllocateBuffer( 02479 IN PBUFFER_INFO Info, 02480 IN ULONG Size 02481 ); 02482 02483 NTSTATUS 02484 IopResizeBuffer( 02485 IN PBUFFER_INFO Info, 02486 IN ULONG NewSize, 02487 IN BOOLEAN CopyContents 02488 ); 02489 02490 VOID 02491 IopFreeBuffer( 02492 IN PBUFFER_INFO Info 02493 ); 02494 02495 02496 // 02497 // UnicodeString management routines. 02498 // 02499 02500 NTSTATUS 02501 IopAllocateUnicodeString( 02502 IN OUT PUNICODE_STRING String, 02503 IN USHORT Length 02504 ); 02505 02506 VOID 02507 IopFreeAllocatedUnicodeString( 02508 PUNICODE_STRING String 02509 ); 02510 02511 // 02512 // Misc. 02513 // 02514 02515 NTSTATUS 02516 PnPBiosGetBiosInfo( 02517 OUT PVOID *BiosInfo, 02518 OUT ULONG *BiosInfoLength 02519 ); 02520 02521 BOOLEAN 02522 IopFixupDeviceId( 02523 PWCHAR DeviceId 02524 ); 02525 02526 // 02527 // Hot Docking Profile Support 02528 // 02529 02530 typedef enum _HARDWARE_PROFILE_BUS_TYPE { 02531 HardwareProfileBusTypeACPI 02532 } HARDWARE_PROFILE_BUS_TYPE, * PHARDWARE_PROFILE_BUS_TYPE; 02533 02534 extern LIST_ENTRY IopDockDeviceListHead; 02535 extern FAST_MUTEX IopDockDeviceListLock; 02536 extern ULONG IopDockDeviceCount; 02537 extern KSEMAPHORE IopProfileChangeSemaphore; 02538 extern LONG IopDocksInTransition; 02539 02540 // 02541 // These six functions are exported by Dockhwp to control hardware profile 02542 // changes 02543 // 02544 VOID 02545 IopHardwareProfileBeginTransition( 02546 IN BOOLEAN SubsumeExistingDeparture 02547 ); 02548 02549 VOID 02550 IopHardwareProfileMarkDock( 02551 PDEVICE_NODE DeviceNode, 02552 PROFILE_STATUS ChangeInPresence 02553 ); 02554 02555 NTSTATUS 02556 IopHardwareProfileQueryChange( 02557 IN BOOLEAN SubsumeExistingDeparture, 02558 IN PROFILE_NOTIFICATION_TIME NotificationTime, 02559 OUT PPNP_VETO_TYPE VetoType, 02560 OUT PUNICODE_STRING VetoName OPTIONAL 02561 ); 02562 02563 VOID 02564 IopHardwareProfileCommitStartedDock( 02565 IN PDEVICE_NODE DeviceNode 02566 ); 02567 02568 VOID 02569 IopHardwareProfileCommitRemovedDock( 02570 IN PDEVICE_NODE DeviceNode 02571 ); 02572 02573 VOID 02574 IopHardwareProfileCancelRemovedDock( 02575 IN PDEVICE_NODE DeviceNode 02576 ); 02577 02578 VOID 02579 IopHardwareProfileCancelTransition( 02580 VOID 02581 ); 02582 02583 VOID 02584 IopHardwareProfileSetMarkedDocksEjected( 02585 VOID 02586 ); 02587 02588 VOID 02589 IopOrphanNotification ( 02590 PDEVICE_NODE DeviceNode 02591 ); 02592 02593 02594 // 02595 // Warm eject externs and function prototypes 02596 // 02597 extern KEVENT IopWarmEjectLock; 02598 extern PDEVICE_OBJECT IopWarmEjectPdo; 02599 02600 NTSTATUS 02601 IopWarmEjectDevice( 02602 IN PDEVICE_OBJECT DeviceToEject, 02603 IN SYSTEM_POWER_STATE LightestSleepState 02604 ); 02605 02606

Generated on Sat May 15 19:41:17 2004 for test by doxygen 1.3.7