]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Revert incompatible change:
authorjyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 5 Feb 2010 22:27:07 +0000 (22:27 +0000)
committerjyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 5 Feb 2010 22:27:07 +0000 (22:27 +0000)
1) No API change from old version.
2) Change MACRO:
#define  MTRR_NUMBER_OF_VARIABLE_MTRR  32 // the semantics are changed from NUMBER to MAX_NUMBER.
#define  FIRMWARE_VARIABLE_MTRR_NUMBER  6 // wrong and deprecated
#define  MTRR_LIB_IA32_VARIABLE_MTRR_END 0x20F // wrong and deprecated
#define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2 // add new one.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9941 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/Include/Library/MtrrLib.h
UefiCpuPkg/Library/MtrrLib/MtrrLib.c

index 14453719bf6ec0ac6592322caa75f4302514a3c1..e2f2491eee1a231b36bc61331246bf8257799786 100644 (file)
 //\r
 \r
 //\r
-// We can not use Pcd as macro to define structure, so we have to define MAX_MTRR_NUMBER_OF_VARIABLE_MTRR\r
+// The semantics of below macro is MAX_MTRR_NUMBER_OF_VARIABLE_MTRR, the real number can be read out from MTRR_CAP register.\r
 //\r
-#define  MAX_MTRR_NUMBER_OF_VARIABLE_MTRR  32\r
+#define  MTRR_NUMBER_OF_VARIABLE_MTRR  32\r
 //\r
 // Firmware need reserve 2 MTRR for OS\r
 //\r
 #define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2\r
 \r
 #define  MTRR_NUMBER_OF_FIXED_MTRR      11\r
+//\r
+// Below macro is deprecated, and should not be used.\r
+//\r
+#define  FIRMWARE_VARIABLE_MTRR_NUMBER  6\r
 #define  MTRR_LIB_IA32_MTRR_CAP                      0x0FE\r
 #define  MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK            0x0FF\r
 #define  MTRR_LIB_IA32_MTRR_FIX64K_00000             0x250\r
 #define  MTRR_LIB_IA32_MTRR_FIX4K_F0000              0x26E\r
 #define  MTRR_LIB_IA32_MTRR_FIX4K_F8000              0x26F\r
 #define  MTRR_LIB_IA32_VARIABLE_MTRR_BASE            0x200\r
+//\r
+// Below macro is deprecated, and should not be used.\r
+//\r
+#define  MTRR_LIB_IA32_VARIABLE_MTRR_END             0x20F\r
 #define  MTRR_LIB_IA32_MTRR_DEF_TYPE                 0x2FF\r
 #define  MTRR_LIB_MSR_VALID_MASK                     0xFFFFFFFFFULL\r
 #define  MTRR_LIB_CACHE_VALID_ADDRESS                0xFFFFFF000ULL\r
@@ -83,7 +91,7 @@ typedef struct _MTRR_VARIABLE_SETTING_ {
 // Array for variable MTRRs\r
 //\r
 typedef struct _MTRR_VARIABLE_SETTINGS_ {\r
-       MTRR_VARIABLE_SETTING   Mtrr[MAX_MTRR_NUMBER_OF_VARIABLE_MTRR];\r
+       MTRR_VARIABLE_SETTING   Mtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];\r
 }      MTRR_VARIABLE_SETTINGS;\r
 \r
 //\r
