16 { 38,
TRUE,
TRUE, CacheUncacheable, 12 },
17 { 38,
TRUE,
TRUE, CacheWriteBack, 12 },
18 { 38,
TRUE,
TRUE, CacheWriteThrough, 12 },
19 { 38,
TRUE,
TRUE, CacheWriteProtected, 12 },
20 { 38,
TRUE,
TRUE, CacheWriteCombining, 12 },
22 { 42,
TRUE,
TRUE, CacheUncacheable, 12 },
23 { 42,
TRUE,
TRUE, CacheWriteBack, 12 },
24 { 42,
TRUE,
TRUE, CacheWriteThrough, 12 },
25 { 42,
TRUE,
TRUE, CacheWriteProtected, 12 },
26 { 42,
TRUE,
TRUE, CacheWriteCombining, 12 },
28 { 48,
TRUE,
TRUE, CacheUncacheable, 12 },
29 { 48,
TRUE,
TRUE, CacheWriteBack, 12 },
30 { 48,
TRUE,
TRUE, CacheWriteThrough, 12 },
31 { 48,
TRUE,
TRUE, CacheWriteProtected, 12 },
32 { 48,
TRUE,
TRUE, CacheWriteCombining, 12 },
34 { 48,
TRUE,
FALSE, CacheUncacheable, 12 },
36 { 48,
TRUE,
FALSE, CacheWriteThrough, 12 },
37 { 48,
TRUE,
FALSE, CacheWriteProtected, 12 },
38 { 48,
TRUE,
FALSE, CacheWriteCombining, 12 },
39 { 48,
TRUE,
TRUE, CacheWriteBack, 12, 7},
42UINT32 mFixedMtrrsIndex[] = {
56 (
ARRAY_SIZE (mFixedMtrrsIndex) == MTRR_NUMBER_OF_FIXED_MTRR),
57 "gFixedMtrrIndex does NOT contain all the fixed MTRRs!"
71 UINT32 NumberOfReservedVariableMtrrs;
75STATIC CHAR8 *mCacheDescription[] = {
"UC",
"WC",
"N/A",
"N/A",
"WT",
"WP",
"WB" };
91 IN UINTN ExpectedMemoryRangeCount,
99 for (Index = 0; Index < ExpectedMemoryRangeCount; Index++) {
100 UT_ASSERT_EQUAL (ExpectedMemoryRanges[Index].BaseAddress, ActualRanges[Index].BaseAddress);
101 UT_ASSERT_EQUAL (ExpectedMemoryRanges[Index].Length, ActualRanges[Index].Length);
102 UT_ASSERT_EQUAL (ExpectedMemoryRanges[Index].Type, ActualRanges[Index].Type);
105 return UNIT_TEST_PASSED;
122 for (Index = 0; Index < RangeCount; Index++) {
123 UT_LOG_INFO (
"\t{ 0x%016llx, 0x%016llx, %a },\n", Ranges[Index].BaseAddress, Ranges[Index].Length, mCacheDescription[Ranges[Index].Type]);
142 IN UINT32 TotalCount,
151 UINT32 TotalMtrrCount;
152 UINT32 *CountPerType[5];
154 CountPerType[0] = UcCount;
155 CountPerType[1] = WtCount;
156 CountPerType[2] = WbCount;
157 CountPerType[3] = WpCount;
158 CountPerType[4] = WcCount;
163 for (Index = 0; Index <
ARRAY_SIZE (CountPerType); Index++) {
164 *(CountPerType[Index]) = 0;
170 TotalMtrrCount =
Random32 (1, TotalCount);
171 for (Index = 0; Index < TotalMtrrCount; Index++) {
197 RETURN_STATUS Status;
210 MTRR_MEMORY_RANGE ExpectedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR *
sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
211 UINT32 ExpectedVariableMtrrUsage;
212 UINTN ExpectedMemoryRangesCount;
214 MTRR_MEMORY_RANGE ActualMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR *
sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
215 UINT32 ActualVariableMtrrUsage;
216 UINTN ActualMemoryRangesCount;
218 MTRR_MEMORY_RANGE ReturnedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR *
sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
219 UINTN ReturnedMemoryRangesCount;
225 SystemParameter->VariableMtrrCount -
PatchPcdGet32 (PcdCpuNumberOfReservedVariableMtrrs),
233 SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits,
242 ExpectedVariableMtrrUsage = UcCount + WtCount + WbCount + WpCount + WcCount;
243 ExpectedMemoryRangesCount =
ARRAY_SIZE (ExpectedMemoryRanges);
245 SystemParameter->DefaultCacheType,
246 SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits,
248 ExpectedVariableMtrrUsage,
249 ExpectedMemoryRanges,
250 &ExpectedMemoryRangesCount
254 "Total MTRR [%d]: UC=%d, WT=%d, WB=%d, WP=%d, WC=%d\n",
255 ExpectedVariableMtrrUsage,
262 UT_LOG_INFO (
"--- Expected Memory Ranges [%d] ---\n", ExpectedMemoryRangesCount);
268 ZeroMem (&LocalMtrrs,
sizeof (LocalMtrrs));
270 ScratchSize = SCRATCH_BUFFER_SIZE;
271 Mtrrs[0] = &LocalMtrrs;
274 for (MtrrIndex = 0; MtrrIndex <
ARRAY_SIZE (Mtrrs); MtrrIndex++) {
275 Scratch = calloc (ScratchSize,
sizeof (UINT8));
278 Scratch = realloc (Scratch, ScratchSize);
284 if (Mtrrs[MtrrIndex] ==
NULL) {
285 ZeroMem (&LocalMtrrs,
sizeof (LocalMtrrs));
289 ActualMemoryRangesCount =
ARRAY_SIZE (ActualMemoryRanges);
291 SystemParameter->DefaultCacheType,
292 SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits,
293 SystemParameter->VariableMtrrCount,
296 &ActualMemoryRangesCount,
297 &ActualVariableMtrrUsage
300 UT_LOG_INFO (
"--- Actual Memory Ranges [%d] ---\n", ActualMemoryRangesCount);
302 VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, ActualMemoryRanges, ActualMemoryRangesCount);
303 UT_ASSERT_TRUE (ExpectedVariableMtrrUsage >= ActualVariableMtrrUsage);
305 ReturnedMemoryRangesCount =
ARRAY_SIZE (ReturnedMemoryRanges);
308 ReturnedMemoryRanges,
309 &ReturnedMemoryRangesCount
312 UT_LOG_INFO (
"--- Returned Memory Ranges [%d] ---\n", ReturnedMemoryRangesCount);
314 VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, ReturnedMemoryRanges, ReturnedMemoryRangesCount);
316 ZeroMem (&LocalMtrrs,
sizeof (LocalMtrrs));
321 return UNIT_TEST_PASSED;
344 RETURN_STATUS Status;
350 MaxAddress = 1ull << (SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits);
352 for (Index = 0; Index < RangeCount; Index++) {
354 BaseAddress =
Random64 (0, MaxAddress);
355 Length =
Random64 (1, MaxAddress - BaseAddress);
356 }
while (((BaseAddress & 0xFFF) == 0) || ((Length & 0xFFF) == 0));
358 Ranges[Index].BaseAddress = BaseAddress;
359 Ranges[Index].Length = Length;
363 Ranges[Index].BaseAddress,
364 Ranges[Index].Length,
374 return UNIT_TEST_PASSED;
398 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
402 SystemParameter.MtrrSupported =
FALSE;
409 SystemParameter.MtrrSupported =
TRUE;
410 SystemParameter.VariableMtrrCount = 0;
411 SystemParameter.FixedMtrrSupported =
FALSE;
418 SystemParameter.MtrrSupported =
TRUE;
419 SystemParameter.VariableMtrrCount = 0;
420 SystemParameter.FixedMtrrSupported =
TRUE;
427 SystemParameter.MtrrSupported =
TRUE;
428 SystemParameter.VariableMtrrCount = 7;
429 SystemParameter.FixedMtrrSupported =
FALSE;
436 SystemParameter.MtrrSupported =
TRUE;
437 SystemParameter.VariableMtrrCount = 7;
438 SystemParameter.FixedMtrrSupported =
TRUE;
442 return UNIT_TEST_PASSED;
467 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
471 SystemParameter.MtrrSupported =
FALSE;
472 for (SystemParameter.VariableMtrrCount = 1; SystemParameter.VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR; SystemParameter.VariableMtrrCount++) {
483 SystemParameter.MtrrSupported =
TRUE;
484 for (SystemParameter.VariableMtrrCount = 1; SystemParameter.VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR; SystemParameter.VariableMtrrCount++) {
493 SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
497 SystemParameter.MtrrSupported =
TRUE;
498 SystemParameter.VariableMtrrCount = MAX_UINT8;
502 return UNIT_TEST_PASSED;
522 UINT32 ReservedMtrrs;
528 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
534 for (ReservedMtrrs = 0; ReservedMtrrs <= SystemParameter.VariableMtrrCount; ReservedMtrrs++) {
535 PatchPcdSet32 (PcdCpuNumberOfReservedVariableMtrrs, ReservedMtrrs);
537 UT_ASSERT_EQUAL (Result, SystemParameter.VariableMtrrCount - ReservedMtrrs);
543 for (ReservedMtrrs = SystemParameter.VariableMtrrCount + 1; ReservedMtrrs <= 255; ReservedMtrrs++) {
544 PatchPcdSet32 (PcdCpuNumberOfReservedVariableMtrrs, ReservedMtrrs);
552 PatchPcdSet32 (PcdCpuNumberOfReservedVariableMtrrs, MAX_UINT32);
559 SystemParameter.MtrrSupported =
FALSE;
568 SystemParameter.MtrrSupported =
TRUE;
569 SystemParameter.FixedMtrrSupported =
FALSE;
578 SystemParameter.FixedMtrrSupported =
TRUE;
579 SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
583 return UNIT_TEST_PASSED;
602 return UNIT_TEST_PASSED;
633 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
640 for (Index = 0; Index < 100; Index++) {
641 for (MsrIndex = 0; MsrIndex <
ARRAY_SIZE (mFixedMtrrsIndex); MsrIndex++) {
643 for (ByteIndex = 0; ByteIndex <
sizeof (UINT64); ByteIndex++) {
647 ExpectedFixedSettings.Mtrr[MsrIndex] = MsrValue;
659 SystemParameter.MtrrSupported =
FALSE;
662 ZeroMem (&FixedSettings,
sizeof (FixedSettings));
663 ZeroMem (&ExpectedFixedSettings,
sizeof (ExpectedFixedSettings));
666 UT_ASSERT_MEM_EQUAL (&ExpectedFixedSettings, &FixedSettings,
sizeof (ExpectedFixedSettings));
671 SystemParameter.MtrrSupported =
TRUE;
672 SystemParameter.FixedMtrrSupported =
FALSE;
675 ZeroMem (&FixedSettings,
sizeof (FixedSettings));
676 ZeroMem (&ExpectedFixedSettings,
sizeof (ExpectedFixedSettings));
679 UT_ASSERT_MEM_EQUAL (&ExpectedFixedSettings, &FixedSettings,
sizeof (ExpectedFixedSettings));
681 return UNIT_TEST_PASSED;
707 for (Index = 0; Index < SystemParameter->VariableMtrrCount; Index++) {
717 if ((Default.
Bits.
FE == 1) && (SystemParameter->MtrrSupported ==
TRUE)) {
718 for (MsrIndex = 0; MsrIndex <
ARRAY_SIZE (mFixedMtrrsIndex); MsrIndex++) {
720 for (ByteIndex = 0; ByteIndex <
sizeof (UINT64); ByteIndex++) {
724 ExpectedMtrrs->Fixed.Mtrr[MsrIndex] = MsrValue;
755 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
760 SystemParameter.MtrrSupported =
TRUE;
761 SystemParameter.FixedMtrrSupported =
FALSE;
766 ZeroMem (&ExpectedMtrrs,
sizeof (ExpectedMtrrs));
767 ExpectedMtrrs.MtrrDefType = Default.
Uint64;
779 SystemParameter.MtrrSupported =
TRUE;
780 SystemParameter.FixedMtrrSupported =
TRUE;
785 ZeroMem (&ExpectedMtrrs,
sizeof (ExpectedMtrrs));
786 ExpectedMtrrs.MtrrDefType = Default.
Uint64;
795 ZeroMem (&ExpectedMtrrs,
sizeof (ExpectedMtrrs));
796 ZeroMem (&Mtrrs,
sizeof (Mtrrs));
798 SystemParameter.MtrrSupported =
FALSE;
807 SystemParameter.MtrrSupported =
TRUE;
808 SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
812 return UNIT_TEST_PASSED;
839 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
845 ZeroMem (&ExpectedMtrrs,
sizeof (ExpectedMtrrs));
846 ExpectedMtrrs.MtrrDefType = Default.
Uint64;
847 for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
851 for (MsrIndex = 0; MsrIndex <
ARRAY_SIZE (mFixedMtrrsIndex); MsrIndex++) {
853 for (ByteIndex = 0; ByteIndex <
sizeof (UINT64); ByteIndex++) {
857 ExpectedMtrrs.Fixed.Mtrr[MsrIndex] = MsrValue;
863 for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
868 return UNIT_TEST_PASSED;
892 UINT64 ValidMtrrBitsMask;
893 UINT64 ValidMtrrAddressMask;
900 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
904 ValidMtrrBitsMask = (1ull << SystemParameter.PhysicalAddressBits) - 1;
905 ValidMtrrAddressMask = ValidMtrrBitsMask & 0xfffffffffffff000ULL;
907 for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
916 for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
917 Base.
Uint64 = VariableMtrr[Index].BaseAddress;
918 Base.
Bits.
Type = (UINT32)VariableMtrr[Index].Type;
921 Mask.Uint64 = ~(VariableMtrr[Index].Length - 1) & ValidMtrrBitsMask;
929 SystemParameter.MtrrSupported =
FALSE;
937 SystemParameter.MtrrSupported =
TRUE;
938 SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
942 return UNIT_TEST_PASSED;
961 return UNIT_TEST_PASSED;
982 MTRR_MEMORY_CACHE_TYPE Result;
984 MTRR_MEMORY_CACHE_TYPE CacheType[5];
986 CacheType[0] = CacheUncacheable;
987 CacheType[1] = CacheWriteCombining;
988 CacheType[2] = CacheWriteThrough;
989 CacheType[3] = CacheWriteProtected;
990 CacheType[4] = CacheWriteBack;
994 CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
999 for (Index = 0; Index <
ARRAY_SIZE (CacheType); Index++) {
1000 SystemParameter.DefaultCacheType = CacheType[Index];
1009 SystemParameter.MtrrSupported =
FALSE;
1017 SystemParameter.MtrrSupported =
TRUE;
1018 SystemParameter.FixedMtrrSupported =
FALSE;
1026 SystemParameter.MtrrSupported =
TRUE;
1027 SystemParameter.FixedMtrrSupported =
TRUE;
1028 SystemParameter.VariableMtrrCount = 0;
1033 return UNIT_TEST_PASSED;
1054 RETURN_STATUS Status;
1066 MTRR_MEMORY_RANGE ExpectedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR *
sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
1067 UINT32 ExpectedVariableMtrrUsage;
1068 UINTN ExpectedMemoryRangesCount;
1070 MTRR_MEMORY_RANGE ActualMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR *
sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
1071 UINT32 ActualVariableMtrrUsage;
1072 UINTN ActualMemoryRangesCount;
1074 MTRR_MEMORY_RANGE ReturnedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR *
sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
1075 UINTN ReturnedMemoryRangesCount;
1081 SystemParameter->VariableMtrrCount -
PatchPcdGet32 (PcdCpuNumberOfReservedVariableMtrrs),
1089 SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits,
1098 ExpectedVariableMtrrUsage = UcCount + WtCount + WbCount + WpCount + WcCount;
1099 ExpectedMemoryRangesCount =
ARRAY_SIZE (ExpectedMemoryRanges);
1101 SystemParameter->DefaultCacheType,
1102 SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits,
1104 ExpectedVariableMtrrUsage,
1105 ExpectedMemoryRanges,
1106 &ExpectedMemoryRangesCount
1109 UT_LOG_INFO (
"--- Expected Memory Ranges [%d] ---\n", ExpectedMemoryRangesCount);
1114 ZeroMem (&LocalMtrrs,
sizeof (LocalMtrrs));
1116 Mtrrs[0] = &LocalMtrrs;
1119 for (MtrrIndex = 0; MtrrIndex <
ARRAY_SIZE (Mtrrs); MtrrIndex++) {
1120 for (Index = 0; Index < ExpectedMemoryRangesCount; Index++) {
1123 ExpectedMemoryRanges[Index].BaseAddress,
1124 ExpectedMemoryRanges[Index].Length,
1125 ExpectedMemoryRanges[Index].Type
1129 return UNIT_TEST_SKIPPED;
1133 if (Mtrrs[MtrrIndex] ==
NULL) {
1134 ZeroMem (&LocalMtrrs,
sizeof (LocalMtrrs));
1138 ActualMemoryRangesCount =
ARRAY_SIZE (ActualMemoryRanges);
1140 SystemParameter->DefaultCacheType,
1141 SystemParameter->PhysicalAddressBits - SystemParameter->MkTmeKeyidBits,
1142 SystemParameter->VariableMtrrCount,
1145 &ActualMemoryRangesCount,
1146 &ActualVariableMtrrUsage
1148 UT_LOG_INFO (
"--- Actual Memory Ranges [%d] ---\n", ActualMemoryRangesCount);
1150 VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, ActualMemoryRanges, ActualMemoryRangesCount);
1151 UT_ASSERT_TRUE (ExpectedVariableMtrrUsage >= ActualVariableMtrrUsage);
1153 ReturnedMemoryRangesCount =
ARRAY_SIZE (ReturnedMemoryRanges);
1156 ReturnedMemoryRanges,
1157 &ReturnedMemoryRangesCount
1160 UT_LOG_INFO (
"--- Returned Memory Ranges [%d] ---\n", ReturnedMemoryRangesCount);
1162 VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, ReturnedMemoryRanges, ReturnedMemoryRangesCount);
1164 ZeroMem (&LocalMtrrs,
sizeof (LocalMtrrs));
1167 return UNIT_TEST_PASSED;
1184 LocalContext->NumberOfReservedVariableMtrrs =
PatchPcdGet32 (PcdCpuNumberOfReservedVariableMtrrs);
1185 return UNIT_TEST_PASSED;
1202 PatchPcdSet32 (PcdCpuNumberOfReservedVariableMtrrs, LocalContext->NumberOfReservedVariableMtrrs);
1224 UNIT_TEST_FRAMEWORK_HANDLE Framework;
1225 UNIT_TEST_SUITE_HANDLE MtrrApiTests;
1231 Context.SystemParameter = &mDefaultSystemParameter;
1232 GetFirmwareVariableMtrrCountContext.SystemParameter = &mDefaultSystemParameter;
1238 Status =
InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
1239 if (EFI_ERROR (Status)) {
1240 DEBUG ((DEBUG_ERROR,
"Failed in InitUnitTestFramework. Status = %r\n", Status));
1252 if (EFI_ERROR (Status)) {
1253 DEBUG ((DEBUG_ERROR,
"Failed in CreateUnitTestSuite for MtrrLib API Tests\n"));
1254 Status = EFI_OUT_OF_RESOURCES;
1269 for (SystemIndex = 0; SystemIndex <
ARRAY_SIZE (mSystemParameters); SystemIndex++) {
1270 for (Index = 0; Index < Iteration; Index++) {
1283 if (Framework !=
NULL) {
1306 DEBUG ((DEBUG_INFO,
"%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
1307 srand ((
unsigned int)time (
NULL));
1312 if ((Argc == 4) && (
AsciiStriCmp (
"generate-random-numbers", Argv[1]) == 0)) {
1313 Count = atoi (Argv[3]);
1314 DEBUG ((DEBUG_INFO,
"Generate %d random numbers to %a.\n", Count, Argv[2]));
1326 mRandomInput =
FALSE;
1327 if ((Argc == 2) || (Argc == 3)) {
1328 Count = atoi (Argv[1]);
1331 mRandomInput =
FALSE;
1333 mRandomInput =
TRUE;
1338 DEBUG ((DEBUG_INFO,
"Iterations = %d\n", Count));
1339 DEBUG ((DEBUG_INFO,
"Input = %a\n", mRandomInput ?
"random" :
"fixed"));
INTN EFIAPI AsciiStriCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
int main()
=== TEST ENGINE ================================================================================
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
UINT64 EFIAPI AsmWriteMsr64(IN UINT32 Index, IN UINT64 Value)
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_ERROR(StatusCode)
#define RETURN_OUT_OF_RESOURCES
#define ARRAY_SIZE(Array)
#define DEBUG(Expression)
#define MSR_IA32_MTRR_PHYSBASE0
#define MSR_IA32_MTRR_FIX4K_E0000
#define MSR_IA32_MTRR_DEF_TYPE
#define MSR_IA32_MTRR_FIX4K_C8000
#define MSR_IA32_MTRR_FIX4K_E8000
#define MSR_IA32_MTRR_FIX4K_F8000
#define MSR_IA32_MTRR_FIX16K_80000
#define MSR_IA32_MTRR_FIX16K_A0000
#define MSR_IA32_MTRR_FIX4K_D0000
#define MSR_IA32_MTRR_PHYSMASK0
#define MSR_IA32_MTRR_FIX64K_00000
#define MSR_IA32_MTRR_FIX4K_D8000
#define MSR_IA32_MTRR_FIX4K_C0000
#define MSR_IA32_MTRR_FIX4K_F0000
UINT32 EFIAPI MtrrGetMemoryAttributeInVariableMtrr(IN UINT64 MtrrValidBitsMask, IN UINT64 MtrrValidAddressMask, OUT VARIABLE_MTRR *VariableMtrr)
MTRR_SETTINGS *EFIAPI MtrrSetAllMtrrs(IN MTRR_SETTINGS *MtrrSetting)
RETURN_STATUS EFIAPI MtrrGetMemoryAttributesInMtrrSettings(IN CONST MTRR_SETTINGS *MtrrSetting OPTIONAL, OUT MTRR_MEMORY_RANGE *Ranges, IN OUT UINTN *RangeCount)
RETURN_STATUS EFIAPI MtrrSetMemoryAttributeInMtrrSettings(IN OUT MTRR_SETTINGS *MtrrSetting, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN MTRR_MEMORY_CACHE_TYPE Attribute)
UINT32 EFIAPI GetVariableMtrrCount(VOID)
UINT32 EFIAPI GetFirmwareVariableMtrrCount(VOID)
BOOLEAN EFIAPI IsMtrrSupported(VOID)
RETURN_STATUS EFIAPI MtrrSetMemoryAttribute(IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN MTRR_MEMORY_CACHE_TYPE Attribute)
MTRR_FIXED_SETTINGS *EFIAPI MtrrGetFixedMtrr(OUT MTRR_FIXED_SETTINGS *FixedSettings)
MTRR_MEMORY_CACHE_TYPE EFIAPI MtrrGetDefaultMemoryType(VOID)
RETURN_STATUS EFIAPI MtrrSetMemoryAttributesInMtrrSettings(IN OUT MTRR_SETTINGS *MtrrSetting, IN VOID *Scratch, IN OUT UINTN *ScratchSize, IN CONST MTRR_MEMORY_RANGE *Ranges, IN UINTN RangeCount)
MTRR_SETTINGS *EFIAPI MtrrGetAllMtrrs(OUT MTRR_SETTINGS *MtrrSetting)
UNIT_TEST_STATUS EFIAPI UnitTestIsMtrrSupported(IN UNIT_TEST_CONTEXT Context)
VOID SetRandomlyGeneratedMtrrSettings(IN MTRR_LIB_SYSTEM_PARAMETER *SystemParameter, IN MTRR_SETTINGS *ExpectedMtrrs)
UNIT_TEST_STATUS VerifyMemoryRanges(IN MTRR_MEMORY_RANGE *ExpectedMemoryRanges, IN UINTN ExpectedMemoryRangeCount, IN MTRR_MEMORY_RANGE *ActualRanges, IN UINTN ActualRangeCount)
VOID DumpMemoryRanges(MTRR_MEMORY_RANGE *Ranges, UINTN RangeCount)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrGetMemoryAttributeInVariableMtrr(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrGetAllMtrrs(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrDebugPrintAllMtrrs(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestGetFirmwareVariableMtrrCount(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrSetAllMtrrs(IN UNIT_TEST_CONTEXT Context)
STATIC EFI_STATUS EFIAPI UnitTestingEntry(UINTN Iteration)
VOID GenerateRandomMemoryTypeCombination(IN UINT32 TotalCount, OUT UINT32 *UcCount, OUT UINT32 *WtCount, OUT UINT32 *WbCount, OUT UINT32 *WpCount, OUT UINT32 *WcCount)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrGetFixedMtrr(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrSetMemoryAttributeAndGetMemoryAttributesInMtrrSettings(IN UNIT_TEST_CONTEXT Context)
VOID EFIAPI RestorePcdValue(UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrSetAndGetMemoryAttributesInMtrrSettings(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrGetMemoryAttribute(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI SavePcdValue(UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestMtrrGetDefaultMemoryType(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestGetVariableMtrrCount(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI UnitTestInvalidMemoryLayouts(IN UNIT_TEST_CONTEXT Context)
VOID CollectTestResult(IN MTRR_MEMORY_CACHE_TYPE DefaultType, IN UINT32 PhysicalAddressBits, IN UINT32 VariableMtrrCount, IN MTRR_SETTINGS *Mtrrs, OUT MTRR_MEMORY_RANGE *Ranges, IN OUT UINTN *RangeCount, OUT UINT32 *MtrrCount)
VOID GenerateValidAndConfigurableMtrrPairs(IN UINT32 PhysicalAddressBits, IN OUT MTRR_MEMORY_RANGE *RawMemoryRanges, IN UINT32 UcCount, IN UINT32 WtCount, IN UINT32 WbCount, IN UINT32 WpCount, IN UINT32 WcCount)
VOID GenerateRandomNumbers(CHAR8 *FilePath, UINTN Count)
UNIT_TEST_STATUS EFIAPI InitializeMtrrRegs(IN MTRR_LIB_SYSTEM_PARAMETER *SystemParameter)
MTRR_MEMORY_CACHE_TYPE GenerateRandomCacheType(VOID)
UNIT_TEST_STATUS EFIAPI InitializeSystem(IN UNIT_TEST_CONTEXT Context)
VOID GetEffectiveMemoryRanges(IN MTRR_MEMORY_CACHE_TYPE DefaultType, IN UINT32 PhysicalAddressBits, IN MTRR_MEMORY_RANGE *RawMemoryRanges, IN UINT32 RawMemoryRangeCount, OUT MTRR_MEMORY_RANGE *MemoryRanges, OUT UINTN *MemoryRangeCount)
VOID GenerateRandomMtrrPair(IN UINT32 PhysicalAddressBits, IN MTRR_MEMORY_CACHE_TYPE CacheType, OUT MTRR_VARIABLE_SETTING *MtrrPair OPTIONAL, OUT MTRR_MEMORY_RANGE *MtrrMemoryRange OPTIONAL)
#define PatchPcdSet32(TokenName, Value)
#define PatchPcdGet32(TokenName)
UINT64 Random64(UINT64 Start, UINT64 Limit)
UINT32 Random32(UINT32 Start, UINT32 Limit)
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
#define UT_EXPECT_ASSERT_FAILURE(FunctionCall, Status)
#define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
#define UT_ASSERT_TRUE(Expression)
#define UT_ASSERT_EQUAL(ValueA, ValueB)
#define UT_ASSERT_STATUS_EQUAL(Status, Expected)
#define UT_LOG_INFO(Format,...)
EFI_STATUS EFIAPI CreateUnitTestSuite(OUT UNIT_TEST_SUITE_HANDLE *SuiteHandle, IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *Name, IN UNIT_TEST_SUITE_SETUP Setup OPTIONAL, IN UNIT_TEST_SUITE_TEARDOWN Teardown OPTIONAL)
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
EFI_STATUS EFIAPI AddTestCase(IN UNIT_TEST_SUITE_HANDLE SuiteHandle, IN CHAR8 *Description, IN CHAR8 *Name, IN UNIT_TEST_FUNCTION Function, IN UNIT_TEST_PREREQUISITE Prerequisite OPTIONAL, IN UNIT_TEST_CLEANUP CleanUp OPTIONAL, IN UNIT_TEST_CONTEXT Context OPTIONAL)
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
#define UT_ASSERT_FALSE(Expression)
struct MSR_IA32_MTRR_DEF_TYPE_REGISTER::@653 Bits
struct MSR_IA32_MTRR_PHYSBASE_REGISTER::@649 Bits