summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorYuanhaoXie <yuanhao.xie@intel.com>2023-09-11 19:02:14 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-10-09 08:22:02 +0000
commit1ec374cb5052dd7999b8289927c5257216fa1026 (patch)
tree6b4c567708a14b298ded18fb19cee3880ffb325c /UefiCpuPkg
parentf784fc0e39f9837dc409aa4f776bcd80e88e925f (diff)
downloadedk2-1ec374cb5052dd7999b8289927c5257216fa1026.tar.gz
edk2-1ec374cb5052dd7999b8289927c5257216fa1026.tar.bz2
edk2-1ec374cb5052dd7999b8289927c5257216fa1026.zip
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>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c
index 75ae4d65b9..1d3573e7b0 100644
--- a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c
+++ b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c
@@ -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;
}