1 #pragma once
2 
3 #include "pel_types.hpp"
4 
5 #include <cstdint>
6 #include <map>
7 #include <string>
8 #include <tuple>
9 #include <vector>
10 
11 namespace openpower
12 {
13 namespace pels
14 {
15 namespace pel_values
16 {
17 
18 // The actual value as it shows up in the PEL
19 const int fieldValuePos = 0;
20 
21 // The name of the value as specified in the message registry
22 const int registryNamePos = 1;
23 
24 // The description of the field, used by PEL parsers
25 const int descriptionPos = 2;
26 
27 using PELFieldValue = std::tuple<uint32_t, const char*, const char*>;
28 using PELValues = std::vector<PELFieldValue>;
29 
30 const std::string sectionVer = "Section Version";
31 const std::string subSection = "Sub-section type";
32 const std::string createdBy = "Created by";
33 
34 /**
35  * @brief Helper function to get values from lookup tables.
36  * @return std::string - the value
37  * @param[in] uint8_t - field to get value for
38  * @param[in] PELValues - lookup table
39  * @param[in] uint8_t - position in the pel_values table to read
40  */
41 std::string getValue(const uint8_t field, const pel_values::PELValues& values,
42                      const uint8_t position = pel_values::descriptionPos);
43 
44 /**
45  * @brief Helper function to get value vector from lookup tables.
46  *
47  * @param[in] value - the value to lookup
48  * @param[in] table - lookup table
49  *
50  * @return std::vector<std::string> - the value vector
51  */
52 std::vector<std::string> getValuesBitwise(uint16_t value,
53                                           const pel_values::PELValues& table);
54 /**
55  * @brief Find the desired entry in a PELValues table based on the
56  *        field value.
57  *
58  * @param[in] value - the PEL value to find
59  * @param[in] fields - the PEL values table to use
60  *
61  * @return PELValues::const_iterator - an iterator to the table entry
62  */
63 PELValues::const_iterator findByValue(uint32_t value, const PELValues& fields);
64 
65 /**
66  * @brief Find the desired entry in a PELValues table based on the
67  *        field message registry name.
68  *
69  * @param[in] name - the PEL message registry enum name
70  * @param[in] fields - the PEL values table to use
71  *
72  * @return PELValues::const_iterator - an iterator to the table entry
73  */
74 PELValues::const_iterator findByName(const std::string& name,
75                                      const PELValues& fields);
76 
77 /**
78  * @brief The values for the 'subsystem' field in the User Header
79  */
80 extern const PELValues subsystemValues;
81 
82 /**
83  * @brief The values for the 'severity' field in the User Header
84  */
85 extern const PELValues severityValues;
86 
87 /**
88  * @brief The values for the 'Event Type' field in the User Header
89  */
90 extern const PELValues eventTypeValues;
91 
92 /**
93  * @brief The values for the 'Event Scope' field in the User Header
94  */
95 extern const PELValues eventScopeValues;
96 
97 /**
98  * @brief The values for the 'Action Flags' field in the User Header
99  */
100 extern const PELValues actionFlagsValues;
101 
102 /**
103  * @brief The values for callout priorities in the SRC section
104  */
105 extern const PELValues calloutPriorityValues;
106 
107 /**
108  * @brief Map for section IDs
109  */
110 extern const std::map<std::string, std::string> sectionTitles;
111 
112 /**
113  * @brief Map for creator IDs
114  */
115 extern const std::map<std::string, std::string> creatorIDs;
116 
117 /**
118  * @brief Map for transmission states
119  */
120 extern const std::map<TransmissionState, std::string> transmissionStates;
121 
122 /**
123  * @brief Map for Procedure Descriptions
124  */
125 extern const std::map<std::string, std::string> procedureDesc;
126 
127 /**
128  * @brief Map for Callout Failing Component Types
129  */
130 extern const std::map<uint8_t, std::string> failingComponentType;
131 
132 /**
133  * @brief Map for Boolean value
134  */
135 extern const std::map<bool, std::string> boolString;
136 
137 /**
138  * @brief Map for maintenance procedures
139  */
140 extern const std::map<std::string, std::string> maintenanceProcedures;
141 
142 /**
143  * @brief Map for symbolic FRUs.
144  */
145 extern const std::map<std::string, std::string> symbolicFRUs;
146 
147 } // namespace pel_values
148 } // namespace pels
149 } // namespace openpower
150