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