sel4/arch/x86/arch/x64/
object.rs1use core::ffi::c_uint;
8
9use sel4_config::{sel4_cfg_enum, sel4_cfg_wrap_match};
10
11use crate::{const_helpers::u32_into_usize, sys};
12
13pub type ObjectTypeSeL4Arch = ObjectTypeX64;
14
15pub type ObjectBlueprintSeL4Arch = ObjectBlueprintX64;
16
17#[sel4_cfg_enum]
18#[derive(Copy, Clone, Debug, Eq, PartialEq)]
19pub enum ObjectTypeX64 {
20 HugePage,
21 PDPT,
22 PML4,
23 #[sel4_cfg(VTX)]
24 EPTPDPT,
25 #[sel4_cfg(VTX)]
26 EPTPML4,
27}
28
29impl ObjectTypeX64 {
30 pub(crate) const fn into_sys(self) -> c_uint {
31 sel4_cfg_wrap_match! {
32 match self {
33 Self::HugePage => sys::_mode_object::seL4_X64_HugePageObject,
34 Self::PDPT => sys::_mode_object::seL4_X86_PDPTObject,
35 Self::PML4 => sys::_mode_object::seL4_X64_PML4Object,
36 #[sel4_cfg(VTX)]
37 Self::EPTPDPT => sys::_object::seL4_X86_EPTPDPTObject,
38 #[sel4_cfg(VTX)]
39 Self::EPTPML4 => sys::_object::seL4_X86_EPTPML4Object,
40 }
41 }
42 }
43}
44
45#[sel4_cfg_enum]
46#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
47pub enum ObjectBlueprintX64 {
48 HugePage,
49 PDPT,
50 PML4,
51 #[sel4_cfg(VTX)]
52 EPTPDPT,
53 #[sel4_cfg(VTX)]
54 EPTPML4,
55}
56
57impl ObjectBlueprintX64 {
58 pub(crate) const fn ty(self) -> ObjectTypeX64 {
59 sel4_cfg_wrap_match! {
60 match self {
61 Self::HugePage => ObjectTypeX64::HugePage,
62 Self::PDPT => ObjectTypeX64::PDPT,
63 Self::PML4 => ObjectTypeX64::PML4,
64 #[sel4_cfg(VTX)]
65 Self::EPTPDPT => ObjectTypeX64::EPTPDPT,
66 #[sel4_cfg(VTX)]
67 Self::EPTPML4 => ObjectTypeX64::EPTPML4,
68 }
69 }
70 }
71
72 pub(crate) const fn physical_size_bits(self) -> usize {
73 sel4_cfg_wrap_match! {
74 match self {
75 Self::HugePage => u32_into_usize(sys::seL4_HugePageBits),
76 Self::PDPT => u32_into_usize(sys::seL4_PDPTBits),
77 Self::PML4 => u32_into_usize(sys::seL4_PML4Bits),
78 #[sel4_cfg(VTX)]
79 Self::EPTPDPT => u32_into_usize(sys::seL4_X86_EPTPDPTBits),
80 #[sel4_cfg(VTX)]
81 Self::EPTPML4 => u32_into_usize(sys::seL4_X86_EPTPML4Bits),
82 }
83 }
84 }
85}