blob: 5c780eb704f46c27e95bcf3614a28e425b045369 [file] [log] [blame]
Brad Bishopf6783cd2020-10-27 19:25:09 -04001#pragma once
2
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -05003#include <phal_exception.H>
4
Brad Bishopf6783cd2020-10-27 19:25:09 -04005#include <nlohmann/json.hpp>
Brad Bishop5e5d4452020-10-27 19:46:13 -04006
Brad Bishopf6783cd2020-10-27 19:25:09 -04007#include <string>
8#include <vector>
9namespace openpower
10{
Brad Bishopf6783cd2020-10-27 19:25:09 -040011namespace pel
12{
13using FFDCData = std::vector<std::pair<std::string, std::string>>;
14
15using json = nlohmann::json;
16
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -050017using namespace openpower::phal;
18
Brad Bishopf6783cd2020-10-27 19:25:09 -040019/**
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -050020 * @brief Create boot error PEL
Brad Bishopf6783cd2020-10-27 19:25:09 -040021 *
22 * @param[in] ffdcData - failure data to append to PEL
23 * @param[in] calloutData - callout data to append to PEL
24 */
25void createBootErrorPEL(const FFDCData& ffdcData, const json& calloutData);
26
27/**
Jayanth Othayothfe37aea2021-10-07 04:41:26 -050028 * @brief Create SBE boot error PEL and return id
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -050029 *
30 * @param[in] event - the event type
31 * @param[in] sbeError - SBE error object
32 * @param[in] ffdcData - failure data to append to PEL
Jayanth Othayothfe37aea2021-10-07 04:41:26 -050033 * @return Platform log id
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -050034 */
Jayanth Othayothfe37aea2021-10-07 04:41:26 -050035uint32_t createSbeErrorPEL(const std::string& event, const sbeError_t& sbeError,
36 const FFDCData& ffdcData);
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -050037
38/**
Jayanth Othayotha8d2f712021-09-20 07:02:51 -050039 * @brief Create a PEL for the specified event type and additional data
Andrew Geissler61febf02021-06-22 17:19:32 -050040 *
Jayanth Othayoth2eb31ad2021-09-20 07:13:28 -050041 * @param[in] event - the event type
Jayanth Othayotha8d2f712021-09-20 07:02:51 -050042 * @param[in] ffdcData - failure data to append to PEL
Andrew Geissler61febf02021-06-22 17:19:32 -050043 */
Jayanth Othayotha8d2f712021-09-20 07:02:51 -050044void createPEL(const std::string& event, const FFDCData& ffdcData = {});
Andrew Geissler61febf02021-06-22 17:19:32 -050045
46/**
Brad Bishopf6783cd2020-10-27 19:25:09 -040047 * @class FFDCFile
48 * @brief This class is used to create ffdc data file and to get fd
49 */
50class FFDCFile
51{
52 public:
53 FFDCFile() = delete;
54 FFDCFile(const FFDCFile&) = delete;
55 FFDCFile& operator=(const FFDCFile&) = delete;
56 FFDCFile(FFDCFile&&) = delete;
57 FFDCFile& operator=(FFDCFile&&) = delete;
58
59 /**
60 * Used to pass json object to create unique ffdc file by using
61 * passed json data.
62 */
63 explicit FFDCFile(const json& pHALCalloutData);
64
65 /**
66 * Used to remove created ffdc file.
67 */
68 ~FFDCFile();
69
70 /**
71 * Used to get created ffdc file file descriptor id.
72 *
73 * @return file descriptor id
74 */
75 int getFileFD() const;
76
77 private:
78 /**
79 * Used to store callout ffdc data from passed json object.
80 */
81 std::string calloutData;
82
83 /**
84 * Used to store unique ffdc file name.
85 */
86 std::string calloutFile;
87
88 /**
89 * Used to store created ffdc file descriptor id.
90 */
91 int fileFD;
92
93 /**
94 * Used to create ffdc file to pass PEL api for creating
95 * pel records.
96 *
97 * @return NULL
98 */
99 void prepareFFDCFile();
100
101 /**
102 * Create unique ffdc file.
103 *
104 * @return NULL
105 */
106 void createCalloutFile();
107
108 /**
109 * Used write json object value into created file.
110 *
111 * @return NULL
112 */
113 void writeCalloutData();
114
115 /**
116 * Used set ffdc file seek position begining to consume by PEL
117 *
118 * @return NULL
119 */
120 void setCalloutFileSeekPos();
121
122 /**
123 * Used to remove created ffdc file.
124 *
125 * @return NULL
126 */
127 void removeCalloutFile();
128
129}; // FFDCFile end
130
131} // namespace pel
132} // namespace openpower