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 | 8fe9ff9 | 2021-11-14 09:15:59 -0600 | [diff] [blame] | 20 | * @brief Create PEL with additional parameters and callout |
Brad Bishop | f6783cd | 2020-10-27 19:25:09 -0400 | [diff] [blame] | 21 | * |
Jayanth Othayoth | 8fe9ff9 | 2021-11-14 09:15:59 -0600 | [diff] [blame] | 22 | * @param[in] event - the event type |
Brad Bishop | f6783cd | 2020-10-27 19:25:09 -0400 | [diff] [blame] | 23 | * @param[in] calloutData - callout data to append to PEL |
Jayanth Othayoth | 8fe9ff9 | 2021-11-14 09:15:59 -0600 | [diff] [blame] | 24 | * @param[in] ffdcData - failure data to append to PEL |
Brad Bishop | f6783cd | 2020-10-27 19:25:09 -0400 | [diff] [blame] | 25 | */ |
Jayanth Othayoth | 8fe9ff9 | 2021-11-14 09:15:59 -0600 | [diff] [blame] | 26 | void createErrorPEL(const std::string& event, const json& calloutData = {}, |
| 27 | const FFDCData& ffdcData = {}); |
Brad Bishop | f6783cd | 2020-10-27 19:25:09 -0400 | [diff] [blame] | 28 | |
| 29 | /** |
Jayanth Othayoth | fe37aea | 2021-10-07 04:41:26 -0500 | [diff] [blame] | 30 | * @brief Create SBE boot error PEL and return id |
Jayanth Othayoth | 2eb31ad | 2021-09-20 07:13:28 -0500 | [diff] [blame] | 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 |
Jayanth Othayoth | fe37aea | 2021-10-07 04:41:26 -0500 | [diff] [blame] | 35 | * @return Platform log id |
Jayanth Othayoth | 2eb31ad | 2021-09-20 07:13:28 -0500 | [diff] [blame] | 36 | */ |
Jayanth Othayoth | fe37aea | 2021-10-07 04:41:26 -0500 | [diff] [blame] | 37 | uint32_t createSbeErrorPEL(const std::string& event, const sbeError_t& sbeError, |
| 38 | const FFDCData& ffdcData); |
Jayanth Othayoth | 2eb31ad | 2021-09-20 07:13:28 -0500 | [diff] [blame] | 39 | |
| 40 | /** |
Jayanth Othayoth | a8d2f71 | 2021-09-20 07:02:51 -0500 | [diff] [blame] | 41 | * @brief Create a PEL for the specified event type and additional data |
Andrew Geissler | 61febf0 | 2021-06-22 17:19:32 -0500 | [diff] [blame] | 42 | * |
Jayanth Othayoth | 2eb31ad | 2021-09-20 07:13:28 -0500 | [diff] [blame] | 43 | * @param[in] event - the event type |
Jayanth Othayoth | a8d2f71 | 2021-09-20 07:02:51 -0500 | [diff] [blame] | 44 | * @param[in] ffdcData - failure data to append to PEL |
Andrew Geissler | 61febf0 | 2021-06-22 17:19:32 -0500 | [diff] [blame] | 45 | */ |
Jayanth Othayoth | a8d2f71 | 2021-09-20 07:02:51 -0500 | [diff] [blame] | 46 | void createPEL(const std::string& event, const FFDCData& ffdcData = {}); |
Andrew Geissler | 61febf0 | 2021-06-22 17:19:32 -0500 | [diff] [blame] | 47 | |
| 48 | /** |
Brad Bishop | f6783cd | 2020-10-27 19:25:09 -0400 | [diff] [blame] | 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 |