Interface for memory-like objects.
More...
|
long | map (Offset offset, Flags flags, Map_addr local_addr, Map_addr min_addr, Map_addr max_addr) const noexcept |
| Request a flex-page mapping from the dataspace. More...
|
|
long | map_region (Offset offset, Flags flags, Map_addr min_addr, Map_addr max_addr) const noexcept |
| Map a part of a dataspace into a local memory area. More...
|
|
long | clear (Offset offset, Size size) |
| Clear parts of a dataspace. More...
|
|
long | allocate (Offset offset, Size size) |
| Allocate a range in the dataspace. More...
|
|
long | copy_in (Offset dst_offs, L4::Ipc::Cap< Dataspace > src, Offset src_offs, Size size) |
| Copy contents from another dataspace. More...
|
|
Size | size () const noexcept |
| Get size of a dataspace. More...
|
|
Flags | flags () const noexcept |
| Get flags of the dataspace. More...
|
|
long | info (Stats *stats) |
| Get information on the dataspace. More...
|
|
l4_msgtag_t | dec_refcnt (l4_mword_t diff, l4_utcb_t *utcb=l4_utcb()) |
| Decrement the in kernel reference counter for the object. More...
|
|
|
typedef Dataspace | Class |
| The target interface type (inheriting from Kobject_t)
|
|
typedef Typeid::Iface< PROTO, Dataspace > | __Iface |
| The interface description for the derived class.
|
|
typedef Typeid::Merge_list< Typeid::Iface_list< __Iface >, typename Base::__Iface_list > | __Iface_list |
| The list of all RPC interfaces provided directly or through inheritance.
|
|
L4::Cap< Class > | c () const noexcept |
| Get the capability to ourselves.
|
|
l4_cap_idx_t | cap () const noexcept |
| Return capability selector. More...
|
|
static void | __check_protocols__ () noexcept |
| Helper to check for protocol conflicts.
|
|
Interface for memory-like objects.
Dataspaces are a central abstraction provided by L4Re. A dataspace is an abstraction for any thing that is available via usual memory access instructions. A dataspace can be a file, as well as the memory-mapped registers of a device, or anonymous memory, such as a heap.
The dataspace interface defines a set of methods that allow any kind of dataspace to be attached (mapped) to the virtual address space of an L4 task and then be accessed via memory-access instructions. The L4Re::Rm interface can be used to attach a dataspace to a virtual address space of a task paged by a certain instance of a region map.
- Include File
-
- Examples
- examples/libs/l4re/c++/mem_alloc/ma+rm.cc, examples/libs/l4re/c++/shared_ds/ds_clnt.cc, and examples/libs/l4re/c++/shared_ds/ds_srv.cc.
Definition at line 60 of file dataspace.
◆ allocate()
long L4Re::Dataspace::allocate |
( |
Offset |
offset, |
|
|
Size |
size |
|
) |
| |
Allocate a range in the dataspace.
- Parameters
-
offset | Offset in the dataspace, in bytes. |
size | Size of the range, in bytes. |
- Return values
-
L4_EOK | Success |
-L4_ERANGE | Given range is outside the dataspace. (A dataspace provider may also silently ignore areas outside the dataspace.) |
-L4_ENOMEM | Not enough memory available. |
<0 | IPC errors |
On success, at least the given range is guaranteed to be allocated. The dataspace manager may also allocate more memory due to page granularity.
The memory is allocated with the same rights as the dataspace capability.
◆ clear()
long L4Re::Dataspace::clear |
( |
Offset |
offset, |
|
|
Size |
size |
|
) |
| |
Clear parts of a dataspace.
- Parameters
-
offset | Offset within dataspace (in bytes). |
size | Size of region to clear (in bytes). |
- Return values
-
>=0 | Success. |
-L4_ERANGE | Given range is outside the dataspace. (A dataspace provider may also silently ignore areas outside the dataspace.) |
-L4_EACCESS | Dataspace is read-only. |
<0 | IPC errors |
Zeroes out the memory. Depending on the type of memory the memory could also be deallocated and replaced by a shared zero-page.
◆ copy_in()
long L4Re::Dataspace::copy_in |
( |
Offset |
dst_offs, |
|
|
L4::Ipc::Cap< Dataspace > |
src, |
|
|
Offset |
src_offs, |
|
|
Size |
size |
|
) |
| |
Copy contents from another dataspace.
- Parameters
-
dst_offs | Offset in destination dataspace. |
src | Source dataspace to copy from. |
src_offs | Offset in the source dataspace. |
size | Size to copy (in bytes). |
- Return values
-
L4_EOK | Success |
-L4_EACCESS | Destination dataspace not writable. |
-L4_EINVAL | Invalid parameter supplied. |
<0 | IPC errors |
The copy operation may use copy-on-write mechanisms. The operation may also fail if both dataspaces are not from the same dataspace manager or the dataspace managers do not cooperate.
◆ flags()
Dataspace::Flags L4Re::Dataspace::flags |
( |
| ) |
const |
|
noexcept |
◆ info()
long L4Re::Dataspace::info |
( |
Stats * |
stats | ) |
|
Get information on the dataspace.
- Parameters
-
- Return values
-
◆ map()
long L4Re::Dataspace::map |
( |
Dataspace::Offset |
offset, |
|
|
Dataspace::Flags |
flags, |
|
|
Dataspace::Map_addr |
local_addr, |
|
|
Dataspace::Map_addr |
min_addr, |
|
|
Dataspace::Map_addr |
max_addr |
|
) |
| const |
|
noexcept |
Request a flex-page mapping from the dataspace.
- Parameters
-
offset | Offset to start within dataspace |
flags | Dataspace flags, see L4Re::Dataspace::F::Flags. |
local_addr | Local address to map to. |
min_addr | Defines start of receive window. (Rounded down to page size.) |
max_addr | Defines end of receive window. (Rounded up to page size.) |
- Return values
-
L4_EOK | Success |
-L4_ERANGE | Invalid offset. |
-L4_EPERM | Insufficient permission to map with requested rights. |
<0 | IPC errors |
The map call will attempt to map the largest possible flexpage that covers the given local address and still fits into the region defined by min_addr
and max_addr
. If the given region is invalid or does not overlap the local address, the smallest valid page size is used.
Definition at line 94 of file dataspace_impl.h.
References L4_LOG2_PAGESIZE.
◆ map_region()
long L4Re::Dataspace::map_region |
( |
Dataspace::Offset |
offset, |
|
|
Dataspace::Flags |
flags, |
|
|
Dataspace::Map_addr |
min_addr, |
|
|
Dataspace::Map_addr |
max_addr |
|
) |
| const |
|
noexcept |
Map a part of a dataspace into a local memory area.
- Parameters
-
offset | Offset to start within dataspace. |
flags | Dataspace flags, see L4Re::Dataspace::F::Flags. |
min_addr | (Inclusive) start of the receive area. |
max_addr | (Exclusive) end of receive area. |
- Return values
-
L4_EOK | Success |
-L4_ERANGE | Invalid offset or receive area larger than the dataspace. |
-L4_EPERM | Insufficient permission to map with requested rights. |
<0 | IPC errors |
This is a convenience function which maps flex-pages consecutively into the given memory area in the local task. The area is expected to be filled completely. If the dataspace is not large enough to provide the mappings for the entire size of the area, then an error is returned. Mappings may or may not have been already established at that point.
offset
and min_addr
are rounded down to the next L4_PAGESIZE
boundary when necessary. max_addr
is rounded up to the page boundary. If the resulting maximum address is less or equal than the minimum address, then the function is a noop.
Definition at line 55 of file dataspace_impl.h.
References L4_LOG2_PAGESIZE, L4_UNLIKELY, L4::round_order(), and L4::trunc_order().
◆ size()
Dataspace::Size L4Re::Dataspace::size |
( |
| ) |
const |
|
noexcept |
The documentation for this class was generated from the following files: