blob: 91a950440e9172f56a66f9a18382425554f612a9 [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#include "pfr_mgr.hpp"
18#include "pfr.hpp"
19
20namespace intel
21{
22namespace pfr
23{
24
25static constexpr uint8_t activeImage = 0;
26static constexpr uint8_t recoveryImage = 1;
27
28PfrVersion::PfrVersion(sdbusplus::asio::object_server &srv_,
29 std::shared_ptr<sdbusplus::asio::connection> &conn_,
30 const std::string &path_) :
31 server(srv_),
32 conn(conn_), path(path_)
33{
34 if (path == "bmc_active")
35 {
36 purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
37 ImageType imgType = ImageType::bmcActive;
38 version = getVersionInfoCPLD(imgType);
39 }
40 else if (path == "bmc_recovery")
41 {
42 purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
43 ImageType imgType = ImageType::bmcRecovery;
44 version = getVersionInfoCPLD(imgType);
45 }
46 else if (path == "bios_active")
47 {
48 purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
49 ImageType imgType = ImageType::biosActive;
50 version = getVersionInfoCPLD(imgType);
51 }
52 else if (path == "bios_recovery")
53 {
54 purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
55 ImageType imgType = ImageType::biosRecovery;
56 version = getVersionInfoCPLD(imgType);
57 }
58 else if (path == "cpld")
59 {
60 purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.Other";
61 ImageType imgType = ImageType::cpld;
62 version = getVersionInfoCPLD(imgType);
63 }
64 else
65 {
66 phosphor::logging::log<phosphor::logging::level::ERR>(
67 "Invalid path specified for PfrVersion");
68 return;
69 }
70
71 std::string objPath = "/xyz/openbmc_project/software/" + path;
72 auto iface =
73 server.add_interface(objPath, "xyz.openbmc_project.Software.Version");
74 iface->register_property("Purpose", purpose);
75 iface->register_property("Version", version);
76
77 iface->initialize();
78}
79
80bool PfrConfig::getPFRProvisionedState()
81{
82 bool ufmProvisioned = false;
83 bool ufmLocked = false;
84 getProvisioningStatus(ufmLocked, ufmProvisioned);
85
86 return ufmProvisioned;
87}
88
89PfrConfig::PfrConfig(sdbusplus::asio::object_server &srv_,
90 std::shared_ptr<sdbusplus::asio::connection> &conn_) :
91 server(srv_),
92 conn(conn_)
93{
94 auto pfrIntf =
95 server.add_interface("/xyz/openbmc_project/intel_pfr",
96 "xyz.openbmc_project.Intel_PFR.Attributes");
97
98 pfrIntf->register_property("provisioned_state", getPFRProvisionedState());
99
100 pfrIntf->initialize();
101}
102
103} // namespace pfr
104} // namespace intel