xref: /openbmc/phosphor-bmc-code-mgmt/common/include/software_config.hpp (revision cc37235521b98887b31d07e8aedd0d86320eeb1d)
1 #pragma once
2 
3 #include "sdbusplus/async/context.hpp"
4 
5 #include <cstdint>
6 #include <string>
7 
8 namespace phosphor::software::device
9 {
10 class Device;
11 }
12 
13 using namespace phosphor::software::device;
14 
15 namespace phosphor::software::config
16 {
17 
18 /* This class represents the device software configuration we get from
19  * entity-manager via D-Bus. Each Code Updater can create its own configuration
20  * class that inherits from this to store additional properties from their
21  * device configuration, like bus/address/...
22  */
23 class SoftwareConfig
24 {
25   public:
26     SoftwareConfig(const std::string& objPath, uint32_t vendorIANA,
27                    const std::string& compatible, const std::string& configType,
28                    const std::string& name);
29 
30     // The dbus object path this configuration was fetched from
31     const std::string objectPath;
32 
33     // https://github.com/openbmc/entity-manager/blob/master/schemas/firmware.json
34 
35     // 'Name' field from the EM config
36     const std::string configName;
37 
38     // 'Type' field from the EM config
39     const std::string configType;
40 
41     // @returns        the object path of the inventory item which
42     //                 can be associated with this device.
43     sdbusplus::async::task<std::string> getInventoryItemObjectPath(
44         sdbusplus::async::context& ctx);
45 
46   private:
47     // 'VendorIANA' field from the EM config
48     const uint32_t vendorIANA; // e.g. "0x0000A015", 4 bytes as per PLDM spec
49 
50     // 'CompatibleHardware' field from the EM config
51     const std::string
52         compatibleHardware; // e.g.
53                             // "com.meta.Hardware.Yosemite4.MedusaBoard.CPLD.LCMX02_2000HC"
54 
55     friend Device;
56 };
57 
58 }; // namespace phosphor::software::config
59