blob: 63fb6ac5eda004156ddbdf330e22baf670a9cdb2 [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>
Jason M. Bills70108442022-09-21 12:32:16 -070022#include <boost/container/flat_map.hpp>
Alex Schendel5cf320c2021-12-09 12:11:04 -080023#include <phosphor-logging/lg2.hpp>
AppaRao Puli67d184c2020-05-29 00:48:33 +053024#include <phosphor-logging/log.hpp>
25#include <sdbusplus/asio/object_server.hpp>
26
27#include <string>
28
AppaRao Pulie63eeda2019-07-05 16:25:38 +053029namespace pfr
30{
31
AppaRao Puli67d184c2020-05-29 00:48:33 +053032static constexpr const char* versionPurposeBMC =
AppaRao Pulie4e95652019-07-19 16:52:01 +053033 "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
AppaRao Puli67d184c2020-05-29 00:48:33 +053034static constexpr const char* versionPurposeHost =
AppaRao Pulie4e95652019-07-19 16:52:01 +053035 "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
AppaRao Puli67d184c2020-05-29 00:48:33 +053036static constexpr const char* versionPurposeOther =
AppaRao Pulie4e95652019-07-19 16:52:01 +053037 "xyz.openbmc_project.Software.Version.VersionPurpose.Other";
38
AppaRao Puli67d184c2020-05-29 00:48:33 +053039static constexpr const char* versionStr = "Version";
40static constexpr const char* ufmProvisionedStr = "UfmProvisioned";
41static constexpr const char* ufmLockedStr = "UfmLocked";
Chalapathi Venkataramashettyf8819702021-02-03 09:43:46 +000042static constexpr const char* ufmSupportStr = "UfmSupport";
AppaRao Pulie4e95652019-07-19 16:52:01 +053043
AppaRao Pulie63eeda2019-07-05 16:25:38 +053044class PfrVersion
45{
46 public:
AppaRao Puli67d184c2020-05-29 00:48:33 +053047 PfrVersion(sdbusplus::asio::object_server& srv_,
48 std::shared_ptr<sdbusplus::asio::connection>& conn_,
49 const std::string& path_, const ImageType& imgType_,
50 const std::string& purpose_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053051 ~PfrVersion() = default;
52
53 std::shared_ptr<sdbusplus::asio::connection> conn;
54
AppaRao Pulie4e95652019-07-19 16:52:01 +053055 void updateVersion();
56
AppaRao Pulie63eeda2019-07-05 16:25:38 +053057 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053058 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053059 std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface;
60 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053061
62 std::string path;
63 std::string version;
64 std::string purpose;
AppaRao Pulie4e95652019-07-19 16:52:01 +053065 ImageType imgType;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053066};
67
68class PfrConfig
69{
70 public:
AppaRao Puli67d184c2020-05-29 00:48:33 +053071 PfrConfig(sdbusplus::asio::object_server& srv_,
72 std::shared_ptr<sdbusplus::asio::connection>& conn_);
AppaRao Pulie63eeda2019-07-05 16:25:38 +053073 ~PfrConfig() = default;
74
75 std::shared_ptr<sdbusplus::asio::connection> conn;
76
AppaRao Pulie4e95652019-07-19 16:52:01 +053077 void updateProvisioningStatus();
78
Zhikui Renc96f37d2021-12-08 15:40:51 -080079 bool getPfrProvisioned() const
80 {
81 return ufmProvisioned;
82 }
83
AppaRao Pulie63eeda2019-07-05 16:25:38 +053084 private:
AppaRao Puli67d184c2020-05-29 00:48:33 +053085 sdbusplus::asio::object_server& server;
AppaRao Pulie4e95652019-07-19 16:52:01 +053086 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrCfgIface;
deepak kumar agrawalb29a15c2022-03-25 07:45:57 +000087 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrMBIface;
88
AppaRao Pulie4e95652019-07-19 16:52:01 +053089 bool internalSet = false;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053090
AppaRao Pulie4e95652019-07-19 16:52:01 +053091 bool ufmProvisioned;
92 bool ufmLocked;
Chalapathi Venkataramashettyf8819702021-02-03 09:43:46 +000093 bool ufmSupport;
AppaRao Pulie63eeda2019-07-05 16:25:38 +053094};
95
Chalapathi Venkataramashettybcc7ce12021-05-17 04:27:21 +000096// Firmware resiliency major map.
97// {<CPLD association>, {<Redfish MessageID>, <Error reason> })
98static const boost::container::flat_map<uint8_t,
99 std::pair<std::string, std::string>>
100 majorErrorCodeMapRev2 = {
101 {0x03, {"FirmwareResiliencyError", "Firmware update failed"}}};
102
Zhikui Renc96f37d2021-12-08 15:40:51 -0800103// postcode (platform state) map.
104static const boost::container::flat_map<uint8_t, std::string> postcodeMap = {
105 {0x00, "Postcode unavailable"},
106 {0x01, "CPLD Nios II processor waiting to start"},
107 {0x02, "CPLD Nios II processor started"},
108 {0x03, "Enter T-1"},
109 {0x04, "T-1 reserved 4"},
110 {0x05, "T-1 Reserved 5"},
111 {0x06, "BMC flash authentication"},
112 {0x07, "PCH/CPU flash authentication"},
113 {0x08, "Lockdown due to authentication failures"},
114 {0x09, "Enter T0"},
115 {0x0A, "T0 BMC booted"},
116 {0x0B, "T0 ME booted"},
117 {0x0C, "T0 Modular booted"},
118 {0x0C, "T0 BIOS booted"},
119 {0x0E, "T0 boot complete"},
120 {0x0F, "T0 Reserved 0xF"},
121 {0x10, "PCH/CPU firmware update"},
122 {0x11, "BMC firmware update"},
123 {0x12, "CPLD update (in CPLD Active Image)"},
124 {0x13, "CPLD update (in CPLD ROM)"},
125 {0x14, "PCH/CPU firmware volume update"},
126 {0x15, "CPLD Nios II processor waiting to start"},
sri anjaneyulu alapatid5c49902023-06-20 11:05:40 +0000127 {0x16, "Combined CPLD authentication"},
128 {0x17, "Combined CPLD booted from CFM0"},
129 {0x18, "Combined CPLD booted from Active CFM"},
130 {0x19, "Combined CPLD image update"},
131 {0x1A, "Combined CPLD image recovery"},
132 {0x1B, "Combined CPLD boot from CFM0 due to recovery failure"},
Zhikui Renc96f37d2021-12-08 15:40:51 -0800133 {0x40, "T-1 firmware recovery due to authentication failure"},
134 {0x41, "T-1 forced active firmware recovery"},
135 {0x42, "WDT timeout recovery"},
136 {0x43, "CPLD recovery (in CPLD ROM)"},
137 {0x44, "Lockdown due to PIT L1"},
138 {0x45, "PIT L2 firmware sealed"},
139 {0x46, "Lockdown due to PIT L2 PCH/CPU firmware hash mismatch"},
140 {0x47, "Lockdown due to PIT L2 BMC firmware hash mismatch"},
141 {0x48, "Reserved 0x48"}};
142
143class PfrPostcode
144{
145 public:
146 PfrPostcode(sdbusplus::asio::object_server& srv_,
147 std::shared_ptr<sdbusplus::asio::connection>& conn_);
148 ~PfrPostcode() = default;
149
150 std::shared_ptr<sdbusplus::asio::connection> conn;
151
152 void updatePostcode();
153
154 private:
155 sdbusplus::asio::object_server& server;
156 std::shared_ptr<sdbusplus::asio::dbus_interface> pfrPostcodeIface;
157 bool internalSet = false;
158 uint8_t postcode;
159};
160
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530161} // namespace pfr