George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 1 | #include "custom_dbus.hpp" |
| 2 | |
| 3 | namespace pldm |
| 4 | { |
| 5 | namespace dbus |
| 6 | { |
| 7 | void CustomDBus::setLocationCode(const std::string& path, std::string value) |
| 8 | { |
| 9 | if (!location.contains(path)) |
| 10 | { |
| 11 | location.emplace(path, |
| 12 | std::make_unique<LocationIntf>( |
| 13 | pldm::utils::DBusHandler::getBus(), path.c_str())); |
| 14 | } |
| 15 | |
| 16 | location.at(path)->locationCode(value); |
| 17 | } |
| 18 | |
| 19 | std::optional<std::string> |
| 20 | CustomDBus::getLocationCode(const std::string& path) const |
| 21 | { |
| 22 | if (location.contains(path)) |
| 23 | { |
| 24 | return location.at(path)->locationCode(); |
| 25 | } |
| 26 | |
| 27 | return std::nullopt; |
| 28 | } |
| 29 | |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 30 | void CustomDBus::implementCpuCoreInterface(const std::string& path) |
| 31 | { |
| 32 | if (!cpuCore.contains(path)) |
| 33 | { |
| 34 | cpuCore.emplace(path, std::make_unique<CPUCore>( |
| 35 | pldm::utils::DBusHandler::getBus(), path)); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | void CustomDBus::setMicroCode(const std::string& path, uint32_t value) |
| 40 | { |
| 41 | if (!cpuCore.contains(path)) |
| 42 | { |
| 43 | cpuCore.emplace(path, std::make_unique<CPUCore>( |
| 44 | pldm::utils::DBusHandler::getBus(), path)); |
| 45 | } |
| 46 | cpuCore.at(path)->microcode(value); |
| 47 | } |
| 48 | |
| 49 | std::optional<uint32_t> CustomDBus::getMicroCode(const std::string& path) const |
| 50 | { |
| 51 | if (cpuCore.contains(path)) |
| 52 | { |
| 53 | return cpuCore.at(path)->microcode(); |
| 54 | } |
| 55 | |
| 56 | return std::nullopt; |
| 57 | } |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 58 | |
| 59 | void CustomDBus::implementPCIeSlotInterface(const std::string& path) |
| 60 | { |
| 61 | if (!pcieSlot.contains(path)) |
| 62 | { |
| 63 | pcieSlot.emplace(path, std::make_unique<PCIeSlot>( |
| 64 | pldm::utils::DBusHandler::getBus(), path)); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void CustomDBus::setSlotType(const std::string& path, |
| 69 | const std::string& slotType) |
| 70 | { |
| 71 | auto typeOfSlot = |
| 72 | pldm::dbus::PCIeSlot::convertSlotTypesFromString(slotType); |
| 73 | if (pcieSlot.contains(path)) |
| 74 | { |
| 75 | pcieSlot.at(path)->slotType(typeOfSlot); |
| 76 | } |
| 77 | } |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame^] | 78 | |
| 79 | void CustomDBus::implementPCIeDeviceInterface(const std::string& path) |
| 80 | { |
| 81 | if (!pcieDevice.contains(path)) |
| 82 | { |
| 83 | pcieDevice.emplace(path, std::make_unique<PCIeDevice>( |
| 84 | pldm::utils::DBusHandler::getBus(), path)); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void CustomDBus::setPCIeDeviceProps(const std::string& path, size_t lanesInUse, |
| 89 | const std::string& value) |
| 90 | { |
| 91 | Generations generationsInUse = |
| 92 | pldm::dbus::PCIeSlot::convertGenerationsFromString(value); |
| 93 | |
| 94 | if (pcieDevice.contains(path)) |
| 95 | { |
| 96 | pcieDevice.at(path)->lanesInUse(lanesInUse); |
| 97 | pcieDevice.at(path)->generationInUse(generationsInUse); |
| 98 | } |
| 99 | } |
| 100 | |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 101 | } // namespace dbus |
| 102 | } // namespace pldm |