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    #[crate::sel4_cfg(all(ARCH_X86_64, IOMMU))]
27    pub use super::vspace::io_space;
28}
29
30pub(crate) use vspace::vspace_levels;
31
32pub const NUM_FAST_MESSAGE_REGISTERS: usize = u32_into_usize(sys::seL4_FastMessageRegisters);
33
34pub(crate) mod cap_type_arch {
35    use crate::{declare_cap_type, declare_cap_type_for_object_of_fixed_size, sel4_cfg_if};
36
37    sel4_cfg_if! {
38        if #[sel4_cfg(VTX)] {
39            declare_cap_type_for_object_of_fixed_size!(
40                /// Corresponds to `seL4_X86_VCPU`.
41                VCpu { ObjectTypeArch, ObjectBlueprintArch }
42            );
43
44            declare_cap_type_for_object_of_fixed_size!(
45                /// Corresponds to `seL4_X86_EPTPML4`.
46                EPTPML4 { ObjectTypeSeL4Arch, ObjectBlueprintSeL4Arch }
47            );
48
49            declare_cap_type_for_object_of_fixed_size!(
50                /// Corresponds to `seL4_X86_EPTPDPT`.
51                EPTPDPT { ObjectTypeSeL4Arch, ObjectBlueprintSeL4Arch }
52            );
53
54            declare_cap_type_for_object_of_fixed_size!(
55                /// Corresponds to `seL4_X86_EPTPD`.
56                EPTPageDirectory { ObjectTypeArch, ObjectBlueprintArch }
57            );
58
59            declare_cap_type_for_object_of_fixed_size!(
60                /// Corresponds to `seL4_X86_EPTPT`.
61                EPTPageTable { ObjectTypeArch, ObjectBlueprintArch }
62            );
63        }
64    }
65
66    sel4_cfg_if! {
67        if #[sel4_cfg(IOMMU)] {
68            declare_cap_type_for_object_of_fixed_size!(
69                IOPageTable { ObjectTypeArch, ObjectBlueprintArch }
70            );
71
72            declare_cap_type!(IOSpace);
73        }
74    }
75
76    declare_cap_type_for_object_of_fixed_size!(_4k {
77        ObjectTypeArch,
78        ObjectBlueprintArch
79    });
80    declare_cap_type_for_object_of_fixed_size!(LargePage {
81        ObjectTypeArch,
82        ObjectBlueprintArch
83    });
84
85    sel4_cfg_if! {
86        if #[sel4_cfg(HUGE_PAGE)] {
87            declare_cap_type_for_object_of_fixed_size!(HugePage {
88                ObjectTypeSeL4Arch,
89                ObjectBlueprintSeL4Arch
90            });
91        }
92    }
93
94    declare_cap_type_for_object_of_fixed_size!(PML4 {
95        ObjectTypeSeL4Arch,
96        ObjectBlueprintSeL4Arch
97    });
98    declare_cap_type_for_object_of_fixed_size!(PDPT {
99        ObjectTypeSeL4Arch,
100        ObjectBlueprintSeL4Arch
101    });
102    declare_cap_type_for_object_of_fixed_size!(PageDirectory {
103        ObjectTypeArch,
104        ObjectBlueprintArch
105    });
106    declare_cap_type_for_object_of_fixed_size!(PageTable {
107        ObjectTypeArch,
108        ObjectBlueprintArch
109    });
110
111    pub type VSpace = PML4;
112    pub type Granule = _4k;
113
114    declare_cap_type!(IOPortControl);
115}
116
117pub(crate) mod cap_arch {
118    use crate::{declare_cap_alias, sel4_cfg_if};
119
120    sel4_cfg_if! {
121        if #[sel4_cfg(VTX)] {
122            declare_cap_alias!(VCpu);
123            declare_cap_alias!(EPTPML4);
124            declare_cap_alias!(EPTPDPT);
125            declare_cap_alias!(EPTPageDirectory);
126            declare_cap_alias!(EPTPageTable);
127        }
128    }
129
130    sel4_cfg_if! {
131        if #[sel4_cfg(IOMMU)] {
132            declare_cap_alias!(IOPageTable);
133            declare_cap_alias!(IOSpace);
134        }
135    }
136
137    declare_cap_alias!(_4k);
138    declare_cap_alias!(LargePage);
139
140    sel4_cfg_if! {
141        if #[sel4_cfg(HUGE_PAGE)] {
142            declare_cap_alias!(HugePage);
143        }
144    }
145
146    declare_cap_alias!(PML4);
147    declare_cap_alias!(PDPT);
148    declare_cap_alias!(PageDirectory);
149    declare_cap_alias!(PageTable);
150
151    declare_cap_alias!(IOPortControl);
152}