1 #pragma once 2 3 #include "xyz/openbmc_project/Logging/Entry/server.hpp" 4 5 #include <phal_exception.H> 6 7 #include <nlohmann/json.hpp> 8 9 #include <string> 10 #include <vector> 11 namespace openpower 12 { 13 namespace pel 14 { 15 using FFDCData = std::vector<std::pair<std::string, std::string>>; 16 17 using json = nlohmann::json; 18 19 using namespace openpower::phal; 20 using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level; 21 /** 22 * @brief Create PEL with additional parameters and callout 23 * 24 * @param[in] event - the event type 25 * @param[in] calloutData - callout data to append to PEL 26 * @param[in] ffdcData - failure data to append to PEL 27 */ 28 void createErrorPEL(const std::string& event, const json& calloutData = {}, 29 const FFDCData& ffdcData = {}); 30 31 /** 32 * @brief Create SBE boot error PEL and return id 33 * 34 * @param[in] event - the event type 35 * @param[in] sbeError - SBE error object 36 * @param[in] ffdcData - failure data to append to PEL 37 * @param[in] severity - severity of the log 38 * @return Platform log id 39 */ 40 uint32_t createSbeErrorPEL(const std::string& event, const sbeError_t& sbeError, 41 const FFDCData& ffdcData, 42 const Severity severity = Severity::Error); 43 44 /** 45 * @brief Create a PEL for the specified event type and additional data 46 * 47 * @param[in] event - the event type 48 * @param[in] ffdcData - failure data to append to PEL 49 */ 50 void createPEL(const std::string& event, const FFDCData& ffdcData = {}); 51 52 /** 53 * @class FFDCFile 54 * @brief This class is used to create ffdc data file and to get fd 55 */ 56 class FFDCFile 57 { 58 public: 59 FFDCFile() = delete; 60 FFDCFile(const FFDCFile&) = delete; 61 FFDCFile& operator=(const FFDCFile&) = delete; 62 FFDCFile(FFDCFile&&) = delete; 63 FFDCFile& operator=(FFDCFile&&) = delete; 64 65 /** 66 * Used to pass json object to create unique ffdc file by using 67 * passed json data. 68 */ 69 explicit FFDCFile(const json& pHALCalloutData); 70 71 /** 72 * Used to remove created ffdc file. 73 */ 74 ~FFDCFile(); 75 76 /** 77 * Used to get created ffdc file file descriptor id. 78 * 79 * @return file descriptor id 80 */ 81 int getFileFD() const; 82 83 private: 84 /** 85 * Used to store callout ffdc data from passed json object. 86 */ 87 std::string calloutData; 88 89 /** 90 * Used to store unique ffdc file name. 91 */ 92 std::string calloutFile; 93 94 /** 95 * Used to store created ffdc file descriptor id. 96 */ 97 int fileFD; 98 99 /** 100 * Used to create ffdc file to pass PEL api for creating 101 * pel records. 102 * 103 * @return NULL 104 */ 105 void prepareFFDCFile(); 106 107 /** 108 * Create unique ffdc file. 109 * 110 * @return NULL 111 */ 112 void createCalloutFile(); 113 114 /** 115 * Used write json object value into created file. 116 * 117 * @return NULL 118 */ 119 void writeCalloutData(); 120 121 /** 122 * Used set ffdc file seek position begining to consume by PEL 123 * 124 * @return NULL 125 */ 126 void setCalloutFileSeekPos(); 127 128 /** 129 * Used to remove created ffdc file. 130 * 131 * @return NULL 132 */ 133 void removeCalloutFile(); 134 135 }; // FFDCFile end 136 137 } // namespace pel 138 } // namespace openpower 139