distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::devices::BlockDeviceToMemoryTechnologyDevice Class Reference

#include "distortos/devices/memory/BlockDeviceToMemoryTechnologyDevice.hpp"

Inheritance diagram for distortos::devices::BlockDeviceToMemoryTechnologyDevice:
[legend]
Collaboration diagram for distortos::devices::BlockDeviceToMemoryTechnologyDevice:
[legend]

Public Member Functions

constexpr BlockDeviceToMemoryTechnologyDevice (BlockDevice &blockDevice)
 BlockDeviceToMemoryTechnologyDevice's constructor. More...
 
 ~BlockDeviceToMemoryTechnologyDevice () override
 BlockDeviceToMemoryTechnologyDevice's destructor. More...
 
int close () override
 Closes device. More...
 
int erase (uint64_t address, uint64_t size) override
 Erases blocks on a device. More...
 
size_t getEraseBlockSize () const override
 
size_t getProgramBlockSize () const override
 
size_t getReadBlockSize () const override
 
uint64_t getSize () const override
 
void lock () override
 Locks the device for exclusive use by current thread. More...
 
int open () override
 Opens device. More...
 
int program (uint64_t address, const void *buffer, size_t size) override
 Programs data to a device. More...
 
int read (uint64_t address, void *buffer, size_t size) override
 Reads data from a device. More...
 
int synchronize () override
 Synchronizes state of a device, ensuring all cached writes are finished. More...
 
void unlock () override
 Unlocks the device which was previously locked by current thread. More...
 
- Public Member Functions inherited from distortos::devices::MemoryTechnologyDevice
virtual ~MemoryTechnologyDevice ()=default
 MemoryTechnologyDevice's destructor. More...
 
 MemoryTechnologyDevice (const MemoryTechnologyDevice &)=delete
 
MemoryTechnologyDeviceoperator= (const MemoryTechnologyDevice &)=delete
 

Private Attributes

uint64_t pendingEraseAddress_
 address of pending erase range, valid only if pendingEraseSize_ != 0 More...
 
uint64_t pendingEraseSize_
 size of pending erase range More...
 
BlockDeviceblockDevice_
 reference to associated block device More...
 
uint8_t openCount_
 number of times this device was opened but not yet closed More...
 

Detailed Description

BlockDeviceToMemoryTechnologyDevice class is a wrapper for BlockDevice which implements MemoryTechnologyDevice interface by buffering erase operations.

Constructor & Destructor Documentation

◆ BlockDeviceToMemoryTechnologyDevice()

constexpr distortos::devices::BlockDeviceToMemoryTechnologyDevice::BlockDeviceToMemoryTechnologyDevice ( BlockDevice blockDevice)
inlineexplicit

BlockDeviceToMemoryTechnologyDevice's constructor.

Parameters
[in]blockDeviceis a reference to associated block device

◆ ~BlockDeviceToMemoryTechnologyDevice()

distortos::devices::BlockDeviceToMemoryTechnologyDevice::~BlockDeviceToMemoryTechnologyDevice ( )
override

BlockDeviceToMemoryTechnologyDevice's destructor.

Warning
This function must not be called from interrupt context!
Precondition
Device is closed.

Member Function Documentation

◆ 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.

Here is the call graph for this function:

◆ 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]addressis the address of range that will be erased, must be a multiple of erase block size
[in]sizeis 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.

Here is the call graph for this function:

◆ getEraseBlockSize()

size_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getEraseBlockSize ( ) const
overridevirtual
Returns
erase block size, bytes

Implements distortos::devices::MemoryTechnologyDevice.

Here is the call graph for this function:

◆ getProgramBlockSize()

size_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getProgramBlockSize ( ) const
overridevirtual
Returns
program block size, bytes

Implements distortos::devices::MemoryTechnologyDevice.

Here is the call graph for this function:

◆ getReadBlockSize()

size_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getReadBlockSize ( ) const
overridevirtual
Returns
read block size, bytes

Implements distortos::devices::MemoryTechnologyDevice.

Here is the call graph for this function:

◆ getSize()

uint64_t distortos::devices::BlockDeviceToMemoryTechnologyDevice::getSize ( ) const
overridevirtual
Returns
size of device, bytes

Implements distortos::devices::MemoryTechnologyDevice.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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]addressis the address of data that will be programmed, must be a multiple of program block size
[in]bufferis the buffer with data that will be programmed, must be valid
[in]sizeis the size of buffer, bytes, must be a multiple of program block size
Returns
0 on success, error code otherwise:

Implements distortos::devices::MemoryTechnologyDevice.

Here is the call graph for this function:

◆ 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]addressis the address of data that will be read, must be a multiple of read block size
[out]bufferis the buffer into which the data will be read, must be valid
[in]sizeis the size of buffer, bytes, must be a multiple of read block size
Returns
0 on success, error code otherwise:

Implements distortos::devices::MemoryTechnologyDevice.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

Member Data Documentation

◆ 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: