Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "common/include/device.hpp" |
| 4 | #include "common/include/software_manager.hpp" |
| 5 | |
| 6 | #include <phosphor-logging/lg2.hpp> |
| 7 | #include <sdbusplus/async.hpp> |
| 8 | #include <sdbusplus/server.hpp> |
| 9 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
| 10 | #include <xyz/openbmc_project/Software/Update/server.hpp> |
| 11 | |
| 12 | namespace phosphor::software::example_device |
| 13 | { |
| 14 | |
| 15 | class ExampleCodeUpdater : public phosphor::software::manager::SoftwareManager |
| 16 | { |
| 17 | public: |
| 18 | ExampleCodeUpdater(sdbusplus::async::context& ctx, |
| 19 | long uniqueSuffix = getRandomId()); |
| 20 | |
| 21 | sdbusplus::async::task<bool> initDevice(const std::string& service, |
| 22 | const std::string& path, |
| 23 | SoftwareConfig& config) final; |
| 24 | |
| 25 | private: |
| 26 | static long getRandomId(); |
| 27 | }; |
| 28 | |
| 29 | const std::string exampleName = "ExampleSoftware"; |
| 30 | |
| 31 | const uint32_t exampleVendorIANA = 0x0000a015; |
| 32 | const std::string exampleCompatibleHardware = "com.example.CompatibleDevice"; |
| 33 | |
| 34 | const std::string exampleInvObjPath = |
| 35 | "/xyz/openbmc_project/inventory/system/board/ExampleBoard/ExampleDevice"; |
| 36 | |
| 37 | class ExampleDevice : public Device |
| 38 | { |
| 39 | public: |
| 40 | using Device::softwarePending; |
| 41 | using phosphor::software::device::Device::softwareCurrent; |
| 42 | |
| 43 | static SoftwareConfig defaultConfig; |
| 44 | |
| 45 | ExampleDevice(sdbusplus::async::context& ctx, |
| 46 | phosphor::software::manager::SoftwareManager* parent, |
| 47 | const SoftwareConfig& config = defaultConfig); |
| 48 | |
| 49 | // NOLINTBEGIN(readability-static-accessed-through-instance) |
| 50 | sdbusplus::async::task<bool> updateDevice(const uint8_t* image, |
| 51 | size_t image_size) override; |
| 52 | // NOLINTEND(readability-static-accessed-through-instance) |
| 53 | |
| 54 | bool deviceSpecificUpdateFunctionCalled = false; |
| 55 | }; |
| 56 | |
| 57 | } // namespace phosphor::software::example_device |