blob: efdaa030444664697fd229054c621634b023f029 [file] [log] [blame]
Jayanth Othayothe8bdeea2021-06-03 03:01:16 -05001#pragma once
2
3#include "additional_data.hpp"
4#include "pel.hpp"
5
6namespace openpower
7{
8namespace pels
9{
10namespace sbe
11{
12
13// SBE FFDC sub type.
14constexpr uint8_t sbeFFDCSubType = 0xCB;
15
16/** @class SbeFFDC
17 *
18 * @brief This class provides higher level interface to process SBE ffdc
19 * for PEL based error logging infrastructure.
20 * Key Functionalities included here
21 * - Process the SBE FFDC data with the help of FAPI infrastructure and
22 * and create PEL required format Callout and user data for hardware
23 * procedure failures specific reason code
24 * - Add the user data section with SBE FFDC data to support SBE provided
25 * parser tool usage.
26 * - Any SBE FFDC processing will result additional log message in journal
27 * and will continue to create Error log with available data. This is to
28 * help user to analyse the failure.
29 */
30class SbeFFDC
31{
32 public:
33 SbeFFDC() = delete;
34 SbeFFDC(const SbeFFDC&) = delete;
35 SbeFFDC& operator=(const SbeFFDC&) = delete;
36 SbeFFDC(SbeFFDC&&) = delete;
37 SbeFFDC& operator=(SbeFFDC&&) = delete;
38
39 /**
40 * @brief Constructor
41 *
42 * Create PEL required format data from SBE provided FFDC data.
43 *
44 * @param[in] data - The AdditionalData properties in this PEL event
45 * @param[in] files - FFDC files that go into UserData sections
46 */
47 SbeFFDC(const AdditionalData& data, const PelFFDC& files);
48
49 /**
50 * @brief Destructor
51 *
52 * Deletes the temporary files
53 */
54 ~SbeFFDC()
55 {
56
57 try
58 {
59 for (auto path : paths)
60 {
61 if (!path.empty())
62 {
63 // Delete temporary file from file system
64 std::error_code ec;
65 std::filesystem::remove(path, ec);
66 // Clear path to indicate file has been deleted
67 path.clear();
68 }
69 }
70 }
71 catch (...)
72 {
73 // Destructors should not throw exceptions
74 }
75 }
76
77 /**
78 * @brief Helper function to return FFDC files information, which
79 * includes SBE FFDC specific callout information.
80 *
81 * return PelFFDC - pel formated FFDC files.
82 */
83 const PelFFDC& getSbeFFDC()
84 {
85 return ffdcFiles;
86 }
87
88 private:
89 /**
90 * @brief Temporary files path information created as part of FFDC
91 * processing.
92 */
93 std::vector<std::filesystem::path> paths;
94
95 /**
96 * @brief PEL FFDC files, which includes the user data sections and the
97 * added callout details if any, found during SBE FFDC processing.
98 */
99 PelFFDC ffdcFiles;
100
101 /**
102 * @brief Processor position associated to SBE FFDC
103 */
104 uint32_t procPos;
105};
106
107} // namespace sbe
108} // namespace pels
109} // namespace openpower