https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9538c3ccd781c22a16363…
commit 9538c3ccd781c22a16363222de30a28acc17d185
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Thu Jan 2 23:13:18 2020 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Thu Jan 2 23:25:26 2020 +0100
[NTOS:IO] Fix indentation. No code changes!
---
ntoskrnl/io/pnpmgr/pnpres.c | 851 ++++++++++++++++++++++----------------------
1 file changed, 430 insertions(+), 421 deletions(-)
diff --git a/ntoskrnl/io/pnpmgr/pnpres.c b/ntoskrnl/io/pnpmgr/pnpres.c
index ef77e7f8790..2711e1a1dac 100644
--- a/ntoskrnl/io/pnpmgr/pnpres.c
+++ b/ntoskrnl/io/pnpmgr/pnpres.c
@@ -14,42 +14,44 @@
static
BOOLEAN
-IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL
PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
+IopCheckDescriptorForConflict(
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc,
+ OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
{
- CM_RESOURCE_LIST CmList;
- NTSTATUS Status;
-
- CmList.Count = 1;
- CmList.List[0].InterfaceType = InterfaceTypeUndefined;
- CmList.List[0].BusNumber = 0;
- CmList.List[0].PartialResourceList.Version = 1;
- CmList.List[0].PartialResourceList.Revision = 1;
- CmList.List[0].PartialResourceList.Count = 1;
- CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc;
-
- Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor);
- if (Status == STATUS_CONFLICTING_ADDRESSES)
- return TRUE;
-
- return FALSE;
+ CM_RESOURCE_LIST CmList;
+ NTSTATUS Status;
+
+ CmList.Count = 1;
+ CmList.List[0].InterfaceType = InterfaceTypeUndefined;
+ CmList.List[0].BusNumber = 0;
+ CmList.List[0].PartialResourceList.Version = 1;
+ CmList.List[0].PartialResourceList.Revision = 1;
+ CmList.List[0].PartialResourceList.Count = 1;
+ CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc;
+
+ Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor);
+ if (Status == STATUS_CONFLICTING_ADDRESSES)
+ return TRUE;
+
+ return FALSE;
}
static
BOOLEAN
IopFindBusNumberResource(
- IN PIO_RESOURCE_DESCRIPTOR IoDesc,
- OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
+ IN PIO_RESOURCE_DESCRIPTOR IoDesc,
+ OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONG Start;
- CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
+ ULONG Start;
+ CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
- ASSERT(IoDesc->Type == CmDesc->Type);
- ASSERT(IoDesc->Type == CmResourceTypeBusNumber);
+ ASSERT(IoDesc->Type == CmDesc->Type);
+ ASSERT(IoDesc->Type == CmResourceTypeBusNumber);
- for (Start = IoDesc->u.BusNumber.MinBusNumber;
- Start <= IoDesc->u.BusNumber.MaxBusNumber - IoDesc->u.BusNumber.Length +
1;
- Start++)
- {
+ for (Start = IoDesc->u.BusNumber.MinBusNumber;
+ Start <= IoDesc->u.BusNumber.MaxBusNumber - IoDesc->u.BusNumber.Length
+ 1;
+ Start++)
+ {
CmDesc->u.BusNumber.Length = IoDesc->u.BusNumber.Length;
CmDesc->u.BusNumber.Start = Start;
@@ -62,30 +64,31 @@ IopFindBusNumberResource(
DPRINT1("Satisfying bus number requirement with 0x%x (length:
0x%x)\n", Start, CmDesc->u.BusNumber.Length);
return TRUE;
}
- }
+ }
- return FALSE;
+ return FALSE;
}
static
BOOLEAN
IopFindMemoryResource(
- IN PIO_RESOURCE_DESCRIPTOR IoDesc,
- OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
+ IN PIO_RESOURCE_DESCRIPTOR IoDesc,
+ OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONGLONG Start;
- CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
+ ULONGLONG Start;
+ CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
- ASSERT(IoDesc->Type == CmDesc->Type);
- ASSERT(IoDesc->Type == CmResourceTypeMemory);
+ ASSERT(IoDesc->Type == CmDesc->Type);
+ ASSERT(IoDesc->Type == CmResourceTypeMemory);
- /* HACK */
- if (IoDesc->u.Memory.Alignment == 0) IoDesc->u.Memory.Alignment = 1;
+ /* HACK */
+ if (IoDesc->u.Memory.Alignment == 0)
+ IoDesc->u.Memory.Alignment = 1;
- for (Start = (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart;
- Start <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart -
IoDesc->u.Memory.Length + 1;
- Start += IoDesc->u.Memory.Alignment)
- {
+ for (Start = (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart;
+ Start <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart -
IoDesc->u.Memory.Length + 1;
+ Start += IoDesc->u.Memory.Alignment)
+ {
CmDesc->u.Memory.Length = IoDesc->u.Memory.Length;
CmDesc->u.Memory.Start.QuadPart = (LONGLONG)Start;
@@ -99,30 +102,31 @@ IopFindMemoryResource(
DPRINT1("Satisfying memory requirement with 0x%I64x (length:
0x%x)\n", Start, CmDesc->u.Memory.Length);
return TRUE;
}
- }
+ }
- return FALSE;
+ return FALSE;
}
static
BOOLEAN
IopFindPortResource(
- IN PIO_RESOURCE_DESCRIPTOR IoDesc,
- OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
+ IN PIO_RESOURCE_DESCRIPTOR IoDesc,
+ OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONGLONG Start;
- CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
+ ULONGLONG Start;
+ CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
- ASSERT(IoDesc->Type == CmDesc->Type);
- ASSERT(IoDesc->Type == CmResourceTypePort);
+ ASSERT(IoDesc->Type == CmDesc->Type);
+ ASSERT(IoDesc->Type == CmResourceTypePort);
- /* HACK */
- if (IoDesc->u.Port.Alignment == 0) IoDesc->u.Port.Alignment = 1;
+ /* HACK */
+ if (IoDesc->u.Port.Alignment == 0)
+ IoDesc->u.Port.Alignment = 1;
- for (Start = (ULONGLONG)IoDesc->u.Port.MinimumAddress.QuadPart;
- Start <= (ULONGLONG)IoDesc->u.Port.MaximumAddress.QuadPart -
IoDesc->u.Port.Length + 1;
- Start += IoDesc->u.Port.Alignment)
- {
+ for (Start = (ULONGLONG)IoDesc->u.Port.MinimumAddress.QuadPart;
+ Start <= (ULONGLONG)IoDesc->u.Port.MaximumAddress.QuadPart -
IoDesc->u.Port.Length + 1;
+ Start += IoDesc->u.Port.Alignment)
+ {
CmDesc->u.Port.Length = IoDesc->u.Port.Length;
CmDesc->u.Port.Start.QuadPart = (LONGLONG)Start;
@@ -135,27 +139,27 @@ IopFindPortResource(
DPRINT("Satisfying port requirement with 0x%I64x (length: 0x%x)\n",
Start, CmDesc->u.Port.Length);
return TRUE;
}
- }
+ }
- DPRINT1("IopFindPortResource failed!\n");
- return FALSE;
+ DPRINT1("IopFindPortResource failed!\n");
+ return FALSE;
}
static
BOOLEAN
IopFindDmaResource(
- IN PIO_RESOURCE_DESCRIPTOR IoDesc,
- OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
+ IN PIO_RESOURCE_DESCRIPTOR IoDesc,
+ OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONG Channel;
+ ULONG Channel;
- ASSERT(IoDesc->Type == CmDesc->Type);
- ASSERT(IoDesc->Type == CmResourceTypeDma);
+ ASSERT(IoDesc->Type == CmDesc->Type);
+ ASSERT(IoDesc->Type == CmResourceTypeDma);
- for (Channel = IoDesc->u.Dma.MinimumChannel;
- Channel <= IoDesc->u.Dma.MaximumChannel;
- Channel++)
- {
+ for (Channel = IoDesc->u.Dma.MinimumChannel;
+ Channel <= IoDesc->u.Dma.MaximumChannel;
+ Channel++)
+ {
CmDesc->u.Dma.Channel = Channel;
CmDesc->u.Dma.Port = 0;
@@ -164,26 +168,26 @@ IopFindDmaResource(
DPRINT1("Satisfying DMA requirement with channel 0x%x\n",
Channel);
return TRUE;
}
- }
+ }
- return FALSE;
+ return FALSE;
}
static
BOOLEAN
IopFindInterruptResource(
- IN PIO_RESOURCE_DESCRIPTOR IoDesc,
- OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
+ IN PIO_RESOURCE_DESCRIPTOR IoDesc,
+ OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONG Vector;
+ ULONG Vector;
- ASSERT(IoDesc->Type == CmDesc->Type);
- ASSERT(IoDesc->Type == CmResourceTypeInterrupt);
+ ASSERT(IoDesc->Type == CmDesc->Type);
+ ASSERT(IoDesc->Type == CmResourceTypeInterrupt);
- for (Vector = IoDesc->u.Interrupt.MinimumVector;
- Vector <= IoDesc->u.Interrupt.MaximumVector;
- Vector++)
- {
+ for (Vector = IoDesc->u.Interrupt.MinimumVector;
+ Vector <= IoDesc->u.Interrupt.MaximumVector;
+ Vector++)
+ {
CmDesc->u.Interrupt.Vector = Vector;
CmDesc->u.Interrupt.Level = Vector;
CmDesc->u.Interrupt.Affinity = (KAFFINITY)-1;
@@ -193,15 +197,15 @@ IopFindInterruptResource(
DPRINT1("Satisfying interrupt requirement with IRQ 0x%x\n",
Vector);
return TRUE;
}
- }
+ }
- return FALSE;
+ return FALSE;
}
NTSTATUS NTAPI
IopFixupResourceListWithRequirements(
- IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
- OUT PCM_RESOURCE_LIST *ResourceList)
+ IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
+ OUT PCM_RESOURCE_LIST *ResourceList)
{
ULONG i, OldCount;
BOOLEAN AlternateRequired = FALSE;
@@ -537,388 +541,393 @@ IopFixupResourceListWithRequirements(
static
BOOLEAN
IopCheckResourceDescriptor(
- IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc,
- IN PCM_RESOURCE_LIST ResourceList,
- IN BOOLEAN Silent,
- OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
+ IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc,
+ IN PCM_RESOURCE_LIST ResourceList,
+ IN BOOLEAN Silent,
+ OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
{
- ULONG i, ii;
- BOOLEAN Result = FALSE;
+ ULONG i, ii;
+ BOOLEAN Result = FALSE;
- for (i = 0; i < ResourceList->Count; i++)
- {
- PCM_PARTIAL_RESOURCE_LIST ResList =
&ResourceList->List[i].PartialResourceList;
- for (ii = 0; ii < ResList->Count; ii++)
- {
- PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 =
&ResList->PartialDescriptors[ii];
+ for (i = 0; i < ResourceList->Count; i++)
+ {
+ PCM_PARTIAL_RESOURCE_LIST ResList =
&ResourceList->List[i].PartialResourceList;
+ for (ii = 0; ii < ResList->Count; ii++)
+ {
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 =
&ResList->PartialDescriptors[ii];
- /* We don't care about shared resources */
- if (ResDesc->ShareDisposition == CmResourceShareShared &&
- ResDesc2->ShareDisposition == CmResourceShareShared)
- continue;
+ /* We don't care about shared resources */
+ if (ResDesc->ShareDisposition == CmResourceShareShared &&
+ ResDesc2->ShareDisposition == CmResourceShareShared)
+ continue;
- /* Make sure we're comparing the same types */
- if (ResDesc->Type != ResDesc2->Type)
- continue;
+ /* Make sure we're comparing the same types */
+ if (ResDesc->Type != ResDesc2->Type)
+ continue;
- switch (ResDesc->Type)
- {
- case CmResourceTypeMemory:
- if (((ULONGLONG)ResDesc->u.Memory.Start.QuadPart <
(ULONGLONG)ResDesc2->u.Memory.Start.QuadPart &&
- (ULONGLONG)ResDesc->u.Memory.Start.QuadPart +
ResDesc->u.Memory.Length >
- (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart) ||
((ULONGLONG)ResDesc2->u.Memory.Start.QuadPart <
- (ULONGLONG)ResDesc->u.Memory.Start.QuadPart &&
(ULONGLONG)ResDesc2->u.Memory.Start.QuadPart +
- ResDesc2->u.Memory.Length >
(ULONGLONG)ResDesc->u.Memory.Start.QuadPart))
- {
- if (!Silent)
- {
- DPRINT1("Resource conflict: Memory (0x%I64x to 0x%I64x vs.
0x%I64x to 0x%I64x)\n",
- 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);
- }
-
- Result = TRUE;
-
- goto ByeBye;
- }
- break;
-
- case CmResourceTypePort:
- if (((ULONGLONG)ResDesc->u.Port.Start.QuadPart <
(ULONGLONG)ResDesc2->u.Port.Start.QuadPart &&
- (ULONGLONG)ResDesc->u.Port.Start.QuadPart +
ResDesc->u.Port.Length >
- (ULONGLONG)ResDesc2->u.Port.Start.QuadPart) ||
((ULONGLONG)ResDesc2->u.Port.Start.QuadPart <
- (ULONGLONG)ResDesc->u.Port.Start.QuadPart &&
(ULONGLONG)ResDesc2->u.Port.Start.QuadPart +
- ResDesc2->u.Port.Length >
(ULONGLONG)ResDesc->u.Port.Start.QuadPart))
- {
- if (!Silent)
- {
- DPRINT1("Resource conflict: Port (0x%I64x to 0x%I64x vs.
0x%I64x to 0x%I64x)\n",
- 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);
- }
-
- Result = TRUE;
-
- goto ByeBye;
- }
- break;
-
- case CmResourceTypeInterrupt:
- if (ResDesc->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector)
- {
- if (!Silent)
- {
- 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);
- }
-
- Result = TRUE;
-
- goto ByeBye;
- }
- break;
-
- case CmResourceTypeBusNumber:
- if ((ResDesc->u.BusNumber.Start < ResDesc2->u.BusNumber.Start
&&
- ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length
>
- ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start
<
- ResDesc->u.BusNumber.Start &&
ResDesc2->u.BusNumber.Start +
- ResDesc2->u.BusNumber.Length >
ResDesc->u.BusNumber.Start))
- {
- if (!Silent)
- {
- DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs.
0x%x to 0x%x)\n",
- ResDesc->u.BusNumber.Start,
ResDesc->u.BusNumber.Start +
- ResDesc->u.BusNumber.Length,
ResDesc2->u.BusNumber.Start,
- ResDesc2->u.BusNumber.Start +
ResDesc2->u.BusNumber.Length);
- }
-
- Result = TRUE;
-
- goto ByeBye;
- }
- break;
-
- case CmResourceTypeDma:
- if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel)
- {
- if (!Silent)
- {
- 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);
- }
-
- Result = TRUE;
-
- goto ByeBye;
- }
- break;
- }
- }
- }
+ switch (ResDesc->Type)
+ {
+ case CmResourceTypeMemory:
+ if (((ULONGLONG)ResDesc->u.Memory.Start.QuadPart <
(ULONGLONG)ResDesc2->u.Memory.Start.QuadPart &&
+ (ULONGLONG)ResDesc->u.Memory.Start.QuadPart +
ResDesc->u.Memory.Length >
+ (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart) ||
((ULONGLONG)ResDesc2->u.Memory.Start.QuadPart <
+ (ULONGLONG)ResDesc->u.Memory.Start.QuadPart &&
(ULONGLONG)ResDesc2->u.Memory.Start.QuadPart +
+ ResDesc2->u.Memory.Length >
(ULONGLONG)ResDesc->u.Memory.Start.QuadPart))
+ {
+ if (!Silent)
+ {
+ DPRINT1("Resource conflict: Memory (0x%I64x to 0x%I64x
vs. 0x%I64x to 0x%I64x)\n",
+ 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);
+ }
-ByeBye:
+ Result = TRUE;
- if (Result && ConflictingDescriptor)
- {
- RtlCopyMemory(ConflictingDescriptor,
- ResDesc,
- sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
- }
+ goto ByeBye;
+ }
+ break;
- return Result;
-}
+ case CmResourceTypePort:
+ if (((ULONGLONG)ResDesc->u.Port.Start.QuadPart <
(ULONGLONG)ResDesc2->u.Port.Start.QuadPart &&
+ (ULONGLONG)ResDesc->u.Port.Start.QuadPart +
ResDesc->u.Port.Length >
+ (ULONGLONG)ResDesc2->u.Port.Start.QuadPart) ||
((ULONGLONG)ResDesc2->u.Port.Start.QuadPart <
+ (ULONGLONG)ResDesc->u.Port.Start.QuadPart &&
(ULONGLONG)ResDesc2->u.Port.Start.QuadPart +
+ ResDesc2->u.Port.Length >
(ULONGLONG)ResDesc->u.Port.Start.QuadPart))
+ {
+ if (!Silent)
+ {
+ DPRINT1("Resource conflict: Port (0x%I64x to 0x%I64x vs.
0x%I64x to 0x%I64x)\n",
+ 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);
+ }
-static
-NTSTATUS
-IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode)
-{
- UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT);
- UNICODE_STRING Control = RTL_CONSTANT_STRING(L"Control");
- UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"AllocConfig");
- HANDLE EnumKey, InstanceKey, ControlKey;
- NTSTATUS Status;
- OBJECT_ATTRIBUTES ObjectAttributes;
+ Result = TRUE;
- /* Open the Enum key */
- Status = IopOpenRegistryKeyEx(&EnumKey, NULL, &EnumRoot,
KEY_ENUMERATE_SUB_KEYS);
- if (!NT_SUCCESS(Status))
- return Status;
+ goto ByeBye;
+ }
+ break;
- /* Open the instance key (eg. Root\PNP0A03) */
- Status = IopOpenRegistryKeyEx(&InstanceKey, EnumKey,
&DeviceNode->InstancePath, KEY_ENUMERATE_SUB_KEYS);
- ZwClose(EnumKey);
+ case CmResourceTypeInterrupt:
+ if (ResDesc->u.Interrupt.Vector ==
ResDesc2->u.Interrupt.Vector)
+ {
+ if (!Silent)
+ {
+ 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);
+ }
- if (!NT_SUCCESS(Status))
- return Status;
+ Result = TRUE;
- /* Create/Open the Control key */
- InitializeObjectAttributes(&ObjectAttributes,
- &Control,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- InstanceKey,
- NULL);
- Status = ZwCreateKey(&ControlKey,
- KEY_SET_VALUE,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_VOLATILE,
- NULL);
- ZwClose(InstanceKey);
+ goto ByeBye;
+ }
+ break;
- if (!NT_SUCCESS(Status))
- return Status;
+ case CmResourceTypeBusNumber:
+ if ((ResDesc->u.BusNumber.Start <
ResDesc2->u.BusNumber.Start &&
+ ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length
>
+ ResDesc2->u.BusNumber.Start) ||
(ResDesc2->u.BusNumber.Start <
+ ResDesc->u.BusNumber.Start &&
ResDesc2->u.BusNumber.Start +
+ ResDesc2->u.BusNumber.Length >
ResDesc->u.BusNumber.Start))
+ {
+ if (!Silent)
+ {
+ DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs.
0x%x to 0x%x)\n",
+ ResDesc->u.BusNumber.Start,
ResDesc->u.BusNumber.Start +
+ ResDesc->u.BusNumber.Length,
ResDesc2->u.BusNumber.Start,
+ ResDesc2->u.BusNumber.Start +
ResDesc2->u.BusNumber.Length);
+ }
- /* Write the resource list */
- Status = ZwSetValueKey(ControlKey,
- &ValueName,
- 0,
- REG_RESOURCE_LIST,
- DeviceNode->ResourceList,
- PnpDetermineResourceListSize(DeviceNode->ResourceList));
- ZwClose(ControlKey);
+ Result = TRUE;
- if (!NT_SUCCESS(Status))
- return Status;
+ goto ByeBye;
+ }
+ break;
- return STATUS_SUCCESS;
+ case CmResourceTypeDma:
+ if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel)
+ {
+ if (!Silent)
+ {
+ 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);
+ }
+
+ Result = TRUE;
+
+ goto ByeBye;
+ }
+ break;
+ }
+ }
+ }
+
+ByeBye:
+
+ if (Result && ConflictingDescriptor)
+ {
+ RtlCopyMemory(ConflictingDescriptor,
+ ResDesc,
+ sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
+ }
+
+ return Result;
}
static
NTSTATUS
-IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode)
+IopUpdateControlKeyWithResources(
+ IN PDEVICE_NODE DeviceNode)
{
- IO_STACK_LOCATION Stack;
- IO_STATUS_BLOCK IoStatusBlock;
- NTSTATUS Status;
-
- DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n");
+ UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT);
+ UNICODE_STRING Control = RTL_CONSTANT_STRING(L"Control");
+ UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"AllocConfig");
+ HANDLE EnumKey, InstanceKey, ControlKey;
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+
+ /* Open the Enum key */
+ Status = IopOpenRegistryKeyEx(&EnumKey, NULL, &EnumRoot,
KEY_ENUMERATE_SUB_KEYS);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Open the instance key (eg. Root\PNP0A03) */
+ Status = IopOpenRegistryKeyEx(&InstanceKey, EnumKey,
&DeviceNode->InstancePath, KEY_ENUMERATE_SUB_KEYS);
+ ZwClose(EnumKey);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Create/Open the Control key */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Control,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ InstanceKey,
+ NULL);
+ Status = ZwCreateKey(&ControlKey,
+ KEY_SET_VALUE,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ NULL);
+ ZwClose(InstanceKey);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Write the resource list */
+ Status = ZwSetValueKey(ControlKey,
+ &ValueName,
+ 0,
+ REG_RESOURCE_LIST,
+ DeviceNode->ResourceList,
+ PnpDetermineResourceListSize(DeviceNode->ResourceList));
+ ZwClose(ControlKey);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ return STATUS_SUCCESS;
+}
- Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList =
DeviceNode->ResourceRequirements;
- Status = IopInitiatePnpIrp(
- DeviceNode->PhysicalDeviceObject,
- &IoStatusBlock,
- IRP_MN_FILTER_RESOURCE_REQUIREMENTS,
- &Stack);
- if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED)
- {
- DPRINT1("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS)
failed\n");
- return Status;
- }
- else if (NT_SUCCESS(Status) && IoStatusBlock.Information)
- {
- DeviceNode->ResourceRequirements =
(PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information;
- }
+static
+NTSTATUS
+IopFilterResourceRequirements(
+ IN PDEVICE_NODE DeviceNode)
+{
+ IO_STACK_LOCATION Stack;
+ IO_STATUS_BLOCK IoStatusBlock;
+ NTSTATUS Status;
+
+ DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n");
+
+ Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList =
DeviceNode->ResourceRequirements;
+ Status = IopInitiatePnpIrp(DeviceNode->PhysicalDeviceObject,
+ &IoStatusBlock,
+ IRP_MN_FILTER_RESOURCE_REQUIREMENTS,
+ &Stack);
+ if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED)
+ {
+ DPRINT1("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS)
failed\n");
+ return Status;
+ }
+ else if (NT_SUCCESS(Status) && IoStatusBlock.Information)
+ {
+ DeviceNode->ResourceRequirements =
(PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information;
+ }
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
NTSTATUS
-IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key)
+IopUpdateResourceMap(
+ IN PDEVICE_NODE DeviceNode,
+ PWCHAR Level1Key,
+ PWCHAR Level2Key)
{
- NTSTATUS Status;
- ULONG Disposition;
- HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey;
- UNICODE_STRING KeyName;
- OBJECT_ATTRIBUTES ObjectAttributes;
-
- RtlInitUnicodeString(&KeyName,
- L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
- NULL,
- NULL);
- Status = ZwCreateKey(&ResourceMapKey,
- KEY_ALL_ACCESS,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_VOLATILE,
- &Disposition);
- if (!NT_SUCCESS(Status))
- return Status;
-
- RtlInitUnicodeString(&KeyName, Level1Key);
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
- ResourceMapKey,
- NULL);
- Status = ZwCreateKey(&PnpMgrLevel1,
- KEY_ALL_ACCESS,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_VOLATILE,
- &Disposition);
- ZwClose(ResourceMapKey);
- if (!NT_SUCCESS(Status))
- return Status;
-
- RtlInitUnicodeString(&KeyName, Level2Key);
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
- PnpMgrLevel1,
- NULL);
- Status = ZwCreateKey(&PnpMgrLevel2,
- KEY_ALL_ACCESS,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_VOLATILE,
- &Disposition);
- ZwClose(PnpMgrLevel1);
- if (!NT_SUCCESS(Status))
- return Status;
-
- if (DeviceNode->ResourceList)
- {
- UNICODE_STRING NameU;
- UNICODE_STRING RawSuffix, TranslatedSuffix;
- ULONG OldLength = 0;
-
- ASSERT(DeviceNode->ResourceListTranslated);
-
- RtlInitUnicodeString(&TranslatedSuffix, L".Translated");
- RtlInitUnicodeString(&RawSuffix, L".Raw");
-
- Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
- DevicePropertyPhysicalDeviceObjectName,
- 0,
- NULL,
- &OldLength);
- if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL)
- {
- ASSERT(OldLength);
+ NTSTATUS Status;
+ ULONG Disposition;
+ HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey;
+ UNICODE_STRING KeyName;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+
+ RtlInitUnicodeString(&KeyName,
+ L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
+ NULL,
+ NULL);
+ Status = ZwCreateKey(&ResourceMapKey,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitUnicodeString(&KeyName, Level1Key);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
+ ResourceMapKey,
+ NULL);
+ Status = ZwCreateKey(&PnpMgrLevel1,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ ZwClose(ResourceMapKey);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitUnicodeString(&KeyName, Level2Key);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
+ PnpMgrLevel1,
+ NULL);
+ Status = ZwCreateKey(&PnpMgrLevel2,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ ZwClose(PnpMgrLevel1);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ if (DeviceNode->ResourceList)
+ {
+ UNICODE_STRING NameU;
+ UNICODE_STRING RawSuffix, TranslatedSuffix;
+ ULONG OldLength = 0;
- NameU.Buffer = ExAllocatePool(PagedPool, OldLength + TranslatedSuffix.Length);
- if (!NameU.Buffer)
- {
- ZwClose(PnpMgrLevel2);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
+ ASSERT(DeviceNode->ResourceListTranslated);
- NameU.Length = 0;
- NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length;
+ RtlInitUnicodeString(&TranslatedSuffix, L".Translated");
+ RtlInitUnicodeString(&RawSuffix, L".Raw");
- Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
- DevicePropertyPhysicalDeviceObjectName,
- NameU.MaximumLength,
- NameU.Buffer,
- &OldLength);
- if (!NT_SUCCESS(Status))
- {
- ZwClose(PnpMgrLevel2);
- ExFreePool(NameU.Buffer);
- return Status;
- }
- }
- else if (!NT_SUCCESS(Status))
- {
- /* Some failure */
- ZwClose(PnpMgrLevel2);
- return Status;
- }
- else
- {
- /* This should never happen */
- ASSERT(FALSE);
- }
+ Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
+ DevicePropertyPhysicalDeviceObjectName,
+ 0,
+ NULL,
+ &OldLength);
+ if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ ASSERT(OldLength);
- NameU.Length = (USHORT)OldLength;
+ NameU.Buffer = ExAllocatePool(PagedPool, OldLength +
TranslatedSuffix.Length);
+ if (!NameU.Buffer)
+ {
+ ZwClose(PnpMgrLevel2);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
- RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
+ NameU.Length = 0;
+ NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length;
- Status = ZwSetValueKey(PnpMgrLevel2,
- &NameU,
- 0,
- REG_RESOURCE_LIST,
- DeviceNode->ResourceList,
- PnpDetermineResourceListSize(DeviceNode->ResourceList));
- if (!NT_SUCCESS(Status))
- {
- ZwClose(PnpMgrLevel2);
- ExFreePool(NameU.Buffer);
- return Status;
- }
+ Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
+ DevicePropertyPhysicalDeviceObjectName,
+ NameU.MaximumLength,
+ NameU.Buffer,
+ &OldLength);
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(PnpMgrLevel2);
+ ExFreePool(NameU.Buffer);
+ return Status;
+ }
+ }
+ else if (!NT_SUCCESS(Status))
+ {
+ /* Some failure */
+ ZwClose(PnpMgrLevel2);
+ return Status;
+ }
+ else
+ {
+ /* This should never happen */
+ ASSERT(FALSE);
+ }
- /* "Remove" the suffix by setting the length back to what it used to be
*/
- NameU.Length = (USHORT)OldLength;
+ NameU.Length = (USHORT)OldLength;
- RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
+ RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
- Status = ZwSetValueKey(PnpMgrLevel2,
- &NameU,
- 0,
- REG_RESOURCE_LIST,
- DeviceNode->ResourceListTranslated,
-
PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
- ZwClose(PnpMgrLevel2);
- ExFreePool(NameU.Buffer);
+ Status = ZwSetValueKey(PnpMgrLevel2,
+ &NameU,
+ 0,
+ REG_RESOURCE_LIST,
+ DeviceNode->ResourceList,
+
PnpDetermineResourceListSize(DeviceNode->ResourceList));
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(PnpMgrLevel2);
+ ExFreePool(NameU.Buffer);
+ return Status;
+ }
- if (!NT_SUCCESS(Status))
- return Status;
- }
- else
- {
- ZwClose(PnpMgrLevel2);
- }
-
- return STATUS_SUCCESS;
+ /* "Remove" the suffix by setting the length back to what it used to be
*/
+ NameU.Length = (USHORT)OldLength;
+
+ RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
+
+ Status = ZwSetValueKey(PnpMgrLevel2,
+ &NameU,
+ 0,
+ REG_RESOURCE_LIST,
+ DeviceNode->ResourceListTranslated,
+
PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
+ ZwClose(PnpMgrLevel2);
+ ExFreePool(NameU.Buffer);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+ }
+ else
+ {
+ ZwClose(PnpMgrLevel2);
+ }
+
+ return STATUS_SUCCESS;
}
NTSTATUS
-IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode)
+IopUpdateResourceMapForPnPDevice(
+ IN PDEVICE_NODE DeviceNode)
{
- return IopUpdateResourceMap(DeviceNode, L"PnP Manager",
L"PnpManager");
+ return IopUpdateResourceMap(DeviceNode, L"PnP Manager",
L"PnpManager");
}
static