From 91f9c2c21598d381d65cd18752484017dd68c1c4 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Mon, 21 Dec 2020 11:54:03 +0200 Subject: [PATCH] wip add specific types --- nucleus/src/caps/capnode_cap.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nucleus/src/caps/capnode_cap.rs b/nucleus/src/caps/capnode_cap.rs index fb89877..f1307ef 100644 --- a/nucleus/src/caps/capnode_cap.rs +++ b/nucleus/src/caps/capnode_cap.rs @@ -2,6 +2,8 @@ * SPDX-License-Identifier: BlueOak-1.0.0 */ +use crate::arch::aarch64::memory::PhysAddr; +use ux::u6; use { super::{ captable::CapTableEntry, derivation_tree::DerivationTreeNode, CapError, Capability, TryFrom, @@ -24,6 +26,7 @@ register_bitfields! { GuardSize OFFSET(6) NUMBITS(6) [], Radix OFFSET(12) NUMBITS(6) [], Ptr OFFSET(16) NUMBITS(48) [], + // Guard is 19 bits in seL4 arm32 (?) Guard OFFSET(64) NUMBITS(64) [], ] } @@ -38,23 +41,23 @@ impl CapNodeCapability { /// Create a capability to CapNode. /// /// 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( CapNodeCap::Type::value + CapNodeCap::Radix.val(radix.into()) + CapNodeCap::GuardSize.val(guard_size.into()) + CapNodeCap::Guard.val(guard.into()) - + CapNodeCap::Ptr.val(pptr.into()), + + CapNodeCap::Ptr.val(capnode_ptr.into()), ))) } /// 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 WORD_BITS: u32 = 64; CapNodeCapability::new( - pptr, + capnode_ptr, CONFIG_ROOT_CAPNODE_SIZE_BITS, WORD_BITS - CONFIG_ROOT_CAPNODE_SIZE_BITS, 0,