PEL: Validate the Action Flags field

According to the PEL spec, the Action Flags and Event Type fields in the
User Header section must be in agreement with the Severity field. So,
when a PEL is being created from an OpenBMC event log, check those
values for correctness and fix them up if required.

In addition, as those fields are optional in the message registry, this
code will also just set these two fields to valid values if they were
left out.

The rules being followed are documented in the PEL readme.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iad88de5080ba79a9ff31f962ef99bfc11994b9ed
diff --git a/extensions/openpower-pels/user_header.cpp b/extensions/openpower-pels/user_header.cpp
index 432ae67..8092e38 100644
--- a/extensions/openpower-pels/user_header.cpp
+++ b/extensions/openpower-pels/user_header.cpp
@@ -62,8 +62,20 @@
 
     // TODO: ibm-dev/dev/#1144 Handle manufacturing sev & action flags
 
-    _eventType = entry.eventType.value_or(
-        static_cast<uint8_t>(EventType::notApplicable));
+    if (entry.eventType)
+    {
+        _eventType = *entry.eventType;
+    }
+    else
+    {
+        // There are different default event types for info errors
+        // vs non info ones.
+        auto sevType = static_cast<SeverityType>(_eventSeverity & 0xF0);
+
+        _eventType = (sevType == SeverityType::nonError)
+                         ? static_cast<uint8_t>(EventType::miscInformational)
+                         : static_cast<uint8_t>(EventType::notApplicable);
+    }
 
     _reserved4Byte1 = 0;
 
@@ -71,6 +83,7 @@
     _problemDomain = 0;
     _problemVector = 0;
 
+    // These will be cleaned up later in pel_rules::check()
     _actionFlags = entry.actionFlags.value_or(0);
 
     _reserved4Byte2 = 0;