blob: 749abe33357dc0b69f40d09fc0989bc62e40a718 [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
19#include <string>
20#include <sdbusplus/asio/object_server.hpp>
21#include <phosphor-logging/log.hpp>
22#include <boost/asio.hpp>
23
AppaRao Pulie4e95652019-07-19 16:52:01 +053024#include "pfr.hpp"
25
AppaRao Pulie63eeda2019-07-05 16:25:38 +053026namespace intel
27{
28namespace pfr
29{
30
AppaRao Pulie4e95652019-07-19 16:52:01 +053031static constexpr const char *versionPurposeBMC =
32 "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
33static constexpr const char *versionPurposeHost =
34 "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
35static constexpr const char *versionPurposeOther =
36 "xyz.openbmc_project.Software.Version.VersionPurpose.Other";
37
38static constexpr const char *versionStr = "Version";
39static constexpr const char *ufmProvisionedStr = "ufm_provisioned";
40static constexpr const char *ufmLockedStr = "ufm_locked";
41
AppaRao Pulie63eeda2019-07-05 16:25:38 +053042class PfrVersion
43{
44 public:
45 PfrVersion(sdbusplus::asio::object_server &srv_,
46 std::shared_ptr<sdbusplus::asio::connection> &conn_,
AppaRao Pulie4e95652019-07-19 16:52:01 +053047 const std::string &path_, const ImageType &imgType_,
48 const std::string &purpose_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053049 ~PfrVersion() = default;
50
51 std::shared_ptr<sdbusplus::asio::connection> conn;
52
AppaRao Pulie4e95652019-07-19 16:52:01 +053053 void updateVersion();
54
AppaRao Pulie63eeda2019-07-05 16:25:38 +053055 private:
56 sdbusplus::asio::object_server &server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053057 std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface;
58 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053059
60 std::string path;
61 std::string version;
62 std::string purpose;
AppaRao Pulie4e95652019-07-19 16:52:01 +053063 ImageType imgType;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053064};
65
66class PfrConfig
67{
68 public:
69 PfrConfig(sdbusplus::asio::object_server &srv_,
70 std::shared_ptr<sdbusplus::asio::connection> &conn_);
71 ~PfrConfig() = default;
72
73 std::shared_ptr<sdbusplus::asio::connection> conn;
74
AppaRao Pulie4e95652019-07-19 16:52:01 +053075 void updateProvisioningStatus();
76
AppaRao Pulie63eeda2019-07-05 16:25:38 +053077 private:
78 sdbusplus::asio::object_server &server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053079 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrCfgIface;
80 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053081
AppaRao Pulie4e95652019-07-19 16:52:01 +053082 bool ufmProvisioned;
83 bool ufmLocked;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053084};
85
86} // namespace pfr
87} // namespace intel