Eddie James | 2f9f9bb | 2021-09-20 14:26:31 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "config.h" |
| 4 | |
| 5 | #include "occ_errors.hpp" |
| 6 | |
| 7 | namespace open_power |
| 8 | { |
| 9 | namespace occ |
| 10 | { |
| 11 | |
| 12 | /** @class FFDC |
| 13 | * @brief Monitors for SBE FFDC availability |
| 14 | */ |
| 15 | class FFDC : public Error |
| 16 | { |
| 17 | public: |
| 18 | FFDC() = delete; |
| 19 | FFDC(const FFDC&) = delete; |
| 20 | FFDC& operator=(const FFDC&) = delete; |
| 21 | FFDC(FFDC&&) = default; |
| 22 | FFDC& operator=(FFDC&&) = default; |
| 23 | |
| 24 | /** @brief Constructs the FFDC object |
| 25 | * |
| 26 | * @param[in] event - reference to sd_event unique_ptr |
| 27 | * @param[in] file - File used by driver to communicate FFDC data |
| 28 | * @param[in] instance - OCC instance number |
| 29 | */ |
| 30 | FFDC(EventPtr& event, const fs::path& file, unsigned int instance) : |
| 31 | Error(event, file, nullptr), instance(instance) |
| 32 | { |
| 33 | // Nothing to do here. |
| 34 | } |
| 35 | |
| 36 | ~FFDC() |
| 37 | { |
| 38 | for (auto&& it : temporaryFiles) |
| 39 | { |
| 40 | close(it.second); |
| 41 | fs::remove(it.first); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** @brief Helper function to create a PEL with the OpenPower DBus |
| 46 | * interface |
| 47 | * |
| 48 | * @param[in] path - the DBus error path |
| 49 | * @param[in] src6 - the SBE error SRC6 word |
| 50 | * @param[in] msg - the error message |
| 51 | * @param[in] fd - the file descriptor for any FFDC |
| 52 | */ |
| 53 | static uint32_t createPEL(const char* path, uint32_t src6, const char* msg, |
| 54 | int fd = -1); |
| 55 | |
Eddie James | 9789e71 | 2022-05-25 15:43:40 -0500 | [diff] [blame] | 56 | /** @brief Helper function to create a PEL for the OCC reset with the |
| 57 | * OpenPower DBus interface |
| 58 | * |
| 59 | * @param[in] instance - the OCC instance id |
| 60 | * @param[in] path - the DBus error path |
| 61 | * @param[in] err - the error return code |
| 62 | * @param[in] callout - the PEL callout path |
| 63 | */ |
| 64 | static void createOCCResetPEL(unsigned int instance, const char* path, |
| 65 | int err, const char* callout); |
| 66 | |
Eddie James | 2f9f9bb | 2021-09-20 14:26:31 -0500 | [diff] [blame] | 67 | private: |
| 68 | /** @brief OCC instance number. Ex, 0,1, etc */ |
| 69 | unsigned int instance; |
| 70 | |
| 71 | /** @brief Stores the temporary files and file descriptors |
| 72 | * in usage. They will be cleaned up when the class |
| 73 | * is destroyed (when the application exits). |
| 74 | */ |
| 75 | std::vector<std::pair<fs::path, int>> temporaryFiles; |
| 76 | |
| 77 | /** @brief When the error event is received, analyzes it |
| 78 | * and makes a callback to error handler if the |
| 79 | * content denotes an error condition |
| 80 | */ |
| 81 | void analyzeEvent() override; |
| 82 | }; |
| 83 | |
| 84 | } // namespace occ |
| 85 | } // namespace open_power |