AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 1 | /* |
| 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 Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 19 | #include "pfr.hpp" |
| 20 | |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 21 | #include <boost/asio.hpp> |
| 22 | #include <phosphor-logging/log.hpp> |
| 23 | #include <sdbusplus/asio/object_server.hpp> |
| 24 | |
| 25 | #include <string> |
| 26 | |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 27 | namespace pfr |
| 28 | { |
| 29 | |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 30 | static constexpr const char* versionPurposeBMC = |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 31 | "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"; |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 32 | static constexpr const char* versionPurposeHost = |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 33 | "xyz.openbmc_project.Software.Version.VersionPurpose.Host"; |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 34 | static constexpr const char* versionPurposeOther = |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 35 | "xyz.openbmc_project.Software.Version.VersionPurpose.Other"; |
| 36 | |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 37 | static constexpr const char* versionStr = "Version"; |
| 38 | static constexpr const char* ufmProvisionedStr = "UfmProvisioned"; |
| 39 | static constexpr const char* ufmLockedStr = "UfmLocked"; |
Chalapathi Venkataramashetty | f881970 | 2021-02-03 09:43:46 +0000 | [diff] [blame] | 40 | static constexpr const char* ufmSupportStr = "UfmSupport"; |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 41 | |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 42 | class PfrVersion |
| 43 | { |
| 44 | public: |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 45 | PfrVersion(sdbusplus::asio::object_server& srv_, |
| 46 | std::shared_ptr<sdbusplus::asio::connection>& conn_, |
| 47 | const std::string& path_, const ImageType& imgType_, |
| 48 | const std::string& purpose_); |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 49 | ~PfrVersion() = default; |
| 50 | |
| 51 | std::shared_ptr<sdbusplus::asio::connection> conn; |
| 52 | |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 53 | void updateVersion(); |
| 54 | |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 55 | private: |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 56 | sdbusplus::asio::object_server& server; |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 57 | std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface; |
| 58 | bool internalSet = false; |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 59 | |
| 60 | std::string path; |
| 61 | std::string version; |
| 62 | std::string purpose; |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 63 | ImageType imgType; |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | class PfrConfig |
| 67 | { |
| 68 | public: |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 69 | PfrConfig(sdbusplus::asio::object_server& srv_, |
| 70 | std::shared_ptr<sdbusplus::asio::connection>& conn_); |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 71 | ~PfrConfig() = default; |
| 72 | |
| 73 | std::shared_ptr<sdbusplus::asio::connection> conn; |
| 74 | |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 75 | void updateProvisioningStatus(); |
| 76 | |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 77 | private: |
AppaRao Puli | 67d184c | 2020-05-29 00:48:33 +0530 | [diff] [blame] | 78 | sdbusplus::asio::object_server& server; |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 79 | std::shared_ptr<sdbusplus::asio::dbus_interface> pfrCfgIface; |
| 80 | bool internalSet = false; |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 81 | |
AppaRao Puli | e4e9565 | 2019-07-19 16:52:01 +0530 | [diff] [blame] | 82 | bool ufmProvisioned; |
| 83 | bool ufmLocked; |
Chalapathi Venkataramashetty | f881970 | 2021-02-03 09:43:46 +0000 | [diff] [blame] | 84 | bool ufmSupport; |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 85 | }; |
| 86 | |
Chalapathi Venkataramashetty | bcc7ce1 | 2021-05-17 04:27:21 +0000 | [diff] [blame] | 87 | // Firmware resiliency major map. |
| 88 | // {<CPLD association>, {<Redfish MessageID>, <Error reason> }) |
| 89 | static const boost::container::flat_map<uint8_t, |
| 90 | std::pair<std::string, std::string>> |
| 91 | majorErrorCodeMapRev2 = { |
| 92 | {0x03, {"FirmwareResiliencyError", "Firmware update failed"}}}; |
| 93 | |
AppaRao Puli | e63eeda | 2019-07-05 16:25:38 +0530 | [diff] [blame] | 94 | } // namespace pfr |