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>
This commit is contained in:
Jeff Fan 2016-04-20 16:58:24 +08:00
parent 0f35412232
commit aaa1e579a5
1 changed files with 3 additions and 11 deletions

View File

@ -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;
}