#include "distortos/devices/memory/BlockDevice.hpp"
|
virtual | ~BlockDevice ()=default |
| BlockDevice'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 | getBlockSize () 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 | 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...
|
|
virtual int | write (uint64_t address, const void *buffer, size_t size)=0 |
| Writes data to a device. More...
|
|
| BlockDevice (const BlockDevice &)=delete |
|
BlockDevice & | operator= (const BlockDevice &)=delete |
|
BlockDevice class is an interface for a block device.
◆ ~BlockDevice()
virtual distortos::devices::BlockDevice::~BlockDevice |
( |
| ) |
|
|
virtualdefault |
BlockDevice's destructor.
- Precondition
- Device is closed.
◆ close()
virtual int distortos::devices::BlockDevice::close |
( |
| ) |
|
|
pure virtual |
◆ erase()
virtual int distortos::devices::BlockDevice::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] | address | is the address of range that will be erased, must be a multiple of block size |
[in] | size | is the size of erased range, bytes, must be a multiple of block size |
- Returns
- 0 on success, error code otherwise
Implemented in distortos::devices::SpiEeprom, distortos::devices::SdCard, and distortos::devices::SdCardSpiBased.
◆ getBlockSize()
virtual size_t distortos::devices::BlockDevice::getBlockSize |
( |
| ) |
const |
|
pure virtual |
◆ getSize()
virtual uint64_t distortos::devices::BlockDevice::getSize |
( |
| ) |
const |
|
pure virtual |
◆ lock()
virtual void distortos::devices::BlockDevice::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::SpiEeprom, distortos::devices::SdCard, and distortos::devices::SdCardSpiBased.
◆ open()
virtual int distortos::devices::BlockDevice::open |
( |
| ) |
|
|
pure virtual |
◆ read()
virtual int distortos::devices::BlockDevice::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] | address | is the address of data that will be read, must be a multiple of 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 block size |
- Returns
- 0 on success, error code otherwise
Implemented in distortos::devices::SpiEeprom, distortos::devices::SdCard, and distortos::devices::SdCardSpiBased.
◆ synchronize()
virtual int distortos::devices::BlockDevice::synchronize |
( |
| ) |
|
|
pure virtual |
◆ unlock()
virtual void distortos::devices::BlockDevice::unlock |
( |
| ) |
|
|
pure virtual |
◆ write()
virtual int distortos::devices::BlockDevice::write |
( |
uint64_t |
address, |
|
|
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
pure virtual |
Writes data to a device.
- 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 written, must be a multiple of block size |
[in] | buffer | is the buffer with data that will be written, must be valid |
[in] | size | is the size of buffer, bytes, must be a multiple of block size |
- Returns
- 0 on success, error code otherwise
Implemented in distortos::devices::SpiEeprom, distortos::devices::SdCard, and distortos::devices::SdCardSpiBased.
The documentation for this class was generated from the following file: