bd: Added get_erase_value function to the block device API

Default implementation returns -1 and is backwards compatible
pull/5925/head
Christopher Haster 2018-01-24 17:19:25 -06:00
parent 98611c8578
commit 7707c8b8b8
1 changed files with 16 additions and 1 deletions

View File

@ -85,7 +85,8 @@ public:
/** Erase blocks on a block device
*
* The state of an erased block is undefined until it has been programmed
* The state of an erased block is undefined until it has been programmed,
* unless get_erase_value returns a non-negative byte value
*
* @param addr Address of block to begin erasing
* @param size Size to erase in bytes, must be a multiple of erase block size
@ -135,6 +136,20 @@ public:
return get_program_size();
}
/** Get the value of storage when erased
*
* If get_erase_value returns a non-negative byte value, the underlying
* storage will be set to that value when erased, and storage containing
* that value can be programmed without another erase.
*
* @return The value of storage when erased, or -1 if the value of
* erased storage can't be relied on
*/
virtual int get_erase_value() const
{
return -1;
}
/** Get the total size of the underlying device
*
* @return Size of the underlying device in bytes