]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MtrrLib/MtrrLib.c
UefiCpuPkg/MtrrLib: Update the comments for RETURN_BUFFER_TOO_SMALL
[mirror_edk2.git] / UefiCpuPkg / Library / MtrrLib / MtrrLib.c
index fafa15fd63f38561a4e864f3b6e49512b41b908a..2496d08ad4c05db55d59221f31c60a849c550aff 100644 (file)
@@ -47,7 +47,7 @@ typedef struct {
   UINT64                 Address;\r
   UINT64                 Alignment;\r
   UINT64                 Length;\r
-  UINT8                  Type : 7;\r
+  MTRR_MEMORY_CACHE_TYPE Type : 7;\r
 \r
   //\r
   // Temprary use for calculating the best MTRR settings.\r
@@ -1171,7 +1171,6 @@ MtrrLibCalculateLeastMtrrs (
 \r
   for (Index = Start; Index <= Stop; Index++) {\r
     Vertices[Index].Visited = FALSE;\r
-    Vertices[Index].Previous = VertexCount;\r
     Mandatory = Weight[M(Start,Index)];\r
     Vertices[Index].Weight = Mandatory;\r
     if (Mandatory != MAX_WEIGHT) {\r
@@ -1429,7 +1428,7 @@ MtrrLibCalculateSubtractivePath (
           while (SubStart != SubStop) {\r
             Status = MtrrLibAppendVariableMtrr (\r
               Mtrrs, MtrrCapacity, MtrrCount,\r
-              Vertices[SubStart].Address, Vertices[SubStart].Length, (MTRR_MEMORY_CACHE_TYPE) Vertices[SubStart].Type\r
+              Vertices[SubStart].Address, Vertices[SubStart].Length, Vertices[SubStart].Type\r
             );\r
             if (RETURN_ERROR (Status)) {\r
               return Status;\r
@@ -1450,10 +1449,11 @@ MtrrLibCalculateSubtractivePath (
             Pre = Vertices[Cur].Previous;\r
             SubStop = Pre;\r
 \r
-            if (Weight[M (Pre, Cur)] != 0) {\r
+            if (Weight[M (Pre, Cur)] + Weight[O (Pre, Cur)] != 0) {\r
               Status = MtrrLibAppendVariableMtrr (\r
                 Mtrrs, MtrrCapacity, MtrrCount,\r
-                Vertices[Pre].Address, Vertices[Cur].Address - Vertices[Pre].Address, LowestPrecedentType\r
+                Vertices[Pre].Address, Vertices[Cur].Address - Vertices[Pre].Address,\r
+                (Pre != Cur - 1) ? LowestPrecedentType : Vertices[Pre].Type\r
               );\r
               if (RETURN_ERROR (Status)) {\r
                 return Status;\r
@@ -2513,7 +2513,9 @@ Exit:
                                     BaseAddress and Length cannot be modified.\r
   @retval RETURN_OUT_OF_RESOURCES   There are not enough system resources to modify the attributes of\r
                                     the memory resource range.\r
-  @retval RETURN_BUFFER_TOO_SMALL   The scratch buffer is too small for MTRR calculation.\r
+  @retval RETURN_BUFFER_TOO_SMALL   The fixed internal scratch buffer is too small for MTRR calculation.\r
+                                    Caller should use MtrrSetMemoryAttributesInMtrrSettings() to specify\r
+                                    external scratch buffer.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
@@ -2559,7 +2561,9 @@ MtrrSetMemoryAttributeInMtrrSettings (
   @retval RETURN_OUT_OF_RESOURCES   There are not enough system resources to\r
                                     modify the attributes of the memory\r
                                     resource range.\r
-  @retval RETURN_BUFFER_TOO_SMALL   The scratch buffer is too small for MTRR calculation.\r
+  @retval RETURN_BUFFER_TOO_SMALL   The fixed internal scratch buffer is too small for MTRR calculation.\r
+                                    Caller should use MtrrSetMemoryAttributesInMtrrSettings() to specify\r
+                                    external scratch buffer.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r