| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include <mos/platform/platform.hpp> |
| 6 | |
| 7 | typedef volatile struct __packed |
| 8 | { |
| 9 | bool present : 1; |
| 10 | bool writable : 1; |
| 11 | bool usermode : 1; |
| 12 | bool write_through : 1; |
| 13 | bool cache_disabled : 1; |
| 14 | bool accessed : 1; |
| 15 | bool _ignored1 : 1; |
| 16 | bool page_size : 1; // reserved for pml4e and pml5e, 1 GiB page for pml3e |
| 17 | u8 available_2 : 3; |
| 18 | bool hlat_restart : 1; // for HLAT: if 1, linear-address translation is restarted with ordinary paging |
| 19 | pfn_t page_table_paddr : 40; |
| 20 | u32 _ignored2 : 11; |
| 21 | bool no_execute : 1; |
| 22 | } x86_pde64_t, x86_pmde64_t, x86_pude64_t; // PD, PDPT (PMD), PML4 (PUD) |
| 23 | |
| 24 | MOS_STATIC_ASSERT(sizeof(x86_pde64_t) == sizeof(pte_content_t), "x86_pde64_t differs from pde_content_t" ); |
| 25 | |
| 26 | typedef volatile struct __packed |
| 27 | { |
| 28 | bool present : 1; |
| 29 | bool writable : 1; |
| 30 | bool usermode : 1; |
| 31 | bool write_through : 1; |
| 32 | bool cache_disabled : 1; |
| 33 | bool accessed : 1; |
| 34 | bool dirty : 1; |
| 35 | bool page_size : 1; // must be 1 |
| 36 | bool global : 1; |
| 37 | u8 available : 2; |
| 38 | bool hlat_restart : 1; // for HLAT: if 1, linear-address translation is restarted with ordinary paging |
| 39 | bool pat : 1; |
| 40 | pfn_t pfn : 39; |
| 41 | u32 reserved_2 : 7; // must be 0 |
| 42 | u32 protection_key : 4; |
| 43 | bool no_execute : 1; |
| 44 | } x86_pde64_huge_t, x86_pmde64_huge_t; // 2MiB, 1GiB huge pages for PD, PDPT (PMD) respectively |
| 45 | |
| 46 | MOS_STATIC_ASSERT(sizeof(x86_pde64_huge_t) == sizeof(pte_content_t), "x86_pde64_huge_t differs from pde_content_t" ); |
| 47 | |
| 48 | typedef volatile struct __packed |
| 49 | { |
| 50 | bool present : 1; |
| 51 | bool writable : 1; |
| 52 | bool usermode : 1; |
| 53 | bool write_through : 1; |
| 54 | bool cache_disabled : 1; |
| 55 | bool accessed : 1; |
| 56 | bool dirty : 1; |
| 57 | bool pat : 1; |
| 58 | bool global : 1; |
| 59 | u32 _ignored1 : 2; |
| 60 | bool hlat_restart : 1; |
| 61 | pfn_t pfn : 40; |
| 62 | u32 _ignored2 : 7; |
| 63 | u32 protection_key : 4; |
| 64 | bool no_execute : 1; |
| 65 | } x86_pte64_t; // PTE (4 KiB page) |
| 66 | |
| 67 | MOS_STATIC_ASSERT(sizeof(x86_pte64_t) == sizeof(pte_content_t), "x86_pde64_t differs from pte_content_t" ); |
| 68 | |
| 69 | void x86_paging_setup(void); |
| 70 | |