Revision: 19195
          http://sourceforge.net/p/edk2/code/19195
Author:   vanjeff
Date:     2015-12-10 07:21:55 +0000 (Thu, 10 Dec 2015)
Log Message:
-----------
UefiCpuPkg/MtrrLib: Add PCD PcdCpuNumberOfReservedVariableMtrrs

Current MtrrLib reserves 2 variable MTRRs for some legacy OS boot (CSM boots)
may require some MTRRs to be reserved for OS use. But UEFI OS boot will not use
MTRRs.

Per Scott's suggestion in
link: http://article.gmane.org/gmane.comp.bios.edk2.devel/4099
Add one PCD PcdCpuNumberOfReservedVariableMtrrs to specify the number of
variable MTRRs reserved for OS use. Setting its default value to 2 is for
back-compatibility.

(Sync patch r19151 from main trunk.)

Cc: Scott Duplichan <[email protected]>
Cc: Feng Tian <[email protected]>
Cc: Michael Kinney <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Suggested-by: Scott Duplichan <[email protected]>
Reviewed-by: Feng Tian <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/19151

Modified Paths:
--------------
    branches/UDK2015/UefiCpuPkg/Include/Library/MtrrLib.h
    branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
    branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
    branches/UDK2015/UefiCpuPkg/UefiCpuPkg.dec

Modified: branches/UDK2015/UefiCpuPkg/Include/Library/MtrrLib.h
===================================================================
--- branches/UDK2015/UefiCpuPkg/Include/Library/MtrrLib.h       2015-12-10 
07:21:12 UTC (rev 19194)
+++ branches/UDK2015/UefiCpuPkg/Include/Library/MtrrLib.h       2015-12-10 
07:21:55 UTC (rev 19195)
@@ -1,7 +1,7 @@
 /** @file
   MTRR setting library
 
-  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -26,6 +26,7 @@
 #define  MTRR_NUMBER_OF_VARIABLE_MTRR  32
 //
 // Firmware need reserve 2 MTRR for OS
+// Note: It is replaced by PCD PcdCpuNumberOfReservedVariableMtrrs
 //
 #define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2
 

Modified: branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
===================================================================
--- branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.c       2015-12-10 
07:21:12 UTC (rev 19194)
+++ branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.c       2015-12-10 
07:21:55 UTC (rev 19195)
@@ -140,13 +140,15 @@
   )
 {
   UINT32  VariableMtrrCount;
+  UINT32  ReservedMtrrNumber;
 
   VariableMtrrCount = GetVariableMtrrCount ();
-  if (VariableMtrrCount < RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER) {
+  ReservedMtrrNumber = PcdGet32 (PcdCpuNumberOfReservedVariableMtrrs);
+  if (VariableMtrrCount < ReservedMtrrNumber) {
     return 0;
   }
 
-  return VariableMtrrCount - RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER;
+  return VariableMtrrCount - ReservedMtrrNumber;
 }
 
 /**

Modified: branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
===================================================================
--- branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf     2015-12-10 
07:21:12 UTC (rev 19194)
+++ branches/UDK2015/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf     2015-12-10 
07:21:55 UTC (rev 19195)
@@ -1,7 +1,7 @@
 ## @file
 #  MTRR library provides APIs for MTRR operation.
 #
-#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
@@ -41,3 +41,6 @@
   CpuLib
   DebugLib
 
+[Pcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs   ## 
SOMETIMES_CONSUMES
+

Modified: branches/UDK2015/UefiCpuPkg/UefiCpuPkg.dec
===================================================================
--- branches/UDK2015/UefiCpuPkg/UefiCpuPkg.dec  2015-12-10 07:21:12 UTC (rev 
19194)
+++ branches/UDK2015/UefiCpuPkg/UefiCpuPkg.dec  2015-12-10 07:21:55 UTC (rev 
19195)
@@ -167,6 +167,11 @@
   # @Prompt SMM CPU Synchronization Method.
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x00|UINT8|0x60000014
 
+  ## Specifies the number of variable MTRRs reserved for OS use. The default 
number of
+  #  MTRRs reserved for OS use is 2.
+  # @Prompt Number of reserved variable MTRRs.
+  
gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0x2|UINT32|0x00000015
+
 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   ## Specifies timeout value in microseconds for the BSP to detect all APs for 
the first time.
   # @Prompt Timeout for the BSP to detect all APs for the first time.


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to