Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "dimm.hpp" |
| 18 | |
| 19 | #include "mdrv2.hpp" |
| 20 | |
kasunath | 634ec6a | 2022-07-25 15:34:17 -0700 | [diff] [blame] | 21 | #include <boost/algorithm/string.hpp> |
kasunath | 2eca4fe | 2022-08-17 17:30:07 -0700 | [diff] [blame] | 22 | #include <phosphor-logging/elog-errors.hpp> |
kasunath | 634ec6a | 2022-07-25 15:34:17 -0700 | [diff] [blame] | 23 | |
Jayaprakash Mutyala | a1ff244 | 2023-06-15 07:10:07 +0000 | [diff] [blame^] | 24 | #include <regex> |
| 25 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 26 | namespace phosphor |
| 27 | { |
| 28 | namespace smbios |
| 29 | { |
| 30 | |
John Edward Broadbent | efd4154 | 2022-12-13 16:39:18 -0800 | [diff] [blame] | 31 | #ifdef DIMM_ONLY_LOCATOR |
| 32 | bool onlyDimmLocationCode = true; |
| 33 | #else |
| 34 | bool onlyDimmLocationCode = false; |
| 35 | #endif |
| 36 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 37 | using DeviceType = |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 38 | sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm::DeviceType; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 39 | |
kasunath | 2eca4fe | 2022-08-17 17:30:07 -0700 | [diff] [blame] | 40 | using EccType = |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 41 | sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm::Ecc; |
kasunath | 2eca4fe | 2022-08-17 17:30:07 -0700 | [diff] [blame] | 42 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 43 | static constexpr uint16_t maxOldDimmSize = 0x7fff; |
Brandon Kim | 5a122a6 | 2023-05-04 04:25:03 +0000 | [diff] [blame] | 44 | void Dimm::memoryInfoUpdate(uint8_t* smbiosTableStorage, |
| 45 | const std::string& motherboard) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 46 | { |
Brandon Kim | 5a122a6 | 2023-05-04 04:25:03 +0000 | [diff] [blame] | 47 | storage = smbiosTableStorage; |
| 48 | motherboardPath = motherboard; |
| 49 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 50 | uint8_t* dataIn = storage; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 51 | |
| 52 | dataIn = getSMBIOSTypePtr(dataIn, memoryDeviceType); |
| 53 | |
| 54 | if (dataIn == nullptr) |
| 55 | { |
| 56 | return; |
| 57 | } |
| 58 | for (uint8_t index = 0; index < dimmNum; index++) |
| 59 | { |
| 60 | dataIn = smbiosNextPtr(dataIn); |
| 61 | if (dataIn == nullptr) |
| 62 | { |
| 63 | return; |
| 64 | } |
| 65 | dataIn = getSMBIOSTypePtr(dataIn, memoryDeviceType); |
| 66 | if (dataIn == nullptr) |
| 67 | { |
| 68 | return; |
| 69 | } |
| 70 | } |
| 71 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 72 | auto memoryInfo = reinterpret_cast<struct MemoryInfo*>(dataIn); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 73 | |
| 74 | memoryDataWidth(memoryInfo->dataWidth); |
| 75 | |
| 76 | if (memoryInfo->size == maxOldDimmSize) |
| 77 | { |
| 78 | dimmSizeExt(memoryInfo->extendedSize); |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | dimmSize(memoryInfo->size); |
| 83 | } |
Tom Tung | 39cc368 | 2023-03-15 04:44:04 +0800 | [diff] [blame] | 84 | // If the size is 0, no memory device is installed in the socket. |
| 85 | const auto isDimmPresent = memoryInfo->size > 0; |
| 86 | present(isDimmPresent); |
| 87 | functional(isDimmPresent); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 88 | |
Konstantin Aladyshev | 744b35a | 2022-11-02 08:34:27 +0000 | [diff] [blame] | 89 | dimmDeviceLocator(memoryInfo->bankLocator, memoryInfo->deviceLocator, |
| 90 | memoryInfo->length, dataIn); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 91 | dimmType(memoryInfo->memoryType); |
| 92 | dimmTypeDetail(memoryInfo->typeDetail); |
| 93 | maxMemorySpeedInMhz(memoryInfo->speed); |
| 94 | dimmManufacturer(memoryInfo->manufacturer, memoryInfo->length, dataIn); |
| 95 | dimmSerialNum(memoryInfo->serialNum, memoryInfo->length, dataIn); |
| 96 | dimmPartNum(memoryInfo->partNum, memoryInfo->length, dataIn); |
| 97 | memoryAttributes(memoryInfo->attributes); |
Jayaprakash Mutyala | a1ff244 | 2023-06-15 07:10:07 +0000 | [diff] [blame^] | 98 | dimmMedia(memoryInfo->memoryTechnology); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 99 | memoryConfiguredSpeedInMhz(memoryInfo->confClockSpeed); |
| 100 | |
kasunath | 2eca4fe | 2022-08-17 17:30:07 -0700 | [diff] [blame] | 101 | updateEccType(memoryInfo->phyArrayHandle); |
| 102 | |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 103 | if (!motherboardPath.empty()) |
| 104 | { |
| 105 | std::vector<std::tuple<std::string, std::string, std::string>> assocs; |
| 106 | assocs.emplace_back("chassis", "memories", motherboardPath); |
| 107 | association::associations(assocs); |
| 108 | } |
| 109 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 110 | return; |
| 111 | } |
| 112 | |
kasunath | 2eca4fe | 2022-08-17 17:30:07 -0700 | [diff] [blame] | 113 | void Dimm::updateEccType(uint16_t exPhyArrayHandle) |
| 114 | { |
| 115 | uint8_t* dataIn = storage; |
| 116 | |
| 117 | while (dataIn != nullptr) |
| 118 | { |
| 119 | dataIn = getSMBIOSTypePtr(dataIn, physicalMemoryArrayType); |
| 120 | if (dataIn == nullptr) |
| 121 | { |
| 122 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 123 | "Failed to get SMBIOS table type-16 data."); |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | auto info = reinterpret_cast<struct PhysicalMemoryArrayInfo*>(dataIn); |
| 128 | if (info->handle == exPhyArrayHandle) |
| 129 | { |
| 130 | std::map<uint8_t, EccType>::const_iterator it = |
| 131 | dimmEccTypeMap.find(info->memoryErrorCorrection); |
| 132 | if (it == dimmEccTypeMap.end()) |
| 133 | { |
| 134 | ecc(EccType::NoECC); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | ecc(it->second); |
| 139 | } |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | dataIn = smbiosNextPtr(dataIn); |
| 144 | } |
| 145 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 146 | "Failed find the corresponding SMBIOS table type-16 data for dimm:", |
| 147 | phosphor::logging::entry("DIMM:%d", dimmNum)); |
| 148 | } |
| 149 | |
| 150 | EccType Dimm::ecc(EccType value) |
| 151 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 152 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm::ecc( |
kasunath | 2eca4fe | 2022-08-17 17:30:07 -0700 | [diff] [blame] | 153 | value); |
| 154 | } |
| 155 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 156 | uint16_t Dimm::memoryDataWidth(uint16_t value) |
| 157 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 158 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 159 | memoryDataWidth(value); |
| 160 | } |
| 161 | |
| 162 | static constexpr uint16_t baseNewVersionDimmSize = 0x8000; |
| 163 | static constexpr uint16_t dimmSizeUnit = 1024; |
| 164 | void Dimm::dimmSize(const uint16_t size) |
| 165 | { |
Joseph Fu | 0b1d942 | 2023-03-31 17:47:12 +0800 | [diff] [blame] | 166 | uint32_t result = size & maxOldDimmSize; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 167 | if (0 == (size & baseNewVersionDimmSize)) |
| 168 | { |
| 169 | result = result * dimmSizeUnit; |
| 170 | } |
| 171 | memorySizeInKB(result); |
| 172 | } |
| 173 | |
Joseph Fu | 0b1d942 | 2023-03-31 17:47:12 +0800 | [diff] [blame] | 174 | void Dimm::dimmSizeExt(uint32_t size) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 175 | { |
| 176 | size = size * dimmSizeUnit; |
| 177 | memorySizeInKB(size); |
| 178 | } |
| 179 | |
Jason M. Bills | e777099 | 2021-05-14 13:24:33 -0700 | [diff] [blame] | 180 | size_t Dimm::memorySizeInKB(size_t value) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 181 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 182 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 183 | memorySizeInKB(value); |
| 184 | } |
| 185 | |
Konstantin Aladyshev | 744b35a | 2022-11-02 08:34:27 +0000 | [diff] [blame] | 186 | void Dimm::dimmDeviceLocator(const uint8_t bankLocatorPositionNum, |
| 187 | const uint8_t deviceLocatorPositionNum, |
| 188 | const uint8_t structLen, uint8_t* dataIn) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 189 | { |
Patrick Williams | c39d3df | 2023-05-10 07:51:14 -0500 | [diff] [blame] | 190 | std::string deviceLocator = positionToString(deviceLocatorPositionNum, |
| 191 | structLen, dataIn); |
| 192 | std::string bankLocator = positionToString(bankLocatorPositionNum, |
| 193 | structLen, dataIn); |
Konstantin Aladyshev | 744b35a | 2022-11-02 08:34:27 +0000 | [diff] [blame] | 194 | |
| 195 | std::string result; |
John Edward Broadbent | efd4154 | 2022-12-13 16:39:18 -0800 | [diff] [blame] | 196 | if (bankLocator.empty() || onlyDimmLocationCode) |
Konstantin Aladyshev | 744b35a | 2022-11-02 08:34:27 +0000 | [diff] [blame] | 197 | { |
John Edward Broadbent | efd4154 | 2022-12-13 16:39:18 -0800 | [diff] [blame] | 198 | result = deviceLocator; |
Konstantin Aladyshev | 744b35a | 2022-11-02 08:34:27 +0000 | [diff] [blame] | 199 | } |
| 200 | else |
| 201 | { |
John Edward Broadbent | efd4154 | 2022-12-13 16:39:18 -0800 | [diff] [blame] | 202 | result = bankLocator + " " + deviceLocator; |
Konstantin Aladyshev | 744b35a | 2022-11-02 08:34:27 +0000 | [diff] [blame] | 203 | } |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 204 | |
| 205 | memoryDeviceLocator(result); |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 206 | |
| 207 | locationCode(result); |
Jayaprakash Mutyala | a1ff244 | 2023-06-15 07:10:07 +0000 | [diff] [blame^] | 208 | const std::string substrCpu = "CPU"; |
| 209 | auto cpuPos = deviceLocator.find(substrCpu); |
| 210 | |
| 211 | if (cpuPos != std::string::npos) |
| 212 | { |
| 213 | std::string socketString = |
| 214 | deviceLocator.substr(cpuPos + substrCpu.length(), 1); |
| 215 | try |
| 216 | { |
| 217 | uint8_t socketNum = |
| 218 | static_cast<uint8_t>(std::stoi(socketString) + 1); |
| 219 | socket(socketNum); |
| 220 | } |
| 221 | catch (const sdbusplus::exception_t& ex) |
| 222 | { |
| 223 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 224 | "std::stoi operation failed ", |
| 225 | phosphor::logging::entry("ERROR=%s", ex.what())); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | const std::string substrDimm = "DIMM"; |
| 230 | auto dimmPos = deviceLocator.find(substrDimm); |
| 231 | |
| 232 | if (dimmPos != std::string::npos) |
| 233 | { |
| 234 | std::string slotString = |
| 235 | deviceLocator.substr(dimmPos + substrDimm.length() + 1); |
| 236 | /* slotString is extracted from substrDimm (DIMM_A) if slotString is |
| 237 | * single alphabet like A, B , C.. then assign ASCII value of slotString |
| 238 | * to slot */ |
| 239 | if ((std::regex_match(slotString, std::regex("^[A-Za-z]+$"))) && |
| 240 | (slotString.length() == 1)) |
| 241 | { |
| 242 | slot(static_cast<uint8_t>(toupper(slotString[0]))); |
| 243 | } |
| 244 | } |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | std::string Dimm::memoryDeviceLocator(std::string value) |
| 248 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 249 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 250 | memoryDeviceLocator(value); |
| 251 | } |
| 252 | |
| 253 | void Dimm::dimmType(const uint8_t type) |
| 254 | { |
| 255 | std::map<uint8_t, DeviceType>::const_iterator it = dimmTypeTable.find(type); |
| 256 | if (it == dimmTypeTable.end()) |
| 257 | { |
| 258 | memoryType(DeviceType::Unknown); |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | memoryType(it->second); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | DeviceType Dimm::memoryType(DeviceType value) |
| 267 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 268 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 269 | memoryType(value); |
| 270 | } |
| 271 | |
Jayaprakash Mutyala | a1ff244 | 2023-06-15 07:10:07 +0000 | [diff] [blame^] | 272 | void Dimm::dimmMedia(const uint8_t type) |
| 273 | { |
| 274 | std::map<uint8_t, MemoryTechType>::const_iterator it = |
| 275 | dimmMemoryTechTypeMap.find(type); |
| 276 | if (it == dimmMemoryTechTypeMap.end()) |
| 277 | { |
| 278 | memoryMedia(MemoryTechType::Unknown); |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | memoryMedia(it->second); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | MemoryTechType Dimm::memoryMedia(MemoryTechType value) |
| 287 | { |
| 288 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
| 289 | memoryMedia(value); |
| 290 | } |
| 291 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 292 | void Dimm::dimmTypeDetail(uint16_t detail) |
| 293 | { |
| 294 | std::string result; |
| 295 | for (uint8_t index = 0; index < (8 * sizeof(detail)); index++) |
| 296 | { |
| 297 | if (detail & 0x01) |
| 298 | { |
| 299 | result += detailTable[index]; |
| 300 | } |
| 301 | detail >>= 1; |
| 302 | } |
| 303 | memoryTypeDetail(result); |
| 304 | } |
| 305 | |
| 306 | std::string Dimm::memoryTypeDetail(std::string value) |
| 307 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 308 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 309 | memoryTypeDetail(value); |
| 310 | } |
| 311 | |
| 312 | uint16_t Dimm::maxMemorySpeedInMhz(uint16_t value) |
| 313 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 314 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 315 | maxMemorySpeedInMhz(value); |
| 316 | } |
| 317 | |
| 318 | void Dimm::dimmManufacturer(const uint8_t positionNum, const uint8_t structLen, |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 319 | uint8_t* dataIn) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 320 | { |
| 321 | std::string result = positionToString(positionNum, structLen, dataIn); |
| 322 | |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 323 | if (result == "NO DIMM") |
| 324 | { |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 325 | // No dimm presence so making manufacturer value as "" (instead of |
| 326 | // NO DIMM - as there won't be any manufacturer for DIMM which is not |
| 327 | // present). |
| 328 | result = ""; |
| 329 | } |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 330 | manufacturer(result); |
| 331 | } |
| 332 | |
| 333 | std::string Dimm::manufacturer(std::string value) |
| 334 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 335 | return sdbusplus::server::xyz::openbmc_project::inventory::decorator:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 336 | Asset::manufacturer(value); |
| 337 | } |
| 338 | |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 339 | bool Dimm::present(bool value) |
| 340 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 341 | return sdbusplus::server::xyz::openbmc_project::inventory::Item::present( |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 342 | value); |
| 343 | } |
| 344 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 345 | void Dimm::dimmSerialNum(const uint8_t positionNum, const uint8_t structLen, |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 346 | uint8_t* dataIn) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 347 | { |
| 348 | std::string result = positionToString(positionNum, structLen, dataIn); |
| 349 | |
| 350 | serialNumber(result); |
| 351 | } |
| 352 | |
| 353 | std::string Dimm::serialNumber(std::string value) |
| 354 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 355 | return sdbusplus::server::xyz::openbmc_project::inventory::decorator:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 356 | Asset::serialNumber(value); |
| 357 | } |
| 358 | |
| 359 | void Dimm::dimmPartNum(const uint8_t positionNum, const uint8_t structLen, |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 360 | uint8_t* dataIn) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 361 | { |
| 362 | std::string result = positionToString(positionNum, structLen, dataIn); |
| 363 | |
kasunath | 634ec6a | 2022-07-25 15:34:17 -0700 | [diff] [blame] | 364 | // Part number could contain spaces at the end. Eg: "abcd123 ". Since its |
| 365 | // unnecessary, we should remove them. |
| 366 | boost::algorithm::trim_right(result); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 367 | partNumber(result); |
| 368 | } |
| 369 | |
| 370 | std::string Dimm::partNumber(std::string value) |
| 371 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 372 | return sdbusplus::server::xyz::openbmc_project::inventory::decorator:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 373 | Asset::partNumber(value); |
| 374 | } |
| 375 | |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 376 | std::string Dimm::locationCode(std::string value) |
| 377 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 378 | return sdbusplus::server::xyz::openbmc_project::inventory::decorator:: |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 379 | LocationCode::locationCode(value); |
| 380 | } |
| 381 | |
George Liu | 036374a | 2023-06-15 08:47:46 +0800 | [diff] [blame] | 382 | size_t Dimm::memoryAttributes(size_t value) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 383 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 384 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 385 | memoryAttributes(value); |
| 386 | } |
| 387 | |
Jayaprakash Mutyala | a1ff244 | 2023-06-15 07:10:07 +0000 | [diff] [blame^] | 388 | uint8_t Dimm::slot(uint8_t value) |
| 389 | { |
| 390 | return sdbusplus::server::xyz::openbmc_project::inventory::item::dimm:: |
| 391 | MemoryLocation::slot(value); |
| 392 | } |
| 393 | |
| 394 | uint8_t Dimm::socket(uint8_t value) |
| 395 | { |
| 396 | return sdbusplus::server::xyz::openbmc_project::inventory::item::dimm:: |
| 397 | MemoryLocation::socket(value); |
| 398 | } |
| 399 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 400 | uint16_t Dimm::memoryConfiguredSpeedInMhz(uint16_t value) |
| 401 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 402 | return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm:: |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 403 | memoryConfiguredSpeedInMhz(value); |
| 404 | } |
| 405 | |
Tim Lee | dc469c7 | 2021-07-20 10:55:58 +0800 | [diff] [blame] | 406 | bool Dimm::functional(bool value) |
| 407 | { |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 408 | return sdbusplus::server::xyz::openbmc_project::state::decorator:: |
Tim Lee | dc469c7 | 2021-07-20 10:55:58 +0800 | [diff] [blame] | 409 | OperationalStatus::functional(value); |
| 410 | } |
| 411 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 412 | } // namespace smbios |
| 413 | } // namespace phosphor |