blob: bf005c19a3cc1edd9572af6d5b2fc7c8c5b3601d [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/**
24 * @class FFDCFile
25 * @brief This class is used to create ffdc data file and to get fd
26 */
27class FFDCFile
28{
29 public:
30 FFDCFile() = delete;
31 FFDCFile(const FFDCFile&) = delete;
32 FFDCFile& operator=(const FFDCFile&) = delete;
33 FFDCFile(FFDCFile&&) = delete;
34 FFDCFile& operator=(FFDCFile&&) = delete;
35
36 /**
37 * Used to pass json object to create unique ffdc file by using
38 * passed json data.
39 */
40 explicit FFDCFile(const json& pHALCalloutData);
41
42 /**
43 * Used to remove created ffdc file.
44 */
45 ~FFDCFile();
46
47 /**
48 * Used to get created ffdc file file descriptor id.
49 *
50 * @return file descriptor id
51 */
52 int getFileFD() const;
53
54 private:
55 /**
56 * Used to store callout ffdc data from passed json object.
57 */
58 std::string calloutData;
59
60 /**
61 * Used to store unique ffdc file name.
62 */
63 std::string calloutFile;
64
65 /**
66 * Used to store created ffdc file descriptor id.
67 */
68 int fileFD;
69
70 /**
71 * Used to create ffdc file to pass PEL api for creating
72 * pel records.
73 *
74 * @return NULL
75 */
76 void prepareFFDCFile();
77
78 /**
79 * Create unique ffdc file.
80 *
81 * @return NULL
82 */
83 void createCalloutFile();
84
85 /**
86 * Used write json object value into created file.
87 *
88 * @return NULL
89 */
90 void writeCalloutData();
91
92 /**
93 * Used set ffdc file seek position begining to consume by PEL
94 *
95 * @return NULL
96 */
97 void setCalloutFileSeekPos();
98
99 /**
100 * Used to remove created ffdc file.
101 *
102 * @return NULL
103 */
104 void removeCalloutFile();
105
106}; // FFDCFile end
107
108} // namespace pel
109} // namespace openpower