1711d51d8SMatt Spinler /**
2711d51d8SMatt Spinler  * Copyright © 2019 IBM Corporation
3711d51d8SMatt Spinler  *
4711d51d8SMatt Spinler  * Licensed under the Apache License, Version 2.0 (the "License");
5711d51d8SMatt Spinler  * you may not use this file except in compliance with the License.
6711d51d8SMatt Spinler  * You may obtain a copy of the License at
7711d51d8SMatt Spinler  *
8711d51d8SMatt Spinler  *     http://www.apache.org/licenses/LICENSE-2.0
9711d51d8SMatt Spinler  *
10711d51d8SMatt Spinler  * Unless required by applicable law or agreed to in writing, software
11711d51d8SMatt Spinler  * distributed under the License is distributed on an "AS IS" BASIS,
12711d51d8SMatt Spinler  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13711d51d8SMatt Spinler  * See the License for the specific language governing permissions and
14711d51d8SMatt Spinler  * limitations under the License.
15711d51d8SMatt Spinler  */
16835a8693SMatt Spinler #include "pel_values.hpp"
17835a8693SMatt Spinler 
18835a8693SMatt Spinler #include <algorithm>
19578e070fSMatt Spinler #include <cassert>
20835a8693SMatt Spinler 
21835a8693SMatt Spinler namespace openpower
22835a8693SMatt Spinler {
23835a8693SMatt Spinler namespace pels
24835a8693SMatt Spinler {
25835a8693SMatt Spinler namespace pel_values
26835a8693SMatt Spinler {
27835a8693SMatt Spinler 
28835a8693SMatt Spinler /**
29835a8693SMatt Spinler  * The possible values for the subsystem field  in the User Header.
30835a8693SMatt Spinler  */
3157a24e38SHarisuddin Mohamed Isa const PELValues subsystemValues = {
32242be740SVijay Lobo     {0x10, "processor", "Processor"},
3357a24e38SHarisuddin Mohamed Isa     {0x11, "processor_fru", "Processor FRU"},
3457a24e38SHarisuddin Mohamed Isa     {0x12, "processor_chip", "Processor Chip Cache"},
3557a24e38SHarisuddin Mohamed Isa     {0x13, "processor_unit", "Processor Unit (CPU)"},
3657a24e38SHarisuddin Mohamed Isa     {0x14, "processor_bus", "Processor Bus Controller"},
37835a8693SMatt Spinler 
38242be740SVijay Lobo     {0x20, "memory", "Memory"},
3957a24e38SHarisuddin Mohamed Isa     {0x21, "memory_ctlr", "Memory Controller"},
4057a24e38SHarisuddin Mohamed Isa     {0x22, "memory_bus", "Memory Bus Interface"},
4157a24e38SHarisuddin Mohamed Isa     {0x23, "memory_dimm", "Memory DIMM"},
4257a24e38SHarisuddin Mohamed Isa     {0x24, "memory_fru", "Memory Card/FRU"},
4357a24e38SHarisuddin Mohamed Isa     {0x25, "external_cache", "External Cache"},
44835a8693SMatt Spinler 
45242be740SVijay Lobo     {0x30, "io", "I/O"},
4657a24e38SHarisuddin Mohamed Isa     {0x31, "io_hub", "I/O Hub"},
4757a24e38SHarisuddin Mohamed Isa     {0x32, "io_bridge", "I/O Bridge"},
4857a24e38SHarisuddin Mohamed Isa     {0x33, "io_bus", "I/O bus interface"},
4957a24e38SHarisuddin Mohamed Isa     {0x34, "io_processor", "I/O Processor"},
5057a24e38SHarisuddin Mohamed Isa     {0x35, "io_hub_other", "SMA Hub"},
5157a24e38SHarisuddin Mohamed Isa     {0x38, "phb", "PCI Bridge Chip"},
52835a8693SMatt Spinler 
53242be740SVijay Lobo     {0x40, "io_adapter", "I/O Adapter"},
5457a24e38SHarisuddin Mohamed Isa     {0x41, "io_adapter_comm", "I/O Adapter Communication"},
55242be740SVijay Lobo     {0x46, "io_device", "I/O Device"},
5657a24e38SHarisuddin Mohamed Isa     {0x47, "io_device_dasd", "I/O Device Disk"},
5757a24e38SHarisuddin Mohamed Isa     {0x4C, "io_external_general", "I/O External Peripheral"},
5857a24e38SHarisuddin Mohamed Isa     {0x4D, "io_external_workstation",
5957a24e38SHarisuddin Mohamed Isa      "I/O External Peripheral Local Work Station"},
60242be740SVijay Lobo     {0x4E, "io_storage_mezz", "I/O Storage Mezza Expansion"},
61835a8693SMatt Spinler 
62242be740SVijay Lobo     {0x50, "cec_hardware", "CEC Hardware"},
63242be740SVijay Lobo     {0x51, "cec_sp_a", "CEC Hardware - Service Processor A"},
64242be740SVijay Lobo     {0x52, "cec_sp_b", "CEC Hardware - Service Processor B"},
65242be740SVijay Lobo     {0x53, "cec_node_controller", "CEC Hardware - Node Controller"},
66242be740SVijay Lobo     {0x55, "cec_vpd", "CEC Hardware - VPD Interface"},
67242be740SVijay Lobo     {0x56, "cec_i2c", "CEC Hardware - I2C Devices"},
68242be740SVijay Lobo     {0x57, "cec_chip_iface", "CEC Hardware - CEC Chip Interface"},
69242be740SVijay Lobo     {0x58, "cec_clocks", "CEC Hardware - Clock"},
70242be740SVijay Lobo     {0x59, "cec_op_panel", "CEC Hardware - Operator Panel"},
71242be740SVijay Lobo     {0x5A, "cec_tod", "CEC Hardware - Time-Of-Day Hardware"},
72242be740SVijay Lobo     {0x5B, "cec_storage_device", "CEC Hardware - Memory Device"},
7357a24e38SHarisuddin Mohamed Isa     {0x5C, "cec_sp_hyp_iface",
74242be740SVijay Lobo      "CEC Hardware - Hypervisor<->Service Processor Interface"},
75242be740SVijay Lobo     {0x5D, "cec_service_network", "CEC Hardware - Service Network"},
7657a24e38SHarisuddin Mohamed Isa     {0x5E, "cec_sp_hostboot_iface",
77242be740SVijay Lobo      "CEC Hardware - Hostboot-Service Processor Interface"},
78835a8693SMatt Spinler 
79242be740SVijay Lobo     {0x60, "power", "Power/Cooling"},
8057a24e38SHarisuddin Mohamed Isa     {0x61, "power_supply", "Power Supply"},
8157a24e38SHarisuddin Mohamed Isa     {0x62, "power_control_hw", "Power Control Hardware"},
8257a24e38SHarisuddin Mohamed Isa     {0x63, "power_fans", "Fan (AMD)"},
83242be740SVijay Lobo     {0x64, "power_sequencer", "Digital Power Supply"},
84835a8693SMatt Spinler 
8557a24e38SHarisuddin Mohamed Isa     {0x70, "others", "Miscellaneous"},
86242be740SVijay Lobo     {0x71, "other_hmc", "HMC & Hardware"},
8757a24e38SHarisuddin Mohamed Isa     {0x72, "other_test_tool", "Test Tool"},
8857a24e38SHarisuddin Mohamed Isa     {0x73, "other_media", "Removable Media"},
8957a24e38SHarisuddin Mohamed Isa     {0x74, "other_multiple_subsystems", "Multiple Subsystems"},
9057a24e38SHarisuddin Mohamed Isa     {0x75, "other_na", "Not Applicable"},
9157a24e38SHarisuddin Mohamed Isa     {0x76, "other_info_src", "Miscellaneous"},
92835a8693SMatt Spinler 
9357a24e38SHarisuddin Mohamed Isa     {0x7A, "surv_hyp_lost_sp",
9457a24e38SHarisuddin Mohamed Isa      "Hypervisor lost communication with service processor"},
9557a24e38SHarisuddin Mohamed Isa     {0x7B, "surv_sp_lost_hyp",
9657a24e38SHarisuddin Mohamed Isa      "Service processor lost communication with Hypervisor"},
9757a24e38SHarisuddin Mohamed Isa     {0x7C, "surv_sp_lost_hmc", "Service processor lost communication with HMC"},
9857a24e38SHarisuddin Mohamed Isa     {0x7D, "surv_hmc_lost_lpar",
9957a24e38SHarisuddin Mohamed Isa      "HMC lost communication with logical partition"},
10057a24e38SHarisuddin Mohamed Isa     {0x7E, "surv_hmc_lost_bpa", "HMC lost communication with BPA"},
10157a24e38SHarisuddin Mohamed Isa     {0x7F, "surv_hmc_lost_hmc", "HMC lost communication with another HMC"},
102835a8693SMatt Spinler 
10357a24e38SHarisuddin Mohamed Isa     {0x80, "platform_firmware", "Platform Firmware"},
10457a24e38SHarisuddin Mohamed Isa     {0x81, "sp_firmware", "Service Processor Firmware"},
10557a24e38SHarisuddin Mohamed Isa     {0x82, "hyp_firmware", "System Hypervisor Firmware"},
10657a24e38SHarisuddin Mohamed Isa     {0x83, "partition_firmware", "Partition Firmware"},
10757a24e38SHarisuddin Mohamed Isa     {0x84, "slic_firmware", "SLIC Firmware"},
10857a24e38SHarisuddin Mohamed Isa     {0x85, "spcn_firmware", "System Power Control Network Firmware"},
10957a24e38SHarisuddin Mohamed Isa     {0x86, "bulk_power_firmware_side_a", "Bulk Power Firmware Side A"},
11057a24e38SHarisuddin Mohamed Isa     {0x87, "hmc_code_firmware", "HMC Code"},
11157a24e38SHarisuddin Mohamed Isa     {0x88, "bulk_power_firmware_side_b", "Bulk Power Firmware Side B"},
11257a24e38SHarisuddin Mohamed Isa     {0x89, "virtual_sp", "Virtual Service Processor Firmware"},
11357a24e38SHarisuddin Mohamed Isa     {0x8A, "hostboot", "HostBoot"},
11457a24e38SHarisuddin Mohamed Isa     {0x8B, "occ", "OCC"},
11557a24e38SHarisuddin Mohamed Isa     {0x8D, "bmc_firmware", "BMC Firmware"},
116835a8693SMatt Spinler 
11757a24e38SHarisuddin Mohamed Isa     {0x90, "software", "Software"},
11857a24e38SHarisuddin Mohamed Isa     {0x91, "os_software", "Operating System software"},
11957a24e38SHarisuddin Mohamed Isa     {0x92, "xpf_software", "XPF software"},
12057a24e38SHarisuddin Mohamed Isa     {0x93, "app_software", "Application software"},
121835a8693SMatt Spinler 
12257a24e38SHarisuddin Mohamed Isa     {0xA0, "ext_env", "External Environment"},
12357a24e38SHarisuddin Mohamed Isa     {0xA1, "input_power_source", "Input Power Source (ac)"},
12457a24e38SHarisuddin Mohamed Isa     {0xA2, "ambient_temp", "Room Ambient Temperature"},
12557a24e38SHarisuddin Mohamed Isa     {0xA3, "user_error", "User Error"},
12657a24e38SHarisuddin Mohamed Isa     {0xA4, "corrosion", "Corrosion"}};
127835a8693SMatt Spinler 
128835a8693SMatt Spinler /**
129835a8693SMatt Spinler  * The possible values for the severity field in the User Header.
130835a8693SMatt Spinler  */
131835a8693SMatt Spinler const PELValues severityValues = {
13257a24e38SHarisuddin Mohamed Isa     {0x00, "non_error", "Informational Event"},
133835a8693SMatt Spinler 
13457a24e38SHarisuddin Mohamed Isa     {0x10, "recovered", "Recovered Error"},
13557a24e38SHarisuddin Mohamed Isa     {0x20, "predictive", "Predictive Error"},
13657a24e38SHarisuddin Mohamed Isa     {0x21, "predictive_degraded_perf",
13757a24e38SHarisuddin Mohamed Isa      "Predictive Error, Degraded Performance"},
13857a24e38SHarisuddin Mohamed Isa     {0x22, "predictive_reboot", "Predictive Error, Correctable"},
13957a24e38SHarisuddin Mohamed Isa     {0x23, "predictive_reboot_degraded",
14057a24e38SHarisuddin Mohamed Isa      "Predictive Error, Correctable, Degraded"},
14157a24e38SHarisuddin Mohamed Isa     {0x24, "predictive_redundancy_loss", "Predictive Error, Redundancy Lost"},
142835a8693SMatt Spinler 
14357a24e38SHarisuddin Mohamed Isa     {0x40, "unrecoverable", "Unrecoverable Error"},
14457a24e38SHarisuddin Mohamed Isa     {0x41, "unrecoverable_degraded_perf",
14557a24e38SHarisuddin Mohamed Isa      "Unrecoverable Error, Degraded Performance"},
14657a24e38SHarisuddin Mohamed Isa     {0x44, "unrecoverable_redundancy_loss",
14757a24e38SHarisuddin Mohamed Isa      "Unrecoverable Error, Loss of Redundancy"},
14857a24e38SHarisuddin Mohamed Isa     {0x45, "unrecoverable_redundancy_loss_perf",
14957a24e38SHarisuddin Mohamed Isa      "Unrecoverable, Loss of Redundancy + Performance"},
15057a24e38SHarisuddin Mohamed Isa     {0x48, "unrecoverable_loss_of_function",
15157a24e38SHarisuddin Mohamed Isa      "Unrecoverable Error, Loss of Function"},
152835a8693SMatt Spinler 
15357a24e38SHarisuddin Mohamed Isa     {0x50, "critical", "Critical Error, Scope of Failure unknown"},
15457a24e38SHarisuddin Mohamed Isa     {0x51, "critical_system_term", "Critical Error, System Termination"},
15557a24e38SHarisuddin Mohamed Isa     {0x52, "critical_imminent_failure",
15657a24e38SHarisuddin Mohamed Isa      "Critical Error, System Failure likely or imminent"},
15757a24e38SHarisuddin Mohamed Isa     {0x53, "critical_partition_term",
15857a24e38SHarisuddin Mohamed Isa      "Critical Error, Partition(s) Termination"},
15957a24e38SHarisuddin Mohamed Isa     {0x54, "critical_partition_imminent_failure",
16057a24e38SHarisuddin Mohamed Isa      "Critical Error, Partition(s) Failure likely or imminent"},
161835a8693SMatt Spinler 
16257a24e38SHarisuddin Mohamed Isa     {0x60, "diagnostic_error", "Error detected during diagnostic test"},
16357a24e38SHarisuddin Mohamed Isa     {0x61, "diagnostic_error_incorrect_results",
16457a24e38SHarisuddin Mohamed Isa      "Diagostic error, resource w/incorrect results"},
165835a8693SMatt Spinler 
16657a24e38SHarisuddin Mohamed Isa     {0x71, "symptom_recovered", "Symptom Recovered"},
16757a24e38SHarisuddin Mohamed Isa     {0x72, "symptom_predictive", "Symptom Predictive"},
16857a24e38SHarisuddin Mohamed Isa     {0x74, "symptom_unrecoverable", "Symptom Unrecoverable"},
16957a24e38SHarisuddin Mohamed Isa     {0x75, "symptom_critical", "Symptom Critical"},
17057a24e38SHarisuddin Mohamed Isa     {0x76, "symptom_diag_err", "Symptom Diag Err"}};
171835a8693SMatt Spinler 
172835a8693SMatt Spinler /**
173835a8693SMatt Spinler  * The possible values for the Event Type field in the User Header.
174835a8693SMatt Spinler  */
17557a24e38SHarisuddin Mohamed Isa const PELValues eventTypeValues = {
17657a24e38SHarisuddin Mohamed Isa     {0x00, "na", "Not Applicable"},
17757a24e38SHarisuddin Mohamed Isa     {0x01, "misc_information_only", "Miscellaneous, Informational Only"},
17857a24e38SHarisuddin Mohamed Isa     {0x02, "tracing_event", "Tracing Event"},
1796b3490acSMatt Spinler     {0x08, "dump_notification", "Dump Notification"},
1806b3490acSMatt Spinler     {0x30, "env_normal", "Customer environmental problem back to normal"}};
181835a8693SMatt Spinler 
182835a8693SMatt Spinler /**
183835a8693SMatt Spinler  * The possible values for the Event Scope field in the User Header.
184835a8693SMatt Spinler  */
185835a8693SMatt Spinler const PELValues eventScopeValues = {
18657a24e38SHarisuddin Mohamed Isa     {0x01, "single_partition", "Single Partition"},
18757a24e38SHarisuddin Mohamed Isa     {0x02, "multiple_partitions", "Multiple Partitions"},
18857a24e38SHarisuddin Mohamed Isa     {0x03, "entire_platform", "Entire Platform"},
18957a24e38SHarisuddin Mohamed Isa     {0x04, "possibly_multiple_platforms", "Multiple Platforms"}};
190835a8693SMatt Spinler 
191835a8693SMatt Spinler /**
192835a8693SMatt Spinler  * The possible values for the Action Flags field in the User Header.
193835a8693SMatt Spinler  */
194835a8693SMatt Spinler const PELValues actionFlagsValues = {
19557a24e38SHarisuddin Mohamed Isa     {0x8000, "service_action", "Service Action Required"},
19657a24e38SHarisuddin Mohamed Isa     {0x4000, "hidden", "Event not customer viewable"},
19757a24e38SHarisuddin Mohamed Isa     {0x2000, "report", "Report Externally"},
198600d15afSHarisuddin Mohamed Isa     {0x1000, "dont_report", "Do Not Report To Hypervisor"},
19957a24e38SHarisuddin Mohamed Isa     {0x0800, "call_home", "HMC Call Home"},
200600d15afSHarisuddin Mohamed Isa     {0x0400, "isolation_incomplete",
201600d15afSHarisuddin Mohamed Isa      "Isolation Incomplete, further analysis required"},
20257a24e38SHarisuddin Mohamed Isa     {0x0100, "termination", "Service Processor Call Home Required"}};
203835a8693SMatt Spinler 
204835a8693SMatt Spinler /**
205835a8693SMatt Spinler  * The possible values for the Callout Priority field in the SRC.
206835a8693SMatt Spinler  */
207835a8693SMatt Spinler const PELValues calloutPriorityValues = {
2080f717e10SHarisuddin Mohamed Isa     {0x48, "high", "Mandatory, replace all with this type as a unit"},
2090f717e10SHarisuddin Mohamed Isa     {0x4D, "medium", "Medium Priority"},
2100f717e10SHarisuddin Mohamed Isa     {0x41, "medium_group_a", "Medium Priority A, replace these as a group"},
2110f717e10SHarisuddin Mohamed Isa     {0x42, "medium_group_b", "Medium Priority B, replace these as a group"},
2120f717e10SHarisuddin Mohamed Isa     {0x43, "medium_group_c", "Medium Priority C, replace these as a group"},
2130f717e10SHarisuddin Mohamed Isa     {0x4C, "low", "Lowest priority replacement"}};
214835a8693SMatt Spinler 
215578e070fSMatt Spinler /**
216a27e2e50SMatt Spinler  * @brief Map of the registry names for the maintenance procedures
217a27e2e50SMatt Spinler  *        to their actual names.
218578e070fSMatt Spinler  */
219a27e2e50SMatt Spinler const std::map<std::string, std::string> maintenanceProcedures = {
220f060bf0dSJayanth Othayoth     {"bmc_code", "BMC0001"},
221f060bf0dSJayanth Othayoth     // Isolation not possible, please contact your next level of support
22252dbaba5SJayanth Othayoth     {"next_level_support", "BMC0002"},
22352dbaba5SJayanth Othayoth     // Problem is in SBE code, upgrade your firmware
22416f5495bSJayanth Othayoth     {"sbe_code", "BMC0003"},
22516f5495bSJayanth Othayoth     // Problem is somewhere in the FSI bus path
2261ba9ef15SBrandon Wyman     {"fsi_path", "BMC0004"},
2271ba9ef15SBrandon Wyman     // Problem is over-current PSU fault
228ef8e79c6SZane Shelley     {"power_overcurrent", "BMC0005"},
229ef8e79c6SZane Shelley     // An unrecoverable event occurred, look for previous errors for the cause
230ef8e79c6SZane Shelley     {"find_sue_root_cause", "BMC0006"},
231134e1e15SPriyanga Ramasamy     // Correct system backplane VPD mismatch
232134e1e15SPriyanga Ramasamy     {"system_vpd_correction", "BMC0007"},
233385446baSMarri Devender Rao     // service reminder about the failed parts present in the system
234385446baSMarri Devender Rao     {"detected_issue_need_service", "BMC0008"},
235ef8e79c6SZane Shelley };
236578e070fSMatt Spinler 
2372b6dfa00SMatt Spinler /**
2382b6dfa00SMatt Spinler  * @brief Map of the registry names for the symbolic FRUs to their
2392b6dfa00SMatt Spinler  *        actual names.
2402b6dfa00SMatt Spinler  */
2412b6dfa00SMatt Spinler const std::map<std::string, std::string> symbolicFRUs = {
2427f678905SJim Wright     {"service_docs", "SVCDOCS"},      {"pwrsply", "PWRSPLY"},
2437f678905SJim Wright     {"air_mover", "AIRMOVR"},         {"pgood_part", "PGDPART"},
2446b3490acSMatt Spinler     {"usb_pgood", "USBPGD"},          {"ambient_temp", "AMBTEMP"},
24554ff54e9SJay Meyer     {"ambient_temp_back", "AMBBACK"}, {"ambient_perf_loss", "AMBPERF"},
246dde99203SMatt Spinler     {"ac_module", "ACMODUL"},         {"fan_cable", "FANCBL"},
247ace33dbeSJim Wright     {"cable_continued", "CBLCONT"},   {"altitude", "ALTTUDE"},
2489b779e42SJim Wright     {"pcie_hot_plug", "PCIEHP"},      {"overtemp", "OVERTMP"},
2499b779e42SJim Wright     {"memory_dimm", "MEMDIMM"}};
2502b6dfa00SMatt Spinler 
findByValue(uint32_t value,const PELValues & fields)251835a8693SMatt Spinler PELValues::const_iterator findByValue(uint32_t value, const PELValues& fields)
252835a8693SMatt Spinler {
253835a8693SMatt Spinler     return std::find_if(fields.begin(), fields.end(),
254835a8693SMatt Spinler                         [value](const auto& entry) {
255835a8693SMatt Spinler         return value == std::get<fieldValuePos>(entry);
256835a8693SMatt Spinler     });
257835a8693SMatt Spinler }
258835a8693SMatt Spinler 
findByName(const std::string & name,const PELValues & fields)259835a8693SMatt Spinler PELValues::const_iterator findByName(const std::string& name,
260835a8693SMatt Spinler                                      const PELValues& fields)
261835a8693SMatt Spinler 
262835a8693SMatt Spinler {
263835a8693SMatt Spinler     return std::find_if(fields.begin(), fields.end(),
264835a8693SMatt Spinler                         [&name](const auto& entry) {
265835a8693SMatt Spinler         return name == std::get<registryNamePos>(entry);
266835a8693SMatt Spinler     });
267835a8693SMatt Spinler }
268835a8693SMatt Spinler 
269186ce8c9SAatir /**
270186ce8c9SAatir  * @brief Map for section IDs
271186ce8c9SAatir  */
272186ce8c9SAatir const std::map<std::string, std::string> sectionTitles = {
273186ce8c9SAatir     {"PH", "Private Header"},
274186ce8c9SAatir     {"UH", "User Header"},
275186ce8c9SAatir     {"PS", "Primary SRC"},
276186ce8c9SAatir     {"SS", "Secondary SRC"},
277186ce8c9SAatir     {"EH", "Extended User Header"},
278186ce8c9SAatir     {"MT", "Failing MTMS"},
279186ce8c9SAatir     {"DH", "Dump Location"},
280186ce8c9SAatir     {"SW", "Firmware Error"},
2810f717e10SHarisuddin Mohamed Isa     {"LP", "Impacted Partition"},
282186ce8c9SAatir     {"LR", "Logical Resource"},
283186ce8c9SAatir     {"HM", "HMC ID"},
284186ce8c9SAatir     {"EP", "EPOW"},
285186ce8c9SAatir     {"IE", "IO Event"},
286186ce8c9SAatir     {"MI", "MFG Info"},
287186ce8c9SAatir     {"CH", "Call Home"},
288186ce8c9SAatir     {"UD", "User Data"},
289186ce8c9SAatir     {"EI", "Env Info"},
2900f717e10SHarisuddin Mohamed Isa     {"ED", "Extended User Data"}};
2910f717e10SHarisuddin Mohamed Isa 
2920f717e10SHarisuddin Mohamed Isa /**
2930f717e10SHarisuddin Mohamed Isa  * @brief Map for Procedure Descriptions
2940f717e10SHarisuddin Mohamed Isa  */
2950f717e10SHarisuddin Mohamed Isa const std::map<std::string, std::string> procedureDesc = {{"TODO", "TODO"}};
2960f717e10SHarisuddin Mohamed Isa 
2970f717e10SHarisuddin Mohamed Isa /**
2980f717e10SHarisuddin Mohamed Isa  * @brief Map for Callout Failing Component Types
2990f717e10SHarisuddin Mohamed Isa  */
3000f717e10SHarisuddin Mohamed Isa const std::map<uint8_t, std::string> failingComponentType = {
3010f717e10SHarisuddin Mohamed Isa     {0x10, "Normal Hardware FRU"},
3020f717e10SHarisuddin Mohamed Isa     {0x20, "Code FRU"},
3030f717e10SHarisuddin Mohamed Isa     {0x30, "Configuration error, configuration procedure required"},
3040f717e10SHarisuddin Mohamed Isa     {0x40, "Maintenance Procedure Required"},
3050f717e10SHarisuddin Mohamed Isa     {0x90, "External FRU"},
3060f717e10SHarisuddin Mohamed Isa     {0xA0, "External Code FRU"},
3070f717e10SHarisuddin Mohamed Isa     {0xB0, "Tool FRU"},
3080f717e10SHarisuddin Mohamed Isa     {0xC0, "Symbolic FRU"},
3090f717e10SHarisuddin Mohamed Isa     {0xE0, "Symbolic FRU with trusted location code"}};
3100f717e10SHarisuddin Mohamed Isa 
3110f717e10SHarisuddin Mohamed Isa /**
3120f717e10SHarisuddin Mohamed Isa  * @brief Map for Boolean value
3130f717e10SHarisuddin Mohamed Isa  */
3140f717e10SHarisuddin Mohamed Isa const std::map<bool, std::string> boolString = {{true, "True"},
3150f717e10SHarisuddin Mohamed Isa                                                 {false, "False"}};
316186ce8c9SAatir 
317c92b4eb4SAatir /**
318c92b4eb4SAatir  * @brief Map for creator IDs
319c92b4eb4SAatir  */
320c92b4eb4SAatir const std::map<std::string, std::string> creatorIDs = {
321c92b4eb4SAatir 
322c92b4eb4SAatir     {"O", "BMC"},      {"C", "HMC"},      {"H", "PHYP"}, {"L", "Partition FW"},
323c92b4eb4SAatir     {"S", "SLIC"},     {"B", "Hostboot"}, {"T", "OCC"},  {"M", "I/O Drawer"},
324c92b4eb4SAatir     {"K", "Sapphire"}, {"P", "PowerNV"}};
325c92b4eb4SAatir 
326455587e5SMatt Spinler /**
327455587e5SMatt Spinler  * @brief Map for transmission states
328455587e5SMatt Spinler  */
329455587e5SMatt Spinler const std::map<TransmissionState, std::string> transmissionStates = {
330455587e5SMatt Spinler     {TransmissionState::newPEL, "Not Sent"},
331455587e5SMatt Spinler     {TransmissionState::badPEL, "Rejected"},
332455587e5SMatt Spinler     {TransmissionState::sent, "Sent"},
333455587e5SMatt Spinler     {TransmissionState::acked, "Acked"}};
334455587e5SMatt Spinler 
getValue(const uint8_t field,const pel_values::PELValues & values,const uint8_t position)335593a4c66SVijay Lobo std::string getValue(const uint8_t field, const pel_values::PELValues& values,
336593a4c66SVijay Lobo                      const uint8_t position)
3377b291ec6SAatir {
3387b291ec6SAatir     auto tmp = pel_values::findByValue(field, values);
3397b291ec6SAatir     if (tmp != values.end())
3407b291ec6SAatir     {
341593a4c66SVijay Lobo         if (position == pel_values::registryNamePos)
342593a4c66SVijay Lobo         {
343593a4c66SVijay Lobo             return std::get<pel_values::registryNamePos>(*tmp);
344593a4c66SVijay Lobo         }
345593a4c66SVijay Lobo         else
346593a4c66SVijay Lobo         {
34757a24e38SHarisuddin Mohamed Isa             return std::get<pel_values::descriptionPos>(*tmp);
3487b291ec6SAatir         }
349593a4c66SVijay Lobo     }
3507b291ec6SAatir     else
3517b291ec6SAatir     {
3527b291ec6SAatir         return "invalid";
3537b291ec6SAatir     }
3547b291ec6SAatir }
355600d15afSHarisuddin Mohamed Isa 
getValuesBitwise(uint16_t value,const pel_values::PELValues & table)356600d15afSHarisuddin Mohamed Isa std::vector<std::string> getValuesBitwise(uint16_t value,
357600d15afSHarisuddin Mohamed Isa                                           const pel_values::PELValues& table)
358600d15afSHarisuddin Mohamed Isa {
359600d15afSHarisuddin Mohamed Isa     std::vector<std::string> foundValues;
360*ac1ba3f2SPatrick Williams     std::for_each(table.begin(), table.end(),
361*ac1ba3f2SPatrick Williams                   [&value, &foundValues](const auto& entry) {
362600d15afSHarisuddin Mohamed Isa         if (value & std::get<fieldValuePos>(entry))
363600d15afSHarisuddin Mohamed Isa         {
364600d15afSHarisuddin Mohamed Isa             foundValues.push_back(std::get<descriptionPos>(entry));
365600d15afSHarisuddin Mohamed Isa         }
366600d15afSHarisuddin Mohamed Isa     });
367600d15afSHarisuddin Mohamed Isa     return foundValues;
368600d15afSHarisuddin Mohamed Isa }
369578e070fSMatt Spinler 
370186ce8c9SAatir } // namespace pel_values
371835a8693SMatt Spinler } // namespace pels
372835a8693SMatt Spinler } // namespace openpower
373