blob: 52da92d4c69fbb76a57e6e58d8bc580d1a01ef9f [file] [log] [blame]
Alexander Hansenaa300642025-02-04 15:51:52 +01001#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
12namespace phosphor::software::example_device
13{
14
Alexander Hansenade5c5a2025-07-29 13:38:24 +020015class ExampleDevice;
16
Alexander Hansenaa300642025-02-04 15:51:52 +010017class ExampleCodeUpdater : public phosphor::software::manager::SoftwareManager
18{
19 public:
20 ExampleCodeUpdater(sdbusplus::async::context& ctx,
21 long uniqueSuffix = getRandomId());
22
Alexander Hansenade5c5a2025-07-29 13:38:24 +020023 // @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 Hansenaa300642025-02-04 15:51:52 +010029 sdbusplus::async::task<bool> initDevice(const std::string& service,
30 const std::string& path,
31 SoftwareConfig& config) final;
32
Alexander Hansenade5c5a2025-07-29 13:38:24 +020033 using SoftwareManager::getBusName;
34
Alexander Hansenaa300642025-02-04 15:51:52 +010035 private:
36 static long getRandomId();
37};
38
39const std::string exampleName = "ExampleSoftware";
40
41const uint32_t exampleVendorIANA = 0x0000a015;
42const std::string exampleCompatibleHardware = "com.example.CompatibleDevice";
43
44const std::string exampleInvObjPath =
45 "/xyz/openbmc_project/inventory/system/board/ExampleBoard/ExampleDevice";
46
Alexander Hansenade5c5a2025-07-29 13:38:24 +020047class 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 Hansenaa300642025-02-04 15:51:52 +010055class ExampleDevice : public Device
56{
57 public:
Alexander Hansenade5c5a2025-07-29 13:38:24 +020058 using Device::softwareCurrent;
Alexander Hansenaa300642025-02-04 15:51:52 +010059 using Device::softwarePending;
Alexander Hansenaa300642025-02-04 15:51:52 +010060
61 static SoftwareConfig defaultConfig;
62
63 ExampleDevice(sdbusplus::async::context& ctx,
64 phosphor::software::manager::SoftwareManager* parent,
65 const SoftwareConfig& config = defaultConfig);
66
Alexander Hansenaa300642025-02-04 15:51:52 +010067 sdbusplus::async::task<bool> updateDevice(const uint8_t* image,
68 size_t image_size) override;
Alexander Hansenaa300642025-02-04 15:51:52 +010069
70 bool deviceSpecificUpdateFunctionCalled = false;
71};
72
73} // namespace phosphor::software::example_device