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