1 #pragma once 2 3 #include <app.hpp> 4 #include <registries/privilege_registry.hpp> 5 #include <utils/fw_utils.hpp> 6 namespace redfish 7 { 8 /** 9 * BiosService class supports handle get method for bios. 10 */ 11 inline void requestRoutesBiosService(App& app) 12 { 13 BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/") 14 .privileges(redfish::privileges::getBios) 15 .methods(boost::beast::http::verb::get)( 16 [](const crow::Request&, 17 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 18 asyncResp->res.jsonValue["@odata.id"] = 19 "/redfish/v1/Systems/system/Bios"; 20 asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios"; 21 asyncResp->res.jsonValue["Name"] = "BIOS Configuration"; 22 asyncResp->res.jsonValue["Description"] = 23 "BIOS Configuration Service"; 24 asyncResp->res.jsonValue["Id"] = "BIOS"; 25 asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { 26 {"target", 27 "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; 28 29 // Get the ActiveSoftwareImage and SoftwareImages 30 fw_util::populateFirmwareInformation( 31 asyncResp, fw_util::biosPurpose, "", true); 32 }); 33 } 34 /** 35 * BiosReset class supports handle POST method for Reset bios. 36 * The class retrieves and sends data directly to D-Bus. 37 * 38 * Function handles POST method request. 39 * Analyzes POST body message before sends Reset request data to D-Bus. 40 */ 41 42 inline void requestRoutesBiosReset(App& app) 43 { 44 BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/") 45 .privileges(redfish::privileges::postBios) 46 .methods(boost::beast::http::verb::post)( 47 [](const crow::Request&, 48 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 49 crow::connections::systemBus->async_method_call( 50 [asyncResp](const boost::system::error_code ec) { 51 if (ec) 52 { 53 BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; 54 messages::internalError(asyncResp->res); 55 return; 56 } 57 }, 58 "org.open_power.Software.Host.Updater", 59 "/xyz/openbmc_project/software", 60 "xyz.openbmc_project.Common.FactoryReset", "Reset"); 61 }); 62 } 63 } // namespace redfish 64