blob: fd6821f7a98b65b88cc1a17cc5318cc35710c6af [file] [log] [blame]
Deepak Kodihalli557dfb02019-05-12 13:11:17 +05301#pragma once
2
Sampa Misraa2fa0702019-05-31 01:28:55 -05003#include "config.h"
4
George Liu6492f522020-06-16 10:34:05 +08005#include "libpldm/platform.h"
6#include "libpldm/states.h"
George Liuc4ea6a92020-07-14 15:48:44 +08007#include "pdr.h"
George Liu6492f522020-06-16 10:34:05 +08008
Deepak Kodihallid130e1a2020-06-17 05:55:32 -05009#include "common/utils.hpp"
TOM JOSEPHd4d97a52020-03-23 14:36:34 +053010#include "event_parser.hpp"
Tom Joseph33e9c7e2020-06-11 22:09:52 +053011#include "fru.hpp"
George Liucae18662020-05-15 09:32:57 +080012#include "host-bmc/dbus_to_event_handler.hpp"
Deepak Kodihalliac19bd62020-06-16 08:25:23 -050013#include "host-bmc/host_pdr_handler.hpp"
Sampa Misraa2fa0702019-05-31 01:28:55 -050014#include "libpldmresponder/pdr.hpp"
George Liue53193f2020-02-24 09:23:26 +080015#include "libpldmresponder/pdr_utils.hpp"
Deepak Kodihalli1521f6d2020-06-16 08:51:02 -050016#include "pldmd/handler.hpp"
Sampa Misraa2fa0702019-05-31 01:28:55 -050017
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053018#include <stdint.h>
19
Sampa Misraa2fa0702019-05-31 01:28:55 -050020#include <map>
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053021
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053022namespace pldm
23{
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053024namespace responder
25{
Sampa Misraa2fa0702019-05-31 01:28:55 -050026namespace platform
27{
28
George Liu1ec85d42020-02-12 16:05:32 +080029using namespace pldm::utils;
30using namespace pldm::responder::pdr_utils;
George Liucae18662020-05-15 09:32:57 +080031using namespace pldm::state_sensor;
George Liu1ec85d42020-02-12 16:05:32 +080032
George Liua2870722020-02-11 11:09:30 +080033using generatePDR =
George Liu36e81352020-07-01 14:40:30 +080034 std::function<void(const pldm::utils::DBusHandler& dBusIntf,
35 const Json& json, pdr_utils::RepoInterface& repo)>;
George Liua2870722020-02-11 11:09:30 +080036
George Liu1ec85d42020-02-12 16:05:32 +080037using EffecterId = uint16_t;
George Liua2870722020-02-11 11:09:30 +080038using DbusObjMaps =
39 std::map<EffecterId,
40 std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>>;
Tom Joseph56e45c52020-03-16 10:01:45 +053041using DbusPath = std::string;
42using EffecterObjs = std::vector<DbusPath>;
43using EventType = uint8_t;
44using EventHandler = std::function<int(
45 const pldm_msg* request, size_t payloadLength, uint8_t formatVersion,
46 uint8_t tid, size_t eventDataOffset)>;
47using EventHandlers = std::vector<EventHandler>;
48using EventMap = std::map<EventType, EventHandlers>;
George Liuc4ea6a92020-07-14 15:48:44 +080049using AssociatedEntityMap = std::map<DbusPath, pldm_entity>;
Deepak Kodihallic682fe22020-03-04 00:42:54 -060050
Zahed Hossain75330f32020-03-24 02:15:03 -050051// EventEntry = <uint8_t> - EventState <uint8_t> - SensorOffset <uint16_t> -
52// SensorID
53using EventEntry = uint32_t;
54struct DBusInfo
55{
56 pldm::utils::DBusMapping dBusValues;
57 pldm::utils::PropertyValue dBusPropertyValue;
58};
59
Deepak Kodihallibc669f12019-11-28 08:52:07 -060060class Handler : public CmdHandler
Sampa Misraa2fa0702019-05-31 01:28:55 -050061{
Deepak Kodihallibc669f12019-11-28 08:52:07 -060062 public:
Deepak Kodihallib5c227e2020-07-13 06:58:34 -050063 Handler(const pldm::utils::DBusHandler* dBusIntf,
George Liu36e81352020-07-01 14:40:30 +080064 const std::string& pdrJsonsDir, const std::string& eventsJsonsDir,
TOM JOSEPHd4d97a52020-03-23 14:36:34 +053065 pldm_pdr* repo, HostPDRHandler* hostPDRHandler,
George Liucae18662020-05-15 09:32:57 +080066 DbusToPLDMEvent* dbusToPLDMEventHandler, fru::Handler* fruHandler,
67 bool buildPDRLazily = false,
Tom Joseph56e45c52020-03-16 10:01:45 +053068 const std::optional<EventMap>& addOnHandlersMap = std::nullopt) :
Pavithra Barithaya51efaf82020-04-02 02:42:27 -050069 pdrRepo(repo),
Tom Joseph33e9c7e2020-06-11 22:09:52 +053070 hostPDRHandler(hostPDRHandler), stateSensorHandler(eventsJsonsDir),
George Liucae18662020-05-15 09:32:57 +080071 dbusToPLDMEventHandler(dbusToPLDMEventHandler), fruHandler(fruHandler),
72 dBusIntf(dBusIntf), pdrJsonsDir(pdrJsonsDir), pdrCreated(false)
Sampa Misraa2fa0702019-05-31 01:28:55 -050073 {
Deepak Kodihallib5c227e2020-07-13 06:58:34 -050074 if (!buildPDRLazily)
75 {
Sampa Misra12afe112020-05-25 11:40:44 -050076 generateTerminusLocatorPDR(pdrRepo);
Deepak Kodihallib5c227e2020-07-13 06:58:34 -050077 generate(*dBusIntf, pdrJsonsDir, pdrRepo);
78 pdrCreated = true;
79 }
Deepak Kodihallic682fe22020-03-04 00:42:54 -060080
Deepak Kodihallibc669f12019-11-28 08:52:07 -060081 handlers.emplace(PLDM_GET_PDR,
82 [this](const pldm_msg* request, size_t payloadLength) {
83 return this->getPDR(request, payloadLength);
84 });
George Liueccb0c52020-01-14 11:09:56 +080085 handlers.emplace(PLDM_SET_NUMERIC_EFFECTER_VALUE,
86 [this](const pldm_msg* request, size_t payloadLength) {
87 return this->setNumericEffecterValue(
88 request, payloadLength);
89 });
Deepak Kodihallibc669f12019-11-28 08:52:07 -060090 handlers.emplace(PLDM_SET_STATE_EFFECTER_STATES,
91 [this](const pldm_msg* request, size_t payloadLength) {
92 return this->setStateEffecterStates(request,
93 payloadLength);
94 });
Tom Joseph56e45c52020-03-16 10:01:45 +053095 handlers.emplace(PLDM_PLATFORM_EVENT_MESSAGE,
96 [this](const pldm_msg* request, size_t payloadLength) {
97 return this->platformEventMessage(request,
98 payloadLength);
99 });
George Liu362c18d2020-05-14 09:46:36 +0800100 handlers.emplace(PLDM_GET_STATE_SENSOR_READINGS,
101 [this](const pldm_msg* request, size_t payloadLength) {
102 return this->getStateSensorReadings(request,
103 payloadLength);
104 });
Tom Joseph56e45c52020-03-16 10:01:45 +0530105
106 // Default handler for PLDM Events
107 eventHandlers[PLDM_SENSOR_EVENT].emplace_back(
108 [this](const pldm_msg* request, size_t payloadLength,
109 uint8_t formatVersion, uint8_t tid, size_t eventDataOffset) {
110 return this->sensorEvent(request, payloadLength, formatVersion,
111 tid, eventDataOffset);
112 });
Deepak Kodihalli8cb6f662020-04-10 02:55:43 -0500113 eventHandlers[PLDM_PDR_REPOSITORY_CHG_EVENT].emplace_back(
114 [this](const pldm_msg* request, size_t payloadLength,
115 uint8_t formatVersion, uint8_t tid, size_t eventDataOffset) {
116 return this->pldmPDRRepositoryChgEvent(request, payloadLength,
117 formatVersion, tid,
118 eventDataOffset);
119 });
Tom Joseph56e45c52020-03-16 10:01:45 +0530120
121 // Additional OEM event handlers for PLDM events, append it to the
122 // standard handlers
123 if (addOnHandlersMap)
124 {
125 auto addOnHandlers = addOnHandlersMap.value();
126 for (EventMap::iterator iter = addOnHandlers.begin();
127 iter != addOnHandlers.end(); ++iter)
128 {
129 auto search = eventHandlers.find(iter->first);
130 if (search != eventHandlers.end())
131 {
132 search->second.insert(std::end(search->second),
133 std::begin(iter->second),
134 std::end(iter->second));
135 }
136 else
137 {
138 eventHandlers.emplace(iter->first, iter->second);
139 }
140 }
141 }
Sampa Misraa2fa0702019-05-31 01:28:55 -0500142 }
143
George Liu1ec85d42020-02-12 16:05:32 +0800144 pdr_utils::Repo& getRepo()
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600145 {
George Liu1ec85d42020-02-12 16:05:32 +0800146 return this->pdrRepo;
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600147 }
148
George Liu1ec85d42020-02-12 16:05:32 +0800149 /** @brief Add D-Bus mapping and value mapping(stateId to D-Bus) for the
George Liuadbe1722020-05-09 19:20:19 +0800150 * Id. If the same id is added, the previous dbusObjs will
George Liu1ec85d42020-02-12 16:05:32 +0800151 * be "over-written".
152 *
George Liuadbe1722020-05-09 19:20:19 +0800153 * @param[in] Id - effecter/sensor id
George Liu1ec85d42020-02-12 16:05:32 +0800154 * @param[in] dbusObj - list of D-Bus object structure and list of D-Bus
155 * property value to attribute value
George Liuadbe1722020-05-09 19:20:19 +0800156 * @param[in] typeId - the type id of enum
George Liu1ec85d42020-02-12 16:05:32 +0800157 */
George Liua2870722020-02-11 11:09:30 +0800158 void addDbusObjMaps(
George Liuadbe1722020-05-09 19:20:19 +0800159 uint16_t id,
160 std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj,
161 TypeId typeId = TypeId::PLDM_EFFECTER_ID);
George Liu1ec85d42020-02-12 16:05:32 +0800162
George Liuadbe1722020-05-09 19:20:19 +0800163 /** @brief Retrieve an id -> D-Bus objects mapping
George Liu1ec85d42020-02-12 16:05:32 +0800164 *
George Liuadbe1722020-05-09 19:20:19 +0800165 * @param[in] Id - id
166 * @param[in] typeId - the type id of enum
George Liu1ec85d42020-02-12 16:05:32 +0800167 *
George Liua2870722020-02-11 11:09:30 +0800168 * @return std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> -
169 * list of D-Bus object structure and list of D-Bus property value
170 * to attribute value
George Liu1ec85d42020-02-12 16:05:32 +0800171 */
George Liua2870722020-02-11 11:09:30 +0800172 const std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>&
George Liuadbe1722020-05-09 19:20:19 +0800173 getDbusObjMaps(uint16_t id,
174 TypeId typeId = TypeId::PLDM_EFFECTER_ID) const;
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600175
176 uint16_t getNextEffecterId()
177 {
178 return ++nextEffecterId;
179 }
180
George Liuadbe1722020-05-09 19:20:19 +0800181 uint16_t getNextSensorId()
182 {
183 return ++nextSensorId;
184 }
185
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600186 /** @brief Parse PDR JSONs and build PDR repository
187 *
George Liu36e81352020-07-01 14:40:30 +0800188 * @param[in] dBusIntf - The interface object
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600189 * @param[in] dir - directory housing platform specific PDR JSON files
190 * @param[in] repo - instance of concrete implementation of Repo
191 */
George Liu36e81352020-07-01 14:40:30 +0800192 void generate(const pldm::utils::DBusHandler& dBusIntf,
193 const std::string& dir, Repo& repo);
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600194
195 /** @brief Parse PDR JSONs and build state effecter PDR repository
196 *
197 * @param[in] json - platform specific PDR JSON files
198 * @param[in] repo - instance of state effecter implementation of Repo
199 */
200 void generateStateEffecterRepo(const Json& json, Repo& repo);
201
Tom Joseph56e45c52020-03-16 10:01:45 +0530202 /** @brief map of PLDM event type to EventHandlers
203 *
204 */
205 EventMap eventHandlers;
206
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600207 /** @brief Handler for GetPDR
208 *
209 * @param[in] request - Request message payload
210 * @param[in] payloadLength - Request payload length
211 * @param[out] Response - Response message written here
212 */
213 Response getPDR(const pldm_msg* request, size_t payloadLength);
Sampa Misraa2fa0702019-05-31 01:28:55 -0500214
George Liueccb0c52020-01-14 11:09:56 +0800215 /** @brief Handler for setNumericEffecterValue
216 *
217 * @param[in] request - Request message
218 * @param[in] payloadLength - Request payload length
219 * @return Response - PLDM Response message
220 */
221 Response setNumericEffecterValue(const pldm_msg* request,
222 size_t payloadLength);
223
George Liu362c18d2020-05-14 09:46:36 +0800224 /** @brief Handler for getStateSensorReadings
225 *
226 * @param[in] request - Request message
227 * @param[in] payloadLength - Request payload length
228 * @return Response - PLDM Response message
229 */
230 Response getStateSensorReadings(const pldm_msg* request,
231 size_t payloadLength);
232
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600233 /** @brief Handler for setStateEffecterStates
234 *
235 * @param[in] request - Request message
236 * @param[in] payloadLength - Request payload length
237 * @return Response - PLDM Response message
238 */
239 Response setStateEffecterStates(const pldm_msg* request,
240 size_t payloadLength);
241
Tom Joseph56e45c52020-03-16 10:01:45 +0530242 /** @brief Handler for PlatformEventMessage
243 *
244 * @param[in] request - Request message
245 * @param[in] payloadLength - Request payload length
246 * @return Response - PLDM Response message
247 */
248 Response platformEventMessage(const pldm_msg* request,
249 size_t payloadLength);
250
251 /** @brief Handler for event class Sensor event
252 *
253 * @param[in] request - Request message
254 * @param[in] payloadLength - Request payload length
255 * @param[in] formatVersion - Version of the event format
256 * @param[in] tid - Terminus ID of the event's originator
257 * @param[in] eventDataOffset - Offset of the event data in the request
258 * message
259 * @return PLDM completion code
260 */
261 int sensorEvent(const pldm_msg* request, size_t payloadLength,
262 uint8_t formatVersion, uint8_t tid, size_t eventDataOffset);
263
Deepak Kodihalli8cb6f662020-04-10 02:55:43 -0500264 /** @brief Handler for pldmPDRRepositoryChgEvent
265 *
266 * @param[in] request - Request message
267 * @param[in] payloadLength - Request payload length
268 * @param[in] formatVersion - Version of the event format
269 * @param[in] tid - Terminus ID of the event's originator
270 * @param[in] eventDataOffset - Offset of the event data in the request
271 * message
272 * @return PLDM completion code
273 */
274 int pldmPDRRepositoryChgEvent(const pldm_msg* request, size_t payloadLength,
275 uint8_t formatVersion, uint8_t tid,
276 size_t eventDataOffset);
277
278 /** @brief Handler for extracting the PDR handles from changeEntries
279 *
280 * @param[in] changeEntryData - ChangeEntry data from changeRecord
281 * @param[in] changeEntryDataSize - total size of changeEntryData
282 * @param[in] numberOfChangeEntries - total number of changeEntries to
283 * extract
284 * @param[out] pdrRecordHandles - std::vector where the extracted PDR
285 * handles are placed
286 * @return PLDM completion code
287 */
288 int getPDRRecordHandles(const ChangeEntry* changeEntryData,
289 size_t changeEntryDataSize,
290 size_t numberOfChangeEntries,
291 PDRRecordHandles& pdrRecordHandles);
292
Zahed Hossain75330f32020-03-24 02:15:03 -0500293 /** @brief Handler for setting Sensor event data
294 *
295 * @param[in] sensorId - sensorID value of the sensor
296 * @param[in] sensorOffset - Identifies which state sensor within a
297 * composite state sensor the event is being returned for
298 * @param[in] eventState - The event state value from the state change that
299 * triggered the event message
300 * @return PLDM completion code
301 */
302 int setSensorEventData(uint16_t sensorId, uint8_t sensorOffset,
303 uint8_t eventState);
304
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600305 /** @brief Function to set the effecter requested by pldm requester
306 * @param[in] dBusIntf - The interface object
307 * @param[in] effecterId - Effecter ID sent by the requester to act on
308 * @param[in] stateField - The state field data for each of the states,
309 * equal to composite effecter count in number
310 * @return - Success or failure in setting the states. Returns failure in
311 * terms of PLDM completion codes if atleast one state fails to be set
312 */
313 template <class DBusInterface>
314 int setStateEffecterStatesHandler(
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600315 const DBusInterface& dBusIntf, uint16_t effecterId,
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600316 const std::vector<set_effecter_state_field>& stateField)
Sampa Misraa2fa0702019-05-31 01:28:55 -0500317 {
George Liue53193f2020-02-24 09:23:26 +0800318 using namespace pldm::responder::pdr;
George Liu1e44c732020-02-28 20:20:06 +0800319 using namespace pldm::utils;
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600320 using StateSetNum = uint8_t;
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600321
322 state_effecter_possible_states* states = nullptr;
323 pldm_state_effecter_pdr* pdr = nullptr;
324 uint8_t compEffecterCnt = stateField.size();
George Liu1ec85d42020-02-12 16:05:32 +0800325
326 std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)>
327 stateEffecterPdrRepo(pldm_pdr_init(), pldm_pdr_destroy);
328 Repo stateEffecterPDRs(stateEffecterPdrRepo.get());
329 getRepoByType(pdrRepo, stateEffecterPDRs, PLDM_STATE_EFFECTER_PDR);
330 if (stateEffecterPDRs.empty())
331 {
332 std::cerr << "Failed to get record by PDR type\n";
333 return PLDM_PLATFORM_INVALID_EFFECTER_ID;
334 }
335
George Liue53193f2020-02-24 09:23:26 +0800336 PdrEntry pdrEntry{};
George Liu1ec85d42020-02-12 16:05:32 +0800337 auto pdrRecord = stateEffecterPDRs.getFirstRecord(pdrEntry);
George Liue53193f2020-02-24 09:23:26 +0800338 while (pdrRecord)
339 {
340 pdr = reinterpret_cast<pldm_state_effecter_pdr*>(pdrEntry.data);
341 if (pdr->effecter_id != effecterId)
Sampa Misraa2fa0702019-05-31 01:28:55 -0500342 {
George Liue53193f2020-02-24 09:23:26 +0800343 pdr = nullptr;
George Liu1ec85d42020-02-12 16:05:32 +0800344 pdrRecord =
345 stateEffecterPDRs.getNextRecord(pdrRecord, pdrEntry);
George Liue53193f2020-02-24 09:23:26 +0800346 continue;
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600347 }
George Liue53193f2020-02-24 09:23:26 +0800348
349 states = reinterpret_cast<state_effecter_possible_states*>(
350 pdr->possible_states);
351 if (compEffecterCnt > pdr->composite_effecter_count)
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600352 {
George Liue53193f2020-02-24 09:23:26 +0800353 std::cerr << "The requester sent wrong composite effecter"
354 << " count for the effecter, EFFECTER_ID="
355 << effecterId << "COMP_EFF_CNT=" << compEffecterCnt
356 << "\n";
357 return PLDM_ERROR_INVALID_DATA;
Sampa Misraa2fa0702019-05-31 01:28:55 -0500358 }
George Liue53193f2020-02-24 09:23:26 +0800359 break;
360 }
361
362 if (!pdr)
363 {
364 return PLDM_PLATFORM_INVALID_EFFECTER_ID;
Sampa Misraa2fa0702019-05-31 01:28:55 -0500365 }
Sampa Misraa2fa0702019-05-31 01:28:55 -0500366
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600367 int rc = PLDM_SUCCESS;
George Liu1ec85d42020-02-12 16:05:32 +0800368 try
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600369 {
George Liu1ec85d42020-02-12 16:05:32 +0800370 const auto& [dbusMappings, dbusValMaps] =
George Liuadbe1722020-05-09 19:20:19 +0800371 effecterDbusObjMaps.at(effecterId);
George Liu1ec85d42020-02-12 16:05:32 +0800372 for (uint8_t currState = 0; currState < compEffecterCnt;
373 ++currState)
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600374 {
George Liu1ec85d42020-02-12 16:05:32 +0800375 std::vector<StateSetNum> allowed{};
376 // computation is based on table 79 from DSP0248 v1.1.1
377 uint8_t bitfieldIndex =
378 stateField[currState].effecter_state / 8;
379 uint8_t bit =
380 stateField[currState].effecter_state - (8 * bitfieldIndex);
381 if (states->possible_states_size < bitfieldIndex ||
382 !(states->states[bitfieldIndex].byte & (1 << bit)))
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600383 {
George Liu1ec85d42020-02-12 16:05:32 +0800384 std::cerr
385 << "Invalid state set value, EFFECTER_ID=" << effecterId
386 << " VALUE=" << stateField[currState].effecter_state
387 << " COMPOSITE_EFFECTER_ID=" << currState
388 << " DBUS_PATH=" << dbusMappings[currState].objectPath
389 << "\n";
390 rc = PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE;
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600391 break;
392 }
George Liu1ec85d42020-02-12 16:05:32 +0800393 const DBusMapping& dbusMapping = dbusMappings[currState];
394 const StatestoDbusVal& dbusValToMap = dbusValMaps[currState];
395
396 if (stateField[currState].set_request == PLDM_REQUEST_SET)
397 {
398 try
399 {
400 dBusIntf.setDbusProperty(
401 dbusMapping,
402 dbusValToMap.at(
403 stateField[currState].effecter_state));
404 }
405 catch (const std::exception& e)
406 {
407 std::cerr
408 << "Error setting property, ERROR=" << e.what()
409 << " PROPERTY=" << dbusMapping.propertyName
410 << " INTERFACE="
411 << dbusMapping.interface << " PATH="
412 << dbusMapping.objectPath << "\n";
413 return PLDM_ERROR;
414 }
415 }
416 uint8_t* nextState =
417 reinterpret_cast<uint8_t*>(states) +
418 sizeof(state_effecter_possible_states) -
419 sizeof(states->states) +
420 (states->possible_states_size * sizeof(states->states));
421 states = reinterpret_cast<state_effecter_possible_states*>(
422 nextState);
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600423 }
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600424 }
George Liu1ec85d42020-02-12 16:05:32 +0800425 catch (const std::out_of_range& e)
426 {
427 std::cerr << "the effecterId does not exist. effecter id: "
428 << effecterId << e.what() << '\n';
429 }
430
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600431 return rc;
432 }
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600433
Sampa Misra12afe112020-05-25 11:40:44 -0500434 /** @brief Build BMC Terminus Locator PDR
435 *
436 * @param[in] repo - instance of concrete implementation of Repo
437 */
438 void generateTerminusLocatorPDR(Repo& repo);
439
George Liuc4ea6a92020-07-14 15:48:44 +0800440 /** @brief Get std::map associated with the entity
441 * key: object path
442 * value: pldm_entity
443 *
444 * @return std::map<ObjectPath, pldm_entity>
445 */
446 inline const AssociatedEntityMap& getAssociateEntityMap() const
447 {
448 if (fruHandler == nullptr)
449 {
450 throw InternalFailure();
451 }
452 return fruHandler->getAssociateEntityMap();
453 }
454
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600455 private:
456 pdr_utils::Repo pdrRepo;
457 uint16_t nextEffecterId{};
George Liuadbe1722020-05-09 19:20:19 +0800458 uint16_t nextSensorId{};
459 DbusObjMaps effecterDbusObjMaps{};
460 DbusObjMaps sensorDbusObjMaps{};
Pavithra Barithaya51efaf82020-04-02 02:42:27 -0500461 HostPDRHandler* hostPDRHandler;
TOM JOSEPHd4d97a52020-03-23 14:36:34 +0530462 events::StateSensorHandler stateSensorHandler;
George Liucae18662020-05-15 09:32:57 +0800463 DbusToPLDMEvent* dbusToPLDMEventHandler;
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530464 fru::Handler* fruHandler;
Deepak Kodihallib5c227e2020-07-13 06:58:34 -0500465 const pldm::utils::DBusHandler* dBusIntf;
466 std::string pdrJsonsDir;
467 bool pdrCreated;
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600468};
469
470} // namespace platform
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530471} // namespace responder
472} // namespace pldm