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