Skip to content

Commit

Permalink
crates/sel4-capdl-initializer: Improve language
Browse files Browse the repository at this point in the history
Rename *relative_cptr* -> *absolute_cptr*

Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Oct 7, 2024
1 parent c752316 commit ab0ae23
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions crates/sel4-capdl-initializer/core/src/hold_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub(crate) struct HoldSlots<T> {
slots: [Slot; NUM_SLOTS],
slots_occupied: [bool; NUM_SLOTS],
which_slot: usize,
relative_cptr_of: T,
absolute_cptr_of: T,
}

impl<T> HoldSlots<T> {
pub(crate) fn new(
cslot_allocator: &mut CSlotAllocator,
relative_cptr_of: T,
absolute_cptr_of: T,
) -> Result<Self, CapDLInitializerError> {
Ok(Self {
slots: {
Expand All @@ -30,15 +30,15 @@ impl<T> HoldSlots<T> {
},
slots_occupied: [false; NUM_SLOTS],
which_slot: 0,
relative_cptr_of,
absolute_cptr_of,
})
}
}

impl<T: FnMut(Slot) -> AbsoluteCPtr> HoldSlots<T> {
pub(crate) fn get_slot(&mut self) -> Result<Slot, CapDLInitializerError> {
if self.slots_occupied[self.which_slot] {
(self.relative_cptr_of)(self.slots[self.which_slot]).delete()?;
(self.absolute_cptr_of)(self.slots[self.which_slot]).delete()?;
self.slots_occupied[self.which_slot] = false;
}
Ok(self.slots[self.which_slot])
Expand Down
38 changes: 19 additions & 19 deletions crates/sel4-capdl-initializer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
// least one reference to an object allocated from an untyped, or else
// its watermark will reset. This juggling approach is an easy way to
// ensure that we are always holding such a reference.
let mut hold_slots = HoldSlots::new(self.cslot_allocator, cslot_to_relative_cptr)?;
let mut hold_slots = HoldSlots::new(self.cslot_allocator, cslot_to_absolute_cptr)?;

// Create root objects

Expand Down Expand Up @@ -221,7 +221,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
);
self.ut_cap(*i_ut).untyped_retype(
&blueprint,
&init_thread_cnode_relative_cptr(),
&init_thread_cnode_absolute_cptr(),
self.alloc_orig_cslot(*obj_id).index(),
1,
)?;
Expand All @@ -244,7 +244,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
&sel4::ObjectBlueprint::Untyped {
size_bits: max_size_bits,
},
&init_thread_cnode_relative_cptr(),
&init_thread_cnode_absolute_cptr(),
hold_slot.index(),
1,
)?;
Expand All @@ -267,7 +267,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
);
self.ut_cap(*i_ut).untyped_retype(
&blueprint,
&init_thread_cnode_relative_cptr(),
&init_thread_cnode_absolute_cptr(),
self.alloc_orig_cslot(obj_id).index(),
1,
)?;
Expand Down Expand Up @@ -299,7 +299,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
);
parent_cptr.untyped_retype(
&child.object.blueprint().unwrap(),
&init_thread_cnode_relative_cptr(),
&init_thread_cnode_absolute_cptr(),
self.alloc_orig_cslot(child_obj_id).index(),
1,
)?;
Expand All @@ -315,7 +315,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
let slot = self.cslot_alloc_or_panic();
init_thread::slot::ASID_CONTROL
.cap()
.asid_control_make_pool(ut, &cslot_to_relative_cptr(slot))?;
.asid_control_make_pool(ut, &cslot_to_absolute_cptr(slot))?;
self.set_orig_cslot(*obj_id, slot);
}
}
Expand All @@ -328,7 +328,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
match self.spec().object(*handler) {
Object::Irq(_) => {
init_thread::slot::IRQ_CONTROL.cap()
.irq_control_get(*irq, &cslot_to_relative_cptr(slot))?;
.irq_control_get(*irq, &cslot_to_absolute_cptr(slot))?;
}
#[sel4_cfg(any(ARCH_AARCH64, ARCH_AARCH32))]
Object::ArmIrq(obj) => {
Expand All @@ -337,14 +337,14 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
init_thread::slot::IRQ_CONTROL.cap().irq_control_get_trigger(
*irq,
obj.extra.trigger != 0,
&cslot_to_relative_cptr(slot),
&cslot_to_absolute_cptr(slot),
)?;
} else {
init_thread::slot::IRQ_CONTROL.cap().irq_control_get_trigger_core(
*irq,
obj.extra.trigger != 0,
obj.extra.target,
&cslot_to_relative_cptr(slot),
&cslot_to_absolute_cptr(slot),
)?;
}
}
Expand All @@ -357,7 +357,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
obj.extra.pci_func,
obj.extra.handle,
*irq,
&cslot_to_relative_cptr(slot),
&cslot_to_absolute_cptr(slot),
)?;
}
#[sel4_cfg(ARCH_X86_64)]
Expand All @@ -368,7 +368,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
obj.extra.level,
obj.extra.polarity,
*irq,
&cslot_to_relative_cptr(slot),
&cslot_to_absolute_cptr(slot),
)?;
}
_ => {
Expand All @@ -393,7 +393,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
let slot = self.cslot_alloc_or_panic();
init_thread::slot::IO_PORT_CONTROL
.cap()
.ioport_control_issue(start_port, end_port, &cslot_to_relative_cptr(slot))?;
.ioport_control_issue(start_port, end_port, &cslot_to_absolute_cptr(slot))?;
self.set_orig_cslot(obj_id, slot);
}
}
Expand Down Expand Up @@ -445,9 +445,9 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
let nfn = match logical_nfn_cap.badge {
0 => self.orig_cap(logical_nfn_cap.object),
badge => {
let orig_cptr = self.orig_relative_cptr(logical_nfn_cap.object);
let orig_cptr = self.orig_absolute_cptr(logical_nfn_cap.object);
let slot = self.cslot_alloc_or_panic();
let cptr = cslot_to_relative_cptr(slot);
let cptr = cslot_to_absolute_cptr(slot);
cptr.mint(&orig_cptr, CapRights::all(), badge)?;
slot.cap().downcast()
}
Expand Down Expand Up @@ -785,7 +785,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().absolute_cptr(cap);
cslot_to_relative_cptr(slot).copy(&src, CapRights::all())?;
cslot_to_absolute_cptr(slot).copy(&src, CapRights::all())?;
Ok(slot.cap().downcast())
}

Expand Down Expand Up @@ -813,19 +813,19 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject
self.orig_cslot(obj_id).cap().downcast()
}

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

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

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

fn init_thread_cnode_relative_cptr() -> sel4::AbsoluteCPtr {
fn init_thread_cnode_absolute_cptr() -> sel4::AbsoluteCPtr {
init_thread::slot::CNODE.cap().absolute_cptr_for_self()
}

0 comments on commit ab0ae23

Please sign in to comment.