[NTOSKRNL]

- Replace the broken CM_RESOURCE_LIST_SIZE with a better function that actually works with resource lists that have device-specific data in them (fixes missing device specific data when resources are retrieved with IoGetDeviceProperty)
- Separate the resource code out of pnpmgr.c and into pnpres.c
- Simplify resource assigning to simply calling one function, IopAssignDeviceResources, which takes care of the registry configuration, translation, etc.
- Set the DNF_NEED_ENUMERATION_ONLY flag only AFTER the device is actually started not before
- Set DNF_START_FAILED if IRP_MN_START_DEVICE fails
- Fix a bug in IoReportDetectedDevice that wrote the AllocConfig value to wrong place

svn path=/trunk/; revision=46983
This commit is contained in:
Cameron Gutman 2010-04-21 22:33:11 +00:00
parent 577625f6f8
commit a31725e572
5 changed files with 1209 additions and 1174 deletions

View file

@ -88,21 +88,6 @@
#define IopFreeMdlFromLookaside \
ObpFreeCapturedAttributes
//
// Returns the size of a CM_RESOURCE_LIST
//
#define CM_RESOURCE_LIST_SIZE(ResList) \
(ResList->Count == 1) ? \
FIELD_OFFSET( \
CM_RESOURCE_LIST, \
List[0].PartialResourceList. \
PartialDescriptors[(ResList)-> \
List[0]. \
PartialResourceList. \
Count]) \
: \
FIELD_OFFSET(CM_RESOURCE_LIST, List)
//
// Determines if the IRP is Synchronous
//
@ -506,6 +491,21 @@ typedef struct _DEVICETREE_TRAVERSE_CONTEXT
PVOID Context;
} DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
//
// Resource code
//
ULONG
NTAPI
IopCalculateResourceListSize(
IN PCM_RESOURCE_LIST ResourceList
);
NTSTATUS
NTAPI
IopAssignDeviceResources(
IN PDEVICE_NODE DeviceNode
);
//
// PNP Routines
//

File diff suppressed because it is too large Load diff

View file

@ -18,28 +18,14 @@ IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
IN ULONG CreateOptions,
OUT PHANDLE Handle);
NTSTATUS
IopAssignDeviceResources(
IN PDEVICE_NODE DeviceNode,
OUT ULONG *pRequiredSize);
NTSTATUS
IopSetDeviceInstanceData(HANDLE InstanceKey,
PDEVICE_NODE DeviceNode);
NTSTATUS
IopTranslateDeviceResources(
IN PDEVICE_NODE DeviceNode,
IN ULONG RequiredSize);
NTSTATUS
IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
PVOID Context);
NTSTATUS
IopUpdateResourceMapForPnPDevice(
IN PDEVICE_NODE DeviceNode);
NTSTATUS
IopDetectResourceConflict(
IN PCM_RESOURCE_LIST ResourceList);
@ -189,6 +175,11 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
/* We don't send IRP_MN_START_DEVICE */
IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED);
/* We need to get device IDs */
#if 0
IopDeviceNodeSetFlag(DeviceNode, DNF_NEED_QUERY_IDS);
#endif
/* This is a legacy driver for this device */
IopDeviceNodeSetFlag(DeviceNode, DNF_LEGACY_DRIVER);
@ -258,9 +249,7 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
if (DeviceNode->BootResources)
IopDeviceNodeSetFlag(DeviceNode, DNF_HAS_BOOT_CONFIG);
if (DeviceNode->ResourceRequirements)
IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_REPORTED);
else
if (!DeviceNode->ResourceRequirements && !DeviceNode->BootResources)
IopDeviceNodeSetFlag(DeviceNode, DNF_NO_RESOURCE_REQUIRED);
/* Write the resource information to the registry */
@ -269,27 +258,7 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
/* If the caller didn't get the resources assigned for us, do it now */
if (!ResourceAssigned)
{
IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES);
Status = IopAssignDeviceResources(DeviceNode, &RequiredLength);
if (NT_SUCCESS(Status))
{
Status = IopTranslateDeviceResources(DeviceNode, RequiredLength);
if (NT_SUCCESS(Status))
{
Status = IopUpdateResourceMapForPnPDevice(DeviceNode);
if (NT_SUCCESS(Status) && DeviceNode->ResourceList)
{
RtlInitUnicodeString(&ValueName, L"AllocConfig");
Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_RESOURCE_LIST,
DeviceNode->ResourceList,
CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceList));
}
}
}
IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES);
Status = IopAssignDeviceResources(DeviceNode);
/* See if we failed */
if (!NT_SUCCESS(Status))

File diff suppressed because it is too large Load diff

View file

@ -270,6 +270,7 @@
<file>pnpmgr.c</file>
<file>pnpnotify.c</file>
<file>pnpreport.c</file>
<file>pnpres.c</file>
<file>pnproot.c</file>
<file>pnputil.c</file>
</directory>