15#include <l4/bid_config.h>
17#include <l4/cxx/minmax>
19#include <l4/sys/cxx/ipc_legacy>
37 Dataspace_svr() noexcept
42 virtual ~Dataspace_svr()
noexcept {}
58 Dataspace::Map_addr local_addr,
59 Dataspace::Flags flags,
60 Dataspace::Map_addr min_addr,
61 Dataspace::Map_addr max_addr,
69 if (!check_limit(offset))
72 printf(
"limit failed: off=%lx sz=%lx\n", offset, size());
86 if (map_base < _ds_start)
89 if (map_base + (1UL << (order + 1)) -1 > (_ds_start + round_size() - 1))
93 if (map_base < min_addr)
96 if (map_base + (1UL << (order + 1)) -1 > max_addr -1)
100 if (local_addr == ~0UL || ((addr ^ local_addr) & mask))
108 Dataspace::Map_addr b = map_base;
109 unsigned send_order = order;
137 [[maybe_unused]]
unsigned order,
138 [[maybe_unused]] Dataspace::Flags flags,
139 [[maybe_unused]] Dataspace::Map_addr *base,
140 [[maybe_unused]]
unsigned *send_order)
178 [[maybe_unused]]
unsigned long size)
noexcept
192 virtual l4_ret_t clear(
unsigned long offs,
unsigned long size)
const noexcept
194 if (!check_limit(offs))
197 size = cxx::min(size, round_size() - offs);
198 memset(
reinterpret_cast<void *
>(_ds_start + offs), 0, size);
215 [[maybe_unused]]
unsigned access)
noexcept
249 [[maybe_unused]]
l4_addr_t &end_addr)
noexcept
253 l4_ret_t op_map(L4Re::Dataspace::Rights rights,
254 L4Re::Dataspace::Offset offset,
255 L4Re::Dataspace::Map_addr spot,
256 L4Re::Dataspace::Flags flags,
259 auto rf = map_flags(rights);
260 if (!rf.w() && flags.w())
263 return map(offset, spot, flags & rf, 0, ~0, fp);
266 l4_ret_t op_allocate(L4Re::Dataspace::Rights rights,
267 L4Re::Dataspace::Offset offset,
268 L4Re::Dataspace::Size size)
269 {
return allocate(offset, size, rights & 3); }
271 l4_ret_t op_copy_in(L4Re::Dataspace::Rights rights,
272 L4Re::Dataspace::Offset dst_offs,
274 L4Re::Dataspace::Offset src_offs,
275 L4Re::Dataspace::Size sz)
286 return copy(dst_offs, src_cap.
data(), src_offs, sz);
289 l4_ret_t op_info(L4Re::Dataspace::Rights rights, L4Re::Dataspace::Stats &s)
293 s.
flags = Dataspace::Flags(0);
294 if (map_flags(rights).w())
299 l4_ret_t op_clear(L4Re::Dataspace::Rights rights,
300 L4Re::Dataspace::Offset offset,
301 L4Re::Dataspace::Size size)
303 if (!map_flags(rights).w())
306 return clear(offset, size);
309 l4_ret_t op_map_info(L4Re::Dataspace::Rights,
316 return map_info(start_addr, end_addr);
321 unsigned long size() const noexcept
323 unsigned long map_flags() const noexcept
324 {
return _map_flags; }
325 unsigned long page_size() const noexcept
327 unsigned long round_size() const noexcept
329 bool check_limit(
l4_addr_t offset)
const noexcept
330 {
return offset < round_size(); }
332 L4Re::Dataspace::Flags
333 map_flags(L4Re::Dataspace::Rights rights =
L4_CAP_FPAGE_W)
const noexcept
343 void size(
unsigned long size)
noexcept { _ds_size = size; }
348 Cache_type _cache_flags;
349 L4Re::Dataspace::Flags _rw_flags;
Interface for memory-like objects.
virtual l4_ret_t allocate(l4_addr_t offset, l4_size_t size, unsigned access) noexcept
Allocate a region within a dataspace.
virtual unsigned long page_shift() const noexcept
Define the size of the flexpage to map.
virtual l4_ret_t map_info(l4_addr_t &start_addr, l4_addr_t &end_addr) noexcept
Return mapping information for no-MMU systems.
virtual l4_ret_t copy(l4_addr_t dst_offs, l4_umword_t src_id, l4_addr_t src_offs, unsigned long size) noexcept
Copy from src dataspace to this destination dataspace.
virtual l4_ret_t map_hook(Dataspace::Offset offs, unsigned order, Dataspace::Flags flags, Dataspace::Map_addr *base, unsigned *send_order)
A hook that is called for acquiring the data to be mapped.
virtual void take() noexcept
Take a reference to this dataspace.
virtual l4_ret_t clear(unsigned long offs, unsigned long size) const noexcept
Clear a region in the dataspace.
l4_ret_t map(Dataspace::Offset offset, Dataspace::Map_addr local_addr, Dataspace::Flags flags, Dataspace::Map_addr min_addr, Dataspace::Map_addr max_addr, L4::Ipc::Snd_fpage &memory)
Map a region of the dataspace.
virtual unsigned long release() noexcept
Release a reference to this dataspace.
virtual bool is_static() const noexcept
Return whether the dataspace is static.
l4_umword_t data() const noexcept
Return the raw flexpage descriptor.
Send item or return item.
bool id_received() const noexcept
(Defined for return items only.) Check if an IPC gate label has been received instead of a mapping.
Map_type
(Defined for send items only.) Kind of mapping.
@ Map
Flag as usual map operation.
Cacheopt
(Defined for memory send items only.) Caching options, see l4_fpage_cacheability_opt_t.
@ Cached
Cacheability option to enable caches for the mapping.
unsigned int l4_size_t
Unsigned size type.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_addr_t
Address type.
@ L4_EACCESS
Permission denied.
@ L4_EINVAL
Invalid argument.
@ L4_ENODEV
No such thing.
L4_CONSTEXPR l4_fpage_t l4_fpage(l4_addr_t address, unsigned int order, unsigned char rights) L4_NOTHROW
Create a memory flexpage.
@ L4_CAP_FPAGE_W
Interface specific 'W' right for capability flexpages.
l4_addr_t l4_trunc_page(l4_addr_t address) L4_NOTHROW
Round an address down to the next lower page boundary.
l4_addr_t l4_trunc_size(l4_addr_t address, unsigned char bits) L4_NOTHROW
Round an address down to the next lower flexpage with size bits.
l4_addr_t l4_round_page(l4_addr_t address) L4_NOTHROW
Round address up to the next page.
#define L4_LOG2_PAGESIZE
Number of bits used for page offset.
#define L4_PAGESHIFT
Size of a page, log2-based.
l4_addr_t l4_round_size(l4_addr_t value, unsigned char bits) L4_NOTHROW
Round value up to the next alignment with bits size.
Common L4 ABI Data Types.
l4_int16_t l4_ret_t
Return value of an IPC call as well as an RPC call.
Documentation of the L4 Runtime Environment utility functionality in C++.
@ Caching_mask
Mask for caching flags.
@ W
Request write-only mapping.