summaryrefslogtreecommitdiffstats
path: root/pnor_partition_table.hpp
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-01 12:07:13 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-24 13:59:32 +1030
commit7f9c343a4f62abb9ea6eb64974b19ff7b6c879f2 (patch)
tree2520990d9e6df9cab7ff06f0cd9ba37fb9dbe406 /pnor_partition_table.hpp
parentb87aa329fa5b00a2f7f27e3cbe18dadad4dd4184 (diff)
downloadphosphor-mboxd-7f9c343a4f62abb9ea6eb64974b19ff7b6c879f2.tar.gz
phosphor-mboxd-7f9c343a4f62abb9ea6eb64974b19ff7b6c879f2.zip
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>
Diffstat (limited to 'pnor_partition_table.hpp')
-rw-r--r--pnor_partition_table.hpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/pnor_partition_table.hpp b/pnor_partition_table.hpp
index fae03a9..d19ff4b 100644
--- a/pnor_partition_table.hpp
+++ b/pnor_partition_table.hpp
@@ -4,6 +4,7 @@
#include <memory>
#include <numeric>
#include <experimental/filesystem>
+#include "common.h"
#include "pnor_partition_defs.h"
namespace openpower
@@ -102,13 +103,34 @@ class Table
Table& operator=(Table&&) = delete;
~Table() = default;
- /** @brief Return size of partition table
+ /** @brief Return the exact size of partition table in bytes
*
- * @returns size_t - size of partition table in blocks
+ * @returns size_t - size of partition table in bytes
*/
size_t size() const
{
- return szBlocks;
+ return szBytes;
+ }
+
+ /** @brief Return aligned size of partition table in bytes
+ *
+ * The value returned will be greater-than or equal to size(), and
+ * aligned to blockSize.
+ *
+ * @returns size_t - capacity of partition table in bytes
+ */
+ size_t capacity() const
+ {
+ return align_up(szBytes, blockSize);
+ }
+
+ /** @brief Return the size of partition table in blocks
+ *
+ * @returns size_t - size of partition table in blocks
+ */
+ size_t blocks() const
+ {
+ return capacity() / blockSize;
}
/** @brief Return a partition table having byte-ordering
@@ -181,9 +203,8 @@ class Table
/** @brief Size of the PNOR partition table -
* sizeof(pnor_partition_table) +
* (no. of partitions * sizeof(pnor_partition)),
- * measured in erase-blocks.
*/
- size_t szBlocks;
+ size_t szBytes;
/** @brief Partition table */
PartitionTable tbl;
OpenPOWER on IntegriCloud