Index: pnpres.c =================================================================== --- ntoskrnl/io/pnpmgr/pnpres.c (revision 69227) +++ ntoskrnl/io/pnpmgr/pnpres.c (working copy) @@ -205,6 +205,9 @@ { ULONG i, OldCount; BOOLEAN AlternateRequired = FALSE; +#if NEW_RES_HANDLING + PIO_RESOURCE_LIST ResList; +#endif /* Save the initial resource count when we got here so we can restore if an alternate fails */ if (*ResourceList != NULL) @@ -212,10 +215,15 @@ else OldCount = 0; +#if NEW_RES_HANDLING + ResList = &RequirementsList->List[0]; +#endif for (i = 0; i < RequirementsList->AlternativeLists; i++) { ULONG ii; +#if !NEW_RES_HANDLING PIO_RESOURCE_LIST ResList = &RequirementsList->List[i]; +#endif /* We need to get back to where we were before processing the last alternative list */ if (OldCount == 0 && *ResourceList != NULL) @@ -513,6 +521,9 @@ DPRINT1("Unable to satisfy preferred resource or alternates in list %lu\n", i); /* Try the next alternate list */ +#if NEW_RES_HANDLING + ResList = (PVOID)&ResList->Descriptors[ResList->Count]; +#endif continue; } @@ -543,11 +554,21 @@ OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) { ULONG i, ii; +#if NEW_RES_HANDLING + PCM_FULL_RESOURCE_DESCRIPTOR FullDesc; +#endif BOOLEAN Result = FALSE; +#if NEW_RES_HANDLING + FullDesc = &ResourceList->List[0]; +#endif for (i = 0; i < ResourceList->Count; i++) { +#if NEW_RES_HANDLING + PCM_PARTIAL_RESOURCE_LIST ResList = &FullDesc->PartialResourceList; +#else PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList->List[i].PartialResourceList; +#endif for (ii = 0; ii < ResList->Count; ii++) { PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList->PartialDescriptors[ii]; @@ -576,6 +597,7 @@ ResDesc->u.Memory.Start.QuadPart, ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart, ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length); + __debugbreak(); } Result = TRUE; @@ -597,6 +619,7 @@ ResDesc->u.Port.Start.QuadPart, ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length, ResDesc2->u.Port.Start.QuadPart, ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length); + __debugbreak(); } Result = TRUE; @@ -613,6 +636,7 @@ DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n", ResDesc->u.Interrupt.Vector, ResDesc->u.Interrupt.Level, ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level); + __debugbreak(); } Result = TRUE; @@ -634,6 +658,7 @@ ResDesc->u.BusNumber.Start, ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length, ResDesc2->u.BusNumber.Start, ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length); + __debugbreak(); } Result = TRUE; @@ -650,6 +675,7 @@ DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n", ResDesc->u.Dma.Channel, ResDesc->u.Dma.Port, ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port); + __debugbreak(); } Result = TRUE; @@ -659,6 +685,9 @@ break; } } +#if NEW_RES_HANDLING + FullDesc = (PVOID)&ResList->PartialDescriptors[ResList->Count]; +#endif } ByeBye: @@ -926,7 +955,12 @@ IopTranslateDeviceResources( IN PDEVICE_NODE DeviceNode) { +#if NEW_RES_HANDLING + PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDesc, FullTranslatedDesc; + PCM_PARTIAL_RESOURCE_LIST pPartialResourceList, pPartialTranslatedList; +#else PCM_PARTIAL_RESOURCE_LIST pPartialResourceList; +#endif PCM_PARTIAL_RESOURCE_DESCRIPTOR DescriptorRaw, DescriptorTranslated; ULONG i, j, ListSize; NTSTATUS Status; @@ -949,14 +983,28 @@ goto cleanup; } RtlCopyMemory(DeviceNode->ResourceListTranslated, DeviceNode->ResourceList, ListSize); +#if NEW_RES_HANDLING + FullResourceDesc = &DeviceNode->ResourceList->List[0]; + FullTranslatedDesc = &DeviceNode->ResourceListTranslated->List[0]; +#endif for (i = 0; i < DeviceNode->ResourceList->Count; i++) { +#if NEW_RES_HANDLING + pPartialResourceList = &FullResourceDesc->PartialResourceList; + pPartialTranslatedList = &FullTranslatedDesc->PartialResourceList; + ASSERT(pPartialResourceList->Count == pPartialTranslatedList->Count); +#else pPartialResourceList = &DeviceNode->ResourceList->List[i].PartialResourceList; +#endif for (j = 0; j < pPartialResourceList->Count; j++) { DescriptorRaw = &pPartialResourceList->PartialDescriptors[j]; +#if NEW_RES_HANDLING + DescriptorTranslated = &pPartialTranslatedList->PartialDescriptors[j]; +#else DescriptorTranslated = &DeviceNode->ResourceListTranslated->List[i].PartialResourceList.PartialDescriptors[j]; +#endif switch (DescriptorRaw->Type) { case CmResourceTypePort: @@ -963,8 +1011,13 @@ { ULONG AddressSpace = 1; /* IO space */ if (!HalTranslateBusAddress( +#if NEW_RES_HANDLING + FullResourceDesc->InterfaceType, + FullResourceDesc->BusNumber, +#else DeviceNode->ResourceList->List[i].InterfaceType, DeviceNode->ResourceList->List[i].BusNumber, +#endif DescriptorRaw->u.Port.Start, &AddressSpace, &DescriptorTranslated->u.Port.Start)) @@ -988,8 +1041,13 @@ case CmResourceTypeInterrupt: { DescriptorTranslated->u.Interrupt.Vector = HalGetInterruptVector( +#if NEW_RES_HANDLING + FullResourceDesc->InterfaceType, + FullResourceDesc->BusNumber, +#else DeviceNode->ResourceList->List[i].InterfaceType, DeviceNode->ResourceList->List[i].BusNumber, +#endif DescriptorRaw->u.Interrupt.Level, DescriptorRaw->u.Interrupt.Vector, (PKIRQL)&DescriptorTranslated->u.Interrupt.Level, @@ -1008,8 +1066,13 @@ { ULONG AddressSpace = 0; /* Memory space */ if (!HalTranslateBusAddress( +#if NEW_RES_HANDLING + FullResourceDesc->InterfaceType, + FullResourceDesc->BusNumber, +#else DeviceNode->ResourceList->List[i].InterfaceType, DeviceNode->ResourceList->List[i].BusNumber, +#endif DescriptorRaw->u.Memory.Start, &AddressSpace, &DescriptorTranslated->u.Memory.Start)) @@ -1039,6 +1102,10 @@ goto cleanup; } } +#if NEW_RES_HANDLING + FullResourceDesc = (PVOID)&pPartialResourceList->PartialDescriptors[pPartialResourceList->Count]; + FullTranslatedDesc = (PVOID)&pPartialTranslatedList->PartialDescriptors[pPartialTranslatedList->Count]; +#endif } return STATUS_SUCCESS; @@ -1098,6 +1165,7 @@ if (!NT_SUCCESS(Status)) { DPRINT1("Boot resources for %wZ cause a resource conflict!\n", &DeviceNode->InstancePath); + __debugbreak(); ExFreePool(DeviceNode->ResourceList); DeviceNode->ResourceList = NULL; } @@ -1174,11 +1242,21 @@ OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) { ULONG i, ii; +#if NEW_RES_HANDLING + PCM_FULL_RESOURCE_DESCRIPTOR FullDesc; +#endif BOOLEAN Result = FALSE; +#if NEW_RES_HANDLING + FullDesc = &ResourceList1->List[0]; +#endif for (i = 0; i < ResourceList1->Count; i++) { +#if NEW_RES_HANDLING + PCM_PARTIAL_RESOURCE_LIST ResList = &FullDesc->PartialResourceList; +#else PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList1->List[i].PartialResourceList; +#endif for (ii = 0; ii < ResList->Count; ii++) { PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc = &ResList->PartialDescriptors[ii]; @@ -1189,6 +1267,9 @@ ConflictingDescriptor); if (Result) goto ByeBye; } +#if NEW_RES_HANDLING + FullDesc = (PVOID)&ResList->PartialDescriptors[ResList->Count]; +#endif } ByeBye: