pnor_partition_table: Rework semantics of Table::size()
Table::size() now returns the exact table size in bytes,
Table::capacity() returns the block-aligned size in bytes (capacity in
terms of how much the table could grow before expanding to another
block), and Table::blocks() returns the size in blocks.
This helps out with code clarity around the codebase and enables the
introduction of ToC-related integration tests.
The one wrinkle is vpnor_get_partition_table_size(), which is modified
to call Table::blocks() but retains 'size' in its name. This is largely
unimportant as the function will go away shortly.
Change-Id: I3becf47f2201df5fe0bed86fcb92d7b94d06ab11
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd_pnor_partition_table.cpp b/mboxd_pnor_partition_table.cpp
index 40d2ea6..39a4529 100644
--- a/mboxd_pnor_partition_table.cpp
+++ b/mboxd_pnor_partition_table.cpp
@@ -64,7 +64,7 @@
size_t vpnor_get_partition_table_size(const struct mbox_context *context)
{
- return context && context->vpnor ? context->vpnor->table->size() : 0;
+ return context && context->vpnor ? context->vpnor->table->blocks() : 0;
}
const struct pnor_partition_table *
@@ -118,11 +118,11 @@
memcpy(&local.paths, &context->paths, sizeof(local.paths));
size_t tocOffset = 0;
- uint32_t tocSize = blTable.size() * eraseSize;
// Copy TOC
copy_flash(&local, tocOffset,
- static_cast<uint8_t *>(context->mem) + tocStart, tocSize);
+ static_cast<uint8_t *>(context->mem) + tocStart,
+ blTable.capacity());
const pnor_partition &partition = blTable.partition(blPartitionName);
size_t hbbOffset = partition.data.base * eraseSize;
uint32_t hbbSize = partition.data.actual;