1#![cfg_attr(not(any(feature = "std", test)), no_std)]
7#![expect(missing_docs)]
9#![forbid(unsafe_code)]
10
11pub mod aarch64;
12pub mod x64;
13
14use thiserror::Error;
15
16#[derive(Debug, PartialEq, Eq, Error)]
18pub enum Error {
19 #[error(
21 "PageTableBuilder bytes buffer size {bytes_buf} does not match the struct buffer size [{struct_buf}]"
22 )]
23 BadBufferSize { bytes_buf: usize, struct_buf: usize },
24
25 #[error(
27 "constructed page tables are larger than the amount memory given for construction by the caller"
28 )]
29 NotEnoughMemory,
30
31 #[error("the page table builder was invoked with unsorted mapping ranges")]
33 UnsortedMappings,
34
35 #[error("page table builder range.end() < range.start()")]
37 InvalidRange,
38
39 #[error("the page table builder was invoked with overlapping mappings")]
41 OverlappingMappings,
42
43 #[error("the page table builder attempted to overwite a leaf mapping")]
45 AttemptedEntryOverwrite,
46}
47
48#[derive(Debug, Copy, Clone)]
50pub enum IdentityMapSize {
51 Size4Gb,
53 Size8Gb,
55}
56
57impl IdentityMapSize {
58 pub const fn address_space_size(self) -> u64 {
60 match self {
61 Self::Size4Gb => 0x1_0000_0000,
62 Self::Size8Gb => 0x2_0000_0000,
63 }
64 }
65}