blob: 13b3134d466fefcbf7f3ea4c34982a141ceb5ee0 [file] [log] [blame]
Sampa Misraaea5dde2020-08-31 08:33:47 -05001#pragma once
Varsha Kaverappabb585b22020-09-10 06:15:42 -05002
Manojkiran Edaa31ceb92021-07-22 09:19:02 +05303#include "collect_slot_vpd.hpp"
4#include "common/utils.hpp"
Rahul D S161e45d2025-11-06 17:34:43 +05305#include "file_table.hpp"
Sampa Misraaea5dde2020-08-31 08:33:47 -05006#include "inband_code_update.hpp"
Archana Kakani97a0f482025-03-10 05:39:38 -05007#include "libpldmresponder/bios_config.hpp"
Sampa Misraaea5dde2020-08-31 08:33:47 -05008#include "libpldmresponder/oem_handler.hpp"
Varsha Kaverappabb585b22020-09-10 06:15:42 -05009#include "libpldmresponder/pdr_utils.hpp"
Sampa Misraaea5dde2020-08-31 08:33:47 -050010#include "libpldmresponder/platform.hpp"
Sampa Misrac0c79482021-06-02 08:01:54 -050011#include "requester/handler.hpp"
Sampa Misraaea5dde2020-08-31 08:33:47 -050012
George Liuc453e162022-12-21 17:16:23 +080013#include <libpldm/entity.h>
Andrew Jeffery21f128d2024-01-15 15:34:26 +103014#include <libpldm/oem/ibm/state_set.h>
George Liuc453e162022-12-21 17:16:23 +080015#include <libpldm/platform.h>
Jayashankar Padathfdf6da72025-04-14 10:54:58 -050016#include <libpldm/state_set.h>
George Liuc453e162022-12-21 17:16:23 +080017
Sagar Srinivas18145f72022-04-11 07:38:26 -050018#include <sdbusplus/bus/match.hpp>
19#include <sdeventplus/event.hpp>
20#include <sdeventplus/utility/timer.hpp>
Alexander Hansen24c04d52025-11-11 14:46:21 +010021#include <xyz/openbmc_project/State/Host/client.hpp>
Sagar Srinivas18145f72022-04-11 07:38:26 -050022
Christian Geddes7f9523c2021-08-03 13:44:38 -050023typedef ibm_oem_pldm_state_set_firmware_update_state_values CodeUpdateState;
24
Alexander Hansen24c04d52025-11-11 14:46:21 +010025using HostState = sdbusplus::common::xyz::openbmc_project::state::Host;
26
Sampa Misraaea5dde2020-08-31 08:33:47 -050027namespace pldm
28{
Sampa Misraaea5dde2020-08-31 08:33:47 -050029namespace responder
30{
Manojkiran Edaa31ceb92021-07-22 09:19:02 +053031using ObjectPath = std::string;
32using AssociatedEntityMap = std::map<ObjectPath, pldm_entity>;
Archana Kakani97a0f482025-03-10 05:39:38 -050033using namespace pldm::bios;
34using namespace pldm::utils;
35
Sampa Misraaea5dde2020-08-31 08:33:47 -050036namespace oem_ibm_platform
37{
Sagar Srinivas78a225a2020-08-27 00:52:20 -050038constexpr uint16_t ENTITY_INSTANCE_0 = 0;
39constexpr uint16_t ENTITY_INSTANCE_1 = 1;
40
Sagar Srinivas3687e2b2023-04-10 05:08:28 -050041constexpr uint32_t BMC_PDR_START_RANGE = 0x00000000;
42constexpr uint32_t BMC_PDR_END_RANGE = 0x00FFFFFF;
43constexpr uint32_t HOST_PDR_START_RANGE = 0x01000000;
44constexpr uint32_t HOST_PDR_END_RANGE = 0x01FFFFFF;
45
Sagar Srinivas18145f72022-04-11 07:38:26 -050046const pldm::pdr::TerminusID HYPERVISOR_TID = 208;
47
48static constexpr uint8_t HEARTBEAT_TIMEOUT_DELTA = 10;
49
Sagar Srinivas7f760b32021-05-12 07:46:56 -050050enum SetEventReceiverCount
51{
52 SET_EVENT_RECEIVER_SENT = 0x2,
53};
54
Sampa Misraaea5dde2020-08-31 08:33:47 -050055class Handler : public oem_platform::Handler
56{
57 public:
58 Handler(const pldm::utils::DBusHandler* dBusIntf,
Manojkiran Edaa31ceb92021-07-22 09:19:02 +053059 pldm::responder::CodeUpdate* codeUpdate,
60 pldm::responder::SlotHandler* slotHandler, int mctp_fd,
Andrew Jefferya330b2f2023-05-04 14:55:37 +093061 uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
Brad Bishop5079ac42021-08-19 18:35:06 -040062 sdeventplus::Event& event,
Sampa Misrac0c79482021-06-02 08:01:54 -050063 pldm::requester::Handler<pldm::requester::Request>* handler) :
Patrick Williams16c2a0a2024-08-16 15:20:59 -040064 oem_platform::Handler(dBusIntf), codeUpdate(codeUpdate),
Manojkiran Edaa31ceb92021-07-22 09:19:02 +053065 slotHandler(slotHandler), platformHandler(nullptr), mctp_fd(mctp_fd),
66 mctp_eid(mctp_eid), instanceIdDb(instanceIdDb), event(event),
67 handler(handler),
Sagar Srinivas18145f72022-04-11 07:38:26 -050068 timer(event, std::bind(std::mem_fn(&Handler::setSurvTimer), this,
69 HYPERVISOR_TID, false)),
70 hostTransitioningToOff(true)
Sampa Misraaea5dde2020-08-31 08:33:47 -050071 {
72 codeUpdate->setVersions();
Sagar Srinivas7f760b32021-05-12 07:46:56 -050073 setEventReceiverCnt = 0;
74
75 using namespace sdbusplus::bus::match::rules;
Patrick Williams84b790c2022-07-22 19:26:56 -050076 hostOffMatch = std::make_unique<sdbusplus::bus::match_t>(
Sagar Srinivas7f760b32021-05-12 07:46:56 -050077 pldm::utils::DBusHandler::getBus(),
78 propertiesChanged("/xyz/openbmc_project/state/host0",
Alexander Hansen24c04d52025-11-11 14:46:21 +010079 HostState::interface),
Patrick Williams84b790c2022-07-22 19:26:56 -050080 [this](sdbusplus::message_t& msg) {
Patrick Williams16c2a0a2024-08-16 15:20:59 -040081 pldm::utils::DbusChangedProps props{};
82 std::string intf;
83 msg.read(intf, props);
Alexander Hansen24c04d52025-11-11 14:46:21 +010084 const auto itr =
85 props.find(HostState::property_names::current_host_state);
Patrick Williams16c2a0a2024-08-16 15:20:59 -040086 if (itr != props.end())
Sagar Srinivas7f760b32021-05-12 07:46:56 -050087 {
Patrick Williams16c2a0a2024-08-16 15:20:59 -040088 pldm::utils::PropertyValue value = itr->second;
89 auto propVal = std::get<std::string>(value);
90 if (propVal ==
91 "xyz.openbmc_project.State.Host.HostState.Off")
92 {
93 hostOff = true;
94 setEventReceiverCnt = 0;
95 disableWatchDogTimer();
96 startStopTimer(false);
Rahul D S161e45d2025-11-06 17:34:43 +053097 pldm::filetable::clearFileTable();
Patrick Williams16c2a0a2024-08-16 15:20:59 -040098 }
99 else if (propVal ==
100 "xyz.openbmc_project.State.Host.HostState.Running")
101 {
102 hostOff = false;
103 hostTransitioningToOff = false;
104 }
105 else if (
106 propVal ==
107 "xyz.openbmc_project.State.Host.HostState.TransitioningToOff")
108 {
109 hostTransitioningToOff = true;
110 }
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500111 }
Patrick Williams16c2a0a2024-08-16 15:20:59 -0400112 });
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500113
Patrick Williams4f152f92024-06-18 02:38:34 -0500114 powerStateOffMatch = std::make_unique<sdbusplus::bus::match_t>(
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500115 pldm::utils::DBusHandler::getBus(),
116 propertiesChanged("/xyz/openbmc_project/state/chassis0",
117 "xyz.openbmc_project.State.Chassis"),
Archana Kakani50554252025-03-17 01:37:29 -0500118 [this](sdbusplus::message_t& msg) {
Patrick Williams16c2a0a2024-08-16 15:20:59 -0400119 pldm::utils::DbusChangedProps props{};
120 std::string intf;
121 msg.read(intf, props);
122 const auto itr = props.find("CurrentPowerState");
123 if (itr != props.end())
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500124 {
Patrick Williams16c2a0a2024-08-16 15:20:59 -0400125 pldm::utils::PropertyValue value = itr->second;
126 auto propVal = std::get<std::string>(value);
127 if (propVal ==
128 "xyz.openbmc_project.State.Chassis.PowerState.Off")
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500129 {
Archana Kakani50554252025-03-17 01:37:29 -0500130 handleBootTypesAtChassisOff();
Patrick Williams16c2a0a2024-08-16 15:20:59 -0400131 static constexpr auto searchpath =
132 "/xyz/openbmc_project/inventory/system/chassis/motherboard";
133 int depth = 0;
134 std::vector<std::string> powerInterface = {
135 "xyz.openbmc_project.State.Decorator.PowerState"};
136 pldm::utils::GetSubTreeResponse response =
137 pldm::utils::DBusHandler().getSubtree(
138 searchpath, depth, powerInterface);
139 for (const auto& [objPath, serviceMap] : response)
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500140 {
Patrick Williams16c2a0a2024-08-16 15:20:59 -0400141 pldm::utils::DBusMapping dbusMapping{
142 objPath,
143 "xyz.openbmc_project.State.Decorator.PowerState",
144 "PowerState", "string"};
145 value =
146 "xyz.openbmc_project.State.Decorator.PowerState.State.Off";
147 try
148 {
149 pldm::utils::DBusHandler().setDbusProperty(
150 dbusMapping, value);
151 }
152 catch (const std::exception& e)
153 {
154 error(
155 "Unable to set the slot power state to Off error - {ERROR}",
156 "ERROR", e);
157 }
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500158 }
159 }
160 }
Patrick Williams16c2a0a2024-08-16 15:20:59 -0400161 });
Jayashankar Padathfdf6da72025-04-14 10:54:58 -0500162
Archana Kakanie26d13f2025-03-09 23:17:46 -0500163 updateBIOSMatch = std::make_unique<sdbusplus::bus::match_t>(
164 pldm::utils::DBusHandler::getBus(),
165 propertiesChanged("/xyz/openbmc_project/bios_config/manager",
166 "xyz.openbmc_project.BIOSConfig.Manager"),
167 [codeUpdate](sdbusplus::message_t& msg) {
168 constexpr auto propertyName = "PendingAttributes";
169 using Value =
170 std::variant<std::string, PendingAttributes, BaseBIOSTable>;
171 using Properties = std::map<pldm::utils::DbusProp, Value>;
172 Properties props{};
173 std::string intf;
174 msg.read(intf, props);
175 auto valPropMap = props.find(propertyName);
176 if (valPropMap == props.end())
177 {
178 return;
179 }
180
181 PendingAttributes pendingAttributes =
182 std::get<PendingAttributes>(valPropMap->second);
183 for (auto it : pendingAttributes)
184 {
185 if (it.first == "fw_boot_side")
186 {
187 auto& [attributeType, attributevalue] = it.second;
188 std::string nextBootSideAttr =
189 std::get<std::string>(attributevalue);
190 std::string nextBootSide =
191 (nextBootSideAttr == "Perm" ? Pside : Tside);
192 codeUpdate->setNextBootSide(nextBootSide);
193 }
194 }
195 });
Jayashankar Padathfdf6da72025-04-14 10:54:58 -0500196
197 platformSAIMatch = std::make_unique<sdbusplus::bus::match_t>(
198 pldm::utils::DBusHandler::getBus(),
199 propertiesChanged(
200 "/xyz/openbmc_project/led/groups/partition_system_attention_indicator",
201 "xyz.openbmc_project.Led.Group"),
202 [this](sdbusplus::message_t& msg) {
203 pldm::utils::DbusChangedProps props{};
204 std::string intf;
205 msg.read(intf, props);
206 const auto itr = props.find("Asserted");
207 if (itr != props.end())
208 {
209 processSAIUpdate();
210 }
211 });
212
213 partitionSAIMatch = std::make_unique<sdbusplus::bus::match_t>(
214 pldm::utils::DBusHandler::getBus(),
215 propertiesChanged(
216 "/xyz/openbmc_project/led/groups/platform_system_attention_indicator",
217 "xyz.openbmc_project.Led.Group"),
218 [this](sdbusplus::message_t& msg) {
219 pldm::utils::DbusChangedProps props{};
220 std::string intf;
221 msg.read(intf, props);
222 const auto itr = props.find("Asserted");
223 if (itr != props.end())
224 {
225 processSAIUpdate();
226 }
227 });
Sampa Misraaea5dde2020-08-31 08:33:47 -0500228 }
229
230 int getOemStateSensorReadingsHandler(
Kamalkumar Patel7d427f12024-05-16 03:44:00 -0500231 pldm::pdr::EntityType entityType,
232 pldm::pdr::EntityInstance entityInstance,
Manojkiran Edaa31ceb92021-07-22 09:19:02 +0530233 pldm::pdr::ContainerID containerId, pldm::pdr::StateSetId stateSetId,
234 pldm::pdr::CompositeCount compSensorCnt, uint16_t sensorId,
Sampa Misraaea5dde2020-08-31 08:33:47 -0500235 std::vector<get_sensor_state_field>& stateField);
236
Sampa Misra3a0e3b92020-10-21 05:58:00 -0500237 int oemSetStateEffecterStatesHandler(
Varsha Kaverappa3fbd39e2020-09-28 01:40:22 -0500238 uint16_t entityType, uint16_t entityInstance, uint16_t stateSetId,
239 uint8_t compEffecterCnt,
240 std::vector<set_effecter_state_field>& stateField, uint16_t effecterId);
Sampa Misraaea5dde2020-08-31 08:33:47 -0500241
242 /** @brief Method to set the platform handler in the
243 * oem_ibm_handler class
244 * @param[in] handler - pointer to PLDM platform handler
245 */
246 void setPlatformHandler(pldm::responder::platform::Handler* handler);
247
Sagar Srinivas78a225a2020-08-27 00:52:20 -0500248 /** @brief Method to fetch the effecter ID of the code update PDRs
249 *
250 * @return platformHandler->getNextEffecterId() - returns the
251 * effecter ID from the platform handler
252 */
Manojkiran Eda6b1d8832021-03-27 11:25:06 +0530253 virtual uint16_t getNextEffecterId()
Sagar Srinivas78a225a2020-08-27 00:52:20 -0500254 {
255 return platformHandler->getNextEffecterId();
256 }
257
258 /** @brief Method to fetch the sensor ID of the code update PDRs
259 *
260 * @return platformHandler->getNextSensorId() - returns the
261 * Sensor ID from the platform handler
262 */
Manojkiran Eda6b1d8832021-03-27 11:25:06 +0530263 virtual uint16_t getNextSensorId()
Sagar Srinivas78a225a2020-08-27 00:52:20 -0500264 {
265 return platformHandler->getNextSensorId();
266 }
267
Manojkiran Edaa31ceb92021-07-22 09:19:02 +0530268 /** @brief Get std::map associated with the entity
269 * key: object path
270 * value: pldm_entity
271 *
272 * @return std::map<ObjectPath, pldm_entity>
273 */
274 virtual const AssociatedEntityMap& getAssociateEntityMap()
275 {
276 return platformHandler->getAssociateEntityMap();
277 }
278
Sagar Srinivas78a225a2020-08-27 00:52:20 -0500279 /** @brief Method to Generate the OEM PDRs
280 *
281 * @param[in] repo - instance of concrete implementation of Repo
282 */
283 void buildOEMPDR(pdr_utils::Repo& repo);
284
Varsha Kaverappabb585b22020-09-10 06:15:42 -0500285 /** @brief Method to send code update event to host
286 * @param[in] sensorId - sendor ID
287 * @param[in] sensorEventClass - event class of sensor
288 * @param[in] sensorOffset - sensor offset
289 * @param[in] eventState - new code update event state
290 * @param[in] prevEventState - previous code update event state
291 * @return none
292 */
293 void sendStateSensorEvent(uint16_t sensorId,
294 enum sensor_event_class_states sensorEventClass,
295 uint8_t sensorOffset, uint8_t eventState,
296 uint8_t prevEventState);
297
298 /** @brief Method to send encoded request msg of code update event to host
299 * @param[in] requestMsg - encoded request msg
Sampa Misrac0c79482021-06-02 08:01:54 -0500300 * @param[in] instanceId - instance id of the message
Varsha Kaverappabb585b22020-09-10 06:15:42 -0500301 * @return PLDM status code
302 */
Sampa Misrac0c79482021-06-02 08:01:54 -0500303 int sendEventToHost(std::vector<uint8_t>& requestMsg, uint8_t instanceId);
Varsha Kaverappabb585b22020-09-10 06:15:42 -0500304
Sampa Misra3a0e3b92020-10-21 05:58:00 -0500305 /** @brief _processEndUpdate processes the actual work that needs
306 * to be carried out after EndUpdate effecter is set. This is done async
307 * after sending response for EndUpdate set effecter
308 * @param[in] source - sdeventplus event source
309 */
310 void _processEndUpdate(sdeventplus::source::EventBase& source);
311
312 /** @brief _processStartUpdate processes the actual work that needs
313 * to be carried out after StartUpdate effecter is set. This is done async
314 * after sending response for StartUpdate set effecter
315 * @param[in] source - sdeventplus event source
316 */
317 void _processStartUpdate(sdeventplus::source::EventBase& source);
318
Sagar Srinivas9a64b4a2021-02-09 07:55:38 -0600319 /** @brief _processSystemReboot processes the actual work that needs to be
320 * carried out after the System Power State effecter is set to reboot
321 * the system
322 * @param[in] source - sdeventplus event source
323 */
324 void _processSystemReboot(sdeventplus::source::EventBase& source);
325
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500326 /*keeps track how many times setEventReceiver is sent */
327 void countSetEventReceiver()
328 {
329 setEventReceiverCnt++;
330 }
331
332 /* disables watchdog if running and Host is up */
333 void checkAndDisableWatchDog();
334
Sagar Srinivas79669c92021-04-28 15:43:30 -0500335 /** @brief To check if the watchdog app is running
336 *
337 * @return the running status of watchdog app
338 */
339 bool watchDogRunning();
340
341 /** @brief Method to reset the Watchdog timer on receiving platform Event
342 * Message for heartbeat elapsed time from Hostboot
343 */
344 void resetWatchDogTimer();
345
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500346 /** @brief To disable to the watchdog timer on host poweron completion*/
347 void disableWatchDogTimer();
348
Pavithra Barithaya99854a72021-09-29 06:58:11 -0500349 /** @brief to check the BMC state*/
350 int checkBMCState();
351
Kamalkumar Patel15ce5a12024-05-07 11:45:11 -0500352 /** @brief update the dbus object paths */
353 void updateOemDbusPaths(std::string& dbusPath);
354
Sagar Srinivas3687e2b2023-04-10 05:08:28 -0500355 /** @brief Method to fetch the last BMC record from the PDR repo
356 *
357 * @param[in] repo - pointer to BMC's primary PDR repo
358 *
359 * @return the last BMC record from the repo
360 */
361 const pldm_pdr_record* fetchLastBMCRecord(const pldm_pdr* repo);
362
363 /** @brief Method to check if the record handle passed is in remote PDR
364 * record handle range
365 *
366 * @param[in] record_handle - record handle of the PDR
367 *
368 * @return true if record handle passed is in host PDR record handle range
369 */
370 bool checkRecordHandleInRange(const uint32_t& record_handle);
371
Sagar Srinivas90314a32023-10-17 10:38:03 -0500372 /** *brief Method to call the setEventReceiver command*/
373 void processSetEventReceiver();
374
375 /** @brief Method to call the setEventReceiver through the platform
376 * handler
377 */
378 virtual void setEventReceiver()
379 {
380 platformHandler->setEventReceiver();
381 }
382
Sagar Srinivas18145f72022-04-11 07:38:26 -0500383 /** @brief Method to Enable/Disable timer to see if remote terminus sends
384 * the surveillance ping and logs informational error if remote terminus
385 * fails to send the surveillance pings
386 *
387 * @param[in] tid - TID of the remote terminus
388 * @param[in] value - true or false, to indicate if the timer is
389 * running or not
390 */
391 void setSurvTimer(uint8_t tid, bool value);
392
Archana Kakani50554252025-03-17 01:37:29 -0500393 /** @brief To handle the boot types bios attributes at power on*/
394 void handleBootTypesAtPowerOn();
395
396 /** @brief To handle the boot types bios attributes at shutdown*/
397 void handleBootTypesAtChassisOff();
398
399 /** @brief To set the boot types bios attributes based on the RestartCause
400 * of host
401 *
402 * @param[in] RestartCause - Host restart cause
403 */
404 void setBootTypesBiosAttr(const std::string& restartCause);
405
Jayashankar Padathfdf6da72025-04-14 10:54:58 -0500406 /** @brief To turn off Real SAI effecter*/
407 void turnOffRealSAIEffecter();
408
409 /** @brief Fetch Real SAI status based on the partition SAI and platform SAI
410 * sensor states. Real SAI is turned on if any of the partition or platform
411 * SAI turned on else Real SAI is turned off
412 * @return Real SAI sensor state PLDM_SENSOR_WARNING/PLDM_SENSOR_NORMAL
413 */
414 uint8_t fetchRealSAIStatus();
415
416 /** @brief Method to process virtual platform/partition SAI update*/
417 void processSAIUpdate();
418
Sampa Misraaea5dde2020-08-31 08:33:47 -0500419 ~Handler() = default;
420
421 pldm::responder::CodeUpdate* codeUpdate; //!< pointer to CodeUpdate object
Manojkiran Edaa31ceb92021-07-22 09:19:02 +0530422
423 pldm::responder::SlotHandler*
424 slotHandler; //!< pointer to SlotHandler object
425
Sampa Misraaea5dde2020-08-31 08:33:47 -0500426 pldm::responder::platform::Handler*
427 platformHandler; //!< pointer to PLDM platform handler
Varsha Kaverappabb585b22020-09-10 06:15:42 -0500428
429 /** @brief fd of MCTP communications socket */
430 int mctp_fd;
431
432 /** @brief MCTP EID of host firmware */
433 uint8_t mctp_eid;
434
Andrew Jefferya330b2f2023-05-04 14:55:37 +0930435 /** @brief reference to an InstanceIdDb object, used to obtain a PLDM
436 * instance id. */
437 pldm::InstanceIdDb& instanceIdDb;
Sampa Misra3a0e3b92020-10-21 05:58:00 -0500438 /** @brief sdeventplus event source */
439 std::unique_ptr<sdeventplus::source::Defer> assembleImageEvent;
440 std::unique_ptr<sdeventplus::source::Defer> startUpdateEvent;
Sagar Srinivas9a64b4a2021-02-09 07:55:38 -0600441 std::unique_ptr<sdeventplus::source::Defer> systemRebootEvent;
Sampa Misra3a0e3b92020-10-21 05:58:00 -0500442
Manojkiran Edaa31ceb92021-07-22 09:19:02 +0530443 /** @brief Effecterid to dbus object path map
444 */
445 std::unordered_map<uint16_t, std::string> effecterIdToDbusMap;
446
Sampa Misra3a0e3b92020-10-21 05:58:00 -0500447 /** @brief reference of main event loop of pldmd, primarily used to schedule
448 * work
449 */
450 sdeventplus::Event& event;
Sagar Srinivas9a64b4a2021-02-09 07:55:38 -0600451
452 private:
Sagar Srinivas18145f72022-04-11 07:38:26 -0500453 /** @brief Method to reset or stop the surveillance timer
454 *
455 * @param[in] value - true or false, to indicate if the timer
456 * should be reset or turned off
457 */
458 void startStopTimer(bool value);
459
Sagar Srinivas9a64b4a2021-02-09 07:55:38 -0600460 /** @brief D-Bus property changed signal match for CurrentPowerState*/
Patrick Williams84b790c2022-07-22 19:26:56 -0500461 std::unique_ptr<sdbusplus::bus::match_t> chassisOffMatch;
Sampa Misrac0c79482021-06-02 08:01:54 -0500462
463 /** @brief PLDM request handler */
464 pldm::requester::Handler<pldm::requester::Request>* handler;
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500465
466 /** @brief D-Bus property changed signal match */
Archana Kakanie26d13f2025-03-09 23:17:46 -0500467 std::unique_ptr<sdbusplus::bus::match_t> updateBIOSMatch;
468
469 /** @brief D-Bus property changed signal match */
Patrick Williams84b790c2022-07-22 19:26:56 -0500470 std::unique_ptr<sdbusplus::bus::match_t> hostOffMatch;
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500471
Pavithra Barithaya0fd6a092024-05-31 08:24:27 -0500472 /** @brief D-Bus property changed signal match */
473 std::unique_ptr<sdbusplus::bus::match_t> powerStateOffMatch;
474
Sagar Srinivas18145f72022-04-11 07:38:26 -0500475 /** @brief Timer used for monitoring surveillance pings from host */
476 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
477
Jayashankar Padathfdf6da72025-04-14 10:54:58 -0500478 /** @brief D-Bus Interface added signal match for virtual platform SAI */
479 std::unique_ptr<sdbusplus::bus::match_t> platformSAIMatch;
480
481 /** @brief D-Bus Interface added signal match for virtual partition SAI */
482 std::unique_ptr<sdbusplus::bus::match_t> partitionSAIMatch;
483
484 /** @brief Real SAI sensor id*/
485 uint16_t realSAISensorId;
486
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500487 bool hostOff = true;
488
Sagar Srinivas18145f72022-04-11 07:38:26 -0500489 bool hostTransitioningToOff;
490
Sagar Srinivas7f760b32021-05-12 07:46:56 -0500491 int setEventReceiverCnt = 0;
Sampa Misraaea5dde2020-08-31 08:33:47 -0500492};
493
Varsha Kaverappabb585b22020-09-10 06:15:42 -0500494/** @brief Method to encode code update event msg
495 * @param[in] eventType - type of event
496 * @param[in] eventDataVec - vector of event data to be sent to host
497 * @param[in/out] requestMsg - request msg to be encoded
498 * @param[in] instanceId - instance ID
499 * @return PLDM status code
500 */
501int encodeEventMsg(uint8_t eventType, const std::vector<uint8_t>& eventDataVec,
502 std::vector<uint8_t>& requestMsg, uint8_t instanceId);
503
Sampa Misraaea5dde2020-08-31 08:33:47 -0500504} // namespace oem_ibm_platform
505
Archana Kakani97a0f482025-03-10 05:39:38 -0500506namespace oem_ibm_bios
507{
508/** @brief The file where bootside data will be saved */
509constexpr auto bootSideDirPath = "/var/lib/pldm/bootSide";
510
511class Handler : public oem_bios::Handler
512{
513 public:
514 Handler() {}
515
516 void processOEMBaseBiosTable(const BaseBIOSTable& biosTable)
517 {
518 for (const auto& [attrName, biostabObj] : biosTable)
519 {
520 // The additional check to see if /var/lib/pldm/bootSide file exists
521 // is added to make sure we are doing the fw_boot_side setting after
522 // the base bios table is initialised.
523 if ((attrName == "fw_boot_side") && fs::exists(bootSideDirPath))
524 {
525 PendingAttributesList biosAttrList;
526
527 std::string nextBootSide =
528 std::get<std::string>(std::get<5>(biostabObj));
529
530 std::string currNextBootSide;
531 auto attributeValue =
532 getBiosAttrValue<std::string>("fw_boot_side");
533
534 if (attributeValue.has_value())
535 {
536 currNextBootSide = attributeValue.value();
537 }
538 else
539 {
540 info(
541 "Boot side is not initialized yet, so setting default value");
542 currNextBootSide = "Temp";
543 }
544
545 if (currNextBootSide != nextBootSide)
546 {
547 biosAttrList.emplace_back(std::make_pair(
548 attrName,
549 std::make_tuple(EnumAttribute, nextBootSide)));
550 setBiosAttr(biosAttrList);
551 }
552 }
553 }
554 }
555};
556
557} // namespace oem_ibm_bios
558
Sampa Misraaea5dde2020-08-31 08:33:47 -0500559} // namespace responder
560
561} // namespace pldm