Implementation of a memory space where the values are not stored in a contiguous storage area but are read and written via callbacks.
More...
#include <VirtualMemorySpace.hxx>
|
| bool | read_only () override |
| |
| address_t | min_address () override |
| |
| address_t | max_address () override |
| |
| size_t | write (address_t destination, const uint8_t *data, size_t len, errorcode_t *error, Notifiable *again) override |
| |
| size_t | read (address_t source, uint8_t *dst, size_t len, errorcode_t *error, Notifiable *again) override |
| |
| virtual bool | set_node (Node *node) |
| | Specifies which node the next operation pertains.
|
| |
| virtual errorcode_t | freeze () |
| | Handles space freeze command.
|
| |
| virtual errorcode_t | unfreeze () |
| | Handles space unfreeze command.
|
| |
|
| address_t | minAddress_ = 0xFFFFFFFFu |
| | Bounds for valid addresses.
|
| |
| address_t | maxAddress_ = 0 |
| | Bounds for valid addresses.
|
| |
| unsigned | isReadOnly_: 1 |
| | Whether the space should report as RO.
|
| |
|
| ssize_t | find_data_element (address_t address, address_t len, const DataElement **ptr, unsigned *repeat) |
| | Look up the first matching data element given an address in the virtual memory space.
|
| |
|
| static constexpr unsigned | NO_CACHE = static_cast<address_t>(-1) |
| |
|
| typedef uint32_t | address_t |
| |
| typedef uint16_t | errorcode_t |
| |
| static const errorcode_t | ERROR_AGAIN = 0x3FFF |
| | This error code signals that the operation was only partially completed, the again notify was used and will be notified when the operation can be re-tried).
|
| |
Implementation of a memory space where the values are not stored in a contiguous storage area but are read and written via callbacks.
Definition at line 49 of file VirtualMemorySpace.hxx.
◆ ElementsType
◆ ReadFunction
Function that will be called for reads.
- Parameters
-
| repeat | 0 to number of repeats if this is in a repeated group. Always 0 if not repeated group. |
| contents | the payload to be returned from this variable shall be written here. Will be zero-padded to size_ bytes if shorter. |
| done | must be notified when the read values are ready. The call will be re-tried if this does not happen inline. |
Definition at line 221 of file VirtualMemorySpace.hxx.
◆ TypedReadFunction
Typed ReadFunction for primitive types.
- Returns
- the read value if the read was successful. If the read did not complete, return 0.
Definition at line 232 of file VirtualMemorySpace.hxx.
◆ TypedWriteFunction
◆ WriteFunction
Function that will be called for writes.
- Parameters
-
| repeat | 0 to number of repeats if this is in a repeated group. Always 0 if not repeated group. |
| contents | data payload that needs to be written. The data bytes of this container start at the address_. |
| done | must be notified when the write is complete (possibly inline). |
Definition at line 212 of file VirtualMemorySpace.hxx.
◆ VirtualMemorySpace()
| openlcb::VirtualMemorySpace::VirtualMemorySpace |
( |
| ) |
|
|
inline |
◆ expand_bounds_from_group()
template<class G >
| void openlcb::VirtualMemorySpace::expand_bounds_from_group |
( |
const G & |
group | ) |
|
|
inlineprotected |
Expand the address bounds from a single CDI group declaration.
- Parameters
-
| group | is an instance of a group, for example a segment. |
Definition at line 245 of file VirtualMemorySpace.hxx.
◆ find_data_element()
| ssize_t openlcb::VirtualMemorySpace::find_data_element |
( |
address_t |
address, |
|
|
address_t |
len, |
|
|
const DataElement ** |
ptr, |
|
|
unsigned * |
repeat |
|
) |
| |
|
inlineprivate |
Look up the first matching data element given an address in the virtual memory space.
- Parameters
-
| address | byte offset to look up. |
| len | how many bytes long range to search from address. |
| ptr | will be filled with a pointer to the data element when found, or filled with nullptr if no data element overlaps with the given range. |
| repeat | output argument, filled with zero or the repetition number. |
- Returns
- 0 if an exact match is found. -N if a data element is found, but N first bytes of this element are not covered. A number N in [1..len-1] if a data element is found, but this many bytes need to be skipped from address to arrive at the given data element's offset. len if there was no data element found (in which case also set ptr to null).
Definition at line 417 of file VirtualMemorySpace.hxx.
◆ max_address()
| address_t openlcb::VirtualMemorySpace::max_address |
( |
| ) |
|
|
inlineoverridevirtual |
◆ min_address()
| address_t openlcb::VirtualMemorySpace::min_address |
( |
| ) |
|
|
inlineoverridevirtual |
◆ read()
| size_t openlcb::VirtualMemorySpace::read |
( |
address_t |
source, |
|
|
uint8_t * |
dst, |
|
|
size_t |
len, |
|
|
errorcode_t * |
error, |
|
|
Notifiable * |
again |
|
) |
| |
|
inlineoverridevirtual |
- Returns
- the number of bytes successfully read (before hitting end of space). If *error is set to non-null, then the operation has failed. If the operation needs to be continued, then sets error to ERROR_AGAIN, and calls the Notifiable
- Parameters
-
| again | when a re-try makes sense. The caller should call read once more, with the offset adjusted with the previously returned bytes. |
Implements openlcb::MemorySpace.
Definition at line 165 of file VirtualMemorySpace.hxx.
◆ read_only()
| bool openlcb::VirtualMemorySpace::read_only |
( |
| ) |
|
|
inlineoverridevirtual |
◆ register_element()
| void openlcb::VirtualMemorySpace::register_element |
( |
address_t |
address, |
|
|
address_t |
size, |
|
|
ReadFunction |
read_f, |
|
|
WriteFunction |
write_f |
|
) |
| |
|
inlineprotected |
Register an untyped element.
- Parameters
-
| address | the address in the memory space |
| size | how many bytes this elements occupes |
| read_f | will be called to read this data |
| write_f | will be called to write this data |
Definition at line 257 of file VirtualMemorySpace.hxx.
◆ register_numeric()
Registers a numeric typed element.
- Parameters
-
| T | is the type argument, e.g. uint8_t. |
| entry | is the CDI ConfigRepresentation. |
| read_f | will be called to read this data |
| write_f | will be called to write this data |
Definition at line 281 of file VirtualMemorySpace.hxx.
◆ register_repeat()
template<class Group , unsigned N>
| void openlcb::VirtualMemorySpace::register_repeat |
( |
const RepeatedGroup< Group, N > & |
group | ) |
|
|
inlineprotected |
Registers a repeated group.
Calling this function means that the virtual memory space of the group will be looped onto the first repetition. The correct usage is to register the elements of the first repetition, then register the repetition itself using this call. Nested repetitions are not supported (either the outer or the inner repetition needs to be unrolled and registered for each repeat there).
- Parameters
-
| group | is the repeated group instance. Will take the start offset, repeat count and repeat size from it. |
Definition at line 313 of file VirtualMemorySpace.hxx.
◆ register_string()
Registers a string typed element.
- Parameters
-
| entry | is the CDI ConfigRepresentation. |
| read_f | will be called to read this data |
| write_f | will be called to write this data |
Definition at line 268 of file VirtualMemorySpace.hxx.
◆ set_bounds_from_group()
template<class G >
| void openlcb::VirtualMemorySpace::set_bounds_from_group |
( |
const G & |
group | ) |
|
|
inlineprotected |
Setup the address bounds from a single CDI group declaration.
- Parameters
-
| group | is an instance of a group, for example a segment. |
Definition at line 237 of file VirtualMemorySpace.hxx.
◆ write()
| size_t openlcb::VirtualMemorySpace::write |
( |
address_t |
destination, |
|
|
const uint8_t * |
data, |
|
|
size_t |
len, |
|
|
errorcode_t * |
error, |
|
|
Notifiable * |
again |
|
) |
| |
|
inlineoverridevirtual |
- Returns
- the number of bytes successfully written (before hitting end of space).
- Parameters
-
| destination | address to write to |
| data | to write |
| len | how many bytes to write |
| error | if set to non-null, then the operation has failed. If the operation needs to be continued, then sets error to MemorySpace::ERROR_AGAIN, and calls the Notifiable |
| again | when a re-try makes sense. The caller should call write once more, with the offset adjusted with the previously returned bytes. |
Reimplemented from openlcb::MemorySpace.
Definition at line 85 of file VirtualMemorySpace.hxx.
◆ bn_
◆ cachedData_
| string openlcb::VirtualMemorySpace::cachedData_ |
|
private |
◆ cacheOffset_
| address_t openlcb::VirtualMemorySpace::cacheOffset_ = NO_CACHE |
|
private |
◆ elements_
◆ isReadOnly_
| unsigned openlcb::VirtualMemorySpace::isReadOnly_ |
|
protected |
◆ maxAddress_
| address_t openlcb::VirtualMemorySpace::maxAddress_ = 0 |
|
protected |
Bounds for valid addresses.
A read of length 1 from this address should succeed in returning the last byte.
Definition at line 328 of file VirtualMemorySpace.hxx.
◆ minAddress_
| address_t openlcb::VirtualMemorySpace::minAddress_ = 0xFFFFFFFFu |
|
protected |
◆ NO_CACHE
| constexpr unsigned openlcb::VirtualMemorySpace::NO_CACHE = static_cast<address_t>(-1) |
|
staticconstexprprivate |
◆ repeats_
The documentation for this class was generated from the following file: