Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ virtual CPU with ID `vcpu`.
Write the registers of a given virtual CPU with ID `vcpu`. The `regs` argument is the pointer to
the struct of registers `seL4_VCPUContext` that are written from.

## `seL4_CPtr microkit_cspace_slot_to_cptr(seL4_Word slot)` {#libmicrokit_cspace_slot_to_cptr}
## `seL4_CPtr microkit_cspace_root_slot_to_cptr(seL4_Word slot)` {#libmicrokit_cspace_root_slot_to_cptr}

Converts the slot identifier of the `<cspace>`'s capability element into an
`seL4_CPtr` value to be used in `libsel4` calls by the PD.
Expand Down Expand Up @@ -1148,7 +1148,7 @@ It supports no attributes, but supports the following elements as children:
* `cap_cspace`: A capability to a protection domain's CSpace.

All of the elements support the `slot` attribute, which is is an opaque identifier used to address the capability at runtime.
To convert the `slot` to an `seL4_CPtr`, use the [`seL4_CPtr microkit_cspace_slot_to_cptr(seL4_Word slot)`](#libmicrokit_cspace_slot_to_cptr) function.
To convert the `slot` to an `seL4_CPtr`, use the [`seL4_CPtr microkit_cspace_root_slot_to_cptr(seL4_Word slot)`](#libmicrokit_cspace_root_slot_to_cptr) function.

See the 'cap_sharing' example packaged in your SDK or [on GitHub](https://github.com/seL4/microkit/tree/main/example/cap_sharing).

Expand Down
8 changes: 4 additions & 4 deletions example/cap_sharing/cap_sharing.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#define CH_SECONDARY ((microkit_channel)0)

// As per cap_sharing.system
#define CAP_SECONDARY_SC (microkit_cspace_slot_to_cptr(1))
#define CAP_SECONDARY_TCB (microkit_cspace_slot_to_cptr(2))
#define CAP_MY_SC (microkit_cspace_slot_to_cptr(3))
#define CAP_MY_TCB (microkit_cspace_slot_to_cptr(4))
#define CAP_SECONDARY_SC (microkit_cspace_root_slot_to_cptr(1))
#define CAP_SECONDARY_TCB (microkit_cspace_root_slot_to_cptr(2))
#define CAP_MY_SC (microkit_cspace_root_slot_to_cptr(3))
#define CAP_MY_TCB (microkit_cspace_root_slot_to_cptr(4))

static void halt(void)
{
Expand Down
2 changes: 1 addition & 1 deletion libmicrokit/include/microkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static inline void microkit_deferred_irq_ack(microkit_channel ch)
* If the slot exceeds the valid range of inputs (0 <= slot < MICROKIT_MAX_USER_CAPS),
* it returns the value `seL4_CapNull`.
**/
static inline seL4_CPtr microkit_cspace_slot_to_cptr(seL4_Word slot)
static inline seL4_CPtr microkit_cspace_root_slot_to_cptr(seL4_Word slot)
{
if (slot > MICROKIT_MAX_USER_CAPS) {
Comment on lines +519 to 521

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, shouldn't this be:

if (slot >= MICROKIT_MAX_USER_CAPS) {

return seL4_CapNull;
Expand Down
Loading