xref: /openbmc/phosphor-logging/extensions/openpower-pels/pel_values.hpp (revision 81bc56119cf2d8e058371b007816aada99110498)
1835a8693SMatt Spinler #pragma once
2835a8693SMatt Spinler 
3455587e5SMatt Spinler #include "pel_types.hpp"
4455587e5SMatt Spinler 
5*81bc5611SMatt Spinler #include <cstdint>
6186ce8c9SAatir #include <map>
7835a8693SMatt Spinler #include <string>
8835a8693SMatt Spinler #include <tuple>
9835a8693SMatt Spinler #include <vector>
10835a8693SMatt Spinler 
11835a8693SMatt Spinler namespace openpower
12835a8693SMatt Spinler {
13835a8693SMatt Spinler namespace pels
14835a8693SMatt Spinler {
15835a8693SMatt Spinler namespace pel_values
16835a8693SMatt Spinler {
17835a8693SMatt Spinler 
18835a8693SMatt Spinler // The actual value as it shows up in the PEL
19835a8693SMatt Spinler const int fieldValuePos = 0;
20835a8693SMatt Spinler 
21835a8693SMatt Spinler // The name of the value as specified in the message registry
22835a8693SMatt Spinler const int registryNamePos = 1;
23835a8693SMatt Spinler 
24835a8693SMatt Spinler // The description of the field, used by PEL parsers
25835a8693SMatt Spinler const int descriptionPos = 2;
26835a8693SMatt Spinler 
27835a8693SMatt Spinler using PELFieldValue = std::tuple<uint32_t, const char*, const char*>;
28835a8693SMatt Spinler using PELValues = std::vector<PELFieldValue>;
29835a8693SMatt Spinler 
30bebeb948SHarisuddin Mohamed Isa const std::string sectionVer = "Section Version";
31bebeb948SHarisuddin Mohamed Isa const std::string subSection = "Sub-section type";
32bebeb948SHarisuddin Mohamed Isa const std::string createdBy = "Created by";
33bebeb948SHarisuddin Mohamed Isa 
34835a8693SMatt Spinler /**
357b291ec6SAatir  * @brief Helper function to get values from lookup tables.
367b291ec6SAatir  * @return std::string - the value
377b291ec6SAatir  * @param[in] uint8_t - field to get value for
387b291ec6SAatir  * @param[in] PELValues - lookup table
39593a4c66SVijay Lobo  * @param[in] uint8_t - position in the pel_values table to read
407b291ec6SAatir  */
41593a4c66SVijay Lobo std::string getValue(const uint8_t field, const pel_values::PELValues& values,
42593a4c66SVijay Lobo                      const uint8_t position = pel_values::descriptionPos);
437b291ec6SAatir 
447b291ec6SAatir /**
45600d15afSHarisuddin Mohamed Isa  * @brief Helper function to get value vector from lookup tables.
46600d15afSHarisuddin Mohamed Isa  *
47600d15afSHarisuddin Mohamed Isa  * @param[in] value - the value to lookup
48600d15afSHarisuddin Mohamed Isa  * @param[in] table - lookup table
49600d15afSHarisuddin Mohamed Isa  *
50600d15afSHarisuddin Mohamed Isa  * @return std::vector<std::string> - the value vector
51600d15afSHarisuddin Mohamed Isa  */
52600d15afSHarisuddin Mohamed Isa std::vector<std::string> getValuesBitwise(uint16_t value,
53600d15afSHarisuddin Mohamed Isa                                           const pel_values::PELValues& table);
54600d15afSHarisuddin Mohamed Isa /**
55835a8693SMatt Spinler  * @brief Find the desired entry in a PELValues table based on the
56835a8693SMatt Spinler  *        field value.
57835a8693SMatt Spinler  *
58835a8693SMatt Spinler  * @param[in] value - the PEL value to find
59835a8693SMatt Spinler  * @param[in] fields - the PEL values table to use
60835a8693SMatt Spinler  *
61835a8693SMatt Spinler  * @return PELValues::const_iterator - an iterator to the table entry
62835a8693SMatt Spinler  */
63835a8693SMatt Spinler PELValues::const_iterator findByValue(uint32_t value, const PELValues& fields);
64835a8693SMatt Spinler 
65835a8693SMatt Spinler /**
66835a8693SMatt Spinler  * @brief Find the desired entry in a PELValues table based on the
67835a8693SMatt Spinler  *        field message registry name.
68835a8693SMatt Spinler  *
69835a8693SMatt Spinler  * @param[in] name - the PEL message registry enum name
70835a8693SMatt Spinler  * @param[in] fields - the PEL values table to use
71835a8693SMatt Spinler  *
72835a8693SMatt Spinler  * @return PELValues::const_iterator - an iterator to the table entry
73835a8693SMatt Spinler  */
74835a8693SMatt Spinler PELValues::const_iterator findByName(const std::string& name,
75835a8693SMatt Spinler                                      const PELValues& fields);
76835a8693SMatt Spinler 
77835a8693SMatt Spinler /**
78835a8693SMatt Spinler  * @brief The values for the 'subsystem' field in the User Header
79835a8693SMatt Spinler  */
80835a8693SMatt Spinler extern const PELValues subsystemValues;
81835a8693SMatt Spinler 
82835a8693SMatt Spinler /**
83835a8693SMatt Spinler  * @brief The values for the 'severity' field in the User Header
84835a8693SMatt Spinler  */
85835a8693SMatt Spinler extern const PELValues severityValues;
86835a8693SMatt Spinler 
87835a8693SMatt Spinler /**
88835a8693SMatt Spinler  * @brief The values for the 'Event Type' field in the User Header
89835a8693SMatt Spinler  */
90835a8693SMatt Spinler extern const PELValues eventTypeValues;
91835a8693SMatt Spinler 
92835a8693SMatt Spinler /**
93835a8693SMatt Spinler  * @brief The values for the 'Event Scope' field in the User Header
94835a8693SMatt Spinler  */
95835a8693SMatt Spinler extern const PELValues eventScopeValues;
96835a8693SMatt Spinler 
97835a8693SMatt Spinler /**
98835a8693SMatt Spinler  * @brief The values for the 'Action Flags' field in the User Header
99835a8693SMatt Spinler  */
100835a8693SMatt Spinler extern const PELValues actionFlagsValues;
101835a8693SMatt Spinler 
102835a8693SMatt Spinler /**
103835a8693SMatt Spinler  * @brief The values for callout priorities in the SRC section
104835a8693SMatt Spinler  */
105835a8693SMatt Spinler extern const PELValues calloutPriorityValues;
106835a8693SMatt Spinler 
107186ce8c9SAatir /**
108186ce8c9SAatir  * @brief Map for section IDs
109186ce8c9SAatir  */
110186ce8c9SAatir extern const std::map<std::string, std::string> sectionTitles;
111186ce8c9SAatir 
112c92b4eb4SAatir /**
113c92b4eb4SAatir  * @brief Map for creator IDs
114c92b4eb4SAatir  */
115c92b4eb4SAatir extern const std::map<std::string, std::string> creatorIDs;
116c92b4eb4SAatir 
117455587e5SMatt Spinler /**
118455587e5SMatt Spinler  * @brief Map for transmission states
119455587e5SMatt Spinler  */
120455587e5SMatt Spinler extern const std::map<TransmissionState, std::string> transmissionStates;
121455587e5SMatt Spinler 
1220f717e10SHarisuddin Mohamed Isa /**
1230f717e10SHarisuddin Mohamed Isa  * @brief Map for Procedure Descriptions
1240f717e10SHarisuddin Mohamed Isa  */
1250f717e10SHarisuddin Mohamed Isa extern const std::map<std::string, std::string> procedureDesc;
1260f717e10SHarisuddin Mohamed Isa 
1270f717e10SHarisuddin Mohamed Isa /**
1280f717e10SHarisuddin Mohamed Isa  * @brief Map for Callout Failing Component Types
1290f717e10SHarisuddin Mohamed Isa  */
1300f717e10SHarisuddin Mohamed Isa extern const std::map<uint8_t, std::string> failingComponentType;
1310f717e10SHarisuddin Mohamed Isa 
1320f717e10SHarisuddin Mohamed Isa /**
1330f717e10SHarisuddin Mohamed Isa  * @brief Map for Boolean value
1340f717e10SHarisuddin Mohamed Isa  */
1350f717e10SHarisuddin Mohamed Isa extern const std::map<bool, std::string> boolString;
1360f717e10SHarisuddin Mohamed Isa 
137578e070fSMatt Spinler /**
138a27e2e50SMatt Spinler  * @brief Map for maintenance procedures
139578e070fSMatt Spinler  */
140a27e2e50SMatt Spinler extern const std::map<std::string, std::string> maintenanceProcedures;
141578e070fSMatt Spinler 
1422b6dfa00SMatt Spinler /**
1432b6dfa00SMatt Spinler  * @brief Map for symbolic FRUs.
1442b6dfa00SMatt Spinler  */
1452b6dfa00SMatt Spinler extern const std::map<std::string, std::string> symbolicFRUs;
1462b6dfa00SMatt Spinler 
147835a8693SMatt Spinler } // namespace pel_values
148835a8693SMatt Spinler } // namespace pels
149835a8693SMatt Spinler } // namespace openpower
150