]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm
UefiCpuPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / UefiCpuPkg / ResetVector / Vtf0 / X64 / PageTables.asm
1 ;------------------------------------------------------------------------------
2 ; @file
3 ; Emits Page Tables for 1:1 mapping of the addresses 0 - 0x100000000 (4GB)
4 ;
5 ; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
6 ; SPDX-License-Identifier: BSD-2-Clause-Patent
7 ;
8 ;------------------------------------------------------------------------------
9
10 BITS 64
11
12 %define ALIGN_TOP_TO_4K_FOR_PAGING
13
14 %define PAGE_PRESENT 0x01
15 %define PAGE_READ_WRITE 0x02
16 %define PAGE_USER_SUPERVISOR 0x04
17 %define PAGE_WRITE_THROUGH 0x08
18 %define PAGE_CACHE_DISABLE 0x010
19 %define PAGE_ACCESSED 0x020
20 %define PAGE_DIRTY 0x040
21 %define PAGE_PAT 0x080
22 %define PAGE_GLOBAL 0x0100
23 %define PAGE_2M_MBO 0x080
24 %define PAGE_2M_PAT 0x01000
25
26 %define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \
27 PAGE_ACCESSED + \
28 PAGE_DIRTY + \
29 PAGE_READ_WRITE + \
30 PAGE_PRESENT)
31
32 %define PAGE_PDP_ATTR (PAGE_ACCESSED + \
33 PAGE_READ_WRITE + \
34 PAGE_PRESENT)
35
36 %define PGTBLS_OFFSET(x) ((x) - TopLevelPageDirectory)
37 %define PGTBLS_ADDR(x) (ADDR_OF(TopLevelPageDirectory) + (x))
38
39 %define PDP(offset) (ADDR_OF(TopLevelPageDirectory) + (offset) + \
40 PAGE_PDP_ATTR)
41 %define PTE_2MB(x) ((x << 21) + PAGE_2M_PDE_ATTR)
42
43 TopLevelPageDirectory:
44
45 ;
46 ; Top level Page Directory Pointers (1 * 512GB entry)
47 ;
48 DQ PDP(0x1000)
49
50
51 ;
52 ; Next level Page Directory Pointers (4 * 1GB entries => 4GB)
53 ;
54 TIMES 0x1000-PGTBLS_OFFSET($) DB 0
55
56 DQ PDP(0x2000)
57 DQ PDP(0x3000)
58 DQ PDP(0x4000)
59 DQ PDP(0x5000)
60
61 ;
62 ; Page Table Entries (2048 * 2MB entries => 4GB)
63 ;
64 TIMES 0x2000-PGTBLS_OFFSET($) DB 0
65
66 %assign i 0
67 %rep 0x800
68 DQ PTE_2MB(i)
69 %assign i i+1
70 %endrep
71
72 EndOfPageTables: