Skip to content

Commit 7707c8b

Browse files
committed
bd: Added get_erase_value function to the block device API
Default implementation returns -1 and is backwards compatible
1 parent 98611c8 commit 7707c8b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

features/filesystem/bd/BlockDevice.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class BlockDevice
8585

8686
/** Erase blocks on a block device
8787
*
88-
* The state of an erased block is undefined until it has been programmed
88+
* The state of an erased block is undefined until it has been programmed,
89+
* unless get_erase_value returns a non-negative byte value
8990
*
9091
* @param addr Address of block to begin erasing
9192
* @param size Size to erase in bytes, must be a multiple of erase block size
@@ -135,6 +136,20 @@ class BlockDevice
135136
return get_program_size();
136137
}
137138

139+
/** Get the value of storage when erased
140+
*
141+
* If get_erase_value returns a non-negative byte value, the underlying
142+
* storage will be set to that value when erased, and storage containing
143+
* that value can be programmed without another erase.
144+
*
145+
* @return The value of storage when erased, or -1 if the value of
146+
* erased storage can't be relied on
147+
*/
148+
virtual int get_erase_value() const
149+
{
150+
return -1;
151+
}
152+
138153
/** Get the total size of the underlying device
139154
*
140155
* @return Size of the underlying device in bytes

0 commit comments

Comments
 (0)