16552de05SJayanth Othayoth #pragma once 26552de05SJayanth Othayoth 32b30dea1SMarri Devender Rao #include "xyz/openbmc_project/Logging/Entry/server.hpp" 42b30dea1SMarri Devender Rao 52eb31ad2SJayanth Othayoth #include <phal_exception.H> 62eb31ad2SJayanth Othayoth 76552de05SJayanth Othayoth #include <nlohmann/json.hpp> 86552de05SJayanth Othayoth 96552de05SJayanth Othayoth #include <string> 106552de05SJayanth Othayoth #include <vector> 11e5ba5fd0SJayanth Othayoth 12e5ba5fd0SJayanth Othayoth extern "C" 13e5ba5fd0SJayanth Othayoth { 14e5ba5fd0SJayanth Othayoth #include <libpdbg.h> 15e5ba5fd0SJayanth Othayoth } 166552de05SJayanth Othayoth namespace openpower 176552de05SJayanth Othayoth { 186552de05SJayanth Othayoth namespace pel 196552de05SJayanth Othayoth { 206552de05SJayanth Othayoth using FFDCData = std::vector<std::pair<std::string, std::string>>; 216552de05SJayanth Othayoth 226552de05SJayanth Othayoth using json = nlohmann::json; 236552de05SJayanth Othayoth 242eb31ad2SJayanth Othayoth using namespace openpower::phal; 252b30dea1SMarri Devender Rao using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level; 266552de05SJayanth Othayoth /** 278fe9ff91SJayanth Othayoth * @brief Create PEL with additional parameters and callout 286552de05SJayanth Othayoth * 298fe9ff91SJayanth Othayoth * @param[in] event - the event type 306552de05SJayanth Othayoth * @param[in] calloutData - callout data to append to PEL 318fe9ff91SJayanth Othayoth * @param[in] ffdcData - failure data to append to PEL 32*4d5b5bfeSMarri Devender Rao * @param[in] severity - severity of the log default to Informational 336552de05SJayanth Othayoth */ 348fe9ff91SJayanth Othayoth void createErrorPEL(const std::string& event, const json& calloutData = {}, 35*4d5b5bfeSMarri Devender Rao const FFDCData& ffdcData = {}, 36*4d5b5bfeSMarri Devender Rao const Severity severity = Severity::Informational); 376552de05SJayanth Othayoth 386552de05SJayanth Othayoth /** 39fe37aea0SJayanth Othayoth * @brief Create SBE boot error PEL and return id 402eb31ad2SJayanth Othayoth * 412eb31ad2SJayanth Othayoth * @param[in] event - the event type 422eb31ad2SJayanth Othayoth * @param[in] sbeError - SBE error object 432eb31ad2SJayanth Othayoth * @param[in] ffdcData - failure data to append to PEL 44e5ba5fd0SJayanth Othayoth * @param[in] procTarget - pdbg processor target 452b30dea1SMarri Devender Rao * @param[in] severity - severity of the log 46fe37aea0SJayanth Othayoth * @return Platform log id 472eb31ad2SJayanth Othayoth */ 48fe37aea0SJayanth Othayoth uint32_t createSbeErrorPEL(const std::string& event, const sbeError_t& sbeError, 492b30dea1SMarri Devender Rao const FFDCData& ffdcData, 50e5ba5fd0SJayanth Othayoth struct pdbg_target* procTarget, 512b30dea1SMarri Devender Rao const Severity severity = Severity::Error); 522eb31ad2SJayanth Othayoth 532eb31ad2SJayanth Othayoth /** 54a8d2f710SJayanth Othayoth * @brief Create a PEL for the specified event type and additional data 556552de05SJayanth Othayoth * 562eb31ad2SJayanth Othayoth * @param[in] event - the event type 57a8d2f710SJayanth Othayoth * @param[in] ffdcData - failure data to append to PEL 586552de05SJayanth Othayoth */ 59a8d2f710SJayanth Othayoth void createPEL(const std::string& event, const FFDCData& ffdcData = {}); 606552de05SJayanth Othayoth 616552de05SJayanth Othayoth /** 626552de05SJayanth Othayoth * @class FFDCFile 636552de05SJayanth Othayoth * @brief This class is used to create ffdc data file and to get fd 646552de05SJayanth Othayoth */ 656552de05SJayanth Othayoth class FFDCFile 666552de05SJayanth Othayoth { 676552de05SJayanth Othayoth public: 686552de05SJayanth Othayoth FFDCFile() = delete; 696552de05SJayanth Othayoth FFDCFile(const FFDCFile&) = delete; 706552de05SJayanth Othayoth FFDCFile& operator=(const FFDCFile&) = delete; 716552de05SJayanth Othayoth FFDCFile(FFDCFile&&) = delete; 726552de05SJayanth Othayoth FFDCFile& operator=(FFDCFile&&) = delete; 736552de05SJayanth Othayoth 746552de05SJayanth Othayoth /** 756552de05SJayanth Othayoth * Used to pass json object to create unique ffdc file by using 766552de05SJayanth Othayoth * passed json data. 776552de05SJayanth Othayoth */ 786552de05SJayanth Othayoth explicit FFDCFile(const json& pHALCalloutData); 796552de05SJayanth Othayoth 806552de05SJayanth Othayoth /** 816552de05SJayanth Othayoth * Used to remove created ffdc file. 826552de05SJayanth Othayoth */ 836552de05SJayanth Othayoth ~FFDCFile(); 846552de05SJayanth Othayoth 856552de05SJayanth Othayoth /** 866552de05SJayanth Othayoth * Used to get created ffdc file file descriptor id. 876552de05SJayanth Othayoth * 886552de05SJayanth Othayoth * @return file descriptor id 896552de05SJayanth Othayoth */ 906552de05SJayanth Othayoth int getFileFD() const; 916552de05SJayanth Othayoth 926552de05SJayanth Othayoth private: 936552de05SJayanth Othayoth /** 946552de05SJayanth Othayoth * Used to store callout ffdc data from passed json object. 956552de05SJayanth Othayoth */ 966552de05SJayanth Othayoth std::string calloutData; 976552de05SJayanth Othayoth 986552de05SJayanth Othayoth /** 996552de05SJayanth Othayoth * Used to store unique ffdc file name. 1006552de05SJayanth Othayoth */ 1016552de05SJayanth Othayoth std::string calloutFile; 1026552de05SJayanth Othayoth 1036552de05SJayanth Othayoth /** 1046552de05SJayanth Othayoth * Used to store created ffdc file descriptor id. 1056552de05SJayanth Othayoth */ 1066552de05SJayanth Othayoth int fileFD; 1076552de05SJayanth Othayoth 1086552de05SJayanth Othayoth /** 1096552de05SJayanth Othayoth * Used to create ffdc file to pass PEL api for creating 1106552de05SJayanth Othayoth * pel records. 1116552de05SJayanth Othayoth * 1126552de05SJayanth Othayoth * @return NULL 1136552de05SJayanth Othayoth */ 1146552de05SJayanth Othayoth void prepareFFDCFile(); 1156552de05SJayanth Othayoth 1166552de05SJayanth Othayoth /** 1176552de05SJayanth Othayoth * Create unique ffdc file. 1186552de05SJayanth Othayoth * 1196552de05SJayanth Othayoth * @return NULL 1206552de05SJayanth Othayoth */ 1216552de05SJayanth Othayoth void createCalloutFile(); 1226552de05SJayanth Othayoth 1236552de05SJayanth Othayoth /** 1246552de05SJayanth Othayoth * Used write json object value into created file. 1256552de05SJayanth Othayoth * 1266552de05SJayanth Othayoth * @return NULL 1276552de05SJayanth Othayoth */ 1286552de05SJayanth Othayoth void writeCalloutData(); 1296552de05SJayanth Othayoth 1306552de05SJayanth Othayoth /** 1316552de05SJayanth Othayoth * Used set ffdc file seek position begining to consume by PEL 1326552de05SJayanth Othayoth * 1336552de05SJayanth Othayoth * @return NULL 1346552de05SJayanth Othayoth */ 1356552de05SJayanth Othayoth void setCalloutFileSeekPos(); 1366552de05SJayanth Othayoth 1376552de05SJayanth Othayoth /** 1386552de05SJayanth Othayoth * Used to remove created ffdc file. 1396552de05SJayanth Othayoth * 1406552de05SJayanth Othayoth * @return NULL 1416552de05SJayanth Othayoth */ 1426552de05SJayanth Othayoth void removeCalloutFile(); 1436552de05SJayanth Othayoth 1446552de05SJayanth Othayoth }; // FFDCFile end 1456552de05SJayanth Othayoth 1466552de05SJayanth Othayoth } // namespace pel 1476552de05SJayanth Othayoth } // namespace openpower 148