]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
CorebootPayloadPkg/PciHostBridgeLib: Fix the wrong PCI resource limit
[mirror_edk2.git] / CorebootPayloadPkg / Library / PciHostBridgeLib / PciHostBridgeSupport.c
index a95ffcaf64906813d4af9520610a6d5498168c97..6d94ff72c95695cf9c0bee7b57738baec5b7b32e 100644 (file)
@@ -91,7 +91,7 @@ AdjustRootBridgeResource (
   // Align IO  resource at 4K  boundary\r
   //\r
   Mask        = 0xFFFULL;\r
-  Io->Limit   = (Io->Limit + Mask) & ~Mask;\r
+  Io->Limit   = ((Io->Limit + Mask) & ~Mask) - 1;\r
   if (Io->Base != MAX_UINT64) {\r
     Io->Base &= ~Mask;\r
   }\r
@@ -100,7 +100,7 @@ AdjustRootBridgeResource (
   // Align MEM resource at 1MB boundary\r
   //\r
   Mask        = 0xFFFFFULL;\r
-  Mem->Limit  = (Mem->Limit + Mask) & ~Mask;\r
+  Mem->Limit  = ((Mem->Limit + Mask) & ~Mask) - 1;\r
   if (Mem->Base != MAX_UINT64) {\r
     Mem->Base &= ~Mask;\r
   }\r
@@ -193,6 +193,7 @@ PcatPciRootBridgeParseBars (
   UINT32                            UpperValue;\r
   UINT64                            Mask;\r
   UINTN                             Offset;\r
+  UINTN                             LowBit;\r
   UINT64                            Base;\r
   UINT64                            Length;\r
   UINT64                            Limit;\r
@@ -262,7 +263,10 @@ PcatPciRootBridgeParseBars (
 \r
           Base = Base | LShiftU64 ((UINT64) OriginalUpperValue, 32);\r
           Length = Length | LShiftU64 ((UINT64) UpperValue, 32);\r
-          Length = (~Length) + 1;\r
+          if (Length != 0) {\r
+            LowBit = LowBitSet64 (Length);\r
+            Length = LShiftU64 (1ULL, LowBit);\r
+          }\r
 \r
           if ((Value & BIT3) == BIT3) {\r
             MemAperture = PMemAbove4G;\r