xref: /openbmc/bmcweb/redfish-core/lib/bios.hpp (revision 432a890c)
1d82a3acdSCarol Wang #pragma once
2d82a3acdSCarol Wang 
37e860f15SJohn Edward Broadbent #include <app.hpp>
472d566d9SGunnar Mills #include <utils/fw_utils.hpp>
5d82a3acdSCarol Wang namespace redfish
6d82a3acdSCarol Wang {
7d82a3acdSCarol Wang /**
8d82a3acdSCarol Wang  * BiosService class supports handle get method for bios.
9d82a3acdSCarol Wang  */
107e860f15SJohn Edward Broadbent inline void requestRoutesBiosService(App& app)
11d82a3acdSCarol Wang {
127e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/")
13*432a890cSEd Tanous         .privileges({{"Login"}})
147e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
157e860f15SJohn Edward Broadbent             [](const crow::Request&,
167e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
17d82a3acdSCarol Wang                 asyncResp->res.jsonValue["@odata.id"] =
18d82a3acdSCarol Wang                     "/redfish/v1/Systems/system/Bios";
19d82a3acdSCarol Wang                 asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
20d82a3acdSCarol Wang                 asyncResp->res.jsonValue["Name"] = "BIOS Configuration";
217e860f15SJohn Edward Broadbent                 asyncResp->res.jsonValue["Description"] =
227e860f15SJohn Edward Broadbent                     "BIOS Configuration Service";
23d82a3acdSCarol Wang                 asyncResp->res.jsonValue["Id"] = "BIOS";
24d82a3acdSCarol Wang                 asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = {
25d82a3acdSCarol Wang                     {"target",
26d82a3acdSCarol Wang                      "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}};
2772d566d9SGunnar Mills 
28f97ddba7SGunnar Mills                 // Get the ActiveSoftwareImage and SoftwareImages
297e860f15SJohn Edward Broadbent                 fw_util::populateFirmwareInformation(
307e860f15SJohn Edward Broadbent                     asyncResp, fw_util::biosPurpose, "", true);
317e860f15SJohn Edward Broadbent             });
32d82a3acdSCarol Wang }
33d82a3acdSCarol Wang /**
34d82a3acdSCarol Wang  * BiosReset class supports handle POST method for Reset bios.
35d82a3acdSCarol Wang  * The class retrieves and sends data directly to D-Bus.
367e860f15SJohn Edward Broadbent  *
37d82a3acdSCarol Wang  * Function handles POST method request.
38d82a3acdSCarol Wang  * Analyzes POST body message before sends Reset request data to D-Bus.
39d82a3acdSCarol Wang  */
40d82a3acdSCarol Wang 
417e860f15SJohn Edward Broadbent inline void requestRoutesBiosReset(App& app)
427e860f15SJohn Edward Broadbent {
437e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/")
44*432a890cSEd Tanous         .privileges({{"ConfigureManager"}})
457e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::post)(
467e860f15SJohn Edward Broadbent             [](const crow::Request&,
477e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
48d82a3acdSCarol Wang                 crow::connections::systemBus->async_method_call(
49d82a3acdSCarol Wang                     [asyncResp](const boost::system::error_code ec) {
50d82a3acdSCarol Wang                         if (ec)
51d82a3acdSCarol Wang                         {
52d82a3acdSCarol Wang                             BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec;
53d82a3acdSCarol Wang                             messages::internalError(asyncResp->res);
54d82a3acdSCarol Wang                             return;
55d82a3acdSCarol Wang                         }
56d82a3acdSCarol Wang                     },
57d82a3acdSCarol Wang                     "org.open_power.Software.Host.Updater",
58d82a3acdSCarol Wang                     "/xyz/openbmc_project/software",
59d82a3acdSCarol Wang                     "xyz.openbmc_project.Common.FactoryReset", "Reset");
607e860f15SJohn Edward Broadbent             });
61d82a3acdSCarol Wang }
62d82a3acdSCarol Wang } // namespace redfish
63