From 44ccc12ac64bb7dd9734cd145c6e66d90b208ae2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 1 Mar 2015 07:52:32 +0000 Subject: [PATCH] [PCI] - Handle 64-bit PCI base address registers (BARs) - Fix maximum address in resource requirements for 20-bit resources - Fix flags on memory and I/O port resources [NTOS] - Fix handling of 64-bit resources svn path=/trunk/; revision=66511 --- reactos/drivers/bus/pci/pdo.c | 365 +++++++++++++++++----------- reactos/ntoskrnl/io/pnpmgr/pnpres.c | 44 ++-- 2 files changed, 240 insertions(+), 169 deletions(-) diff --git a/reactos/drivers/bus/pci/pdo.c b/reactos/drivers/bus/pci/pdo.c index 6440d407e70..bca71c1f36f 100644 --- a/reactos/drivers/bus/pci/pdo.c +++ b/reactos/drivers/bus/pci/pdo.c @@ -21,6 +21,9 @@ #define DBGPRINT(...) #endif +#define PCI_ADDRESS_MEMORY_ADDRESS_MASK_64 0xfffffffffffffff0ull +#define PCI_ADDRESS_IO_ADDRESS_MASK_64 0xfffffffffffffffcull + /*** PRIVATE *****************************************************************/ static NTSTATUS @@ -191,60 +194,49 @@ PdoQueryCapabilities( return STATUS_SUCCESS; } - static BOOLEAN -PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, - ULONG Offset, - PULONG Base, - PULONG Length, - PULONG Flags) +PdoReadPciBar(PPDO_DEVICE_EXTENSION DeviceExtension, + ULONG Offset, + PULONG OriginalValue, + PULONG NewValue) { - ULONG OrigValue; - ULONG BaseValue; - ULONG NewValue; ULONG Size; - ULONG XLength; - - /* Save original value */ - Size= HalGetBusDataByOffset(PCIConfiguration, - DeviceExtension->PciDevice->BusNumber, - DeviceExtension->PciDevice->SlotNumber.u.AsULONG, - &OrigValue, - Offset, - sizeof(ULONG)); + ULONG AllOnes; + + /* Read the original value */ + Size = HalGetBusDataByOffset(PCIConfiguration, + DeviceExtension->PciDevice->BusNumber, + DeviceExtension->PciDevice->SlotNumber.u.AsULONG, + OriginalValue, + Offset, + sizeof(ULONG)); if (Size != sizeof(ULONG)) { DPRINT1("Wrong size %lu\n", Size); return FALSE; } - - BaseValue = (OrigValue & PCI_ADDRESS_IO_SPACE) - ? (OrigValue & PCI_ADDRESS_IO_ADDRESS_MASK) - : (OrigValue & PCI_ADDRESS_MEMORY_ADDRESS_MASK); - - *Base = BaseValue; - - /* Set magic value */ - NewValue = MAXULONG; - Size= HalSetBusDataByOffset(PCIConfiguration, - DeviceExtension->PciDevice->BusNumber, - DeviceExtension->PciDevice->SlotNumber.u.AsULONG, - &NewValue, - Offset, - sizeof(ULONG)); + + /* Write all ones to determine which bits are held to zero */ + AllOnes = MAXULONG; + Size = HalSetBusDataByOffset(PCIConfiguration, + DeviceExtension->PciDevice->BusNumber, + DeviceExtension->PciDevice->SlotNumber.u.AsULONG, + &AllOnes, + Offset, + sizeof(ULONG)); if (Size != sizeof(ULONG)) { DPRINT1("Wrong size %lu\n", Size); return FALSE; } - + /* Get the range length */ - Size= HalGetBusDataByOffset(PCIConfiguration, - DeviceExtension->PciDevice->BusNumber, - DeviceExtension->PciDevice->SlotNumber.u.AsULONG, - &NewValue, - Offset, - sizeof(ULONG)); + Size = HalGetBusDataByOffset(PCIConfiguration, + DeviceExtension->PciDevice->BusNumber, + DeviceExtension->PciDevice->SlotNumber.u.AsULONG, + NewValue, + Offset, + sizeof(ULONG)); if (Size != sizeof(ULONG)) { DPRINT1("Wrong size %lu\n", Size); @@ -252,19 +244,109 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, } /* Restore original value */ - Size= HalSetBusDataByOffset(PCIConfiguration, - DeviceExtension->PciDevice->BusNumber, - DeviceExtension->PciDevice->SlotNumber.u.AsULONG, - &OrigValue, - Offset, - sizeof(ULONG)); + Size = HalSetBusDataByOffset(PCIConfiguration, + DeviceExtension->PciDevice->BusNumber, + DeviceExtension->PciDevice->SlotNumber.u.AsULONG, + OriginalValue, + Offset, + sizeof(ULONG)); if (Size != sizeof(ULONG)) { DPRINT1("Wrong size %lu\n", Size); return FALSE; } + + return TRUE; +} - if (NewValue == 0) +static BOOLEAN +PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, + UCHAR Bar, + PULONGLONG Base, + PULONGLONG Length, + PULONG Flags, + PUCHAR NextBar, + PULONGLONG MaximumAddress) +{ + union { + struct { + ULONG Bar0; + ULONG Bar1; + } Bars; + ULONGLONG Bar; + } OriginalValue; + union { + struct { + ULONG Bar0; + ULONG Bar1; + } Bars; + ULONGLONG Bar; + } NewValue; + ULONG Offset; + + /* Compute the offset of this BAR in PCI config space */ + Offset = 0x10 + Bar * 4; + + /* Assume this is a 32-bit BAR until we find wrong */ + *NextBar = Bar + 1; + + /* Initialize BAR values to zero */ + OriginalValue.Bar = 0ULL; + NewValue.Bar = 0ULL; + + /* Read the first BAR */ + if (!PdoReadPciBar(DeviceExtension, Offset, + &OriginalValue.Bars.Bar0, + &NewValue.Bars.Bar0)) + { + return FALSE; + } + + /* Check if this is a memory BAR */ + if (!(OriginalValue.Bars.Bar0 & PCI_ADDRESS_IO_SPACE)) + { + /* Write the maximum address if the caller asked for it */ + if (MaximumAddress != NULL) + { + if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_32BIT) + { + *MaximumAddress = 0x00000000FFFFFFFFULL; + } + else if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_20BIT) + { + *MaximumAddress = 0x00000000000FFFFFULL; + } + else if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT) + { + *MaximumAddress = 0xFFFFFFFFFFFFFFFFULL; + } + } + + /* Check if this is a 64-bit BAR */ + if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT) + { + /* We've now consumed the next BAR too */ + *NextBar = Bar + 2; + + /* Read the next BAR */ + if (!PdoReadPciBar(DeviceExtension, Offset + 4, + &OriginalValue.Bars.Bar1, + &NewValue.Bars.Bar1)) + { + return FALSE; + } + } + } + else + { + /* Write the maximum I/O port address */ + if (MaximumAddress != NULL) + { + *MaximumAddress = 0x00000000FFFFFFFFULL; + } + } + + if (NewValue.Bar == 0) { DPRINT("Unused address register\n"); *Base = 0; @@ -272,48 +354,16 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, *Flags = 0; return TRUE; } + + *Base = OriginalValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64; - XLength = ~((NewValue & PCI_ADDRESS_IO_SPACE) - ? (NewValue & PCI_ADDRESS_IO_ADDRESS_MASK) - : (NewValue & PCI_ADDRESS_MEMORY_ADDRESS_MASK)) + 1; + *Length = ~((NewValue.Bar & PCI_ADDRESS_IO_SPACE) + ? (NewValue.Bar & PCI_ADDRESS_IO_ADDRESS_MASK_64) + : (NewValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64)) + 1; -#if 0 - DbgPrint("BaseAddress 0x%08lx Length 0x%08lx", - BaseValue, XLength); - - if (NewValue & PCI_ADDRESS_IO_SPACE) - { - DbgPrint(" IO range"); - } - else - { - DbgPrint(" Memory range"); - if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 0) - { - DbgPrint(" in 32-Bit address space"); - } - else if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 2) - { - DbgPrint(" below 1BM "); - } - else if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 4) - { - DbgPrint(" in 64-Bit address space"); - } - - if (NewValue & PCI_ADDRESS_MEMORY_PREFETCHABLE) - { - DbgPrint(" prefetchable"); - } - } - - DbgPrint("\n"); -#endif - - *Length = XLength; - *Flags = (NewValue & PCI_ADDRESS_IO_SPACE) - ? (NewValue & ~PCI_ADDRESS_IO_ADDRESS_MASK) - : (NewValue & ~PCI_ADDRESS_MEMORY_ADDRESS_MASK); + *Flags = (NewValue.Bar & PCI_ADDRESS_IO_SPACE) + ? (NewValue.Bar & ~PCI_ADDRESS_IO_ADDRESS_MASK_64) + : (NewValue.Bar & ~PCI_ADDRESS_MEMORY_ADDRESS_MASK_64); return TRUE; } @@ -332,10 +382,11 @@ PdoQueryResourceRequirements( ULONG Size; ULONG ResCount = 0; ULONG ListSize; - ULONG i; - ULONG Base; - ULONG Length; + UCHAR Bar; + ULONGLONG Base; + ULONGLONG Length; ULONG Flags; + ULONGLONG MaximumAddress; UNREFERENCED_PARAMETER(IrpSp); DPRINT("PdoQueryResourceRequirements() called\n"); @@ -361,13 +412,15 @@ PdoQueryResourceRequirements( ResCount = 0; if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE) { - for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) + &Flags, + &Bar, + NULL)) break; if (Length != 0) @@ -381,13 +434,15 @@ PdoQueryResourceRequirements( } else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE) { - for (i = 0; i < PCI_TYPE1_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) + &Flags, + &Bar, + NULL)) break; if (Length != 0) @@ -442,13 +497,15 @@ PdoQueryResourceRequirements( Descriptor = &ResourceList->List[0].Descriptors[0]; if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE) { - for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) + &Flags, + &Bar, + &MaximumAddress)) { DPRINT1("PdoGetRangeLength() failed\n"); break; @@ -472,19 +529,20 @@ PdoQueryResourceRequirements( Descriptor->u.Port.Length = Length; Descriptor->u.Port.Alignment = 1; - Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)Base; - Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1); + Descriptor->u.Port.MinimumAddress.QuadPart = Base; + Descriptor->u.Port.MaximumAddress.QuadPart = Base + Length - 1; } else { Descriptor->Type = CmResourceTypeMemory; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE | + (Flags & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? CM_RESOURCE_MEMORY_PREFETCHABLE : 0; Descriptor->u.Memory.Length = Length; Descriptor->u.Memory.Alignment = 1; - Descriptor->u.Memory.MinimumAddress.QuadPart = (ULONGLONG)Base; - Descriptor->u.Memory.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1); + Descriptor->u.Memory.MinimumAddress.QuadPart = Base; + Descriptor->u.Memory.MaximumAddress.QuadPart = Base + Length - 1; } Descriptor++; @@ -500,19 +558,20 @@ PdoQueryResourceRequirements( Descriptor->u.Port.Length = Length; Descriptor->u.Port.Alignment = Length; - Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0; - Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF; + Descriptor->u.Port.MinimumAddress.QuadPart = 0; + Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress; } else { Descriptor->Type = CmResourceTypeMemory; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE | + (Flags & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? CM_RESOURCE_MEMORY_PREFETCHABLE : 0; Descriptor->u.Memory.Length = Length; Descriptor->u.Memory.Alignment = Length; - Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0; - Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF; + Descriptor->u.Port.MinimumAddress.QuadPart = 0; + Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress; } Descriptor++; } @@ -532,13 +591,15 @@ PdoQueryResourceRequirements( } else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE) { - for (i = 0; i < PCI_TYPE1_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) + &Flags, + &Bar, + &MaximumAddress)) { DPRINT1("PdoGetRangeLength() failed\n"); break; @@ -562,19 +623,20 @@ PdoQueryResourceRequirements( Descriptor->u.Port.Length = Length; Descriptor->u.Port.Alignment = 1; - Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)Base; - Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1); + Descriptor->u.Port.MinimumAddress.QuadPart = Base; + Descriptor->u.Port.MaximumAddress.QuadPart = Base + Length - 1; } else { Descriptor->Type = CmResourceTypeMemory; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE | + (Flags & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? CM_RESOURCE_MEMORY_PREFETCHABLE : 0; Descriptor->u.Memory.Length = Length; Descriptor->u.Memory.Alignment = 1; - Descriptor->u.Memory.MinimumAddress.QuadPart = (ULONGLONG)Base; - Descriptor->u.Memory.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1); + Descriptor->u.Memory.MinimumAddress.QuadPart = Base; + Descriptor->u.Memory.MaximumAddress.QuadPart = Base + Length - 1; } Descriptor++; @@ -590,19 +652,20 @@ PdoQueryResourceRequirements( Descriptor->u.Port.Length = Length; Descriptor->u.Port.Alignment = Length; - Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0; - Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF; + Descriptor->u.Port.MinimumAddress.QuadPart = 0; + Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress; } else { Descriptor->Type = CmResourceTypeMemory; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE | + (Flags & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? CM_RESOURCE_MEMORY_PREFETCHABLE : 0; Descriptor->u.Memory.Length = Length; Descriptor->u.Memory.Alignment = Length; - Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0; - Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF; + Descriptor->u.Port.MinimumAddress.QuadPart = 0; + Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress; } Descriptor++; } @@ -645,9 +708,9 @@ PdoQueryResources( ULONG Size; ULONG ResCount = 0; ULONG ListSize; - ULONG i; - ULONG Base; - ULONG Length; + UCHAR Bar; + ULONGLONG Base; + ULONGLONG Length; ULONG Flags; DPRINT("PdoQueryResources() called\n"); @@ -674,13 +737,15 @@ PdoQueryResources( ResCount = 0; if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE) { - for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) + &Flags, + &Bar, + NULL)) break; if (Length) @@ -694,13 +759,15 @@ PdoQueryResources( } else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE) { - for (i = 0; i < PCI_TYPE1_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) + &Flags, + &Bar, + NULL)) break; if (Length != 0) @@ -749,17 +816,16 @@ PdoQueryResources( Descriptor = &PartialList->PartialDescriptors[0]; if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE) { - for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) - { - DPRINT1("PdoGetRangeLength() failed\n"); + &Flags, + &Bar, + NULL)) break; - } if (Length == 0) { @@ -771,7 +837,9 @@ PdoQueryResources( { Descriptor->Type = CmResourceTypePort; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_PORT_IO; + Descriptor->Flags = CM_RESOURCE_PORT_IO | + CM_RESOURCE_PORT_16_BIT_DECODE | + CM_RESOURCE_PORT_POSITIVE_DECODE; Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base; Descriptor->u.Port.Length = Length; @@ -782,7 +850,8 @@ PdoQueryResources( { Descriptor->Type = CmResourceTypeMemory; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE | + (Flags & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? CM_RESOURCE_MEMORY_PREFETCHABLE : 0; Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base; Descriptor->u.Memory.Length = Length; @@ -811,17 +880,16 @@ PdoQueryResources( } else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE) { - for (i = 0; i < PCI_TYPE1_ADDRESSES; i++) + for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;) { if (!PdoGetRangeLength(DeviceExtension, - 0x10 + i * 4, + Bar, &Base, &Length, - &Flags)) - { - DPRINT1("PdoGetRangeLength() failed\n"); + &Flags, + &Bar, + NULL)) break; - } if (Length == 0) { @@ -833,7 +901,9 @@ PdoQueryResources( { Descriptor->Type = CmResourceTypePort; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_PORT_IO; + Descriptor->Flags = CM_RESOURCE_PORT_IO | + CM_RESOURCE_PORT_16_BIT_DECODE | + CM_RESOURCE_PORT_POSITIVE_DECODE; Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base; Descriptor->u.Port.Length = Length; @@ -844,7 +914,8 @@ PdoQueryResources( { Descriptor->Type = CmResourceTypeMemory; Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; - Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE | + (Flags & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? CM_RESOURCE_MEMORY_PREFETCHABLE : 0; Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base; Descriptor->u.Memory.Length = Length; diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpres.c b/reactos/ntoskrnl/io/pnpmgr/pnpres.c index 85ae78449f7..aa29bca895d 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpres.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpres.c @@ -73,7 +73,7 @@ IopFindMemoryResource( IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - LONGLONG Start; + ULONGLONG Start; CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; ASSERT(IoDesc->Type == CmDesc->Type); @@ -82,16 +82,16 @@ IopFindMemoryResource( /* HACK */ if (IoDesc->u.Memory.Alignment == 0) IoDesc->u.Memory.Alignment = 1; - for (Start = IoDesc->u.Memory.MinimumAddress.QuadPart; - Start <= IoDesc->u.Memory.MaximumAddress.QuadPart - IoDesc->u.Memory.Length + 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) { CmDesc->u.Memory.Length = IoDesc->u.Memory.Length; - CmDesc->u.Memory.Start.QuadPart = Start; + CmDesc->u.Memory.Start.QuadPart = (LONGLONG)Start; if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) { - Start += ConflictingDesc.u.Memory.Start.QuadPart + + Start += (ULONGLONG)ConflictingDesc.u.Memory.Start.QuadPart + ConflictingDesc.u.Memory.Length; } else @@ -110,7 +110,7 @@ IopFindPortResource( IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - LONGLONG Start; + ULONGLONG Start; CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; ASSERT(IoDesc->Type == CmDesc->Type); @@ -119,16 +119,16 @@ IopFindPortResource( /* HACK */ if (IoDesc->u.Port.Alignment == 0) IoDesc->u.Port.Alignment = 1; - for (Start = IoDesc->u.Port.MinimumAddress.QuadPart; - Start <= IoDesc->u.Port.MaximumAddress.QuadPart - IoDesc->u.Port.Length + 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) { CmDesc->u.Port.Length = IoDesc->u.Port.Length; - CmDesc->u.Port.Start.QuadPart = Start; + CmDesc->u.Port.Start.QuadPart = (LONGLONG)Start; if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) { - Start += ConflictingDesc.u.Port.Start.QuadPart + ConflictingDesc.u.Port.Length; + Start += (ULONGLONG)ConflictingDesc.u.Port.Start.QuadPart + ConflictingDesc.u.Port.Length; } else { @@ -300,8 +300,8 @@ IopFixupResourceListWithRequirements( case CmResourceTypePort: /* Make sure the length matches and it satisfies our address range */ if (CmDesc->u.Memory.Length == IoDesc->u.Memory.Length && - CmDesc->u.Memory.Start.QuadPart >= IoDesc->u.Memory.MinimumAddress.QuadPart && - CmDesc->u.Memory.Start.QuadPart + CmDesc->u.Memory.Length - 1 <= IoDesc->u.Memory.MaximumAddress.QuadPart) + (ULONGLONG)CmDesc->u.Memory.Start.QuadPart >= (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart && + (ULONGLONG)CmDesc->u.Memory.Start.QuadPart + CmDesc->u.Memory.Length - 1 <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart) { /* Found it */ Matched = TRUE; @@ -564,11 +564,11 @@ IopCheckResourceDescriptor( switch (ResDesc->Type) { case CmResourceTypeMemory: - if ((ResDesc->u.Memory.Start.QuadPart < ResDesc2->u.Memory.Start.QuadPart && - ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length > - ResDesc2->u.Memory.Start.QuadPart) || (ResDesc2->u.Memory.Start.QuadPart < - ResDesc->u.Memory.Start.QuadPart && ResDesc2->u.Memory.Start.QuadPart + - ResDesc2->u.Memory.Length > ResDesc->u.Memory.Start.QuadPart)) + 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) { @@ -585,11 +585,11 @@ IopCheckResourceDescriptor( break; case CmResourceTypePort: - if ((ResDesc->u.Port.Start.QuadPart < ResDesc2->u.Port.Start.QuadPart && - ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length > - ResDesc2->u.Port.Start.QuadPart) || (ResDesc2->u.Port.Start.QuadPart < - ResDesc->u.Port.Start.QuadPart && ResDesc2->u.Port.Start.QuadPart + - ResDesc2->u.Port.Length > ResDesc->u.Port.Start.QuadPart)) + 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) {