Matt Spinler | 711d51d | 2019-11-06 09:36:51 -0600 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2019 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 16 | #include "pel_values.hpp" |
| 17 | |
| 18 | #include <algorithm> |
| 19 | |
| 20 | namespace openpower |
| 21 | { |
| 22 | namespace pels |
| 23 | { |
| 24 | namespace pel_values |
| 25 | { |
| 26 | |
| 27 | // Note: The description fields will be filled in as part of the |
| 28 | // PEL parser work. |
| 29 | |
| 30 | /** |
| 31 | * The possible values for the subsystem field in the User Header. |
| 32 | */ |
| 33 | const PELValues subsystemValues = {{0x10, "processor", "TODO"}, |
| 34 | {0x11, "processor_fru", "TODO"}, |
| 35 | {0x12, "processor_chip", "TODO"}, |
| 36 | {0x13, "processor_unit", "TODO"}, |
| 37 | {0x14, "processor_bus", "TODO"}, |
| 38 | |
| 39 | {0x20, "memory", "TODO"}, |
| 40 | {0x21, "memory_ctlr", "TODO"}, |
| 41 | {0x22, "memory_bus", "TODO"}, |
| 42 | {0x23, "memory_dimm", "TODO"}, |
| 43 | {0x24, "memory_fru", "TODO"}, |
| 44 | {0x25, "external_cache", "TODO"}, |
| 45 | |
| 46 | {0x30, "io", "TODO"}, |
| 47 | {0x31, "io_hub", "TODO"}, |
| 48 | {0x32, "io_bridge", "TODO"}, |
| 49 | {0x33, "io_bus", "TODO"}, |
| 50 | {0x34, "io_processor", "TODO"}, |
| 51 | {0x35, "io_hub_other", "TODO"}, |
| 52 | {0x38, "phb", "TODO"}, |
| 53 | |
| 54 | {0x40, "io_adapter", "TODO"}, |
| 55 | {0x41, "io_adapter_comm", "TODO"}, |
| 56 | {0x46, "io_device", "TODO"}, |
| 57 | {0x47, "io_device_dasd", "TODO"}, |
| 58 | {0x4C, "io_external_general", "TODO"}, |
| 59 | {0x4D, "io_external_workstation", "TODO"}, |
| 60 | {0x4E, "io_storage_mezz", "TODO"}, |
| 61 | |
| 62 | {0x50, "cec_hardware", "TODO"}, |
| 63 | {0x51, "cec_sp_a", "TODO"}, |
| 64 | {0x52, "cec_sp_b", "TODO"}, |
| 65 | {0x53, "cec_node_controller", "TODO"}, |
| 66 | {0x55, "cec_vpd", "TODO"}, |
| 67 | {0x56, "cec_i2c", "TODO"}, |
| 68 | {0x57, "cec_chip_iface", "TODO"}, |
| 69 | {0x58, "cec_clocks", "TODO"}, |
| 70 | {0x59, "cec_op_panel", "TODO"}, |
| 71 | {0x5A, "cec_tod", "TODO"}, |
| 72 | {0x5B, "cec_storage_device", "TODO"}, |
| 73 | {0x5C, "cec_sp_hyp_iface", "TODO"}, |
| 74 | {0x5D, "cec_service_network", "TODO"}, |
| 75 | {0x5E, "cec_sp_hostboot_iface", "TODO"}, |
| 76 | |
| 77 | {0x60, "power", "TODO"}, |
| 78 | {0x61, "power_supply", "TODO"}, |
| 79 | {0x62, "power_control_hw", "TODO"}, |
Matt Spinler | 66d3036 | 2019-10-11 16:24:49 -0500 | [diff] [blame] | 80 | {0x63, "power_fans", "TODO"}, |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 81 | {0x64, "power_sequencer", "TODO"}, |
| 82 | |
| 83 | {0x70, "others", "TODO"}, |
| 84 | {0x71, "other_hmc", "TODO"}, |
| 85 | {0x72, "other_test_tool", "TODO"}, |
| 86 | {0x73, "other_media", "TODO"}, |
| 87 | {0x74, "other_multiple_subsystems", "TODO"}, |
| 88 | {0x75, "other_na", "TODO"}, |
| 89 | {0x76, "other_info_src", "TODO"}, |
| 90 | |
| 91 | {0x7A, "surv_hyp_lost_sp", "TODO"}, |
| 92 | {0x7B, "surv_sp_lost_hyp", "TODO"}, |
| 93 | {0x7C, "surv_sp_lost_hmc", "TODO"}, |
| 94 | {0x7D, "surv_hmc_lost_lpar", "TODO"}, |
| 95 | {0x7E, "surv_hmc_lost_bpa", "TODO"}, |
| 96 | {0x7F, "surv_hmc_lost_hmc", "TODO"}, |
| 97 | |
| 98 | {0x80, "platform_firmware", "TODO"}, |
| 99 | {0x81, "sp_firmware", "TODO"}, |
| 100 | {0x82, "hyp_firmware", "TODO"}, |
| 101 | {0x83, "partition_firmware", "TODO"}, |
| 102 | {0x84, "slic_firmware", "TODO"}, |
| 103 | {0x85, "spcn_firmware", "TODO"}, |
| 104 | {0x86, "bulk_power_firmware_side_a", "TODO"}, |
| 105 | {0x87, "hmc_code_firmware", "TODO"}, |
| 106 | {0x88, "bulk_power_firmware_side_b", "TODO"}, |
| 107 | {0x89, "virtual_sp", "TODO"}, |
| 108 | {0x8A, "hostboot", "TODO"}, |
| 109 | {0x8B, "occ", "TODO"}, |
| 110 | {0x8D, "bmc_firmware", "TODO"}, |
| 111 | |
| 112 | {0x90, "software", "TODO"}, |
| 113 | {0x91, "os_software", "TODO"}, |
| 114 | {0x92, "xpf_software", "TODO"}, |
| 115 | {0x93, "app_software", "TODO"}, |
| 116 | |
| 117 | {0xA0, "ext_env", "TODO"}, |
| 118 | {0xA1, "input_power_source", "TODO"}, |
| 119 | {0xA2, "ambient_temp", "TODO"}, |
| 120 | {0xA3, "user_error", "TODO"}, |
| 121 | {0xA4, "corrosion", "TODO"}}; |
| 122 | |
| 123 | /** |
| 124 | * The possible values for the severity field in the User Header. |
| 125 | */ |
| 126 | const PELValues severityValues = { |
| 127 | {0x00, "non_error", "TODO"}, |
| 128 | |
| 129 | {0x10, "recovered", "TODO"}, |
| 130 | {0x20, "predictive", "TODO"}, |
| 131 | {0x21, "predictive_degraded_perf", "TODO"}, |
| 132 | {0x22, "predictive_reboot", "TODO"}, |
| 133 | {0x23, "predictive_reboot_degraded", "TODO"}, |
| 134 | {0x24, "predictive_redundancy_loss", "TODO"}, |
| 135 | |
| 136 | {0x40, "unrecoverable", "TODO"}, |
| 137 | {0x41, "unrecoverable_degraded_perf", "TODO"}, |
| 138 | {0x44, "unrecoverable_redundancy_loss", "TODO"}, |
| 139 | {0x45, "unrecoverable_redundancy_loss_perf", "TODO"}, |
| 140 | {0x48, "unrecoverable_loss_of_function", "TODO"}, |
| 141 | |
| 142 | {0x50, "critical", "TODO"}, |
| 143 | {0x51, "critical_system_term", "TODO"}, |
| 144 | {0x52, "critical_imminent_failure", "TODO"}, |
| 145 | {0x53, "critical_partition_term", "TODO"}, |
| 146 | {0x54, "critical_partition_imminent_failure", "TODO"}, |
| 147 | |
| 148 | {0x60, "diagnostic_error", "TODO"}, |
| 149 | {0x61, "diagnostic_error_incorrect_results", "TODO"}, |
| 150 | |
| 151 | {0x71, "symptom_recovered", "TODO"}, |
| 152 | {0x72, "symptom_predictive", "TODO"}, |
| 153 | {0x74, "symptom_unrecoverable", "TODO"}, |
| 154 | {0x75, "symptom_critical", "TODO"}, |
| 155 | {0x76, "symptom_diag_err", "TODO"}}; |
| 156 | |
| 157 | /** |
| 158 | * The possible values for the Event Type field in the User Header. |
| 159 | */ |
| 160 | const PELValues eventTypeValues = {{0x00, "na", "TODO"}, |
| 161 | {0x01, "misc_information_only", "TODO"}, |
| 162 | {0x02, "tracing_event", "TODO"}, |
| 163 | {0x08, "dump_notification", "TODO"}}; |
| 164 | |
| 165 | /** |
| 166 | * The possible values for the Event Scope field in the User Header. |
| 167 | */ |
| 168 | const PELValues eventScopeValues = { |
| 169 | {0x01, "single_partition", "TODO"}, |
| 170 | {0x02, "multiple_partitions", "TODO"}, |
| 171 | {0x03, "entire_platform", "TODO"}, |
| 172 | {0x04, "possibly_multiple_platforms", "TODO"}}; |
| 173 | |
| 174 | /** |
| 175 | * The possible values for the Action Flags field in the User Header. |
| 176 | */ |
| 177 | const PELValues actionFlagsValues = { |
| 178 | {0x8000, "service_action", "TODO"}, {0x4000, "hidden", "TODO"}, |
| 179 | {0x2000, "report", "TODO"}, {0x1000, "dont_report", "TODO"}, |
| 180 | {0x0800, "call_home", "TODO"}, {0x0100, "termination", "TODO"}}; |
| 181 | |
| 182 | /** |
| 183 | * The possible values for the Callout Priority field in the SRC. |
| 184 | */ |
| 185 | const PELValues calloutPriorityValues = { |
| 186 | {'H', "high", "TODO"}, {'M', "medium", "TODO"}, |
| 187 | {'A', "medium_group_a", "TODO"}, {'B', "medium_group_b", "TODO"}, |
| 188 | {'C', "medium_group_c", "TODO"}, {'L', "low", "TODO"}}; |
| 189 | |
| 190 | PELValues::const_iterator findByValue(uint32_t value, const PELValues& fields) |
| 191 | { |
| 192 | return std::find_if(fields.begin(), fields.end(), |
| 193 | [value](const auto& entry) { |
| 194 | return value == std::get<fieldValuePos>(entry); |
| 195 | }); |
| 196 | } |
| 197 | |
| 198 | PELValues::const_iterator findByName(const std::string& name, |
| 199 | const PELValues& fields) |
| 200 | |
| 201 | { |
| 202 | return std::find_if(fields.begin(), fields.end(), |
| 203 | [&name](const auto& entry) { |
| 204 | return name == std::get<registryNamePos>(entry); |
| 205 | }); |
| 206 | } |
| 207 | |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 208 | /** |
| 209 | * @brief Map for section IDs |
| 210 | */ |
| 211 | const std::map<std::string, std::string> sectionTitles = { |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 212 | |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 213 | {"PH", "Private Header"}, |
| 214 | {"UH", "User Header"}, |
| 215 | {"PS", "Primary SRC"}, |
| 216 | {"SS", "Secondary SRC"}, |
| 217 | {"EH", "Extended User Header"}, |
| 218 | {"MT", "Failing MTMS"}, |
| 219 | {"DH", "Dump Location"}, |
| 220 | {"SW", "Firmware Error"}, |
| 221 | {"LP", "Impacted Part"}, |
| 222 | {"LR", "Logical Resource"}, |
| 223 | {"HM", "HMC ID"}, |
| 224 | {"EP", "EPOW"}, |
| 225 | {"IE", "IO Event"}, |
| 226 | {"MI", "MFG Info"}, |
| 227 | {"CH", "Call Home"}, |
| 228 | {"UD", "User Data"}, |
| 229 | {"EI", "Env Info"}, |
| 230 | {"ED", "Extended User Data"}, |
| 231 | }; |
| 232 | |
Aatir | c92b4eb | 2019-11-18 13:44:51 -0600 | [diff] [blame] | 233 | /** |
| 234 | * @brief Map for creator IDs |
| 235 | */ |
| 236 | const std::map<std::string, std::string> creatorIDs = { |
| 237 | |
| 238 | {"O", "BMC"}, {"C", "HMC"}, {"H", "PHYP"}, {"L", "Partition FW"}, |
| 239 | {"S", "SLIC"}, {"B", "Hostboot"}, {"T", "OCC"}, {"M", "I/O Drawer"}, |
| 240 | {"K", "Sapphire"}, {"P", "PowerNV"}}; |
| 241 | |
Aatir | 7b291ec | 2019-11-19 10:37:37 -0600 | [diff] [blame] | 242 | std::string getValue(const uint8_t field, const pel_values::PELValues& values) |
| 243 | { |
| 244 | |
| 245 | auto tmp = pel_values::findByValue(field, values); |
| 246 | if (tmp != values.end()) |
| 247 | { |
| 248 | return std::get<pel_values::registryNamePos>(*tmp); |
| 249 | } |
| 250 | else |
| 251 | { |
| 252 | return "invalid"; |
| 253 | } |
| 254 | } |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 255 | } // namespace pel_values |
Matt Spinler | 835a869 | 2019-08-27 13:56:05 -0500 | [diff] [blame] | 256 | } // namespace pels |
| 257 | } // namespace openpower |