blob: 163c6da8b3bdb5c4b44eb974d2c0039b59b027db [file] [log] [blame]
Matt Spinler835a8692019-08-27 13:56:05 -05001#pragma once
2
Matt Spinler455587e2020-01-15 14:31:52 -06003#include "pel_types.hpp"
4
Aatir186ce8c2019-10-20 15:13:39 -05005#include <map>
Matt Spinler835a8692019-08-27 13:56:05 -05006#include <string>
7#include <tuple>
8#include <vector>
9
10namespace openpower
11{
12namespace pels
13{
14namespace pel_values
15{
16
17// The actual value as it shows up in the PEL
18const int fieldValuePos = 0;
19
20// The name of the value as specified in the message registry
21const int registryNamePos = 1;
22
23// The description of the field, used by PEL parsers
24const int descriptionPos = 2;
25
26using PELFieldValue = std::tuple<uint32_t, const char*, const char*>;
27using PELValues = std::vector<PELFieldValue>;
28
Matt Spinler578e0702020-03-13 09:40:43 -050029// The maintenance procedure enum
30const int mpEnumPos = 0;
31
32// The maintenance procedure value from the registry
33const int mpRegistryNamePos = 1;
34
35// The string name of the maintenance procedure
36const int mpNamePos = 2;
37
38using MaintenanceProcedureValue =
39 std::tuple<MaintProcedure, const char*, const char*>;
40using MaintenanceProcedureValues = std::vector<MaintenanceProcedureValue>;
41
Harisuddin Mohamed Isabebeb942020-03-12 17:12:24 +080042const std::string sectionVer = "Section Version";
43const std::string subSection = "Sub-section type";
44const std::string createdBy = "Created by";
45
Matt Spinler835a8692019-08-27 13:56:05 -050046/**
Aatir7b291ec2019-11-19 10:37:37 -060047 * @brief Helper function to get values from lookup tables.
48 * @return std::string - the value
49 * @param[in] uint8_t - field to get value for
50 * @param[in] PELValues - lookup table
51 */
52std::string getValue(const uint8_t field, const pel_values::PELValues& values);
53
54/**
Harisuddin Mohamed Isa600d15a2019-12-20 12:42:26 +080055 * @brief Helper function to get value vector from lookup tables.
56 *
57 * @param[in] value - the value to lookup
58 * @param[in] table - lookup table
59 *
60 * @return std::vector<std::string> - the value vector
61 */
62std::vector<std::string> getValuesBitwise(uint16_t value,
63 const pel_values::PELValues& table);
64/**
Matt Spinler835a8692019-08-27 13:56:05 -050065 * @brief Find the desired entry in a PELValues table based on the
66 * field value.
67 *
68 * @param[in] value - the PEL value to find
69 * @param[in] fields - the PEL values table to use
70 *
71 * @return PELValues::const_iterator - an iterator to the table entry
72 */
73PELValues::const_iterator findByValue(uint32_t value, const PELValues& fields);
74
75/**
76 * @brief Find the desired entry in a PELValues table based on the
77 * field message registry name.
78 *
79 * @param[in] name - the PEL message registry enum name
80 * @param[in] fields - the PEL values table to use
81 *
82 * @return PELValues::const_iterator - an iterator to the table entry
83 */
84PELValues::const_iterator findByName(const std::string& name,
85 const PELValues& fields);
86
87/**
Matt Spinler578e0702020-03-13 09:40:43 -050088 * @brief Finds the entry in the maintenance procedure list
89 * based on the enum passed in.
90 *
91 * The function asserts that a result is found.
92 *
93 * @param[in] procedure - The procedure enum
94 *
95 * @return const_iterator - Iterator for that list entry
96 */
97MaintenanceProcedureValues::const_iterator
98 getMaintProcedure(MaintProcedure procedure);
99
100/**
Matt Spinler835a8692019-08-27 13:56:05 -0500101 * @brief The values for the 'subsystem' field in the User Header
102 */
103extern const PELValues subsystemValues;
104
105/**
106 * @brief The values for the 'severity' field in the User Header
107 */
108extern const PELValues severityValues;
109
110/**
111 * @brief The values for the 'Event Type' field in the User Header
112 */
113extern const PELValues eventTypeValues;
114
115/**
116 * @brief The values for the 'Event Scope' field in the User Header
117 */
118extern const PELValues eventScopeValues;
119
120/**
121 * @brief The values for the 'Action Flags' field in the User Header
122 */
123extern const PELValues actionFlagsValues;
124
125/**
126 * @brief The values for callout priorities in the SRC section
127 */
128extern const PELValues calloutPriorityValues;
129
Aatir186ce8c2019-10-20 15:13:39 -0500130/**
131 * @brief Map for section IDs
132 */
133extern const std::map<std::string, std::string> sectionTitles;
134
Aatirc92b4eb2019-11-18 13:44:51 -0600135/**
136 * @brief Map for creator IDs
137 */
138extern const std::map<std::string, std::string> creatorIDs;
139
Matt Spinler455587e2020-01-15 14:31:52 -0600140/**
141 * @brief Map for transmission states
142 */
143extern const std::map<TransmissionState, std::string> transmissionStates;
144
Harisuddin Mohamed Isa0f717e12020-01-15 20:05:33 +0800145/**
146 * @brief Map for Procedure Descriptions
147 */
148extern const std::map<std::string, std::string> procedureDesc;
149
150/**
151 * @brief Map for Callout Failing Component Types
152 */
153extern const std::map<uint8_t, std::string> failingComponentType;
154
155/**
156 * @brief Map for Boolean value
157 */
158extern const std::map<bool, std::string> boolString;
159
Matt Spinler578e0702020-03-13 09:40:43 -0500160/**
161 * @brief All maintenance procedures.
162 *
163 * The procedure enum, registry name, and actual string value.
164 */
165extern const MaintenanceProcedureValues maintenanceProcedures;
166
Matt Spinler835a8692019-08-27 13:56:05 -0500167} // namespace pel_values
168} // namespace pels
169} // namespace openpower