TianoCore EDK2 master
Loading...
Searching...
No Matches
CpuPageTableLib.h
Go to the documentation of this file.
1
9#ifndef PAGE_TABLE_LIB_H_
10#define PAGE_TABLE_LIB_H_
11
12typedef union {
13 struct {
14 UINT32 Present : 1; // 0 = Not present in memory, 1 = Present in memory
15 UINT32 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write
16 UINT32 UserSupervisor : 1; // 0 = Supervisor, 1=User
17 UINT32 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching
18 UINT32 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached
19 UINT32 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU)
20 UINT32 Dirty : 1; // 0 = Not dirty, 1 = Dirty (set by CPU)
21 UINT32 Pat : 1; // PAT
22 UINT32 Global : 1; // 0 = Not global, 1 = Global (if CR4.PGE = 1)
23 UINT32 Reserved1 : 3; // Ignored
24 UINT32 PageTableBaseAddressLow : 20; // Page Table Base Address Low
25
26 UINT32 PageTableBaseAddressHigh : 20; // Page Table Base Address High
27 UINT32 Reserved2 : 7; // Ignored
28 UINT32 ProtectionKey : 4; // Protection key
29 UINT32 Nx : 1; // No Execute bit
30 } Bits;
31 UINT64 Uint64;
33
34#define IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK 0xFFFFFFFFFF000ull
35#define IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS(pa) ((pa)->Uint64 & IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK)
36#define IA32_MAP_ATTRIBUTE_ATTRIBUTES(pa) ((pa)->Uint64 & ~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK)
37
38//
39// Below enum follows "4.1.1 Four Paging Modes" in Chapter 4 Paging of SDM Volume 3.
40// Page1GB is only supported in 4-level and 5-level.
41//
42typedef enum {
43 Paging32bit,
44
45 //
46 // High byte in paging mode indicates the max levels of the page table.
47 // Low byte in paging mode indicates the max level that can be a leaf entry.
48 //
49 PagingPae4KB = 0x0301,
50 PagingPae2MB = 0x0302,
51 PagingPae = 0x0302,
52
53 Paging4Level4KB = 0x0401,
54 Paging4Level2MB = 0x0402,
55 Paging4Level = 0x0402,
56 Paging4Level1GB = 0x0403,
57
58 Paging5Level4KB = 0x0501,
59 Paging5Level2MB = 0x0502,
60 Paging5Level = 0x0502,
61 Paging5Level1GB = 0x0503,
62
63 PagingModeMax
64} PAGING_MODE;
65
100RETURN_STATUS
101EFIAPI
103 IN OUT UINTN *PageTable OPTIONAL,
104 IN PAGING_MODE PagingMode,
105 IN VOID *Buffer,
106 IN OUT UINTN *BufferSize,
107 IN UINT64 LinearAddress,
108 IN UINT64 Length,
109 IN IA32_MAP_ATTRIBUTE *Attribute,
111 OUT BOOLEAN *IsModified OPTIONAL
112 );
113
114typedef struct {
115 UINT64 LinearAddress;
116 UINT64 Length;
117 IA32_MAP_ATTRIBUTE Attribute;
119
135RETURN_STATUS
136EFIAPI
138 IN UINTN PageTable,
139 IN PAGING_MODE PagingMode,
140 IN IA32_MAP_ENTRY *Map,
141 IN OUT UINTN *MapCount
142 );
143
144#endif
UINT64 UINTN
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)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284