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/pel_minimal.cpp b/attn/pel/pel_minimal.cpp
new file mode 100644
index 0000000..9d7dfc1
--- /dev/null
+++ b/attn/pel/pel_minimal.cpp
@@ -0,0 +1,95 @@
+#include "pel_minimal.hpp"
+
+#include "stream.hpp"
+
+namespace attn
+{
+namespace pel
+{
+
+PelMinimal::PelMinimal(std::vector<uint8_t>& data)
+{
+    Stream pelData{data};
+
+    _ph = std::make_unique<PrivateHeader>(pelData);
+    _uh = std::make_unique<UserHeader>(pelData);
+    _ps = std::make_unique<PrimarySrc>(pelData);
+}
+
+void PelMinimal::raw(std::vector<uint8_t>& pelBuffer) const
+{
+    Stream pelData{pelBuffer};
+
+    // stream from object to buffer
+    _ph->flatten(pelData);
+    _uh->flatten(pelData);
+    _ps->flatten(pelData);
+}
+
+size_t PelMinimal::size() const
+{
+    size_t size = 0;
+
+    // size of private header section
+    if (_ph)
+    {
+        size += _ph->header().size;
+    }
+
+    // size of user header section
+    if (_uh)
+    {
+        size += _uh->header().size;
+    }
+
+    // size of primary SRC section
+    if (_ps)
+    {
+        size += _ph->header().size;
+    }
+
+    return ((size > _maxPELSize) ? _maxPELSize : size);
+}
+
+void PelMinimal::setSubsystem(uint8_t subsystem)
+{
+    _uh->setSubsystem(subsystem);
+}
+
+void PelMinimal::setSeverity(uint8_t severity)
+{
+    _uh->setSeverity(severity);
+}
+
+void PelMinimal::setType(uint8_t type)
+{
+    _uh->setType(type);
+}
+
+void PelMinimal::setAction(uint16_t action)
+{
+    _uh->setAction(action);
+}
+
+void PelMinimal::setSrcWords(std::array<uint32_t, numSrcWords> srcWords)
+{
+    _ps->setSrcWords(srcWords);
+}
+
+void PelMinimal::setAsciiString(std::array<char, asciiStringSize> asciiString)
+{
+    _ps->setAsciiString(asciiString);
+}
+
+uint8_t PelMinimal::getSectionCount()
+{
+    return _ph->getSectionCount();
+}
+
+void PelMinimal::setSectionCount(uint8_t sectionCount)
+{
+    _ph->setSectionCount(sectionCount);
+}
+
+} // namespace pel
+} // namespace attn