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