1d82a3acdSCarol Wang #pragma once 2d82a3acdSCarol Wang 37e860f15SJohn Edward Broadbent #include <app.hpp> 4*ed398213SEd Tanous #include <registries/privilege_registry.hpp> 572d566d9SGunnar Mills #include <utils/fw_utils.hpp> 6d82a3acdSCarol Wang namespace redfish 7d82a3acdSCarol Wang { 8d82a3acdSCarol Wang /** 9d82a3acdSCarol Wang * BiosService class supports handle get method for bios. 10d82a3acdSCarol Wang */ 117e860f15SJohn Edward Broadbent inline void requestRoutesBiosService(App& app) 12d82a3acdSCarol Wang { 137e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/") 14*ed398213SEd Tanous .privileges(redfish::privileges::getBios) 157e860f15SJohn Edward Broadbent .methods(boost::beast::http::verb::get)( 167e860f15SJohn Edward Broadbent [](const crow::Request&, 177e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 18d82a3acdSCarol Wang asyncResp->res.jsonValue["@odata.id"] = 19d82a3acdSCarol Wang "/redfish/v1/Systems/system/Bios"; 20d82a3acdSCarol Wang asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios"; 21d82a3acdSCarol Wang asyncResp->res.jsonValue["Name"] = "BIOS Configuration"; 227e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Description"] = 237e860f15SJohn Edward Broadbent "BIOS Configuration Service"; 24d82a3acdSCarol Wang asyncResp->res.jsonValue["Id"] = "BIOS"; 25d82a3acdSCarol Wang asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { 26d82a3acdSCarol Wang {"target", 27d82a3acdSCarol Wang "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; 2872d566d9SGunnar Mills 29f97ddba7SGunnar Mills // Get the ActiveSoftwareImage and SoftwareImages 307e860f15SJohn Edward Broadbent fw_util::populateFirmwareInformation( 317e860f15SJohn Edward Broadbent asyncResp, fw_util::biosPurpose, "", true); 327e860f15SJohn Edward Broadbent }); 33d82a3acdSCarol Wang } 34d82a3acdSCarol Wang /** 35d82a3acdSCarol Wang * BiosReset class supports handle POST method for Reset bios. 36d82a3acdSCarol Wang * The class retrieves and sends data directly to D-Bus. 377e860f15SJohn Edward Broadbent * 38d82a3acdSCarol Wang * Function handles POST method request. 39d82a3acdSCarol Wang * Analyzes POST body message before sends Reset request data to D-Bus. 40d82a3acdSCarol Wang */ 41d82a3acdSCarol Wang 427e860f15SJohn Edward Broadbent inline void requestRoutesBiosReset(App& app) 437e860f15SJohn Edward Broadbent { 447e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/") 45*ed398213SEd Tanous // Incorrect Privilege; Should be ConfigureComponents 46*ed398213SEd Tanous //.privileges(redfish::privileges::postBios) 47432a890cSEd Tanous .privileges({{"ConfigureManager"}}) 487e860f15SJohn Edward Broadbent .methods(boost::beast::http::verb::post)( 497e860f15SJohn Edward Broadbent [](const crow::Request&, 507e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 51d82a3acdSCarol Wang crow::connections::systemBus->async_method_call( 52d82a3acdSCarol Wang [asyncResp](const boost::system::error_code ec) { 53d82a3acdSCarol Wang if (ec) 54d82a3acdSCarol Wang { 55d82a3acdSCarol Wang BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; 56d82a3acdSCarol Wang messages::internalError(asyncResp->res); 57d82a3acdSCarol Wang return; 58d82a3acdSCarol Wang } 59d82a3acdSCarol Wang }, 60d82a3acdSCarol Wang "org.open_power.Software.Host.Updater", 61d82a3acdSCarol Wang "/xyz/openbmc_project/software", 62d82a3acdSCarol Wang "xyz.openbmc_project.Common.FactoryReset", "Reset"); 637e860f15SJohn Edward Broadbent }); 64d82a3acdSCarol Wang } 65d82a3acdSCarol Wang } // namespace redfish 66