16852d722SMatt Spinler #pragma once 26852d722SMatt Spinler 36852d722SMatt Spinler #include "registry.hpp" 46852d722SMatt Spinler #include "stream.hpp" 56852d722SMatt Spinler 66852d722SMatt Spinler #include <string> 76852d722SMatt Spinler 86852d722SMatt Spinler namespace openpower 96852d722SMatt Spinler { 106852d722SMatt Spinler namespace pels 116852d722SMatt Spinler { 126852d722SMatt Spinler namespace src 136852d722SMatt Spinler { 146852d722SMatt Spinler 156852d722SMatt Spinler const size_t asciiStringSize = 32; 166852d722SMatt Spinler 176852d722SMatt Spinler /** 186852d722SMatt Spinler * @class AsciiString 196852d722SMatt Spinler * 206852d722SMatt Spinler * This represents the ASCII string field in the SRC PEL section. 216852d722SMatt Spinler * This 32 character string shows up on the panel on a function 11. 226852d722SMatt Spinler * 236852d722SMatt Spinler * The first 2 characters are the SRC type, like 'BD' or '11'. 246852d722SMatt Spinler * Next is the subsystem, like '8D', if a BD SRC, otherwise '00'. 256852d722SMatt Spinler * Next is the reason code, like 'AAAA'. 266852d722SMatt Spinler * The rest is filled in with spaces. 276852d722SMatt Spinler */ 286852d722SMatt Spinler class AsciiString 296852d722SMatt Spinler { 306852d722SMatt Spinler public: 316852d722SMatt Spinler AsciiString() = delete; 326852d722SMatt Spinler ~AsciiString() = default; 336852d722SMatt Spinler AsciiString(const AsciiString&) = default; 346852d722SMatt Spinler AsciiString& operator=(const AsciiString&) = default; 356852d722SMatt Spinler AsciiString(AsciiString&&) = default; 366852d722SMatt Spinler AsciiString& operator=(AsciiString&&) = default; 376852d722SMatt Spinler 386852d722SMatt Spinler /** 396852d722SMatt Spinler * @brief Constructor 406852d722SMatt Spinler * 416852d722SMatt Spinler * Fills in this class's data fields from the stream. 426852d722SMatt Spinler * 436852d722SMatt Spinler * @param[in] pel - the PEL data stream 446852d722SMatt Spinler */ 456852d722SMatt Spinler explicit AsciiString(Stream& stream); 466852d722SMatt Spinler 476852d722SMatt Spinler /** 486852d722SMatt Spinler * @brief Constructor 496852d722SMatt Spinler * 506852d722SMatt Spinler * Fills in the class from the registry entry 516852d722SMatt Spinler */ 526852d722SMatt Spinler explicit AsciiString(const message::Entry& entry); 536852d722SMatt Spinler 546852d722SMatt Spinler /** 556852d722SMatt Spinler * @brief Flatten the object into the stream 566852d722SMatt Spinler * 576852d722SMatt Spinler * @param[in] stream - The stream to write to 586852d722SMatt Spinler */ 59724d0d8cSMatt Spinler void flatten(Stream& stream) const; 606852d722SMatt Spinler 616852d722SMatt Spinler /** 626852d722SMatt Spinler * @brief Fills in the object from the stream data 636852d722SMatt Spinler * 646852d722SMatt Spinler * @param[in] stream - The stream to read from 656852d722SMatt Spinler */ 666852d722SMatt Spinler void unflatten(Stream& stream); 676852d722SMatt Spinler 686852d722SMatt Spinler /** 696852d722SMatt Spinler * @brief Return the 32 character ASCII string data 706852d722SMatt Spinler * 716852d722SMatt Spinler * @return std::string - The data 726852d722SMatt Spinler */ 736852d722SMatt Spinler std::string get() const; 746852d722SMatt Spinler 756852d722SMatt Spinler /** 766852d722SMatt Spinler * @brief Converts a byte of raw data to 2 characters 776852d722SMatt Spinler * and writes it to the offset. 786852d722SMatt Spinler * 796852d722SMatt Spinler * For example, if string is: "AABBCCDD" 806852d722SMatt Spinler * 816852d722SMatt Spinler * setByte(0, 0x11); 826852d722SMatt Spinler * setByte(1, 0x22); 836852d722SMatt Spinler * setByte(2, 0x33); 846852d722SMatt Spinler * setByte(3, 0x44); 856852d722SMatt Spinler * 866852d722SMatt Spinler * results in "11223344" 876852d722SMatt Spinler * 886852d722SMatt Spinler * @param[in] offset - The offset into the ascii string 896852d722SMatt Spinler * @param[in] value - The value to write (0x55 -> "55") 906852d722SMatt Spinler */ 916852d722SMatt Spinler void setByte(size_t offset, uint8_t value); 926852d722SMatt Spinler 93*50bfa69aSSumit Kumar private: 946852d722SMatt Spinler /** 956852d722SMatt Spinler * @brief The ASCII string itself 966852d722SMatt Spinler */ 976852d722SMatt Spinler std::array<char, asciiStringSize> _string; 986852d722SMatt Spinler }; 996852d722SMatt Spinler 1006852d722SMatt Spinler } // namespace src 1016852d722SMatt Spinler 1026852d722SMatt Spinler } // namespace pels 1036852d722SMatt Spinler } // namespace openpower 104