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