PEL: Add PrivateHeader class
The first section in a PEL is always the 'Private Header' section. This
commit adds a class to represent that. Right now, the only constructor
available is filling in its data fields from a PEL stream.
The Section base class, which will be the base class of all PEL
sections, is also being introduced here. It contains the section header
structure, and a valid flag that derived classes can use.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ia5806017155fe1ef29ea57bf8ab202ff861bde2e
diff --git a/extensions/openpower-pels/section.hpp b/extensions/openpower-pels/section.hpp
new file mode 100644
index 0000000..7214e17
--- /dev/null
+++ b/extensions/openpower-pels/section.hpp
@@ -0,0 +1,73 @@
+#pragma once
+#include "section_header.hpp"
+
+namespace openpower
+{
+namespace pels
+{
+
+/**
+ * @class Section
+ *
+ * The base class for a PEL section. It contains the SectionHeader
+ * as all sections start with it.
+ *
+ */
+class Section
+{
+ public:
+ Section() = default;
+ virtual ~Section() = default;
+ Section(const Section&) = default;
+ Section& operator=(const Section&) = default;
+ Section(Section&&) = default;
+ Section& operator=(Section&&) = default;
+
+ /**
+ * @brief Returns a reference to the SectionHeader
+ */
+ SectionHeader& header()
+ {
+ return _header;
+ }
+
+ /**
+ * @brief Says if the section is valid.
+ */
+ bool valid() const
+ {
+ return _valid;
+ }
+
+ protected:
+ /**
+ * @brief Returns the flattened size of the section header
+ */
+ static constexpr size_t flattenedSize()
+ {
+ return SectionHeader::flattenedSize();
+ }
+
+ /**
+ * @brief Used to validate the section.
+ *
+ * Implemented by derived classes.
+ */
+ virtual void validate() = 0;
+
+ /**
+ * @brief The section header structure.
+ *
+ * Filled in by derived classes.
+ */
+ SectionHeader _header;
+
+ /**
+ * @brief The section valid flag.
+ *
+ * This is determined by the derived class.
+ */
+ bool _valid = false;
+};
+} // namespace pels
+} // namespace openpower