summaryrefslogtreecommitdiffstats
path: root/pnor_partition_table.hpp
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-09 15:27:03 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-19 10:56:22 +1030
commitf34db31d768e38c3add58a83cd943609771fd212 (patch)
tree659f3f17e8405f5edd7000f251345f5c889d5a22 /pnor_partition_table.hpp
parent25eca77fabceb86e10ac4eb0cbe32484cbf21c14 (diff)
downloadphosphor-mboxd-f34db31d768e38c3add58a83cd943609771fd212.tar.gz
phosphor-mboxd-f34db31d768e38c3add58a83cd943609771fd212.zip
Format C++ files according to OpenBMC style guide
We don't touch the C yet as upstream hasn't got such a change in place. Change-Id: Ie6cab4bf99df520bb6655b9b00ae31e762e3c57b Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'pnor_partition_table.hpp')
-rw-r--r--pnor_partition_table.hpp329
1 files changed, 162 insertions, 167 deletions
diff --git a/pnor_partition_table.hpp b/pnor_partition_table.hpp
index 2d0d007..d3d7fa4 100644
--- a/pnor_partition_table.hpp
+++ b/pnor_partition_table.hpp
@@ -34,8 +34,7 @@ namespace details
*
* @returns computed checksum
*/
-template <class T>
-checksum_t checksum(const T& data)
+template <class T> checksum_t checksum(const T& data)
{
static_assert(sizeof(decltype(data)) % sizeof(checksum_t) == 0,
"sizeof(data) is not aligned to sizeof(checksum_t) boundary");
@@ -70,171 +69,167 @@ namespace partition
*/
class Table
{
- public:
- /** @brief Constructor accepting the path of the directory
- * that houses the PNOR partition files.
- *
- * @param[in] directory - path of the directory housing PNOR partitions
- * @param[in] blockSize - PNOR block size, in bytes. See
- * open-power/hostboot/blob/master/src/usr/pnor/ffs.h for
- * the PNOR FFS structure.
- * @param[in] pnorSize - PNOR size, in bytes
- */
- Table(fs::path&& directory,
- size_t blockSize,
- size_t pnorSize);
-
- /** @brief Constructor - creates partition table
- *
- * @param[in] blockSize - PNOR block size, in bytes
- * @param[in] pnorSize - PNOR size, in bytes
- */
- Table(size_t blockSize,
- size_t pnorSize);
-
- Table(const Table&) = delete;
- Table& operator=(const Table&) = delete;
- Table(Table&&) = delete;
- Table& operator=(Table&&) = delete;
- ~Table() = default;
-
- /** @brief Return size of partition table
- *
- * @returns size_t - size of partition table in blocks
- */
- size_t size() const
- {
- return szBlocks;
- }
-
- /** @brief Return a partition table having byte-ordering
- * that the host expects.
- *
- * The host needs the partion table in big-endian.
- *
- * @returns const reference to host partition table.
- */
- const pnor_partition_table& getHostTable() const
- {
- return *(reinterpret_cast<
- const pnor_partition_table*>(hostTbl.data()));
- }
-
- /** @brief Return a little-endian partition table
- *
- * @returns const reference to native partition table
- */
- const pnor_partition_table& getNativeTable() const
- {
- return *(reinterpret_cast<const pnor_partition_table*>(tbl.data()));
- }
-
- /** @brief Return partition corresponding to PNOR offset, the offset
- * is within returned partition.
- *
- * @param[in] offset - PNOR offset in bytes
- *
- * @returns const reference to pnor_partition, if found, else an
- * exception will be thrown.
- */
- const pnor_partition& partition(size_t offset) const;
-
- /** @brief Return partition corresponding to input partition name.
- *
- * @param[in] name - PNOR partition name
- *
- * @returns const reference to pnor_partition, if found, else an
- * exception will be thrown.
- */
- const pnor_partition& partition(const std::string& name) const;
-
- private:
- /** @brief Prepares a vector of PNOR partition structures.
- */
- void preparePartitions();
-
- /** @brief Prepares the PNOR header.
- */
- void prepareHeader();
-
- /** @brief Allocate memory to hold the partion table. Determine the
- * amount needed based on the partition files in the toc file.
- *
- * @param[in] tocFile - Table of contents file path.
- */
- void allocateMemory(const fs::path& tocFile);
-
- /** @brief Populate fields related to sizes for the input
- * pnor_partition structure.
- *
- * @param[in/out] part - pnor_partition structure
- * @param[in] start - partition start address
- * @param[in] end - partition end address
- */
- void writeSizes(pnor_partition& part, size_t start, size_t end);
-
- /** @brief Populate userdata bits for the input
- * pnor_partition structure.
- *
- * @param[in/out] part - pnor_partition structure
- * @param[in] version - partition version check algorithm to be used
- * (see pnor_partition_defs.h)
- * @param[in] data - string having userdata fields in a
- * comma-separated line.
- */
- void writeUserdata(pnor_partition& part, uint32_t version,
- const std::string& data);
-
- /** @brief Populate the name and id fields for the input
- * pnor_partition structure.
- *
- * @param[in/out] part - pnor_partition structure
- * @param[in] name - partition name
- * @param[id] id - partition id
- */
- void writeNameAndId(pnor_partition& part, std::string&& name,
- const std::string& id);
-
- /** @brief Populate default/unused fields for the input
- * pnor_partition structure.
- *
- * @param[in/out] part - pnor_partition structure
- */
- void writeDefaults(pnor_partition& part);
-
- /** @brief Return a little-endian partition table
- *
- * @returns reference to native partition table
- */
- pnor_partition_table& getNativeTable()
- {
- return *(reinterpret_cast<pnor_partition_table*>(tbl.data()));
- }
-
- /** @brief Size of the PNOR partition table -
- * sizeof(pnor_partition_table) +
- * (no. of partitions * sizeof(pnor_partition)),
- * measured in erase-blocks.
- */
- size_t szBlocks;
-
- /** @brief Partition table */
- PartitionTable tbl;
-
- /** @brief Partition table with host byte ordering */
- PartitionTable hostTbl;
-
- /** @brief Directory housing generated PNOR partition files */
- fs::path directory;
-
- /** @brief Number of partitions */
- size_t numParts;
-
- /** @brief PNOR block size, in bytes */
- size_t blockSize;
-
- /** @brief PNOR size, in bytes */
- size_t pnorSize;
+ public:
+ /** @brief Constructor accepting the path of the directory
+ * that houses the PNOR partition files.
+ *
+ * @param[in] directory - path of the directory housing PNOR partitions
+ * @param[in] blockSize - PNOR block size, in bytes. See
+ * open-power/hostboot/blob/master/src/usr/pnor/ffs.h for
+ * the PNOR FFS structure.
+ * @param[in] pnorSize - PNOR size, in bytes
+ */
+ Table(fs::path&& directory, size_t blockSize, size_t pnorSize);
+
+ /** @brief Constructor - creates partition table
+ *
+ * @param[in] blockSize - PNOR block size, in bytes
+ * @param[in] pnorSize - PNOR size, in bytes
+ */
+ Table(size_t blockSize, size_t pnorSize);
+
+ Table(const Table&) = delete;
+ Table& operator=(const Table&) = delete;
+ Table(Table&&) = delete;
+ Table& operator=(Table&&) = delete;
+ ~Table() = default;
+
+ /** @brief Return size of partition table
+ *
+ * @returns size_t - size of partition table in blocks
+ */
+ size_t size() const
+ {
+ return szBlocks;
+ }
+
+ /** @brief Return a partition table having byte-ordering
+ * that the host expects.
+ *
+ * The host needs the partion table in big-endian.
+ *
+ * @returns const reference to host partition table.
+ */
+ const pnor_partition_table& getHostTable() const
+ {
+ return *(reinterpret_cast<const pnor_partition_table*>(hostTbl.data()));
+ }
+
+ /** @brief Return a little-endian partition table
+ *
+ * @returns const reference to native partition table
+ */
+ const pnor_partition_table& getNativeTable() const
+ {
+ return *(reinterpret_cast<const pnor_partition_table*>(tbl.data()));
+ }
+
+ /** @brief Return partition corresponding to PNOR offset, the offset
+ * is within returned partition.
+ *
+ * @param[in] offset - PNOR offset in bytes
+ *
+ * @returns const reference to pnor_partition, if found, else an
+ * exception will be thrown.
+ */
+ const pnor_partition& partition(size_t offset) const;
+
+ /** @brief Return partition corresponding to input partition name.
+ *
+ * @param[in] name - PNOR partition name
+ *
+ * @returns const reference to pnor_partition, if found, else an
+ * exception will be thrown.
+ */
+ const pnor_partition& partition(const std::string& name) const;
+
+ private:
+ /** @brief Prepares a vector of PNOR partition structures.
+ */
+ void preparePartitions();
+
+ /** @brief Prepares the PNOR header.
+ */
+ void prepareHeader();
+
+ /** @brief Allocate memory to hold the partion table. Determine the
+ * amount needed based on the partition files in the toc file.
+ *
+ * @param[in] tocFile - Table of contents file path.
+ */
+ void allocateMemory(const fs::path& tocFile);
+
+ /** @brief Populate fields related to sizes for the input
+ * pnor_partition structure.
+ *
+ * @param[in/out] part - pnor_partition structure
+ * @param[in] start - partition start address
+ * @param[in] end - partition end address
+ */
+ void writeSizes(pnor_partition& part, size_t start, size_t end);
+
+ /** @brief Populate userdata bits for the input
+ * pnor_partition structure.
+ *
+ * @param[in/out] part - pnor_partition structure
+ * @param[in] version - partition version check algorithm to be used
+ * (see pnor_partition_defs.h)
+ * @param[in] data - string having userdata fields in a
+ * comma-separated line.
+ */
+ void writeUserdata(pnor_partition& part, uint32_t version,
+ const std::string& data);
+
+ /** @brief Populate the name and id fields for the input
+ * pnor_partition structure.
+ *
+ * @param[in/out] part - pnor_partition structure
+ * @param[in] name - partition name
+ * @param[id] id - partition id
+ */
+ void writeNameAndId(pnor_partition& part, std::string&& name,
+ const std::string& id);
+
+ /** @brief Populate default/unused fields for the input
+ * pnor_partition structure.
+ *
+ * @param[in/out] part - pnor_partition structure
+ */
+ void writeDefaults(pnor_partition& part);
+
+ /** @brief Return a little-endian partition table
+ *
+ * @returns reference to native partition table
+ */
+ pnor_partition_table& getNativeTable()
+ {
+ return *(reinterpret_cast<pnor_partition_table*>(tbl.data()));
+ }
+
+ /** @brief Size of the PNOR partition table -
+ * sizeof(pnor_partition_table) +
+ * (no. of partitions * sizeof(pnor_partition)),
+ * measured in erase-blocks.
+ */
+ size_t szBlocks;
+
+ /** @brief Partition table */
+ PartitionTable tbl;
+
+ /** @brief Partition table with host byte ordering */
+ PartitionTable hostTbl;
+
+ /** @brief Directory housing generated PNOR partition files */
+ fs::path directory;
+
+ /** @brief Number of partitions */
+ size_t numParts;
+
+ /** @brief PNOR block size, in bytes */
+ size_t blockSize;
+
+ /** @brief PNOR size, in bytes */
+ size_t pnorSize;
};
} // namespace partition
OpenPOWER on IntegriCloud