blob: fb2da90c75451fbdeac543e2b0a8aefedd682d8e [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:
40 PelMinimal() = delete;
41 ~PelMinimal() = default;
42 PelMinimal(const PelMinimal&) = delete;
43 PelMinimal& operator=(const PelMinimal&) = delete;
44 PelMinimal(PelMinimal&&) = delete;
45 PelMinimal& operator=(PelMinimal&&) = delete;
46
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 /**
55 * @brief Stream raw PEL data to buffer
56 *
57 * @param[out] pelBuffer - What the data will be written to
58 */
59 void raw(std::vector<uint8_t>& pelBuffer) const;
60
61 /**
62 * @brief Set the User Header subsystem field
63 *
64 * @param[in] subsystem - The subsystem value
65 */
66 void setSubsystem(uint8_t subsystem);
67
68 /**
69 * @brief Set the User Header severity field
70 *
71 * @param[in] severity - The severity to set
72 */
73 void setSeverity(uint8_t severity);
74
75 /**
76 * @brief Set the User Header event type field
77 *
78 * @param[in] type - The event type
79 */
80 void setType(uint8_t type);
81
82 /**
83 * @brief Set the User Header action flags field
84 *
85 * @param[in] action - The action flags to set
86 */
87 void setAction(uint16_t action);
88
89 /**
90 * @brief Set the Primary SRC section SRC words
91 *
92 * @param[in] srcWords - The SRC words
93 */
94 void setSrcWords(std::array<uint32_t, numSrcWords> srcWords);
95
96 /**
97 * @brief Set the Primary SRC section ascii string field
98 *
99 * @param[in] asciiString - The ascii string
100 */
101 void setAsciiString(std::array<char, asciiStringSize> asciiString);
102
103 /**
104 * @brief Get section count from the private header
105 *
106 * @return Number of sections
107 */
108 uint8_t getSectionCount();
109
110 /**
111 * @brief Set section count in private heasder
112 *
113 * @param[in] sectionCount - Number of sections
114 */
115 void setSectionCount(uint8_t sectionCount);
116
Ben Tynerfeeea832021-04-06 10:08:11 -0500117 /**
118 * @brief Set the symptom id field in extended user header
119 *
120 * @param[in] symptomId - The symptom ID to set
121 */
122 void setSymptomId(const std::string& symptomId);
123
Ben Tyner135793a2021-10-27 09:18:41 -0500124 /**
125 * @brief Update the PLID
126 */
127 void setPlid(uint32_t plid);
128
Ben Tynerf5210bb2021-01-05 12:58:10 -0600129 private:
130 /**
131 * @brief Maximum PEL size
132 */
133 static constexpr size_t _maxPELSize = 16384;
134
135 /**
136 * @brief Returns the size of the PEL
137 *
138 * @return size_t The PEL size in bytes
139 */
140 size_t size() const;
141
142 /**
143 * @brief PEL Private Header
144 */
145 std::unique_ptr<PrivateHeader> _ph;
146
147 /**
148 * @brief PEL User Header
149 */
150 std::unique_ptr<UserHeader> _uh;
151
152 /**
153 * @brief PEL Primary SRC
154 */
155 std::unique_ptr<PrimarySrc> _ps;
Ben Tynerfeeea832021-04-06 10:08:11 -0500156
157 /**
158 * @brief PEL Extended User Header
159 */
160 std::unique_ptr<ExtendedUserHeader> _eh;
Ben Tynerf5210bb2021-01-05 12:58:10 -0600161};
162
163} // namespace pel
164} // namespace attn