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