Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <sdbusplus/server.hpp> |
| 5 | #include "types.hpp" |
| 6 | |
| 7 | namespace ipmi |
| 8 | { |
| 9 | |
| 10 | namespace sel |
| 11 | { |
| 12 | |
| 13 | static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper"; |
| 14 | static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper"; |
| 15 | static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper"; |
| 16 | |
| 17 | static constexpr auto logBasePath = "/xyz/openbmc_project/logging/entry"; |
| 18 | static constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry"; |
| 19 | static constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete"; |
| 20 | |
| 21 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 22 | |
| 23 | using PropertyType = sdbusplus::message::variant<bool, uint32_t, uint64_t, |
| 24 | std::string, std::vector<std::string>>; |
| 25 | |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 26 | static constexpr auto selVersion = 0x51; |
| 27 | static constexpr auto invalidTimeStamp = 0xFFFFFFFF; |
| 28 | static constexpr auto operationSupport = 0x0A; |
| 29 | |
| 30 | /** @struct GetSELInfoResponse |
| 31 | * |
| 32 | * IPMI payload for Get SEL Info command response. |
| 33 | */ |
| 34 | struct GetSELInfoResponse |
| 35 | { |
| 36 | uint8_t selVersion; //!< SEL revision. |
| 37 | uint16_t entries; //!< Number of log entries in SEL. |
| 38 | uint16_t freeSpace; //!< Free Space in bytes. |
| 39 | uint32_t addTimeStamp; //!< Most recent addition timestamp. |
| 40 | uint32_t eraseTimeStamp; //!< Most recent erase timestamp. |
| 41 | uint8_t operationSupport; //!< Operation support. |
| 42 | } __attribute__((packed)); |
| 43 | |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 44 | static constexpr auto firstEntry = 0x0000; |
| 45 | static constexpr auto lastEntry = 0xFFFF; |
| 46 | static constexpr auto entireRecord = 0xFF; |
| 47 | static constexpr auto selRecordSize = 16; |
| 48 | |
| 49 | /** @struct GetSELEntryRequest |
| 50 | * |
| 51 | * IPMI payload for Get SEL Entry command request. |
| 52 | */ |
| 53 | struct GetSELEntryRequest |
| 54 | { |
| 55 | uint16_t reservationID; //!< Reservation ID. |
| 56 | uint16_t selRecordID; //!< SEL Record ID. |
| 57 | uint8_t offset; //!< Offset into record. |
| 58 | uint8_t readLength; //!< Bytes to read. |
| 59 | } __attribute__((packed)); |
| 60 | |
Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 61 | /** @struct GetSELEntryResponse |
| 62 | * |
| 63 | * IPMI payload for Get SEL Entry command response. |
| 64 | */ |
| 65 | struct GetSELEntryResponse |
| 66 | { |
| 67 | uint16_t nextRecordID; //!< Next RecordID. |
| 68 | uint16_t recordID; //!< Record ID. |
| 69 | uint8_t recordType; //!< Record Type. |
| 70 | uint32_t timeStamp; //!< Timestamp. |
| 71 | uint16_t generatorID; //!< Generator ID. |
| 72 | uint8_t eventMsgRevision; //!< Event Message Revision. |
| 73 | uint8_t sensorType; //!< Sensor Type. |
| 74 | uint8_t sensorNum; //!< Sensor Number. |
| 75 | uint8_t eventType; //!< Event Dir | Event Type. |
| 76 | uint8_t eventData1; //!< Event Data 1. |
| 77 | uint8_t eventData2; //!< Event Data 2. |
| 78 | uint8_t eventData3; //!< Event Data 3. |
| 79 | } __attribute__((packed)); |
| 80 | |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 81 | /** @struct DeleteSELEntryRequest |
| 82 | * |
| 83 | * IPMI payload for Delete SEL Entry command request. |
| 84 | */ |
| 85 | struct DeleteSELEntryRequest |
| 86 | { |
| 87 | uint16_t reservationID; //!< Reservation ID. |
| 88 | uint16_t selRecordID; //!< SEL Record ID. |
| 89 | } __attribute__((packed)); |
| 90 | |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame^] | 91 | static constexpr auto initiateErase = 0xAA; |
| 92 | static constexpr auto getEraseStatus = 0x00; |
| 93 | static constexpr auto eraseComplete = 0x01; |
| 94 | |
| 95 | /** @struct ClearSELRequest |
| 96 | * |
| 97 | * IPMI payload for Clear SEL command request. |
| 98 | */ |
| 99 | struct ClearSELRequest |
| 100 | { |
| 101 | uint16_t reservationID; //!< Reservation ID. |
| 102 | uint8_t charC; //!< Char 'C'(0x43h). |
| 103 | uint8_t charL; //!< Char 'L'(0x4Ch). |
| 104 | uint8_t charR; //!< Char 'R'(0x52h). |
| 105 | uint8_t eraseOperation; //!< Erase operation. |
| 106 | } __attribute__((packed)); |
| 107 | |
Tom Joseph | 6edc8a0 | 2017-06-30 18:52:56 +0530 | [diff] [blame] | 108 | /** @brief Convert logging entry to SEL |
| 109 | * |
| 110 | * @param[in] objPath - DBUS object path of the logging entry. |
| 111 | * |
| 112 | * @return On success return the response of Get SEL entry command. |
| 113 | */ |
| 114 | GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath); |
| 115 | |
Tom Joseph | 399fd92 | 2017-06-30 18:40:30 +0530 | [diff] [blame] | 116 | /** @brief Get the timestamp of the log entry |
| 117 | * |
| 118 | * @param[in] objPath - DBUS object path of the logging entry. |
| 119 | * |
| 120 | * @return On success return the timestamp of the log entry as number of |
| 121 | * seconds from epoch. |
| 122 | */ |
| 123 | std::chrono::seconds getEntryTimeStamp(const std::string& objPath); |
Tom Joseph | 6edc8a0 | 2017-06-30 18:52:56 +0530 | [diff] [blame] | 124 | |
Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 125 | namespace internal |
| 126 | { |
| 127 | |
| 128 | /** @brief Convert logging entry to SEL event record |
| 129 | * |
| 130 | * @param[in] objPath - DBUS object path of the logging entry. |
| 131 | * @param[in] iter - Iterator to the sensor data corresponding to the logging |
| 132 | * entry |
| 133 | * |
| 134 | * @return On success return the SEL event record, throw an exception in case |
| 135 | * of failure. |
| 136 | */ |
| 137 | GetSELEntryResponse prepareSELEntry( |
| 138 | const std::string& objPath, |
| 139 | ipmi::sensor::InvObjectIDMap::const_iterator iter); |
| 140 | |
Tom Joseph | 399fd92 | 2017-06-30 18:40:30 +0530 | [diff] [blame] | 141 | } |
Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 142 | |
| 143 | } // namespace sel |
| 144 | |
| 145 | } // namespace ipmi |