diff --git a/kernel/src/objects/frame.rs b/kernel/src/objects/frame.rs index 69c68b3..2532f44 100644 --- a/kernel/src/objects/frame.rs +++ b/kernel/src/objects/frame.rs @@ -52,10 +52,8 @@ impl<'a> FrameCap<'a> { const VM_RIGHT_MASK: usize = MASK!(Self::VM_RIGHT_BITS); const VM_RIGHT_OFFSET: usize = 0; - pub fn mint(ptr: PhysAddr, size: usize, attr: MapAttr, is_device: bool) -> RawCap { - let size_bits = size.ilog2() as usize; - debug_assert!(size_bits <= FrameCap::FRAME_SIZE_BITS); - assert!(size >= PAGE_SIZE); + pub fn mint(ptr: PhysAddr, size_bits: usize, attr: MapAttr, is_device: bool) -> RawCap { + debug_assert!(size_bits <= MASK!(Self::FRAME_SIZE_BITS)); // 1<<63 let arg0 = 0 | ((attr.bits() & Self::VM_RIGHT_MASK) << Self::VM_RIGHT_OFFSET) diff --git a/kernel/src/objects/untyped.rs b/kernel/src/objects/untyped.rs index 8ff8709..ebbae98 100644 --- a/kernel/src/objects/untyped.rs +++ b/kernel/src/objects/untyped.rs @@ -1,7 +1,8 @@ use super::cap::RawCap; use super::cnode::{CNodeCap, CNodeObject}; use super::null::NullCap; -use super::{Cap, KernelObject, TableCap, TcbCap}; +use super::{Cap, FrameCap, KernelObject, TableCap, TcbCap}; +use crate::vspace::MapAttr; use core::fmt::Debug; use uapi::cap::ObjectType; use uapi::error::{SysError, SysResult}; @@ -107,7 +108,6 @@ impl UntypedCap<'_> { // Check whether we are handling device memory if self.is_device() && obj_type != ObjectType::Frame && obj_type != ObjectType::Untyped { - // TODO: we might split frame into tera, giga, mega, kilo... return Err(SysError::InvalidArgument); } @@ -119,6 +119,7 @@ impl UntypedCap<'_> { ObjectType::CNode => CNodeCap::mint(user_obj_bits, 0, 0, addr), ObjectType::TCB => TcbCap::mint(addr), ObjectType::Table => TableCap::mint(addr), + ObjectType::Frame => FrameCap::mint(addr, user_obj_bits, MapAttr::empty(), self.is_device()), // TODO: other object types _ => return Err(SysError::InvalidArgument), };