mirror of https://github.com/ARMmbed/mbed-os.git
bd: Adopted the get_erase_value function in the util block devices
parent
7707c8b8b8
commit
88aad81345
|
@ -20,6 +20,7 @@
|
|||
ChainingBlockDevice::ChainingBlockDevice(BlockDevice **bds, size_t bd_count)
|
||||
: _bds(bds), _bd_count(bd_count)
|
||||
, _read_size(0), _program_size(0), _erase_size(0), _size(0)
|
||||
, _erase_value(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,6 +34,7 @@ int ChainingBlockDevice::init()
|
|||
_read_size = 0;
|
||||
_program_size = 0;
|
||||
_erase_size = 0;
|
||||
_erase_value = -1;
|
||||
_size = 0;
|
||||
|
||||
// Initialize children block devices, find all sizes and
|
||||
|
@ -66,6 +68,13 @@ int ChainingBlockDevice::init()
|
|||
MBED_ASSERT(_erase_size > erase && is_aligned(_erase_size, erase));
|
||||
}
|
||||
|
||||
int value = _bds[i]->get_erase_value();
|
||||
if (i == 0 || value == _erase_value) {
|
||||
_erase_value = value;
|
||||
} else {
|
||||
_erase_value = -1;
|
||||
}
|
||||
|
||||
_size += _bds[i]->size();
|
||||
}
|
||||
|
||||
|
@ -190,6 +199,11 @@ bd_size_t ChainingBlockDevice::get_erase_size() const
|
|||
return _erase_size;
|
||||
}
|
||||
|
||||
int ChainingBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _erase_value;
|
||||
}
|
||||
|
||||
bd_size_t ChainingBlockDevice::size() const
|
||||
{
|
||||
return _size;
|
||||
|
|
|
@ -107,7 +107,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,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
@ -148,6 +160,7 @@ protected:
|
|||
bd_size_t _program_size;
|
||||
bd_size_t _erase_size;
|
||||
bd_size_t _size;
|
||||
int _erase_value;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -102,6 +102,11 @@ bd_size_t ExhaustibleBlockDevice::get_erase_size() const
|
|||
return _bd->get_erase_size();
|
||||
}
|
||||
|
||||
int ExhaustibleBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _bd->get_erase_value();
|
||||
}
|
||||
|
||||
bd_size_t ExhaustibleBlockDevice::size() const
|
||||
{
|
||||
return _bd->size();
|
||||
|
|
|
@ -92,7 +92,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
|
||||
|
@ -118,6 +119,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
|
|
@ -267,6 +267,11 @@ bd_size_t MBRBlockDevice::get_erase_size() const
|
|||
return _bd->get_erase_size();
|
||||
}
|
||||
|
||||
int MBRBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _bd->get_erase_value();
|
||||
}
|
||||
|
||||
bd_size_t MBRBlockDevice::size() const
|
||||
{
|
||||
return _size;
|
||||
|
|
|
@ -161,7 +161,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
|
||||
|
@ -189,6 +190,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
|
|
@ -91,6 +91,11 @@ bd_size_t ObservingBlockDevice::get_erase_size() const
|
|||
return _bd->get_erase_size();
|
||||
}
|
||||
|
||||
int ObservingBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _bd->get_erase_value();
|
||||
}
|
||||
|
||||
bd_size_t ObservingBlockDevice::size() const
|
||||
{
|
||||
return _bd->size();
|
||||
|
|
|
@ -78,7 +78,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
|
||||
|
@ -104,6 +105,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
|
|
@ -77,6 +77,11 @@ bd_size_t ProfilingBlockDevice::get_erase_size() const
|
|||
return _bd->get_erase_size();
|
||||
}
|
||||
|
||||
int ProfilingBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _bd->get_erase_value();
|
||||
}
|
||||
|
||||
bd_size_t ProfilingBlockDevice::size() const
|
||||
{
|
||||
return _bd->size();
|
||||
|
|
|
@ -93,7 +93,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
|
||||
|
@ -121,6 +122,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
|
|
@ -77,6 +77,11 @@ bd_size_t ReadOnlyBlockDevice::get_erase_size() const
|
|||
return _bd->get_erase_size();
|
||||
}
|
||||
|
||||
int ReadOnlyBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _bd->get_erase_value();
|
||||
}
|
||||
|
||||
bd_size_t ReadOnlyBlockDevice::size() const
|
||||
{
|
||||
return _bd->size();
|
||||
|
|
|
@ -71,7 +71,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
|
||||
|
@ -97,6 +98,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
|
|
@ -97,6 +97,11 @@ bd_size_t SlicingBlockDevice::get_erase_size() const
|
|||
return _bd->get_erase_size();
|
||||
}
|
||||
|
||||
int SlicingBlockDevice::get_erase_value() const
|
||||
{
|
||||
return _bd->get_erase_value();
|
||||
}
|
||||
|
||||
bd_size_t SlicingBlockDevice::size() const
|
||||
{
|
||||
return _stop - _start;
|
||||
|
|
|
@ -99,7 +99,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
|
||||
|
@ -127,6 +128,17 @@ public:
|
|||
*/
|
||||
virtual bd_size_t get_erase_size() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Get the total size of the underlying device
|
||||
*
|
||||
* @return Size of the underlying device in bytes
|
||||
|
|
Loading…
Reference in New Issue