1d82a3acdSCarol Wang #pragma once 2d82a3acdSCarol Wang 37e860f15SJohn Edward Broadbent #include <app.hpp> 445ca1b86SEd Tanous #include <query.hpp> 5ed398213SEd Tanous #include <registries/privilege_registry.hpp> 672d566d9SGunnar Mills #include <utils/fw_utils.hpp> 745ca1b86SEd Tanous 8d82a3acdSCarol Wang namespace redfish 9d82a3acdSCarol Wang { 10d82a3acdSCarol Wang /** 11d82a3acdSCarol Wang * BiosService class supports handle get method for bios. 12d82a3acdSCarol Wang */ 1358eaf5f0SJohn Edward Broadbent inline void 1445ca1b86SEd Tanous handleBiosServiceGet(crow::App& app, const crow::Request& req, 1558eaf5f0SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1658eaf5f0SJohn Edward Broadbent { 17*3ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 1845ca1b86SEd Tanous { 1945ca1b86SEd Tanous return; 2045ca1b86SEd Tanous } 2158eaf5f0SJohn Edward Broadbent asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Bios"; 2258eaf5f0SJohn Edward Broadbent asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios"; 2358eaf5f0SJohn Edward Broadbent asyncResp->res.jsonValue["Name"] = "BIOS Configuration"; 2458eaf5f0SJohn Edward Broadbent asyncResp->res.jsonValue["Description"] = "BIOS Configuration Service"; 2558eaf5f0SJohn Edward Broadbent asyncResp->res.jsonValue["Id"] = "BIOS"; 2658eaf5f0SJohn Edward Broadbent asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { 2758eaf5f0SJohn Edward Broadbent {"target", "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; 2858eaf5f0SJohn Edward Broadbent 2958eaf5f0SJohn Edward Broadbent // Get the ActiveSoftwareImage and SoftwareImages 3058eaf5f0SJohn Edward Broadbent fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, "", 3158eaf5f0SJohn Edward Broadbent true); 3258eaf5f0SJohn Edward Broadbent } 3345ca1b86SEd Tanous 347e860f15SJohn Edward Broadbent inline void requestRoutesBiosService(App& app) 35d82a3acdSCarol Wang { 367e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/") 37ed398213SEd Tanous .privileges(redfish::privileges::getBios) 3845ca1b86SEd Tanous .methods(boost::beast::http::verb::get)( 3945ca1b86SEd Tanous std::bind_front(handleBiosServiceGet, std::ref(app))); 40d82a3acdSCarol Wang } 4158eaf5f0SJohn Edward Broadbent 42d82a3acdSCarol Wang /** 43d82a3acdSCarol Wang * BiosReset class supports handle POST method for Reset bios. 44d82a3acdSCarol Wang * The class retrieves and sends data directly to D-Bus. 457e860f15SJohn Edward Broadbent * 46d82a3acdSCarol Wang * Function handles POST method request. 47d82a3acdSCarol Wang * Analyzes POST body message before sends Reset request data to D-Bus. 48d82a3acdSCarol Wang */ 4958eaf5f0SJohn Edward Broadbent inline void 5045ca1b86SEd Tanous handleBiosResetPost(crow::App& app, const crow::Request& req, 5158eaf5f0SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 527e860f15SJohn Edward Broadbent { 53*3ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 5445ca1b86SEd Tanous { 5545ca1b86SEd Tanous return; 5645ca1b86SEd Tanous } 57d82a3acdSCarol Wang crow::connections::systemBus->async_method_call( 58d82a3acdSCarol Wang [asyncResp](const boost::system::error_code ec) { 59d82a3acdSCarol Wang if (ec) 60d82a3acdSCarol Wang { 61d82a3acdSCarol Wang BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; 62d82a3acdSCarol Wang messages::internalError(asyncResp->res); 63d82a3acdSCarol Wang return; 64d82a3acdSCarol Wang } 65d82a3acdSCarol Wang }, 6658eaf5f0SJohn Edward Broadbent "org.open_power.Software.Host.Updater", "/xyz/openbmc_project/software", 67d82a3acdSCarol Wang "xyz.openbmc_project.Common.FactoryReset", "Reset"); 68d82a3acdSCarol Wang } 6958eaf5f0SJohn Edward Broadbent 7058eaf5f0SJohn Edward Broadbent inline void requestRoutesBiosReset(App& app) 7158eaf5f0SJohn Edward Broadbent { 7258eaf5f0SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/") 73b7ff3445SJohn Edward Broadbent .privileges(redfish::privileges::postBios) 7445ca1b86SEd Tanous .methods(boost::beast::http::verb::post)( 7545ca1b86SEd Tanous std::bind_front(handleBiosResetPost, std::ref(app))); 7658eaf5f0SJohn Edward Broadbent } 7758eaf5f0SJohn Edward Broadbent 78d82a3acdSCarol Wang } // namespace redfish 79