12UINTN RandomNumber = 0;
18extern UINTN mNumberCount;
19extern UINT8 mNumbers[];
21UINT64 AlignedTable[] = {
22 ~((UINT64)SIZE_4KB - 1),
23 ~((UINT64)SIZE_2MB - 1),
24 ~((UINT64)SIZE_1GB - 1)
47 for (Index = 0; Index < Size; Index++) {
48 if (mNumberIndex >= mNumberCount) {
52 Output[Index] = mNumbers[mNumberIndex];
77 if (mRandomOption & USE_RANDOM_ARRAY) {
100 return (UINT32)(Value % (Limit - Start + 1)) + Start;
119 if (Limit - Start == MAX_UINT64) {
120 return (UINT64)(Value);
123 return (UINT64)(Value % (Limit - Start + 1)) + Start;
149 UINT64 Buffer[SIZE_1KB];
152 for (Index = 0; Index < SIZE_1KB; Index++) {
153 Buffer[Index] =
Random64 (0, MAX_UINT64);
154 Buffer[Index] = Buffer[Index];
177 UINT32 PageTableBaseAddressLow;
178 UINT32 PageTableBaseAddressHigh;
182 if (PagingEntry->Pce.Present == 0) {
183 return UNIT_TEST_PASSED;
186 if ((PagingEntry->Uint64 & mValidMaskLeafFlag[Level].Uint64) == mValidMaskLeafFlag[Level].Uint64) {
190 if (Level > MaxLeafLevel) {
194 if ((PagingEntry->Uint64 & mValidMaskLeaf[Level].Uint64) != PagingEntry->Uint64) {
195 UT_ASSERT_EQUAL ((PagingEntry->Uint64 & mValidMaskLeaf[Level].Uint64), PagingEntry->Uint64);
201 PageTableBaseAddressLow = PagingEntry->Pte4K.Bits.PageTableBaseAddressLow;
202 PageTableBaseAddressHigh = PagingEntry->Pte4K.Bits.PageTableBaseAddressHigh;
204 PageTableBaseAddressLow = PagingEntry->PleB.Bits.PageTableBaseAddressLow;
205 PageTableBaseAddressHigh = PagingEntry->PleB.Bits.PageTableBaseAddressHigh;
208 PagingEntry->Uint64 = (
Random64 (0, MAX_UINT64) & mValidMaskLeaf[Level].Uint64) | mValidMaskLeafFlag[Level].Uint64;
209 PagingEntry->Pte4K.Bits.Present = 1;
211 PagingEntry->Pte4K.Bits.PageTableBaseAddressLow = PageTableBaseAddressLow;
212 PagingEntry->Pte4K.Bits.PageTableBaseAddressHigh = PageTableBaseAddressHigh;
214 PagingEntry->PleB.Bits.PageTableBaseAddressLow = PageTableBaseAddressLow;
215 PagingEntry->PleB.Bits.PageTableBaseAddressHigh = PageTableBaseAddressHigh;
218 if ((PagingEntry->Uint64 & mValidMaskLeaf[Level].Uint64) != PagingEntry->Uint64) {
219 UT_ASSERT_EQUAL ((PagingEntry->Uint64 & mValidMaskLeaf[Level].Uint64), PagingEntry->Uint64);
223 return UNIT_TEST_PASSED;
230 if ((PagingEntry->Uint64 & mValidMaskNoLeaf[Level].Uint64) != PagingEntry->Uint64) {
231 DEBUG ((DEBUG_ERROR,
"ERROR: Level %d no Leaf entry is 0x%lx, which reserved bit is set \n", Level, PagingEntry->Uint64));
232 UT_ASSERT_EQUAL ((PagingEntry->Uint64 & mValidMaskNoLeaf[Level].Uint64), PagingEntry->Uint64);
237 PageTableBaseAddressLow = PagingEntry->PleB.Bits.PageTableBaseAddressLow;
238 PageTableBaseAddressHigh = PagingEntry->PleB.Bits.PageTableBaseAddressHigh;
240 PagingEntry->Uint64 =
Random64 (0, MAX_UINT64) & mValidMaskNoLeaf[Level].Uint64;
241 PagingEntry->Pnle.Bits.Present = 1;
242 PagingEntry->PleB.Bits.PageTableBaseAddressLow = PageTableBaseAddressLow;
243 PagingEntry->PleB.Bits.PageTableBaseAddressHigh = PageTableBaseAddressHigh;
244 ASSERT ((PagingEntry->Uint64 & mValidMaskLeafFlag[Level].Uint64) != mValidMaskLeafFlag[Level].Uint64);
248 for (Index = 0; Index < 512; Index++) {
250 if (Status != UNIT_TEST_PASSED) {
255 return UNIT_TEST_PASSED;
269 IN PAGING_MODE PagingMode
278 if ((PagingMode == Paging32bit) || (PagingMode >= PagingModeMax)) {
282 return UNIT_TEST_ERROR_TEST_FAILED;
285 MaxLeafLevel = (UINT8)PagingMode;
286 MaxLevel = (UINT8)(PagingMode >> 8);
289 for (Index = 0; Index < 512; Index++) {
291 if (Status != UNIT_TEST_PASSED) {
311 if (MapEntrys->Count == 0) {
315 MapsIndex = MapEntrys->Count - 1;
317 MapEntrys->Count = MapsIndex;
330 IN UINT64 MaxAddress,
335 UINT64 FormerLinearAddress;
336 UINT64 FormerLinearAddressBottom;
337 UINT64 FormerLinearAddressTop;
339 MapsIndex = MapEntrys->Count;
341 ASSERT (MapsIndex < MapEntrys->MaxCount);
346 FormerLinearAddress = MapEntrys->Maps[
Random32 (0, (UINT32)MapsIndex-1)].LinearAddress;
347 if (FormerLinearAddress < 2 * (UINT64)SIZE_1GB) {
348 FormerLinearAddressBottom = 0;
350 FormerLinearAddressBottom = FormerLinearAddress - 2 * (UINT64)SIZE_1GB;
353 if (FormerLinearAddress + 2 * (UINT64)SIZE_1GB > MaxAddress) {
354 FormerLinearAddressTop = MaxAddress;
356 FormerLinearAddressTop = FormerLinearAddress + 2 * (UINT64)SIZE_1GB;
359 MapEntrys->Maps[MapsIndex].LinearAddress =
Random64 (FormerLinearAddressBottom, FormerLinearAddressTop) & AlignedTable[
Random32 (0,
ARRAY_SIZE (AlignedTable) -1)];
361 MapEntrys->Maps[MapsIndex].LinearAddress =
Random64 (0, MaxAddress) & AlignedTable[
Random32 (0,
ARRAY_SIZE (AlignedTable) -1)];
367 MapEntrys->Maps[MapsIndex].Length =
Random64 (0,
MIN (MaxAddress - MapEntrys->Maps[MapsIndex].LinearAddress, 10 * (UINT64)SIZE_1GB)) & AlignedTable[
Random32 (0,
ARRAY_SIZE (AlignedTable) -1)];
370 MapEntrys->Maps[MapsIndex].Attribute.Uint64 = MapEntrys->Maps[
Random32 (0, (UINT32)MapsIndex-1)].Attribute.Uint64;
371 MapEntrys->Maps[MapsIndex].Mask.Uint64 = MapEntrys->Maps[
Random32 (0, (UINT32)MapsIndex-1)].Mask.Uint64;
373 MapEntrys->Maps[MapsIndex].Attribute.Uint64 =
Random64 (0, MAX_UINT64) & mSupportedBit.Uint64;
379 MapEntrys->Maps[MapsIndex].Mask.Uint64 =
Random64 (0, MAX_UINT64) & mSupportedBit.Uint64;
381 MapEntrys->Maps[MapsIndex].Mask.Uint64 = MAX_UINT64;
384 if (MapEntrys->Maps[MapsIndex].Mask.Bits.ProtectionKey != 0) {
385 MapEntrys->Maps[MapsIndex].Mask.Bits.ProtectionKey = 0xF;
389 if (mRandomOption & ONLY_ONE_ONE_MAPPING) {
390 MapEntrys->Maps[MapsIndex].Attribute.Uint64 &= (~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK);
391 MapEntrys->Maps[MapsIndex].Attribute.Uint64 |= MapEntrys->Maps[MapsIndex].LinearAddress;
392 MapEntrys->Maps[MapsIndex].Mask.Uint64 |= IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK;
394 MapEntrys->Maps[MapsIndex].Attribute.Uint64 &= (~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK);
395 MapEntrys->Maps[MapsIndex].Attribute.Uint64 |= (
Random64 (0, (((UINT64)1)<<52) - 1) & AlignedTable[
Random32 (0,
ARRAY_SIZE (AlignedTable) -1)]);
398 MapEntrys->Count += 1;
433 AttributeInMap.Uint64 = 0;
434 AttributeInMapEntrys.Uint64 = 0;
435 AttributeInInitMap.Uint64 = 0;
436 MaskInMapEntrys.Uint64 = 0;
440 for (Index = 0; Index < MapCount; Index++) {
441 if ((Address >= Map[Index].LinearAddress) && (Address < (Map[Index].LinearAddress + Map[Index].Length))) {
442 AttributeInMap.Uint64 = (Map[Index].Attribute.Uint64 & mSupportedBit.Uint64);
443 AttributeInMap.Uint64 &= (~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK);
444 AttributeInMap.Uint64 |= (Address - Map[Index].LinearAddress + IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&Map[Index].Attribute)) & IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK;
452 for (Index = 0; Index < InitMapCount; Index++) {
453 if ((Address >= InitMap[Index].LinearAddress) && (Address < (InitMap[Index].LinearAddress + InitMap[Index].Length))) {
454 AttributeInInitMap.Uint64 = (InitMap[Index].Attribute.Uint64 & mSupportedBit.Uint64);
455 AttributeInInitMap.Uint64 &= (~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK);
456 AttributeInInitMap.Uint64 |= (Address - InitMap[Index].LinearAddress + IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&InitMap[Index].Attribute)) & IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK;
462 AttributeInMapEntrys.Uint64 = AttributeInInitMap.Uint64;
464 for (Index = MapEntrys->InitCount; Index < MapEntrys->Count; Index++) {
465 if ((Address >= MapEntrys->Maps[Index].LinearAddress) && (Address < (MapEntrys->Maps[Index].LinearAddress + MapEntrys->Maps[Index].Length))) {
466 if (AttributeInMapEntrys.Bits.Present == 0) {
467 AttributeInMapEntrys.Uint64 = 0;
468 MaskInMapEntrys.Uint64 = 0;
471 MaskInMapEntrys.Uint64 |= MapEntrys->Maps[Index].Mask.Uint64;
472 AttributeInMapEntrys.Uint64 &= (~MapEntrys->Maps[Index].Mask.Uint64);
473 AttributeInMapEntrys.Uint64 |= (MapEntrys->Maps[Index].Attribute.Uint64 & MapEntrys->Maps[Index].Mask.Uint64);
474 if (IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&MapEntrys->Maps[Index].Mask) != 0) {
475 AttributeInMapEntrys.Uint64 &= (~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK);
476 AttributeInMapEntrys.Uint64 |= (Address - MapEntrys->Maps[Index].LinearAddress + IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&MapEntrys->Maps[Index].Attribute)) & IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK;
481 if (AttributeInMap.Bits.Present == 0) {
482 if (AttributeInMapEntrys.Bits.Present == 0) {
487 if ((AttributeInMap.Uint64 & MaskInMapEntrys.Uint64) != (AttributeInMapEntrys.Uint64 & MaskInMapEntrys.Uint64)) {
488 DEBUG ((DEBUG_INFO,
"======detailed information begin=====\n"));
489 DEBUG ((DEBUG_INFO,
"\nError: Detect different attribute on a point with linear address: 0x%lx\n", Address));
490 DEBUG ((DEBUG_INFO,
"By parsing page table, the point has Attribute 0x%lx, and map to physical address 0x%lx\n", IA32_MAP_ATTRIBUTE_ATTRIBUTES (&AttributeInMap) & MaskInMapEntrys.Uint64, IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&AttributeInMap)));
491 DEBUG ((DEBUG_INFO,
"While according to inputs, the point should Attribute 0x%lx, and should map to physical address 0x%lx\n", IA32_MAP_ATTRIBUTE_ATTRIBUTES (&AttributeInMapEntrys) & MaskInMapEntrys.Uint64, IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&AttributeInMapEntrys)));
492 DEBUG ((DEBUG_INFO,
"The total Mask is 0x%lx\n", MaskInMapEntrys.Uint64));
494 if (MapEntrys->InitCount != 0) {
495 DEBUG ((DEBUG_INFO,
"Below is the initialization status:\n"));
496 for (Index = 0; Index < InitMapCount; Index++) {
497 if ((Address >= InitMap[Index].LinearAddress) && (Address < (InitMap[Index].LinearAddress + InitMap[Index].Length))) {
498 DEBUG ((DEBUG_INFO,
" *"));
500 DEBUG ((DEBUG_INFO,
" "));
503 DEBUG ((DEBUG_INFO,
" %02d: {0x%lx, 0x%lx, 0x%lx}\n", Index, InitMap[Index].LinearAddress, InitMap[Index].LinearAddress + InitMap[Index].Length, InitMap[Index].Attribute.Uint64));
507 DEBUG ((DEBUG_INFO,
"Below is the inputs:\n"));
508 DEBUG ((DEBUG_INFO,
" Index: {LinearAddress, LinearLimit, Mask, Attribute}\n"));
509 for (Index = MapEntrys->InitCount; Index < MapEntrys->Count; Index++) {
510 if ((Address >= MapEntrys->Maps[Index].LinearAddress) && (Address < (MapEntrys->Maps[Index].LinearAddress + MapEntrys->Maps[Index].Length))) {
511 DEBUG ((DEBUG_INFO,
" *"));
513 DEBUG ((DEBUG_INFO,
" "));
518 " %02d: {0x%lx, 0x%lx, 0x%lx,0x%lx}\n",
520 MapEntrys->Maps[Index].LinearAddress,
521 MapEntrys->Maps[Index].LinearAddress + MapEntrys->Maps[Index].Length,
522 MapEntrys->Maps[Index].Mask.Uint64,
523 MapEntrys->Maps[Index].Attribute.Uint64
527 DEBUG ((DEBUG_INFO,
"Below is the dumped from pagetable:\n"));
528 for (Index = 0; Index < MapCount; Index++) {
529 if ((Address >= Map[Index].LinearAddress) && (Address < (Map[Index].LinearAddress + Map[Index].Length))) {
530 DEBUG ((DEBUG_INFO,
" *"));
532 DEBUG ((DEBUG_INFO,
" "));
535 DEBUG ((DEBUG_INFO,
"%02d: {0x%lx, 0x%lx, 0x%lx}\n", Index, Map[Index].LinearAddress, Map[Index].LinearAddress + Map[Index].Length, Map[Index].Attribute.Uint64));
538 DEBUG ((DEBUG_INFO,
"======detailed information done=====\n"));
555 IN OUT UINT64 *Buffer,
560 if ( Buffer !=
NULL) {
561 Buffer[*Count] = Address;
563 Buffer[*Count] = Address+1;
565 Buffer[*Count] = Address-1;
568 (*Count) = (*Count) +3;
587 IN OUT UINT64 *Buffer,
597 for (Index1 = 0; Index1 < MapEntrys->Count; Index1++) {
599 AppendKeyPointToBuffer (Buffer, &TemCount, MapEntrys->Maps[Index1].LinearAddress + MapEntrys->Maps[Index1].Length);
602 for (Index2 = 0; Index2 < MapCount; Index2++) {
603 if (Buffer !=
NULL) {
604 for (Index1 = 0; Index1 < TemCount; Index1++) {
605 if (Buffer[Index1] == Map[Index2].LinearAddress) {
610 if (Index1 < TemCount) {
618 for (Index2 = 0; Index2 < MapCount; Index2++) {
619 if (Buffer !=
NULL) {
620 for (Index1 = 0; Index1 < TemCount; Index1++) {
621 if (Buffer[Index1] == (Map[Index2].LinearAddress + Map[Index2].Length)) {
626 if (Index1 < TemCount) {
654 IN PAGING_MODE PagingMode,
655 IN UINT64 MaxAddress,
663 RETURN_STATUS Status;
664 UINTN PageTableBufferSize;
672 UINTN NewKeyPointCount;
673 UINT64 *KeyPointBuffer;
680 UINT64 LastNotPresentRegionStart;
681 BOOLEAN IsNotPresent;
684 MapsIndex = MapEntrys->Count;
686 LastNotPresentRegionStart = 0;
687 IsNotPresent =
FALSE;
692 LastMapEntry = &MapEntrys->Maps[MapsIndex];
698 ASSERT (Map !=
NULL);
705 if (LastMapEntry->Length > 0) {
706 for (Index = 0; Index < MapCount; Index++) {
707 if ((LastNotPresentRegionStart < Map[Index].LinearAddress) &&
708 (LastMapEntry->LinearAddress < Map[Index].LinearAddress) && (LastMapEntry->LinearAddress + LastMapEntry->Length > LastNotPresentRegionStart))
716 LastNotPresentRegionStart = Map[Index].LinearAddress + Map[Index].Length;
722 if (LastNotPresentRegionStart < LastMapEntry->LinearAddress + LastMapEntry->Length) {
727 PageTableBufferSize = 0;
732 &PageTableBufferSize,
733 LastMapEntry->LinearAddress,
734 LastMapEntry->Length,
735 &LastMapEntry->Attribute,
740 Attribute = &LastMapEntry->Attribute;
741 Mask = &LastMapEntry->Mask;
746 if ((LastMapEntry->Length > 0) && (Attribute->Bits.Present == 0) && (Mask->Bits.Present == 1) && (Mask->Uint64 > 1)) {
749 return UNIT_TEST_PASSED;
758 if ((Mask->Bits.Present == 1) && (Attribute->Bits.Present == 1)) {
762 if ((Mask->Bits.ReadWrite == 0) || (Mask->Bits.UserSupervisor == 0) || (Mask->Bits.WriteThrough == 0) || (Mask->Bits.CacheDisabled == 0) ||
763 (Mask->Bits.Accessed == 0) || (Mask->Bits.Dirty == 0) || (Mask->Bits.Pat == 0) || (Mask->Bits.Global == 0) ||
764 ((Mask->Bits.PageTableBaseAddressLow == 0) && (Mask->Bits.PageTableBaseAddressHigh == 0)) || (Mask->Bits.ProtectionKey == 0) || (Mask->Bits.Nx == 0))
768 return UNIT_TEST_PASSED;
770 }
else if ((Mask->Bits.Present == 0) && (Mask->Uint64 > 1)) {
776 return UNIT_TEST_PASSED;
780 if (PageTableBufferSize != 0) {
787 Buffer = PagesRecord->AllocatePagesForPageTable (PagesRecord,
EFI_SIZE_TO_PAGES (PageTableBufferSize));
793 &PageTableBufferSize,
794 LastMapEntry->LinearAddress,
795 LastMapEntry->Length,
796 &LastMapEntry->Attribute,
808 if (TestStatus != UNIT_TEST_PASSED) {
814 if (MapCount2 != 0) {
822 ASSERT (Map2 !=
NULL);
823 Status =
PageTableParse (*PageTable, PagingMode, Map2, &MapCount2);
829 if (MapCount2 != MapCount) {
848 ASSERT (KeyPointBuffer !=
NULL);
849 NewKeyPointCount = 0;
850 GetKeyPointList (MapEntrys, Map2, MapCount2, KeyPointBuffer, &NewKeyPointCount);
855 for (Index = 0; Index < NewKeyPointCount; Index++) {
857 DEBUG ((DEBUG_INFO,
"Error happens at below key point\n"));
858 DEBUG ((DEBUG_INFO,
"Index = %d KeyPointBuffer[Index] = 0x%lx\n", Index, KeyPointBuffer[Index]));
860 DEBUG ((DEBUG_INFO,
"From Page table, this key point is in level %d entry, with entry value is 0x%lx\n", Level, Value));
870 if (MapCount2 != 0) {
874 return UNIT_TEST_PASSED;
895 if (PagesRecord->Count < PagesRecord->MaxCount) {
897 PagesRecord->Records[PagesRecord->Count].Buffer = Buffer;
898 PagesRecord->Records[PagesRecord->Count].Pages = Pages;
899 PagesRecord->Count++;
902 ASSERT (Buffer !=
NULL);
918 IN PAGING_MODE PagingMode
927 RETURN_STATUS Status;
934 ASSERT (MapEntrys !=
NULL);
935 MapEntrys->Count = 0;
936 MapEntrys->InitCount = 0;
937 MapEntrys->MaxCount = 1000;
939 ASSERT (PagesRecord !=
NULL);
940 PagesRecord->Count = 0;
941 PagesRecord->MaxCount = 1000;
944 if (mRandomOption & MANUAL_CHANGE_PAGE_TABLE) {
945 ExpctedEntryNumber = ExpctedEntryNumber/2;
948 for (Index = 0; Index < ExpctedEntryNumber; Index++) {
958 if (TestStatus != UNIT_TEST_PASSED) {
963 if ((mRandomOption & MANUAL_CHANGE_PAGE_TABLE) != 0) {
964 MapEntrys->InitCount = ExpctedEntryNumber;
967 if (TestStatus != UNIT_TEST_PASSED) {
973 if (InitMapCount != 0) {
981 ASSERT (InitMap !=
NULL);
982 Status =
PageTableParse (PageTable, PagingMode, InitMap, &InitMapCount);
986 for (Index = 0; Index < ExpctedEntryNumber; Index++) {
996 if (TestStatus != UNIT_TEST_PASSED) {
1001 if (InitMapCount != 0) {
1011 for (Index = 0; Index < PagesRecord->Count; Index++) {
1012 FreePages (PagesRecord->Records[Index].Buffer, PagesRecord->Records[Index].Pages);
1017 return UNIT_TEST_PASSED;
1049 mSupportedBit.Uint64 = 0;
1050 mSupportedBit.Bits.Present = 1;
1051 mSupportedBit.Bits.ReadWrite = 1;
1052 mSupportedBit.Bits.UserSupervisor = 1;
1053 mSupportedBit.Bits.WriteThrough = 1;
1054 mSupportedBit.Bits.CacheDisabled = 1;
1055 mSupportedBit.Bits.Accessed = 1;
1056 mSupportedBit.Bits.Dirty = 1;
1057 mSupportedBit.Bits.Pat = 1;
1058 mSupportedBit.Bits.Global = 1;
1059 mSupportedBit.Bits.ProtectionKey = 0xF;
1061 mSupportedBit.Bits.ProtectionKey = 0;
1064 mSupportedBit.Bits.Nx = 1;
1074 if (Status != UNIT_TEST_PASSED) {
1078 DEBUG ((DEBUG_INFO,
"."));
1081 DEBUG ((DEBUG_INFO,
"\n"));
1083 return UNIT_TEST_PASSED;
BOOLEAN EFIAPI RandomBytes(OUT UINT8 *Output, IN UINTN Size)
BOOLEAN EFIAPI RandomSeed(IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
RETURN_STATUS EFIAPI PageTableMap(IN OUT UINTN *PageTable OPTIONAL, IN PAGING_MODE PagingMode, IN VOID *Buffer, IN OUT UINTN *BufferSize, IN UINT64 LinearAddress, IN UINT64 Length, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask, OUT BOOLEAN *IsModified OPTIONAL)
RETURN_STATUS EFIAPI PageTableParse(IN UINTN PageTable, IN PAGING_MODE PagingMode, IN IA32_MAP_ENTRY *Map, IN OUT UINTN *MapCount)
UNIT_TEST_STATUS IsPageTableValid(IN UINTN PageTable, IN PAGING_MODE PagingMode)
UINT64 GetMaxAddress(IN PAGING_MODE Mode)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
#define RETURN_BUFFER_TOO_SMALL
#define ARRAY_SIZE(Array)
#define RETURN_INVALID_PARAMETER
#define DEBUG(Expression)
VOID *EFIAPI AllocatePages(IN UINTN Pages)
UINT64 Random64(UINT64 Start, UINT64 Limit)
VOID SetRandomStack(VOID)
VOID AppendKeyPointToBuffer(IN OUT UINT64 *Buffer, IN OUT UINTN *Count, IN UINT64 Address)
BOOLEAN EFIAPI RandomBytesUsingArray(OUT UINT8 *Output, IN UINTN Size)
UNIT_TEST_STATUS EFIAPI TestCaseforRandomTest(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS ValidateAndRandomeModifyPageTable(IN UINTN PageTable, IN PAGING_MODE PagingMode)
UNIT_TEST_STATUS ValidateAndRandomeModifyPageTablePageTableEntry(IN IA32_PAGING_ENTRY *PagingEntry, IN UINTN Level, IN UINTN MaxLeafLevel, IN UINT64 Address)
BOOLEAN RandomBoolean(UINT8 Probability)
VOID RemoveLastMapEntry(IN OUT MAP_ENTRYS *MapEntrys)
VOID GenerateSingleRandomMapEntry(IN UINT64 MaxAddress, IN OUT MAP_ENTRYS *MapEntrys)
UINT32 Random32(UINT32 Start, UINT32 Limit)
UNIT_TEST_STATUS MultipleMapEntryTest(IN UINTN ExpctedEntryNumber, IN PAGING_MODE PagingMode)
BOOLEAN CompareEntrysforOnePoint(IN UINT64 Address, IN MAP_ENTRYS *MapEntrys, IN IA32_MAP_ENTRY *Map, IN UINTN MapCount, IN IA32_MAP_ENTRY *InitMap, IN UINTN InitMapCount)
VOID GetKeyPointList(IN MAP_ENTRYS *MapEntrys, IN IA32_MAP_ENTRY *Map, IN UINTN MapCount, IN OUT UINT64 *Buffer, IN OUT UINTN *Count)
VOID *EFIAPI RecordAllocatePages(IN ALLOCATE_PAGE_RECORDS *PagesRecord, IN UINTN Pages)
BOOLEAN EFIAPI LocalRandomBytes(OUT UINT8 *Output, IN UINTN Size)
UNIT_TEST_STATUS SingleMapEntryTest(IN OUT UINTN *PageTable, IN PAGING_MODE PagingMode, IN UINT64 MaxAddress, IN MAP_ENTRYS *MapEntrys, IN ALLOCATE_PAGE_RECORDS *PagesRecord, IN IA32_MAP_ENTRY *InitMap, IN UINTN InitMapCount)
UINT64 GetEntryFromPageTable(IN UINTN PageTable, IN PAGING_MODE PagingMode, IN UINT64 Address, OUT UINTN *Level)
#define EFI_SIZE_TO_PAGES(Size)
#define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
#define UT_ASSERT_TRUE(Expression)
#define UT_ASSERT_EQUAL(ValueA, ValueB)