L4Re Operating System Framework
Interface and Usage Documentation
|
Internal reference-counting cap allocator. More...
#include <counting_cap_alloc>
Public Member Functions | |
L4::Cap< void > | alloc () noexcept |
Allocate a new capability slot. | |
template<typename T > | |
L4::Cap< T > | alloc () noexcept |
Allocate a new capability slot. | |
void | take (L4::Cap< void > cap) noexcept |
Increase the reference counter for the capability. | |
bool | free (L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES) noexcept |
Free the capability. | |
bool | release (L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES) noexcept |
Decrease the reference counter for a capability. | |
long | last () noexcept |
Return highest capability id managed by this allocator. | |
Protected Member Functions | |
Counting_cap_alloc () noexcept | |
Create a new, empty allocator. | |
void | setup (void *m, long capacity, long bias, Dbg *dbg) noexcept |
Set up the backing memory for the allocator and the area of managed capability slots. | |
Internal reference-counting cap allocator.
This is intended for internal use only. L4Re applications should use L4Re::Util::cap_alloc().
Allocator for capability slots that automatically frees the slot and optionally unmaps the capability when the reference count goes down to zero. Reference counting must be done manually via take() and release(). The backing store for the reference counters must be provided in the setup() method. The allocator can recognize capability slots that are not managed by itself and does nothing on such slots.
Definition at line 202 of file counting_cap_alloc.
|
inlineprotectednoexcept |
Create a new, empty allocator.
Needs to be initialized with setup() before it can be used.
Definition at line 231 of file counting_cap_alloc.
|
inlinenoexcept |
Allocate a new capability slot.
Definition at line 269 of file counting_cap_alloc.
References L4_CAP_SHIFT.
Referenced by L4Re::Util::Counting_cap_alloc< COUNTERTYPE, Dbg >::alloc().
|
inlinenoexcept |
Allocate a new capability slot.
Definition at line 294 of file counting_cap_alloc.
References L4Re::Util::Counting_cap_alloc< COUNTERTYPE, Dbg >::alloc().
|
inlinenoexcept |
Free the capability.
cap | Capability to free. |
task | If set, task to unmap the capability from. |
unmap_flags | Flags for unmap, see l4_unmap_flags_t. |
Definition at line 333 of file counting_cap_alloc.
References l4_assert, l4_is_valid_cap(), and l4_task_unmap().
|
inlinenoexcept |
Decrease the reference counter for a capability.
cap | Capability to release. |
task | If set, task to unmap the capability from. |
unmap_flags | Flags for unmap, see l4_unmap_flags_t. |
Does nothing apart from returning false if the capability is not managed by this allocator.
Definition at line 371 of file counting_cap_alloc.
References l4_assert, L4_INVALID_CAP, and l4_task_unmap().
|
inlineprotectednoexcept |
Set up the backing memory for the allocator and the area of managed capability slots.
m | Pointer to backing memory. |
capacity | Number of capabilities that can be stored. |
bias | First capability id to use by this allocator. |
dbg | Logger for warnings if counter got saturated. |
The allocator will manage the capability slots between bias
and bias
+ capacity
- 1 (inclusive). It is the responsibility of the user to ensure that these slots are not used otherwise.
Definition at line 254 of file counting_cap_alloc.
|
inlinenoexcept |
Increase the reference counter for the capability.
cap | Capability, whose reference counter should be increased. |
If the capability was still free, it will be automatically allocated. Silently does nothing if the capability is not managed by this allocator.
Definition at line 308 of file counting_cap_alloc.
References L4_CAP_SHIFT, and L4_UNLIKELY.