@@ -282,25 +290,19 @@ MtrrSetAllMtrrs (
   This function shadows the content of variable MTRRs into\r
   an internal array: VariableMtrr\r
 \r
-  @param  MtrrValidBitsMask        The mask for the valid bit of the MTRR\r
-  @param  MtrrValidAddressMask     The valid address mask for MTRR since the base address in\r
-                                   MTRR must align to 4K, so valid address mask equal to\r
-                                   MtrrValidBitsMask & 0xfffffffffffff000ULL\r
-  @param  VariableMtrrCount        On input, it means the array number of variable MTRRs passed in.\r
-                                   On output, it means the number of MTRRs which has been used if EFI_SUCCESS,\r
-                                   or the number of MTRR required if BUFFER_TOO_SMALL.\r
-  @param  VariableMtrr             The array to shadow variable MTRRs content\r
-\r
-  @retval RETURN_SUCCESS           The variable MTRRs are returned.\r
-  @retval RETURN_BUFFER_TOO_SMALL  The input buffer is too small to hold the variable MTRRs.\r
-\r
+  @param  MtrrValidBitsMask     The mask for the valid bit of the MTRR\r
+  @param  MtrrValidAddressMask  The valid address mask for MTRR since the base address in\r
+                                MTRR must align to 4K, so valid address mask equal to\r
+                                MtrrValidBitsMask & 0xfffffffffffff000ULL\r
+  @param  VariableMtrr          The array to shadow variable MTRRs content\r
+  @return                       The ruturn value of this paramter indicates the number of\r
+                                MTRRs which has been used.\r
 **/\r
-RETURN_STATUS\r
+UINT32\r
 EFIAPI\r
 MtrrGetMemoryAttributeInVariableMtrr (\r
   IN  UINT64                    MtrrValidBitsMask,\r
   IN  UINT64                    MtrrValidAddressMask,\r
-  IN OUT UINT32                 *VariableMtrrCount,\r
   OUT VARIABLE_MTRR             *VariableMtrr\r
   );\r
 \r
index a95a72bfa3c8933b88be3f526cf7790b2e9bd930..1a8ffc2cdc234d4dd54f10d3f5d6897945da279c 100644 (file)
@@ -300,49 +300,35 @@ ProgramFixedMtrr (
 /**\r
   Get the attribute of variable MTRRs.\r
 \r
-  This function shadows the content of variable MTRRs into\r
-  an internal array: VariableMtrr\r
+  This function shadows the content of variable MTRRs into an\r
+  internal array: VariableMtrr.\r
 \r
-  @param  MtrrValidBitsMask        The mask for the valid bit of the MTRR\r
-  @param  MtrrValidAddressMask     The valid address mask for MTRR since the base address in\r
-                                   MTRR must align to 4K, so valid address mask equal to\r
-                                   MtrrValidBitsMask & 0xfffffffffffff000ULL\r
-  @param  VariableMtrrCount        On input, it means the array number of variable MTRRs passed in.\r
-                                   On output, it means the number of MTRRs which has been used if EFI_SUCCESS,\r
-                                   or the number of MTRR required if BUFFER_TOO_SMALL.\r
-  @param  VariableMtrr             The array to shadow variable MTRRs content\r
+  @param  MtrrValidBitsMask     The mask for the valid bit of the MTRR\r
+  @param  MtrrValidAddressMask  The valid address mask for MTRR\r
+  @param  VariableMtrr          The array to shadow variable MTRRs content\r
 \r
-  @retval RETURN_SUCCESS           The variable MTRRs are returned.\r
-  @retval RETURN_BUFFER_TOO_SMALL  The input buffer is too small to hold the variable MTRRs.\r
+  @return                       The return value of this paramter indicates the\r
+                                number of MTRRs which has been used.\r
 \r
 **/\r
-RETURN_STATUS\r
+UINT32\r
 EFIAPI\r
 MtrrGetMemoryAttributeInVariableMtrr (\r
   IN  UINT64                    MtrrValidBitsMask,\r
   IN  UINT64                    MtrrValidAddressMask,\r
-  IN OUT UINT32                 *VariableMtrrCount,\r
   OUT VARIABLE_MTRR             *VariableMtrr\r
   )\r
 {\r
   UINTN   Index;\r
   UINT32  MsrNum;\r
   UINT32  UsedMtrr;\r
-  UINT  FirmwareVariableMtrrCount;\r
+  UINT32  FirmwareVariableMtrrCount;\r
   UINT32  VariableMtrrEnd;\r
 \r
-  //\r
-  // Check if input buffer is large enough\r
-  //\r
   FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();\r
-  if (*VariableMtrrCount < FirmwareVariableMtrrCount) {\r
-    *VariableMtrrCount = (UINT32)FirmwareVariableMtrrCount;\r
-    return RETURN_BUFFER_TOO_SMALL;\r
-  }\r
-\r
   VariableMtrrEnd = MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (2 * GetVariableMtrrCount ()) - 1;\r
 \r
-  ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * (*VariableMtrrCount));\r
+  ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * MTRR_NUMBER_OF_VARIABLE_MTRR);\r
   UsedMtrr = 0;\r
 \r
   for (MsrNum = MTRR_LIB_IA32_VARIABLE_MTRR_BASE, Index = 0;\r
@@ -368,8 +354,7 @@ MtrrGetMemoryAttributeInVariableMtrr (
       Index++;\r
     }\r
   }\r
-  *VariableMtrrCount = UsedMtrr;\r
-  return RETURN_SUCCESS;\r
+  return UsedMtrr;\r
 }\r
 \r
 \r
