21 #ifndef MBED_EXHAUSTIBLE_BLOCK_DEVICE_H 22 #define MBED_EXHAUSTIBLE_BLOCK_DEVICE_H 24 #include "BlockDevice.h" 85 virtual int read(
void *buffer, bd_addr_t addr, bd_size_t
size);
96 virtual int program(
const void *buffer, bd_addr_t addr, bd_size_t size);
107 virtual int erase(bd_addr_t addr, bd_size_t size);
150 virtual bd_size_t
size()
const;
156 virtual const char *
get_type()
const;
160 uint32_t *_erase_array;
161 uint32_t _erase_cycles;
162 uint32_t _init_ref_count;
163 bool _is_initialized;
169 #ifndef MBED_NO_GLOBAL_USING_DIRECTIVE virtual int deinit()
Deinitialize a block device.
virtual bd_size_t size() const
Get the total size of the underlying device.
virtual int get_erase_value() const
Get the value of storage when erased.
virtual bd_size_t get_read_size() const
Get the size of a readable block.
virtual bd_size_t get_erase_size() const
Get the size of an erasable block.
A hardware device capable of writing and reading blocks.
void set_erase_cycles(bd_addr_t addr, uint32_t cycles)
Set the number of erase cycles before failure.
virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size)
Program blocks to a block device.
Heap backed block device which simulates failures.
virtual int read(void *buffer, bd_addr_t addr, bd_size_t size)
Read blocks from a block device.
virtual int erase(bd_addr_t addr, bd_size_t size)
Erase blocks on a block device.
virtual int sync()
Ensure data on storage is in sync with the driver.
virtual bd_size_t get_program_size() const
Get the size of a programmable block.
virtual int init()
Initialize a block device.
virtual const char * get_type() const
Get the BlockDevice class type.
ExhaustibleBlockDevice(BlockDevice *bd, uint32_t erase_cycles)
Lifetime of the block device.
uint32_t get_erase_cycles(bd_addr_t addr) const
Get the number of erase cycles remaining on a block.