Skip to content

Commit

Permalink
crates/sel4: Don't export cap::*
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Mar 14, 2024
1 parent 99ff513 commit db62444
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 88 deletions.
4 changes: 2 additions & 2 deletions crates/examples/root-task/spawn-task/child/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ mod runtime;
fn main() -> ! {
sel4::debug_println!("In child task");

sel4::Notification::from_bits(1).signal();
sel4::cap::Notification::from_bits(1).signal();

sel4::Tcb::from_bits(2).tcb_suspend().unwrap();
sel4::cap::Tcb::from_bits(2).tcb_suspend().unwrap();

unreachable!()
}
14 changes: 7 additions & 7 deletions crates/examples/root-task/spawn-task/src/child_vspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const GRANULE_SIZE: usize = sel4::FrameObjectType::GRANULE.bytes();
pub(crate) fn create_child_vspace<'a>(
allocator: &mut ObjectAllocator,
image: &'a impl Object<'a, 'a>,
caller_vspace: sel4::VSpace,
caller_vspace: sel4::cap::VSpace,
free_page_addr: usize,
asid_pool: sel4::AsidPool,
) -> (sel4::VSpace, usize, sel4::Granule) {
asid_pool: sel4::cap::AsidPool,
) -> (sel4::cap::VSpace, usize, sel4::cap::Granule) {
let child_vspace = allocator.allocate_fixed_sized::<sel4::cap_type::VSpace>();
asid_pool.asid_pool_assign(child_vspace).unwrap();

Expand Down Expand Up @@ -77,7 +77,7 @@ fn footprint<'a>(image: &'a impl Object<'a, 'a>) -> Range<usize> {

fn map_intermediate_translation_tables(
allocator: &mut ObjectAllocator,
vspace: sel4::VSpace,
vspace: sel4::cap::VSpace,
footprint: Range<usize>,
) {
for level in 1..sel4::vspace_levels::NUM_LEVELS {
Expand All @@ -102,10 +102,10 @@ fn map_intermediate_translation_tables(

fn map_image<'a>(
allocator: &mut ObjectAllocator,
vspace: sel4::VSpace,
vspace: sel4::cap::VSpace,
footprint: Range<usize>,
image: &'a impl Object<'a, 'a>,
caller_vspace: sel4::VSpace,
caller_vspace: sel4::cap::VSpace,
free_page_addr: usize,
) {
let num_pages = footprint.len() / GRANULE_SIZE;
Expand All @@ -116,7 +116,7 @@ fn map_image<'a>(
sel4::CapRightsBuilder::none(),
)
})
.collect::<Vec<(sel4::Granule, sel4::CapRightsBuilder)>>();
.collect::<Vec<(sel4::cap::Granule, sel4::CapRightsBuilder)>>();

for seg in image.segments() {
let segment_addr = usize::try_from(seg.address()).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions crates/examples/root-task/spawn-task/src/object_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::ops::Range;

pub(crate) struct ObjectAllocator {
empty_slots: Range<usize>,
ut: sel4::Untyped,
ut: sel4::cap::Untyped,
}

impl ObjectAllocator {
Expand All @@ -19,7 +19,7 @@ impl ObjectAllocator {
}
}

pub(crate) fn allocate(&mut self, blueprint: sel4::ObjectBlueprint) -> sel4::Unspecified {
pub(crate) fn allocate(&mut self, blueprint: sel4::ObjectBlueprint) -> sel4::cap::Unspecified {
let slot_index = self.empty_slots.next().unwrap();
self.ut
.untyped_retype(
Expand All @@ -46,7 +46,7 @@ impl ObjectAllocator {
}
}

fn find_largest_untyped(bootinfo: &sel4::BootInfo) -> sel4::Untyped {
fn find_largest_untyped(bootinfo: &sel4::BootInfo) -> sel4::cap::Untyped {
let (ut_ix, _desc) = bootinfo
.untyped_list()
.iter()
Expand Down
6 changes: 3 additions & 3 deletions crates/examples/root-task/spawn-thread/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {

struct ObjectAllocator {
empty_slots: Range<usize>,
ut: sel4::Untyped,
ut: sel4::cap::Untyped,
}

impl ObjectAllocator {
Expand Down Expand Up @@ -116,7 +116,7 @@ impl ObjectAllocator {
}
}

fn find_largest_untyped(bootinfo: &sel4::BootInfo) -> sel4::Untyped {
fn find_largest_untyped(bootinfo: &sel4::BootInfo) -> sel4::cap::Untyped {
let (ut_ix, _desc) = bootinfo
.untyped_list()
.iter()
Expand Down Expand Up @@ -284,7 +284,7 @@ impl IpcBufferFrame {
self.0.get().cast()
}

fn cap(&self, bootinfo: &sel4::BootInfo) -> sel4::Granule {
fn cap(&self, bootinfo: &sel4::BootInfo) -> sel4::cap::Granule {
get_user_image_frame_slot(bootinfo, self.ptr() as usize).cap()
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/private/support/sel4-simple-task/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extern crate alloc;
use core::ptr;
use core::slice;

use sel4::Endpoint;
use sel4_dlmalloc::StaticHeapBounds;
use sel4_immediate_sync_once_cell::ImmediateSyncOnceCell;
use sel4_panicking::ExternalPanicInfo;
Expand Down Expand Up @@ -91,11 +90,12 @@ pub unsafe extern "C" fn cont_fn(cont_arg: *mut sel4_runtime_common::ContArg) ->
sel4_runtime_common::run_ctors();
__sel4_simple_task_main(config.arg());
} else {
let endpoint = Endpoint::from_bits(thread_config.endpoint().unwrap().try_into().unwrap());
let endpoint =
sel4::cap::Endpoint::from_bits(thread_config.endpoint().unwrap().try_into().unwrap());
let reply_authority = {
sel4::sel4_cfg_if! {
if #[sel4_cfg(KERNEL_MCS)] {
sel4::Reply::from_bits(thread_config.reply_authority().unwrap())
sel4::cap::Reply::from_bits(thread_config.reply_authority().unwrap())
} else {
assert!(thread_config.reply_authority().is_none());
sel4::ImplicitReplyAuthority
Expand All @@ -114,8 +114,8 @@ pub fn try_idle() {
.and_then(RuntimeConfig::idle_notification)
.map(sel4::CPtrBits::try_from)
.map(Result::unwrap)
.map(sel4::Notification::from_bits)
.map(sel4::Notification::wait);
.map(sel4::cap::Notification::from_bits)
.map(sel4::cap::Notification::wait);
}

pub fn idle() -> ! {
Expand Down Expand Up @@ -152,14 +152,14 @@ fn get_static_heap_bounds() -> StaticHeapBounds {
)
}

fn get_static_heap_mutex_notification() -> sel4::Notification {
fn get_static_heap_mutex_notification() -> sel4::cap::Notification {
CONFIG
.get()
.unwrap()
.static_heap_mutex_notification()
.map(sel4::CPtrBits::try_from)
.map(Result::unwrap)
.map(sel4::Notification::from_bits)
.map(sel4::cap::Notification::from_bits)
.unwrap()
}

Expand Down
24 changes: 12 additions & 12 deletions crates/private/support/sel4-simple-task/threading/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@

use core::mem;

use sel4::{Endpoint, RecvWithMRs, ReplyAuthority, Word};

#[cfg(feature = "alloc")]
extern crate alloc;

pub type StaticThreadEntryFn = extern "C" fn(arg0: Word, arg1: Word);
pub type StaticThreadEntryFn = extern "C" fn(arg0: sel4::Word, arg1: sel4::Word);

#[derive(Copy, Clone, Debug)]
pub struct StaticThread(Endpoint);
pub struct StaticThread(sel4::cap::Endpoint);

impl StaticThread {
pub fn new(endpoint: Endpoint) -> Self {
pub fn new(endpoint: sel4::cap::Endpoint) -> Self {
Self(endpoint)
}

#[allow(clippy::missing_safety_doc)]
pub unsafe fn recv_and_run(endpoint: Endpoint, reply_authority: ReplyAuthority) {
let RecvWithMRs {
pub unsafe fn recv_and_run(
endpoint: sel4::cap::Endpoint,
reply_authority: sel4::ReplyAuthority,
) {
let sel4::RecvWithMRs {
msg: [entry_vaddr, entry_arg0, entry_arg1, ..],
..
} = endpoint.recv_with_mrs(reply_authority);
Expand All @@ -35,8 +36,8 @@ impl StaticThread {
}
}

impl From<Endpoint> for StaticThread {
fn from(endpoint: Endpoint) -> Self {
impl From<sel4::cap::Endpoint> for StaticThread {
fn from(endpoint: sel4::cap::Endpoint) -> Self {
Self::new(endpoint)
}
}
Expand All @@ -46,7 +47,6 @@ mod when_alloc {
use alloc::boxed::Box;
use core::panic::UnwindSafe;

use sel4::Word;
use sel4_panicking::catch_unwind;

use crate::StaticThread;
Expand All @@ -57,12 +57,12 @@ mod when_alloc {
let f_arg = Box::into_raw(b);
self.0.send_with_mrs(
sel4::MessageInfoBuilder::default().length(3).build(),
[entry as usize as Word, f_arg as Word, 0],
[entry as usize as sel4::Word, f_arg as sel4::Word, 0],
);
}
}

extern "C" fn entry(f_arg: Word) {
extern "C" fn entry(f_arg: sel4::Word) {
let f = unsafe { Box::from_raw(f_arg as *mut Box<dyn FnOnce() + UnwindSafe>) };
let _ = catch_unwind(f);
}
Expand Down
32 changes: 14 additions & 18 deletions crates/sel4-capdl-initializer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ use log::{debug, info, trace};
use sel4::{
cap_type,
init_thread::{self, Slot},
AbsoluteCPtr, BootInfoPtr, CNodeCapData, Cap, CapRights, CapType,
CapTypeForFrameObjectOfFixedSize, ObjectBlueprint, Untyped, UserContext,
CapRights, CapTypeForFrameObjectOfFixedSize,
};
use sel4_capdl_initializer_types::*;

#[allow(unused_imports)]
use sel4::{CapTypeForFrameObject, FrameObjectType, VSpace};

mod buffers;
mod cslot_allocator;
mod error;
Expand All @@ -45,7 +41,7 @@ compile_error!("unsupported configuration");
type Result<T> = result::Result<T, CapDLInitializerError>;

pub struct Initializer<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B> {
bootinfo: &'a BootInfoPtr,
bootinfo: &'a sel4::BootInfoPtr,
user_image_bounds: Range<usize>,
copy_addrs: CopyAddrs,
spec_with_sources: &'a SpecWithSources<'a, N, D, M>,
Expand All @@ -57,7 +53,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
Initializer<'a, N, D, M, B>
{
pub fn initialize(
bootinfo: &BootInfoPtr,
bootinfo: &sel4::BootInfoPtr,
user_image_bounds: Range<usize>,
spec_with_sources: &SpecWithSources<N, D, M>,
buffers: &mut InitializerBuffers<B>,
Expand Down Expand Up @@ -246,7 +242,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
max_size_bits
);
self.ut_cap(*i_ut).untyped_retype(
&ObjectBlueprint::Untyped {
&sel4::ObjectBlueprint::Untyped {
size_bits: max_size_bits,
},
&init_thread_cnode_relative_cptr(),
Expand Down Expand Up @@ -494,7 +490,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject

fn fill_frame(
&self,
frame: Cap<cap_type::UnspecifiedFrame>,
frame: sel4::Cap<cap_type::UnspecifiedFrame>,
frame_object_type: sel4::FrameObjectType,
fill: &[FillEntry<D>],
) -> Result<()> {
Expand Down Expand Up @@ -554,7 +550,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject

fn init_vspace(
&mut self,
vspace: VSpace,
vspace: sel4::cap::VSpace,
level: usize,
vaddr: usize,
obj: &object::PageTable,
Expand Down Expand Up @@ -637,7 +633,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject

{
let cspace = self.orig_cap(obj.cspace().object);
let cspace_root_data = CNodeCapData::new(
let cspace_root_data = sel4::CNodeCapData::new(
obj.cspace().guard,
obj.cspace().guard_size.try_into().unwrap(),
);
Expand Down Expand Up @@ -734,7 +730,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
}

{
let mut regs = UserContext::default();
let mut regs = sel4::UserContext::default();
*regs.pc_mut() = obj.extra.ip;
*regs.sp_mut() = obj.extra.sp;
for (i, value) in obj.extra.gprs.iter().enumerate() {
Expand Down Expand Up @@ -784,7 +780,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject

//

fn copy<U: CapType>(&mut self, cap: Cap<U>) -> Result<Cap<U>> {
fn copy<U: sel4::CapType>(&mut self, cap: sel4::Cap<U>) -> Result<sel4::Cap<U>> {
let slot = self.cslot_alloc_or_panic();
let src = init_thread::slot::CNODE.cap().relative(cap);
cslot_to_relative_cptr(slot).copy(&src, CapRights::all())?;
Expand All @@ -811,23 +807,23 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
slot
}

fn orig_cap<U: CapType>(&self, obj_id: ObjectId) -> Cap<U> {
fn orig_cap<U: sel4::CapType>(&self, obj_id: ObjectId) -> sel4::Cap<U> {
self.orig_cslot(obj_id).cap().downcast()
}

fn orig_relative_cptr(&self, obj_id: ObjectId) -> AbsoluteCPtr {
fn orig_relative_cptr(&self, obj_id: ObjectId) -> sel4::AbsoluteCPtr {
cslot_to_relative_cptr(self.orig_cslot(obj_id))
}

fn ut_cap(&self, ut_index: usize) -> Untyped {
fn ut_cap(&self, ut_index: usize) -> sel4::cap::Untyped {
self.bootinfo.untyped().index(ut_index).cap()
}
}

fn cslot_to_relative_cptr(slot: Slot) -> AbsoluteCPtr {
fn cslot_to_relative_cptr(slot: Slot) -> sel4::AbsoluteCPtr {
init_thread::slot::CNODE.cap().relative(slot.cptr())
}

fn init_thread_cnode_relative_cptr() -> AbsoluteCPtr {
fn init_thread_cnode_relative_cptr() -> sel4::AbsoluteCPtr {
init_thread::slot::CNODE.cap().relative_self()
}
6 changes: 3 additions & 3 deletions crates/sel4-microkit/base/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ impl Channel {
}

#[doc(hidden)]
pub fn notification(&self) -> sel4::Notification {
pub fn notification(&self) -> sel4::cap::Notification {
self.cap::<sel4::cap_type::Notification>(BASE_OUTPUT_NOTIFICATION_SLOT)
}

#[doc(hidden)]
pub fn irq_handler(&self) -> sel4::IrqHandler {
pub fn irq_handler(&self) -> sel4::cap::IrqHandler {
self.cap::<sel4::cap_type::IrqHandler>(BASE_IRQ_SLOT)
}

#[doc(hidden)]
pub fn endpoint(&self) -> sel4::Endpoint {
pub fn endpoint(&self) -> sel4::cap::Endpoint {
self.cap::<sel4::cap_type::Endpoint>(BASE_ENDPOINT_SLOT)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/sel4-microkit/src/defer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ impl DeferredAction {

#[derive(Debug, Clone, Eq, PartialEq)]
pub(crate) struct PreparedDeferredAction {
cptr: sel4::Unspecified,
cptr: sel4::cap::Unspecified,
msg_info: sel4::MessageInfo,
}

impl PreparedDeferredAction {
pub(crate) fn new(cptr: sel4::Unspecified, msg_info: sel4::MessageInfo) -> Self {
pub(crate) fn new(cptr: sel4::cap::Unspecified, msg_info: sel4::MessageInfo) -> Self {
Self { cptr, msg_info }
}

pub(crate) fn cptr(&self) -> sel4::Unspecified {
pub(crate) fn cptr(&self) -> sel4::cap::Unspecified {
self.cptr
}

Expand Down
6 changes: 3 additions & 3 deletions crates/sel4-microkit/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use crate::{

pub use core::convert::Infallible;

const INPUT_CAP: sel4::Endpoint = sel4::Cap::from_bits(1);
const REPLY_CAP: sel4::Reply = sel4::Cap::from_bits(4);
const MONITOR_EP_CAP: sel4::Endpoint = sel4::Cap::from_bits(5);
const INPUT_CAP: sel4::cap::Endpoint = sel4::Cap::from_bits(1);
const REPLY_CAP: sel4::cap::Reply = sel4::Cap::from_bits(4);
const MONITOR_EP_CAP: sel4::cap::Endpoint = sel4::Cap::from_bits(5);

const EVENT_TYPE_MASK: sel4::Word = 1 << (sel4::WORD_SIZE - 1);

Expand Down
Loading

0 comments on commit db62444

Please sign in to comment.