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