Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matt Spinler | 455587e | 2020-01-15 14:31:52 -0600 | [diff] [blame] | 3 | #include "pel_types.hpp" |
| 4 | |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 5 | #include <map> |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 6 | #include <string> |
| 7 | #include <tuple> |
| 8 | #include <vector> |
| 9 | |
| 10 | namespace openpower |
| 11 | { |
| 12 | namespace pels |
| 13 | { |
| 14 | namespace pel_values |
| 15 | { |
| 16 | |
| 17 | // The actual value as it shows up in the PEL |
| 18 | const int fieldValuePos = 0; |
| 19 | |
| 20 | // The name of the value as specified in the message registry |
| 21 | const int registryNamePos = 1; |
| 22 | |
| 23 | // The description of the field, used by PEL parsers |
| 24 | const int descriptionPos = 2; |
| 25 | |
| 26 | using PELFieldValue = std::tuple<uint32_t, const char*, const char*>; |
| 27 | using PELValues = std::vector<PELFieldValue>; |
| 28 | |
Matt Spinler | 578e070 | 2020-03-13 09:40:43 -0500 | [diff] [blame] | 29 | // The maintenance procedure enum |
| 30 | const int mpEnumPos = 0; |
| 31 | |
| 32 | // The maintenance procedure value from the registry |
| 33 | const int mpRegistryNamePos = 1; |
| 34 | |
| 35 | // The string name of the maintenance procedure |
| 36 | const int mpNamePos = 2; |
| 37 | |
| 38 | using MaintenanceProcedureValue = |
| 39 | std::tuple<MaintProcedure, const char*, const char*>; |
| 40 | using MaintenanceProcedureValues = std::vector<MaintenanceProcedureValue>; |
| 41 | |
Harisuddin Mohamed Isa | bebeb94 | 2020-03-12 17:12:24 +0800 | [diff] [blame] | 42 | const std::string sectionVer = "Section Version"; |
| 43 | const std::string subSection = "Sub-section type"; |
| 44 | const std::string createdBy = "Created by"; |
| 45 | |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 46 | /** |
Aatir | 7b291ec | 2019-11-19 10:37:37 -0600 | [diff] [blame] | 47 | * @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 | */ |
| 52 | std::string getValue(const uint8_t field, const pel_values::PELValues& values); |
| 53 | |
| 54 | /** |
Harisuddin Mohamed Isa | 600d15a | 2019-12-20 12:42:26 +0800 | [diff] [blame] | 55 | * @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 | */ |
| 62 | std::vector<std::string> getValuesBitwise(uint16_t value, |
| 63 | const pel_values::PELValues& table); |
| 64 | /** |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 65 | * @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 | */ |
| 73 | PELValues::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 | */ |
| 84 | PELValues::const_iterator findByName(const std::string& name, |
| 85 | const PELValues& fields); |
| 86 | |
| 87 | /** |
Matt Spinler | 578e070 | 2020-03-13 09:40:43 -0500 | [diff] [blame] | 88 | * @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 | */ |
| 97 | MaintenanceProcedureValues::const_iterator |
| 98 | getMaintProcedure(MaintProcedure procedure); |
| 99 | |
| 100 | /** |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 101 | * @brief The values for the 'subsystem' field in the User Header |
| 102 | */ |
| 103 | extern const PELValues subsystemValues; |
| 104 | |
| 105 | /** |
| 106 | * @brief The values for the 'severity' field in the User Header |
| 107 | */ |
| 108 | extern const PELValues severityValues; |
| 109 | |
| 110 | /** |
| 111 | * @brief The values for the 'Event Type' field in the User Header |
| 112 | */ |
| 113 | extern const PELValues eventTypeValues; |
| 114 | |
| 115 | /** |
| 116 | * @brief The values for the 'Event Scope' field in the User Header |
| 117 | */ |
| 118 | extern const PELValues eventScopeValues; |
| 119 | |
| 120 | /** |
| 121 | * @brief The values for the 'Action Flags' field in the User Header |
| 122 | */ |
| 123 | extern const PELValues actionFlagsValues; |
| 124 | |
| 125 | /** |
| 126 | * @brief The values for callout priorities in the SRC section |
| 127 | */ |
| 128 | extern const PELValues calloutPriorityValues; |
| 129 | |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 130 | /** |
| 131 | * @brief Map for section IDs |
| 132 | */ |
| 133 | extern const std::map<std::string, std::string> sectionTitles; |
| 134 | |
Aatir | c92b4eb | 2019-11-18 13:44:51 -0600 | [diff] [blame] | 135 | /** |
| 136 | * @brief Map for creator IDs |
| 137 | */ |
| 138 | extern const std::map<std::string, std::string> creatorIDs; |
| 139 | |
Matt Spinler | 455587e | 2020-01-15 14:31:52 -0600 | [diff] [blame] | 140 | /** |
| 141 | * @brief Map for transmission states |
| 142 | */ |
| 143 | extern const std::map<TransmissionState, std::string> transmissionStates; |
| 144 | |
Harisuddin Mohamed Isa | 0f717e1 | 2020-01-15 20:05:33 +0800 | [diff] [blame] | 145 | /** |
| 146 | * @brief Map for Procedure Descriptions |
| 147 | */ |
| 148 | extern const std::map<std::string, std::string> procedureDesc; |
| 149 | |
| 150 | /** |
| 151 | * @brief Map for Callout Failing Component Types |
| 152 | */ |
| 153 | extern const std::map<uint8_t, std::string> failingComponentType; |
| 154 | |
| 155 | /** |
| 156 | * @brief Map for Boolean value |
| 157 | */ |
| 158 | extern const std::map<bool, std::string> boolString; |
| 159 | |
Matt Spinler | 578e070 | 2020-03-13 09:40:43 -0500 | [diff] [blame] | 160 | /** |
| 161 | * @brief All maintenance procedures. |
| 162 | * |
| 163 | * The procedure enum, registry name, and actual string value. |
| 164 | */ |
| 165 | extern const MaintenanceProcedureValues maintenanceProcedures; |
| 166 | |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 167 | } // namespace pel_values |
| 168 | } // namespace pels |
| 169 | } // namespace openpower |