How to access a capability from an AbsoluteCPtr
I have a project where the number of capabilities created exceeds the number of root CNode slots. Therefore, I need to create nested CNodes to store more caps. I'm unsure how to get from an AbsoluteCPtr pointing to a specific slot in a nested CNode to the Cap itself. I tried the following,
`let cnode = root.create_variable_size_capability::sel4::cap_type::CNode(4); // this is essentially the same as an ObjectAllocator
cnode.relative_bits_with_depth(0, 4).mint( &sel4::init_thread::slot::CNODE.cap().relative(test_endpoint), sel4::CapRights::all(), 0, ).unwrap();
let endpoint = sel4::cap::Endpoint::from_bits(cnode.relative_bits_with_depth(0, 4).path().bits());
endpoint.send(sel4::MessageInfo::new(0, 0, 0, 0));`
However, this throws back a null cap warning. I am looking through the documentation and I cannot find a way. How could I achieve this?
An alternative is to increase the size with the config option KernelRootCNodeSizeBits (default is 12).
Going from a 1-level CSpace to a 2-level CSpace is not trivial. Edit: But if you just need a space to park caps without direct access, you can create sub CNodes and clean up cap space by moving caps into that. I'm not familiar enough with the Rust binding to know how to do that exactly, but the principles are explained in the seL4 manual in the "Capability Spaces" chapter.
Where can I find KernelRootCNodeSizeBits to configure my enviroment?
During the kernel build, if you're using ccmake, it's under advanced settings (Toggle advanced mode).
If you're using a .cmake file you should be able to set it via e.g.
set(KernelRootCNodeSizeBits 19 CACHE STRING "")
One of the verified configs has an example.