30#include <l4/sys/l4int.h>
35#include <l4/sys/cxx/ipc_ret_array>
94 L4::Type_info::Demand_t<1> >
97 typedef L4Re::Dataspace::Offset Offset;
105 Detach_result_mask = 3,
115 Caching_shift = Dataspace::F::Caching_shift,
125 Search_addr = 0x20000,
131 No_eager_map = 0x100000,
133 Attach_mask = 0x1f0000,
150 RW = Dataspace::F::RW,
152 RX = Dataspace::F::RX,
154 RWX = Dataspace::F::RWX,
165 Caching_mask = Dataspace::F::Caching_mask,
167 Cache_normal = Dataspace::F::Normal,
169 Cache_buffered = Dataspace::F::Bufferable,
171 Cache_uncached = Dataspace::F::Uncacheable,
177 Region_flags_mask = 0xffff,
182 friend constexpr Dataspace::Flags map_flags(
Region_flags rf)
184 return Dataspace::Flags(
static_cast<l4_uint16_t>(rf) & Ds_map_mask);
191 explicit constexpr Flags(
l4_uint32_t f) : raw(f) {}
192 constexpr Flags(Attach_flags rf) : raw(static_cast<
l4_uint32_t>(rf)) {}
193 constexpr Flags(Region_flags rf) : raw(static_cast<
l4_uint32_t>(rf)) {}
195 friend constexpr Dataspace::Flags map_flags(Flags f)
197 return Dataspace::Flags(f.raw & Ds_map_mask);
200 constexpr Region_flags region_flags()
const
202 return Region_flags(raw & Region_flags_mask);
205 constexpr Attach_flags attach_flags()
const
207 return Attach_flags(raw & Attach_mask);
210 constexpr bool r()
const {
return raw &
L4_FPAGE_RO; }
211 constexpr bool w()
const {
return raw &
L4_FPAGE_W; }
212 constexpr bool x()
const {
return raw &
L4_FPAGE_X; }
213 constexpr unsigned cap_rights()
const
217 friend constexpr Flags operator | (Region_flags l, Attach_flags r)
218 {
return Flags(l) | Flags(r); }
220 friend constexpr Flags operator | (Attach_flags l, Region_flags r)
221 {
return Flags(l) | Flags(r); }
224 using Attach_flags = F::Attach_flags;
225 using Region_flags = F::Region_flags;
226 using Flags = F::Flags;
289 Flags flags = Flags(0),
291 {
return reserve_area_t::call(c(), start, size, flags, align); }
296 unsigned char align));
313 template<
typename T >
315 Flags flags = Flags(0),
318 return reserve_area_t::call(c(),
reinterpret_cast<l4_addr_t*
>(start), size,
337 unsigned long size, Flags flags,
339 Offset offs,
unsigned char align,
401 long attach(
l4_addr_t *start,
unsigned long size, Flags flags,
410 template<
typename T >
411 long attach(T **start,
unsigned long size, Flags flags,
418 X *x =
reinterpret_cast<X*
>(start);
419 return attach(&x->a, size, flags, mem, offs, align, task);
422#if __cplusplus >= 201103L
433 template<
typename T >
448 : _addr(0), _rm(
L4::Cap<
Rm>::Invalid) {}
465 : _addr(addr), _rm(rm) {}
485 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
500 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
552 T operator * () const noexcept {
return _addr; }
555 T operator -> () const noexcept {
return _addr; }
558 template<
typename T >
559 long attach(Unique_region<T> *start,
unsigned long size, Flags flags,
567 long res = attach(&addr, size, flags, mem, offs, align, task);
571 start->reset(
reinterpret_cast<T
>(addr),
L4::Cap<Rm>(cap()));
670 {
return find_t::call(c(), addr, size, flags, offset, m); }
674 L4Re::Rm::Flags *flags, Offset *offset,
740 reserve_area_t, free_area_t,
741 get_regions_t, get_areas_t>
Rpcs;
748{
return detach(addr, 1, mem, task, Detach_overlap); }
754 return detach(
reinterpret_cast<l4_addr_t>(addr), 1, mem, task,
761{
return detach(addr, size, mem, task, Detach_exact); }
L4::Cap related definitions.
Unique_region(T addr) noexcept
Construct a Unique_region from an address.
Unique_region(Unique_region &&o) noexcept
Move-Construct a Unique_region
T get() const noexcept
Return the address.
void reset() noexcept
Make the Unique_region invalid.
bool is_valid() const noexcept
Check if the Unique_region is valid.
void reset(T addr, L4::Cap< Rm > const &rm) noexcept
Set new address and region manager.
Unique_region() noexcept
Construct an invalid Unique_region
~Unique_region() noexcept
Destructor.
Unique_region(T addr, L4::Cap< Rm > const &rm) noexcept
Construct a valid Unique_region from an address and a region manager.
T release() noexcept
Return the address and invalidate the Unique_region
Detach_result
Result values for detach operation.
long reserve_area(T **start, unsigned long size, Flags flags=Flags(0), unsigned char align=L4_PAGESHIFT) const noexcept
Reserve the given area in the region map.
Region_flag_shifts
Region flag shifts.
long attach(T **start, unsigned long size, Flags flags, L4::Ipc::Cap< Dataspace > mem, Offset offs=0, unsigned char align=L4_PAGESHIFT, L4::Cap< L4::Task > const task=L4::Cap< L4::Task >::Invalid) const noexcept
Attach a data space to a region.
Detach_flags
Flags for detach operation.
long reserve_area(l4_addr_t *start, unsigned long size, Flags flags=Flags(0), unsigned char align=L4_PAGESHIFT) const noexcept
Reserve the given area in the region map.
long find(l4_addr_t *addr, unsigned long *size, Offset *offset, L4Re::Rm::Flags *flags, L4::Cap< Dataspace > *m) noexcept
Find a region given an address and size.
int detach(l4_addr_t addr, L4::Cap< Dataspace > *mem, L4::Cap< L4::Task > const &task=This_task) const noexcept
Detach and unmap a region from the address space.
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
C++ interface for capabilities.
Capability type for RPC interfaces (see L4::Cap<T>).
Helper class to create an L4Re interface class that is derived from a single base class.
unsigned long l4_addr_t
Address type.
unsigned int l4_uint32_t
Unsigned 32bit value.
unsigned short int l4_uint16_t
Unsigned 16bit value.
unsigned long l4_cap_idx_t
Capability selector type.
@ L4_FPAGE_X
Executable flex page.
@ L4_FPAGE_RO
Read-only flex page
@ L4_FPAGE_W
Writable flex page.
@ L4_CAP_FPAGE_RO
Read right for capability flex-pages.
@ L4_CAP_FPAGE_RW
Read and interface specific 'W' right for capability flex-pages.
#define L4_PAGESHIFT
Size of a page, log2-based.
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
Interface Definition Language.
#define L4_RPC(res, name, args, attr...)
Define an RPC call (type and callable).
#define L4_RPC_NF(res, name, args...)
Define an RPC call type (the type only, no callable).
Common L4 ABI Data Types.
L4 low-level kernel interface.
L4Re Protocol Constants (C version)
Region_flags
Region flags (permissions, cacheability, special).
Attach_flags
Flags for attach operation.
A range of virtual addresses.
l4_addr_t start
First address of the range.
l4_addr_t end
Last address of the range.
Pass the argument as plain data value.
Mark an argument as in-out argument.
Attribute for defining an optional RPC argument.
Dynamically sized output array of type T.
Standard list of RPCs of an interface.
Mixin class to define a set of friend bitwise operators on DT.
#define L4_TYPES_FLAGS_OPS_DEF(T)
Helper macro to define a set of bitwise operators on an enum type.