Attn: Add support for raw PEL creation

Attention handler needs to pass raw PEL's to phosphor logging in order
to submit PEL's on behalf of other components (e.g. hypervisor)

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: Id9a30728e7b463ac876b5dca023ca2627a25bb16
diff --git a/attn/pel/section_header.hpp b/attn/pel/section_header.hpp
new file mode 100644
index 0000000..ae0a2c5
--- /dev/null
+++ b/attn/pel/section_header.hpp
@@ -0,0 +1,130 @@
+#pragma once
+
+#include "stream.hpp"
+
+#include <cstdint>
+
+namespace attn
+{
+namespace pel
+{
+
+/**
+ * @class SectionHeader
+ *
+ * @brief This 8-byte header is at the start of every PEL section.
+ *
+ * |--------+------------+------------+-----------+------------|
+ * | length | byte0      | byte1      | byte2     | byte3      |
+ * |--------+------------+------------+-----------+------------|
+ * | 4      | Section ID              | Section Length         |
+ * |--------+------------+-------------------------------------|
+ * | 4      | Version    | Sub-type   | Component ID           |
+ * |--------+--------------------------------------------------|
+ *
+ * Section ID:
+ * A two-ASCII character field which uniquely identifies the type of section.
+ *
+ * Section length:
+ * Length in bytes of the section, including the entire section header.
+ *
+ * Section Version:
+ * A one byte integer intended to identify differences in header structures.
+ *
+ * Section sub-type:
+ * Optional. Additional identifier describing the section.
+ *
+ * Component IDs:
+ * Optional. By convention the creator's component ID is placed in the
+ * component ID field of the Private Header and the committing component
+ * ID is placed in the component ID field of the User Header.
+ */
+struct SectionHeader
+{
+  public:
+    /**
+     * @brief Constructor
+     */
+    SectionHeader() : id(0), size(0), version(0), subType(0), componentID(0) {}
+
+    /**
+     * @brief Constructor
+     *
+     * @param[in] id - the ID field
+     * @param[in] size - the size field
+     * @param[in] version - the version field
+     * @param[in] subType - the sub-type field
+     * @param[in] componentID - the component ID field
+     */
+    SectionHeader(uint16_t id, uint16_t size, uint8_t version, uint8_t subType,
+                  uint16_t componentID) :
+        id(id),
+        size(size), version(version), subType(subType), componentID(componentID)
+    {}
+
+    /**
+     * @brief A two character ASCII field which identifies the section type.
+     */
+    uint16_t id;
+
+    /**
+     * @brief The size of the section in bytes, including this section header.
+     */
+    uint16_t size;
+
+    /**
+     * @brief The section format version.
+     */
+    uint8_t version;
+
+    /**
+     * @brief The section sub-type.
+     */
+    uint8_t subType;
+
+    /**
+     * @brief The component ID, which has various meanings depending on the
+     * section.
+     */
+    uint16_t componentID;
+
+    /**
+     * @brief Returns the size of header when flattened into a PEL.
+     *
+     * @return size_t - the size of the header
+     */
+    static constexpr size_t flattenedSize()
+    {
+        return sizeof(id) + sizeof(size) + sizeof(version) + sizeof(subType) +
+               sizeof(componentID);
+    }
+};
+
+/**
+ * @brief Stream extraction operator for the SectionHeader
+ *
+ * @param[in] s - the stream
+ * @param[out] header - the SectionHeader object
+ */
+inline Stream& operator>>(Stream& s, SectionHeader& header)
+{
+    s >> header.id >> header.size >> header.version >> header.subType >>
+        header.componentID;
+    return s;
+}
+
+/**
+ * @brief Stream insertion operator for the section header
+ *
+ * @param[out] s - the stream
+ * @param[in] header - the SectionHeader object
+ */
+inline Stream& operator<<(Stream& s, const SectionHeader& header)
+{
+    s << header.id << header.size << header.version << header.subType
+      << header.componentID;
+    return s;
+}
+
+} // namespace pel
+} // namespace attn