xref: /openbmc/entity-manager/src/devicetree_vpd_parser/devicetree_vpd_parser.cpp (revision cfc7f4f423c8163c394fbd777afcaf10a835206f)
1 #include "machine_context.hpp"
2 
3 #include <memory>
4 
main()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 };
45