Skip to main content

sel4/arch/x86/
mod.rs

1//
2// Copyright 2023, Colias Group, LLC
3//
4// SPDX-License-Identifier: MIT
5//
6
7use crate::{const_helpers::u32_into_usize, sys};
8
9mod arch;
10mod invocations;
11mod object;
12mod vm_attributes;
13mod vspace;
14
15pub(crate) mod fault;
16
17pub(crate) mod top_level {
18    pub use super::{
19        NUM_FAST_MESSAGE_REGISTERS,
20        arch::top_level::*,
21        object::{ObjectBlueprintArch, ObjectBlueprintX86, ObjectTypeArch, ObjectTypeX86},
22        vm_attributes::VmAttributes,
23        vspace::{FrameObjectType, TranslationTableObjectType},
24    };
25}
26
27pub(crate) use vspace::vspace_levels;
28
29pub const NUM_FAST_MESSAGE_REGISTERS: usize = u32_into_usize(sys::seL4_FastMessageRegisters);
30
31pub(crate) mod cap_type_arch {
32    use crate::{declare_cap_type, declare_cap_type_for_object_of_fixed_size, sel4_cfg_if};
33
34    sel4_cfg_if! {
35        if #[sel4_cfg(VTX)] {
36            declare_cap_type_for_object_of_fixed_size!(
37                /// Corresponds to `seL4_X86_VCPU`.
38                VCpu { ObjectTypeArch, ObjectBlueprintArch }
39            );
40
41            declare_cap_type_for_object_of_fixed_size!(
42                /// Corresponds to `seL4_X86_EPTPML4`.
43                EPTPML4 { ObjectTypeSeL4Arch, ObjectBlueprintSeL4Arch }
44            );
45
46            declare_cap_type_for_object_of_fixed_size!(
47                /// Corresponds to `seL4_X86_EPTPDPT`.
48                EPTPDPT { ObjectTypeSeL4Arch, ObjectBlueprintSeL4Arch }
49            );
50
51            declare_cap_type_for_object_of_fixed_size!(
52                /// Corresponds to `seL4_X86_EPTPD`.
53                EPTPageDirectory { ObjectTypeArch, ObjectBlueprintArch }
54            );
55
56            declare_cap_type_for_object_of_fixed_size!(
57                /// Corresponds to `seL4_X86_EPTPT`.
58                EPTPageTable { ObjectTypeArch, ObjectBlueprintArch }
59            );
60        }
61    }
62
63    declare_cap_type_for_object_of_fixed_size!(_4k {
64        ObjectTypeArch,
65        ObjectBlueprintArch
66    });
67    declare_cap_type_for_object_of_fixed_size!(LargePage {
68        ObjectTypeArch,
69        ObjectBlueprintArch
70    });
71
72    sel4_cfg_if! {
73        if #[sel4_cfg(HUGE_PAGE)] {
74            declare_cap_type_for_object_of_fixed_size!(HugePage {
75                ObjectTypeSeL4Arch,
76                ObjectBlueprintSeL4Arch
77            });
78        }
79    }
80
81    declare_cap_type_for_object_of_fixed_size!(PML4 {
82        ObjectTypeSeL4Arch,
83        ObjectBlueprintSeL4Arch
84    });
85    declare_cap_type_for_object_of_fixed_size!(PDPT {
86        ObjectTypeSeL4Arch,
87        ObjectBlueprintSeL4Arch
88    });
89    declare_cap_type_for_object_of_fixed_size!(PageDirectory {
90        ObjectTypeArch,
91        ObjectBlueprintArch
92    });
93    declare_cap_type_for_object_of_fixed_size!(PageTable {
94        ObjectTypeArch,
95        ObjectBlueprintArch
96    });
97
98    pub type VSpace = PML4;
99    pub type Granule = _4k;
100
101    declare_cap_type!(IOPortControl);
102}
103
104pub(crate) mod cap_arch {
105    use crate::{declare_cap_alias, sel4_cfg_if};
106
107    sel4_cfg_if! {
108        if #[sel4_cfg(VTX)] {
109            declare_cap_alias!(VCpu);
110            declare_cap_alias!(EPTPML4);
111            declare_cap_alias!(EPTPDPT);
112            declare_cap_alias!(EPTPageDirectory);
113            declare_cap_alias!(EPTPageTable);
114        }
115    }
116
117    declare_cap_alias!(_4k);
118    declare_cap_alias!(LargePage);
119
120    sel4_cfg_if! {
121        if #[sel4_cfg(HUGE_PAGE)] {
122            declare_cap_alias!(HugePage);
123        }
124    }
125
126    declare_cap_alias!(PML4);
127    declare_cap_alias!(PDPT);
128    declare_cap_alias!(PageDirectory);
129    declare_cap_alias!(PageTable);
130
131    declare_cap_alias!(IOPortControl);
132}