wip add specific types

This commit is contained in:
Berkus Decker 2020-12-21 11:54:03 +02:00
parent d8de631b44
commit 91f9c2c215
1 changed files with 7 additions and 4 deletions

View File

@ -2,6 +2,8 @@
* SPDX-License-Identifier: BlueOak-1.0.0 * SPDX-License-Identifier: BlueOak-1.0.0
*/ */
use crate::arch::aarch64::memory::PhysAddr;
use ux::u6;
use { use {
super::{ super::{
captable::CapTableEntry, derivation_tree::DerivationTreeNode, CapError, Capability, TryFrom, captable::CapTableEntry, derivation_tree::DerivationTreeNode, CapError, Capability, TryFrom,
@ -24,6 +26,7 @@ register_bitfields! {
GuardSize OFFSET(6) NUMBITS(6) [], GuardSize OFFSET(6) NUMBITS(6) [],
Radix OFFSET(12) NUMBITS(6) [], Radix OFFSET(12) NUMBITS(6) [],
Ptr OFFSET(16) NUMBITS(48) [], Ptr OFFSET(16) NUMBITS(48) [],
// Guard is 19 bits in seL4 arm32 (?)
Guard OFFSET(64) NUMBITS(64) [], Guard OFFSET(64) NUMBITS(64) [],
] ]
} }
@ -38,23 +41,23 @@ impl CapNodeCapability {
/// Create a capability to CapNode. /// Create a capability to CapNode.
/// ///
/// CapNode capabilities allow to address a capability node tree entry. /// CapNode capabilities allow to address a capability node tree entry.
pub fn new(pptr: u64, radix: u32, guard_size: u32, guard: u64) -> CapNodeCapability { pub fn new(capnode_ptr: PhysAddr, radix: u6, guard_size: u6, guard: u64) -> CapNodeCapability {
CapNodeCapability(LocalRegisterCopy::new(u128::from( CapNodeCapability(LocalRegisterCopy::new(u128::from(
CapNodeCap::Type::value CapNodeCap::Type::value
+ CapNodeCap::Radix.val(radix.into()) + CapNodeCap::Radix.val(radix.into())
+ CapNodeCap::GuardSize.val(guard_size.into()) + CapNodeCap::GuardSize.val(guard_size.into())
+ CapNodeCap::Guard.val(guard.into()) + CapNodeCap::Guard.val(guard.into())
+ CapNodeCap::Ptr.val(pptr.into()), + CapNodeCap::Ptr.val(capnode_ptr.into()),
))) )))
} }
/// Create new root node. /// Create new root node.
pub fn new_root(pptr: u64) -> CapNodeCapability { pub fn new_root(capnode_ptr: PhysAddr) -> CapNodeCapability {
const CONFIG_ROOT_CAPNODE_SIZE_BITS: u32 = 12; const CONFIG_ROOT_CAPNODE_SIZE_BITS: u32 = 12;
const WORD_BITS: u32 = 64; const WORD_BITS: u32 = 64;
CapNodeCapability::new( CapNodeCapability::new(
pptr, capnode_ptr,
CONFIG_ROOT_CAPNODE_SIZE_BITS, CONFIG_ROOT_CAPNODE_SIZE_BITS,
WORD_BITS - CONFIG_ROOT_CAPNODE_SIZE_BITS, WORD_BITS - CONFIG_ROOT_CAPNODE_SIZE_BITS,
0, 0,