UefiCpuPkg/MtrrUnitTest: Update UnitTestMtrrGetDefaultMemoryType.

Update UnitTestMtrrGetDefaultMemoryType for the case the when Fixed
MTRRs are not supported.
The original implementation returns FALSE when either fixed MTRR isn't
supported or the number of variable MTRRs is 0. The correct behavior
should return FALSE only when both fixed MTRR isn't supported and the
number of variable MTRRs is 0.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
YuanhaoXie 2023-09-11 19:02:14 +08:00 committed by mergify[bot]
parent f784fc0e39
commit 1ec374cb50
1 changed files with 8 additions and 2 deletions

View File

@ -904,18 +904,24 @@ UnitTestMtrrGetDefaultMemoryType (
Result = MtrrGetDefaultMemoryType ();
UT_ASSERT_EQUAL (Result, CacheUncacheable);
//
// If MTRRs are supported, but Fixed MTRRs are not supported.
//
SystemParameter.MtrrSupported = TRUE;
SystemParameter.FixedMtrrSupported = FALSE;
InitializeMtrrRegs (&SystemParameter);
Result = MtrrGetDefaultMemoryType ();
UT_ASSERT_EQUAL (Result, CacheUncacheable);
UT_ASSERT_EQUAL (Result, SystemParameter.DefaultCacheType);
//
// If MTRRs are supported, but Variable MTRRs are not supported.
//
SystemParameter.MtrrSupported = TRUE;
SystemParameter.FixedMtrrSupported = TRUE;
SystemParameter.VariableMtrrCount = 0;
InitializeMtrrRegs (&SystemParameter);
Result = MtrrGetDefaultMemoryType ();
UT_ASSERT_EQUAL (Result, CacheUncacheable);
UT_ASSERT_EQUAL (Result, SystemParameter.DefaultCacheType);
return UNIT_TEST_PASSED;
}