Barrelfish
Functions
capabilities.h File Reference

Base capability/cnode handling functions. More...

Functions

__BEGIN_DECLS errval_t cnode_create (struct capref *ret_dest, struct cnoderef *cnoderef, cslot_t slots, cslot_t *retslots)
 Create a CNode from newly-allocated RAM in a newly-allocated slot. More...
 
errval_t cnode_create_foreign_l2 (struct capref dest_l1, cslot_t dest_slot, struct cnoderef *cnoderef)
 Create a CNode for another cspace from newly-allocated RAM in a newly-allocated slot. More...
 
errval_t cnode_create_l2 (struct capref *ret_dest, struct cnoderef *cnoderef)
 Create a L2 CNode from newly-allocated RAM in a newly-allocated slot. More...
 
errval_t cnode_create_raw (struct capref dest, struct cnoderef *cnoderef, enum objtype cntype, cslot_t slots, cslot_t *retslots)
 Create a CNode from newly-allocated RAM in the given slot. More...
 
errval_t cnode_create_with_guard (struct capref dest, struct cnoderef *cnoderef, cslot_t slots, cslot_t *retslots, uint64_t guard, uint8_t guard_size)
 Create CNode with a given guard. More...
 
errval_t cnode_create_from_mem (struct capref dest, struct capref src, enum objtype cntype, struct cnoderef *cnoderef, size_t slots)
 Create a CNode from a given RAM capability in a specific slot. More...
 
errval_t root_cnode_resize (struct capref new, struct capref ret)
 Replace own L1 CNode. More...
 
errval_t cap_retype (struct capref dest_start, struct capref src, gensize_t offset, enum objtype new_type, gensize_t objsize, size_t count)
 Retype (part of) a capability into one or more new capabilities. More...
 
errval_t cap_create (struct capref dest, enum objtype type, size_t bytes)
 Create a capability. More...
 
errval_t cap_delete (struct capref cap)
 Delete the given capability. More...
 
errval_t cap_revoke (struct capref cap)
 Revoke (delete all copies and descendants of) the given capability. More...
 
errval_t cap_destroy (struct capref cap)
 Destroy a capability, i.e. delete it and free the slot. More...
 
errval_t vnode_create (struct capref dest, enum objtype type)
 Create a VNode in newly-allocated memory. More...
 
errval_t frame_create (struct capref dest, size_t bytes, size_t *retbytes)
 Create a Frame cap referring to newly-allocated RAM in a given slot. More...
 
errval_t frame_alloc (struct capref *dest, size_t bytes, size_t *retbytes)
 Create a Frame cap referring to newly-allocated RAM in an allocated slot. More...
 
errval_t devframe_type (struct capref *dest, struct capref src, uint8_t bits)
 Create a DevFrame cap by retyping out of given source PhysAddr cap. More...
 
errval_t dispatcher_create (struct capref dest)
 Create a Dispatcher in newly-allocated memory. More...
 
errval_t endpoint_create (size_t buflen, struct capref *retcap, struct lmp_endpoint **retep)
 Create endpoint to caller on current dispatcher. More...
 
errval_t idcap_alloc (struct capref *dest)
 Create an ID cap in a newly allocated slot. More...
 
errval_t idcap_create (struct capref dest)
 Create an ID cap in the specified slot. More...
 
errval_t cnode_build_cnoderef (struct cnoderef *cnoder, struct capref capr)
 Builds a cnoderef struct from a capref struct using cap identification. More...
 

Detailed Description

Base capability/cnode handling functions.

Function Documentation

errval_t cap_create ( struct capref  dest,
enum objtype  type,
size_t  size 
)

Create a capability.

Parameters
destLocation where to create the cap, which must be empty.
typeKernel object type to create.
sizeSize of the created capability in bytes. (ignored for fixed-size objects)

Only certain types of capabilities can be created this way. If invoked on a capability type, that is not creatable at runtime the error SYS_ERR_TYPE_NOT_CREATABLE is returned. Most capabilities have to be retyped from other capabilities with cap_retype().

