sel4/arch/arm/arch/aarch64/
object.rs

1//
2// Copyright 2023, Colias Group, LLC
3//
4// SPDX-License-Identifier: MIT
5//
6
7use core::ffi::c_uint;
8
9use crate::{const_helpers::u32_into_usize, sys};
10
11/// Alias for [`ObjectTypeAArch64`].
12pub type ObjectTypeSeL4Arch = ObjectTypeAArch64;
13
14/// Alias for [`ObjectBlueprintAArch64`].
15pub type ObjectBlueprintSeL4Arch = ObjectBlueprintAArch64;
16
17/// Corresponds to `seL4_ModeObjectType`.
18#[derive(Copy, Clone, Debug, Eq, PartialEq)]
19pub enum ObjectTypeAArch64 {
20    HugePage,
21    VSpace,
22}
23
24impl ObjectTypeAArch64 {
25    pub(crate) const fn into_sys(self) -> c_uint {
26        match self {
27            Self::HugePage => sys::_mode_object::seL4_ARM_HugePageObject,
28            Self::VSpace => sys::_mode_object::seL4_ARM_VSpaceObject,
29        }
30    }
31}
32
33/// AArch64-specific variants of [`ObjectBlueprint`](crate::ObjectBlueprint).
34#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
35pub enum ObjectBlueprintAArch64 {
36    HugePage,
37    VSpace,
38}
39
40impl ObjectBlueprintAArch64 {
41    pub(crate) const fn ty(self) -> ObjectTypeAArch64 {
42        match self {
43            Self::HugePage => ObjectTypeAArch64::HugePage,
44            Self::VSpace => ObjectTypeAArch64::VSpace,
45        }
46    }
47
48    pub(crate) const fn physical_size_bits(self) -> usize {
49        match self {
50            Self::HugePage => u32_into_usize(sys::seL4_HugePageBits),
51            Self::VSpace => u32_into_usize(sys::seL4_VSpaceBits),
52        }
53    }
54}