#include "distortos/devices/memory/BlockDeviceToMemoryTechnologyDevice.hpp"
BlockDeviceToMemoryTechnologyDevice class is a wrapper for BlockDevice which implements MemoryTechnologyDevice interface by buffering erase operations.
◆ BlockDeviceToMemoryTechnologyDevice()
constexpr distortos::devices::BlockDeviceToMemoryTechnologyDevice::BlockDeviceToMemoryTechnologyDevice |
( |
BlockDevice & |
blockDevice | ) |
|
|
inlineexplicit |
◆ ~BlockDeviceToMemoryTechnologyDevice()
distortos::devices::BlockDeviceToMemoryTechnologyDevice::~BlockDeviceToMemoryTechnologyDevice |
( |
| ) |
|
|
override |
◆ close()
int distortos::devices::BlockDeviceToMemoryTechnologyDevice::close |
( |
| ) |
|
|
overridevirtual |
Closes device.
- Note
- Even if error code is returned, the device must not be used from the context which opened it (until it is successfully opened again).
- Warning
- This function must not be called from interrupt context!
- Precondition
- Device is opened.
- Returns
- 0 on success, error code otherwise:
Implements distortos::devices::MemoryTechnologyDevice.
◆ erase()
int distortos::devices::BlockDeviceToMemoryTechnologyDevice::erase |
( |
uint64_t |
address, |
|
|
uint64_t |
size |
|
) |
| |
|
overridevirtual |
Erases blocks on a device.
- Warning
- This function must not be called from interrupt context!
- Precondition
- Device is opened.
-
address and size are valid.
-
Selected range is within address space of device.
- Parameters
-
[in] | address | is the address of range that will be erased, must be a multiple of erase block size |
[in] | size | is the size of erased range, bytes, must be a multiple of erase block size |
- Returns
- 0 on success, error code otherwise:
Implements distortos::devices::MemoryTechnologyDevice.
◆ getEraseBlockSize()
size_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getEraseBlockSize |
( |
| ) |
const |
|
overridevirtual |
◆ getProgramBlockSize()
size_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getProgramBlockSize |
( |
| ) |
const |
|
overridevirtual |
◆ getReadBlockSize()
size_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getReadBlockSize |
( |
| ) |
const |
|
overridevirtual |
◆ getSize()
uint64_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getSize |
( |
| ) |
const |
|
overridevirtual |
◆ lock()
void distortos::devices::BlockDeviceToMemoryTechnologyDevice::lock |
( |
| ) |
|
|
overridevirtual |
Locks the device for exclusive use by current thread.
When the object is locked, any call to any member function from other thread will be blocked until the object is unlocked. Locking is optional, but may be useful when more than one transaction must be done atomically.
- Note
- Locks are recursive.
- Warning
- This function must not be called from interrupt context!
- Precondition
- The number of recursive locks of device is less than 65535.
- Postcondition
- Device is locked.
Implements distortos::devices::MemoryTechnologyDevice.
◆ open()
int distortos::devices::BlockDeviceToMemoryTechnologyDevice::open |
( |
| ) |
|
|
overridevirtual |
Opens device.
- Warning
- This function must not be called from interrupt context!
- Precondition
- The number of times the device is opened is less than 255.
- Returns
- 0 on success, error code otherwise:
Implements distortos::devices::MemoryTechnologyDevice.
◆ program()
int distortos::devices::BlockDeviceToMemoryTechnologyDevice::program |
( |
uint64_t |
address, |
|
|
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Programs data to a device.
Selected range of blocks must have been erased prior to being programmed.
- Warning
- This function must not be called from interrupt context!
- Precondition
- Device is opened.
-
address and buffer and size are valid.
-
Selected range is within address space of device.
- Parameters
-
[in] | address | is the address of data that will be programmed, must be a multiple of program block size |
[in] | buffer | is the buffer with data that will be programmed, must be valid |
[in] | size | is the size of buffer, bytes, must be a multiple of program block size |
- Returns
- 0 on success, error code otherwise:
Implements distortos::devices::MemoryTechnologyDevice.
◆ read()
int distortos::devices::BlockDeviceToMemoryTechnologyDevice::read |
( |
uint64_t |
address, |
|
|
void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Reads data from a device.
- Warning
- This function must not be called from interrupt context!
- Precondition
- Device is opened.
-
address and buffer and size are valid.
-
Selected range is within address space of device.
- Parameters
-
[in] | address | is the address of data that will be read, must be a multiple of read block size |
[out] | buffer | is the buffer into which the data will be read, must be valid |
[in] | size | is the size of buffer, bytes, must be a multiple of read block size |
- Returns
- 0 on success, error code otherwise:
Implements distortos::devices::MemoryTechnologyDevice.
◆ synchronize()
int distortos::devices::BlockDeviceToMemoryTechnologyDevice::synchronize |
( |
| ) |
|
|
overridevirtual |
Synchronizes state of a device, ensuring all cached writes are finished.
- Warning
- This function must not be called from interrupt context!
- Precondition
- Device is opened.
- Returns
- 0 on success, error code otherwise:
Implements distortos::devices::MemoryTechnologyDevice.
◆ unlock()
void distortos::devices::BlockDeviceToMemoryTechnologyDevice::unlock |
( |
| ) |
|
|
overridevirtual |
Unlocks the device which was previously locked by current thread.
- Note
- Locks are recursive.
- Warning
- This function must not be called from interrupt context!
- Precondition
- This function is called by the thread that locked the device.
Implements distortos::devices::MemoryTechnologyDevice.
◆ blockDevice_
BlockDevice& distortos::devices::BlockDeviceToMemoryTechnologyDevice::blockDevice_ |
|
private |
reference to associated block device
◆ openCount_
uint8_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::openCount_ |
|
private |
number of times this device was opened but not yet closed
◆ pendingEraseAddress_
uint64_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::pendingEraseAddress_ |
|
private |
address of pending erase range, valid only if pendingEraseSize_ != 0
◆ pendingEraseSize_
uint64_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::pendingEraseSize_ |
|
private |
size of pending erase range
The documentation for this class was generated from the following files: