30#include <l4/cxx/type_traits>
57 virtual
void take(
L4::Cap<
void> cap) noexcept = 0;
63 template< typename T >
65 {
return L4::cap_cast<T>(
alloc()); }
88 template<
typename CAP_ALLOC >
95 L4::Cap<void> alloc()
noexcept override {
return _ca.alloc(); }
96 void take(
L4::Cap<void> cap)
noexcept override { _ca.take(cap); }
100 { _ca.free(cap, task, unmap_flags); }
103 unsigned unmap_flags)
noexcept override
104 {
return _ca.release(cap, task, unmap_flags); }
106 void operator delete(
void *) {}
108 CA(CAP_ALLOC &ca) : _ca(ca) {}
116template<
typename ALLOC>
119 template<
typename ...ARGS>
120 Cap_alloc_t(ARGS &&...args) : ALLOC(
cxx::forward<ARGS>(args)...) {}
122 L4::Cap<void> alloc() noexcept
override {
return ALLOC::alloc(); }
123 void take(
L4::Cap<void> cap)
noexcept override { ALLOC::take(cap); }
127 { ALLOC::free(cap, task, unmap_flags); }
130 unsigned unmap_flags)
noexcept override
131 {
return ALLOC::release(cap, task, unmap_flags); }
133 void operator delete(
void *) {}
146template<
unsigned long Unmap_flags = L4_FP_ALL_SPACES >
175template<
unsigned long Unmap_flags = L4_FP_ALL_SPACES >
192 if (_ca && _ca->release(
L4::Cap<void>(c.cap()), This_task, Unmap_flags))
Capability allocator interface.
virtual L4::Cap< void > alloc() noexcept=0
Allocate a capability.
static L4Re::Cap_alloc * get_cap_alloc(CAP_ALLOC &ca)
Construct an instance of a capability allocator.
virtual void free(L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES) noexcept=0
Free a capability.
Helper for Unique_cap and Unique_del_cap.
Helper for Ref_cap and Ref_del_cap.
L4::Cap_base copy(L4::Cap_base const &src)
Copy operation for L4::Smart_cap (increment ref count).
void free(L4::Cap_base &c) noexcept
Free operation for L4::Smart_cap (decrement ref count and delete if 0).
static void invalidate(L4::Cap_base &c) noexcept
Invalidate operation for L4::Smart_cap.
Base class for all kinds of capabilities.
void invalidate() noexcept
Set this capability to invalid (L4_INVALID_CAP).
l4_cap_idx_t cap() const noexcept
Return capability selector.
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
C++ interface for capabilities.
unsigned long l4_cap_idx_t
Capability selector type.
@ L4_INVALID_CAP
Invalid capability selector.
@ L4_FP_ALL_SPACES
Flag to tell the unmap operation to revoke permissions from all child mappings including the mapping ...
virtual ~Cap_alloc()=0
Destructor.
L4 low-level kernel interface.
Common task related definitions.