Memory space implementation that exports the contents of a file as a memory space.
More...
#include <MemoryConfig.hxx>
|
| | FileMemorySpace (int fd, address_t len=AUTO_LEN) |
| | Creates a memory space based on an fd.
|
| |
| | FileMemorySpace (const char *name, address_t len=AUTO_LEN) |
| | Creates a memory space based on a file name.
|
| |
| bool | read_only () 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 address_t | min_address () |
| |
| virtual errorcode_t | freeze () |
| | Handles space freeze command.
|
| |
| virtual errorcode_t | unfreeze () |
| | Handles space unfreeze command.
|
| |
|
| static const address_t | AUTO_LEN = (address_t) - 1 |
| |
| static const address_t | UNLIMITED_LEN = (address_t) - 2 |
| |
| 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).
|
| |
|
| void | ensure_file_open () |
| | Makes fd a valid parameter, and ensures fileSize is filled in.
|
| |
Memory space implementation that exports the contents of a file as a memory space.
The file can be specified either as a path or an fd. By default writes are also allowed.
Definition at line 244 of file MemoryConfig.hxx.
◆ FileMemorySpace() [1/2]
| openlcb::FileMemorySpace::FileMemorySpace |
( |
int |
fd, |
|
|
address_t |
len = AUTO_LEN |
|
) |
| |
Creates a memory space based on an fd.
- Parameters
-
| fd | is an open file descriptor with the data. |
| len | tells how many bytes there are in the memory space. If specified as AUTO_LEN, then uses fstat to figure out the size of the file. |
Definition at line 100 of file MemoryConfig.cxx.
◆ FileMemorySpace() [2/2]
| openlcb::FileMemorySpace::FileMemorySpace |
( |
const char * |
name, |
|
|
address_t |
len = AUTO_LEN |
|
) |
| |
Creates a memory space based on a file name.
Opens the file at the first use, and never closes it.
- Parameters
-
| name | is the file name to open. The pointer must stay alive so long as *this is around. |
| len | tells how many bytes there are in the memory space. If specified as AUTO_LEN, then uses fstat to figure out the size of the file. |
Definition at line 108 of file MemoryConfig.cxx.
◆ ensure_file_open()
| void openlcb::FileMemorySpace::ensure_file_open |
( |
| ) |
|
|
private |
Makes fd a valid parameter, and ensures fileSize is filled in.
Definition at line 116 of file MemoryConfig.cxx.
◆ max_address()
| address_t openlcb::FileMemorySpace::max_address |
( |
| ) |
|
|
inlinevirtual |
- Returns
- the largest valid address for this block. A read of 1 from this address should succeed in returning the last byte.
Implements openlcb::MemorySpace.
Definition at line 275 of file MemoryConfig.hxx.
◆ read()
| size_t openlcb::FileMemorySpace::read |
( |
address_t |
source, |
|
|
uint8_t * |
dst, |
|
|
size_t |
len, |
|
|
errorcode_t * |
error, |
|
|
Notifiable * |
again |
|
) |
| |
|
virtual |
- 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 181 of file MemoryConfig.cxx.
◆ read_only()
| bool openlcb::FileMemorySpace::read_only |
( |
| ) |
|
|
inlinevirtual |
◆ write()
| size_t openlcb::FileMemorySpace::write |
( |
address_t |
destination, |
|
|
const uint8_t * |
data, |
|
|
size_t |
len, |
|
|
errorcode_t * |
error, |
|
|
Notifiable * |
again |
|
) |
| |
|
virtual |
- Returns
- the number of bytes successfully written (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 MemorySpace::ERROR_AGAIN, and calls the Notifiable
- Parameters
-
| 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 145 of file MemoryConfig.cxx.
◆ AUTO_LEN
| const address_t openlcb::FileMemorySpace::AUTO_LEN = (address_t) - 1 |
|
static |
◆ fd_
| int openlcb::FileMemorySpace::fd_ |
|
private |
◆ fileSize_
| address_t openlcb::FileMemorySpace::fileSize_ |
|
private |
◆ name_
| const char* openlcb::FileMemorySpace::name_ |
|
private |
◆ UNLIMITED_LEN
| const address_t openlcb::FileMemorySpace::UNLIMITED_LEN = (address_t) - 2 |
|
static |
The documentation for this class was generated from the following files: