distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
BlockDevice.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_DEVICES_MEMORY_BLOCKDEVICE_HPP_
13 #define INCLUDE_DISTORTOS_DEVICES_MEMORY_BLOCKDEVICE_HPP_
14 
15 #include <cstddef>
16 #include <cstdint>
17 
18 namespace distortos
19 {
20 
21 namespace devices
22 {
23 
31 {
32 public:
33 
40  virtual ~BlockDevice() = default;
41 
53  virtual int close() = 0;
54 
68  virtual int erase(uint64_t address, uint64_t size) = 0;
69 
74  virtual size_t getBlockSize() const = 0;
75 
80  virtual uint64_t getSize() const = 0;
81 
97  virtual void lock() = 0;
98 
107  virtual int open() = 0;
108 
123  virtual int read(uint64_t address, void* buffer, size_t size) = 0;
124 
133  virtual int synchronize() = 0;
134 
145  virtual void unlock() = 0;
146 
161  virtual int write(uint64_t address, const void* buffer, size_t size) = 0;
162 
163  BlockDevice() = default;
164  BlockDevice(const BlockDevice&) = delete;
165  BlockDevice& operator=(const BlockDevice&) = delete;
166 };
167 
168 } // namespace devices
169 
170 } // namespace distortos
171 
172 #endif // INCLUDE_DISTORTOS_DEVICES_MEMORY_BLOCKDEVICE_HPP_
virtual ~BlockDevice()=default
BlockDevice's destructor.
virtual int close()=0
Closes device.
virtual void unlock()=0
Unlocks the device which was previously locked by current thread.
virtual uint64_t getSize() const =0
virtual int open()=0
Opens device.
virtual int synchronize()=0
Synchronizes state of a device, ensuring all cached writes are finished.
Top-level namespace of distortos project.
Definition: buttons.hpp:33
Definition: BlockDevice.hpp:30
virtual size_t getBlockSize() const =0
virtual int write(uint64_t address, const void *buffer, size_t size)=0
Writes data to a device.
virtual int erase(uint64_t address, uint64_t size)=0
Erases blocks on a device.
virtual int read(uint64_t address, void *buffer, size_t size)=0
Reads data from a device.
virtual void lock()=0
Locks the device for exclusive use by current thread.