Skip to content

Commit

Permalink
crates/sel4: Rename relative -> absolute_cptr
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Oct 7, 2024
1 parent a5760b7 commit c752316
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {

cnode
.with(&mut ipc_buffer)
.relative(badged_notification_slot.cptr())
.absolute_cptr(badged_notification_slot.cptr())
.mint(
&cnode.relative(unbadged_notification_slot.cptr()),
&cnode.absolute_cptr(unbadged_notification_slot.cptr()),
sel4::CapRights::write_only(),
badge,
)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/examples/root-task/example-root-task/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {

let badge = 0x1337;

cnode.relative(badged_notification_slot.cptr()).mint(
&cnode.relative(unbadged_notification_slot.cptr()),
cnode.absolute_cptr(badged_notification_slot.cptr()).mint(
&cnode.absolute_cptr(unbadged_notification_slot.cptr()),
sel4::CapRights::write_only(),
badge,
)?;
Expand Down
6 changes: 3 additions & 3 deletions crates/examples/root-task/serial-device/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {
SERIAL_DEVICE_IRQ.try_into().unwrap(),
&sel4::init_thread::slot::CNODE
.cap()
.relative(irq_handler_cap),
.absolute_cptr(irq_handler_cap),
)
.unwrap();

Expand Down Expand Up @@ -165,10 +165,10 @@ fn trim_untyped(
) {
let rel_a = sel4::init_thread::slot::CNODE
.cap()
.relative(free_slot_a.cptr());
.absolute_cptr(free_slot_a.cptr());
let rel_b = sel4::init_thread::slot::CNODE
.cap()
.relative(free_slot_b.cptr());
.absolute_cptr(free_slot_b.cptr());
let mut cur_paddr = ut_paddr;
while cur_paddr != target_paddr {
let size_bits = (target_paddr - cur_paddr).ilog2().try_into().unwrap();
Expand Down
6 changes: 4 additions & 2 deletions crates/examples/root-task/spawn-task/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {
.mint(
&sel4::init_thread::slot::CNODE
.cap()
.relative(inter_task_nfn),
.absolute_cptr(inter_task_nfn),
sel4::CapRights::write_only(),
0,
)
Expand All @@ -75,7 +75,9 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {
child_cnode
.absolute_cptr_from_bits_with_depth(2, child_cnode_size_bits)
.mint(
&sel4::init_thread::slot::CNODE.cap().relative(child_tcb),
&sel4::init_thread::slot::CNODE
.cap()
.absolute_cptr(child_tcb),
sel4::CapRights::all(),
0,
)
Expand Down
10 changes: 5 additions & 5 deletions crates/sel4-capdl-initializer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
if badge == 0 && rights == CapRights::all() {
orig
} else {
let src = init_thread::slot::CNODE.cap().relative(orig);
let src = init_thread::slot::CNODE.cap().absolute_cptr(orig);
let new = self.cslot_alloc_or_panic().cap();
let dst = init_thread::slot::CNODE.cap().relative(new);
let dst = init_thread::slot::CNODE.cap().absolute_cptr(new);
dst.mint(&src, rights, badge)?;
new.cast()
}
Expand Down Expand Up @@ -757,7 +757,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
let rights = cap.rights().map(From::from).unwrap_or(CapRights::all());
let src = init_thread::slot::CNODE
.cap()
.relative(self.orig_cap::<cap_type::Unspecified>(cap.obj()));
.absolute_cptr(self.orig_cap::<cap_type::Unspecified>(cap.obj()));
let dst = cnode
.absolute_cptr_from_bits_with_depth((*i).try_into().unwrap(), obj.size_bits);
match badge {
Expand All @@ -784,7 +784,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject

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);
let src = init_thread::slot::CNODE.cap().absolute_cptr(cap);
cslot_to_relative_cptr(slot).copy(&src, CapRights::all())?;
Ok(slot.cap().downcast())
}
Expand Down Expand Up @@ -823,7 +823,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
}

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

fn init_thread_cnode_relative_cptr() -> sel4::AbsoluteCPtr {
Expand Down
6 changes: 3 additions & 3 deletions crates/sel4/src/cptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl HasCPtrWithDepth for CPtrWithDepth {
}

impl<C> CNode<C> {
pub fn relative<T: HasCPtrWithDepth>(self, path: T) -> AbsoluteCPtr<C> {
pub fn absolute_cptr<T: HasCPtrWithDepth>(self, path: T) -> AbsoluteCPtr<C> {
AbsoluteCPtr {
root: self,
path: path.cptr_with_depth(),
Expand All @@ -402,10 +402,10 @@ impl<C> CNode<C> {
bits: CPtrBits,
depth: usize,
) -> AbsoluteCPtr<C> {
self.relative(CPtrWithDepth::from_bits_with_depth(bits, depth))
self.absolute_cptr(CPtrWithDepth::from_bits_with_depth(bits, depth))
}

pub fn absolute_cptr_for_self(self) -> AbsoluteCPtr<C> {
self.relative(CPtrWithDepth::empty())
self.absolute_cptr(CPtrWithDepth::empty())
}
}

0 comments on commit c752316

Please sign in to comment.