summaryrefslogtreecommitdiff
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2016-04-20 16:58:24 +0800
committerJeff Fan <jeff.fan@intel.com>2016-04-29 10:07:06 +0800
commitaaa1e579a5109a868863c8a3c7a51580f83b4c38 (patch)
tree38b760a69d717c59b529a33a22a22914977acc47 /UefiCpuPkg
parent0f354122328755c7a1cb0f68a37748f166d412ae (diff)
downloadedk2-platforms-aaa1e579a5109a868863c8a3c7a51580f83b4c38.tar.xz
UefiCpuPkg/MtrrLib: Remove the loop of calculating byte offset in MSR
Calculate byte offset in MSR directly and removing the loop. Cc: Feng Tian <feng.tian@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 609aca5c3e..06a361bd84 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -486,18 +486,10 @@ ProgramFixedMtrr (
//
// We found the fixed MTRR to be programmed
//
- for (ByteShift = 0; ByteShift < 8; ByteShift++) {
- if (*Base ==
- (
- mMtrrLibFixedMtrrTable[MsrNum].BaseAddress +
- (ByteShift * mMtrrLibFixedMtrrTable[MsrNum].Length)
- )
- ) {
- break;
- }
- }
+ ByteShift = ((UINT32)*Base - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress)
+ / mMtrrLibFixedMtrrTable[MsrNum].Length;
- if (ByteShift == 8) {
+ if (ByteShift >= 8) {
return RETURN_UNSUPPORTED;
}