service: device-tree node vpd to d-bus hw id data

A daemon for transferring Viable Product Data (VPD) from device-tree
nodes to D-Bus as described in the design doc @
https://gerrit.openbmc.org/c/openbmc/docs/+/66369

and discussed in this Technical Oversight Forum topic @
https://github.com/openbmc/technical-oversight-forum/issues/38

Tested:
Ensure 'model' and/or 'serial-number' nodes are populated in
/proc/device-tree. Can be hardcoded into platform DTS via
linux-kernel recipe if needed.

'''
After OBMC boot, calling
> busctl introspect xyz.openbmc_project.MachineContext /xyz/openbmc_project/MachineContext

produces the following output:

NAME                                          TYPE      SIGNATURE  RESULT/VALUE  FLAGS
...
xyz.openbmc_project.Inventory.Decorator.Asset interface -          -             -
.BuildDate                                    property  s          ""            emits-change writable
.Manufacturer                                 property  s          ""            emits-change writable
.Model                                        property  s          "hpe,dl360"   emits-change writable
.PartNumber                                   property  s          ""            emits-change writable
.SerialNumber                                 property  s          "t5texpl"     emits-change writable
...

Note: Writing to one of these properties will update the property on D-Bus without affecting the
underlying device-tree node. An 'updated' event will be fired, so Entity-Manager probes monitoring
a given property would recognize the new value and key off it.
'''

Change-Id: Id52d1fc3b26010c864c7e64d3dfdf0a2b5de9294
Signed-off-by: Chris Sides <Christopher.Sides@hpe.com>
diff --git a/src/devicetree_vpd_parser.cpp b/src/devicetree_vpd_parser.cpp
new file mode 100644
index 0000000..87bd2d7
--- /dev/null
+++ b/src/devicetree_vpd_parser.cpp
@@ -0,0 +1,44 @@
+#include "machine_context.hpp"
+
+#include <memory>
+
+int main()
+{
+    static constexpr auto reqDBusPath = "/xyz/openbmc_project/MachineContext";
+    static constexpr auto reqDBusName = "xyz.openbmc_project.MachineContext";
+
+    /*Note: OpenBMC convention typically has service name = bus name,
+    where the bus name is representative of the underlying hardware.
+
+    In the case of MachineContext, the BMC is not gathering data from
+    specific hardware, but is instead parsing device-tree nodes for
+    context about the hardware OpenBMC is running on.
+
+    Because the VPD data being parsed is coming from device-tree,
+    the daemon and matching service name reflect that.
+
+    Because the parsed data represents 'machine context' data,
+    the bus name and associated path the daemon writes to
+    reflects that instead.
+    */
+
+    sdbusplus::async::context ctx;
+    sdbusplus::server::manager_t manager{ctx, reqDBusPath};
+
+    std::unique_ptr<MachineContext> mc = nullptr;
+    if (MachineContext::keyNodeExists())
+    {
+        mc = std::make_unique<MachineContext>(ctx, reqDBusPath);
+        mc->populateFromDeviceTree();
+    }
+
+    // NOLINTNEXTLINE(readability-static-accessed-through-instance)
+    ctx.spawn([](sdbusplus::async::context& ctx) -> sdbusplus::async::task<> {
+        ctx.request_name(reqDBusName);
+        co_return;
+    }(ctx));
+
+    ctx.run();
+
+    return 0;
+};