]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Replace SetPower2 by EDKII baselib - GetPowerOfTwo64.
authorYao, Jiewen <Jiewen.Yao@intel.com>
Tue, 28 Apr 2015 02:48:57 +0000 (02:48 +0000)
committerjyao1 <jyao1@Edk2>
Tue, 28 Apr 2015 02:48:57 +0000 (02:48 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <Jiewen.Yao@intel.com>
Reviewed-by: "Ma, Maurice" <Maurice.Ma@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17222 6f19259b-4bc3-4df7-8a09-765794883524

IntelFspPkg/Library/BaseCacheLib/CacheLib.c

index 40d404dd69e70660868ae3fa55bb687d4ae1e799..1a089185974f6d7811a6f7a273394cbb55eeeba9 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include <Library/CacheAsRamLib.h>\r
 #include "CacheLibInternal.h"\r
 \r
-/**\r
-  Calculate the maximum value which is a power of 2, but less the Input.\r
-\r
-  @param[in]  Input        The number to pass in.\r
-  @return The maximum value which is align to power of 2 and less the Input\r
-**/\r
-UINT32\r
-SetPower2 (\r
-  IN  UINT32                    Input\r
-  );\r
-\r
 /**\r
   Search the memory cache type for specific memory from MTRR.\r
 \r
@@ -236,11 +225,7 @@ Power2MaxMemory (
   //\r
   // Compute inital power of 2 size to return\r
   //\r
-  if (RShiftU64(MemoryLength, 32)) {\r
-    Result = LShiftU64((UINT64)SetPower2((UINT32) RShiftU64(MemoryLength, 32)), 32);\r
-  } else {\r
-    Result = (UINT64)SetPower2((UINT32)MemoryLength);\r
-  }\r
+  Result = GetPowerOfTwo64(MemoryLength);\r
 \r
   //\r
   // Special case base of 0 as all ranges are valid\r
@@ -295,37 +280,6 @@ CheckMtrrAlignment (
   return ShiftedBase % ShiftedSize;\r
 }\r
 \r
-/**\r
-  Calculate the maximum value which is a power of 2, but less the Input.\r
-\r
-  @param[in]  Input        The number to pass in.\r
-\r
-  @return The maximum value which is align to power of 2 and less the Input.\r
-**/\r
-UINT32\r
-SetPower2 (\r
-  IN UINT32 Input\r
-  )\r
-{\r
-  UINT32 Result;\r
-\r
-  Result = 0;\r
-#if defined(__GCC__)\r
-  asm("bsr %1, \\r
-      %%eax; \\r
-     bts %%eax, \\r
-      %0;" :"=r"(Result) :\r
-    "r"(Input)\r
-  );\r
-#elif defined(_MSC_VER)\r
-  _asm {\r
-    bsr eax, Input\r
-    bts Result, eax\r
-  }\r
-#endif\r
-  return Result;\r
-}\r
-\r
 /**\r
   Programs fixed MTRRs registers.\r
 \r