@@ -882,7 +867,7 @@ MtrrSetMemoryAttribute (
   BOOLEAN                   Positive;\r
   UINT32                    MsrNum;\r
   UINTN                     MtrrNumber;\r
-  VARIABLE_MTRR             VariableMtrr[MAX_MTRR_NUMBER_OF_VARIABLE_MTRR];\r
+  VARIABLE_MTRR             VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];\r
   UINT32                    UsedMtrr;\r
   UINT64                    MtrrValidBitsMask;\r
   UINT64                    MtrrValidAddressMask;\r
@@ -960,8 +945,7 @@ MtrrSetMemoryAttribute (
   //\r
   // Check for overlap\r
   //\r
-  UsedMtrr = MAX_MTRR_NUMBER_OF_VARIABLE_MTRR;\r
-  MtrrGetMemoryAttributeInVariableMtrr (MtrrValidBitsMask, MtrrValidAddressMask, &UsedMtrr, VariableMtrr);\r
+  UsedMtrr = MtrrGetMemoryAttributeInVariableMtrr (MtrrValidBitsMask, MtrrValidAddressMask, VariableMtrr);\r
   OverLap = CheckMemoryAttributeOverlap (BaseAddress, BaseAddress + Length - 1, VariableMtrr);\r
   if (OverLap) {\r
     Status = CombineMemoryAttribute (MemoryType, &BaseAddress, &Length, VariableMtrr, &UsedMtrr, &OverwriteExistingMtrr);\r
@@ -1127,11 +1111,10 @@ MtrrGetMemoryAttribute (
   UINT64                  MtrrType;\r
   UINT64                  TempMtrrType;\r
   MTRR_MEMORY_CACHE_TYPE  CacheType;\r
-  VARIABLE_MTRR           VariableMtrr[MAX_MTRR_NUMBER_OF_VARIABLE_MTRR];\r
+  VARIABLE_MTRR           VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];\r
   UINT64                  MtrrValidBitsMask;\r
   UINT64                  MtrrValidAddressMask;\r
   UINTN                   VariableMtrrCount;\r
-  UINT32                  UsedMtrr;\r
 \r
   //\r
   // Check if MTRR is enabled, if not, return UC as attribute\r
@@ -1169,11 +1152,9 @@ MtrrGetMemoryAttribute (
     }\r
   }\r
   MtrrLibInitializeMtrrMask(&MtrrValidBitsMask, &MtrrValidAddressMask);\r
-  UsedMtrr = MAX_MTRR_NUMBER_OF_VARIABLE_MTRR;\r
   MtrrGetMemoryAttributeInVariableMtrr(\r
     MtrrValidBitsMask,\r
     MtrrValidAddressMask,\r
-    &UsedMtrr,\r
     VariableMtrr\r
     );\r
 \r