]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm
UefiCpuPkg VTF0 X64: Build page tables in NASM code
[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 ; This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php
10 ;
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 ;
14 ;------------------------------------------------------------------------------
15
16 BITS 64
17
18 %define ALIGN_TOP_TO_4K_FOR_PAGING
19
20 %define PAGE_PRESENT 0x01
21 %define PAGE_READ_WRITE 0x02
22 %define PAGE_USER_SUPERVISOR 0x04
23 %define PAGE_WRITE_THROUGH 0x08
24 %define PAGE_CACHE_DISABLE 0x010
25 %define PAGE_ACCESSED 0x020
26 %define PAGE_DIRTY 0x040
27 %define PAGE_PAT 0x080
28 %define PAGE_GLOBAL 0x0100
29 %define PAGE_2M_MBO 0x080
30 %define PAGE_2M_PAT 0x01000
31
32 %define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \
33 PAGE_ACCESSED + \
34 PAGE_DIRTY + \
35 PAGE_READ_WRITE + \
36 PAGE_PRESENT)
37
38 %define PAGE_PDP_ATTR (PAGE_ACCESSED + \
39 PAGE_READ_WRITE + \
40 PAGE_PRESENT)
41
42 %define PGTBLS_OFFSET(x) ((x) - TopLevelPageDirectory)
43 %define PGTBLS_ADDR(x) (ADDR_OF(TopLevelPageDirectory) + (x))
44
45 %define PDP(offset) (ADDR_OF(TopLevelPageDirectory) + (offset) + \
46 PAGE_PDP_ATTR)
47 %define PTE_2MB(x) ((x << 21) + PAGE_2M_PDE_ATTR)
48
49 TopLevelPageDirectory:
50
51 ;
52 ; Top level Page Directory Pointers (1 * 512GB entry)
53 ;
54 DQ PDP(0x1000)
55
56
57 ;
58 ; Next level Page Directory Pointers (4 * 1GB entries => 4GB)
59 ;
60 TIMES 0x1000-PGTBLS_OFFSET($) DB 0
61
62 DQ PDP(0x2000)
63 DQ PDP(0x3000)
64 DQ PDP(0x4000)
65 DQ PDP(0x5000)
66
67 ;
68 ; Page Table Entries (2048 * 2MB entries => 4GB)
69 ;
70 TIMES 0x2000-PGTBLS_OFFSET($) DB 0
71
72 %assign i 0
73 %rep 0x800
74 DQ PTE_2MB(i)
75 %assign i i+1
76 %endrep
77
78 EndOfPageTables: