blob: a582d0e4b062316abfd48dce3b54243afaacf90d [file] [log] [blame]
Brad Bishopf6783cd2020-10-27 19:25:09 -04001#pragma once
2
3#include <nlohmann/json.hpp>
Brad Bishop5e5d4452020-10-27 19:46:13 -04004
Brad Bishopf6783cd2020-10-27 19:25:09 -04005#include <string>
6#include <vector>
7namespace openpower
8{
Brad Bishopf6783cd2020-10-27 19:25:09 -04009namespace pel
10{
11using FFDCData = std::vector<std::pair<std::string, std::string>>;
12
13using json = nlohmann::json;
14
15/**
16 * Create boot error PEL
17 *
18 * @param[in] ffdcData - failure data to append to PEL
19 * @param[in] calloutData - callout data to append to PEL
20 */
21void createBootErrorPEL(const FFDCData& ffdcData, const json& calloutData);
22
23/**
Jayanth Othayothac95c562021-07-16 05:56:04 -050024 * @brief Create a PEL for the specified event type
Andrew Geissler61febf02021-06-22 17:19:32 -050025 *
Jayanth Othayothac95c562021-07-16 05:56:04 -050026 * @param event - the event type
Andrew Geissler61febf02021-06-22 17:19:32 -050027 */
Jayanth Othayothac95c562021-07-16 05:56:04 -050028void createPEL(const std::string& event);
Andrew Geissler61febf02021-06-22 17:19:32 -050029
30/**
Brad Bishopf6783cd2020-10-27 19:25:09 -040031 * @class FFDCFile
32 * @brief This class is used to create ffdc data file and to get fd
33 */
34class FFDCFile
35{
36 public:
37 FFDCFile() = delete;
38 FFDCFile(const FFDCFile&) = delete;
39 FFDCFile& operator=(const FFDCFile&) = delete;
40 FFDCFile(FFDCFile&&) = delete;
41 FFDCFile& operator=(FFDCFile&&) = delete;
42
43 /**
44 * Used to pass json object to create unique ffdc file by using
45 * passed json data.
46 */
47 explicit FFDCFile(const json& pHALCalloutData);
48
49 /**
50 * Used to remove created ffdc file.
51 */
52 ~FFDCFile();
53
54 /**
55 * Used to get created ffdc file file descriptor id.
56 *
57 * @return file descriptor id
58 */
59 int getFileFD() const;
60
61 private:
62 /**
63 * Used to store callout ffdc data from passed json object.
64 */
65 std::string calloutData;
66
67 /**
68 * Used to store unique ffdc file name.
69 */
70 std::string calloutFile;
71
72 /**
73 * Used to store created ffdc file descriptor id.
74 */
75 int fileFD;
76
77 /**
78 * Used to create ffdc file to pass PEL api for creating
79 * pel records.
80 *
81 * @return NULL
82 */
83 void prepareFFDCFile();
84
85 /**
86 * Create unique ffdc file.
87 *
88 * @return NULL
89 */
90 void createCalloutFile();
91
92 /**
93 * Used write json object value into created file.
94 *
95 * @return NULL
96 */
97 void writeCalloutData();
98
99 /**
100 * Used set ffdc file seek position begining to consume by PEL
101 *
102 * @return NULL
103 */
104 void setCalloutFileSeekPos();
105
106 /**
107 * Used to remove created ffdc file.
108 *
109 * @return NULL
110 */
111 void removeCalloutFile();
112
113}; // FFDCFile end
114
115} // namespace pel
116} // namespace openpower