Debian Codegraph @

src/cpu/x86/64bit/pt.S

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /*
4 * For reference see "AMD64 Architecture Programmer's Manual Volume 2",
5 * Document 24593-Rev. 3.31-July 2019 Chapter 5.3.4
6 *
7 * Page table attributes: WB, User+Supervisor, Present, Writeable, Accessed, Dirty
8 */
9
10 .section .rodata
11 #define _PRES (1ULL << 0)
12 #define _RW (1ULL << 1)
13 #define _US (1ULL << 2)
14 #define _A (1ULL << 5)
15 #define _D (1ULL << 6)
16 #define _PS (1ULL << 7)
17 #define _GEN_DIR(a) (_PRES + _RW + _US + _A + (a))
18 #define _GEN_PAGE(a) (_PRES + _RW + _US + _PS + _A + _D + (a))
19
20 .global PML4E
21 .align 4096
22 PML4E:
23 /* For every 512GiB generate a pointer to the corresponding PDPT */
24 .rept ((CONFIG_CPU_PT_ROM_MAP_GB + 511) >> 9)
25 .quad _GEN_DIR(PDPT + 4096 * ((. - PML4E) >> 3)) /* Point to PDPT */
26 .endr
27
28 .align 4096
29 PDT:
30 /* For every 2MiB generate a page entry. In one GiB there are 512 pages. */
31 .rept (CONFIG_CPU_PT_ROM_MAP_GB << 9)
32 .quad _GEN_PAGE(0x200000 * ((. - PDT) >> 3)) /* identity map 2MiB page */
33 .endr
34
35 .align 4096
36 PDPT:
37 /* For every 1GiB generate a pointer to the corresponding PDT */
38 .rept CONFIG_CPU_PT_ROM_MAP_GB
39 .quad _GEN_DIR(PDT + 4096 * ((. - PDPT) >> 3)) /* Point to PDT */
40 .endr