Extend storage volume for fw update installation
To install update images into storage, a flash storage volume needs
to be erased prior to streamed write operations to install the new
image. This change extends volume support to add an erase operation
that can be implemented by a concrete volume. Block volume tests
have been extended to include a test scenario that mimics multiple
image install operations. Also adds an optional method to get
GUIDs related to volume storage to facilitate populating the
FWU fw_directory.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I3ba4dea6d0ed82d6bb54066c7df97c5d6d7d4c87
diff --git a/components/media/disk/formatter/disk_formatter.c b/components/media/disk/formatter/disk_formatter.c
index 6b6d146..1d8e2fe 100644
--- a/components/media/disk/formatter/disk_formatter.c
+++ b/components/media/disk/formatter/disk_formatter.c
@@ -10,14 +10,14 @@
int disk_formatter_clone(
uintptr_t dev_handle,
- uintptr_t volume_spec,
+ uintptr_t io_spec,
const uint8_t *source_image,
size_t source_image_size)
{
uintptr_t volume_handle;
int result;
- result = io_open(dev_handle, volume_spec, &volume_handle);
+ result = io_open(dev_handle, io_spec, &volume_handle);
if (result != 0)
return result;
diff --git a/components/media/disk/formatter/disk_formatter.h b/components/media/disk/formatter/disk_formatter.h
index 95b058e..e461d9a 100644
--- a/components/media/disk/formatter/disk_formatter.h
+++ b/components/media/disk/formatter/disk_formatter.h
@@ -18,7 +18,7 @@
* @brief Format a storage volume by cloning a disk image
*
* @param[in] dev_handle IO device handle
- * @param[in] volume_spec Opaque volume spec
+ * @param[in] io_spec Opaque volume spec
* @param[in] source_image The source disk image to clone
* @param[in] source_image_size The size of the source image
*
@@ -26,7 +26,7 @@
*/
int disk_formatter_clone(
uintptr_t dev_handle,
- uintptr_t volume_spec,
+ uintptr_t io_spec,
const uint8_t *source_image,
size_t source_image_size);
diff --git a/components/media/disk/test/partition_table_tests.cpp b/components/media/disk/test/partition_table_tests.cpp
index 9a38a99..29cf0dd 100644
--- a/components/media/disk/test/partition_table_tests.cpp
+++ b/components/media/disk/test/partition_table_tests.cpp
@@ -11,7 +11,7 @@
#include <service/block_storage/block_store/device/ram/ram_block_store.h>
#include <service/block_storage/config/ref/ref_partition_configurator.h>
#include <media/volume/index/volume_index.h>
-#include <media/volume/block_io_dev/block_io_dev.h>
+#include <media/volume/block_volume/block_volume.h>
#include <media/disk/disk_images/ref_partition.h>
#include <media/disk/formatter/disk_formatter.h>
#include <media/disk/partition_table.h>
@@ -33,30 +33,28 @@
memset(m_partition_guid.octets, 0, sizeof(m_partition_guid.octets));
- m_dev_handle = 0;
- m_volume_spec = 0;
+ m_volume = NULL;
- int result = block_io_dev_init(&m_block_io_dev,
+ int result = block_volume_init(&m_block_volume,
m_block_store, &m_partition_guid,
- &m_dev_handle, &m_volume_spec);
+ &m_volume);
LONGS_EQUAL(0, result);
- CHECK_TRUE(m_dev_handle);
- CHECK_TRUE(m_volume_spec);
+ CHECK_TRUE(m_volume);
result = disk_formatter_clone(
- m_dev_handle, m_volume_spec,
+ m_volume->dev_handle, m_volume->io_spec,
ref_partition_data, ref_partition_data_length);
LONGS_EQUAL(0, result);
volume_index_init();
- volume_index_add(VOLUME_ID_SECURE_FLASH, m_dev_handle, m_volume_spec);
+ volume_index_add(VOLUME_ID_SECURE_FLASH, m_volume);
}
void teardown()
{
- block_io_dev_deinit(&m_block_io_dev);
+ block_volume_deinit(&m_block_volume);
ram_block_store_deinit(&m_ram_block_store);
volume_index_clear();
}
@@ -92,9 +90,8 @@
struct uuid_octets m_partition_guid;
struct block_store *m_block_store;
struct ram_block_store m_ram_block_store;
- struct block_io_dev m_block_io_dev;
- uintptr_t m_dev_handle;
- uintptr_t m_volume_spec;
+ struct block_volume m_block_volume;
+ struct volume *m_volume;
};
TEST(PartitionTableTests, loadRefPartitionTable)