[Barrelfish-users] capref or capability?
Simon Gerber
simon.gerber at inf.ethz.ch
Wed Jul 26 10:18:36 CEST 2017
Hi Jingmei,
The function that returns a struct capability given a struct capref is called debug_cap_identify() and can be found in lib/barrelfish/debug.c. The debug_cap_identify() function should be used sparingly, as it is almost never necessary to read the whole struct capability in a regular user application except for debugging purposes or in the rare case where it's necessary to dynamically determine the type of a received capability as we're currently missing a function that returns type information given a struct capref.
The function that takes a capref and returns the base and size of the capability is called frame_identify() and can be found in lib/barrelfish/capabilities.c.
A capaddr_t is the 32 bit concatenation of the indices of a capability slot in a cspace. A cspace in turn is a two-level table which stores the capabilities of a domain. As you may have already figured out, a cspace is constructed from a (dynamically resizable) L1 or root CNode, and a number of fixed-size, 256 slot L2 CNodes.
A capref is just a different encoding of a capaddr_t that eliminates the need to have complicated case distinctions on every capability invocation. A cnoderef is one element of a capref and provides the information necessary to understand how to translate a capref to a capaddr_t. See include/barrelfish/caddr.h for the details. Particularly useful functions are capaddr_t get_cap_addr(struct capref cap); capaddr_t get_cnode_addr(struct capref cap), which are used to translate the abstract caprefs into capaddr_t for regular capabilities and CNodes respectively.
Note that all kernel functions to do with capabilities are invocations of those capabilities and that the kernel interface always takes capaddr_t arguments of all the involved capabilities. The struct capref and struct cnoderef types are only ever used in user space.
I hope this answers your questions.
Best,
-- Simon
On 25.07.2017 22:51, Hu, Jingmei wrote:
> Hi Barrelfish Users,
>
> We have some questions regarding the data types involved in capability handling: capref, cnoderef, and capaddr_t. We were wondering if there exists a kernel function that takes a capref struct as an input and returns its corresponding capability struct, or one that gives a capability's physical address given its capaddr_t. Are there conventions regarding the uses of these data types generally?
>
> Thanks a lot,
> Jingmei
>
>
> _______________________________________________
> Barrelfish-users mailing list
> Barrelfish-users at lists.inf.ethz.ch
> https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users
>
More information about the Barrelfish-users
mailing list