Add input fixed-MTRR MSR index to be start MSR index to avoid finding fixed-MTRR
MSR index from 0 at each time.
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>
/** @file\r
MTRR setting library\r
\r
/** @file\r
MTRR setting library\r
\r
- Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2008 - 2016, 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
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
@param[in] MemoryCacheType The memory type to set.\r
@param[in, out] Base The base address of memory range.\r
@param[in, out] Length The length of memory range.\r
@param[in] MemoryCacheType The memory type to set.\r
@param[in, out] Base The base address of memory range.\r
@param[in, out] Length The length of memory range.\r
- @param[out] ReturnMsrNum The index of the fixed MTRR MSR to program.\r
+ @param[in, out] LastMsrNum On input, the last index of the fixed MTRR MSR to program.\r
+ On return, the current index of the fixed MTRR MSR to program.\r
@param[out] ReturnClearMask The bits to clear in the fixed MTRR MSR.\r
@param[out] ReturnOrMask The bits to set in the fixed MTRR MSR.\r
\r
@param[out] ReturnClearMask The bits to clear in the fixed MTRR MSR.\r
@param[out] ReturnOrMask The bits to set in the fixed MTRR MSR.\r
\r
IN UINT64 MemoryCacheType,\r
IN OUT UINT64 *Base,\r
IN OUT UINT64 *Length,\r
IN UINT64 MemoryCacheType,\r
IN OUT UINT64 *Base,\r
IN OUT UINT64 *Length,\r
- OUT UINT32 *ReturnMsrNum,\r
+ IN OUT UINT32 *LastMsrNum,\r
OUT UINT64 *ReturnClearMask,\r
OUT UINT64 *ReturnOrMask\r
)\r
OUT UINT64 *ReturnClearMask,\r
OUT UINT64 *ReturnOrMask\r
)\r
OrMask = 0;\r
ClearMask = 0;\r
\r
OrMask = 0;\r
ClearMask = 0;\r
\r
- for (MsrNum = 0; MsrNum < MTRR_NUMBER_OF_FIXED_MTRR; MsrNum++) {\r
+ for (MsrNum = *LastMsrNum + 1; MsrNum < MTRR_NUMBER_OF_FIXED_MTRR; MsrNum++) {\r
if ((*Base >= mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) &&\r
(*Base <\r
(\r
if ((*Base >= mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) &&\r
(*Base <\r
(\r
- if (MsrNum == MTRR_NUMBER_OF_FIXED_MTRR) {\r
+ if (MsrNum >= MTRR_NUMBER_OF_FIXED_MTRR) {\r
return RETURN_UNSUPPORTED;\r
}\r
\r
return RETURN_UNSUPPORTED;\r
}\r
\r
return RETURN_UNSUPPORTED;\r
}\r
\r
return RETURN_UNSUPPORTED;\r
}\r
\r
- *ReturnMsrNum = MsrNum;\r
+ *LastMsrNum = MsrNum;\r
*ReturnClearMask = ClearMask;\r
*ReturnOrMask = OrMask;\r
\r
*ReturnClearMask = ClearMask;\r
*ReturnOrMask = OrMask;\r
\r
//\r
Status = RETURN_SUCCESS;\r
if (BaseAddress < BASE_1MB) {\r
//\r
Status = RETURN_SUCCESS;\r
if (BaseAddress < BASE_1MB) {\r
while ((BaseAddress < BASE_1MB) && (Length > 0) && Status == RETURN_SUCCESS) {\r
Status = ProgramFixedMtrr (MemoryType, &BaseAddress, &Length, &MsrNum, &ClearMask, &OrMask);\r
if (RETURN_ERROR (Status)) {\r
while ((BaseAddress < BASE_1MB) && (Length > 0) && Status == RETURN_SUCCESS) {\r
Status = ProgramFixedMtrr (MemoryType, &BaseAddress, &Length, &MsrNum, &ClearMask, &OrMask);\r
if (RETURN_ERROR (Status)) {\r