24#include <l4/sys/cxx/ipc_ret_array>
83 L4::Type_info::Demand_t<1> >
86 typedef L4Re::Dataspace::Offset Offset;
94 Detach_result_mask = 3,
174 friend constexpr Dataspace::Flags map_flags(Region_flags rf)
176 return Dataspace::Flags(
static_cast<l4_uint16_t>(rf) & Ds_map_mask);
183 explicit constexpr Flags(
l4_uint32_t f) : raw(f) {}
184 constexpr Flags(Attach_flags rf) : raw(static_cast<
l4_uint32_t>(rf)) {}
185 constexpr Flags(Region_flags rf) : raw(static_cast<
l4_uint32_t>(rf)) {}
187 friend constexpr Dataspace::Flags map_flags(Flags f)
189 return Dataspace::Flags(f.raw & Ds_map_mask);
192 constexpr Region_flags region_flags()
const
194 return Region_flags(raw & Region_flags_mask);
197 constexpr Attach_flags attach_flags()
const
199 return Attach_flags(raw & Attach_mask);
202 constexpr bool r()
const {
return raw &
L4_FPAGE_RO; }
203 constexpr bool w()
const {
return raw &
L4_FPAGE_W; }
204 constexpr bool x()
const {
return raw &
L4_FPAGE_X; }
205 constexpr unsigned cap_rights()
const
209 friend constexpr Flags operator | (Region_flags l, Attach_flags r)
210 {
return Flags(l) | Flags(r); }
212 friend constexpr Flags operator | (Attach_flags l, Region_flags r)
213 {
return Flags(l) | Flags(r); }
216 using Attach_flags = F::Attach_flags;
217 using Region_flags = F::Region_flags;
218 using Flags = F::Flags;
281 Flags flags = Flags(0),
283 {
return reserve_area_t::call(
c(), start, size, flags, align); }
288 unsigned char align));
305 template<
typename T >
307 Flags flags = Flags(0),
310 return reserve_area_t::call(
c(),
reinterpret_cast<l4_addr_t*
>(start), size,
329 unsigned long size, Flags flags,
331 Offset offs,
unsigned char align,
333 L4::Ipc::String<> name, Offset backing_offset));
402 char const *name =
nullptr,
403 Offset backing_offset = 0) const noexcept;
408 template< typename T >
409 long attach(T **start,
unsigned long size, Flags flags,
412 L4::Cap<
L4::Task> const task
413 =
L4::Cap<
L4::Task>::Invalid,
414 char const *name =
nullptr,
415 Offset backing_offset = 0) const noexcept
418 X *x =
reinterpret_cast<X*
>(start);
419 return attach(&x->a, size, flags, mem, offs, align, task,
420 name, backing_offset);
423#if __cplusplus >= 201103L
434 template<
typename T >
442 Unique_region(Unique_region
const &) =
delete;
443 Unique_region &operator = (Unique_region
const &) =
delete;
449 : _addr(0), _rm(
L4::Cap<
Rm>::Invalid) {}
466 : _addr(addr), _rm(rm) {}
481 Unique_region &operator = (Unique_region &&o)
noexcept
486 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
501 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
550 {
return _rm.is_valid(); }
553 T operator * () const noexcept {
return _addr; }
556 T operator -> () const noexcept {
return _addr; }
559 template<
typename T >
560 long attach(Unique_region<T> *start,
unsigned long size, Flags flags,
565 char const *name =
nullptr,
566 Offset backing_offset = 0) const noexcept
570 long res = attach(&addr, size, flags, mem, offs, align, task,
571 name, backing_offset);
575 start->reset(
reinterpret_cast<T
>(addr),
L4::Cap<Rm>(cap()));
674 {
return find_t::call(
c(), addr, size, flags, offset, m); }
678 L4Re::Rm::Flags *flags, Offset *offset,
752 Offset &backing_offset));
758 reserve_area_t, free_area_t,
759 get_regions_t, get_areas_t,
L4::Cap related definitions.
Interface for memory-like objects.
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.
long free_area(l4_addr_t addr)
Free an area from the region map.
Detach_result
Result values for detach operation.
@ Detached_ds
Detached data sapce.
@ Detach_again
Detached data space, more to do.
@ Split_ds
Splitted data space, and done.
@ Kept_ds
Kept data space.
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.
@ Caching_shift
Start of Rm cache bits.
Detach_flags
Flags for detach operation.
@ Detach_overlap
Do an unmap of all overlapping regions.
@ Detach_exact
Do an unmap of the exact region given.
@ Detach_keep
Do not free the detached data space, ignore the F::Detach_free.
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 get_regions(l4_addr_t start, L4::Ipc::Ret_array< Region > regions)
Return the list of regions whose starting addresses are higher or equal to start in the address space...
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.
long get_areas(l4_addr_t start, L4::Ipc::Ret_array< Area > areas)
Return the list of areas whose starting addresses are higher or equal to start in the address space m...
long attach(l4_addr_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, char const *name=nullptr, Offset backing_offset=0) const noexcept
Attach a data space to a region.
long get_info(l4_addr_t addr, L4::Ipc::String< char > &name, Offset &backing_offset)
Return auxiliary information of a region.
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.
@ Invalid
Invalid capability selector.
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.
L4::Cap< Class > c() const noexcept
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 flexpage.
@ L4_FPAGE_RO
Read-only flexpage.
@ L4_FPAGE_W
Writable flexpage.
@ L4_CAP_FPAGE_RO
Read right for capability flexpages.
@ L4_CAP_FPAGE_RW
Read and interface specific 'W' right for capability flexpages.
#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).
Fixed sized integer types, generic version.
Common L4 ABI Data Types.
L4 low-level kernel interface.
L4Re Protocol Constants (C version).
@ Caching_shift
shift value for caching flags
@ Uncacheable
Request uncacheable memory mappings.
@ RW
Request read-write mapping.
@ Normal
Request normal (cached) memory mapping.
@ Caching_mask
Mask for caching flags.
@ X
Request execute-only mapping.
@ R
Request read-only mapping.
@ RWX
Request read-write-execute mapping.
@ W
Request write-only mapping.
@ Bufferable
Request bufferable (write buffered) mappings.
@ RX
Request read-execute mapping.
An area is a range of virtual addresses which is reserved, see L4Re::Rm::reserve_area().
Region_flags
Region flags (permissions, cacheability, special).
@ Cache_uncached
Cache bits for uncached memory.
@ Rights_mask
Region rights.
@ Region_flags_mask
Mask of all region flags.
@ Ds_map_mask
Mask for all bits for cache options and rights.
@ Reserved
Region is reserved (blocked).
@ Pager
Region has a pager.
@ RWX
Readable, writable and executable region.
@ RW
Readable and writable region.
@ RX
Readable and executable region.
@ Detach_free
Free the portion of the data space after detach.
@ Cache_buffered
Cache bits for buffered (write combining) memory.
@ Cache_normal
Cache bits for normal cacheable memory.
@ Caching_mask
Mask of all Rm cache bits.
@ Kernel
Kernel-provided memory (KUMEM).
Attach_flags
Flags for attach operation.
@ Search_addr
Search for a suitable address range.
@ Attach_mask
Mask of all attach flags.
@ No_eager_map
Prevent eager mapping of the attached data space.
@ Eager_map
Eagerly map the attached data space in.
@ In_area
Search only in area, or map into area.
A region is a range of virtual addresses which is backed by content.
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.