31 MapAttribute.Uint64 = IA32_PLEB_PAGE_TABLE_BASE_ADDRESS (PleB);
33 MapAttribute.Bits.Present = ParentMapAttribute->Bits.Present & PleB->Bits.Present;
34 MapAttribute.Bits.ReadWrite = ParentMapAttribute->Bits.ReadWrite & PleB->Bits.ReadWrite;
35 MapAttribute.Bits.UserSupervisor = ParentMapAttribute->Bits.UserSupervisor & PleB->Bits.UserSupervisor;
36 MapAttribute.Bits.Nx = ParentMapAttribute->Bits.Nx | PleB->Bits.Nx;
37 MapAttribute.Bits.WriteThrough = PleB->Bits.WriteThrough;
38 MapAttribute.Bits.CacheDisabled = PleB->Bits.CacheDisabled;
39 MapAttribute.Bits.Accessed = PleB->Bits.Accessed;
41 MapAttribute.Bits.Pat = PleB->Bits.Pat;
42 MapAttribute.Bits.Dirty = PleB->Bits.Dirty;
43 MapAttribute.Bits.Global = PleB->Bits.Global;
44 MapAttribute.Bits.ProtectionKey = PleB->Bits.ProtectionKey;
46 return MapAttribute.Uint64;
65 MapAttribute.Uint64 = IA32_PTE4K_PAGE_TABLE_BASE_ADDRESS (Pte4K);
67 MapAttribute.Bits.Present = ParentMapAttribute->Bits.Present & Pte4K->Bits.Present;
68 MapAttribute.Bits.ReadWrite = ParentMapAttribute->Bits.ReadWrite & Pte4K->Bits.ReadWrite;
69 MapAttribute.Bits.UserSupervisor = ParentMapAttribute->Bits.UserSupervisor & Pte4K->Bits.UserSupervisor;
70 MapAttribute.Bits.Nx = ParentMapAttribute->Bits.Nx | Pte4K->Bits.Nx;
71 MapAttribute.Bits.WriteThrough = Pte4K->Bits.WriteThrough;
72 MapAttribute.Bits.CacheDisabled = Pte4K->Bits.CacheDisabled;
73 MapAttribute.Bits.Accessed = Pte4K->Bits.Accessed;
75 MapAttribute.Bits.Pat = Pte4K->Bits.Pat;
76 MapAttribute.Bits.Dirty = Pte4K->Bits.Dirty;
77 MapAttribute.Bits.Global = Pte4K->Bits.Global;
78 MapAttribute.Bits.ProtectionKey = Pte4K->Bits.ProtectionKey;
80 return MapAttribute.Uint64;
99 MapAttribute.Uint64 = Pnle->Uint64;
101 MapAttribute.Bits.Present = ParentMapAttribute->Bits.Present & Pnle->Bits.Present;
102 MapAttribute.Bits.ReadWrite = ParentMapAttribute->Bits.ReadWrite & Pnle->Bits.ReadWrite;
103 MapAttribute.Bits.UserSupervisor = ParentMapAttribute->Bits.UserSupervisor & Pnle->Bits.UserSupervisor;
104 MapAttribute.Bits.Nx = ParentMapAttribute->Bits.Nx | Pnle->Bits.Nx;
105 MapAttribute.Bits.WriteThrough = Pnle->Bits.WriteThrough;
106 MapAttribute.Bits.CacheDisabled = Pnle->Bits.CacheDisabled;
107 MapAttribute.Bits.Accessed = Pnle->Bits.Accessed;
108 return MapAttribute.Uint64;
134 if (((Level == 3) || (Level == 2))) {
135 if (PagingEntry->PleB.Bits.MustBeOne == 1) {
159 IN UINT64 PageTableBaseAddress,
162 IN UINT64 RegionStart,
175 UINTN PagingEntryNumber;
177 ASSERT (OneEntry !=
NULL);
180 RegionLength = REGION_LENGTH (Level);
181 PagingEntryNumber = ((MaxLevel == 3) && (Level == 3)) ? MAX_PAE_PDPTE_NUM : 512;
183 for (Index = 0; Index < PagingEntryNumber; Index++, RegionStart += RegionLength) {
184 if (PagingEntry[Index].Pce.Present == 0) {
188 if (
IsPle (&PagingEntry[Index], Level)) {
189 ASSERT (Level == 1 || Level == 2 || Level == 3);
197 if ((*LastEntry !=
NULL) &&
198 ((*LastEntry)->LinearAddress + (*LastEntry)->Length == RegionStart) &&
199 (IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&(*LastEntry)->Attribute) + (*LastEntry)->Length
200 == IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (&MapAttribute)) &&
201 (IA32_MAP_ATTRIBUTE_ATTRIBUTES (&(*LastEntry)->Attribute) == IA32_MAP_ATTRIBUTE_ATTRIBUTES (&MapAttribute))
207 (*LastEntry)->Length += RegionLength;
209 if (*MapCount < MapCapacity) {
213 *LastEntry = &Map[*MapCount];
218 *LastEntry = OneEntry;
224 (*LastEntry)->LinearAddress = RegionStart;
225 (*LastEntry)->Length = RegionLength;
226 (*LastEntry)->Attribute.Uint64 = MapAttribute.Uint64;
232 IA32_PNLE_PAGE_TABLE_BASE_ADDRESS (&PagingEntry[Index].Pnle),
266 IN PAGING_MODE PagingMode,
279 if ((PagingMode == Paging32bit) || (PagingMode >= PagingModeMax)) {
286 if (MapCount ==
NULL) {
290 if ((*MapCount != 0) && (Map ==
NULL)) {
294 if (PageTable == 0) {
299 if (PagingMode == PagingPae) {
300 CopyMem (BufferInStack, (VOID *)PageTable,
sizeof (BufferInStack));
301 for (Index = 0; Index < MAX_PAE_PDPTE_NUM; Index++) {
302 BufferInStack[Index].Pnle.Bits.ReadWrite = 1;
303 BufferInStack[Index].Pnle.Bits.UserSupervisor = 1;
304 BufferInStack[Index].Pnle.Bits.Nx = 0;
307 PageTable = (
UINTN)BufferInStack;
330 NopAttribute.Uint64 = 0;
331 NopAttribute.Bits.Present = 1;
332 NopAttribute.Bits.ReadWrite = 1;
333 NopAttribute.Bits.UserSupervisor = 1;
335 MaxLevel = (UINT8)(PagingMode >> 8);
336 MapCapacity = *MapCount;
339 PageTableLibParsePnle ((UINT64)PageTable, MaxLevel, MaxLevel, 0, &NopAttribute, Map, MapCount, MapCapacity, &LastEntry, &OneEntry);
341 if (*MapCount > MapCapacity) {
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
RETURN_STATUS EFIAPI PageTableParse(IN UINTN PageTable, IN PAGING_MODE PagingMode, OUT IA32_MAP_ENTRY *Map, IN OUT UINTN *MapCount)
UINT64 PageTableLibGetPte4KMapAttribute(IN IA32_PTE_4K *Pte4K, IN IA32_MAP_ATTRIBUTE *ParentMapAttribute)
UINT64 PageTableLibGetPnleMapAttribute(IN IA32_PAGE_NON_LEAF_ENTRY *Pnle, IN IA32_MAP_ATTRIBUTE *ParentMapAttribute)
UINT64 PageTableLibGetPleBMapAttribute(IN IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE *PleB, IN IA32_MAP_ATTRIBUTE *ParentMapAttribute)
VOID PageTableLibParsePnle(IN UINT64 PageTableBaseAddress, IN UINTN Level, IN UINTN MaxLevel, IN UINT64 RegionStart, IN IA32_MAP_ATTRIBUTE *ParentMapAttribute, IN OUT IA32_MAP_ENTRY *Map, IN OUT UINTN *MapCount, IN UINTN MapCapacity, IN IA32_MAP_ENTRY **LastEntry, IN IA32_MAP_ENTRY *OneEntry)
BOOLEAN IsPle(IN IA32_PAGING_ENTRY *PagingEntry, IN UINTN Level)
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_UNSUPPORTED
#define RETURN_INVALID_PARAMETER