distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::devices::MemoryTechnologyDevice Class Referenceabstract

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

Inheritance diagram for distortos::devices::MemoryTechnologyDevice:
[legend]

Public Member Functions

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

Detailed Description

MemoryTechnologyDevice class is an interface for a memory technology device (flash memory).

Constructor & Destructor Documentation

◆ ~MemoryTechnologyDevice()

virtual distortos::devices::MemoryTechnologyDevice::~MemoryTechnologyDevice ( )
virtualdefault

MemoryTechnologyDevice's destructor.

Precondition
Device is closed.

Member Function Documentation

◆ close()

virtual int distortos::devices::MemoryTechnologyDevice::close ( )
pure virtual

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).
Precondition
Device is opened.
Returns
0 on success, error code otherwise

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

Here is the caller graph for this function:

◆ erase()

virtual int distortos::devices::MemoryTechnologyDevice::erase ( uint64_t  address,
uint64_t  size 
)
pure virtual

Erases blocks on a device.

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

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

◆ getEraseBlockSize()

virtual size_t distortos::devices::MemoryTechnologyDevice::getEraseBlockSize ( ) const
pure virtual
Returns
erase block size, bytes

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

Here is the caller graph for this function:

◆ getProgramBlockSize()

virtual size_t distortos::devices::MemoryTechnologyDevice::getProgramBlockSize ( ) const
pure virtual
Returns
program block size, bytes

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

Here is the caller graph for this function:

◆ getReadBlockSize()

virtual size_t distortos::devices::MemoryTechnologyDevice::getReadBlockSize ( ) const
pure virtual
Returns
read block size, bytes

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

Here is the caller graph for this function:

◆ getSize()

virtual uint64_t distortos::devices::MemoryTechnologyDevice::getSize ( ) const
pure virtual
Returns
size of device, bytes

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

Here is the caller graph for this function:

◆ lock()

virtual void distortos::devices::MemoryTechnologyDevice::lock ( )
pure virtual

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.

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

◆ open()

virtual int distortos::devices::MemoryTechnologyDevice::open ( )
pure virtual

Opens device.

Precondition
The number of times the device is opened is less than 255.
Returns
0 on success, error code otherwise

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

Here is the caller graph for this function:

◆ program()

virtual int distortos::devices::MemoryTechnologyDevice::program ( uint64_t  address,
const void *  buffer,
size_t  size 
)
pure virtual

Programs data to a device.

Selected range of blocks must have been erased prior to being programmed.

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

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

◆ read()

virtual int distortos::devices::MemoryTechnologyDevice::read ( uint64_t  address,
void *  buffer,
size_t  size 
)
pure virtual

Reads data from a device.

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

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

◆ synchronize()

virtual int distortos::devices::MemoryTechnologyDevice::synchronize ( )
pure virtual

Synchronizes state of a device, ensuring all cached writes are finished.

Precondition
Device is opened.
Returns
0 on success, error code otherwise

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.

◆ unlock()

virtual void distortos::devices::MemoryTechnologyDevice::unlock ( )
pure virtual

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.

Implemented in distortos::devices::BlockDeviceToMemoryTechnologyDevice.


The documentation for this class was generated from the following file: