blob: 4116049e51469b1b68cbfc082f12cb3352e1fccf [file] [log] [blame]
Ben Tynerf5210bb2021-01-05 12:58:10 -06001#pragma once
2
Ben Tynerfeeea832021-04-06 10:08:11 -05003#include "extended_user_header.hpp"
Ben Tynerf5210bb2021-01-05 12:58:10 -06004#include "pel_common.hpp"
5#include "primary_src.hpp"
6#include "private_header.hpp"
7#include "user_header.hpp"
8
9#include <vector>
10
11namespace attn
12{
13namespace pel
14{
15
16/** @class PelMinimal
17 *
18 * @brief Class for a minimal platform event log (PEL)
19 *
20 * This class can be used to create form a PEL and create a raw PEL file. The
21 * implementation based on "Platform Event Log and SRC PLDD v1.1"
22 *
23 * This PEL consists of the following position dependent sections:
24 *
25 * |----------+------------------------------|
26 * | length | section |
27 * |----------+------------------------------|
28 * | 48 | Private Header Section |
29 * |----------+------------------------------|
30 * | 24 | User Header Section |
31 * |----------+------------------------------|
32 * | 72 | Primary SRC Section |
33 * |----------+------------------------------|
Ben Tynerfeeea832021-04-06 10:08:11 -050034 * | 20 | Extended User Header |
35 * |----------+------------------------------|
Ben Tynerf5210bb2021-01-05 12:58:10 -060036 */
37class PelMinimal
38{
39 public:
Patrick Williams27dd6362023-05-10 07:51:20 -050040 PelMinimal() = delete;
41 ~PelMinimal() = default;
42 PelMinimal(const PelMinimal&) = delete;
Ben Tynerf5210bb2021-01-05 12:58:10 -060043 PelMinimal& operator=(const PelMinimal&) = delete;
Patrick Williams27dd6362023-05-10 07:51:20 -050044 PelMinimal(PelMinimal&&) = delete;
45 PelMinimal& operator=(PelMinimal&&) = delete;
Ben Tynerf5210bb2021-01-05 12:58:10 -060046
47 /**
48 * @brief Create a minimal PEL object from raw data
49 *
50 * @param[in] pelBuffer - buffer containing a raw PEL
51 */
Ben Tynerdc5b0ff2021-01-14 14:01:39 -060052 explicit PelMinimal(std::vector<uint8_t>& data);
Ben Tynerf5210bb2021-01-05 12:58:10 -060053
54 /**
austinfcui9e4d1902022-02-22 11:03:49 -060055 * @brief Initialize the object's data members
56 *
57 * @param[in] data - reference to the vector
58 */
59 void initialize(std::vector<uint8_t>& data);
60
61 /**
Ben Tynerf5210bb2021-01-05 12:58:10 -060062 * @brief Stream raw PEL data to buffer
63 *
64 * @param[out] pelBuffer - What the data will be written to
65 */
66 void raw(std::vector<uint8_t>& pelBuffer) const;
67
68 /**
69 * @brief Set the User Header subsystem field
70 *
71 * @param[in] subsystem - The subsystem value
72 */
73 void setSubsystem(uint8_t subsystem);
74
75 /**
76 * @brief Set the User Header severity field
77 *
78 * @param[in] severity - The severity to set
79 */
80 void setSeverity(uint8_t severity);
81
82 /**
83 * @brief Set the User Header event type field
84 *
85 * @param[in] type - The event type
86 */
87 void setType(uint8_t type);
88
89 /**
90 * @brief Set the User Header action flags field
91 *
92 * @param[in] action - The action flags to set
93 */
94 void setAction(uint16_t action);
95
96 /**
97 * @brief Set the Primary SRC section SRC words
98 *
99 * @param[in] srcWords - The SRC words
100 */
101 void setSrcWords(std::array<uint32_t, numSrcWords> srcWords);
102
103 /**
104 * @brief Set the Primary SRC section ascii string field
105 *
106 * @param[in] asciiString - The ascii string
107 */
108 void setAsciiString(std::array<char, asciiStringSize> asciiString);
109
110 /**
111 * @brief Get section count from the private header
112 *
113 * @return Number of sections
114 */
115 uint8_t getSectionCount();
116
117 /**
118 * @brief Set section count in private heasder
119 *
120 * @param[in] sectionCount - Number of sections
121 */
122 void setSectionCount(uint8_t sectionCount);
123
Ben Tynerfeeea832021-04-06 10:08:11 -0500124 /**
125 * @brief Set the symptom id field in extended user header
126 *
127 * @param[in] symptomId - The symptom ID to set
128 */
129 void setSymptomId(const std::string& symptomId);
130
Ben Tyner135793a2021-10-27 09:18:41 -0500131 /**
132 * @brief Update the PLID
133 */
134 void setPlid(uint32_t plid);
135
Ben Tynerf5210bb2021-01-05 12:58:10 -0600136 private:
137 /**
138 * @brief Maximum PEL size
139 */
140 static constexpr size_t _maxPELSize = 16384;
141
142 /**
143 * @brief Returns the size of the PEL
144 *
145 * @return size_t The PEL size in bytes
146 */
147 size_t size() const;
148
149 /**
150 * @brief PEL Private Header
151 */
152 std::unique_ptr<PrivateHeader> _ph;
153
154 /**
155 * @brief PEL User Header
156 */
157 std::unique_ptr<UserHeader> _uh;
158
159 /**
160 * @brief PEL Primary SRC
161 */
162 std::unique_ptr<PrimarySrc> _ps;
Ben Tynerfeeea832021-04-06 10:08:11 -0500163
164 /**
165 * @brief PEL Extended User Header
166 */
167 std::unique_ptr<ExtendedUserHeader> _eh;
Ben Tynerf5210bb2021-01-05 12:58:10 -0600168};
169
170} // namespace pel
171} // namespace attn