1 #pragma once 2 3 #include "pel_common.hpp" 4 #include "pel_section.hpp" 5 #include "stream.hpp" 6 7 #include <array> 8 9 namespace attn 10 { 11 namespace pel 12 { 13 14 /** 15 * @class PrimarySrc 16 * 17 * @brief This class represents the primary SRC sections in the PEL. 18 * 19 * |--------+--------------------------------------------| 20 * | length | field | 21 * |--------+--------------------------------------------| 22 * | 1 | Version = 0x02 | 23 * |--------+--------------------------------------------| 24 * | 1 | Flags = 0x00 (no additional data sections) | 25 * |--------+--------------------------------------------| 26 * | 1 | reserved | 27 * |--------+--------------------------------------------| 28 * | 1 | Number of words of hex data + 1 = 0x09 | 29 * |--------+--------------------------------------------| 30 * | 2 | reserved | 31 * |--------+--------------------------------------------| 32 * | 2 | Total length of SRC in bytes = 0x48 | 33 * |--------+--------------------------------------------| 34 * | 4 | Hex Word 2 (word 1 intentionally skipped) | 35 * |--------+--------------------------------------------| 36 * | 4 | Hex Word 3 | 37 * |--------+--------------------------------------------| 38 * | 4 | Hex Word 4 | 39 * |--------+--------------------------------------------| 40 * | 4 | Hex Word 5 | 41 * |--------+--------------------------------------------| 42 * | 4 | Hex Word 6 | 43 * |--------+--------------------------------------------| 44 * | 4 | Hex Word 7 | 45 * |--------+--------------------------------------------| 46 * | 4 | Hex Word 8 | 47 * |--------+--------------------------------------------| 48 * | 4 | Hex Word 9 | 49 * |--------+--------------------------------------------| 50 * | 32 | ASCII String | 51 * |--------+--------------------------------------------| 52 */ 53 class PrimarySrc : public Section 54 { 55 public: 56 enum HeaderFlags 57 { 58 additionalSections = 0x01, 59 powerFaultEvent = 0x02, 60 hypDumpInit = 0x04, 61 i5OSServiceEventBit = 0x10, 62 virtualProgressSRC = 0x80 63 }; 64 65 PrimarySrc() = delete; 66 ~PrimarySrc() = default; 67 PrimarySrc(const PrimarySrc&) = delete; 68 PrimarySrc& operator=(const PrimarySrc&) = delete; 69 PrimarySrc(PrimarySrc&&) = delete; 70 PrimarySrc& operator=(PrimarySrc&&) = delete; 71 72 /** 73 * @brief Constructor 74 * 75 * Fills in this class's data fields from raw data. 76 * 77 * @param[in] pel - the PEL data stream 78 */ 79 explicit PrimarySrc(Stream& pel); 80 81 /** 82 * @brief Flatten the section into the stream 83 * 84 * @param[in] stream - The stream to write to 85 */ 86 void flatten(Stream& stream) const override; 87 88 /** 89 * @brief Fills in the object from the stream data 90 * 91 * @param[in] stream - The stream to read from 92 */ 93 void unflatten(Stream& stream); 94 95 /** 96 * @brief Set the SRC words 97 * 98 * @param[in] srcWords - The SRC words 99 */ 100 void setSrcWords(std::array<uint32_t, numSrcWords> srcWords); 101 102 /** 103 * @brief Set the ascii string field 104 * 105 * @param[in] asciiString - The ascii string 106 */ 107 void setAsciiString(std::array<char, asciiStringSize> asciiString); 108 109 private: 110 /** 111 * @brief The SRC version field 112 */ 113 uint8_t _version = 0x02; 114 115 /** 116 * @brief The SRC flags field 117 */ 118 uint8_t _flags = 0; 119 120 /** 121 * @brief A byte of reserved data after the flags field 122 */ 123 uint8_t _reserved1B = 0; 124 125 /** 126 * @brief The hex data word count. 127 */ 128 uint8_t _wordCount = numSrcWords + 1; // +1 for backward compatability 129 130 /** 131 * @brief Two bytes of reserved data after the hex word count 132 */ 133 uint16_t _reserved2B = 0; 134 135 /** 136 * @brief The total size of the SRC section (w/o section header) 137 */ 138 uint16_t _size = 72; // 72 (bytes) = size of basic SRC section 139 140 /** 141 * @brief The SRC 'hex words'. 142 */ 143 std::array<uint32_t, numSrcWords> _srcWords; 144 145 /** 146 * @brief The 32 byte ASCII character string of the SRC 147 */ 148 std::array<char, asciiStringSize> _asciiString; 149 }; 150 151 } // namespace pel 152 } // namespace attn 153