blob: c0d6fd50f84708069327e6dda5807db775000d15 [file] [log] [blame]
AppaRao Pulie63eeda2019-07-05 16:25:38 +05301/*
2// Copyright (c) 2019 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16
17#pragma once
18
AppaRao Pulie4e95652019-07-19 16:52:01 +053019#include "pfr.hpp"
20
AppaRao Puli67d184c2020-05-29 00:48:33 +053021#include <boost/asio.hpp>
Alex Schendel5cf320c2021-12-09 12:11:04 -080022#include <phosphor-logging/lg2.hpp>
AppaRao Puli67d184c2020-05-29 00:48:33 +053023#include <phosphor-logging/log.hpp>
24#include <sdbusplus/asio/object_server.hpp>
25
26#include <string>
27
AppaRao Pulie63eeda2019-07-05 16:25:38 +053028namespace pfr
29{
30
AppaRao Puli67d184c2020-05-29 00:48:33 +053031static constexpr const char* versionPurposeBMC =
AppaRao Pulie4e95652019-07-19 16:52:01 +053032 "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
AppaRao Puli67d184c2020-05-29 00:48:33 +053033static constexpr const char* versionPurposeHost =
AppaRao Pulie4e95652019-07-19 16:52:01 +053034 "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
AppaRao Puli67d184c2020-05-29 00:48:33 +053035static constexpr const char* versionPurposeOther =
AppaRao Pulie4e95652019-07-19 16:52:01 +053036 "xyz.openbmc_project.Software.Version.VersionPurpose.Other";
37
AppaRao Puli67d184c2020-05-29 00:48:33 +053038static constexpr const char* versionStr = "Version";
39static constexpr const char* ufmProvisionedStr = "UfmProvisioned";
40static constexpr const char* ufmLockedStr = "UfmLocked";
Chalapathi Venkataramashettyf8819702021-02-03 09:43:46 +000041static constexpr const char* ufmSupportStr = "UfmSupport";
AppaRao Pulie4e95652019-07-19 16:52:01 +053042
AppaRao Pulie63eeda2019-07-05 16:25:38 +053043class PfrVersion
44{
45 public:
AppaRao Puli67d184c2020-05-29 00:48:33 +053046 PfrVersion(sdbusplus::asio::object_server& srv_,
47 std::shared_ptr<sdbusplus::asio::connection>& conn_,
48 const std::string& path_, const ImageType& imgType_,
49 const std::string& purpose_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053050 ~PfrVersion() = default;
51
52 std::shared_ptr<sdbusplus::asio::connection> conn;
53
AppaRao Pulie4e95652019-07-19 16:52:01 +053054 void updateVersion();
55
AppaRao Pulie63eeda2019-07-05 16:25:38 +053056 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053057 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053058 std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface;
59 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053060
61 std::string path;
62 std::string version;
63 std::string purpose;
AppaRao Pulie4e95652019-07-19 16:52:01 +053064 ImageType imgType;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053065};
66
67class PfrConfig
68{
69 public:
AppaRao Puli67d184c2020-05-29 00:48:33 +053070 PfrConfig(sdbusplus::asio::object_server& srv_,
71 std::shared_ptr<sdbusplus::asio::connection>& conn_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053072 ~PfrConfig() = default;
73
74 std::shared_ptr<sdbusplus::asio::connection> conn;
75
AppaRao Pulie4e95652019-07-19 16:52:01 +053076 void updateProvisioningStatus();
77
AppaRao Pulie63eeda2019-07-05 16:25:38 +053078 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053079 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053080 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrCfgIface;
81 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053082
AppaRao Pulie4e95652019-07-19 16:52:01 +053083 bool ufmProvisioned;
84 bool ufmLocked;
Chalapathi Venkataramashettyf8819702021-02-03 09:43:46 +000085 bool ufmSupport;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053086};
87
Chalapathi Venkataramashettybcc7ce12021-05-17 04:27:21 +000088// Firmware resiliency major map.
89// {<CPLD association>, {<Redfish MessageID>, <Error reason> })
90static const boost::container::flat_map<uint8_t,
91 std::pair<std::string, std::string>>
92 majorErrorCodeMapRev2 = {
93 {0x03, {"FirmwareResiliencyError", "Firmware update failed"}}};
94
AppaRao Pulie63eeda2019-07-05 16:25:38 +053095} // namespace pfr