blob: d773e4f7cf2405d7d832f04c0ca05979dc2ae72f [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
Zhikui Renc96f37d2021-12-08 15:40:51 -080078 bool getPfrProvisioned() const
79 {
80 return ufmProvisioned;
81 }
82
AppaRao Pulie63eeda2019-07-05 16:25:38 +053083 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053084 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053085 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrCfgIface;
86 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053087
AppaRao Pulie4e95652019-07-19 16:52:01 +053088 bool ufmProvisioned;
89 bool ufmLocked;
Chalapathi Venkataramashettyf8819702021-02-03 09:43:46 +000090 bool ufmSupport;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053091};
92
Chalapathi Venkataramashettybcc7ce12021-05-17 04:27:21 +000093// Firmware resiliency major map.
94// {<CPLD association>, {<Redfish MessageID>, <Error reason> })
95static const boost::container::flat_map<uint8_t,
96 std::pair<std::string, std::string>>
97 majorErrorCodeMapRev2 = {
98 {0x03, {"FirmwareResiliencyError", "Firmware update failed"}}};
99
Zhikui Renc96f37d2021-12-08 15:40:51 -0800100// postcode (platform state) map.
101static const boost::container::flat_map<uint8_t, std::string> postcodeMap = {
102 {0x00, "Postcode unavailable"},
103 {0x01, "CPLD Nios II processor waiting to start"},
104 {0x02, "CPLD Nios II processor started"},
105 {0x03, "Enter T-1"},
106 {0x04, "T-1 reserved 4"},
107 {0x05, "T-1 Reserved 5"},
108 {0x06, "BMC flash authentication"},
109 {0x07, "PCH/CPU flash authentication"},
110 {0x08, "Lockdown due to authentication failures"},
111 {0x09, "Enter T0"},
112 {0x0A, "T0 BMC booted"},
113 {0x0B, "T0 ME booted"},
114 {0x0C, "T0 Modular booted"},
115 {0x0C, "T0 BIOS booted"},
116 {0x0E, "T0 boot complete"},
117 {0x0F, "T0 Reserved 0xF"},
118 {0x10, "PCH/CPU firmware update"},
119 {0x11, "BMC firmware update"},
120 {0x12, "CPLD update (in CPLD Active Image)"},
121 {0x13, "CPLD update (in CPLD ROM)"},
122 {0x14, "PCH/CPU firmware volume update"},
123 {0x15, "CPLD Nios II processor waiting to start"},
124 {0x16, "Reserved 0x16"},
125 {0x40, "T-1 firmware recovery due to authentication failure"},
126 {0x41, "T-1 forced active firmware recovery"},
127 {0x42, "WDT timeout recovery"},
128 {0x43, "CPLD recovery (in CPLD ROM)"},
129 {0x44, "Lockdown due to PIT L1"},
130 {0x45, "PIT L2 firmware sealed"},
131 {0x46, "Lockdown due to PIT L2 PCH/CPU firmware hash mismatch"},
132 {0x47, "Lockdown due to PIT L2 BMC firmware hash mismatch"},
133 {0x48, "Reserved 0x48"}};
134
135class PfrPostcode
136{
137 public:
138 PfrPostcode(sdbusplus::asio::object_server& srv_,
139 std::shared_ptr<sdbusplus::asio::connection>& conn_);
140 ~PfrPostcode() = default;
141
142 std::shared_ptr<sdbusplus::asio::connection> conn;
143
144 void updatePostcode();
145
146 private:
147 sdbusplus::asio::object_server& server;
148 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrPostcodeIface;
149 bool internalSet = false;
150 uint8_t postcode;
151};
152
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530153} // namespace pfr