Define Redfish interface "/Registries/Bios" and enable Attributes property
1. Define Redfish interface "/Registries/Bios" for BIOS Attribute Registry
RBC Daemon provide method to get BIOS attribute registry.
2. Enable Attributes property for BIOS resource
3. Define Redfish interface "/Systems/system/Bios/Settings" for BIOS
settings
4. RBC daemon is at
https://gerrit.openbmc-project.xyz/#/c/openbmc/bios-settings-mgr/+/35563/
5. IPMI command implementation is at
https://gerrit.openbmc-project.xyz/#/c/openbmc/intel-ipmi-oem/+/30827/
6. Property design is at
https://github.com/openbmc/phosphor-dbus-interfaces/tree/master/xyz/openbmc_project/BIOSConfig
7. Design doc is at
https://github.com/openbmc/docs/blob/master/designs/remote-bios-configuration.md
8. There will be 95 test cases for this feature in the validation team.
Tested:
1. Use postman could get all the attributes in bios
resouce, get bios settings, get bios attribute
registry.
https://IP_ADDR/redfish/v1/Systems/system/Bios
{
"@Redfish.Settings": {
"@odata.type": "#Settings.v1_3_0.Settings",
"SettingsObject": {
"@odata.id": "/redfish/v1/Systems/system/Bios/Settings"
}
},
"@odata.id": "/redfish/v1/Systems/system/Bios",
"@odata.type": "#Bios.v1_1_0.Bios",
"Actions": {
"#Bios.ChangePassword": {
"target": "/redfish/v1/Systems/system/Bios/Actions/Bios.ChangePassword"
},
"#Bios.ResetBios": {
"target": "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"
}
},
"AttributeRegistry": "BiosAttributeRegistry",
"Attributes": {
"attr0": "current value"
},
"Description": "BIOS Configuration Service",
"Id": "BIOS",
"Links": {
"ActiveSoftwareImage": {
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/bios_active"
},
"SoftwareImages": [
{
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/bios_active"
}
],
"SoftwareImages@odata.count": 1
},
"Name": "BIOS Configuration"
}
Redfish interface: https://BMCIP/redfish/v1/Registries/BiosAttributeRegistry
{
"@odata.id": "/redfish/v1/Registries/BiosAttributeRegistry",
"@odata.type": "#MessageRegistryFile.v1_1_0.MessageRegistryFile",
"Description": "BiosAttributeRegistry Message Registry File Location",
"Id": "BiosAttributeRegistry",
"Languages": [
"en"
],
"Languages@odata.count": 1,
"Location": [
{
"Language": "en",
"Uri": "/redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry"
}
],
"Location@odata.count": 1,
"Name": "BiosAttributeRegistry Message Registry File",
"Registry": "BiosAttributeRegistry.1.0.0"
}
Redfish interface: https://BMCIP/redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry
{
"@odata.id": "/redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry",
"@odata.type": "#AttributeRegistry.v1_3_2.AttributeRegistry",
"Id": "BiosAttributeRegistry",
"Language": "en",
"Name": "Bios Attribute Registry",
"OwningEntity": "OpenBMC",
"RegistryEntries": {
"Attributes": [
{
"AttributeName": "attr0",
"CurrentValue": "current value",
"DefaultValue": "default value",
"DisplayName": "display name for attr0",
"HelpText": "description for attr0",
"MenuPath": "./menu/path/for/attr0",
"ReadOnly": false,
"Type": "String",
"Value": [
{
"ValueName": "..."
},
.
.
]
},
.
.
]
},
"RegistryVersion": "1.0.0"
}
https://BMC_IPADDR/redfish/v1/Systems/system/Bios/Settings
{
"@odata.id": "/redfish/v1/Systems/system/Bios/Settings",
"@odata.type": "#Bios.v1_1_0.Bios",
"AttributeRegistry": "BiosAttributeRegistry",
"Attributes": {
"QuietBoot": "0x0"
},
"Id": "BiosSettingsV1",
"Name": "Bios Settings Version 1"
}
2. Passed Validator check for bios resource and bios attribute registry
*** /redfish/v1/Systems/system/Bios
INFO - Type (#Bios.v1_1_0.Bios), GET SUCCESS (time: 1.57377)
INFO - PASS
*** /redfish/v1/Registries/BiosAttributeRegistry
INFO - Type (#MessageRegistryFile.v1_1_0.MessageRegistryFile), GET SUCCESS (time: 0.075438)
INFO - PASS
INFO -
*** /redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry
INFO - Type (#AttributeRegistry.v1_3_2.AttributeRegistry), GET SUCCESS (time: 0.075751)
INFO - PASS
@odata.id /redfish/v1/Systems/system/Bios odata Exists PASS
@odata.type #Settings.v1_3_0.Settings odata Exists PASS
Links [JSON Object] Bios.v1_1_0.Links Yes complex
Links.ActiveSoftwareImage Link: /redfish/v1/UpdateService/FirmwareInventory/bios_active link to: SoftwareInventory Yes PASS
Links.SoftwareImages Array (size: 1) array of: SoftwareInventory Yes ...
Links.SoftwareImages[0] Link: /redfish/v1/UpdateService/FirmwareInventory/bios_active SoftwareInventory Yes PASS
Links.Oem - Resource.Oem No Optional
SoftwareImages@odata.count 1 odata Exists PASS
AttributeRegistry BiosAttributeRegistry string Yes PASS
Actions [JSON Object] Bios.v1_0_0.Actions Yes complex
Actions.#Bios.ResetBios Action - Yes PASS
Actions.#Bios.ChangePassword Action - Yes PASS
Attributes [JSON Object] Bios.v1_0_0.Attributes Yes complex
Attributes.attr0 current value primitive Yes PASS
Id BIOS string Yes PASS
Description BIOS Configuration Service string Yes PASS
Name BIOS Configuration string Yes PASS
Oem - Resource.Oem No Optional
@Redfish.Settings [JSON Object] Settings.Settings Yes complex
@Redfish.Settings.MaintenanceWindowResource - link to: ItemOrCollection No Optional
@Redfish.Settings.SupportedApplyTimes - string (enum) No Optional
@Redfish.Settings.Time - date No Optional
@Redfish.Settings.ETag - string No Optional
@Redfish.Settings.SettingsObject Link: /redfish/v1/Systems/system/Bios/Settings link to: Item Yes PASS
@Redfish.Settings.Messages - Message No Optional
@odata.id /redfish/v1/Registries/BiosAttributeRegistry odata Exists PASS
@odata.type #MessageRegistryFile.v1_1_0.MessageRegistryFile odata Exists PASS
Languages@odata.count 1 odata Exists PASS
Location@odata.count 1 odata Exists PASS
Actions - MessageRegistryFile.v1_1_0.Actions No Optional
Languages Array (size: 1) string Yes ...
Languages[0] en string Yes PASS
Registry BiosAttributeRegistry.1.0.0 string Yes PASS
Location Array (size: 1) array of: Location Yes ...
Location[0] [JSON Object] Location Yes complex
Location[0].Language en string Yes PASS
Location[0].Uri /redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry string Yes PASS
Location[0].ArchiveUri - string No Optional
Location[0].PublicationUri - string No Optional
Location[0].ArchiveFile - string No Optional
Id BiosAttributeRegistry string Yes PASS
Description BiosAttributeRegistry Message Registry File Location string Yes PASS
Name BiosAttributeRegistry Message Registry File string Yes PASS
Oem - Resource.Oem No Optional
@odata.id /redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry odata Exists PASS
@odata.type #AttributeRegistry.v1_3_2.AttributeRegistry odata Exists PASS
Actions - AttributeRegistry.v1_1_0.Actions No Optional
Language en string Yes PASS
RegistryVersion 1.0.0 string Yes PASS
OwningEntity OpenBMC string Yes PASS
SupportedSystems - SupportedSystems No Optional
RegistryEntries [JSON Object] AttributeRegistry.v1_0_0.RegistryEntries Yes complex
RegistryEntries.Attributes Array (size: 1) array of: Attributes Yes ...
RegistryEntries.Attributes[0] [JSON Object] Attributes Yes complex
RegistryEntries.Attributes[0].Oem - Resource.Oem No Optional
RegistryEntries.Attributes[0].ResetRequired - boolean No Optional
RegistryEntries.Attributes[0].UefiDevicePath - string No Optional
RegistryEntries.Attributes[0].UefiKeywordName - string No Optional
RegistryEntries.Attributes[0].UefiNamespaceId - string No Optional
RegistryEntries.Attributes[0].AttributeName attr0 string Yes PASS
RegistryEntries.Attributes[0].Type String string (enum) Yes PASS
RegistryEntries.Attributes[0].Value Array (size: 0) array of: AttributeValue Yes ...
RegistryEntries.Attributes[0].DisplayName display name for attr0 string Yes PASS
RegistryEntries.Attributes[0].HelpText description for attr0 string Yes PASS
RegistryEntries.Attributes[0].WarningText - string No Optional
RegistryEntries.Attributes[0].CurrentValue current value primitive Yes PASS
RegistryEntries.Attributes[0].DefaultValue default value primitive Yes PASS
RegistryEntries.Attributes[0].DisplayOrder - number No Optional
RegistryEntries.Attributes[0].MenuPath ./menu/path/for/attr0 string Yes PASS
RegistryEntries.Attributes[0].ReadOnly False boolean Yes PASS
RegistryEntries.Attributes[0].WriteOnly - boolean No Optional
RegistryEntries.Attributes[0].GrayOut - boolean No Optional
RegistryEntries.Attributes[0].Hidden - boolean No Optional
RegistryEntries.Attributes[0].Immutable - boolean No Optional
RegistryEntries.Attributes[0].IsSystemUniqueProperty - boolean No Optional
RegistryEntries.Attributes[0].MaxLength - number No Optional
RegistryEntries.Attributes[0].MinLength - number No Optional
RegistryEntries.Attributes[0].ScalarIncrement - number No Optional
RegistryEntries.Attributes[0].UpperBound - number No Optional
RegistryEntries.Attributes[0].LowerBound - number No Optional
RegistryEntries.Attributes[0].ValueExpression - string No Optional
RegistryEntries.Menus - Menus No Optional
RegistryEntries.Dependencies - Dependencies No Optional
Id BiosAttributeRegistry string Yes PASS
Description - string No Optional
Name Bios Attribute Registry string Yes PASS
Oem - Resource.Oem No Optional
Change-Id: Iecc61018c350f0b8c89df59b2864b941508b1916
Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index aad28ac..edc0372 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -160,6 +160,8 @@
nodes.emplace_back(std::make_unique<SystemActionsReset>(app));
nodes.emplace_back(std::make_unique<SystemResetActionInfo>(app));
nodes.emplace_back(std::make_unique<BiosService>(app));
+ nodes.emplace_back(std::make_unique<BiosSettings>(app));
+ nodes.emplace_back(std::make_unique<BiosAttributeRegistry>(app));
nodes.emplace_back(std::make_unique<BiosReset>(app));
#ifdef BMCWEB_ENABLE_VM_NBDPROXY
nodes.emplace_back(std::make_unique<VirtualMedia>(app));
diff --git a/redfish-core/include/registries/bios_registry.hpp b/redfish-core/include/registries/bios_registry.hpp
new file mode 100644
index 0000000..88ef782
--- /dev/null
+++ b/redfish-core/include/registries/bios_registry.hpp
@@ -0,0 +1,31 @@
+/*
+// Copyright (c) 2020 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+#pragma once
+
+namespace redfish::message_registries::bios
+{
+const Header header = {
+ "Copyright 2020 OpenBMC. All rights reserved.",
+ "#MessageRegistry.v1_4_0.MessageRegistry",
+ "BiosAttributeRegistry.1.0.0",
+ "Bios Attribute Registry",
+ "en",
+ "This registry defines the messages for bios attribute registry.",
+ "BiosAttributeRegistry",
+ "1.0.0",
+ "OpenBMC",
+};
+} // namespace redfish::message_registries::bios
\ No newline at end of file
diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp
index 2c31077..ec67ebc 100644
--- a/redfish-core/lib/bios.hpp
+++ b/redfish-core/lib/bios.hpp
@@ -3,8 +3,140 @@
#include "node.hpp"
#include <utils/fw_utils.hpp>
+
namespace redfish
{
+
+/*baseBIOSTable
+map{attributeName,struct{attributeType,readonlyStatus,displayname,
+ description,menuPath,current,default,
+ array{struct{optionstring,optionvalue}}}}
+*/
+using BiosBaseTableType = std::vector<std::pair<
+ std::string,
+ std::tuple<
+ std::string, bool, std::string, std::string, std::string,
+ std::variant<int64_t, std::string>, std::variant<int64_t, std::string>,
+ std::vector<
+ std::tuple<std::string, std::variant<int64_t, std::string>>>>>>;
+using BiosBaseTableItemType = std::pair<
+ std::string,
+ std::tuple<
+ std::string, bool, std::string, std::string, std::string,
+ std::variant<int64_t, std::string>, std::variant<int64_t, std::string>,
+ std::vector<
+ std::tuple<std::string, std::variant<int64_t, std::string>>>>>;
+using OptionsItemType =
+ std::tuple<std::string, std::variant<int64_t, std::string>>;
+
+enum BiosBaseTableIndex
+{
+ biosBaseAttrType = 0,
+ biosBaseReadonlyStatus,
+ biosBaseDisplayName,
+ biosBaseDescription,
+ biosBaseMenuPath,
+ biosBaseCurrValue,
+ biosBaseDefaultValue,
+ biosBaseOptions
+};
+enum OptionsItemIndex
+{
+ optItemType = 0,
+ optItemValue
+};
+/*
+ The Pending attribute name and new value.
+ ex- { {"QuietBoot",Type.Integer, 0x1},
+ { "DdrFreqLimit",Type.String,"2933"}
+ }
+*/
+using PendingAttributesType = std::vector<std::pair<
+ std::string, std::tuple<std::string, std::variant<int64_t, std::string>>>>;
+using PendingAttributesItemType =
+ std::pair<std::string,
+ std::tuple<std::string, std::variant<int64_t, std::string>>>;
+enum PendingAttributesIndex
+{
+ pendingAttrType = 0,
+ pendingAttrValue
+};
+static std::string mapAttrTypeToRedfish(const std::string_view typeDbus)
+{
+ std::string ret;
+ if (typeDbus == "xyz.openbmc_project.BIOSConfig.Manager."
+ "AttributeType.Enumeration")
+ {
+ ret = "Enumeration";
+ }
+ else if (typeDbus == "xyz.openbmc_project.BIOSConfig."
+ "Manager.AttributeType.String")
+ {
+ ret = "String";
+ }
+ else if (typeDbus == "xyz.openbmc_project.BIOSConfig."
+ "Manager.AttributeType.Password")
+ {
+ ret = "Password";
+ }
+ else if (typeDbus == "xyz.openbmc_project.BIOSConfig."
+ "Manager.AttributeType.Integer")
+ {
+ ret = "Integer";
+ }
+ else if (typeDbus == "xyz.openbmc_project.BIOSConfig."
+ "Manager.AttributeType.Boolean")
+ {
+ ret = "Boolean";
+ }
+ else
+ {
+ ret = "UNKNOWN";
+ }
+
+ return ret;
+}
+static std::string mapBoundTypeToRedfish(const std::string_view typeDbus)
+{
+ std::string ret;
+ if (typeDbus ==
+ "xyz.openbmc_project.BIOSConfig.Manager.BoundType.ScalarIncrement")
+ {
+ ret = "ScalarIncrement";
+ }
+ else if (typeDbus ==
+ "xyz.openbmc_project.BIOSConfig.Manager.BoundType.LowerBound")
+ {
+ ret = "LowerBound";
+ }
+ else if (typeDbus ==
+ "xyz.openbmc_project.BIOSConfig.Manager.BoundType.UpperBound")
+ {
+ ret = "UpperBound";
+ }
+ else if (typeDbus ==
+ "xyz.openbmc_project.BIOSConfig.Manager.BoundType.MinStringLength")
+ {
+ ret = "MinLength";
+ }
+ else if (typeDbus ==
+ "xyz.openbmc_project.BIOSConfig.Manager.BoundType.MaxStringLength")
+ {
+ ret = "MaxLength";
+ }
+ else if (typeDbus ==
+ "xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf")
+ {
+ ret = "OneOf";
+ }
+ else
+ {
+ ret = "UNKNOWN";
+ }
+
+ return ret;
+}
+
/**
* BiosService class supports handle get method for bios.
*/
@@ -35,6 +167,392 @@
// Get the ActiveSoftwareImage and SoftwareImages
fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose,
"", true);
+ asyncResp->res.jsonValue["@Redfish.Settings"] = {
+ {"@odata.type", "#Settings.v1_3_0.Settings"},
+ {"SettingsObject",
+ {{"@odata.id", "/redfish/v1/Systems/system/Bios/Settings"}}}};
+ asyncResp->res.jsonValue["AttributeRegistry"] = "BiosAttributeRegistry";
+ asyncResp->res.jsonValue["Attributes"] = {};
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
+ const GetObjectType& getObjectType) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: "
+ << ec;
+ messages::internalError(asyncResp->res);
+
+ return;
+ }
+ const std::string& service = getObjectType.begin()->first;
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](
+ const boost::system::error_code ec,
+ const std::variant<BiosBaseTableType>& retBiosTable) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "getBiosAttributes DBUS error: "
+ << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const BiosBaseTableType* baseBiosTable =
+ std::get_if<BiosBaseTableType>(&retBiosTable);
+ nlohmann::json& attributesJson =
+ asyncResp->res.jsonValue["Attributes"];
+ if (baseBiosTable == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "baseBiosTable == nullptr ";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ for (const BiosBaseTableItemType& item : *baseBiosTable)
+ {
+ const std::string& key = item.first;
+ const std::string& itemType =
+ std::get<biosBaseAttrType>(item.second);
+ std::string attrType =
+ mapAttrTypeToRedfish(itemType);
+ if (attrType == "String")
+ {
+ const std::string* currValue =
+ std::get_if<std::string>(
+ &std::get<biosBaseCurrValue>(
+ item.second));
+ attributesJson.emplace(key, currValue != nullptr
+ ? *currValue
+ : "");
+ }
+ else if (attrType == "Integer")
+ {
+ const int64_t* currValue = std::get_if<int64_t>(
+ &std::get<biosBaseCurrValue>(item.second));
+ attributesJson.emplace(
+ key, currValue != nullptr ? *currValue : 0);
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR
+ << "Unsupported attribute type.";
+ messages::internalError(asyncResp->res);
+ }
+ }
+ },
+ service, "/xyz/openbmc_project/bios_config/manager",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.BIOSConfig.Manager", "BaseBIOSTable");
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetObject",
+ "/xyz/openbmc_project/bios_config/manager",
+ std::array<const char*, 0>());
+ }
+};
+
+/**
+ * BiosSettings class supports handle GET/PATCH method for
+ * BIOS configuration pending settings.
+ */
+class BiosSettings : public Node
+{
+ public:
+ BiosSettings(App& app) :
+ Node(app, "/redfish/v1/Systems/system/Bios/Settings")
+ {
+ entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}};
+ }
+
+ private:
+ void doGet(crow::Response& res, const crow::Request&,
+ const std::vector<std::string>&) override
+ {
+ auto asyncResp = std::make_shared<AsyncResp>(res);
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/Bios/Settings";
+ asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
+ asyncResp->res.jsonValue["Name"] = "Bios Settings";
+ asyncResp->res.jsonValue["Id"] = "BiosSettings";
+ asyncResp->res.jsonValue["AttributeRegistry"] = "BiosAttributeRegistry";
+ asyncResp->res.jsonValue["Attributes"] = {};
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
+ const GetObjectType& getObjectType) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: "
+ << ec;
+ messages::internalError(asyncResp->res);
+
+ return;
+ }
+ std::string service = getObjectType.begin()->first;
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
+ const std::variant<PendingAttributesType>&
+ retPendingAttributes) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "getBiosSettings DBUS error: "
+ << ec;
+ messages::resourceNotFound(asyncResp->res,
+ "Systems/system/Bios",
+ "Settings");
+ return;
+ }
+ const PendingAttributesType* pendingAttributes =
+ std::get_if<PendingAttributesType>(
+ &retPendingAttributes);
+ nlohmann::json& attributesJson =
+ asyncResp->res.jsonValue["Attributes"];
+ if (pendingAttributes == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "pendingAttributes == nullptr ";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ for (const PendingAttributesItemType& item :
+ *pendingAttributes)
+ {
+ const std::string& key = item.first;
+ const std::string& itemType =
+ std::get<pendingAttrType>(item.second);
+ std::string attrType =
+ mapAttrTypeToRedfish(itemType);
+ if (attrType == "String")
+ {
+ const std::string* currValue =
+ std::get_if<std::string>(
+ &std::get<pendingAttrValue>(
+ item.second));
+ attributesJson.emplace(key, currValue != nullptr
+ ? *currValue
+ : "");
+ }
+ else if (attrType == "Integer")
+ {
+ const int64_t* currValue = std::get_if<int64_t>(
+ &std::get<pendingAttrValue>(item.second));
+ attributesJson.emplace(
+ key, currValue != nullptr ? *currValue : 0);
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR
+ << "Unsupported attribute type.";
+ messages::internalError(asyncResp->res);
+ }
+ }
+ },
+ service, "/xyz/openbmc_project/bios_config/manager",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.BIOSConfig.Manager",
+ "PendingAttributes");
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetObject",
+ "/xyz/openbmc_project/bios_config/manager",
+ std::array<const char*, 0>());
+ }
+};
+/**
+ * BiosAttributeRegistry class supports handle get method for BIOS attribute
+ * registry.
+ */
+class BiosAttributeRegistry : public Node
+{
+ public:
+ BiosAttributeRegistry(App& app) :
+ Node(app, "/redfish/v1/Registries/BiosAttributeRegistry/"
+ "BiosAttributeRegistry")
+ {
+ entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}};
+ }
+
+ private:
+ void doGet(crow::Response& res, const crow::Request&,
+ const std::vector<std::string>&) override
+ {
+ auto asyncResp = std::make_shared<AsyncResp>(res);
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Registries/BiosAttributeRegistry/"
+ "BiosAttributeRegistry";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#AttributeRegistry.v1_3_2.AttributeRegistry";
+ asyncResp->res.jsonValue["Name"] = "Bios Attribute Registry";
+ asyncResp->res.jsonValue["Id"] = "BiosAttributeRegistry";
+ asyncResp->res.jsonValue["RegistryVersion"] = "1.0.0";
+ asyncResp->res.jsonValue["Language"] = "en";
+ asyncResp->res.jsonValue["OwningEntity"] = "OpenBMC";
+ asyncResp->res.jsonValue["RegistryEntries"]["Attributes"] =
+ nlohmann::json::array();
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
+ const GetObjectType& getObjectType) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: "
+ << ec;
+ messages::internalError(asyncResp->res);
+
+ return;
+ }
+ std::string service = getObjectType.begin()->first;
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](
+ const boost::system::error_code ec,
+ const std::variant<BiosBaseTableType>& retBiosTable) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR
+ << "getBiosAttributeRegistry DBUS error: "
+ << ec;
+ messages::resourceNotFound(
+ asyncResp->res, "Registries/Bios", "Bios");
+ return;
+ }
+ const BiosBaseTableType* baseBiosTable =
+ std::get_if<BiosBaseTableType>(&retBiosTable);
+ nlohmann::json& attributeArray =
+ asyncResp->res
+ .jsonValue["RegistryEntries"]["Attributes"];
+ if (baseBiosTable == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "baseBiosTable == nullptr ";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ for (const BiosBaseTableItemType& item : *baseBiosTable)
+ {
+ nlohmann::json optionsArray =
+ nlohmann::json::array();
+ const std::string& itemType =
+ std::get<biosBaseAttrType>(item.second);
+ std::string attrType =
+ mapAttrTypeToRedfish(itemType);
+ if (attrType == "UNKNOWN")
+ {
+ BMCWEB_LOG_ERROR << "attrType == UNKNOWN";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json attributeItem;
+ attributeItem["AttributeName"] = item.first;
+ attributeItem["Type"] = attrType;
+ attributeItem["ReadOnly"] =
+ std::get<biosBaseReadonlyStatus>(item.second);
+ attributeItem["DisplayName"] =
+ std::get<biosBaseDisplayName>(item.second);
+ attributeItem["HelpText"] =
+ std::get<biosBaseDescription>(item.second);
+ if ((std::get<biosBaseMenuPath>(item.second)) != "")
+ {
+ attributeItem["MenuPath"] =
+ std::get<biosBaseMenuPath>(item.second);
+ }
+
+ if (attrType == "String")
+ {
+ const std::string* currValue =
+ std::get_if<std::string>(
+ &std::get<biosBaseCurrValue>(
+ item.second));
+ const std::string* defValue =
+ std::get_if<std::string>(
+ &std::get<biosBaseDefaultValue>(
+ item.second));
+ if (currValue && *currValue != "")
+ {
+ attributeItem["CurrentValue"] = *currValue;
+ }
+ if (defValue && *defValue != "")
+ {
+ attributeItem["DefaultValue"] = *defValue;
+ }
+ }
+ else if (attrType == "Integer")
+ {
+ const int64_t* currValue = std::get_if<int64_t>(
+ &std::get<biosBaseCurrValue>(item.second));
+ const int64_t* defValue = std::get_if<int64_t>(
+ &std::get<biosBaseDefaultValue>(
+ item.second));
+ attributeItem["CurrentValue"] =
+ currValue != nullptr ? *currValue : 0;
+ attributeItem["DefaultValue"] =
+ defValue != nullptr ? *defValue : 0;
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR
+ << "Unsupported attribute type.";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ const std::vector<OptionsItemType>& optionsVector =
+ std::get<biosBaseOptions>(item.second);
+ for (const OptionsItemType& optItem : optionsVector)
+ {
+ nlohmann::json optItemJson;
+ const std::string& strOptItemType =
+ std::get<optItemType>(optItem);
+ std::string optItemTypeRedfish =
+ mapBoundTypeToRedfish(strOptItemType);
+ if (optItemTypeRedfish == "UNKNOWN")
+ {
+ BMCWEB_LOG_ERROR
+ << "optItemTypeRedfish == UNKNOWN";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (optItemTypeRedfish == "OneOf")
+ {
+ const std::string* currValue =
+ std::get_if<std::string>(
+ &std::get<optItemValue>(optItem));
+ if (currValue != nullptr)
+ {
+ optItemJson["ValueName"] = *currValue;
+ optionsArray.push_back(optItemJson);
+ }
+ }
+ else
+ {
+ const int64_t* currValue =
+ std::get_if<int64_t>(
+ &std::get<optItemValue>(optItem));
+ if (currValue != nullptr)
+ {
+ attributeItem[optItemTypeRedfish] =
+ *currValue;
+ }
+ }
+ }
+
+ if (optionsArray.size() > 0)
+ {
+ attributeItem["Value"] = optionsArray;
+ }
+ attributeArray.push_back(attributeItem);
+ }
+ },
+ service, "/xyz/openbmc_project/bios_config/manager",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.BIOSConfig.Manager", "BaseBIOSTable");
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetObject",
+ "/xyz/openbmc_project/bios_config/manager",
+ std::array<const char*, 0>());
}
};
/**
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index 77fc10e..0caf01c 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -18,6 +18,7 @@
#include "node.hpp"
#include "registries.hpp"
#include "registries/base_message_registry.hpp"
+#include "registries/bios_registry.hpp"
#include "registries/openbmc_message_registry.hpp"
#include "registries/resource_event_message_registry.hpp"
#include "registries/task_event_message_registry.hpp"
@@ -56,11 +57,12 @@
{"@odata.id", "/redfish/v1/Registries"},
{"Name", "MessageRegistryFile Collection"},
{"Description", "Collection of MessageRegistryFiles"},
- {"Members@odata.count", 4},
+ {"Members@odata.count", 5},
{"Members",
{{{"@odata.id", "/redfish/v1/Registries/Base"}},
{{"@odata.id", "/redfish/v1/Registries/TaskEvent"}},
{{"@odata.id", "/redfish/v1/Registries/ResourceEvent"}},
+ {{"@odata.id", "/redfish/v1/Registries/BiosAttributeRegistry"}},
{{"@odata.id", "/redfish/v1/Registries/OpenBMC"}}}}};
res.end();
@@ -118,6 +120,11 @@
header = &message_registries::resource_event::header;
url = message_registries::resource_event::url;
}
+ else if (registry == "BiosAttributeRegistry")
+ {
+ header = &message_registries::bios::header;
+ dmtf.clear();
+ }
else
{
messages::resourceNotFound(