SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 1 | #include <algorithm> |
| 2 | #include <com/ibm/VPD/Manager/server.hpp> |
| 3 | #include <com/ibm/VPD/error.hpp> |
| 4 | #include <map> |
| 5 | #include <sdbusplus/exception.hpp> |
| 6 | #include <sdbusplus/sdbus.hpp> |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 7 | #include <sdbusplus/sdbuspp_support/server.hpp> |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 8 | #include <sdbusplus/server.hpp> |
| 9 | #include <string> |
| 10 | #include <tuple> |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 11 | #include <xyz/openbmc_project/Common/error.hpp> |
| 12 | |
| 13 | namespace sdbusplus |
| 14 | { |
| 15 | namespace com |
| 16 | { |
| 17 | namespace ibm |
| 18 | { |
| 19 | namespace VPD |
| 20 | { |
| 21 | namespace server |
| 22 | { |
| 23 | |
Patrick Williams | 2eb0176 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 24 | Manager::Manager(bus_t& bus, const char* path) : |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 25 | _com_ibm_VPD_Manager_interface(bus, path, interface, _vtable, this), |
| 26 | _intf(bus.getInterface()) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | int Manager::_callback_WriteKeyword(sd_bus_message* msg, void* context, |
| 31 | sd_bus_error* error) |
| 32 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 33 | auto o = static_cast<Manager*>(context); |
| 34 | |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 35 | try |
| 36 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 37 | return sdbusplus::sdbuspp::method_callback( |
| 38 | msg, o->_intf, error, |
| 39 | std::function([=](sdbusplus::message::object_path&& path, |
| 40 | std::string&& record, std::string&& keyword, |
| 41 | std::vector<uint8_t>&& value) { |
| 42 | return o->writeKeyword(path, record, keyword, value); |
| 43 | })); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 44 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 45 | catch ( |
| 46 | const sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& |
| 47 | e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 48 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 49 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 50 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 51 | catch (const sdbusplus::com::ibm::VPD::Error::PathNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 52 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 53 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 54 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 55 | catch (const sdbusplus::com::ibm::VPD::Error::RecordNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 56 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 57 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 58 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 59 | catch (const sdbusplus::com::ibm::VPD::Error::KeywordNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 60 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 61 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 62 | } |
| 63 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 64 | return 0; |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | namespace details |
| 68 | { |
| 69 | namespace Manager |
| 70 | { |
| 71 | static const auto _param_WriteKeyword = utility::tuple_to_array( |
| 72 | message::types::type_id<sdbusplus::message::object_path, std::string, |
| 73 | std::string, std::vector<uint8_t>>()); |
| 74 | static const auto _return_WriteKeyword = |
| 75 | utility::tuple_to_array(std::make_tuple('\0')); |
| 76 | } // namespace Manager |
| 77 | } // namespace details |
| 78 | |
| 79 | int Manager::_callback_GetFRUsByUnexpandedLocationCode(sd_bus_message* msg, |
| 80 | void* context, |
| 81 | sd_bus_error* error) |
| 82 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 83 | auto o = static_cast<Manager*>(context); |
| 84 | |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 85 | try |
| 86 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 87 | return sdbusplus::sdbuspp::method_callback( |
| 88 | msg, o->_intf, error, |
| 89 | std::function( |
| 90 | [=](std::string&& locationCode, uint16_t&& nodeNumber) { |
| 91 | return o->getFRUsByUnexpandedLocationCode(locationCode, |
| 92 | nodeNumber); |
| 93 | })); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 94 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 95 | catch ( |
| 96 | const sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& |
| 97 | e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 98 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 99 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 100 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 101 | catch (const sdbusplus::com::ibm::VPD::Error::LocationNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 102 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 103 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 104 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 105 | catch (const sdbusplus::com::ibm::VPD::Error::NodeNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 106 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 107 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 108 | } |
| 109 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 110 | return 0; |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | namespace details |
| 114 | { |
| 115 | namespace Manager |
| 116 | { |
| 117 | static const auto _param_GetFRUsByUnexpandedLocationCode = |
| 118 | utility::tuple_to_array(message::types::type_id<std::string, uint16_t>()); |
| 119 | static const auto _return_GetFRUsByUnexpandedLocationCode = |
| 120 | utility::tuple_to_array(message::types::type_id< |
| 121 | std::vector<sdbusplus::message::object_path>>()); |
| 122 | } // namespace Manager |
| 123 | } // namespace details |
| 124 | |
| 125 | int Manager::_callback_GetFRUsByExpandedLocationCode(sd_bus_message* msg, |
| 126 | void* context, |
| 127 | sd_bus_error* error) |
| 128 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 129 | auto o = static_cast<Manager*>(context); |
| 130 | |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 131 | try |
| 132 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 133 | return sdbusplus::sdbuspp::method_callback( |
| 134 | msg, o->_intf, error, |
| 135 | std::function([=](std::string&& locationCode) { |
| 136 | return o->getFRUsByExpandedLocationCode(locationCode); |
| 137 | })); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 138 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 139 | catch ( |
| 140 | const sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& |
| 141 | e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 142 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 143 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 144 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 145 | catch (const sdbusplus::com::ibm::VPD::Error::LocationNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 146 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 147 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 148 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 149 | catch (const sdbusplus::com::ibm::VPD::Error::NodeNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 150 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 151 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 152 | } |
| 153 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 154 | return 0; |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | namespace details |
| 158 | { |
| 159 | namespace Manager |
| 160 | { |
| 161 | static const auto _param_GetFRUsByExpandedLocationCode = |
| 162 | utility::tuple_to_array(message::types::type_id<std::string>()); |
| 163 | static const auto _return_GetFRUsByExpandedLocationCode = |
| 164 | utility::tuple_to_array(message::types::type_id< |
| 165 | std::vector<sdbusplus::message::object_path>>()); |
| 166 | } // namespace Manager |
| 167 | } // namespace details |
| 168 | |
| 169 | int Manager::_callback_GetExpandedLocationCode(sd_bus_message* msg, |
| 170 | void* context, |
| 171 | sd_bus_error* error) |
| 172 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 173 | auto o = static_cast<Manager*>(context); |
| 174 | |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 175 | try |
| 176 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 177 | return sdbusplus::sdbuspp::method_callback( |
| 178 | msg, o->_intf, error, |
| 179 | std::function( |
| 180 | [=](std::string&& locationCode, uint16_t&& nodeNumber) { |
| 181 | return o->getExpandedLocationCode(locationCode, nodeNumber); |
| 182 | })); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 183 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 184 | catch ( |
| 185 | const sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& |
| 186 | e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 187 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 188 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 189 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 190 | catch (const sdbusplus::com::ibm::VPD::Error::LocationNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 191 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 192 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 193 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 194 | catch (const sdbusplus::com::ibm::VPD::Error::NodeNotFound& e) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 195 | { |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 196 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 197 | } |
| 198 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 199 | return 0; |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | namespace details |
| 203 | { |
| 204 | namespace Manager |
| 205 | { |
| 206 | static const auto _param_GetExpandedLocationCode = |
| 207 | utility::tuple_to_array(message::types::type_id<std::string, uint16_t>()); |
| 208 | static const auto _return_GetExpandedLocationCode = |
| 209 | utility::tuple_to_array(message::types::type_id<std::string>()); |
| 210 | } // namespace Manager |
| 211 | } // namespace details |
| 212 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 213 | int Manager::_callback_PerformVPDRecollection(sd_bus_message* msg, |
| 214 | void* context, |
| 215 | sd_bus_error* error) |
| 216 | { |
| 217 | auto o = static_cast<Manager*>(context); |
| 218 | |
| 219 | try |
| 220 | { |
| 221 | return sdbusplus::sdbuspp::method_callback( |
| 222 | msg, o->_intf, error, |
| 223 | std::function([=]() { return o->performVPDRecollection(); })); |
| 224 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 225 | catch ( |
| 226 | const sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& |
| 227 | e) |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 228 | { |
| 229 | return o->_intf->sd_bus_error_set(error, e.name(), e.description()); |
| 230 | } |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | namespace details |
| 236 | { |
| 237 | namespace Manager |
| 238 | { |
| 239 | static const auto _param_PerformVPDRecollection = |
| 240 | utility::tuple_to_array(std::make_tuple('\0')); |
| 241 | static const auto _return_PerformVPDRecollection = |
| 242 | utility::tuple_to_array(std::make_tuple('\0')); |
| 243 | } // namespace Manager |
| 244 | } // namespace details |
| 245 | |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 246 | const vtable::vtable_t Manager::_vtable[] = { |
| 247 | vtable::start(), |
| 248 | |
| 249 | vtable::method("WriteKeyword", details::Manager::_param_WriteKeyword.data(), |
| 250 | details::Manager::_return_WriteKeyword.data(), |
| 251 | _callback_WriteKeyword), |
| 252 | |
| 253 | vtable::method( |
| 254 | "GetFRUsByUnexpandedLocationCode", |
| 255 | details::Manager::_param_GetFRUsByUnexpandedLocationCode.data(), |
| 256 | details::Manager::_return_GetFRUsByUnexpandedLocationCode.data(), |
| 257 | _callback_GetFRUsByUnexpandedLocationCode), |
| 258 | |
| 259 | vtable::method( |
| 260 | "GetFRUsByExpandedLocationCode", |
| 261 | details::Manager::_param_GetFRUsByExpandedLocationCode.data(), |
| 262 | details::Manager::_return_GetFRUsByExpandedLocationCode.data(), |
| 263 | _callback_GetFRUsByExpandedLocationCode), |
| 264 | |
| 265 | vtable::method("GetExpandedLocationCode", |
| 266 | details::Manager::_param_GetExpandedLocationCode.data(), |
| 267 | details::Manager::_return_GetExpandedLocationCode.data(), |
| 268 | _callback_GetExpandedLocationCode), |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 269 | |
| 270 | vtable::method("PerformVPDRecollection", |
| 271 | details::Manager::_param_PerformVPDRecollection.data(), |
| 272 | details::Manager::_return_PerformVPDRecollection.data(), |
| 273 | _callback_PerformVPDRecollection), |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 274 | vtable::end()}; |
| 275 | |
| 276 | } // namespace server |
| 277 | } // namespace VPD |
| 278 | } // namespace ibm |
| 279 | } // namespace com |
| 280 | } // namespace sdbusplus |