Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 1 | #pragma once
|
| 2 |
|
Ramesh Iyyar | ef767ee | 2020-09-22 02:46:51 -0500 | [diff] [blame^] | 3 | #include <nlohmann/json.hpp>
|
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp>
|
| 5 | #include <string>
|
| 6 | #include <vector>
|
| 7 | namespace openpower
|
| 8 | {
|
| 9 | namespace util
|
| 10 | {
|
| 11 | /**
|
| 12 | * Get D-Bus service name for the specified object and interface
|
| 13 | *
|
| 14 | * @param[in] bus - sdbusplus D-Bus to attach to
|
| 15 | * @param[in] objectPath - D-Bus object path
|
| 16 | * @param[in] interface - D-Bus interface name
|
| 17 | *
|
| 18 | * @return service name on success and exception on failure
|
| 19 | */
|
| 20 | std::string getService(sdbusplus::bus::bus& bus, const std::string& objectPath,
|
| 21 | const std::string& interface);
|
| 22 | } // namespace util
|
| 23 | namespace pel
|
| 24 | {
|
| 25 | using FFDCData = std::vector<std::pair<std::string, std::string>>;
|
Ramesh Iyyar | ef767ee | 2020-09-22 02:46:51 -0500 | [diff] [blame^] | 26 |
|
| 27 | using json = nlohmann::json;
|
| 28 |
|
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 29 | /**
|
| 30 | * Create boot error PEL
|
| 31 | *
|
| 32 | * @param[in] ffdcData - failure data to append to PEL
|
Ramesh Iyyar | ef767ee | 2020-09-22 02:46:51 -0500 | [diff] [blame^] | 33 | * @param[in] calloutData - callout data to append to PEL
|
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 34 | */
|
Ramesh Iyyar | ef767ee | 2020-09-22 02:46:51 -0500 | [diff] [blame^] | 35 | void createBootErrorPEL(const FFDCData& ffdcData, const json& calloutData);
|
| 36 |
|
| 37 | /**
|
| 38 | * @class FFDCFile
|
| 39 | * @brief This class is used to create ffdc data file and to get fd
|
| 40 | */
|
| 41 | class FFDCFile
|
| 42 | {
|
| 43 | public:
|
| 44 | FFDCFile() = delete;
|
| 45 | FFDCFile(const FFDCFile&) = delete;
|
| 46 | FFDCFile& operator=(const FFDCFile&) = delete;
|
| 47 | FFDCFile(FFDCFile&&) = delete;
|
| 48 | FFDCFile& operator=(FFDCFile&&) = delete;
|
| 49 |
|
| 50 | /**
|
| 51 | * Used to pass json object to create unique ffdc file by using
|
| 52 | * passed json data.
|
| 53 | */
|
| 54 | explicit FFDCFile(const json& pHALCalloutData);
|
| 55 |
|
| 56 | /**
|
| 57 | * Used to remove created ffdc file.
|
| 58 | */
|
| 59 | ~FFDCFile();
|
| 60 |
|
| 61 | /**
|
| 62 | * Used to get created ffdc file file descriptor id.
|
| 63 | *
|
| 64 | * @return file descriptor id
|
| 65 | */
|
| 66 | int getFileFD() const;
|
| 67 |
|
| 68 | private:
|
| 69 | /**
|
| 70 | * Used to store callout ffdc data from passed json object.
|
| 71 | */
|
| 72 | std::string calloutData;
|
| 73 |
|
| 74 | /**
|
| 75 | * Used to store unique ffdc file name.
|
| 76 | */
|
| 77 | std::string calloutFile;
|
| 78 |
|
| 79 | /**
|
| 80 | * Used to store created ffdc file descriptor id.
|
| 81 | */
|
| 82 | int fileFD;
|
| 83 |
|
| 84 | /**
|
| 85 | * Used to create ffdc file to pass PEL api for creating
|
| 86 | * pel records.
|
| 87 | *
|
| 88 | * @return NULL
|
| 89 | */
|
| 90 | void prepareFFDCFile();
|
| 91 |
|
| 92 | /**
|
| 93 | * Create unique ffdc file.
|
| 94 | *
|
| 95 | * @return NULL
|
| 96 | */
|
| 97 | void createCalloutFile();
|
| 98 |
|
| 99 | /**
|
| 100 | * Used write json object value into created file.
|
| 101 | *
|
| 102 | * @return NULL
|
| 103 | */
|
| 104 | void writeCalloutData();
|
| 105 |
|
| 106 | /**
|
| 107 | * Used set ffdc file seek position begining to consume by PEL
|
| 108 | *
|
| 109 | * @return NULL
|
| 110 | */
|
| 111 | void setCalloutFileSeekPos();
|
| 112 |
|
| 113 | /**
|
| 114 | * Used to remove created ffdc file.
|
| 115 | *
|
| 116 | * @return NULL
|
| 117 | */
|
| 118 | void removeCalloutFile();
|
| 119 |
|
| 120 | }; // FFDCFile end
|
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 121 |
|
| 122 | } // namespace pel
|
| 123 | } // namespace openpower
|