blob: e66cd0cdd779bd4f86f53d78c8748ce24df35672 [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 Spinlera7d9d962019-11-06 15:01:25 -06006#include <phosphor-logging/log.hpp>
Matt Spinlerc8705e22019-09-11 12:36:07 -05007#include <sdbusplus/bus.hpp>
8#include <sdbusplus/bus/match.hpp>
9
Patrick Williams2544b412022-10-04 08:41:06 -050010#include <filesystem>
11#include <fstream>
12
Matt Spinlerc8705e22019-09-11 12:36:07 -050013namespace openpower
14{
15namespace pels
16{
17
Matt Spinlerc8705e22019-09-11 12:36:07 -050018/**
19 * @class DataInterface
20 *
Matt Spinler19e89ce2019-11-06 13:02:23 -060021 * A base class for gathering data about the system for use
22 * in PELs. Implemented this way to facilitate mocking.
Matt Spinlerc8705e22019-09-11 12:36:07 -050023 */
24class DataInterfaceBase
25{
26 public:
27 DataInterfaceBase() = default;
28 virtual ~DataInterfaceBase() = default;
29 DataInterfaceBase(const DataInterfaceBase&) = default;
30 DataInterfaceBase& operator=(const DataInterfaceBase&) = default;
31 DataInterfaceBase(DataInterfaceBase&&) = default;
32 DataInterfaceBase& operator=(DataInterfaceBase&&) = default;
33
34 /**
Matt Spinler19e89ce2019-11-06 13:02:23 -060035 * @brief Returns the machine Type/Model
Matt Spinlerc8705e22019-09-11 12:36:07 -050036 *
37 * @return string - The machine Type/Model string
38 */
Vijay Lobo81b4dca2021-04-29 00:04:00 -050039 virtual std::string getMachineTypeModel() const = 0;
Matt Spinlerc8705e22019-09-11 12:36:07 -050040
41 /**
Matt Spinler19e89ce2019-11-06 13:02:23 -060042 * @brief Returns the machine serial number
Matt Spinlerc8705e22019-09-11 12:36:07 -050043 *
44 * @return string - The machine serial number
45 */
Vijay Lobo81b4dca2021-04-29 00:04:00 -050046 virtual std::string getMachineSerialNumber() const = 0;
Matt Spinler19e89ce2019-11-06 13:02:23 -060047
Matt Spinlera7d9d962019-11-06 15:01:25 -060048 /**
Matt Spinlercce14112019-12-11 14:20:36 -060049 * @brief Says if the system is managed by a hardware
50 * management console.
51 * @return bool - If the system is HMC managed
52 */
53 virtual bool isHMCManaged() const
54 {
55 return _hmcManaged;
56 }
57
58 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -060059 * @brief Says if the host is up and running
60 *
61 * @return bool - If the host is running
62 */
63 virtual bool isHostUp() const
64 {
65 return _hostUp;
66 }
67
68 using HostStateChangeFunc = std::function<void(bool)>;
69
70 /**
71 * @brief Register a callback function that will get
72 * called on all host on/off transitions.
73 *
74 * The void(bool) function will get passed the new
75 * value of the host state.
76 *
77 * @param[in] name - The subscription name
78 * @param[in] func - The function to run
79 */
80 void subscribeToHostStateChange(const std::string& name,
81 HostStateChangeFunc func)
82 {
83 _hostChangeCallbacks[name] = func;
84 }
85
86 /**
87 * @brief Unsubscribe from host state changes.
88 *
89 * @param[in] name - The subscription name
90 */
91 void unsubscribeFromHostStateChange(const std::string& name)
92 {
93 _hostChangeCallbacks.erase(name);
94 }
95
Matt Spinlercad9c2b2019-12-02 15:42:01 -060096 /**
97 * @brief Returns the BMC firmware version
98 *
99 * @return std::string - The BMC version
100 */
101 virtual std::string getBMCFWVersion() const
102 {
103 return _bmcFWVersion;
104 }
105
106 /**
107 * @brief Returns the server firmware version
108 *
109 * @return std::string - The server firmware version
110 */
111 virtual std::string getServerFWVersion() const
112 {
113 return _serverFWVersion;
114 }
115
Matt Spinler4dcd3f42020-01-22 14:55:07 -0600116 /**
Matt Spinler677381b2020-01-23 10:04:29 -0600117 * @brief Returns the BMC FW version ID
118 *
119 * @return std::string - The BMC FW version ID
120 */
121 virtual std::string getBMCFWVersionID() const
122 {
123 return _bmcFWVersionID;
124 }
125
126 /**
Matt Spinler4dcd3f42020-01-22 14:55:07 -0600127 * @brief Returns the process name given its PID.
128 *
129 * @param[in] pid - The PID value as a string
130 *
131 * @return std::optional<std::string> - The name, or std::nullopt
132 */
133 std::optional<std::string> getProcessName(const std::string& pid) const
134 {
135 namespace fs = std::filesystem;
136
137 fs::path path{"/proc"};
138 path /= fs::path{pid} / "exe";
139
140 if (fs::exists(path))
141 {
142 return fs::read_symlink(path);
143 }
144
145 return std::nullopt;
146 }
147
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600148 /**
George Liu9ac0d9b2022-07-15 10:57:38 +0800149 * @brief Returns the time the system was running.
150 *
151 * @return std::optional<uint64_t> - The System uptime or std::nullopt
152 */
153 std::optional<uint64_t> getUptimeInSeconds() const
154 {
155 std::ifstream versionFile{"/proc/uptime"};
156 std::string line{};
157
158 std::getline(versionFile, line);
159 auto pos = line.find(" ");
160 if (pos == std::string::npos)
161 {
162 return std::nullopt;
163 }
164
165 uint64_t seconds = atol(line.substr(0, pos).c_str());
166 if (seconds == 0)
167 {
168 return std::nullopt;
169 }
170
171 return seconds;
172 }
173
174 /**
175 * @brief Returns the time the system was running.
176 *
177 * @param[in] seconds - The number of seconds the system has been running
178 *
179 * @return std::string - days/hours/minutes/seconds
180 */
181 std::string getBMCUptime(uint64_t seconds) const
182 {
183 time_t t(seconds);
184 tm* p = gmtime(&t);
185
186 std::string uptime = std::to_string(p->tm_year - 70) + "y " +
187 std::to_string(p->tm_yday) + "d " +
188 std::to_string(p->tm_hour) + "h " +
189 std::to_string(p->tm_min) + "m " +
190 std::to_string(p->tm_sec) + "s";
191
192 return uptime;
193 }
194
195 /**
196 * @brief Returns the system load average over the past 1 minute, 5 minutes
197 * and 15 minutes.
198 *
199 * @return std::string - The system load average
200 */
201 std::string getBMCLoadAvg() const
202 {
203 std::string loadavg{};
204
205 std::ifstream loadavgFile{"/proc/loadavg"};
206 std::string line;
207 std::getline(loadavgFile, line);
208
209 size_t count = 3;
210 for (size_t i = 0; i < count; i++)
211 {
212 auto pos = line.find(" ");
213 if (pos == std::string::npos)
214 {
215 return {};
216 }
217
218 if (i != count - 1)
219 {
220 loadavg.append(line.substr(0, pos + 1));
221 }
222 else
223 {
224 loadavg.append(line.substr(0, pos));
225 }
226
227 line = line.substr(pos + 1);
228 }
229
230 return loadavg;
231 }
232
233 /**
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600234 * @brief Returns the 'send event logs to host' setting.
235 *
236 * @return bool - If sending PELs to the host is enabled.
237 */
238 virtual bool getHostPELEnablement() const
239 {
240 return _sendPELsToHost;
241 }
242
Matt Spinler4aa23a12020-02-03 15:05:09 -0600243 /**
244 * @brief Returns the BMC state
245 *
246 * @return std::string - The BMC state property value
247 */
248 virtual std::string getBMCState() const
249 {
250 return _bmcState;
251 }
252
253 /**
254 * @brief Returns the Chassis state
255 *
256 * @return std::string - The chassis state property value
257 */
258 virtual std::string getChassisState() const
259 {
260 return _chassisState;
261 }
262
263 /**
264 * @brief Returns the chassis requested power
265 * transition value.
266 *
267 * @return std::string - The chassis transition property
268 */
269 virtual std::string getChassisTransition() const
270 {
271 return _chassisTransition;
272 }
273
274 /**
275 * @brief Returns the Host state
276 *
277 * @return std::string - The Host state property value
278 */
279 virtual std::string getHostState() const
280 {
281 return _hostState;
282 }
283
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600284 /**
Sumit Kumar2c36fdd2021-09-21 03:12:11 -0500285 * @brief Returns the Boot state
286 *
287 * @return std::string - The Boot state property value
288 */
289 virtual std::string getBootState() const
290 {
291 return _bootState;
292 }
293
294 /**
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600295 * @brief Returns the motherboard CCIN
296 *
297 * @return std::string The motherboard CCIN
298 */
Vijay Lobo81b4dca2021-04-29 00:04:00 -0500299 virtual std::string getMotherboardCCIN() const = 0;
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600300
Matt Spinler60c4e792020-03-13 13:45:36 -0500301 /**
Ben Tynere32b7e72021-05-18 12:38:40 -0500302 * @brief Returns the system IM
303 *
304 * @return std::string The system IM
305 */
306 virtual std::vector<uint8_t> getSystemIMKeyword() const = 0;
307
308 /**
Matt Spinler60c4e792020-03-13 13:45:36 -0500309 * @brief Get the fields from the inventory necessary for doing
310 * a callout on an inventory path.
311 *
312 * @param[in] inventoryPath - The item to get the data for
Matt Spinler60c4e792020-03-13 13:45:36 -0500313 * @param[out] fruPartNumber - Filled in with the VINI/FN keyword
314 * @param[out] ccin - Filled in with the VINI/CC keyword
315 * @param[out] serialNumber - Filled in with the VINI/SN keyword
316 */
317 virtual void getHWCalloutFields(const std::string& inventoryPath,
Matt Spinler60c4e792020-03-13 13:45:36 -0500318 std::string& fruPartNumber,
319 std::string& ccin,
320 std::string& serialNumber) const = 0;
321
Matt Spinler03984582020-04-09 13:17:58 -0500322 /**
Matt Spinler9b90e2a2020-04-14 10:59:04 -0500323 * @brief Get the location code for an inventory item.
324 *
325 * @param[in] inventoryPath - The item to get the data for
326 *
327 * @return std::string - The location code
328 */
329 virtual std::string
330 getLocationCode(const std::string& inventoryPath) const = 0;
331
332 /**
Matt Spinler6ea4d5f2020-05-20 13:31:07 -0500333 * @brief Get the list of system type names the system is called.
Matt Spinler03984582020-04-09 13:17:58 -0500334 *
Matt Spinler6ea4d5f2020-05-20 13:31:07 -0500335 * @return std::vector<std::string> - The list of names
Matt Spinler03984582020-04-09 13:17:58 -0500336 */
Matt Spinler1ab66962020-10-29 13:21:44 -0500337 virtual std::vector<std::string> getSystemNames() const = 0;
Matt Spinler03984582020-04-09 13:17:58 -0500338
Matt Spinler5fb24c12020-06-04 11:21:33 -0500339 /**
340 * @brief Fills in the placeholder 'Ufcs' in the passed in location
341 * code with the machine feature code and serial number, which
342 * is needed to create a valid location code.
343 *
344 * @param[in] locationCode - Location code value starting with Ufcs-, and
345 * if that isn't present it will be added first.
346 *
347 * @param[in] node - The node number the location is on.
348 *
349 * @return std::string - The expanded location code
350 */
351 virtual std::string expandLocationCode(const std::string& locationCode,
352 uint16_t node) const = 0;
353
354 /**
355 * @brief Returns the inventory path for the FRU that the location
356 * code represents.
357 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500358 * @param[in] locationCode - If an expanded location code, then the
359 * full location code.
360 * If not expanded, a location code value
361 * starting with Ufcs-, and if that isn't
362 * present it will be added first.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500363 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500364 * @param[in] node - The node number the location is on. Ignored if the
365 * expanded location code is passed in.
366 *
367 * @param[in] expanded - If the location code already has the relevent
368 * VPD fields embedded in it.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500369 *
370 * @return std::string - The inventory D-Bus object
371 */
Matt Spinler2f9225a2020-08-05 12:58:49 -0500372 virtual std::string getInventoryFromLocCode(const std::string& LocationCode,
373 uint16_t node,
374 bool expanded) const = 0;
Matt Spinler5fb24c12020-06-04 11:21:33 -0500375
Matt Spinler34a904c2020-08-05 14:53:28 -0500376 /**
Matt Spinler34a904c2020-08-05 14:53:28 -0500377 * @brief Sets the Asserted property on the LED group passed in.
378 *
379 * @param[in] ledGroup - The LED group D-Bus path
380 * @param[in] value - The value to set it to
381 */
382 virtual void assertLEDGroup(const std::string& ledGroup,
383 bool value) const = 0;
384
Matt Spinler993168d2021-04-07 16:05:03 -0500385 /**
386 * @brief Sets the Functional property on the OperationalStatus
387 * interface on a D-Bus object.
388 *
389 * @param[in] objectPath - The D-Bus object path
390 * @param[in] functional - The value
391 */
392 virtual void setFunctional(const std::string& objectPath,
393 bool functional) const = 0;
394
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500395 /**
Sumit Kumar76198a22021-07-15 05:59:57 -0500396 * @brief Sets the critical association on the D-Bus object.
397 *
398 * @param[in] objectPath - The D-Bus object path
399 */
400 virtual void
401 setCriticalAssociation(const std::string& objectPath) const = 0;
402
403 /**
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500404 * @brief Returns the manufacturing QuiesceOnError property
405 *
406 * @return bool - Manufacturing QuiesceOnError property
407 */
408 virtual bool getQuiesceOnError() const = 0;
409
Matt Spinler0d92b522021-06-16 13:28:17 -0600410 /**
411 * @brief Split location code into base and connector segments
412 *
413 * A location code that ends in '-Tx', where 'x' is a number,
414 * represents a connector, such as a USB cable connector.
415 *
416 * This function splits the passed in location code into a
417 * base and connector segment. e.g.:
418 * P0-T1 -> ['P0', '-T1']
419 * P0 -> ['P0', '']
420 *
421 * @param[in] locationCode - location code to split
422 * @return pair<string, string> - The base and connector segments
423 */
424 static std::pair<std::string, std::string>
425 extractConnectorFromLocCode(const std::string& locationCode);
426
Sumit Kumar9d43a722021-08-24 09:46:19 -0500427 /**
428 * @brief Returns the dump status
429 *
430 * @return bool dump status
431 */
432 virtual std::vector<bool>
433 checkDumpStatus(const std::vector<std::string>& type) const = 0;
434
Jayanth Othayothecaa2fc2021-11-05 02:02:52 -0500435 /**
436 * @brief Create guard record
437 *
438 * @param[in] binPath: phal devtree binary path used as key
439 * @param[in] type: Guard type
440 * @param[in] logPath: error log entry object path
441 */
442 virtual void createGuardRecord(const std::vector<uint8_t>& binPath,
443 const std::string& type,
444 const std::string& logPath) const = 0;
445
Sumit Kumar3e274432021-09-14 06:37:56 -0500446 /**
447 * @brief Create Progress SRC property on the boot progress
448 * interface on a D-Bus object.
449 *
450 * @param[in] priSRC - Primary SRC value (e.g. BD8D1001)
451 * @param[in] srcStruct - Full SRC base structure
452 */
453 virtual void
454 createProgressSRC(const uint64_t& priSRC,
455 const std::vector<uint8_t>& srcStruct) const = 0;
456
Sumit Kumar027bf282022-01-24 11:25:19 -0600457 /**
458 * @brief Get the list of unresolved OpenBMC event log ids that have an
459 * associated hardware isolation entry.
460 *
461 * @return std::vector<uint32_t> - The list of log ids
462 */
463 virtual std::vector<uint32_t> getLogIDWithHwIsolation() const = 0;
464
Matt Spinler19e89ce2019-11-06 13:02:23 -0600465 protected:
466 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -0600467 * @brief Sets the host on/off state and runs any
468 * callback functions (if there was a change).
469 */
Matt Spinler4aa23a12020-02-03 15:05:09 -0600470 void setHostUp(bool hostUp)
Matt Spinlera7d9d962019-11-06 15:01:25 -0600471 {
Matt Spinler4aa23a12020-02-03 15:05:09 -0600472 if (_hostUp != hostUp)
Matt Spinlera7d9d962019-11-06 15:01:25 -0600473 {
Matt Spinler4aa23a12020-02-03 15:05:09 -0600474 _hostUp = hostUp;
Matt Spinlera7d9d962019-11-06 15:01:25 -0600475
476 for (auto& [name, func] : _hostChangeCallbacks)
477 {
478 try
479 {
480 func(_hostUp);
481 }
Patrick Williams66491c62021-10-06 12:23:37 -0500482 catch (const std::exception& e)
Matt Spinlera7d9d962019-11-06 15:01:25 -0600483 {
484 using namespace phosphor::logging;
485 log<level::ERR>("A host state change callback threw "
486 "an exception");
487 }
488 }
489 }
490 }
491
492 /**
Matt Spinlercce14112019-12-11 14:20:36 -0600493 * @brief The hardware management console status. Always kept
494 * up to date.
495 */
496 bool _hmcManaged = false;
497
498 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -0600499 * @brief The host up status. Always kept up to date.
500 */
501 bool _hostUp = false;
502
503 /**
504 * @brief The map of host state change subscriber
505 * names to callback functions.
506 */
507 std::map<std::string, HostStateChangeFunc> _hostChangeCallbacks;
Matt Spinlercad9c2b2019-12-02 15:42:01 -0600508
509 /**
510 * @brief The BMC firmware version string
511 */
512 std::string _bmcFWVersion;
513
514 /**
515 * @brief The server firmware version string
516 */
517 std::string _serverFWVersion;
Matt Spinler677381b2020-01-23 10:04:29 -0600518
519 /**
520 * @brief The BMC firmware version ID string
521 */
522 std::string _bmcFWVersionID;
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600523
524 /**
525 * @brief If sending PELs is enabled.
526 *
527 * This is usually set to false in manufacturing test.
528 */
529 bool _sendPELsToHost = true;
Matt Spinler4aa23a12020-02-03 15:05:09 -0600530
531 /**
532 * @brief The BMC state property
533 */
534 std::string _bmcState;
535
536 /**
537 * @brief The Chassis current power state property
538 */
539 std::string _chassisState;
540
541 /**
542 * @brief The Chassis requested power transition property
543 */
544 std::string _chassisTransition;
545
546 /**
547 * @brief The host state property
548 */
549 std::string _hostState;
Sumit Kumar2c36fdd2021-09-21 03:12:11 -0500550
551 /**
552 * @brief The boot state property
553 */
554 std::string _bootState;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500555};
556
557/**
558 * @class DataInterface
559 *
560 * Concrete implementation of DataInterfaceBase.
561 */
562class DataInterface : public DataInterfaceBase
563{
564 public:
565 DataInterface() = delete;
566 ~DataInterface() = default;
567 DataInterface(const DataInterface&) = default;
568 DataInterface& operator=(const DataInterface&) = default;
569 DataInterface(DataInterface&&) = default;
570 DataInterface& operator=(DataInterface&&) = default;
571
572 /**
573 * @brief Constructor
574 *
575 * @param[in] bus - The sdbusplus bus object
576 */
Patrick Williams45e83522022-07-22 19:26:52 -0500577 explicit DataInterface(sdbusplus::bus_t& bus);
Matt Spinlerc8705e22019-09-11 12:36:07 -0500578
Matt Spinlerb3f51862019-12-09 13:55:10 -0600579 /**
Matt Spinlerc8705e22019-09-11 12:36:07 -0500580 * @brief Finds the D-Bus service name that hosts the
581 * passed in path and interface.
582 *
583 * @param[in] objectPath - The D-Bus object path
584 * @param[in] interface - The D-Bus interface
585 */
586 DBusService getService(const std::string& objectPath,
Matt Spinlerb3f51862019-12-09 13:55:10 -0600587 const std::string& interface) const;
Matt Spinler9cf3cfd2020-02-03 14:41:55 -0600588
Matt Spinlerc8705e22019-09-11 12:36:07 -0500589 /**
590 * @brief Wrapper for the 'GetAll' properties method call
591 *
592 * @param[in] service - The D-Bus service to call it on
593 * @param[in] objectPath - The D-Bus object path
594 * @param[in] interface - The interface to get the props on
595 *
596 * @return DBusPropertyMap - The property results
597 */
598 DBusPropertyMap getAllProperties(const std::string& service,
599 const std::string& objectPath,
Matt Spinler2a28c932020-02-03 14:23:40 -0600600 const std::string& interface) const;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500601 /**
Matt Spinlera7d9d962019-11-06 15:01:25 -0600602 * @brief Wrapper for the 'Get' properties method call
603 *
604 * @param[in] service - The D-Bus service to call it on
605 * @param[in] objectPath - The D-Bus object path
606 * @param[in] interface - The interface to get the property on
607 * @param[in] property - The property name
608 * @param[out] value - Filled in with the property value.
609 */
610 void getProperty(const std::string& service, const std::string& objectPath,
611 const std::string& interface, const std::string& property,
Matt Spinler2a28c932020-02-03 14:23:40 -0600612 DBusValue& value) const;
Vijay Lobo81b4dca2021-04-29 00:04:00 -0500613 /**
614 * @brief Returns the machine Type/Model
615 *
616 * @return string - The machine Type/Model string
617 */
618 std::string getMachineTypeModel() const override;
619
620 /**
621 * @brief Returns the machine serial number
622 *
623 * @return string - The machine serial number
624 */
625 std::string getMachineSerialNumber() const override;
626
627 /**
628 * @brief Returns the motherboard CCIN
629 *
630 * @return std::string The motherboard CCIN
631 */
632 std::string getMotherboardCCIN() const override;
Matt Spinler2a28c932020-02-03 14:23:40 -0600633
Matt Spinler60c4e792020-03-13 13:45:36 -0500634 /**
Ben Tynere32b7e72021-05-18 12:38:40 -0500635 * @brief Returns the system IM
636 *
637 * @return std::vector The system IM keyword in 4 byte vector
638 */
639 std::vector<uint8_t> getSystemIMKeyword() const override;
640
641 /**
Matt Spinler60c4e792020-03-13 13:45:36 -0500642 * @brief Get the fields from the inventory necessary for doing
643 * a callout on an inventory path.
644 *
645 * @param[in] inventoryPath - The item to get the data for
Matt Spinler60c4e792020-03-13 13:45:36 -0500646 * @param[out] fruPartNumber - Filled in with the VINI/FN keyword
647 * @param[out] ccin - Filled in with the VINI/CC keyword
648 * @param[out] serialNumber - Filled in with the VINI/SN keyword
649 */
650 void getHWCalloutFields(const std::string& inventoryPath,
Matt Spinler60c4e792020-03-13 13:45:36 -0500651 std::string& fruPartNumber, std::string& ccin,
652 std::string& serialNumber) const override;
653
Matt Spinler9b90e2a2020-04-14 10:59:04 -0500654 /**
655 * @brief Get the location code for an inventory item.
656 *
657 * Throws an exception if the inventory item doesn't have the
658 * location code interface.
659 *
660 * @param[in] inventoryPath - The item to get the data for
661 *
662 * @return std::string - The location code
663 */
664 std::string
665 getLocationCode(const std::string& inventoryPath) const override;
666
Matt Spinler5fb24c12020-06-04 11:21:33 -0500667 /**
Matt Spinler1ab66962020-10-29 13:21:44 -0500668 * @brief Get the list of system type names the system is called.
669 *
670 * @return std::vector<std::string> - The list of names
671 */
672 std::vector<std::string> getSystemNames() const override;
673
674 /**
Matt Spinler5fb24c12020-06-04 11:21:33 -0500675 * @brief Fills in the placeholder 'Ufcs' in the passed in location
676 * code with the machine feature code and serial number, which
677 * is needed to create a valid location code.
678 *
679 * @param[in] locationCode - Location code value starting with Ufcs-, and
680 * if that isn't present it will be added first.
681 *
682 * @param[in] node - The node number the location is one.
683 *
684 * @return std::string - The expanded location code
685 */
686 std::string expandLocationCode(const std::string& locationCode,
687 uint16_t node) const override;
688
689 /**
690 * @brief Returns the inventory path for the FRU that the location
691 * code represents.
692 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500693 * @param[in] locationCode - If an expanded location code, then the
694 * full location code.
695 * If not expanded, a location code value
696 * starting with Ufcs-, and if that isn't
697 * present it will be added first.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500698 *
Matt Spinler2f9225a2020-08-05 12:58:49 -0500699 * @param[in] node - The node number the location is on. Ignored if the
700 * expanded location code is passed in.
701 *
702 * @param[in] expanded - If the location code already has the relevent
703 * VPD fields embedded in it.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500704 *
705 * @return std::string - The inventory D-Bus object
706 */
Matt Spinler2f9225a2020-08-05 12:58:49 -0500707 std::string getInventoryFromLocCode(const std::string& locationCode,
708 uint16_t node,
709 bool expanded) const override;
Matt Spinler5fb24c12020-06-04 11:21:33 -0500710
Matt Spinler34a904c2020-08-05 14:53:28 -0500711 /**
Matt Spinler34a904c2020-08-05 14:53:28 -0500712 * @brief Sets the Asserted property on the LED group passed in.
713 *
714 * @param[in] ledGroup - The LED group D-Bus path
715 * @param[in] value - The value to set it to
716 */
717 void assertLEDGroup(const std::string& ledGroup, bool value) const override;
718
Matt Spinler993168d2021-04-07 16:05:03 -0500719 /**
720 * @brief Sets the Functional property on the OperationalStatus
721 * interface on a D-Bus object.
722 *
723 * @param[in] objectPath - The D-Bus object path
724 * @param[in] functional - The value
725 */
726 void setFunctional(const std::string& objectPath,
727 bool functional) const override;
728
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500729 /**
Sumit Kumar76198a22021-07-15 05:59:57 -0500730 * @brief Sets the critical association on the D-Bus object.
731 *
732 * @param[in] objectPath - The D-Bus object path
733 */
734 void setCriticalAssociation(const std::string& objectPath) const override;
735
736 /**
Sumit Kumar3b8ed7f2021-05-18 12:38:35 -0500737 * @brief Returns the manufacturing QuiesceOnError property
738 *
739 * @return bool - Manufacturing QuiesceOnError property
740 */
741 bool getQuiesceOnError() const override;
742
Sumit Kumar9d43a722021-08-24 09:46:19 -0500743 /**
744 * @brief Returns the dump status
745 *
746 * @param[in] type - The dump type to check for
747 *
748 * @return bool dump status
749 */
750 std::vector<bool>
751 checkDumpStatus(const std::vector<std::string>& type) const override;
752
Jayanth Othayothecaa2fc2021-11-05 02:02:52 -0500753 /**
754 * @brief Create guard record
755 *
756 * @param[in] binPath: phal devtree binary path used as key
757 * @param[in] type: Guard type
758 * @param[in] logPath: error log entry object path
759 */
760 void createGuardRecord(const std::vector<uint8_t>& binPath,
761 const std::string& type,
762 const std::string& logPath) const override;
763
Sumit Kumar3e274432021-09-14 06:37:56 -0500764 /**
765 * @brief Create Progress SRC property on the boot progress
766 * interface on a D-Bus object.
767 *
768 * @param[in] priSRC - Primary SRC value
769 * @param[in] srcStruct - Full SRC base structure
770 */
771 void
772 createProgressSRC(const uint64_t& priSRC,
773 const std::vector<uint8_t>& srcStruct) const override;
774
Sumit Kumar027bf282022-01-24 11:25:19 -0600775 /**
776 * @brief Get the list of unresolved OpenBMC event log ids that have an
777 * associated hardware isolation entry.
778 *
779 * @return std::vector<uint32_t> - The list of log ids
780 */
781 std::vector<uint32_t> getLogIDWithHwIsolation() const override;
782
Matt Spinler2a28c932020-02-03 14:23:40 -0600783 private:
784 /**
785 * @brief Reads the BMC firmware version string and puts it into
786 * _bmcFWVersion.
787 */
788 void readBMCFWVersion();
Matt Spinlera7d9d962019-11-06 15:01:25 -0600789
790 /**
Matt Spinler2a28c932020-02-03 14:23:40 -0600791 * @brief Reads the server firmware version string and puts it into
792 * _serverFWVersion.
Matt Spinlerc8705e22019-09-11 12:36:07 -0500793 */
Matt Spinler2a28c932020-02-03 14:23:40 -0600794 void readServerFWVersion();
Matt Spinlerc8705e22019-09-11 12:36:07 -0500795
796 /**
Matt Spinler2a28c932020-02-03 14:23:40 -0600797 * @brief Reads the BMC firmware version ID and puts it into
798 * _bmcFWVersionID.
Matt Spinlera7d9d962019-11-06 15:01:25 -0600799 */
Matt Spinler2a28c932020-02-03 14:23:40 -0600800 void readBMCFWVersionID();
Matt Spinlera7d9d962019-11-06 15:01:25 -0600801
802 /**
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600803 * @brief Finds all D-Bus paths that contain any of the interfaces
804 * passed in, by using GetSubTreePaths.
805 *
806 * @param[in] interfaces - The desired interfaces
807 *
808 * @return The D-Bus paths.
809 */
810 DBusPathList getPaths(const DBusInterfaceList& interfaces) const;
811
812 /**
813 * @brief The interfacesAdded callback used on the inventory to
814 * find the D-Bus object that has the motherboard interface.
815 * When the motherboard is found, it then adds a PropertyWatcher
816 * for the motherboard CCIN.
817 */
Patrick Williams45e83522022-07-22 19:26:52 -0500818 void motherboardIfaceAdded(sdbusplus::message_t& msg);
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600819
820 /**
Matt Spinler0e4d72e2020-08-05 12:36:53 -0500821 * @brief Adds the Ufcs- prefix to the location code passed in
822 * if necessary.
Matt Spinler5fb24c12020-06-04 11:21:33 -0500823 *
Matt Spinler0e4d72e2020-08-05 12:36:53 -0500824 * Needed because the location codes that come back from the
Matt Spinler5fb24c12020-06-04 11:21:33 -0500825 * message registry and device callout JSON don't have it.
826 *
827 * @param[in] - The location code without a prefix, like P1-C1
828 *
829 * @return std::string - The location code with the prefix
830 */
831 static std::string addLocationCodePrefix(const std::string& locationCode);
832
833 /**
Matt Spinler2a28c932020-02-03 14:23:40 -0600834 * @brief The D-Bus property or interface watchers that have callbacks
835 * registered that will set members in this class when
836 * they change.
Matt Spinlerc8705e22019-09-11 12:36:07 -0500837 */
Matt Spinler2a28c932020-02-03 14:23:40 -0600838 std::vector<std::unique_ptr<DBusWatcher>> _properties;
Matt Spinlera7d9d962019-11-06 15:01:25 -0600839
840 /**
Matt Spinlerc8705e22019-09-11 12:36:07 -0500841 * @brief The sdbusplus bus object for making D-Bus calls.
842 */
Patrick Williams45e83522022-07-22 19:26:52 -0500843 sdbusplus::bus_t& _bus;
Matt Spinlerb3d488f2020-02-21 15:30:46 -0600844
845 /**
846 * @brief The interfacesAdded match object used to wait for inventory
847 * interfaces to show up, so that the object with the motherboard
848 * interface can be found. After it is found, this object is
849 * deleted.
850 */
851 std::unique_ptr<sdbusplus::bus::match_t> _inventoryIfacesAddedMatch;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500852};
853
854} // namespace pels
855} // namespace openpower