blob: 482b4f1f1c953242b8c3d7cb4b61d13580a508cc [file] [log] [blame]
Matt Spinlerc8705e22019-09-11 12:36:07 -05001#pragma once
2
Matt Spinler2a28c932020-02-03 14:23:40 -06003#include "dbus_types.hpp"
4#include "dbus_watcher.hpp"
5
Matt Spinler4dcd3f42020-01-22 14:55:07 -06006#include <filesystem>
Matt Spinlera7d9d962019-11-06 15:01:25 -06007#include <phosphor-logging/log.hpp>
Matt Spinlerc8705e22019-09-11 12:36:07 -05008#include <sdbusplus/bus.hpp>
9#include <sdbusplus/bus/match.hpp>
10
11namespace openpower
12{
13namespace pels
14{
15
Matt Spinlerc8705e22019-09-11 12:36:07 -050016/**
17 * @class DataInterface
18 *
Matt Spinler19e89ce2019-11-06 13:02:23 -060019 * A base class for gathering data about the system for use
20 * in PELs. Implemented this way to facilitate mocking.
Matt Spinlerc8705e22019-09-11 12:36:07 -050021 */
22class DataInterfaceBase
23{
24 public:
25 DataInterfaceBase() = default;
26 virtual ~DataInterfaceBase() = default;
27 DataInterfaceBase(const DataInterfaceBase&) = default;
28 DataInterfaceBase& operator=(const DataInterfaceBase&) = default;
29 DataInterfaceBase(DataInterfaceBase&&) = default;
30 DataInterfaceBase& operator=(DataInterfaceBase&&) = default;
31
32 /**
Matt Spinler19e89ce2019-11-06 13:02:23 -060033 * @brief Returns the machine Type/Model
Matt Spinlerc8705e22019-09-11 12:36:07 -050034 *
35 * @return string - The machine Type/Model string
36 */
Vijay Lobo81b4dca2021-04-29 00:04:00 -050037 virtual std::string getMachineTypeModel() const = 0;
Matt Spinlerc8705e22019-09-11 12:36:07 -050038
39 /**
Matt Spinler19e89ce2019-11-06 13:02:23 -060040 * @brief Returns the machine serial number
Matt Spinlerc8705e22019-09-11 12:36:07 -050041 *
42 * @return string - The machine serial number
43 */
Vijay Lobo81b4dca2021-04-29 00:04:00 -050044 virtual std::string getMachineSerialNumber() const = 0;
Matt Spinler19e89ce2019-11-06 13:02:23 -060045
Matt Spinlera7d9d962019-11-06 15:01:25 -060046 /**
Matt Spinlercce14112019-12-11 14:20:36 -060047 * @brief Says if the system is managed by a hardware
48 * management console.
49 * @return bool - If the system is HMC managed
50 */
51 virtual bool isHMCManaged() const
52 {
53 return _hmcManaged;
54 }
55
56 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -060057 * @brief Says if the host is up and running
58 *
59 * @return bool - If the host is running
60 */
61 virtual bool isHostUp() const
62 {
63 return _hostUp;
64 }
65
66 using HostStateChangeFunc = std::function<void(bool)>;
67
68 /**
69 * @brief Register a callback function that will get
70 * called on all host on/off transitions.
71 *
72 * The void(bool) function will get passed the new
73 * value of the host state.
74 *
75 * @param[in] name - The subscription name
76 * @param[in] func - The function to run
77 */
78 void subscribeToHostStateChange(const std::string& name,
79 HostStateChangeFunc func)
80 {
81 _hostChangeCallbacks[name] = func;
82 }
83
84 /**
85 * @brief Unsubscribe from host state changes.
86 *
87 * @param[in] name - The subscription name
88 */
89 void unsubscribeFromHostStateChange(const std::string& name)
90 {
91 _hostChangeCallbacks.erase(name);
92 }
93
Matt Spinlercad9c2b2019-12-02 15:42:01 -060094 /**
95 * @brief Returns the BMC firmware version
96 *
97 * @return std::string - The BMC version
98 */
99 virtual std::string getBMCFWVersion() const
100 {
101 return _bmcFWVersion;
102 }
103
104 /**
105 * @brief Returns the server firmware version
106 *
107 * @return std::string - The server firmware version
108 */
109 virtual std::string getServerFWVersion() const
110 {
111 return _serverFWVersion;
112 }
113
Matt Spinler4dcd3f42020-01-22 14:55:07 -0600114 /**
Matt Spinler677381b2020-01-23 10:04:29 -0600115 * @brief Returns the BMC FW version ID
116 *
117 * @return std::string - The BMC FW version ID
118 */
119 virtual std::string getBMCFWVersionID() const
120 {
121 return _bmcFWVersionID;
122 }
123
124 /**
Matt Spinler4dcd3f42020-01-22 14:55:07 -0600125 * @brief Returns the process name given its PID.
126 *
127 * @param[in] pid - The PID value as a string
128 *
129 * @return std::optional<std::string> - The name, or std::nullopt
130 */
131 std::optional<std::string> getProcessName(const std::string& pid) const
132 {
133 namespace fs = std::filesystem;
134
135 fs::path path{"/proc"};
136 path /= fs::path{pid} / "exe";
137
138 if (fs::exists(path))
139 {
140 return fs::read_symlink(path);
141 }
142
143 return std::nullopt;
144 }
145
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600146 /**
147 * @brief Returns the 'send event logs to host' setting.
148 *
149 * @return bool - If sending PELs to the host is enabled.
150 */
151 virtual bool getHostPELEnablement() const
152 {
153 return _sendPELsToHost;
154 }
155
Matt Spinler4aa23a12020-02-03 15:05:09 -0600156 /**
157 * @brief Returns the BMC state
158 *
159 * @return std::string - The BMC state property value
160 */
161 virtual std::string getBMCState() const
162 {
163 return _bmcState;
164 }
165
166 /**
167 * @brief Returns the Chassis state
168 *
169 * @return std::string - The chassis state property value
170 */
171 virtual std::string getChassisState() const
172 {
173 return _chassisState;
174 }
175
176 /**
177 * @brief Returns the chassis requested power
178 * transition value.
179 *
180 * @return std::string - The chassis transition property
181 */
182 virtual std::string getChassisTransition() const
183 {
184 return _chassisTransition;
185 }
186
187 /**
188 * @brief Returns the Host state
189 *
190 * @return std::string - The Host state property value
191 */
192 virtual std::string getHostState() const
193 {
194 return _hostState;
195 }
196
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600197 /**
198 * @brief Returns the motherboard CCIN
199 *
200 * @return std::string The motherboard CCIN
201 */
Vijay Lobo81b4dca2021-04-29 00:04:00 -0500202 virtual std::string getMotherboardCCIN() const = 0;
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600203
Matt Spinler60c4e792020-03-13 13:45:36 -0500204 /**
Ben Tynere32b7e72021-05-18 12:38:40 -0500205 * @brief Returns the system IM
206 *
207 * @return std::string The system IM
208 */
209 virtual std::vector<uint8_t> getSystemIMKeyword() const = 0;
210
211 /**
Matt Spinler60c4e792020-03-13 13:45:36 -0500212 * @brief Get the fields from the inventory necessary for doing
213 * a callout on an inventory path.
214 *
215 * @param[in] inventoryPath - The item to get the data for
Matt Spinler60c4e792020-03-13 13:45:36 -0500216 * @param[out] fruPartNumber - Filled in with the VINI/FN keyword
217 * @param[out] ccin - Filled in with the VINI/CC keyword
218 * @param[out] serialNumber - Filled in with the VINI/SN keyword
219 */
220 virtual void getHWCalloutFields(const std::string& inventoryPath,
Matt Spinler60c4e792020-03-13 13:45:36 -0500221 std::string& fruPartNumber,
222 std::string& ccin,
223 std::string& serialNumber) const = 0;
224
Matt Spinler03984582020-04-09 13:17:58 -0500225 /**
Matt Spinler9b90e2a2020-04-14 10:59:04 -0500226 * @brief Get the location code for an inventory item.
227 *
228 * @param[in] inventoryPath - The item to get the data for
229 *
230 * @return std::string - The location code
231 */
232 virtual std::string
233 getLocationCode(const std::string& inventoryPath) const = 0;
234
235 /**
Matt Spinler6ea4d5f2020-05-20 13:31:07 -0500236 * @brief Get the list of system type names the system is called.
Matt Spinler03984582020-04-09 13:17:58 -0500237 *
Matt Spinler6ea4d5f2020-05-20 13:31:07 -0500238 * @return std::vector<std::string> - The list of names
Matt Spinler03984582020-04-09 13:17:58 -0500239 */
Matt Spinler1ab66962020-10-29 13:21:44 -0500240 virtual std::vector<std::string> getSystemNames() const = 0;
Matt Spinler03984582020-04-09 13:17:58 -0500241
Matt Spinler5fb24c12020-06-04 11:21:33 -0500242 /**
243 * @brief Fills in the placeholder 'Ufcs' in the passed in location
244 * code with the machine feature code and serial number, which
245 * is needed to create a valid location code.
246 *
247 * @param[in] locationCode - Location code value starting with Ufcs-, and
248 * if that isn't present it will be added first.
249 *
250 * @param[in] node - The node number the location is on.
251 *
252 * @return std::string - The expanded location code
253 */
254 virtual std::string expandLocationCode(const std::string& locationCode,
255 uint16_t node) const = 0;
256
257 /**
258 * @brief Returns the inventory path for the FRU that the location
259 * code represents.
260 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500261 * @param[in] locationCode - If an expanded location code, then the
262 * full location code.
263 * If not expanded, a location code value
264 * starting with Ufcs-, and if that isn't
265 * present it will be added first.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500266 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500267 * @param[in] node - The node number the location is on. Ignored if the
268 * expanded location code is passed in.
269 *
270 * @param[in] expanded - If the location code already has the relevent
271 * VPD fields embedded in it.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500272 *
273 * @return std::string - The inventory D-Bus object
274 */
Matt Spinler2f9225a2020-08-05 12:58:49 -0500275 virtual std::string getInventoryFromLocCode(const std::string& LocationCode,
276 uint16_t node,
277 bool expanded) const = 0;
Matt Spinler5fb24c12020-06-04 11:21:33 -0500278
Matt Spinler34a904c2020-08-05 14:53:28 -0500279 /**
Matt Spinler34a904c2020-08-05 14:53:28 -0500280 * @brief Sets the Asserted property on the LED group passed in.
281 *
282 * @param[in] ledGroup - The LED group D-Bus path
283 * @param[in] value - The value to set it to
284 */
285 virtual void assertLEDGroup(const std::string& ledGroup,
286 bool value) const = 0;
287
Matt Spinler993168d2021-04-07 16:05:03 -0500288 /**
289 * @brief Sets the Functional property on the OperationalStatus
290 * interface on a D-Bus object.
291 *
292 * @param[in] objectPath - The D-Bus object path
293 * @param[in] functional - The value
294 */
295 virtual void setFunctional(const std::string& objectPath,
296 bool functional) const = 0;
297
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500298 /**
Sumit Kumar76198a22021-07-15 05:59:57 -0500299 * @brief Sets the critical association on the D-Bus object.
300 *
301 * @param[in] objectPath - The D-Bus object path
302 */
303 virtual void
304 setCriticalAssociation(const std::string& objectPath) const = 0;
305
306 /**
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500307 * @brief Returns the manufacturing QuiesceOnError property
308 *
309 * @return bool - Manufacturing QuiesceOnError property
310 */
311 virtual bool getQuiesceOnError() const = 0;
312
Matt Spinler0d92b522021-06-16 13:28:17 -0600313 /**
314 * @brief Split location code into base and connector segments
315 *
316 * A location code that ends in '-Tx', where 'x' is a number,
317 * represents a connector, such as a USB cable connector.
318 *
319 * This function splits the passed in location code into a
320 * base and connector segment. e.g.:
321 * P0-T1 -> ['P0', '-T1']
322 * P0 -> ['P0', '']
323 *
324 * @param[in] locationCode - location code to split
325 * @return pair<string, string> - The base and connector segments
326 */
327 static std::pair<std::string, std::string>
328 extractConnectorFromLocCode(const std::string& locationCode);
329
Sumit Kumar9d43a722021-08-24 09:46:19 -0500330 /**
331 * @brief Returns the dump status
332 *
333 * @return bool dump status
334 */
335 virtual std::vector<bool>
336 checkDumpStatus(const std::vector<std::string>& type) const = 0;
337
Matt Spinler19e89ce2019-11-06 13:02:23 -0600338 protected:
339 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -0600340 * @brief Sets the host on/off state and runs any
341 * callback functions (if there was a change).
342 */
Matt Spinler4aa23a12020-02-03 15:05:09 -0600343 void setHostUp(bool hostUp)
Matt Spinlera7d9d962019-11-06 15:01:25 -0600344 {
Matt Spinler4aa23a12020-02-03 15:05:09 -0600345 if (_hostUp != hostUp)
Matt Spinlera7d9d962019-11-06 15:01:25 -0600346 {
Matt Spinler4aa23a12020-02-03 15:05:09 -0600347 _hostUp = hostUp;
Matt Spinlera7d9d962019-11-06 15:01:25 -0600348
349 for (auto& [name, func] : _hostChangeCallbacks)
350 {
351 try
352 {
353 func(_hostUp);
354 }
355 catch (std::exception& e)
356 {
357 using namespace phosphor::logging;
358 log<level::ERR>("A host state change callback threw "
359 "an exception");
360 }
361 }
362 }
363 }
364
365 /**
Matt Spinlercce14112019-12-11 14:20:36 -0600366 * @brief The hardware management console status. Always kept
367 * up to date.
368 */
369 bool _hmcManaged = false;
370
371 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -0600372 * @brief The host up status. Always kept up to date.
373 */
374 bool _hostUp = false;
375
376 /**
377 * @brief The map of host state change subscriber
378 * names to callback functions.
379 */
380 std::map<std::string, HostStateChangeFunc> _hostChangeCallbacks;
Matt Spinlercad9c2b2019-12-02 15:42:01 -0600381
382 /**
383 * @brief The BMC firmware version string
384 */
385 std::string _bmcFWVersion;
386
387 /**
388 * @brief The server firmware version string
389 */
390 std::string _serverFWVersion;
Matt Spinler677381b2020-01-23 10:04:29 -0600391
392 /**
393 * @brief The BMC firmware version ID string
394 */
395 std::string _bmcFWVersionID;
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600396
397 /**
398 * @brief If sending PELs is enabled.
399 *
400 * This is usually set to false in manufacturing test.
401 */
402 bool _sendPELsToHost = true;
Matt Spinler4aa23a12020-02-03 15:05:09 -0600403
404 /**
405 * @brief The BMC state property
406 */
407 std::string _bmcState;
408
409 /**
410 * @brief The Chassis current power state property
411 */
412 std::string _chassisState;
413
414 /**
415 * @brief The Chassis requested power transition property
416 */
417 std::string _chassisTransition;
418
419 /**
420 * @brief The host state property
421 */
422 std::string _hostState;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500423};
424
425/**
426 * @class DataInterface
427 *
428 * Concrete implementation of DataInterfaceBase.
429 */
430class DataInterface : public DataInterfaceBase
431{
432 public:
433 DataInterface() = delete;
434 ~DataInterface() = default;
435 DataInterface(const DataInterface&) = default;
436 DataInterface& operator=(const DataInterface&) = default;
437 DataInterface(DataInterface&&) = default;
438 DataInterface& operator=(DataInterface&&) = default;
439
440 /**
441 * @brief Constructor
442 *
443 * @param[in] bus - The sdbusplus bus object
444 */
445 explicit DataInterface(sdbusplus::bus::bus& bus);
446
Matt Spinlerb3f51862019-12-09 13:55:10 -0600447 /**
Matt Spinlerc8705e22019-09-11 12:36:07 -0500448 * @brief Finds the D-Bus service name that hosts the
449 * passed in path and interface.
450 *
451 * @param[in] objectPath - The D-Bus object path
452 * @param[in] interface - The D-Bus interface
453 */
454 DBusService getService(const std::string& objectPath,
Matt Spinlerb3f51862019-12-09 13:55:10 -0600455 const std::string& interface) const;
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600456
Matt Spinlerc8705e22019-09-11 12:36:07 -0500457 /**
458 * @brief Wrapper for the 'GetAll' properties method call
459 *
460 * @param[in] service - The D-Bus service to call it on
461 * @param[in] objectPath - The D-Bus object path
462 * @param[in] interface - The interface to get the props on
463 *
464 * @return DBusPropertyMap - The property results
465 */
466 DBusPropertyMap getAllProperties(const std::string& service,
467 const std::string& objectPath,
Matt Spinler2a28c932020-02-03 14:23:40 -0600468 const std::string& interface) const;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500469 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -0600470 * @brief Wrapper for the 'Get' properties method call
471 *
472 * @param[in] service - The D-Bus service to call it on
473 * @param[in] objectPath - The D-Bus object path
474 * @param[in] interface - The interface to get the property on
475 * @param[in] property - The property name
476 * @param[out] value - Filled in with the property value.
477 */
478 void getProperty(const std::string& service, const std::string& objectPath,
479 const std::string& interface, const std::string& property,
Matt Spinler2a28c932020-02-03 14:23:40 -0600480 DBusValue& value) const;
Vijay Lobo81b4dca2021-04-29 00:04:00 -0500481 /**
482 * @brief Returns the machine Type/Model
483 *
484 * @return string - The machine Type/Model string
485 */
486 std::string getMachineTypeModel() const override;
487
488 /**
489 * @brief Returns the machine serial number
490 *
491 * @return string - The machine serial number
492 */
493 std::string getMachineSerialNumber() const override;
494
495 /**
496 * @brief Returns the motherboard CCIN
497 *
498 * @return std::string The motherboard CCIN
499 */
500 std::string getMotherboardCCIN() const override;
Matt Spinler2a28c932020-02-03 14:23:40 -0600501
Matt Spinler60c4e792020-03-13 13:45:36 -0500502 /**
Ben Tynere32b7e72021-05-18 12:38:40 -0500503 * @brief Returns the system IM
504 *
505 * @return std::vector The system IM keyword in 4 byte vector
506 */
507 std::vector<uint8_t> getSystemIMKeyword() const override;
508
509 /**
Matt Spinler60c4e792020-03-13 13:45:36 -0500510 * @brief Get the fields from the inventory necessary for doing
511 * a callout on an inventory path.
512 *
513 * @param[in] inventoryPath - The item to get the data for
Matt Spinler60c4e792020-03-13 13:45:36 -0500514 * @param[out] fruPartNumber - Filled in with the VINI/FN keyword
515 * @param[out] ccin - Filled in with the VINI/CC keyword
516 * @param[out] serialNumber - Filled in with the VINI/SN keyword
517 */
518 void getHWCalloutFields(const std::string& inventoryPath,
Matt Spinler60c4e792020-03-13 13:45:36 -0500519 std::string& fruPartNumber, std::string& ccin,
520 std::string& serialNumber) const override;
521
Matt Spinler9b90e2a2020-04-14 10:59:04 -0500522 /**
523 * @brief Get the location code for an inventory item.
524 *
525 * Throws an exception if the inventory item doesn't have the
526 * location code interface.
527 *
528 * @param[in] inventoryPath - The item to get the data for
529 *
530 * @return std::string - The location code
531 */
532 std::string
533 getLocationCode(const std::string& inventoryPath) const override;
534
Matt Spinler5fb24c12020-06-04 11:21:33 -0500535 /**
Matt Spinler1ab66962020-10-29 13:21:44 -0500536 * @brief Get the list of system type names the system is called.
537 *
538 * @return std::vector<std::string> - The list of names
539 */
540 std::vector<std::string> getSystemNames() const override;
541
542 /**
Matt Spinler5fb24c12020-06-04 11:21:33 -0500543 * @brief Fills in the placeholder 'Ufcs' in the passed in location
544 * code with the machine feature code and serial number, which
545 * is needed to create a valid location code.
546 *
547 * @param[in] locationCode - Location code value starting with Ufcs-, and
548 * if that isn't present it will be added first.
549 *
550 * @param[in] node - The node number the location is one.
551 *
552 * @return std::string - The expanded location code
553 */
554 std::string expandLocationCode(const std::string& locationCode,
555 uint16_t node) const override;
556
557 /**
558 * @brief Returns the inventory path for the FRU that the location
559 * code represents.
560 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500561 * @param[in] locationCode - If an expanded location code, then the
562 * full location code.
563 * If not expanded, a location code value
564 * starting with Ufcs-, and if that isn't
565 * present it will be added first.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500566 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500567 * @param[in] node - The node number the location is on. Ignored if the
568 * expanded location code is passed in.
569 *
570 * @param[in] expanded - If the location code already has the relevent
571 * VPD fields embedded in it.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500572 *
573 * @return std::string - The inventory D-Bus object
574 */
Matt Spinler2f9225a2020-08-05 12:58:49 -0500575 std::string getInventoryFromLocCode(const std::string& locationCode,
576 uint16_t node,
577 bool expanded) const override;
Matt Spinler5fb24c12020-06-04 11:21:33 -0500578
Matt Spinler34a904c2020-08-05 14:53:28 -0500579 /**
Matt Spinler34a904c2020-08-05 14:53:28 -0500580 * @brief Sets the Asserted property on the LED group passed in.
581 *
582 * @param[in] ledGroup - The LED group D-Bus path
583 * @param[in] value - The value to set it to
584 */
585 void assertLEDGroup(const std::string& ledGroup, bool value) const override;
586
Matt Spinler993168d2021-04-07 16:05:03 -0500587 /**
588 * @brief Sets the Functional property on the OperationalStatus
589 * interface on a D-Bus object.
590 *
591 * @param[in] objectPath - The D-Bus object path
592 * @param[in] functional - The value
593 */
594 void setFunctional(const std::string& objectPath,
595 bool functional) const override;
596
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500597 /**
Sumit Kumar76198a22021-07-15 05:59:57 -0500598 * @brief Sets the critical association on the D-Bus object.
599 *
600 * @param[in] objectPath - The D-Bus object path
601 */
602 void setCriticalAssociation(const std::string& objectPath) const override;
603
604 /**
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500605 * @brief Returns the manufacturing QuiesceOnError property
606 *
607 * @return bool - Manufacturing QuiesceOnError property
608 */
609 bool getQuiesceOnError() const override;
610
Sumit Kumar9d43a722021-08-24 09:46:19 -0500611 /**
612 * @brief Returns the dump status
613 *
614 * @param[in] type - The dump type to check for
615 *
616 * @return bool dump status
617 */
618 std::vector<bool>
619 checkDumpStatus(const std::vector<std::string>& type) const override;
620
Matt Spinler2a28c932020-02-03 14:23:40 -0600621 private:
622 /**
623 * @brief Reads the BMC firmware version string and puts it into
624 * _bmcFWVersion.
625 */
626 void readBMCFWVersion();
Matt Spinlera7d9d962019-11-06 15:01:25 -0600627
628 /**
Matt Spinler2a28c932020-02-03 14:23:40 -0600629 * @brief Reads the server firmware version string and puts it into
630 * _serverFWVersion.
Matt Spinlerc8705e22019-09-11 12:36:07 -0500631 */
Matt Spinler2a28c932020-02-03 14:23:40 -0600632 void readServerFWVersion();
Matt Spinlerc8705e22019-09-11 12:36:07 -0500633
634 /**
Matt Spinler2a28c932020-02-03 14:23:40 -0600635 * @brief Reads the BMC firmware version ID and puts it into
636 * _bmcFWVersionID.
Matt Spinlera7d9d962019-11-06 15:01:25 -0600637 */
Matt Spinler2a28c932020-02-03 14:23:40 -0600638 void readBMCFWVersionID();
Matt Spinlera7d9d962019-11-06 15:01:25 -0600639
640 /**
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600641 * @brief Finds all D-Bus paths that contain any of the interfaces
642 * passed in, by using GetSubTreePaths.
643 *
644 * @param[in] interfaces - The desired interfaces
645 *
646 * @return The D-Bus paths.
647 */
648 DBusPathList getPaths(const DBusInterfaceList& interfaces) const;
649
650 /**
651 * @brief The interfacesAdded callback used on the inventory to
652 * find the D-Bus object that has the motherboard interface.
653 * When the motherboard is found, it then adds a PropertyWatcher
654 * for the motherboard CCIN.
655 */
656 void motherboardIfaceAdded(sdbusplus::message::message& msg);
657
658 /**
Matt Spinler0e4d72e2020-08-05 12:36:53 -0500659 * @brief Adds the Ufcs- prefix to the location code passed in
660 * if necessary.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500661 *
Matt Spinler0e4d72e2020-08-05 12:36:53 -0500662 * Needed because the location codes that come back from the
Matt Spinler5fb24c12020-06-04 11:21:33 -0500663 * message registry and device callout JSON don't have it.
664 *
665 * @param[in] - The location code without a prefix, like P1-C1
666 *
667 * @return std::string - The location code with the prefix
668 */
669 static std::string addLocationCodePrefix(const std::string& locationCode);
670
671 /**
Matt Spinler2a28c932020-02-03 14:23:40 -0600672 * @brief The D-Bus property or interface watchers that have callbacks
673 * registered that will set members in this class when
674 * they change.
Matt Spinlerc8705e22019-09-11 12:36:07 -0500675 */
Matt Spinler2a28c932020-02-03 14:23:40 -0600676 std::vector<std::unique_ptr<DBusWatcher>> _properties;
Matt Spinlera7d9d962019-11-06 15:01:25 -0600677
678 /**
Matt Spinlerc8705e22019-09-11 12:36:07 -0500679 * @brief The sdbusplus bus object for making D-Bus calls.
680 */
681 sdbusplus::bus::bus& _bus;
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600682
683 /**
684 * @brief The interfacesAdded match object used to wait for inventory
685 * interfaces to show up, so that the object with the motherboard
686 * interface can be found. After it is found, this object is
687 * deleted.
688 */
689 std::unique_ptr<sdbusplus::bus::match_t> _inventoryIfacesAddedMatch;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500690};
691
692} // namespace pels
693} // namespace openpower