blob: 13091d756ddddbba5787e48f007990550e3ab71e [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>
22#include <phosphor-logging/log.hpp>
23#include <sdbusplus/asio/object_server.hpp>
24
25#include <string>
26
AppaRao Pulie63eeda2019-07-05 16:25:38 +053027namespace pfr
28{
29
AppaRao Puli67d184c2020-05-29 00:48:33 +053030static constexpr const char* versionPurposeBMC =
AppaRao Pulie4e95652019-07-19 16:52:01 +053031 "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
AppaRao Puli67d184c2020-05-29 00:48:33 +053032static constexpr const char* versionPurposeHost =
AppaRao Pulie4e95652019-07-19 16:52:01 +053033 "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
AppaRao Puli67d184c2020-05-29 00:48:33 +053034static constexpr const char* versionPurposeOther =
AppaRao Pulie4e95652019-07-19 16:52:01 +053035 "xyz.openbmc_project.Software.Version.VersionPurpose.Other";
36
AppaRao Puli67d184c2020-05-29 00:48:33 +053037static constexpr const char* versionStr = "Version";
38static constexpr const char* ufmProvisionedStr = "UfmProvisioned";
39static constexpr const char* ufmLockedStr = "UfmLocked";
AppaRao Pulie4e95652019-07-19 16:52:01 +053040
AppaRao Pulie63eeda2019-07-05 16:25:38 +053041class PfrVersion
42{
43 public:
AppaRao Puli67d184c2020-05-29 00:48:33 +053044 PfrVersion(sdbusplus::asio::object_server& srv_,
45 std::shared_ptr<sdbusplus::asio::connection>& conn_,
46 const std::string& path_, const ImageType& imgType_,
47 const std::string& purpose_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053048 ~PfrVersion() = default;
49
50 std::shared_ptr<sdbusplus::asio::connection> conn;
51
AppaRao Pulie4e95652019-07-19 16:52:01 +053052 void updateVersion();
53
AppaRao Pulie63eeda2019-07-05 16:25:38 +053054 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053055 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053056 std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface;
57 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053058
59 std::string path;
60 std::string version;
61 std::string purpose;
AppaRao Pulie4e95652019-07-19 16:52:01 +053062 ImageType imgType;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053063};
64
65class PfrConfig
66{
67 public:
AppaRao Puli67d184c2020-05-29 00:48:33 +053068 PfrConfig(sdbusplus::asio::object_server& srv_,
69 std::shared_ptr<sdbusplus::asio::connection>& conn_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053070 ~PfrConfig() = default;
71
72 std::shared_ptr<sdbusplus::asio::connection> conn;
73
AppaRao Pulie4e95652019-07-19 16:52:01 +053074 void updateProvisioningStatus();
75
AppaRao Pulie63eeda2019-07-05 16:25:38 +053076 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053077 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053078 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrCfgIface;
79 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053080
AppaRao Pulie4e95652019-07-19 16:52:01 +053081 bool ufmProvisioned;
82 bool ufmLocked;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053083};
84
85} // namespace pfr