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,
125 friend void enum_bitops_enable(Attach_flags);
172 friend void enum_bitops_enable(Region_flags);
174 friend constexpr Dataspace::Flags map_flags(Region_flags rf)
175 {
return Dataspace::Flags(
static_cast<l4_uint16_t>(rf) & Ds_map_mask); }
182 explicit constexpr Flags(
l4_uint32_t f) : raw(f) {}
183 constexpr Flags(Attach_flags af) : raw(static_cast<
l4_uint32_t>(af)) {}
184 constexpr Flags(Region_flags rf) : raw(static_cast<
l4_uint32_t>(rf)) {}
186 constexpr Dataspace::Flags map_flags()
const
187 {
return Dataspace::Flags(raw & Ds_map_mask); }
189 constexpr Region_flags region_flags()
const
190 {
return Region_flags(raw & Region_flags_mask); }
192 constexpr Attach_flags attach_flags()
const
193 {
return Attach_flags(raw & Attach_mask); }
195 constexpr bool r()
const {
return raw &
L4_FPAGE_RO; }
196 constexpr bool w()
const {
return raw &
L4_FPAGE_W; }
197 constexpr bool x()
const {
return raw &
L4_FPAGE_X; }
199 constexpr unsigned cap_rights()
const
203 friend constexpr Flags
operator | (Region_flags l, Attach_flags r)
204 {
return Flags(l) | Flags(r); }
206 friend constexpr Flags
operator | (Attach_flags l, Region_flags r)
207 {
return Flags(l) | Flags(r); }
210 using Attach_flags = F::Attach_flags;
211 using Region_flags = F::Region_flags;
212 using Flags = F::Flags;
277 Flags flags = Flags(0),
279 {
return reserve_area_t::call(
c(), start, size, flags, align); }
284 unsigned char align));
305 Flags flags = Flags(0),
308 return reserve_area_t::call(
c(),
reinterpret_cast<l4_addr_t*
>(start), size,
328 unsigned long size, Flags flags,
330 Offset offs,
unsigned char align,
332 L4::Ipc::String<> name, Offset backing_offset));
401 char const *name =
nullptr,
402 Offset backing_offset = 0) const noexcept;
408 long attach(T **start,
unsigned long size, Flags flags,
411 L4::Cap<
L4::Task> const task
412 =
L4::Cap<
L4::Task>::Invalid,
413 char const *name =
nullptr,
414 Offset backing_offset = 0) const noexcept
417 X *x =
reinterpret_cast<X*
>(start);
418 return attach(&x->a, size, flags, mem, offs, align, task,
419 name, backing_offset);
422#if __cplusplus >= 201103L
441 Unique_region(Unique_region
const &) =
delete;
442 Unique_region &operator = (Unique_region
const &) =
delete;
448 : _addr(0), _rm(
L4::Cap<
Rm>::Invalid) {}
465 : _addr(addr), _rm(rm) {}
480 Unique_region &operator = (Unique_region &&o)
noexcept
485 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
500 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
549 {
return _rm.is_valid(); }
552 T operator * () const noexcept {
return _addr; }
555 T operator -> () const noexcept {
return _addr; }
559 long attach(Unique_region<T> *start,
unsigned long size, Flags flags,
564 char const *name =
nullptr,
565 Offset backing_offset = 0) const noexcept
569 long res = attach(&addr, size, flags, mem, offs, align, task,
570 name, backing_offset);
574 start->reset(
reinterpret_cast<T
>(addr),
L4::Cap<Rm>(cap()));
673 {
return find_t::call(
c(), addr, size, flags, offset, m); }
677 L4Re::Rm::Flags *flags, Offset *offset,
750 Offset &backing_offset));
756 reserve_area_t, free_area_t,
757 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.
constexpr T operator|(T l, T r) noexcept
Union enum values.
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.