errval_t cap_delete ( struct capref  cap)

Delete the given capability.

Parameters
capCapability to be deleted

Deletes (but does not revoke) the given capability, allowing the CNode slot to be reused.

errval_t cap_destroy ( struct capref  cap)

Destroy a capability, i.e. delete it and free the slot.

Parameters
capCapability to be destroyed
errval_t cap_retype ( struct capref  dest_start,
struct capref  src,
gensize_t  offset,
enum objtype  new_type,
gensize_t  objsize,
size_t  count 
)

Retype (part of) a capability into one or more new capabilities.

Parameters
dest_startLocation of first destination slot, which must be empty
srcSource capability to retype
offsetOffset into source capability
new_typeKernel object type to retype to.
objsizeSize of created objects in bytes (ignored for fixed-size objects)
countThe number of new objects to create

When retyping IRQSrc capabilities, offset and objsize represent the start and end of the to be created interrupt range. Count must be 1 for IRQSrc.

Retypes (part of) the given source capability into a number of new capabilities, which may be of the same or of different type. The new capabilities are created in the slots starting from dest_start, which must all be empty and lie in the same CNode. The number of objects created is determined by the argument count.

errval_t cap_revoke ( struct capref  cap)

Revoke (delete all copies and descendants of) the given capability.

Parameters
capCapability to be revoked

Deletes all copies and descendants of the given capability, but not the capability itself. If this succeeds, the capability is guaranteed to be the only copy in the system.

errval_t cnode_build_cnoderef ( struct cnoderef cnoder,
struct capref  capr 
)

Builds a cnoderef struct from a capref struct using cap identification.

Parameters
cnoderPointer to a cnoderef struct, fill-in by function.
caprCapref to a CNode capability.
__BEGIN_DECLS errval_t cnode_create ( struct capref ret_dest,
struct cnoderef cnoderef,
cslot_t  slots,
cslot_t *  retslots 
)

Create a CNode from newly-allocated RAM in a newly-allocated slot.

Parameters
ret_destcapref struct to be filled-in with location of CNode
cnoderefcnoderef struct, filled-in if non-NULL with relevant info
slotsMinimum number of slots in created CNode
retslotsIf non-NULL, filled in with the number of slots in created CNode
errval_t cnode_create_foreign_l2 ( struct capref  dest_l1,
cslot_t  dest_slot,
struct cnoderef cnoderef 
)

Create a CNode for another cspace from newly-allocated RAM in a newly-allocated slot.

Parameters
dest_l1capref to L1 (root) cnode of destination cspace
dest_slotslot to fill with new cnode in destination L1 cnode
cnoderefcnoderef struct, filled-in if non-NULL with relevant info

This function creates a CNode which contains 256 capabilities initially and puts it in a slot in our cspace.

errval_t cnode_create_from_mem ( struct capref  dest,
struct capref  src,
enum objtype  cntype,
struct cnoderef cnoderef,
size_t  slots 
)

Create a CNode from a given RAM capability in a specific slot.

Parameters
destlocation in which to place newly-created CNode cap
srclocation of RAM capability to be retyped to new CNode
cnoderefcnoderef struct, filled-in if non-NULL with relevant info
slotsnumber of slots in created CNode must match size of RAM capability.

This function requires that dest refer to an existing but empty slot. It retypes the given memory to a new CNode.

errval_t cnode_create_l2 ( struct capref ret_dest,
struct cnoderef cnoderef 
)

Create a L2 CNode from newly-allocated RAM in a newly-allocated slot.

Parameters
ret_destcapref struct to be filled-in with location of CNode
cnoderefcnoderef struct, filled-in if non-NULL with relevant info

This function always creates a L2 CNode which contains 256 capabilities

errval_t cnode_create_raw ( struct capref  dest,
struct cnoderef cnoderef,
enum objtype  cntype,
cslot_t  slots,
cslot_t *  retslots 
)

