mn::device::basic_block_device Class Referenceabstract

basic_block_device class is an interface for a block device. More...

#include <mn_block_device.hpp>

+ Inheritance diagram for mn::device::basic_block_device:
+ Collaboration diagram for mn::device::basic_block_device:

Public Member Functions

 basic_block_device (char prefix[8])
 
virtual ~basic_block_device ()=default
 BlockDevice's destructor. More...
 
virtual int open ()=0
 Opens device. More...
 
virtual int synchronize ()=0
 Synchronizes state of a device, ensuring all cached writes are finished. More...
 
virtual int stop ()=0
 Closes device. More...
 
virtual void lock ()=0
 Locks the device for exclusive use by current thread. More...
 
virtual void unlock ()=0
 Unlocks the device which was previously locked by current thread. More...
 
virtual int read (uint64_t address, void *buffer, size_t size)=0
 Reads data from a device. More...
 
virtual int write (uint64_t address, const void *buffer, size_t size)=0
 Writes data to a device. More...
 
virtual int erase (uint64_t address, uint64_t size)=0
 Erases blocks on a device. More...
 
virtual size_t get_block_size () const =0
 
virtual uint64_t get_size () const =0
 
 basic_block_device (const basic_block_device &)=delete
 
basic_block_deviceoperator= (const basic_block_device &)=delete
 
- Public Member Functions inherited from mn::device::basic_device
 basic_device (char prefix[8])
 
virtual bool is_enable ()=0
 
virtual bool is_stream_support ()=0
 
const char * get_prefix ()
 

Additional Inherited Members

- Protected Attributes inherited from mn::device::basic_device
const char * m_prefix
 

Detailed Description

basic_block_device class is an interface for a block device.

Constructor & Destructor Documentation

◆ basic_block_device() [1/2]

mn::device::basic_block_device::basic_block_device ( char  prefix[8])
inline

◆ ~basic_block_device()

virtual mn::device::basic_block_device::~basic_block_device ( )
virtualdefault

BlockDevice's destructor.

◆ basic_block_device() [2/2]

mn::device::basic_block_device::basic_block_device ( const basic_block_device )
delete

Member Function Documentation

◆ erase()

virtual int mn::device::basic_block_device::erase ( uint64_t  address,
uint64_t  size 
)
pure virtual

Erases blocks on a device.

Parameters
[in]addressis the address of range that will be erased, must be a multiple of block size
[in]sizeis the size of erased range, bytes, must be a multiple of block size
Returns
0 on success, error code otherwise

◆ get_block_size()

virtual size_t mn::device::basic_block_device::get_block_size ( ) const
pure virtual
Returns
block size, bytes

◆ get_size()

virtual uint64_t mn::device::basic_block_device::get_size ( ) const
pure virtual
Returns
size of block device, bytes

◆ lock()

virtual void mn::device::basic_block_device::lock ( )
pure virtual

Locks the device for exclusive use by current thread.

◆ open()

virtual int mn::device::basic_block_device::open ( )
pure virtual

Opens device.

Returns
0 on success, error code otherwise

Implements mn::device::basic_device.

◆ operator=()

basic_block_device& mn::device::basic_block_device::operator= ( const basic_block_device )
delete

◆ read()

virtual int mn::device::basic_block_device::read ( uint64_t  address,
void *  buffer,
size_t  size 
)
pure virtual

Reads data from a device.

Parameters
[in]addressis the address of data that will be read, must be a multiple of 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 block size
Returns
The size to readed and 0 on error.

◆ stop()

virtual int mn::device::basic_block_device::stop ( )
pure virtual

Closes device.

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

Implements mn::device::basic_device.

◆ synchronize()

virtual int mn::device::basic_block_device::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

◆ unlock()

virtual void mn::device::basic_block_device::unlock ( )
pure virtual

Unlocks the device which was previously locked by current thread.

Warning
This function must not be called from interrupt context!

◆ write()

virtual int mn::device::basic_block_device::write ( uint64_t  address,
const void *  buffer,
size_t  size 
)
pure virtual

Writes data to a device.

Precondition
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 written, must be a multiple of block size
[in]bufferis the buffer with data that will be written, must be valid
[in]sizeis the size of buffer, bytes, must be a multiple of block size
Returns
The size to written and 0 on error.

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