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 | |
Alexander Hansen | ade5c5a | 2025-07-29 13:38:24 +0200 | [diff] [blame^] | 15 | class ExampleDevice; |
| 16 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 17 | class ExampleCodeUpdater : public phosphor::software::manager::SoftwareManager |
| 18 | { |
| 19 | public: |
| 20 | ExampleCodeUpdater(sdbusplus::async::context& ctx, |
| 21 | long uniqueSuffix = getRandomId()); |
| 22 | |
Alexander Hansen | ade5c5a | 2025-07-29 13:38:24 +0200 | [diff] [blame^] | 23 | // @param swVersion if this is nullptr, do not create the software |
| 24 | // version. |
| 25 | ExampleCodeUpdater(sdbusplus::async::context& ctx, const char* swVersion); |
| 26 | |
| 27 | std::unique_ptr<ExampleDevice>& getDevice(); |
| 28 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 29 | sdbusplus::async::task<bool> initDevice(const std::string& service, |
| 30 | const std::string& path, |
| 31 | SoftwareConfig& config) final; |
| 32 | |
Alexander Hansen | ade5c5a | 2025-07-29 13:38:24 +0200 | [diff] [blame^] | 33 | using SoftwareManager::getBusName; |
| 34 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 35 | private: |
| 36 | static long getRandomId(); |
| 37 | }; |
| 38 | |
| 39 | const std::string exampleName = "ExampleSoftware"; |
| 40 | |
| 41 | const uint32_t exampleVendorIANA = 0x0000a015; |
| 42 | const std::string exampleCompatibleHardware = "com.example.CompatibleDevice"; |
| 43 | |
| 44 | const std::string exampleInvObjPath = |
| 45 | "/xyz/openbmc_project/inventory/system/board/ExampleBoard/ExampleDevice"; |
| 46 | |
Alexander Hansen | ade5c5a | 2025-07-29 13:38:24 +0200 | [diff] [blame^] | 47 | class ExampleSoftware : public Software |
| 48 | { |
| 49 | public: |
| 50 | using Software::createInventoryAssociation; |
| 51 | using Software::objectPath; |
| 52 | ExampleSoftware(sdbusplus::async::context& ctx, ExampleDevice& parent); |
| 53 | }; |
| 54 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 55 | class ExampleDevice : public Device |
| 56 | { |
| 57 | public: |
Alexander Hansen | ade5c5a | 2025-07-29 13:38:24 +0200 | [diff] [blame^] | 58 | using Device::softwareCurrent; |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 59 | using Device::softwarePending; |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 60 | |
| 61 | static SoftwareConfig defaultConfig; |
| 62 | |
| 63 | ExampleDevice(sdbusplus::async::context& ctx, |
| 64 | phosphor::software::manager::SoftwareManager* parent, |
| 65 | const SoftwareConfig& config = defaultConfig); |
| 66 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 67 | sdbusplus::async::task<bool> updateDevice(const uint8_t* image, |
| 68 | size_t image_size) override; |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 69 | |
| 70 | bool deviceSpecificUpdateFunctionCalled = false; |
| 71 | }; |
| 72 | |
| 73 | } // namespace phosphor::software::example_device |