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

pnpdd.c File Reference

#include "iop.h"

Go to the source code of this file.

Classes

struct  _DEVICE_LIST_CONTEXT

Typedefs

typedef _DEVICE_LIST_CONTEXT DEVICE_LIST_CONTEXT
typedef _DEVICE_LIST_CONTEXTPDEVICE_LIST_CONTEXT

Functions

BOOLEAN IopAddDevicesToBootDriverWorker (IN HANDLE DeviceInstanceHandle, IN PUNICODE_STRING DeviceInstancePath, IN OUT PVOID Context)
NTSTATUS IopProcessAddDevicesWorker (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
NTSTATUS IopProcessAssignResourcesWorker (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
VOID IopPnPCompleteRequest (IN OUT PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
NTSTATUS IopGetDriverDeviceList (IN PDRIVER_OBJECT DriverObject, OUT PDEVICE_LIST_CONTEXT *DeviceList)
BOOLEAN IopGetDriverDeviceListWorker (IN HANDLE DeviceInstanceHandle, IN PUNICODE_STRING DeviceInstancePath, IN OUT PVOID Context)
NTSTATUS IopAssignResourcesToDevices (IN ULONG DeviceCount, IN PIOP_RESOURCE_REQUEST RequestTable, IN BOOLEAN BootConfigsOK)
BOOLEAN IopIsFirmwareDisabled (IN PDEVICE_NODE DeviceNode)
NTSTATUS IopAddDevicesToBootDriver (IN PDRIVER_OBJECT DriverObject)
NTSTATUS IopReleaseDeviceResources (IN PDEVICE_NODE DeviceNode, IN BOOLEAN ReserveResources)
NTSTATUS IopPnPAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject)
NTSTATUS IopArbiterHandlerxx (IN PVOID Context, IN ARBITER_ACTION Action, IN OUT PARBITER_PARAMETERS Parameters)
NTSTATUS IopTranslatorHandlerCm (IN PVOID Context, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount, OPTIONAL IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL IN PDEVICE_OBJECT DeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
NTSTATUS IopTranslatorHandlerIo (IN PVOID Context, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT DeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
NTSTATUS IopPowerDispatch (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
NTSTATUS IopPnPDispatch (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
USHORT IopProcessAddDevices (IN PDEVICE_NODE DeviceNode, IN USHORT StartOrder, IN ULONG DriverStartType)
BOOLEAN IopProcessAssignResources (IN PDEVICE_NODE DeviceNode, IN BOOLEAN Reallocation, IN BOOLEAN BootConfigsOK)
VOID IopNewDevice (IN PDEVICE_OBJECT DeviceObject)
NTSTATUS IopStartDriverDevices (IN PDRIVER_OBJECT DriverObject)
NTSTATUS IopAssignResourcesToDevices (IN ULONG DeviceCount, IN OUT PIOP_RESOURCE_REQUEST RequestTable, IN BOOLEAN BootConfigsOK)
NTSTATUS IopWriteAllocatedResourcesToRegistry (PDEVICE_NODE DeviceNode, PCM_RESOURCE_LIST CmResourceList, ULONG Length)


Typedef Documentation

typedef struct _DEVICE_LIST_CONTEXT DEVICE_LIST_CONTEXT
 

typedef struct _DEVICE_LIST_CONTEXT * PDEVICE_LIST_CONTEXT
 

Referenced by IopGetDriverDeviceList(), IopGetDriverDeviceListWorker(), IopProcessAssignResources(), IopProcessAssignResourcesWorker(), and IopStartDriverDevices().


Function Documentation

NTSTATUS IopAddDevicesToBootDriver IN PDRIVER_OBJECT  DriverObject  ) 
 

Definition at line 117 of file pnpdd.c.

References IopAddDevicesToBootDriverWorker(), IopApplyFunctionToServiceInstances(), NTSTATUS(), NULL, and TRUE.

Referenced by IopInitializeBootDrivers().

00123 : 00124 00125 This functions is used by Pnp manager to inform a boot device driver of 00126 all the devices it can possibly control. This routine is for boot 00127 drivers only. 00128 00129 Parameters: 00130 00131 DriverObject - Supplies a driver object to receive its boot devices. 00132 00133 Return Value: 00134 00135 NTSTATUS code. 00136 00137 --*/ 00138 { 00139 NTSTATUS status; 00140 00141 00142 // 00143 // For each device instance in the driver's service/enum key, we will 00144 // invoke the driver's AddDevice routine and perform enumeration on 00145 // the device. 00146 // Note, we don't acquire registry lock before calling IopApplyFunction 00147 // routine. We know this code is for boot driver initialization. No 00148 // one else would access the registry Enum key at this time and most 00149 // important we need the registry lock in other down level routines. 00150 // 00151 00152 status = IopApplyFunctionToServiceInstances( 00153 NULL, 00154 &DriverObject->DriverExtension->ServiceKeyName, 00155 KEY_ALL_ACCESS, 00156 TRUE, 00157 IopAddDevicesToBootDriverWorker, 00158 DriverObject, 00159 NULL 00160 ); 00161 00162 return status; 00163 }

BOOLEAN IopAddDevicesToBootDriverWorker IN HANDLE  DeviceInstanceHandle,
IN PUNICODE_STRING  DeviceInstancePath,
IN OUT PVOID  Context
 

Definition at line 166 of file pnpdd.c.

References ASSERT, _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, DNF_DUPLICATE, _ADD_CONTEXT::DriverStartType, _DEVICE_NODE::DuplicatePDO, exit, FALSE, _DEVICE_NODE::Flags, _ADD_CONTEXT::GroupsToStart, _ADD_CONTEXT::GroupToStartNext, IopCallDriverAddDevice(), IopDeviceObjectFromDeviceInstance(), NTSTATUS(), ObDereferenceObject, OK_TO_ADD_DEVICE, _DEVICE_NODE::PhysicalDeviceObject, and TRUE.

Referenced by IopAddDevicesToBootDriver().

00174 : 00175 00176 This routine is a callback function for IopApplyFunctionToServiceInstances. 00177 It is called for each device instance key referenced by a service instance 00178 value under the specified service's volatile Enum subkey. The purpose of this 00179 routine is to invoke the AddDevice() entry of a boot driver with the device 00180 object. 00181 00182 Note this routine is also used for the devices controlled by a legacy driver. 00183 If the specified device instance is controlled by a legacy driver this routine 00184 sets the device node flags. 00185 00186 Arguments: 00187 00188 DeviceInstanceHandle - Supplies a handle to the registry path (relative to 00189 HKLM\CCS\System\Enum) to this device instance. 00190 00191 DeviceInstancePath - Supplies the registry path (relative to HKLM\CCS\System\Enum) 00192 to this device instance. 00193 00194 Context - Supplies a pointer to a DRIVER_OBJECT structure. 00195 00196 Return Value: 00197 00198 TRUE to continue the enumeration. 00199 FALSE to abort it. 00200 00201 --*/ 00202 00203 { 00204 NTSTATUS status; 00205 // PDRIVER_OBJECT driverObject = (PDRIVER_OBJECT)Context; 00206 PDEVICE_OBJECT physicalDevice; 00207 PDEVICE_NODE deviceNode; 00208 ULONG length; 00209 BOOLEAN conflict; 00210 PCM_RESOURCE_LIST cmResource; 00211 00212 ADD_CONTEXT addContext; 00213 00214 00215 // 00216 // Reference the physical device object associated with the device instance. 00217 // 00218 00219 physicalDevice = IopDeviceObjectFromDeviceInstance(DeviceInstanceHandle, 00220 DeviceInstancePath); 00221 if (!physicalDevice) { 00222 return TRUE; 00223 } 00224 00225 deviceNode = (PDEVICE_NODE)physicalDevice->DeviceObjectExtension->DeviceNode; 00226 ASSERT(deviceNode && (deviceNode->PhysicalDeviceObject == physicalDevice)); 00227 00228 // 00229 // If the device has been added (or failed) skip it. 00230 // 00231 00232 if (!OK_TO_ADD_DEVICE(deviceNode)) { 00233 goto exit; 00234 } 00235 00236 // 00237 // If we know the device is a duplicate of another device which 00238 // has been enumerated at this point. we will skip this device. 00239 // 00240 00241 if ((deviceNode->Flags & DNF_DUPLICATE) && (deviceNode->DuplicatePDO)) { 00242 goto exit; 00243 } 00244 00245 // 00246 // Invoke driver's AddDevice Entry for the device. 00247 // Since the driver has already been loaded, we generate a fake 00248 // context to make sure that group order won't get in the way of 00249 // adding the drivers. 00250 00251 addContext.GroupsToStart = 0xffff; 00252 addContext.GroupToStartNext = 0; 00253 addContext.DriverStartType = SERVICE_BOOT_START; 00254 00255 IopCallDriverAddDevice(deviceNode, FALSE, &addContext); 00256 00257 exit: 00258 ObDereferenceObject(physicalDevice); 00259 return TRUE; 00260 }

NTSTATUS IopArbiterHandlerxx IN PVOID  Context,
IN ARBITER_ACTION  Action,
IN OUT PARBITER_PARAMETERS  Parameters
 

Definition at line 459 of file pnpdd.c.

References Action, _ARBITER_LIST_ENTRY::Alternatives, ArbiterActionQueryArbitrate, _ARBITER_LIST_ENTRY::Assignment, and NULL.

00464 { 00465 PLIST_ENTRY listHead, listEntry; 00466 PIO_RESOURCE_DESCRIPTOR ioDesc; 00467 PCM_PARTIAL_RESOURCE_DESCRIPTOR cmDesc; 00468 PARBITER_LIST_ENTRY arbiterListEntry; 00469 00470 if (Action == ArbiterActionQueryArbitrate) { 00471 return STATUS_SUCCESS; 00472 } 00473 if (Parameters == NULL) { 00474 return STATUS_SUCCESS; 00475 } 00476 listHead = Parameters->Parameters.TestAllocation.ArbitrationList; 00477 if (IsListEmpty(listHead)) { 00478 return STATUS_SUCCESS; 00479 } 00480 listEntry = listHead->Flink; 00481 while (listEntry != listHead) { 00482 arbiterListEntry = (PARBITER_LIST_ENTRY)listEntry; 00483 cmDesc = arbiterListEntry->Assignment; 00484 ioDesc = arbiterListEntry->Alternatives; 00485 if (cmDesc == NULL || ioDesc == NULL) { 00486 return STATUS_SUCCESS; 00487 } 00488 cmDesc->Type = ioDesc->Type; 00489 cmDesc->ShareDisposition = ioDesc->ShareDisposition; 00490 cmDesc->Flags = ioDesc->Flags; 00491 if (ioDesc->Type == CmResourceTypePort) { 00492 cmDesc->u.Port.Start = ioDesc->u.Port.MinimumAddress; 00493 cmDesc->u.Port.Length = ioDesc->u.Port.Length; 00494 } else if (ioDesc->Type == CmResourceTypeInterrupt) { 00495 cmDesc->u.Interrupt.Level = ioDesc->u.Interrupt.MinimumVector; 00496 cmDesc->u.Interrupt.Vector = ioDesc->u.Interrupt.MinimumVector; 00497 cmDesc->u.Interrupt.Affinity = (ULONG) -1; 00498 } else if (ioDesc->Type == CmResourceTypeMemory) { 00499 cmDesc->u.Memory.Start = ioDesc->u.Memory.MinimumAddress; 00500 cmDesc->u.Memory.Length = ioDesc->u.Memory.Length; 00501 } else if (ioDesc->Type == CmResourceTypeDma) { 00502 cmDesc->u.Dma.Channel = ioDesc->u.Dma.MinimumChannel; 00503 cmDesc->u.Dma.Port = 0; 00504 cmDesc->u.Dma.Reserved1 = 0; 00505 } 00506 listEntry = listEntry->Flink; 00507 } 00508 return STATUS_SUCCESS; 00509 }

NTSTATUS IopAssignResourcesToDevices IN ULONG  DeviceCount,
IN OUT PIOP_RESOURCE_REQUEST  RequestTable,
IN BOOLEAN  BootConfigsOK
 

Definition at line 1824 of file pnpdd.c.

References ArbiterRequestLegacyReported, ArbiterRequestPnpEnumerated, ASSERT, DNF_MADEUP, FALSE, IopAllocateResources(), IopDeviceObjectToDeviceInstance(), NT_SUCCESS, NTSTATUS(), NULL, and PAGED_CODE.

Referenced by IopNewDevice(), and IopProcessAssignResources().

01831 : 01832 01833 This routine takes an input array of IOP_RESOURCE_REQUEST structures, and 01834 allocates resource for the physical device object specified in 01835 the structure. The allocated resources are automatically recorded 01836 in the registry. 01837 01838 Arguments: 01839 01840 DeviceCount - Supplies the number of device objects whom we need to 01841 allocate resource to. That is the number of entries 01842 in the RequestTable. 01843 01844 RequestTable - Supplies an array of IOP_RESOURCE_REQUEST structures which 01845 contains the Physical device object to allocate resource to. 01846 Upon entry, the ResourceAssignment pointer is NULL and on 01847 return the allocated resource is returned via the this pointer. 01848 01849 BootConfigsOK - Allow assignment of BOOT configs. 01850 01851 Return Value: 01852 01853 The status returned is the final completion status of the operation. 01854 01855 NOTE: 01856 If NTSTATUS_SUCCESS is returned, the resource allocation for *all* the devices 01857 specified is succeeded. Otherwise, one or more are failed and caller must 01858 examine the ResourceAssignment pointer in each IOP_RESOURCE_REQUEST structure to 01859 determine which devices failed and which succeeded. 01860 01861 --*/ 01862 { 01863 NTSTATUS status; 01864 ULONG i; 01865 01866 PAGED_CODE(); 01867 01868 ASSERT(DeviceCount != 0); 01869 01870 for (i = 0; i < DeviceCount; i++) { 01871 01872 // 01873 // Initialize table entry. 01874 // 01875 01876 RequestTable[i].ResourceAssignment = NULL; 01877 RequestTable[i].Status = 0; 01878 RequestTable[i].Flags = 0; 01879 RequestTable[i].AllocationType = ArbiterRequestPnpEnumerated; 01880 if (((PDEVICE_NODE)(RequestTable[i].PhysicalDevice->DeviceObjectExtension->DeviceNode))->Flags & DNF_MADEUP) { 01881 01882 ULONG reportedDevice = 0; 01883 HANDLE hInstance; 01884 01885 status = IopDeviceObjectToDeviceInstance(RequestTable[i].PhysicalDevice, &hInstance, KEY_READ); 01886 if (NT_SUCCESS(status)) { 01887 01888 ULONG resultSize = 0; 01889 UCHAR buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)]; 01890 UNICODE_STRING unicodeString; 01891 01892 PiWstrToUnicodeString(&unicodeString, REGSTR_VALUE_DEVICE_REPORTED); 01893 status = ZwQueryValueKey( hInstance, 01894 &unicodeString, 01895 KeyValuePartialInformation, 01896 (PVOID)buffer, 01897 sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG), 01898 &resultSize); 01899 if (NT_SUCCESS(status)) { 01900 01901 reportedDevice = *(PULONG)(((PKEY_VALUE_PARTIAL_INFORMATION)buffer)->Data); 01902 01903 } 01904 01905 ZwClose(hInstance); 01906 } 01907 01908 // 01909 // Change the AllocationType for reported devices. 01910 // 01911 01912 if (reportedDevice) { 01913 01914 RequestTable[i].AllocationType = ArbiterRequestLegacyReported; 01915 01916 } 01917 01918 } 01919 RequestTable[i].ResourceRequirements = NULL; 01920 } 01921 01922 // 01923 // Allocate memory to build a IOP_ASSIGN table to call IopAllocateResources() 01924 // 01925 01926 status = IopAllocateResources(&DeviceCount, &RequestTable, FALSE, BootConfigsOK); 01927 return status; 01928 }

NTSTATUS IopAssignResourcesToDevices IN ULONG  DeviceCount,
IN PIOP_RESOURCE_REQUEST  RequestTable,
IN BOOLEAN  BootConfigsOK
 

NTSTATUS IopGetDriverDeviceList IN PDRIVER_OBJECT  DriverObject,
OUT PDEVICE_LIST_CONTEXT DeviceList
 

Definition at line 1411 of file pnpdd.c.

References _DEVICE_LIST_CONTEXT::DeviceCount, ExAcquireResourceShared, ExAllocatePool, ExFreePool(), exit, ExReleaseResource, FALSE, IopApplyFunctionToServiceInstances(), IopGetDriverDeviceListWorker(), IopGetRegistryValue(), IopOpenServiceEnumKeys(), KeEnterCriticalRegion, KeLeaveCriticalRegion, KEY_VALUE_DATA, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, PDEVICE_LIST_CONTEXT, PpRegistryDeviceResource, and TRUE.

Referenced by IopStartDriverDevices().

01418 : 01419 01420 This functions is used by Pnp manager to inform a device driver of 01421 all the devices it can possibly control. See IopStartDriverDevices(). 01422 01423 Parameters: 01424 01425 DriverObject - Supplies a driver object to receive its boot devices. 01426 01427 DeviceList - Specifies a pointer to a variable to receive the list of device 01428 objects controlled by the driver. 01429 01430 Return Value: 01431 01432 NTSTATUS code. 01433 01434 --*/ 01435 { 01436 NTSTATUS status; 01437 HANDLE enumHandle; 01438 ULONG count = 0; 01439 PKEY_VALUE_FULL_INFORMATION keyValueInformation; 01440 PDEVICE_LIST_CONTEXT deviceList; 01441 01442 PAGED_CODE(); 01443 01444 *DeviceList = NULL; 01445 KeEnterCriticalRegion(); 01446 ExAcquireResourceShared(&PpRegistryDeviceResource, TRUE); 01447 01448 // 01449 // Open System\CurrentControlSet\Services 01450 // 01451 01452 status = IopOpenServiceEnumKeys ( 01453 &DriverObject->DriverExtension->ServiceKeyName, 01454 KEY_READ, 01455 NULL, 01456 &enumHandle, 01457 FALSE 01458 ); 01459 if (!NT_SUCCESS(status)) { 01460 goto exit; 01461 } 01462 01463 // 01464 // Read value of Count if present. If it is not present, a value of 01465 // zero will be returned. 01466 // 01467 01468 status = IopGetRegistryValue(enumHandle, REGSTR_VALUE_COUNT, &keyValueInformation); 01469 ZwClose(enumHandle); 01470 if (NT_SUCCESS(status)) { 01471 if (keyValueInformation->DataLength != 0) { 01472 count = *(PULONG)KEY_VALUE_DATA(keyValueInformation); 01473 } 01474 ExFreePool(keyValueInformation); 01475 } 01476 01477 if (count == 0) { 01478 goto exit; 01479 } 01480 01481 deviceList = (PDEVICE_LIST_CONTEXT) ExAllocatePool( 01482 PagedPool, 01483 sizeof(DEVICE_LIST_CONTEXT) + 01484 sizeof(PDEVICE_OBJECT) * count * 2 01485 ); 01486 01487 if (!deviceList) { 01488 status = STATUS_INSUFFICIENT_RESOURCES; 01489 goto exit; 01490 } 01491 01492 deviceList->DeviceCount = 0; 01493 01494 // 01495 // For each device instance in the driver's service/enum key, we will 01496 // invoke the our worker routine to collect its corresponding device object. 01497 // 01498 01499 status = IopApplyFunctionToServiceInstances( 01500 NULL, 01501 &DriverObject->DriverExtension->ServiceKeyName, 01502 KEY_ALL_ACCESS, 01503 TRUE, 01504 IopGetDriverDeviceListWorker, 01505 deviceList, 01506 NULL 01507 ); 01508 *DeviceList = deviceList; 01509 exit: 01510 ExReleaseResource(&PpRegistryDeviceResource); 01511 KeLeaveCriticalRegion(); 01512 return status; 01513 }

BOOLEAN IopGetDriverDeviceListWorker IN HANDLE  DeviceInstanceHandle,
IN PUNICODE_STRING  DeviceInstancePath,
IN OUT PVOID  Context
 

Definition at line 1516 of file pnpdd.c.

References _DEVICE_LIST_CONTEXT::DeviceCount, _DEVICE_LIST_CONTEXT::DeviceList, _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, DNF_DUPLICATE, _DEVICE_NODE::DuplicatePDO, exit, _DEVICE_NODE::Flags, IopDeviceObjectFromDeviceInstance(), IopDoesDevNodeHaveProblem, IopIsDeviceInstanceEnabled(), ObDereferenceObject, PAGED_CODE, PDEVICE_LIST_CONTEXT, and TRUE.

Referenced by IopGetDriverDeviceList().

01524 : 01525 01526 This routine is a callback function for IopApplyFunctionToServiceInstances. 01527 It is called for each device instance key referenced by a service instance 01528 value under the specified service's volatile Enum subkey. The purpose of this 01529 routine is to generate a device list controlled by the same driver. 01530 01531 Arguments: 01532 01533 DeviceInstanceHandle - Supplies a handle to the registry path (relative to 01534 HKLM\CCS\System\Enum) to this device instance. 01535 01536 DeviceInstancePath - Supplies the registry path (relative to HKLM\CCS\System\Enum) 01537 to this device instance. 01538 01539 Context - Supplies a pointer to a PDEVICE_LIST_CONTEXT structure. 01540 01541 Return Value: 01542 01543 TRUE to continue the enumeration. 01544 FALSE to abort it. 01545 01546 --*/ 01547 01548 { 01549 PDEVICE_LIST_CONTEXT deviceList = (PDEVICE_LIST_CONTEXT)Context; 01550 PDEVICE_OBJECT physicalDevice; 01551 PDEVICE_NODE deviceNode; 01552 01553 PAGED_CODE(); 01554 01555 // 01556 // Reference the physical device object associated with the device instance. 01557 // 01558 01559 physicalDevice = IopDeviceObjectFromDeviceInstance(DeviceInstanceHandle, 01560 DeviceInstancePath); 01561 if (!physicalDevice) { 01562 return TRUE; 01563 } 01564 01565 deviceNode = (PDEVICE_NODE)physicalDevice->DeviceObjectExtension->DeviceNode; 01566 01567 // 01568 // Make sure the device instance is not disabled. 01569 // 01570 01571 if (IopDoesDevNodeHaveProblem(deviceNode)) { 01572 goto exit; 01573 } else if (!IopIsDeviceInstanceEnabled(DeviceInstanceHandle, DeviceInstancePath, TRUE)) { 01574 goto exit; 01575 } 01576 01577 // 01578 // If we know the device is a duplicate of another enumerated device and it 01579 // has been enumerated at this point. we will skip this device. 01580 // 01581 01582 if ((deviceNode->Flags & DNF_DUPLICATE) && (deviceNode->DuplicatePDO)) { 01583 01584 goto exit; 01585 } 01586 01587 deviceList->DeviceList[deviceList->DeviceCount] = physicalDevice; 01588 deviceList->DeviceCount++; 01589 return TRUE; 01590 exit: 01591 ObDereferenceObject(physicalDevice); 01592 return TRUE; 01593 }

BOOLEAN IopIsFirmwareDisabled IN PDEVICE_NODE  DeviceNode  ) 
 

Definition at line 2009 of file pnpdd.c.

References ExAcquireResourceShared, ExReleaseResource, FALSE, IopCreateRegistryKeyEx(), IopDeviceObjectToDeviceInstance(), KeEnterCriticalRegion, KeLeaveCriticalRegion, NT_SUCCESS, NTSTATUS(), NULL, PpRegistryDeviceResource, RtlInitUnicodeString(), and TRUE.

Referenced by IopPnPDispatch().

02015 : 02016 02017 This routine determines if the devicenode has been disabled by firmware. 02018 02019 Arguments: 02020 02021 DeviceNode - Supplies a pointer to the device node structure of the device. 02022 02023 Return Value: 02024 02025 TRUE if disabled, otherwise FALSE 02026 02027 --*/ 02028 { 02029 NTSTATUS status; 02030 PDEVICE_OBJECT deviceObject = DeviceNode->PhysicalDeviceObject; 02031 HANDLE handle, handlex; 02032 UNICODE_STRING unicodeName; 02033 UCHAR buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION)+sizeof(ULONG)]; 02034 PKEY_VALUE_PARTIAL_INFORMATION value = (PKEY_VALUE_PARTIAL_INFORMATION)buffer; 02035 ULONG buflen; 02036 BOOLEAN FirmwareDisabled = FALSE; 02037 02038 KeEnterCriticalRegion(); 02039 ExAcquireResourceShared(&PpRegistryDeviceResource, TRUE); 02040 02041 status = IopDeviceObjectToDeviceInstance( 02042 deviceObject, 02043 &handlex, 02044 KEY_ALL_ACCESS); 02045 if (NT_SUCCESS(status)) { 02046 02047 // 02048 // Open the LogConfig key of the device instance. 02049 // 02050 02051 PiWstrToUnicodeString(&unicodeName, REGSTR_KEY_CONTROL); 02052 status = IopCreateRegistryKeyEx( &handle, 02053 handlex, 02054 &unicodeName, 02055 KEY_ALL_ACCESS, 02056 REG_OPTION_VOLATILE, 02057 NULL 02058 ); 02059 ZwClose(handlex); 02060 if (NT_SUCCESS(status)) { 02061 02062 RtlInitUnicodeString(&unicodeName, REGSTR_VAL_FIRMWAREDISABLED); 02063 value = (PKEY_VALUE_PARTIAL_INFORMATION)buffer; 02064 buflen = sizeof(buffer); 02065 status = ZwQueryValueKey(handle, 02066 &unicodeName, 02067 KeyValuePartialInformation, 02068 value, 02069 sizeof(buffer), 02070 &buflen 02071 ); 02072 02073 ZwClose(handle); 02074 02075 // 02076 // We don't need to check the buffer was big enough because it starts 02077 // off that way and doesn't get any smaller! 02078 // 02079 02080 if (NT_SUCCESS(status) 02081 && value->Type == REG_DWORD 02082 && value->DataLength == sizeof(ULONG) 02083 && (*(PULONG)(value->Data))!=0) { 02084 02085 // 02086 // firmware disabled 02087 // 02088 FirmwareDisabled = TRUE; 02089 } 02090 } 02091 } 02092 ExReleaseResource(&PpRegistryDeviceResource); 02093 KeLeaveCriticalRegion(); 02094 return FirmwareDisabled; 02095 }

VOID IopNewDevice IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 1596 of file pnpdd.c.

References _START_CONTEXT::AddContext, DNF_ADDED, DNF_LEGACY_DRIVER, DNF_NEED_QUERY_IDS, DNF_NO_RESOURCE_REQUIRED, DNF_RESOURCE_ASSIGNED, DNF_RESOURCE_REPORTED, _ADD_CONTEXT::DriverStartType, exit, FALSE, _DEVICE_NODE::Flags, _ADD_CONTEXT::GroupsToStart, _ADD_CONTEXT::GroupToStartNext, IopAssignResourcesToDevices(), IopCallDriverAddDevice(), IopProcessAssignResources(), IopProcessStartDevices(), IopSetDevNodeProblem, IopStartAndEnumerateDevice(), _START_CONTEXT::LoadDriver, _START_CONTEXT::NewDevice, NO_MORE_GROUP, NT_SUCCESS, NTSTATUS(), PAGED_CODE, _IOP_RESOURCE_REQUEST::PhysicalDevice, _IOP_RESOURCE_REQUEST::Priority, _IOP_RESOURCE_REQUEST::ResourceAssignment, _DEVICE_NODE::ResourceList, _DEVICE_NODE::ResourceListTranslated, _IOP_RESOURCE_REQUEST::Status, _IOP_RESOURCE_REQUEST::TranslatedResourceAssignment, and TRUE.

Referenced by IopDeviceActionWorker().

01602 : 01603 01604 This routine handles user-mode initiated starts of devices. 01605 01606 Parameters: 01607 01608 DeviceObject - PDO. 01609 01610 ReturnValue: 01611 01612 None. 01613 01614 --*/ 01615 01616 { 01617 PDEVICE_NODE deviceNode, parent; 01618 IOP_RESOURCE_REQUEST requestTable; 01619 NTSTATUS status; 01620 BOOLEAN newDevice; 01621 START_CONTEXT startContext; 01622 ADD_CONTEXT addContext; 01623 01624 PAGED_CODE(); 01625 01626 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 01627 01628 // 01629 // Make sure the device is not started 01630 // 01631 01632 if (deviceNode->Flags & DNF_ADDED) { 01633 goto exit; 01634 } 01635 01636 // 01637 // Need enumeration on IoReportDetectedDevice 01638 // 01639 01640 if (!(deviceNode->Flags & DNF_NEED_QUERY_IDS)) { 01641 // 01642 // Invoke the driver's AddDevice() entry and enumerate the device. 01643 // 01644 01645 addContext.GroupsToStart = 0xffff; 01646 addContext.GroupToStartNext = 0xffff; 01647 addContext.DriverStartType = SERVICE_DEMAND_START; 01648 01649 status = IopCallDriverAddDevice(deviceNode, TRUE, &addContext); 01650 if (!NT_SUCCESS(status) || (deviceNode->Flags & DNF_LEGACY_DRIVER)) { 01651 goto exit; 01652 } else if (deviceNode->Flags & DNF_NEED_QUERY_IDS) { 01653 01654 // 01655 // The driver may perform IoReportDetectedDevice 01656 // 01657 01658 goto enumerate; 01659 } 01660 01661 // 01662 // Assign resource to the device 01663 // 01664 01665 requestTable.PhysicalDevice = DeviceObject; 01666 requestTable.Priority = 0; 01667 01668 IopAssignResourcesToDevices(1, &requestTable, TRUE); 01669 01670 if (NT_SUCCESS(requestTable.Status)) { 01671 if (requestTable.ResourceAssignment) { 01672 if (!(deviceNode->Flags & DNF_RESOURCE_REPORTED)) { 01673 deviceNode->Flags |= DNF_RESOURCE_ASSIGNED; 01674 } 01675 // deviceNode->Flags &= ~DNF_INSUFFICIENT_RESOURCES; 01676 deviceNode->ResourceList = requestTable.ResourceAssignment; 01677 deviceNode->ResourceListTranslated = requestTable.TranslatedResourceAssignment; 01678 } else { 01679 deviceNode->Flags |= DNF_NO_RESOURCE_REQUIRED; 01680 } 01681 } else if (requestTable.Status == STATUS_DEVICE_CONFIGURATION_ERROR) { 01682 IopSetDevNodeProblem(deviceNode, CM_PROB_NO_SOFTCONFIG); 01683 goto exit; 01684 } else if (requestTable.Status == STATUS_PNP_BAD_MPS_TABLE) { 01685 IopSetDevNodeProblem(deviceNode, CM_PROB_BIOS_TABLE); 01686 goto exit; 01687 } else if (requestTable.Status == STATUS_PNP_TRANSLATION_FAILED) { 01688 IopSetDevNodeProblem(deviceNode, CM_PROB_TRANSLATION_FAILED); 01689 goto exit; 01690 } else if (requestTable.Status == STATUS_PNP_IRQ_TRANSLATION_FAILED) { 01691 IopSetDevNodeProblem(deviceNode, CM_PROB_IRQ_TRANSLATION_FAILED); 01692 goto exit; 01693 } else { 01694 IopSetDevNodeProblem(deviceNode, CM_PROB_NORMAL_CONFLICT); 01695 goto exit; 01696 } 01697 } 01698 01699 enumerate: 01700 01701 // 01702 // Start and enumerate the device 01703 // 01704 01705 startContext.LoadDriver = TRUE; 01706 startContext.NewDevice = FALSE; 01707 startContext.AddContext.GroupsToStart = NO_MORE_GROUP; 01708 startContext.AddContext.GroupToStartNext = NO_MORE_GROUP; 01709 startContext.AddContext.DriverStartType = SERVICE_DEMAND_START; 01710 01711 IopStartAndEnumerateDevice(deviceNode, &startContext); 01712 newDevice = startContext.NewDevice; 01713 while (newDevice) { 01714 01715 startContext.NewDevice = FALSE; 01716 01717 // 01718 // Process the whole device tree to assign resources to those devices who 01719 // have been successfully added to their drivers. 01720 // 01721 01722 newDevice = IopProcessAssignResources(deviceNode, FALSE, TRUE); 01723 01724 // 01725 // Process the whole device tree to start those devices who have been allocated 01726 // resources and waiting to be started. 01727 // Note, the IopProcessStartDevices routine may enumerate new devices. 01728 // 01729 01730 IopProcessStartDevices(deviceNode, &startContext); 01731 newDevice |= startContext.NewDevice; 01732 01733 } 01734 01735 exit: 01736 ; 01737 }

NTSTATUS IopPnPAddDevice IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  DeviceObject
 

Definition at line 419 of file pnpdd.c.

References PAGED_CODE.

Referenced by IopPnPDriverEntry().

00426 : 00427 00428 This routine handles AddDevice for an madeup PDO device. 00429 00430 Arguments: 00431 00432 DriverObject - Pointer to our pseudo driver object. 00433 00434 DeviceObject - Pointer to the device object for which this requestapplies. 00435 00436 Return Value: 00437 00438 NT status. 00439 00440 --*/ 00441 { 00442 PAGED_CODE(); 00443 00444 #if DBG 00445 00446 // 00447 // We should never get an AddDevice request. 00448 // 00449 00450 DbgBreakPoint(); 00451 00452 #endif 00453 00454 return STATUS_SUCCESS; 00455 } // PNPRES test

VOID IopPnPCompleteRequest IN OUT PIRP  Irp,
IN NTSTATUS  Status,
IN ULONG_PTR  Information
 

Definition at line 1009 of file pnpdd.c.

References IO_NO_INCREMENT, IoCompleteRequest, _IRP::IoStatus, Irp, and Status.

Referenced by IopPnPDispatch().

01017 : 01018 01019 This routine completes PnP irps for our pseudo driver. 01020 01021 Arguments: 01022 01023 Irp - Supplies a pointer to the irp to be completed. 01024 01025 Status - completion status. 01026 01027 Information - completion information to be passed back. 01028 01029 Return Value: 01030 01031 None. 01032 01033 --*/ 01034 01035 { 01036 KIRQL oldIrql; 01037 01038 // 01039 // Complete the IRP. First update the status... 01040 // 01041 01042 Irp->IoStatus.Status = Status; 01043 Irp->IoStatus.Information = Information; 01044 01045 // 01046 // ... and complete it. 01047 // 01048 01049 IoCompleteRequest(Irp, IO_NO_INCREMENT); 01050 }

NTSTATUS IopPnPDispatch IN PDEVICE_OBJECT  DeviceObject,
IN OUT PIRP  Irp
 

Definition at line 648 of file pnpdd.c.

References ArbArbiterHandler(), _ARBITER_INTERFACE::ArbiterHandler, _PNP_BUS_INFORMATION::BusNumber, BusQueryCompatibleIDs, BusQueryDeviceID, BusQueryInstanceID, BusRelations, _PNP_BUS_INFORMATION::BusTypeGuid, _IOPNP_DEVICE_EXTENSION::CompatibleIdList, _IOPNP_DEVICE_EXTENSION::CompatibleIdListSize, _ARBITER_INTERFACE::Context, _DEVICE_RELATIONS::Count, _DEVICE_CAPABILITIES::DeviceState, ExAllocatePool, _DEVICE_CAPABILITIES::HardwareDisabled, _DEVICE_NODE::InstancePath, IoGetCurrentIrpStackLocation, IopCompareGuid, IopGetDeviceResourcesFromRegistry(), IopGetRootDevices(), IopIsFirmwareDisabled(), IopPnPCompleteRequest(), IopRootBusNumberArbiter, IopRootDeviceNode, IopRootDmaArbiter, IopRootIrqArbiter, IopRootMemArbiter, IopRootPortArbiter, IopTranslatorHandlerCm(), IopTranslatorHandlerIo(), _IRP::IoStatus, Irp, IRP_MN_CANCEL_REMOVE_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_DEVICE_USAGE_NOTIFICATION, IRP_MN_QUERY_BUS_INFORMATION, IRP_MN_QUERY_CAPABILITIES, IRP_MN_QUERY_DEVICE_RELATIONS, IRP_MN_QUERY_ID, IRP_MN_QUERY_INTERFACE, IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_QUERY_RESOURCE_REQUIREMENTS, IRP_MN_QUERY_RESOURCES, IRP_MN_QUERY_STOP_DEVICE, IRP_MN_REMOVE_DEVICE, IRP_MN_START_DEVICE, IRP_MN_STOP_DEVICE, _PNP_BUS_INFORMATION::LegacyBusType, _IO_STACK_LOCATION::MinorFunction, NT_SUCCESS, NTSTATUS(), NULL, _DEVICE_RELATIONS::Objects, ObReferenceObject, PAGED_CODE, PagedPool, _IO_STACK_LOCATION::Parameters, _DEVICE_NODE::PhysicalDeviceObject, PIOPNP_DEVICE_EXTENSION, PnpDefaultInterfaceType, QUERY_RESOURCE_LIST, QUERY_RESOURCE_REQUIREMENTS, REGISTRY_BASIC_CONFIGVECTOR, REGISTRY_BOOT_CONFIG, _DEVICE_CAPABILITIES::Size, TargetDeviceRelation, _TRANSLATOR_INTERFACE::TranslateResourceRequirements, _TRANSLATOR_INTERFACE::TranslateResources, TRUE, and _DEVICE_CAPABILITIES::Version.

Referenced by IopPnPDriverEntry().

00655 : 00656 00657 This routine handles all IRP_MJ_PNP IRPs for madeup PDO device. 00658 00659 Arguments: 00660 00661 DeviceObject - Pointer to the device object for which this IRP applies. 00662 00663 Irp - Pointer to the IRP_MJ_PNP IRP to dispatch. 00664 00665 Return Value: 00666 00667 NT status. 00668 00669 --*/ 00670 { 00671 PIOPNP_DEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension; 00672 PIO_STACK_LOCATION irpSp; 00673 NTSTATUS status; 00674 PVOID information = NULL; 00675 ULONG length; 00676 PWCHAR id, wp; 00677 PDEVICE_NODE deviceNode; 00678 PARBITER_INTERFACE arbiterInterface; // PNPRES test 00679 PTRANSLATOR_INTERFACE translatorInterface; // PNPRES test 00680 00681 PAGED_CODE(); 00682 00683 // 00684 // Get a pointer to our stack location and take appropriate action based 00685 // on the minor function. 00686 // 00687 00688 irpSp = IoGetCurrentIrpStackLocation(Irp); 00689 switch (irpSp->MinorFunction){ 00690 00691 case IRP_MN_DEVICE_USAGE_NOTIFICATION: 00692 case IRP_MN_START_DEVICE: 00693 00694 // 00695 // If we get a start device request for a PDO, we simply 00696 // return success. 00697 // 00698 00699 status = STATUS_SUCCESS; 00700 break; 00701 00702 case IRP_MN_CANCEL_STOP_DEVICE: 00703 00704 // 00705 // As we fail all STOP's, this cancel is always successful, and we have 00706 // no work to do. 00707 // 00708 status = STATUS_SUCCESS; 00709 break; 00710 00711 case IRP_MN_QUERY_STOP_DEVICE: 00712 case IRP_MN_STOP_DEVICE: 00713 00714 // 00715 // We can not success the query stop. We don't handle it. because 00716 // we don't know how to stop a root enumerated device. 00717 // 00718 status = STATUS_UNSUCCESSFUL ; 00719 break; 00720 00721 case IRP_MN_QUERY_RESOURCES: 00722 00723 status = IopGetDeviceResourcesFromRegistry( 00724 DeviceObject, 00725 QUERY_RESOURCE_LIST, 00726 REGISTRY_BOOT_CONFIG, 00727 &information, 00728 &length); 00729 if (status == STATUS_OBJECT_NAME_NOT_FOUND) { 00730 status = STATUS_SUCCESS; 00731 information = NULL; 00732 } 00733 break; 00734 00735 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: 00736 00737 status = IopGetDeviceResourcesFromRegistry( 00738 DeviceObject, 00739 QUERY_RESOURCE_REQUIREMENTS, 00740 REGISTRY_BASIC_CONFIGVECTOR, 00741 &information, 00742 &length); 00743 if (status == STATUS_OBJECT_NAME_NOT_FOUND) { 00744 status = STATUS_SUCCESS; 00745 information = NULL; 00746 } 00747 break; 00748 00749 case IRP_MN_QUERY_REMOVE_DEVICE: 00750 case IRP_MN_REMOVE_DEVICE: 00751 case IRP_MN_CANCEL_REMOVE_DEVICE: 00752 00753 // 00754 // For root enumerated devices we let the device objects stays. 00755 // So, they will be marked as deleted but still show up in the tree. 00756 // 00757 00758 //IoDeleteDevice(DeviceObject); 00759 status = STATUS_SUCCESS; 00760 break; 00761 00762 case IRP_MN_QUERY_DEVICE_RELATIONS: 00763 00764 if (DeviceObject == IopRootDeviceNode->PhysicalDeviceObject && 00765 irpSp->Parameters.QueryDeviceRelations.Type == BusRelations) { 00766 status = IopGetRootDevices((PDEVICE_RELATIONS *)&information); 00767 } else { 00768 if (irpSp->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation) { 00769 PDEVICE_RELATIONS deviceRelations; 00770 00771 deviceRelations = ExAllocatePool(PagedPool, sizeof(DEVICE_RELATIONS)); 00772 if (deviceRelations == NULL) { 00773 status = STATUS_INSUFFICIENT_RESOURCES; 00774 } else { 00775 deviceRelations->Count = 1; 00776 deviceRelations->Objects[0] = DeviceObject; 00777 ObReferenceObject(DeviceObject); 00778 information = (PVOID)deviceRelations; 00779 status = STATUS_SUCCESS; 00780 } 00781 } else { 00782 information = (PVOID)Irp->IoStatus.Information; 00783 status = Irp->IoStatus.Status; 00784 } 00785 } 00786 break; 00787 00788 case IRP_MN_QUERY_INTERFACE: 00789 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00790 if (deviceNode == IopRootDeviceNode) { 00791 if ( IopCompareGuid((PVOID)irpSp->Parameters.QueryInterface.InterfaceType, (PVOID)&GUID_ARBITER_INTERFACE_STANDARD)) { 00792 status = STATUS_SUCCESS; 00793 arbiterInterface = (PARBITER_INTERFACE) irpSp->Parameters.QueryInterface.Interface; 00794 arbiterInterface->ArbiterHandler = ArbArbiterHandler; 00795 switch ((UCHAR)((ULONG_PTR)irpSp->Parameters.QueryInterface.InterfaceSpecificData)) { 00796 case CmResourceTypePort: 00797 arbiterInterface->Context = (PVOID) &IopRootPortArbiter; 00798 break; 00799 case CmResourceTypeMemory: 00800 arbiterInterface->Context = (PVOID) &IopRootMemArbiter; 00801 break; 00802 case CmResourceTypeInterrupt: 00803 arbiterInterface->Context = (PVOID) &IopRootIrqArbiter; 00804 break; 00805 case CmResourceTypeDma: 00806 arbiterInterface->Context = (PVOID) &IopRootDmaArbiter; 00807 break; 00808 case CmResourceTypeBusNumber: 00809 arbiterInterface->Context = (PVOID) &IopRootBusNumberArbiter; 00810 break; 00811 default: 00812 status = STATUS_INVALID_PARAMETER; 00813 break; 00814 } 00815 } else if ( IopCompareGuid((PVOID)irpSp->Parameters.QueryInterface.InterfaceType, (PVOID)&GUID_TRANSLATOR_INTERFACE_STANDARD)) { 00816 translatorInterface = (PTRANSLATOR_INTERFACE) irpSp->Parameters.QueryInterface.Interface; 00817 translatorInterface->TranslateResources = IopTranslatorHandlerCm; 00818 translatorInterface->TranslateResourceRequirements = IopTranslatorHandlerIo; 00819 status = STATUS_SUCCESS; 00820 } 00821 break; 00822 } 00823 00824 status = Irp->IoStatus.Status; 00825 break; 00826 00827 case IRP_MN_QUERY_CAPABILITIES: 00828 00829 { 00830 ULONG i; 00831 PDEVICE_POWER_STATE state; 00832 PDEVICE_CAPABILITIES deviceCapabilities; 00833 00834 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00835 00836 deviceCapabilities = irpSp->Parameters.DeviceCapabilities.Capabilities; 00837 deviceCapabilities->Size = sizeof(DEVICE_CAPABILITIES); 00838 deviceCapabilities->Version = 1; 00839 00840 deviceCapabilities->DeviceState[PowerSystemUnspecified]=PowerDeviceUnspecified; 00841 deviceCapabilities->DeviceState[PowerSystemWorking]=PowerDeviceD0; 00842 00843 state = &deviceCapabilities->DeviceState[PowerSystemSleeping1]; 00844 00845 for (i = PowerSystemSleeping1; i < PowerSystemMaximum; i++) { 00846 00847 // 00848 // Only supported state, currently, is off. 00849 // 00850 00851 *state++ = PowerDeviceD3; 00852 } 00853 00854 00855 if(IopIsFirmwareDisabled(deviceNode)) { 00856 // 00857 // this device has been disabled by BIOS 00858 // 00859 deviceCapabilities->HardwareDisabled = TRUE; 00860 } 00861 00862 status = STATUS_SUCCESS; 00863 } 00864 break; 00865 00866 case IRP_MN_QUERY_ID: 00867 if (DeviceObject != IopRootDeviceNode->PhysicalDeviceObject && 00868 (!NT_SUCCESS(Irp->IoStatus.Status) || !Irp->IoStatus.Information)) { 00869 00870 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00871 switch (irpSp->Parameters.QueryId.IdType) { 00872 00873 case BusQueryInstanceID: 00874 case BusQueryDeviceID: 00875 00876 id = (PWCHAR)ExAllocatePool(PagedPool, deviceNode->InstancePath.Length); 00877 if (id) { 00878 ULONG separatorCount = 0; 00879 00880 RtlZeroMemory(id, deviceNode->InstancePath.Length); 00881 information = id; 00882 status = STATUS_SUCCESS; 00883 wp = deviceNode->InstancePath.Buffer; 00884 if (irpSp->Parameters.QueryId.IdType == BusQueryDeviceID) { 00885 while(*wp) { 00886 if (*wp == OBJ_NAME_PATH_SEPARATOR) { 00887 separatorCount++; 00888 if (separatorCount == 2) { 00889 break; 00890 } 00891 } 00892 *id = *wp; 00893 id++; 00894 wp++; 00895 } 00896 } else { 00897 while(*wp) { 00898 if (*wp == OBJ_NAME_PATH_SEPARATOR) { 00899 separatorCount++; 00900 if (separatorCount == 2) { 00901 wp++; 00902 break; 00903 } 00904 } 00905 wp++; 00906 } 00907 while (*wp) { 00908 *id = *wp; 00909 id++; 00910 wp++; 00911 } 00912 } 00913 } else { 00914 status = STATUS_INSUFFICIENT_RESOURCES; 00915 } 00916 break; 00917 00918 case BusQueryCompatibleIDs: 00919 00920 if((Irp->IoStatus.Status != STATUS_NOT_SUPPORTED) || 00921 (deviceExtension == NULL)) { 00922 00923 // 00924 // Upper driver has given some sort of reply or this device 00925 // object wasn't allocated to handle these requests. 00926 // 00927 00928 status = Irp->IoStatus.Status; 00929 break; 00930 } 00931 00932 if(deviceExtension->CompatibleIdListSize != 0) { 00933 00934 id = ExAllocatePool(PagedPool, 00935 deviceExtension->CompatibleIdListSize); 00936 00937 if(id == NULL) { 00938 status = STATUS_INSUFFICIENT_RESOURCES; 00939 break; 00940 } 00941 00942 RtlCopyMemory(id, 00943 deviceExtension->CompatibleIdList, 00944 deviceExtension->CompatibleIdListSize); 00945 00946 information = id; 00947 status = STATUS_SUCCESS; 00948 break; 00949 } 00950 00951 default: 00952 00953 information = (PVOID)Irp->IoStatus.Information; 00954 status = Irp->IoStatus.Status; 00955 } 00956 } else { 00957 information = (PVOID)Irp->IoStatus.Information; 00958 status = Irp->IoStatus.Status; 00959 } 00960 00961 break; 00962 #if 0 00963 case IRP_MN_QUERY_BUS_INFORMATION: 00964 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00965 if (deviceNode == IopRootDeviceNode) { 00966 PPNP_BUS_INFORMATION busInfo; 00967 00968 busInfo = (PPNP_BUS_INFORMATION) ExAllocatePool(PagedPool, sizeof(PNP_BUS_INFORMATION)); 00969 if (busInfo) { 00970 busInfo->LegacyBusType = PnpDefaultInterfaceType; 00971 busInfo->BusNumber = 0; 00972 if (PnpDefaultInterfaceType == Isa) { 00973 busInfo->BusTypeGuid = GUID_BUS_TYPE_ISAPNP; // BUGBUG 00974 } else if (PnpDefaultInterfaceType == Eisa) { 00975 busInfo->BusTypeGuid = GUID_BUS_TYPE_EISA; 00976 } else { // Microchannel 00977 busInfo->BusTypeGuid = GUID_BUS_TYPE_MCA; 00978 } 00979 information = busInfo; 00980 status = STATUS_SUCCESS; 00981 } else { 00982 status = STATUS_INSUFFICIENT_RESOURCES; 00983 information = NULL; 00984 } 00985 break; 00986 } 00987 #endif 00988 00989 // 00990 // Otherwise, let it fall through the default path. 00991 // 00992 00993 default: 00994 00995 information = (PVOID)Irp->IoStatus.Information; 00996 status = Irp->IoStatus.Status; 00997 break; 00998 } 00999 01000 // 01001 // Complete the Irp and return. 01002 // 01003 01004 IopPnPCompleteRequest(Irp, status, (ULONG_PTR)information); 01005 return status; 01006 }

NTSTATUS IopPowerDispatch IN PDEVICE_OBJECT  DeviceObject,
IN OUT PIRP  Irp
 

Definition at line 570 of file pnpdd.c.

References IO_NO_INCREMENT, IoCompleteRequest, IoGetCurrentIrpStackLocation, _IRP::IoStatus, Irp, IRP_MN_POWER_SEQUENCE, IRP_MN_QUERY_POWER, IRP_MN_SET_POWER, IRP_MN_WAIT_WAKE, _IO_STACK_LOCATION::MinorFunction, NTSTATUS(), _IO_STACK_LOCATION::Parameters, PoPowerSequence, PoStartNextPowerIrp(), _POWER_SEQUENCE::SequenceD1, _POWER_SEQUENCE::SequenceD2, _POWER_SEQUENCE::SequenceD3, and Status.

Referenced by IopPnPDriverEntry().

00574 { 00575 PIO_STACK_LOCATION IrpSp; 00576 PPOWER_SEQUENCE PowerSequence; 00577 NTSTATUS Status; 00578 00579 00580 UNREFERENCED_PARAMETER( DeviceObject ); 00581 00582 IrpSp = IoGetCurrentIrpStackLocation (Irp); 00583 Status = Irp->IoStatus.Status; 00584 00585 switch (IrpSp->MinorFunction) { 00586 case IRP_MN_WAIT_WAKE: 00587 Status = STATUS_NOT_SUPPORTED; 00588 break; 00589 00590 case IRP_MN_POWER_SEQUENCE: 00591 PowerSequence = IrpSp->Parameters.PowerSequence.PowerSequence; 00592 PowerSequence->SequenceD1 = PoPowerSequence; 00593 PowerSequence->SequenceD2 = PoPowerSequence; 00594 PowerSequence->SequenceD3 = PoPowerSequence; 00595 Status = STATUS_SUCCESS; 00596 break; 00597 00598 case IRP_MN_QUERY_POWER: 00599 Status = STATUS_SUCCESS; 00600 break; 00601 00602 case IRP_MN_SET_POWER: 00603 switch (IrpSp->Parameters.Power.Type) { 00604 case SystemPowerState: 00605 Status = STATUS_SUCCESS; 00606 break; 00607 00608 case DevicePowerState: 00609 // 00610 // To be here the FDO must have passed the IRP on. 00611 // We do not know how to turn the device off, but the 00612 // FDO is prepaired for it work 00613 // 00614 00615 Status = STATUS_SUCCESS; 00616 break; 00617 00618 default: 00619 // Unkown power type 00620 Status = STATUS_NOT_SUPPORTED; 00621 break; 00622 } 00623 break; 00624 00625 default: 00626 // Unkown power minor code 00627 Status = STATUS_NOT_SUPPORTED; 00628 break; 00629 } 00630 00631 00632 // 00633 // For lagecy devices that do not have drivers loaded, complete 00634 // power irps with success. 00635 // 00636 00637 PoStartNextPowerIrp(Irp); 00638 if (Status != STATUS_NOT_SUPPORTED) { 00639 Irp->IoStatus.Status = Status; 00640 } else { 00641 Status = Irp->IoStatus.Status; 00642 } 00643 IoCompleteRequest( Irp, IO_NO_INCREMENT ); 00644 return Status; 00645 }

USHORT IopProcessAddDevices IN PDEVICE_NODE  DeviceNode,
IN USHORT  StartOrder,
IN ULONG  DriverStartType
 

Definition at line 1053 of file pnpdd.c.

References _DEVICE_NODE::Child, _ADD_CONTEXT::DriverStartType, _ADD_CONTEXT::GroupsToStart, _ADD_CONTEXT::GroupToStartNext, IopAcquireEnumerationLock, IopProcessAddDevicesWorker(), IopReleaseEnumerationLock, IopRootDeviceNode, NO_MORE_GROUP, _DEVICE_NODE::Sibling, and USHORT.

Referenced by IopInitializeSystemDrivers().

01061 : 01062 01063 This functions is used by Pnp manager to load driver and perform AddDevice for 01064 all the devices under DeviceNode subtree. This routine is used at boot time 01065 to process devices which were not processed during boot driver initialization. 01066 01067 Note, caller must acquire the enumeration mutex of the DeviceNode before calling 01068 this routine. 01069 01070 Parameters: 01071 01072 DeviceNode - Specifies the device node whose subtree is to be checked for StartDevice. 01073 01074 StartOrder - The group orders to start. 01075 01076 Return Value: 01077 01078 TRUE - if any new device is successfully added to its driver. 01079 01080 --*/ 01081 { 01082 PDEVICE_NODE deviceNode, nextDeviceNode; 01083 USHORT returnValue = NO_MORE_GROUP; 01084 ADD_CONTEXT context; 01085 01086 context.GroupsToStart = StartOrder; 01087 context.GroupToStartNext = NO_MORE_GROUP; 01088 context.DriverStartType = DriverStartType; 01089 01090 // 01091 // Traverse the device node subtree to perform AddDevice call. 01092 // 01093 01094 if (DeviceNode != IopRootDeviceNode) { 01095 IopAcquireEnumerationLock(DeviceNode); 01096 } 01097 01098 deviceNode = DeviceNode->Child; 01099 while (deviceNode) { 01100 01101 // 01102 // We need to remember the 'next' device node. If the deviceNode is a madeup device 01103 // it may be deleted while processing the IopProcessAddDeviceWorker. 01104 // 01105 01106 nextDeviceNode = deviceNode->Sibling; 01107 IopProcessAddDevicesWorker(deviceNode, &context); 01108 deviceNode = nextDeviceNode; 01109 } 01110 if (DeviceNode != IopRootDeviceNode) { 01111 IopReleaseEnumerationLock(DeviceNode); 01112 } 01113 return context.GroupToStartNext; 01114 }

NTSTATUS IopProcessAddDevicesWorker IN PDEVICE_NODE  DeviceNode,
IN PVOID  Context
 

Definition at line 1117 of file pnpdd.c.

References DNF_ADDED, IopAcquireEnumerationLock, IopCallDriverAddDevice(), IopForAllChildDeviceNodes(), IopProcessAddDevicesWorker(), IopReleaseEnumerationLock, OK_TO_ADD_DEVICE, PADD_CONTEXT, and TRUE.

Referenced by IopProcessAddDevices(), and IopProcessAddDevicesWorker().

01124 : 01125 01126 This function checks if the driver for the DeviceNode is present and loads 01127 the driver if necessary. 01128 01129 Arguments: 01130 01131 DeviceNode - Supplies a pointer to the device node which is to be added. 01132 01133 Context - Supplies a pointer to a BOOLEAN value to indicate if the specified device 01134 is successfully added to its driver. 01135 01136 Return Value: 01137 01138 NTSTATUS code. 01139 01140 --*/ 01141 01142 { 01143 PADD_CONTEXT addContext = (PADD_CONTEXT)Context; 01144 01145 01146 if (DeviceNode->Flags & DNF_ADDED) { 01147 01148 // 01149 // If the device has been added, move to its children. 01150 // 01151 01152 // 01153 // Acquire enumeration mutex to make sure its children won't change by 01154 // someone else. Note, the current device node is protected by its parent's 01155 // Enumeration mutex and it won't disappear either. 01156 // 01157 01158 IopAcquireEnumerationLock(DeviceNode); 01159 01160 // 01161 // Recursively mark all of our children deleted. 01162 // 01163 01164 IopForAllChildDeviceNodes(DeviceNode, IopProcessAddDevicesWorker, Context); 01165 01166 // 01167 // Release the enumeration mutex of the device node. 01168 // 01169 01170 IopReleaseEnumerationLock(DeviceNode); 01171 01172 } else if (OK_TO_ADD_DEVICE(DeviceNode)) { 01173 01174 // 01175 // If this device is not added (not because of failure), load its controlling 01176 // driver and invoke the driver's AddDevice entry. 01177 // 01178 01179 IopCallDriverAddDevice(DeviceNode, TRUE, addContext); 01180 } 01181 return STATUS_SUCCESS; 01182 }

BOOLEAN IopProcessAssignResources IN PDEVICE_NODE  DeviceNode,
IN BOOLEAN  Reallocation,
IN BOOLEAN  BootConfigsOK
 

Definition at line 1185 of file pnpdd.c.

References _DEVICE_NODE::Child, _DEVICE_LIST_CONTEXT::DeviceCount, _DEVICE_LIST_CONTEXT::DeviceList, _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, DNF_ASSIGNING_RESOURCES, DNF_NO_RESOURCE_REQUIRED, DNF_RESOURCE_ASSIGNED, DNF_RESOURCE_REPORTED, ExAcquireResourceShared, ExAllocatePool, ExFreePool(), ExReleaseResource, FALSE, _DEVICE_NODE::Flags, IOP_RESOURCE_REQUEST, IopAcquireEnumerationLock, IopAssignResourcesToDevices(), IopDeviceTreeLock, IopNumberDeviceNodes, IopProcessAssignResourcesWorker(), IopReleaseEnumerationLock, IopSetDevNodeProblem, NT_SUCCESS, PAGED_CODE, PagedPool, PDEVICE_LIST_CONTEXT, _IOP_RESOURCE_REQUEST::PhysicalDevice, _IOP_RESOURCE_REQUEST::Priority, _DEVICE_LIST_CONTEXT::Reallocation, _IOP_RESOURCE_REQUEST::ResourceAssignment, _DEVICE_NODE::ResourceList, _DEVICE_NODE::ResourceListTranslated, _DEVICE_NODE::Sibling, Status, _IOP_RESOURCE_REQUEST::Status, _IOP_RESOURCE_REQUEST::TranslatedResourceAssignment, and TRUE.

Referenced by IopBusCheck(), IopDeviceActionWorker(), IopInitializeSystemDrivers(), and IopNewDevice().

01193 : 01194 01195 This functions is used by Pnp manager to allocate resources for the devices 01196 which have been successfully added to their drivers and waiting to be started. 01197 01198 Note, the caller must acquire the enumeration mutex before calling this routine. 01199 01200 Parameters: 01201 01202 DeviceNode - specifies the device node whose subtree is to be checked for AssignRes. 01203 01204 Reallocation - specifies if we are assigning resources for DNF_INSUFFICIENT_RESOURCES 01205 devices. 01206 01207 BootConfigsOK - Indicates that it is OK to assign BOOT configs. 01208 01209 Return Value: 01210 01211 TRUE - if more devices need resources. This means we did not assign resources for all 01212 the devices. caller must call this routine again. 01213 01214 --*/ 01215 { 01216 PDEVICE_NODE deviceNode; 01217 PDEVICE_LIST_CONTEXT context; 01218 BOOLEAN again = FALSE; 01219 ULONG count, i; 01220 PIOP_RESOURCE_REQUEST requestTable; 01221 01222 PAGED_CODE(); 01223 01224 // 01225 // Allocate and init memory for resource context 01226 // 01227 01228 context = (PDEVICE_LIST_CONTEXT) ExAllocatePool( 01229 PagedPool, 01230 sizeof(DEVICE_LIST_CONTEXT) + 01231 sizeof(PDEVICE_OBJECT) * IopNumberDeviceNodes 01232 ); 01233 if (!context) { 01234 return again; 01235 } 01236 context->DeviceCount = 0; 01237 context->Reallocation = Reallocation; 01238 01239 // 01240 // Parse the device node subtree to determine which devices need resources 01241 // 01242 01243 IopAcquireEnumerationLock(DeviceNode); 01244 deviceNode = DeviceNode->Child; 01245 01246 while (deviceNode) { 01247 IopProcessAssignResourcesWorker(deviceNode, context); 01248 deviceNode = deviceNode->Sibling; 01249 } 01250 IopReleaseEnumerationLock(DeviceNode); 01251 count = context->DeviceCount; 01252 if (count == 0) { 01253 ExFreePool(context); 01254 return again; 01255 } 01256 01257 // 01258 // Need to assign resources to devices. Build the resource request table and call 01259 // resource assignment routine. 01260 // 01261 01262 requestTable = (PIOP_RESOURCE_REQUEST) ExAllocatePool( 01263 PagedPool, 01264 sizeof(IOP_RESOURCE_REQUEST) * count 01265 ); 01266 if (requestTable) { 01267 01268 for (i = 0; i < count; i++) { 01269 requestTable[i].Priority = 0; 01270 requestTable[i].PhysicalDevice = context->DeviceList[i]; 01271 } 01272 01273 // 01274 // Assign resources 01275 // 01276 01277 ExAcquireResourceShared(&IopDeviceTreeLock, TRUE); 01278 IopAssignResourcesToDevices(count, requestTable, BootConfigsOK); 01279 01280 // 01281 // Check the results 01282 // 01283 01284 for (i = 0; i < count; i++) { 01285 01286 deviceNode = (PDEVICE_NODE) 01287 requestTable[i].PhysicalDevice->DeviceObjectExtension->DeviceNode; 01288 if (NT_SUCCESS(requestTable[i].Status)) { 01289 if (requestTable[i].ResourceAssignment) { 01290 if (!(deviceNode->Flags & DNF_RESOURCE_REPORTED)) { 01291 deviceNode->Flags |= DNF_RESOURCE_ASSIGNED; 01292 } 01293 //deviceNode->Flags &= ~DNF_INSUFFICIENT_RESOURCES; 01294 deviceNode->ResourceList = requestTable[i].ResourceAssignment; 01295 deviceNode->ResourceListTranslated = requestTable[i].TranslatedResourceAssignment; 01296 } else { 01297 deviceNode->Flags |= DNF_NO_RESOURCE_REQUIRED; 01298 } 01299 } else if (requestTable[i].Status == STATUS_RETRY) { 01300 again = TRUE; 01301 } else if (requestTable[i].Status == STATUS_DEVICE_CONFIGURATION_ERROR) { 01302 IopSetDevNodeProblem(deviceNode, CM_PROB_NO_SOFTCONFIG); 01303 } else if (requestTable[i].Status == STATUS_PNP_BAD_MPS_TABLE) { 01304 IopSetDevNodeProblem(deviceNode, CM_PROB_BIOS_TABLE); 01305 } else if (requestTable[i].Status == STATUS_PNP_TRANSLATION_FAILED) { 01306 IopSetDevNodeProblem(deviceNode, CM_PROB_TRANSLATION_FAILED); 01307 } else if (requestTable[i].Status == STATUS_PNP_IRQ_TRANSLATION_FAILED) { 01308 IopSetDevNodeProblem(deviceNode, CM_PROB_IRQ_TRANSLATION_FAILED); 01309 } else { 01310 IopSetDevNodeProblem(deviceNode, CM_PROB_NORMAL_CONFLICT); 01311 } 01312 01313 // 01314 // IopProcessAssignReourcesWork marks the device nodes as DNF_ASSIGNING_RESOURCES 01315 // We need to clear it to indicate the assigment is done. 01316 // 01317 01318 deviceNode->Flags &= ~DNF_ASSIGNING_RESOURCES; 01319 } 01320 ExReleaseResource(&IopDeviceTreeLock); 01321 ExFreePool(requestTable); 01322 } 01323 ExFreePool(context); 01324 return again; 01325 }

NTSTATUS IopProcessAssignResourcesWorker IN PDEVICE_NODE  DeviceNode,
IN PVOID  Context
 

Definition at line 1328 of file pnpdd.c.

References _DEVICE_LIST_CONTEXT::DeviceCount, _DEVICE_LIST_CONTEXT::DeviceList, DNF_ADDED, DNF_ASSIGN_RESOURCE_PHASE, DNF_ASSIGNING_RESOURCES, DNF_START_PHASE, _DEVICE_OBJECT::Flags, IopAcquireEnumerationLock, IopClearDevNodeProblem, IopForAllChildDeviceNodes(), IopIsDevNodeProblem, IopProcessAssignResourcesWorker(), IopReleaseEnumerationLock, PAGED_CODE, PDEVICE_LIST_CONTEXT, and _DEVICE_LIST_CONTEXT::Reallocation.

Referenced by IopProcessAssignResources(), and IopProcessAssignResourcesWorker().

01335 : 01336 01337 This functions searches the DeviceNode subtree to locate all the device objects 01338 which have been successfully added to their drivers and waiting for resources to 01339 be started. 01340 01341 Parameters: 01342 01343 DeviceNode - specifies the device node whose subtree is to be checked for AssignRes. 01344 01345 Context - specifies a pointer to a structure to pass resource assignment information. 01346 01347 Return Value: 01348 01349 TRUE. 01350 01351 --*/ 01352 { 01353 PDEVICE_LIST_CONTEXT resourceContext = (PDEVICE_LIST_CONTEXT) Context; 01354 01355 PAGED_CODE(); 01356 01357 // 01358 // If the device node/object has not been add, skip it. 01359 // 01360 01361 if (!(DeviceNode->Flags & DNF_ADDED)) { 01362 return STATUS_SUCCESS; 01363 } 01364 01365 if (resourceContext->Reallocation && 01366 ( IopIsDevNodeProblem(DeviceNode, CM_PROB_NORMAL_CONFLICT) || 01367 IopIsDevNodeProblem(DeviceNode, CM_PROB_TRANSLATION_FAILED) || 01368 IopIsDevNodeProblem(DeviceNode, CM_PROB_IRQ_TRANSLATION_FAILED))) { 01369 IopClearDevNodeProblem(DeviceNode); 01370 } 01371 01372 // 01373 // If the device object has not been started and has no resources yet. 01374 // Append it to our list. 01375 // 01376 01377 if ( !(DeviceNode->Flags & DNF_START_PHASE) && 01378 !(DeviceNode->Flags & DNF_ASSIGN_RESOURCE_PHASE)) { 01379 01380 resourceContext->DeviceList[resourceContext->DeviceCount] = 01381 DeviceNode->PhysicalDeviceObject; 01382 DeviceNode->Flags |= DNF_ASSIGNING_RESOURCES; 01383 resourceContext->DeviceCount++; 01384 01385 } else { 01386 01387 // 01388 // Acquire enumeration mutex to make sure its children won't change by 01389 // someone else. Note, the current device node is protected by its parent's 01390 // Enumeration mutex and it won't disappear either. 01391 // 01392 01393 IopAcquireEnumerationLock(DeviceNode); 01394 01395 // 01396 // Recursively mark all of our children deleted. 01397 // 01398 01399 IopForAllChildDeviceNodes(DeviceNode, IopProcessAssignResourcesWorker, Context); 01400 01401 // 01402 // Release the enumeration mutex of the device node. 01403 // 01404 01405 IopReleaseEnumerationLock(DeviceNode); 01406 } 01407 return STATUS_SUCCESS; 01408 }

NTSTATUS IopReleaseDeviceResources IN PDEVICE_NODE  DeviceNode,
IN BOOLEAN  ReserveResources
 

Definition at line 263 of file pnpdd.c.

References ArbiterRequestPnpEnumerated, ArbiterRequestUndefined, ASSERT, DNF_BOOT_CONFIG_RESERVED, DNF_HAS_BOOT_CONFIG, DNF_MADEUP, ExAcquireResourceShared, ExReleaseResource, IopCreateRegistryKeyEx(), IopDeviceObjectToDeviceInstance(), IopLegacyResourceAllocation(), IoPnpDriverObject, IopQueryDeviceResources(), IopResourcesReleased, KeEnterCriticalRegion, KeLeaveCriticalRegion, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PpRegistryDeviceResource, QUERY_RESOURCE_LIST, TITLE_INDEX_VALUE, and TRUE.

Referenced by IopDeleteLegacyKey(), IopDeleteLockedDeviceNode(), IopDisableDevice(), IopDriverLoadingFailed(), and IoReportDetectedDevice().

00270 : 00271 00272 This routine releases the resources assigned to a device. 00273 00274 Arguments: 00275 00276 DeviceObject - supplies a pointer to a device whose resources are to be released. 00277 00278 ReserveResources - indicates whether we need to re-query and reserve BOOT config for DeviceObject. 00279 00280 Return Value: 00281 00282 NTSTATUS code. 00283 00284 00285 --*/ 00286 { 00287 BOOLEAN conflict; 00288 NTSTATUS status= STATUS_SUCCESS; 00289 PCM_RESOURCE_LIST cmResource; 00290 ULONG cmLength; 00291 00292 PAGED_CODE(); 00293 00294 if (DeviceNode->ResourceList || (DeviceNode->Flags & DNF_BOOT_CONFIG_RESERVED)) { 00295 00296 cmResource = NULL; 00297 cmLength = 0; 00298 00299 // 00300 // If needed, re-query for BOOT configs. We need to do this BEFORE we 00301 // release the BOOT config (otherwise ROOT devices cannot report BOOT 00302 // config). 00303 // 00304 00305 if (ReserveResources && !(DeviceNode->Flags & DNF_MADEUP)) { 00306 00307 // 00308 // First query for new BOOT config (order important for ROOT devices). 00309 // 00310 00311 status = IopQueryDeviceResources ( DeviceNode->PhysicalDeviceObject, 00312 QUERY_RESOURCE_LIST, 00313 &cmResource, 00314 &cmLength); 00315 00316 if (!NT_SUCCESS(status)) { 00317 00318 cmResource = NULL; 00319 cmLength = 0; 00320 00321 } 00322 } 00323 00324 // 00325 // Release resources for this device. 00326 // 00327 00328 status = IopLegacyResourceAllocation( ArbiterRequestUndefined, 00329 IoPnpDriverObject, 00330 DeviceNode->PhysicalDeviceObject, 00331 NULL, 00332 NULL); 00333 if (NT_SUCCESS(status)) { 00334 00335 IopResourcesReleased = TRUE; // Signal there are resources available. 00336 00337 // 00338 // If needed, re-query and reserve current BOOT config for this device. 00339 // We always rereserve the boot config (ie DNF_MADEUP root enumerated 00340 // and IoReportDetected) devices in IopLegacyResourceAllocation. 00341 // 00342 00343 if (ReserveResources && !(DeviceNode->Flags & DNF_MADEUP)) { 00344 00345 UNICODE_STRING unicodeName; 00346 HANDLE logConfHandle; 00347 HANDLE handle; 00348 00349 ASSERT(DeviceNode->BootResources == NULL); 00350 00351 status = IopDeviceObjectToDeviceInstance(DeviceNode->PhysicalDeviceObject, &handle, KEY_ALL_ACCESS); 00352 logConfHandle = NULL; 00353 if (NT_SUCCESS(status)) { 00354 00355 00356 PiWstrToUnicodeString(&unicodeName, REGSTR_KEY_LOG_CONF); 00357 status = IopCreateRegistryKeyEx( &logConfHandle, 00358 handle, 00359 &unicodeName, 00360 KEY_ALL_ACCESS, 00361 REG_OPTION_NON_VOLATILE, 00362 NULL); 00363 if (!NT_SUCCESS(status)) { 00364 00365 logConfHandle = NULL; 00366 00367 } 00368 } 00369 00370 if (logConfHandle) { 00371 00372 PiWstrToUnicodeString(&unicodeName, REGSTR_VAL_BOOTCONFIG); 00373 KeEnterCriticalRegion(); 00374 ExAcquireResourceShared(&PpRegistryDeviceResource, TRUE); 00375 if (cmResource) { 00376 00377 ZwSetValueKey( logConfHandle, 00378 &unicodeName, 00379 TITLE_INDEX_VALUE, 00380 REG_RESOURCE_LIST, 00381 cmResource, 00382 cmLength); 00383 } else { 00384 00385 ZwDeleteValueKey(logConfHandle, &unicodeName); 00386 00387 } 00388 ExReleaseResource(&PpRegistryDeviceResource); 00389 KeLeaveCriticalRegion(); 00390 00391 ZwClose(logConfHandle); 00392 } 00393 00394 // 00395 // Reserve any remaining BOOT config. 00396 // 00397 00398 if (cmResource) { 00399 00400 DeviceNode->Flags |= DNF_HAS_BOOT_CONFIG; 00401 DeviceNode->BootResources = cmResource; 00402 00403 // 00404 // This device consumes BOOT resources. Reserve its boot resources 00405 // 00406 00407 (*IopReserveResourcesRoutine)( ArbiterRequestPnpEnumerated, 00408 DeviceNode->PhysicalDeviceObject, 00409 cmResource); 00410 } 00411 } 00412 } 00413 } 00414 00415 return status; 00416 }

NTSTATUS IopStartDriverDevices IN PDRIVER_OBJECT  DriverObject  ) 
 

Definition at line 1740 of file pnpdd.c.

References ASSERT, _DEVICE_LIST_CONTEXT::DeviceCount, _DEVICE_LIST_CONTEXT::DeviceList, _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, DNF_NEED_QUERY_IDS, ExFreePool(), _DEVICE_NODE::Flags, IopGetDriverDeviceList(), IopRequestDeviceAction(), NTSTATUS(), NULL, ObDereferenceObject, PAGED_CODE, PDEVICE_LIST_CONTEXT, PDRIVER_ADD_DEVICE, PnPInitialized, and StartDevice.

Referenced by IopLoadDriver().

01746 : 01747 01748 This routine is used by IopLoadDriver to add/start the devices controlled by 01749 the newly loaded driver. 01750 01751 Arguments: 01752 01753 DriverObject - specifies the driver object which is being started thru 01754 IopLoadDriver after the boot drivers and system drivers init 01755 phase. 01756 01757 Return Value: 01758 01759 NTSTATUS code. 01760 01761 --*/ 01762 01763 { 01764 ULONG count, i; 01765 PDEVICE_LIST_CONTEXT deviceList; 01766 PDEVICE_NODE deviceNode; 01767 NTSTATUS status = STATUS_SUCCESS; 01768 PDRIVER_ADD_DEVICE addDeviceRoutine; 01769 01770 PAGED_CODE(); 01771 01772 if (!PnPInitialized) { 01773 01774 // 01775 // If this function is called at PnP Init time, we don't start the devices 01776 // for the specified driver. The device add/start is handled by pnp based 01777 // on the device enumeration. 01778 // 01779 01780 return status; 01781 } 01782 01783 addDeviceRoutine = DriverObject->DriverExtension->AddDevice; 01784 if (addDeviceRoutine == NULL) { 01785 ASSERT(addDeviceRoutine); 01786 return status; 01787 } 01788 01789 IopGetDriverDeviceList(DriverObject, &deviceList); 01790 count = deviceList ? deviceList->DeviceCount : 0; 01791 if (count == 0) { 01792 01793 if (deviceList != NULL) { 01794 ExFreePool(deviceList); 01795 } 01796 01797 return STATUS_PLUGPLAY_NO_DEVICE; 01798 } 01799 01800 // 01801 // For each device int the list queue an IopNewDeviceEvent if the device is reported by driver 01802 // 01803 01804 for (i = 0; i < count; i++) { 01805 01806 deviceNode = (PDEVICE_NODE)deviceList->DeviceList[i]->DeviceObjectExtension->DeviceNode; 01807 if (!deviceNode || !(deviceNode->Flags & DNF_NEED_QUERY_IDS) ) { 01808 ObDereferenceObject(deviceList->DeviceList[i]); 01809 continue; 01810 } 01811 IopRequestDeviceAction(deviceList->DeviceList[i], StartDevice, NULL, NULL); 01812 } 01813 01814 ExFreePool(deviceList); 01815 return status; 01816 }

NTSTATUS IopTranslatorHandlerCm IN PVOID  Context,
IN PCM_PARTIAL_RESOURCE_DESCRIPTOR  Source,
IN RESOURCE_TRANSLATION_DIRECTION  Direction,
IN ULONG  AlternativesCount,
OPTIONAL IN IO_RESOURCE_DESCRIPTOR  Alternatives[],
OPTIONAL IN PDEVICE_OBJECT  DeviceObject,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR  Target
 

Definition at line 511 of file pnpdd.c.

References TranslateChildToParent.

Referenced by IopPnPDispatch().

00520 { 00521 *Target = *Source; 00522 #if 0 00523 if (Direction == TranslateChildToParent) { 00524 if (Target->Type == CmResourceTypePort) { 00525 Target->u.Port.Start.LowPart += 0x10000; 00526 } else if (Target->Type == CmResourceTypeMemory) { 00527 Target->u.Memory.Start.LowPart += 0x100000; 00528 } 00529 } else { 00530 if (Target->Type == CmResourceTypePort) { 00531 Target->u.Port.Start.LowPart -= 0x10000; 00532 } else if (Target->Type == CmResourceTypeMemory) { 00533 Target->u.Memory.Start.LowPart -= 0x100000; 00534 } 00535 } 00536 #endif 00537 return STATUS_SUCCESS; 00538 }

NTSTATUS IopTranslatorHandlerIo IN PVOID  Context,
IN PIO_RESOURCE_DESCRIPTOR  Source,
IN PDEVICE_OBJECT  DeviceObject,
OUT PULONG  TargetCount,
OUT PIO_RESOURCE_DESCRIPTOR *  Target
 

Definition at line 540 of file pnpdd.c.

References ExAllocatePool, NULL, and PagedPool.

Referenced by IopPnPDispatch().

00547 { 00548 PIO_RESOURCE_DESCRIPTOR newDesc; 00549 00550 newDesc = (PIO_RESOURCE_DESCRIPTOR) ExAllocatePool(PagedPool, sizeof(IO_RESOURCE_DESCRIPTOR)); 00551 if (newDesc == NULL) { 00552 return STATUS_INSUFFICIENT_RESOURCES; 00553 } 00554 *TargetCount = 1; 00555 *newDesc = *Source; 00556 #if 0 00557 if (newDesc->Type == CmResourceTypePort) { 00558 newDesc->u.Port.MinimumAddress.LowPart += 0x10000; 00559 newDesc->u.Port.MaximumAddress.LowPart += 0x10000; 00560 } else if (newDesc->Type == CmResourceTypeMemory) { 00561 newDesc->u.Memory.MinimumAddress.LowPart += 0x100000; 00562 newDesc->u.Memory.MaximumAddress.LowPart += 0x100000; 00563 } 00564 #endif 00565 *Target = newDesc; 00566 return STATUS_SUCCESS; 00567 }

NTSTATUS IopWriteAllocatedResourcesToRegistry PDEVICE_NODE  DeviceNode,
PCM_RESOURCE_LIST  CmResourceList,
ULONG  Length
 

Definition at line 1931 of file pnpdd.c.

References ExAcquireResourceShared, ExReleaseResource, IopCreateRegistryKeyEx(), IopDeviceObjectToDeviceInstance(), KeEnterCriticalRegion, KeLeaveCriticalRegion, NT_SUCCESS, NTSTATUS(), NULL, _DEVICE_NODE::PhysicalDeviceObject, PpRegistryDeviceResource, RtlInitUnicodeString(), TITLE_INDEX_VALUE, and TRUE.

01939 : 01940 01941 This routine writes allocated resources for a device to its control key of device 01942 instance path key. 01943 01944 Arguments: 01945 01946 DeviceNode - Supplies a pointer to the device node structure of the device. 01947 01948 CmResourceList - Supplies a pointer to the device's allocated CM resource list. 01949 01950 Length - Supplies the length of the CmResourceList. 01951 01952 Return Value: 01953 01954 The status returned is the final completion status of the operation. 01955 01956 --*/ 01957 { 01958 NTSTATUS status; 01959 PDEVICE_OBJECT deviceObject = DeviceNode->PhysicalDeviceObject; 01960 HANDLE handle, handlex; 01961 UNICODE_STRING unicodeName; 01962 01963 KeEnterCriticalRegion(); 01964 ExAcquireResourceShared(&PpRegistryDeviceResource, TRUE); 01965 01966 status = IopDeviceObjectToDeviceInstance( 01967 deviceObject, 01968 &handlex, 01969 KEY_ALL_ACCESS); 01970 if (NT_SUCCESS(status)) { 01971 01972 // 01973 // Open the LogConfig key of the device instance. 01974 // 01975 01976 PiWstrToUnicodeString(&unicodeName, REGSTR_KEY_CONTROL); 01977 status = IopCreateRegistryKeyEx( &handle, 01978 handlex, 01979 &unicodeName, 01980 KEY_ALL_ACCESS, 01981 REG_OPTION_VOLATILE, 01982 NULL 01983 ); 01984 ZwClose(handlex); 01985 if (NT_SUCCESS(status)) { 01986 01987 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_ALLOC_CONFIG); 01988 if (CmResourceList) { 01989 status = ZwSetValueKey( 01990 handle, 01991 &unicodeName, 01992 TITLE_INDEX_VALUE, 01993 REG_RESOURCE_LIST, 01994 CmResourceList, 01995 Length 01996 ); 01997 } else { 01998 status = ZwDeleteValueKey(handle, &unicodeName); 01999 } 02000 ZwClose(handle); 02001 } 02002 } 02003 ExReleaseResource(&PpRegistryDeviceResource); 02004 KeLeaveCriticalRegion(); 02005 return status; 02006 }


Generated on Sat May 15 19:45:10 2004 for test by doxygen 1.3.7