Create a CNode from newly-allocated RAM in the given slot.

Parameters
destlocation in which to place CNode cap
cnoderefcnoderef struct, filled-in if non-NULL with relevant info
cntype,typeof new cnode
slotsMinimum number of slots in created CNode
retslotsIf non-NULL, filled in with the number of slots in created CNode

This function requires that dest refer to an existing but empty slot. It allocates memory (using ram_alloc), and retypes that memory to a new CNode. The intermediate ram cap is destroyed.

errval_t cnode_create_with_guard ( struct capref  dest,
struct cnoderef cnoderef,
cslot_t  slots,
cslot_t *  retslots,
uint64_t  guard,
uint8_t  guard_size 
)

Create CNode with a given guard.

Parameters
destLocation where to place the cnode
cnoderefFilled in cnoderef struct if non-NULL
slotsMinimum number of slots in created CNode
retslotsIf non-NULL, filled in with the number of slots in created CNode
guardThe guard value to set
guard_sizeThe length of the guard in bits

This function requires that dest refer to an existing but empty slot. It allocates memory (using ram_alloc), and retypes that memory to a new CNode with the given guard value and size. An intermediate slot is used in order to set the guard value.

errval_t devframe_type ( struct capref dest,
struct capref  src,
uint8_t  bits 
)

Create a DevFrame cap by retyping out of given source PhysAddr cap.

Parameters
destPointer to capref struct, filled-in with location of new cap
srcCap_info struct for the source PhysAddr cap
size_bitsSize of created objects as a power of two (ignored for fixed-size objects)
errval_t dispatcher_create ( struct capref  dest)

Create a Dispatcher in newly-allocated memory.

Parameters
destlocation to place new dispatcher cap

This function requires that dest refer to an existing but empty slot. It does not map in nor initialise the Dispatcher. The intermediate ram cap is destroyed.

errval_t endpoint_create ( size_t  buflen,
struct capref retcap,
struct lmp_endpoint **  retep 
)

Create endpoint to caller on current dispatcher.

Parameters
buflenLength of incoming LMP buffer, in words
retcapPointer to capref struct, filled-in with location of cap
retepDouble pointer to LMP endpoint, filled-in with allocated EP
errval_t frame_alloc ( struct capref dest,
size_t  bytes,
size_t *  retbytes 
)

Create a Frame cap referring to newly-allocated RAM in an allocated slot.

Parameters
destPointer to capref struct, filled-in with location of new cap
bytesMinimum size of frame to create
retbytesIf non-NULL, filled in with size of created frame
errval_t frame_create ( struct capref  dest,
size_t  bytes,
size_t *  retbytes 
)

Create a Frame cap referring to newly-allocated RAM in a given slot.

Parameters
destLocation to place new frame cap
bytesMinimum size of frame to create
retbytesIf non-NULL, filled in with size of created frame

This function requires that dest refer to an existing but empty slot. ram_alloc is used to allocate memory. After retyping the intermediate ram cap is destroyed.

This function will returns a special error code if ram_alloc fails due to the constrains on the memory server (size of cap or region of memory). This is to facilitate retrying with different constraints.

errval_t idcap_alloc ( struct capref dest)

Create an ID cap in a newly allocated slot.

Parameters
destPointer to capref struct, filld-in with location of new cap.

The caller is responsible for revoking the cap after using it.

errval_t idcap_create ( struct capref  dest)

Create an ID cap in the specified slot.

Parameters
destCapref, where ID cap should be created.

The caller is responsible for revoking the cap after using it.

errval_t root_cnode_resize ( struct capref  new,
struct capref  ret 
)

Replace own L1 CNode.

Parameters
newthe replacement L1 CNode
retthe slot to put the old L1 CNode
errval_t vnode_create ( struct capref  dest,
enum objtype  type 
)

Create a VNode in newly-allocated memory.

Parameters
destlocation to place new VNode cap
typeVNode type to create

This function requires that dest refer to an existing but empty slot. The intermidiate ram cap is destroyed.