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