/* If MtrrSetting is not NULL, gets the variable MTRRs raw value from input MTRR settings buffer. If MtrrSetting is NULL, gets the variable MTRRs raw value from MTRRs. */
MTRR_VARIABLE_SETTINGS* MtrrGetVariableMtrrWorker(IN MTRR_SETTINGS *MtrrSetting, IN UINT32 VariableMtrrCount, OUT MTRR_VARIABLE_SETTINGS *VariableSettings)
/* If MtrrSetting is not NULL, gets the variable MTRRs raw value from input MTRR settings buffer. If MtrrSetting is NULL, gets the variable MTRRs raw value from MTRRs. */
MTRR_VARIABLE_SETTINGS* MtrrGetVariableMtrrWorker(IN MTRR_SETTINGS *MtrrSetting, IN UINT32 VariableMtrrCount, OUT MTRR_VARIABLE_SETTINGS *VariableSettings)
{
  UINT32  Index;
  ASSERT (VariableMtrrCount <= ARRAY_SIZE (VariableSettings->Mtrr));
  for (Index = 0; Index < VariableMtrrCount; Index++) {
    if (MtrrSetting == NULL) {
      VariableSettings->Mtrr[Index].Base =
        AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1));
      VariableSettings->Mtrr[Index].Mask =
        AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1));
    } else {
      VariableSettings->Mtrr[Index].Base = MtrrSetting->Variables.Mtrr[Index].Base;
      VariableSettings->Mtrr[Index].Mask = MtrrSetting->Variables.Mtrr[Index].Mask;
    }
  }
  return VariableSettings;
}