blob: 9c253bdcd8dfb3bd9f87d14d9582f62ab8ffaf6f [file] [log] [blame]
Tom Joseph6b7a1432017-05-19 10:43:36 +05301#pragma once
2
3#include <cstdint>
4#include <sdbusplus/server.hpp>
5#include "types.hpp"
6
7namespace ipmi
8{
9
10namespace sel
11{
12
13static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
14static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper";
15static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
16
17static constexpr auto logBasePath = "/xyz/openbmc_project/logging/entry";
18static constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry";
19static constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete";
20
21static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
22
23using PropertyType = sdbusplus::message::variant<bool, uint32_t, uint64_t,
24 std::string, std::vector<std::string>>;
25
Tom Joseph6f7deaa2017-06-30 19:03:54 +053026static constexpr auto selVersion = 0x51;
27static constexpr auto invalidTimeStamp = 0xFFFFFFFF;
28static constexpr auto operationSupport = 0x0A;
29
30/** @struct GetSELInfoResponse
31 *
32 * IPMI payload for Get SEL Info command response.
33 */
34struct 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 Joseph6b7a1432017-05-19 10:43:36 +053044/** @struct GetSELEntryResponse
45 *
46 * IPMI payload for Get SEL Entry command response.
47 */
48struct GetSELEntryResponse
49{
50 uint16_t nextRecordID; //!< Next RecordID.
51 uint16_t recordID; //!< Record ID.
52 uint8_t recordType; //!< Record Type.
53 uint32_t timeStamp; //!< Timestamp.
54 uint16_t generatorID; //!< Generator ID.
55 uint8_t eventMsgRevision; //!< Event Message Revision.
56 uint8_t sensorType; //!< Sensor Type.
57 uint8_t sensorNum; //!< Sensor Number.
58 uint8_t eventType; //!< Event Dir | Event Type.
59 uint8_t eventData1; //!< Event Data 1.
60 uint8_t eventData2; //!< Event Data 2.
61 uint8_t eventData3; //!< Event Data 3.
62} __attribute__((packed));
63
Tom Joseph6edc8a02017-06-30 18:52:56 +053064/** @brief Convert logging entry to SEL
65 *
66 * @param[in] objPath - DBUS object path of the logging entry.
67 *
68 * @return On success return the response of Get SEL entry command.
69 */
70GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath);
71
Tom Joseph399fd922017-06-30 18:40:30 +053072/** @brief Get the timestamp of the log entry
73 *
74 * @param[in] objPath - DBUS object path of the logging entry.
75 *
76 * @return On success return the timestamp of the log entry as number of
77 * seconds from epoch.
78 */
79std::chrono::seconds getEntryTimeStamp(const std::string& objPath);
Tom Joseph6edc8a02017-06-30 18:52:56 +053080
Tom Joseph6b7a1432017-05-19 10:43:36 +053081namespace internal
82{
83
84/** @brief Convert logging entry to SEL event record
85 *
86 * @param[in] objPath - DBUS object path of the logging entry.
87 * @param[in] iter - Iterator to the sensor data corresponding to the logging
88 * entry
89 *
90 * @return On success return the SEL event record, throw an exception in case
91 * of failure.
92 */
93GetSELEntryResponse prepareSELEntry(
94 const std::string& objPath,
95 ipmi::sensor::InvObjectIDMap::const_iterator iter);
96
Tom Joseph399fd922017-06-30 18:40:30 +053097}
Tom Joseph6b7a1432017-05-19 10:43:36 +053098
99} // namespace sel
100
101} // namespace ipmi