Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "instance_id.hpp" |
| 4 | #include "xyz/openbmc_project/PLDM/Requester/server.hpp" |
| 5 | |
Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <sdbusplus/server/object.hpp> |
| 8 | |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 9 | #include <map> |
| 10 | |
Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 11 | namespace pldm |
| 12 | { |
| 13 | namespace dbus_api |
| 14 | { |
| 15 | |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 16 | using RequesterIntf = sdbusplus::server::object_t< |
Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 17 | sdbusplus::xyz::openbmc_project::PLDM::server::Requester>; |
| 18 | |
| 19 | /** @class Requester |
| 20 | * @brief OpenBMC PLDM.Requester implementation. |
| 21 | * @details A concrete implementation for the |
| 22 | * xyz.openbmc_project.PLDM.Requester DBus APIs. |
| 23 | */ |
| 24 | class Requester : public RequesterIntf |
| 25 | { |
| 26 | public: |
| 27 | Requester() = delete; |
| 28 | Requester(const Requester&) = delete; |
| 29 | Requester& operator=(const Requester&) = delete; |
| 30 | Requester(Requester&&) = delete; |
| 31 | Requester& operator=(Requester&&) = delete; |
| 32 | virtual ~Requester() = default; |
| 33 | |
| 34 | /** @brief Constructor to put object onto bus at a dbus path. |
| 35 | * @param[in] bus - Bus to attach to. |
| 36 | * @param[in] path - Path to attach at. |
| 37 | */ |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 38 | Requester(sdbusplus::bus_t& bus, const std::string& path) : |
Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 39 | RequesterIntf(bus, path.c_str()){}; |
| 40 | |
| 41 | /** @brief Implementation for RequesterIntf.GetInstanceId */ |
| 42 | uint8_t getInstanceId(uint8_t eid) override; |
| 43 | |
| 44 | /** @brief Mark an instance id as unused |
| 45 | * @param[in] eid - MCTP eid to which this instance id belongs |
| 46 | * @param[in] instanceId - PLDM instance id to be freed |
| 47 | * @note will throw std::out_of_range if instanceId > 31 |
| 48 | */ |
| 49 | void markFree(uint8_t eid, uint8_t instanceId) |
| 50 | { |
| 51 | ids[eid].markFree(instanceId); |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | /** @brief EID to PLDM Instance ID map */ |
| 56 | std::map<uint8_t, InstanceId> ids; |
| 57 | }; |
| 58 | |
| 59 | } // namespace dbus_api |
| 60 | } // namespace pldm |