mirror of https://github.com/ARMmbed/mbed-os.git
Add overloaded get_erase_size API with address parameter to all block devices
parent
7c30faf69d
commit
a6048005d7
|
@ -48,6 +48,7 @@ void test_slicing() {
|
||||||
TEST_ASSERT_EQUAL(0, err);
|
TEST_ASSERT_EQUAL(0, err);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(BLOCK_SIZE, slice1.get_program_size());
|
TEST_ASSERT_EQUAL(BLOCK_SIZE, slice1.get_program_size());
|
||||||
|
TEST_ASSERT_EQUAL(BLOCK_SIZE, slice1.get_erase_size(BLOCK_SIZE));
|
||||||
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, slice1.size());
|
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, slice1.size());
|
||||||
|
|
||||||
// Fill with random sequence
|
// Fill with random sequence
|
||||||
|
@ -142,6 +143,7 @@ void test_chaining() {
|
||||||
TEST_ASSERT_EQUAL(0, err);
|
TEST_ASSERT_EQUAL(0, err);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(BLOCK_SIZE, chain.get_program_size());
|
TEST_ASSERT_EQUAL(BLOCK_SIZE, chain.get_program_size());
|
||||||
|
TEST_ASSERT_EQUAL(BLOCK_SIZE, chain.get_erase_size((BLOCK_COUNT/2)*BLOCK_SIZE+1));
|
||||||
TEST_ASSERT_EQUAL(BLOCK_COUNT*BLOCK_SIZE, chain.size());
|
TEST_ASSERT_EQUAL(BLOCK_COUNT*BLOCK_SIZE, chain.size());
|
||||||
|
|
||||||
// Fill with random sequence
|
// Fill with random sequence
|
||||||
|
|
|
@ -135,9 +135,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const = 0;
|
virtual bd_size_t get_program_size() const = 0;
|
||||||
|
|
||||||
/** Get the size of a eraseable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a eraseable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
* @note Must be a multiple of the program size
|
* @note Must be a multiple of the program size
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const
|
virtual bd_size_t get_erase_size() const
|
||||||
|
@ -145,6 +145,17 @@ public:
|
||||||
return get_program_size();
|
return get_program_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return get_erase_size();
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -211,6 +211,22 @@ bd_size_t ChainingBlockDevice::get_erase_size() const
|
||||||
return _erase_size;
|
return _erase_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t ChainingBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
bd_addr_t bd_start_addr = 0;
|
||||||
|
for (size_t i = 0; i < _bd_count; i++) {
|
||||||
|
bd_size_t bdsize = _bds[i]->size();
|
||||||
|
if (addr < (bd_start_addr + bdsize)) {
|
||||||
|
return _bds[i]->get_erase_size(addr - bd_start_addr);
|
||||||
|
}
|
||||||
|
bd_start_addr += bdsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getting here implies an illegal address
|
||||||
|
MBED_ASSERT(0);
|
||||||
|
return 0; // satisfy compiler
|
||||||
|
}
|
||||||
|
|
||||||
int ChainingBlockDevice::get_erase_value() const
|
int ChainingBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _erase_value;
|
return _erase_value;
|
||||||
|
|
|
@ -135,13 +135,21 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a eraseable block
|
/** Get the size of an eraseable block
|
||||||
*
|
*
|
||||||
* @return Size of a eraseable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
* @note Must be a multiple of the program size
|
* @note Must be a multiple of the program size
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -107,6 +107,11 @@ bd_size_t ExhaustibleBlockDevice::get_erase_size() const
|
||||||
return _bd->get_erase_size();
|
return _bd->get_erase_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t ExhaustibleBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return _bd->get_erase_size(addr);
|
||||||
|
}
|
||||||
|
|
||||||
int ExhaustibleBlockDevice::get_erase_value() const
|
int ExhaustibleBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _bd->get_erase_value();
|
return _bd->get_erase_value();
|
||||||
|
|
|
@ -119,12 +119,20 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a erasable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a erasable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -81,6 +81,12 @@ bd_size_t HeapBlockDevice::get_erase_size() const
|
||||||
return _erase_size;
|
return _erase_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t HeapBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
MBED_ASSERT(_blocks != NULL);
|
||||||
|
return _erase_size;
|
||||||
|
}
|
||||||
|
|
||||||
bd_size_t HeapBlockDevice::size() const
|
bd_size_t HeapBlockDevice::size() const
|
||||||
{
|
{
|
||||||
MBED_ASSERT(_blocks != NULL);
|
MBED_ASSERT(_blocks != NULL);
|
||||||
|
|
|
@ -124,12 +124,20 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a eraseable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a eraseable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the total size of the underlying device
|
/** Get the total size of the underlying device
|
||||||
*
|
*
|
||||||
* @return Size of the underlying device in bytes
|
* @return Size of the underlying device in bytes
|
||||||
|
|
|
@ -276,6 +276,11 @@ bd_size_t MBRBlockDevice::get_erase_size() const
|
||||||
return _bd->get_erase_size();
|
return _bd->get_erase_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t MBRBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return _bd->get_erase_size(_offset + addr);
|
||||||
|
}
|
||||||
|
|
||||||
int MBRBlockDevice::get_erase_value() const
|
int MBRBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _bd->get_erase_value();
|
return _bd->get_erase_value();
|
||||||
|
|
|
@ -194,13 +194,21 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a eraseable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a eraseable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
* @note Must be a multiple of the program size
|
* @note Must be a multiple of the program size
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -96,6 +96,11 @@ bd_size_t ObservingBlockDevice::get_erase_size() const
|
||||||
return _bd->get_erase_size();
|
return _bd->get_erase_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t ObservingBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return _bd->get_erase_size(addr);
|
||||||
|
}
|
||||||
|
|
||||||
int ObservingBlockDevice::get_erase_value() const
|
int ObservingBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _bd->get_erase_value();
|
return _bd->get_erase_value();
|
||||||
|
|
|
@ -105,12 +105,20 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a erasable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a erasable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -82,6 +82,11 @@ bd_size_t ProfilingBlockDevice::get_erase_size() const
|
||||||
return _bd->get_erase_size();
|
return _bd->get_erase_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t ProfilingBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return _bd->get_erase_size(addr);
|
||||||
|
}
|
||||||
|
|
||||||
int ProfilingBlockDevice::get_erase_value() const
|
int ProfilingBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _bd->get_erase_value();
|
return _bd->get_erase_value();
|
||||||
|
|
|
@ -121,13 +121,21 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a eraseable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a eraseable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
* @note Must be a multiple of the program size
|
* @note Must be a multiple of the program size
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -82,6 +82,11 @@ bd_size_t ReadOnlyBlockDevice::get_erase_size() const
|
||||||
return _bd->get_erase_size();
|
return _bd->get_erase_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t ReadOnlyBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return _bd->get_erase_size(addr);
|
||||||
|
}
|
||||||
|
|
||||||
int ReadOnlyBlockDevice::get_erase_value() const
|
int ReadOnlyBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _bd->get_erase_value();
|
return _bd->get_erase_value();
|
||||||
|
|
|
@ -98,12 +98,20 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a erasable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a erasable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
|
@ -102,6 +102,11 @@ bd_size_t SlicingBlockDevice::get_erase_size() const
|
||||||
return _bd->get_erase_size();
|
return _bd->get_erase_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd_size_t SlicingBlockDevice::get_erase_size(bd_addr_t addr) const
|
||||||
|
{
|
||||||
|
return _bd->get_erase_size(_start + addr);
|
||||||
|
}
|
||||||
|
|
||||||
int SlicingBlockDevice::get_erase_value() const
|
int SlicingBlockDevice::get_erase_value() const
|
||||||
{
|
{
|
||||||
return _bd->get_erase_value();
|
return _bd->get_erase_value();
|
||||||
|
|
|
@ -127,13 +127,21 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_program_size() const;
|
virtual bd_size_t get_program_size() const;
|
||||||
|
|
||||||
/** Get the size of a eraseable block
|
/** Get the size of an erasable block
|
||||||
*
|
*
|
||||||
* @return Size of a eraseable block in bytes
|
* @return Size of an erasable block in bytes
|
||||||
* @note Must be a multiple of the program size
|
* @note Must be a multiple of the program size
|
||||||
*/
|
*/
|
||||||
virtual bd_size_t get_erase_size() const;
|
virtual bd_size_t get_erase_size() const;
|
||||||
|
|
||||||
|
/** Get the size of an erasable block given address
|
||||||
|
*
|
||||||
|
* @param addr Address within the erasable block
|
||||||
|
* @return Size of an erasable block in bytes
|
||||||
|
* @note Must be a multiple of the program size
|
||||||
|
*/
|
||||||
|
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
|
||||||
|
|
||||||
/** Get the value of storage when erased
|
/** Get the value of storage when erased
|
||||||
*
|
*
|
||||||
* If get_erase_value returns a non-negative byte value, the underlying
|
* If get_erase_value returns a non-negative byte value, the underlying
|
||||||
|
|
Loading…
Reference in New Issue