diff options
author | Jeff Fan <jeff.fan@intel.com> | 2016-04-20 16:58:24 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-15 13:33:38 +0800 |
commit | bdd6d367ec95846d549422b9838894269c24b307 (patch) | |
tree | 6ac7ed5bf3a0b2f4e0177bb398fb3073c0c65634 /UefiCpuPkg | |
parent | 298667c01b6676b01cbea3954c0436f595536ec2 (diff) | |
download | edk2-platforms-bdd6d367ec95846d549422b9838894269c24b307.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>
(cherry picked from commit aaa1e579a5109a868863c8a3c7a51580f83b4c38)
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r-- | UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 14 |
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;
}
|