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/primary_src.cpp b/attn/pel/primary_src.cpp
new file mode 100644
index 0000000..0123395
--- /dev/null
+++ b/attn/pel/primary_src.cpp
@@ -0,0 +1,50 @@
+#include "primary_src.hpp"
+
+namespace attn
+{
+namespace pel
+{
+
+PrimarySrc::PrimarySrc(Stream& pel)
+{
+    unflatten(pel);
+}
+
+void PrimarySrc::flatten(Stream& stream) const
+{
+    stream << _header << _version << _flags << _reserved1B << _wordCount
+           << _reserved2B << _size;
+
+    for (auto& word : _srcWords)
+    {
+        stream << word;
+    }
+
+    stream.write(_asciiString.data(), _asciiString.size());
+}
+
+void PrimarySrc::unflatten(Stream& stream)
+{
+    stream >> _header >> _version >> _flags >> _reserved1B >> _wordCount >>
+        _reserved2B >> _size;
+
+    for (auto& word : _srcWords)
+    {
+        stream >> word;
+    }
+
+    stream.read(_asciiString.data(), _asciiString.size());
+}
+
+void PrimarySrc::setSrcWords(std::array<uint32_t, numSrcWords> srcWords)
+{
+    _srcWords = srcWords;
+}
+
+void PrimarySrc::setAsciiString(std::array<char, asciiStringSize> asciiString)
+{
+    _asciiString = asciiString;
+}
+
+} // namespace pel
+} // namespace attn