blob: cde0ead79f8d9795f10745701148bdaad81b824e [file] [log] [blame]
Ben Tynerf5210bb2021-01-05 12:58:10 -06001#pragma once
2
3#include "pel_common.hpp"
4#include "primary_src.hpp"
5#include "private_header.hpp"
6#include "user_header.hpp"
7
8#include <vector>
9
10namespace attn
11{
12namespace pel
13{
14
15/** @class PelMinimal
16 *
17 * @brief Class for a minimal platform event log (PEL)
18 *
19 * This class can be used to create form a PEL and create a raw PEL file. The
20 * implementation based on "Platform Event Log and SRC PLDD v1.1"
21 *
22 * This PEL consists of the following position dependent sections:
23 *
24 * |----------+------------------------------|
25 * | length | section |
26 * |----------+------------------------------|
27 * | 48 | Private Header Section |
28 * |----------+------------------------------|
29 * | 24 | User Header Section |
30 * |----------+------------------------------|
31 * | 72 | Primary SRC Section |
32 * |----------+------------------------------|
33 */
34class PelMinimal
35{
36 public:
37 PelMinimal() = delete;
38 ~PelMinimal() = default;
39 PelMinimal(const PelMinimal&) = delete;
40 PelMinimal& operator=(const PelMinimal&) = delete;
41 PelMinimal(PelMinimal&&) = delete;
42 PelMinimal& operator=(PelMinimal&&) = delete;
43
44 /**
45 * @brief Create a minimal PEL object from raw data
46 *
47 * @param[in] pelBuffer - buffer containing a raw PEL
48 */
49 PelMinimal(std::vector<uint8_t>& data);
50
51 /**
52 * @brief Stream raw PEL data to buffer
53 *
54 * @param[out] pelBuffer - What the data will be written to
55 */
56 void raw(std::vector<uint8_t>& pelBuffer) const;
57
58 /**
59 * @brief Set the User Header subsystem field
60 *
61 * @param[in] subsystem - The subsystem value
62 */
63 void setSubsystem(uint8_t subsystem);
64
65 /**
66 * @brief Set the User Header severity field
67 *
68 * @param[in] severity - The severity to set
69 */
70 void setSeverity(uint8_t severity);
71
72 /**
73 * @brief Set the User Header event type field
74 *
75 * @param[in] type - The event type
76 */
77 void setType(uint8_t type);
78
79 /**
80 * @brief Set the User Header action flags field
81 *
82 * @param[in] action - The action flags to set
83 */
84 void setAction(uint16_t action);
85
86 /**
87 * @brief Set the Primary SRC section SRC words
88 *
89 * @param[in] srcWords - The SRC words
90 */
91 void setSrcWords(std::array<uint32_t, numSrcWords> srcWords);
92
93 /**
94 * @brief Set the Primary SRC section ascii string field
95 *
96 * @param[in] asciiString - The ascii string
97 */
98 void setAsciiString(std::array<char, asciiStringSize> asciiString);
99
100 /**
101 * @brief Get section count from the private header
102 *
103 * @return Number of sections
104 */
105 uint8_t getSectionCount();
106
107 /**
108 * @brief Set section count in private heasder
109 *
110 * @param[in] sectionCount - Number of sections
111 */
112 void setSectionCount(uint8_t sectionCount);
113
114 private:
115 /**
116 * @brief Maximum PEL size
117 */
118 static constexpr size_t _maxPELSize = 16384;
119
120 /**
121 * @brief Returns the size of the PEL
122 *
123 * @return size_t The PEL size in bytes
124 */
125 size_t size() const;
126
127 /**
128 * @brief PEL Private Header
129 */
130 std::unique_ptr<PrivateHeader> _ph;
131
132 /**
133 * @brief PEL User Header
134 */
135 std::unique_ptr<UserHeader> _uh;
136
137 /**
138 * @brief PEL Primary SRC
139 */
140 std::unique_ptr<PrimarySrc> _ps;
141};
142
143} // namespace pel
144} // namespace attn