1*cfc7f4f4SChristopher Meis #include "machine_context.hpp" 2*cfc7f4f4SChristopher Meis 3*cfc7f4f4SChristopher Meis #include <memory> 4*cfc7f4f4SChristopher Meis main()5*cfc7f4f4SChristopher Meisint main() 6*cfc7f4f4SChristopher Meis { 7*cfc7f4f4SChristopher Meis static constexpr auto reqDBusPath = "/xyz/openbmc_project/MachineContext"; 8*cfc7f4f4SChristopher Meis static constexpr auto reqDBusName = "xyz.openbmc_project.MachineContext"; 9*cfc7f4f4SChristopher Meis 10*cfc7f4f4SChristopher Meis /*Note: OpenBMC convention typically has service name = bus name, 11*cfc7f4f4SChristopher Meis where the bus name is representative of the underlying hardware. 12*cfc7f4f4SChristopher Meis 13*cfc7f4f4SChristopher Meis In the case of MachineContext, the BMC is not gathering data from 14*cfc7f4f4SChristopher Meis specific hardware, but is instead parsing device-tree nodes for 15*cfc7f4f4SChristopher Meis context about the hardware OpenBMC is running on. 16*cfc7f4f4SChristopher Meis 17*cfc7f4f4SChristopher Meis Because the VPD data being parsed is coming from device-tree, 18*cfc7f4f4SChristopher Meis the daemon and matching service name reflect that. 19*cfc7f4f4SChristopher Meis 20*cfc7f4f4SChristopher Meis Because the parsed data represents 'machine context' data, 21*cfc7f4f4SChristopher Meis the bus name and associated path the daemon writes to 22*cfc7f4f4SChristopher Meis reflects that instead. 23*cfc7f4f4SChristopher Meis */ 24*cfc7f4f4SChristopher Meis 25*cfc7f4f4SChristopher Meis sdbusplus::async::context ctx; 26*cfc7f4f4SChristopher Meis sdbusplus::server::manager_t manager{ctx, reqDBusPath}; 27*cfc7f4f4SChristopher Meis 28*cfc7f4f4SChristopher Meis std::unique_ptr<MachineContext> mc = nullptr; 29*cfc7f4f4SChristopher Meis if (MachineContext::keyNodeExists()) 30*cfc7f4f4SChristopher Meis { 31*cfc7f4f4SChristopher Meis mc = std::make_unique<MachineContext>(ctx, reqDBusPath); 32*cfc7f4f4SChristopher Meis mc->populateFromDeviceTree(); 33*cfc7f4f4SChristopher Meis } 34*cfc7f4f4SChristopher Meis 35*cfc7f4f4SChristopher Meis // NOLINTNEXTLINE(readability-static-accessed-through-instance) 36*cfc7f4f4SChristopher Meis ctx.spawn([](sdbusplus::async::context& ctx) -> sdbusplus::async::task<> { 37*cfc7f4f4SChristopher Meis ctx.request_name(reqDBusName); 38*cfc7f4f4SChristopher Meis co_return; 39*cfc7f4f4SChristopher Meis }(ctx)); 40*cfc7f4f4SChristopher Meis 41*cfc7f4f4SChristopher Meis ctx.run(); 42*cfc7f4f4SChristopher Meis 43*cfc7f4f4SChristopher Meis return 0; 44*cfc7f4f4SChristopher Meis }; 45