103c1d915SMatt Spinler #pragma once 203c1d915SMatt Spinler 3fdb6a202SMatt Spinler #include "elog_entry.hpp" 4fdb6a202SMatt Spinler #include "registry.hpp" 503c1d915SMatt Spinler #include "section.hpp" 603c1d915SMatt Spinler #include "stream.hpp" 703c1d915SMatt Spinler 803c1d915SMatt Spinler namespace openpower 903c1d915SMatt Spinler { 1003c1d915SMatt Spinler namespace pels 1103c1d915SMatt Spinler { 1203c1d915SMatt Spinler 131a94cc38SMatt Spinler static constexpr uint8_t userHeaderVersion = 0x01; 1403c1d915SMatt Spinler 1503c1d915SMatt Spinler /** 1603c1d915SMatt Spinler * @class UserHeader 1703c1d915SMatt Spinler * 1803c1d915SMatt Spinler * This represents the User Header section in a PEL. It is required, 1903c1d915SMatt Spinler * and it is always the second section. 2003c1d915SMatt Spinler * 2103c1d915SMatt Spinler * The Section base class handles the section header structure that every 2203c1d915SMatt Spinler * PEL section has at offset zero. 2303c1d915SMatt Spinler * 2403c1d915SMatt Spinler * The fields in this class directly correspond to the order and sizes of 2503c1d915SMatt Spinler * the fields in the section. 2603c1d915SMatt Spinler */ 2703c1d915SMatt Spinler class UserHeader : public Section 2803c1d915SMatt Spinler { 2903c1d915SMatt Spinler public: 3003c1d915SMatt Spinler UserHeader() = delete; 3103c1d915SMatt Spinler ~UserHeader() = default; 3203c1d915SMatt Spinler UserHeader(const UserHeader&) = default; 3303c1d915SMatt Spinler UserHeader& operator=(const UserHeader&) = default; 3403c1d915SMatt Spinler UserHeader(UserHeader&&) = default; 3503c1d915SMatt Spinler UserHeader& operator=(UserHeader&&) = default; 3603c1d915SMatt Spinler 3703c1d915SMatt Spinler /** 3803c1d915SMatt Spinler * @brief Constructor 3903c1d915SMatt Spinler * 40fdb6a202SMatt Spinler * Creates a valid UserHeader with the passed in data. 41fdb6a202SMatt Spinler * 42fdb6a202SMatt Spinler * @param[in] entry - The message registry entry for this error 43fdb6a202SMatt Spinler * @param[in] severity - The OpenBMC event log severity for this error 44fdb6a202SMatt Spinler */ 45fdb6a202SMatt Spinler UserHeader(const message::Entry& entry, 46fdb6a202SMatt Spinler phosphor::logging::Entry::Level severity); 47fdb6a202SMatt Spinler 48fdb6a202SMatt Spinler /** 49fdb6a202SMatt Spinler * @brief Constructor 50fdb6a202SMatt Spinler * 5103c1d915SMatt Spinler * Fills in this class's data fields from the stream. 5203c1d915SMatt Spinler * 5303c1d915SMatt Spinler * @param[in] pel - the PEL data stream 5403c1d915SMatt Spinler */ 5503c1d915SMatt Spinler explicit UserHeader(Stream& pel); 5603c1d915SMatt Spinler 5703c1d915SMatt Spinler /** 58cf5a8d0fSMatt Spinler * @brief Flatten the section into the stream 59cf5a8d0fSMatt Spinler * 60cf5a8d0fSMatt Spinler * @param[in] stream - The stream to write to 61cf5a8d0fSMatt Spinler */ 62cf5a8d0fSMatt Spinler void flatten(Stream& stream) override; 63cf5a8d0fSMatt Spinler 64cf5a8d0fSMatt Spinler /** 6503c1d915SMatt Spinler * @brief Returns the subsystem field. 6603c1d915SMatt Spinler * 6797d19b48SMatt Spinler * @return uint8_t - the subsystem 6803c1d915SMatt Spinler */ 6997d19b48SMatt Spinler uint8_t subsystem() const 7003c1d915SMatt Spinler { 7103c1d915SMatt Spinler return _eventSubsystem; 7203c1d915SMatt Spinler } 7303c1d915SMatt Spinler 7403c1d915SMatt Spinler /** 7503c1d915SMatt Spinler * @brief Returns the event scope field. 7603c1d915SMatt Spinler * 7797d19b48SMatt Spinler * @return uint8_t - the event scope 7803c1d915SMatt Spinler */ 7997d19b48SMatt Spinler uint8_t scope() const 8003c1d915SMatt Spinler { 8103c1d915SMatt Spinler return _eventScope; 8203c1d915SMatt Spinler } 8303c1d915SMatt Spinler 8403c1d915SMatt Spinler /** 8503c1d915SMatt Spinler * @brief Returns the severity field. 8603c1d915SMatt Spinler * 8797d19b48SMatt Spinler * @return uint8_t - the severity 8803c1d915SMatt Spinler */ 8997d19b48SMatt Spinler uint8_t severity() const 9003c1d915SMatt Spinler { 9103c1d915SMatt Spinler return _eventSeverity; 9203c1d915SMatt Spinler } 9303c1d915SMatt Spinler 9403c1d915SMatt Spinler /** 9503c1d915SMatt Spinler * @brief Returns the event type field. 9603c1d915SMatt Spinler * 9797d19b48SMatt Spinler * @return uint8_t - the event type 9803c1d915SMatt Spinler */ 9997d19b48SMatt Spinler uint8_t eventType() const 10003c1d915SMatt Spinler { 10103c1d915SMatt Spinler return _eventType; 10203c1d915SMatt Spinler } 10303c1d915SMatt Spinler 10403c1d915SMatt Spinler /** 105*f1e85e20SMatt Spinler * @brief Set the event type field 106*f1e85e20SMatt Spinler * 107*f1e85e20SMatt Spinler * @param[in] type - the new event type 108*f1e85e20SMatt Spinler */ 109*f1e85e20SMatt Spinler void setEventType(uint8_t type) 110*f1e85e20SMatt Spinler { 111*f1e85e20SMatt Spinler _eventType = type; 112*f1e85e20SMatt Spinler } 113*f1e85e20SMatt Spinler 114*f1e85e20SMatt Spinler /** 11503c1d915SMatt Spinler * @brief Returns the problem domain field. 11603c1d915SMatt Spinler * 11797d19b48SMatt Spinler * @return uint8_t - the problem domain 11803c1d915SMatt Spinler */ 11997d19b48SMatt Spinler uint8_t problemDomain() const 12003c1d915SMatt Spinler { 12103c1d915SMatt Spinler return _problemDomain; 12203c1d915SMatt Spinler } 12303c1d915SMatt Spinler 12403c1d915SMatt Spinler /** 12503c1d915SMatt Spinler * @brief Returns the problem vector field. 12603c1d915SMatt Spinler * 12797d19b48SMatt Spinler * @return uint8_t - the problem vector 12803c1d915SMatt Spinler */ 12997d19b48SMatt Spinler uint8_t problemVector() const 13003c1d915SMatt Spinler { 13103c1d915SMatt Spinler return _problemVector; 13203c1d915SMatt Spinler } 13303c1d915SMatt Spinler 13403c1d915SMatt Spinler /** 13503c1d915SMatt Spinler * @brief Returns the action flags field. 13603c1d915SMatt Spinler * 13797d19b48SMatt Spinler * @return uint16_t - the action flags 13803c1d915SMatt Spinler */ 13997d19b48SMatt Spinler uint16_t actionFlags() const 14003c1d915SMatt Spinler { 14103c1d915SMatt Spinler return _actionFlags; 14203c1d915SMatt Spinler } 14303c1d915SMatt Spinler 14403c1d915SMatt Spinler /** 145*f1e85e20SMatt Spinler * @brief Sets the action flags field 146*f1e85e20SMatt Spinler * 147*f1e85e20SMatt Spinler * @param[in] flags - the new action flags 148*f1e85e20SMatt Spinler */ 149*f1e85e20SMatt Spinler void setActionFlags(uint16_t flags) 150*f1e85e20SMatt Spinler { 151*f1e85e20SMatt Spinler _actionFlags = flags; 152*f1e85e20SMatt Spinler } 153*f1e85e20SMatt Spinler 154*f1e85e20SMatt Spinler /** 15503c1d915SMatt Spinler * @brief Returns the size of this section when flattened into a PEL 15603c1d915SMatt Spinler * 15703c1d915SMatt Spinler * @return size_t - the size of the section 15803c1d915SMatt Spinler */ 15903c1d915SMatt Spinler static constexpr size_t flattenedSize() 16003c1d915SMatt Spinler { 16103c1d915SMatt Spinler return Section::flattenedSize() + sizeof(_eventSubsystem) + 16203c1d915SMatt Spinler sizeof(_eventScope) + sizeof(_eventSeverity) + 16303c1d915SMatt Spinler sizeof(_eventType) + sizeof(_reserved4Byte1) + 16403c1d915SMatt Spinler sizeof(_problemDomain) + sizeof(_problemVector) + 16503c1d915SMatt Spinler sizeof(_actionFlags) + sizeof(_reserved4Byte2); 16603c1d915SMatt Spinler } 16703c1d915SMatt Spinler 16803c1d915SMatt Spinler private: 16903c1d915SMatt Spinler /** 170cf5a8d0fSMatt Spinler * @brief Fills in the object from the stream data 171cf5a8d0fSMatt Spinler * 172cf5a8d0fSMatt Spinler * @param[in] stream - The stream to read from 173cf5a8d0fSMatt Spinler */ 174cf5a8d0fSMatt Spinler void unflatten(Stream& stream); 175cf5a8d0fSMatt Spinler 176cf5a8d0fSMatt Spinler /** 17703c1d915SMatt Spinler * @brief Validates the section contents 17803c1d915SMatt Spinler * 17903c1d915SMatt Spinler * Updates _valid (in Section) with the results. 18003c1d915SMatt Spinler */ 18103c1d915SMatt Spinler void validate() override; 18203c1d915SMatt Spinler 18303c1d915SMatt Spinler /** 18403c1d915SMatt Spinler * @brief The subsystem associated with the event. 18503c1d915SMatt Spinler */ 18603c1d915SMatt Spinler uint8_t _eventSubsystem; 18703c1d915SMatt Spinler 18803c1d915SMatt Spinler /** 18903c1d915SMatt Spinler * @brief The event scope field. 19003c1d915SMatt Spinler */ 19103c1d915SMatt Spinler uint8_t _eventScope; 19203c1d915SMatt Spinler 19303c1d915SMatt Spinler /** 19403c1d915SMatt Spinler * @brief The event severity. 19503c1d915SMatt Spinler */ 19603c1d915SMatt Spinler uint8_t _eventSeverity; 19703c1d915SMatt Spinler 19803c1d915SMatt Spinler /** 19903c1d915SMatt Spinler * @brief The event type. 20003c1d915SMatt Spinler */ 20103c1d915SMatt Spinler uint8_t _eventType; 20203c1d915SMatt Spinler 20303c1d915SMatt Spinler /** 20403c1d915SMatt Spinler * @brief A reserved word placeholder 20503c1d915SMatt Spinler */ 20603c1d915SMatt Spinler uint32_t _reserved4Byte1; 20703c1d915SMatt Spinler 20803c1d915SMatt Spinler /** 20903c1d915SMatt Spinler * @brief The problem domain field. 21003c1d915SMatt Spinler */ 21103c1d915SMatt Spinler uint8_t _problemDomain; 21203c1d915SMatt Spinler 21303c1d915SMatt Spinler /** 21403c1d915SMatt Spinler * @brief The problem vector field. 21503c1d915SMatt Spinler */ 21603c1d915SMatt Spinler uint8_t _problemVector; 21703c1d915SMatt Spinler 21803c1d915SMatt Spinler /** 21903c1d915SMatt Spinler * @brief The action flags field. 22003c1d915SMatt Spinler */ 22103c1d915SMatt Spinler uint16_t _actionFlags; 22203c1d915SMatt Spinler 22303c1d915SMatt Spinler /** 22403c1d915SMatt Spinler * @brief The second reserved word placeholder. 22503c1d915SMatt Spinler */ 22603c1d915SMatt Spinler uint32_t _reserved4Byte2; 22703c1d915SMatt Spinler }; 22803c1d915SMatt Spinler 22903c1d915SMatt Spinler } // namespace pels 23003c1d915SMatt Spinler } // namespace openpower 231