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>
//\r
// We found the fixed MTRR to be programmed\r
//\r
- for (ByteShift = 0; ByteShift < 8; ByteShift++) {\r
- if (*Base ==\r
- (\r
- mMtrrLibFixedMtrrTable[MsrNum].BaseAddress +\r
- (ByteShift * mMtrrLibFixedMtrrTable[MsrNum].Length)\r
- )\r
- ) {\r
- break;\r
- }\r
- }\r
+ ByteShift = ((UINT32)*Base - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress)\r
+ / mMtrrLibFixedMtrrTable[MsrNum].Length;\r
\r
- if (ByteShift == 8) {\r
+ if (ByteShift >= 8) {\r
return RETURN_UNSUPPORTED;\r
}\r
\r