24#include <l4/sys/cxx/ipc_array>
83 L4::Type_info::Demand_t<1> >
86 typedef L4Re::Dataspace::Offset Offset;
94 Detach_result_mask = 3,
127 friend void enum_bitops_enable(Attach_flags);
180 friend void enum_bitops_enable(Region_flags);
182 friend constexpr Dataspace::Flags map_flags(Region_flags rf)
183 {
return Dataspace::Flags(
static_cast<l4_uint16_t>(rf) & Ds_map_mask); }
190 explicit constexpr Flags(
l4_uint32_t f) : raw(f) {}
191 constexpr Flags(Attach_flags af) : raw(static_cast<
l4_uint32_t>(af)) {}
192 constexpr Flags(Region_flags rf) : raw(static_cast<
l4_uint32_t>(rf)) {}
194 constexpr Dataspace::Flags map_flags()
const
195 {
return Dataspace::Flags(raw & Ds_map_mask); }
197 constexpr Region_flags region_flags()
const
198 {
return Region_flags(raw & Region_flags_mask); }
200 constexpr Attach_flags attach_flags()
const
201 {
return Attach_flags(raw & Attach_mask); }
203 constexpr bool r()
const {
return raw &
L4_FPAGE_RO; }
204 constexpr bool w()
const {
return raw &
L4_FPAGE_W; }
205 constexpr bool x()
const {
return raw &
L4_FPAGE_X; }
207 constexpr unsigned cap_rights()
const
211 friend constexpr Flags
operator | (Region_flags l, Attach_flags r)
212 {
return Flags(l) | Flags(r); }
214 friend constexpr Flags
operator | (Attach_flags l, Region_flags r)
215 {
return Flags(l) | Flags(r); }
218 using Attach_flags = F::Attach_flags;
219 using Region_flags = F::Region_flags;
220 using Flags = F::Flags;
276 Flags flags = Flags(0),
278 {
return reserve_area_t::call(
c(), start, size, flags, align); }
283 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));
398 char const *name =
nullptr,
399 Offset backing_offset = 0) const noexcept;
408 L4::Cap<
L4::Task> const task
409 =
L4::Cap<
L4::Task>::Invalid,
410 char const *name =
nullptr,
411 Offset backing_offset = 0) const noexcept
414 X *x =
reinterpret_cast<X*
>(start);
415 return attach(&x->a, size, flags, mem, offs, align, task,
416 name, backing_offset);
419#if __cplusplus >= 201103L
438 Unique_region(Unique_region
const &) =
delete;
439 Unique_region &operator = (Unique_region
const &) =
delete;
445 : _addr(0), _rm(
L4::Cap<
Rm>::Invalid) {}
462 : _addr(addr), _rm(rm) {}
477 Unique_region &operator = (Unique_region &&o)
noexcept
482 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
497 _rm->detach(
reinterpret_cast<l4_addr_t>(_addr), 0);
546 {
return _rm.is_valid(); }
549 T operator * () const noexcept {
return _addr; }
552 T operator -> () const noexcept {
return _addr; }
554 explicit operator bool() const noexcept
555 {
return is_valid(); }
559 l4_ret_t 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()));
597 L4::Cap<L4::Task>
const &task = This_task)
const noexcept;
602 l4_ret_t detach(
void *addr, L4::Cap<Dataspace> *mem,
603 L4::Cap<L4::Task>
const &task = This_task)
const noexcept;
625 L4::Cap<L4::Task>
const &task = This_task)
const noexcept;
675 l4_ret_t ret = find_t::call(
c(), addr, size, flags, offset, &ds_idx);
683 L4Re::Rm::Flags *flags, Offset *offset,
757 Offset &backing_offset));
848 Region_flags rights);
879 reserve_area_t, free_area_t,
880 get_regions_t, get_areas_t,
881 get_info_t, add_rescue_jump_t,
882 remove_rescue_jump_t, page_in_t>
Rpcs;
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.
l4_ret_t get_regions(l4_addr_t start, L4::Ipc::Array_ref< Region > ®ions)
Return the list of regions whose starting addresses are higher or equal to start in the address space...
l4_ret_t add_rescue_jump(l4_addr_t pc_begin, l4_addr_t pc_end, l4_addr_t rescue_pc)
Register a rescue jump for a range of program counters.
l4_ret_t 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.
l4_ret_t free_area(l4_addr_t addr)
Free an area from the region map.
Detach_result
Result values for detach operation.
@ Detached_ds
Detached data space.
@ Unmapped_range
The region mananager has already unmapped the pages.
@ Detach_again
Detached data space, more to do.
@ Split_ds
Split data space, and done.
@ Kept_ds
Kept data space.
l4_ret_t page_in(l4_addr_t start, unsigned long size, Region_flags rights, L4::Cap< L4::Task > dst=L4::Cap< L4::Task >::Invalid) const noexcept
Allocate and map pages for the given region.
Region_flag_shifts
Region flag shifts.
@ Caching_shift
Start of Rm cache bits.
l4_ret_t 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_areas(l4_addr_t start, L4::Ipc::Array_ref< Area > &areas)
Return the list of areas whose starting addresses are higher or equal to start in the address space m...
l4_ret_t(* page_in_fn)(l4_addr_t min_addr, l4_addr_t max_addr, Region_flags rights)
In-thread eager paging function.
l4_ret_t 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.
l4_ret_t 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.
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.
L4::Typeid::Rpcs< attach_t, detach_t, find_t, reserve_area_t, free_area_t, get_regions_t, get_areas_t, get_info_t, add_rescue_jump_t, remove_rescue_jump_t, page_in_t > Rpcs
Eager paging RPC call.
l4_ret_t get_info(l4_addr_t addr, L4::Ipc::String< char > &name, Offset &backing_offset)
Return auxiliary information of a region.
l4_ret_t remove_rescue_jump(l4_addr_t pc)
Remove a previously registered rescue jump.
l4_ret_t 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.
@ Invalid
Invalid capability selector.
C++ interface for capabilities.
Capability type for RPC interfaces (see L4::Cap<T>).
Send item or return item.
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_int16_t l4_ret_t
Return value of an IPC call as well as an RPC call.
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.
@ Private
Attach the dataspace privately with copy-on-write semantics.
@ 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.
@ Cache_buffered
Cache bits for buffered (write combining) memory.
@ Cache_normal
Cache bits for normal cacheable memory.
@ Anonymous
Attach anonymous memory in the region.
@ 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.
Array reference data type for arrays located in the message.
Mark an argument as in-out argument.
Attribute for defining an optional RPC argument.
Standard list of RPCs of an interface.
Mixin class to define a set of friend bitwise operators on DT.