/* This function will do some preparation for programming MTRRs: disable cache, invalid cache and disable MTRR caching functionality */
VOID MtrrLibPreMtrrChange(OUT MTRR_CONTEXT *MtrrContext)
/* This function will do some preparation for programming MTRRs: disable cache, invalid cache and disable MTRR caching functionality */
VOID MtrrLibPreMtrrChange(OUT MTRR_CONTEXT *MtrrContext)
{
  MSR_IA32_MTRR_DEF_TYPE_REGISTER  DefType;
  MtrrContext->InterruptState = SaveAndDisableInterrupts ();
  AsmDisableCache ();
  MtrrContext->Cr4 = AsmReadCr4 ();
  AsmWriteCr4 (MtrrContext->Cr4 & (~BIT7));
  CpuFlushTlb ();
  MtrrContext->DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
  DefType.Uint64              = MtrrContext->DefType.Uint64;
  DefType.Bits.E              = 0;
  AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);
}