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