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    declare_cap_type_for_object_of_fixed_size!(HugePage {
72        ObjectTypeSeL4Arch,
73        ObjectBlueprintSeL4Arch
74    });
75
76    declare_cap_type_for_object_of_fixed_size!(PML4 {
77        ObjectTypeSeL4Arch,
78        ObjectBlueprintSeL4Arch
79    });
80    declare_cap_type_for_object_of_fixed_size!(PDPT {
81        ObjectTypeSeL4Arch,
82        ObjectBlueprintSeL4Arch
83    });
84    declare_cap_type_for_object_of_fixed_size!(PageDirectory {
85        ObjectTypeArch,
86        ObjectBlueprintArch
87    });
88    declare_cap_type_for_object_of_fixed_size!(PageTable {
89        ObjectTypeArch,
90        ObjectBlueprintArch
91    });
92
93    pub type VSpace = PML4;
94    pub type Granule = _4k;
95
96    declare_cap_type!(IOPortControl);
97}
98
99pub(crate) mod cap_arch {
100    use crate::{declare_cap_alias, sel4_cfg_if};
101
102    sel4_cfg_if! {
103        if #[sel4_cfg(VTX)] {
104            declare_cap_alias!(VCpu);
105            declare_cap_alias!(EPTPML4);
106            declare_cap_alias!(EPTPDPT);
107            declare_cap_alias!(EPTPageDirectory);
108            declare_cap_alias!(EPTPageTable);
109        }
110    }
111
112    declare_cap_alias!(_4k);
113    declare_cap_alias!(LargePage);
114    declare_cap_alias!(HugePage);
115
116    declare_cap_alias!(PML4);
117    declare_cap_alias!(PDPT);
118    declare_cap_alias!(PageDirectory);
119    declare_cap_alias!(PageTable);
120
121    declare_cap_alias!(IOPortControl);
122}