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 | #pragma once |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 18 | #include "smbios_mdrv2.hpp" |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 19 | |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 20 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
Jie Yang | 41654fc | 2021-09-07 20:26:32 -0700 | [diff] [blame] | 21 | #include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp> |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 22 | #include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp> |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 23 | #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 24 | #include <xyz/openbmc_project/Inventory/Item/Dimm/server.hpp> |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 25 | #include <xyz/openbmc_project/Inventory/Item/server.hpp> |
Tim Lee | dc469c7 | 2021-07-20 10:55:58 +0800 | [diff] [blame] | 26 | #include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp> |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 27 | |
| 28 | namespace phosphor |
| 29 | { |
| 30 | |
| 31 | namespace smbios |
| 32 | { |
| 33 | |
| 34 | using DeviceType = |
| 35 | sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm::DeviceType; |
| 36 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 37 | class Dimm : |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 38 | sdbusplus::server::object_t< |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 39 | sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm>, |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 40 | sdbusplus::server::object_t< |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 41 | sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset>, |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 42 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 43 | Decorator::server::LocationCode>, |
| 44 | sdbusplus::server::object_t< |
Jie Yang | 41654fc | 2021-09-07 20:26:32 -0700 | [diff] [blame] | 45 | sdbusplus::xyz::openbmc_project::Inventory::Connector::server::Slot>, |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 46 | sdbusplus::server::object_t< |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 47 | sdbusplus::xyz::openbmc_project::Inventory::server::Item>, |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 48 | sdbusplus::server::object_t< |
Tim Lee | dc469c7 | 2021-07-20 10:55:58 +0800 | [diff] [blame] | 49 | sdbusplus::xyz::openbmc_project::Association::server::Definitions>, |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 50 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::State:: |
| 51 | Decorator::server::OperationalStatus> |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 52 | { |
| 53 | public: |
| 54 | Dimm() = delete; |
| 55 | ~Dimm() = default; |
| 56 | Dimm(const Dimm&) = delete; |
| 57 | Dimm& operator=(const Dimm&) = delete; |
| 58 | Dimm(Dimm&&) = default; |
| 59 | Dimm& operator=(Dimm&&) = default; |
| 60 | |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 61 | Dimm(sdbusplus::bus_t& bus, const std::string& objPath, |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 62 | const uint8_t& dimmId, uint8_t* smbiosTableStorage, |
| 63 | const std::string& motherboard) : |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 64 | |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 65 | sdbusplus::server::object_t< |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 66 | sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm>( |
| 67 | bus, objPath.c_str()), |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 68 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 69 | Decorator::server::Asset>( |
| 70 | bus, objPath.c_str()), |
| 71 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 72 | Decorator::server::LocationCode>( |
| 73 | bus, objPath.c_str()), |
| 74 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 75 | Connector::server::Slot>( |
| 76 | bus, objPath.c_str()), |
| 77 | sdbusplus::server::object_t< |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 78 | sdbusplus::xyz::openbmc_project::Inventory::server::Item>( |
| 79 | bus, objPath.c_str()), |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 80 | sdbusplus::server::object_t< |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 81 | sdbusplus::xyz::openbmc_project::Association::server::Definitions>( |
| 82 | bus, objPath.c_str()), |
Patrick Williams | 77b9c47 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 83 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::State:: |
| 84 | Decorator::server::OperationalStatus>( |
| 85 | bus, objPath.c_str()), |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 86 | dimmNum(dimmId), storage(smbiosTableStorage), |
| 87 | motherboardPath(motherboard) |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 88 | { |
| 89 | memoryInfoUpdate(); |
| 90 | } |
| 91 | |
| 92 | void memoryInfoUpdate(void); |
| 93 | |
| 94 | uint16_t memoryDataWidth(uint16_t value) override; |
Jason M. Bills | e777099 | 2021-05-14 13:24:33 -0700 | [diff] [blame] | 95 | size_t memorySizeInKB(size_t value) override; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 96 | std::string memoryDeviceLocator(std::string value) override; |
| 97 | DeviceType memoryType(DeviceType value) override; |
| 98 | std::string memoryTypeDetail(std::string value) override; |
| 99 | uint16_t maxMemorySpeedInMhz(uint16_t value) override; |
| 100 | std::string manufacturer(std::string value) override; |
Joshi-Mansi | 33c948a | 2021-03-20 00:58:50 +0530 | [diff] [blame] | 101 | bool present(bool value) override; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 102 | std::string serialNumber(std::string value) override; |
| 103 | std::string partNumber(std::string value) override; |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 104 | std::string locationCode(std::string value) override; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 105 | uint8_t memoryAttributes(uint8_t value) override; |
| 106 | uint16_t memoryConfiguredSpeedInMhz(uint16_t value) override; |
Tim Lee | dc469c7 | 2021-07-20 10:55:58 +0800 | [diff] [blame] | 107 | bool functional(bool value) override; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 108 | |
| 109 | private: |
| 110 | uint8_t dimmNum; |
| 111 | |
| 112 | uint8_t* storage; |
| 113 | |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 114 | std::string motherboardPath; |
| 115 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 116 | void dimmSize(const uint16_t size); |
Jason M. Bills | e777099 | 2021-05-14 13:24:33 -0700 | [diff] [blame] | 117 | void dimmSizeExt(const size_t size); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 118 | void dimmDeviceLocator(const uint8_t positionNum, const uint8_t structLen, |
| 119 | uint8_t* dataIn); |
| 120 | void dimmType(const uint8_t type); |
| 121 | void dimmTypeDetail(const uint16_t detail); |
| 122 | void dimmManufacturer(const uint8_t positionNum, const uint8_t structLen, |
| 123 | uint8_t* dataIn); |
| 124 | void dimmSerialNum(const uint8_t positionNum, const uint8_t structLen, |
| 125 | uint8_t* dataIn); |
| 126 | void dimmPartNum(const uint8_t positionNum, const uint8_t structLen, |
| 127 | uint8_t* dataIn); |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 128 | }; |
| 129 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 130 | struct MemoryInfo |
| 131 | { |
| 132 | uint8_t type; |
| 133 | uint8_t length; |
| 134 | uint16_t handle; |
| 135 | uint16_t phyArrayHandle; |
| 136 | uint16_t errInfoHandle; |
| 137 | uint16_t totalWidth; |
| 138 | uint16_t dataWidth; |
| 139 | uint16_t size; |
| 140 | uint8_t formFactor; |
| 141 | uint8_t deviceSet; |
| 142 | uint8_t deviceLocator; |
| 143 | uint8_t bankLocator; |
| 144 | uint8_t memoryType; |
| 145 | uint16_t typeDetail; |
| 146 | uint16_t speed; |
| 147 | uint8_t manufacturer; |
| 148 | uint8_t serialNum; |
| 149 | uint8_t assetTag; |
| 150 | uint8_t partNum; |
| 151 | uint8_t attributes; |
Jason M. Bills | e777099 | 2021-05-14 13:24:33 -0700 | [diff] [blame] | 152 | size_t extendedSize; |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 153 | uint16_t confClockSpeed; |
| 154 | uint16_t minimumVoltage; |
| 155 | uint16_t maximumVoltage; |
| 156 | uint16_t configuredVoltage; |
| 157 | uint8_t memoryTechnology; |
| 158 | uint16_t memoryOperatingModeCap; |
| 159 | uint8_t firwareVersion; |
| 160 | uint16_t modelManufId; |
| 161 | uint16_t modelProdId; |
| 162 | uint16_t memSubConManufId; |
| 163 | uint16_t memSubConProdId; |
| 164 | uint64_t nvSize; |
| 165 | uint64_t volatileSize; |
| 166 | uint64_t cacheSize; |
| 167 | uint64_t logicalSize; |
| 168 | } __attribute__((packed)); |
| 169 | |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 170 | const std::map<uint8_t, DeviceType> dimmTypeTable = { |
| 171 | {0x1, DeviceType::Other}, {0x2, DeviceType::Unknown}, |
| 172 | {0x3, DeviceType::DRAM}, {0x4, DeviceType::EDRAM}, |
| 173 | {0x5, DeviceType::VRAM}, {0x6, DeviceType::SRAM}, |
| 174 | {0x7, DeviceType::RAM}, {0x8, DeviceType::ROM}, |
| 175 | {0x9, DeviceType::FLASH}, {0xa, DeviceType::EEPROM}, |
| 176 | {0xb, DeviceType::FEPROM}, {0xc, DeviceType::EPROM}, |
| 177 | {0xd, DeviceType::CDRAM}, {0xe, DeviceType::ThreeDRAM}, |
| 178 | {0xf, DeviceType::SDRAM}, {0x10, DeviceType::DDR_SGRAM}, |
| 179 | {0x11, DeviceType::RDRAM}, {0x12, DeviceType::DDR}, |
| 180 | {0x13, DeviceType::DDR2}, {0x14, DeviceType::DDR2_SDRAM_FB_DIMM}, |
| 181 | {0x18, DeviceType::DDR3}, {0x19, DeviceType::FBD2}, |
| 182 | {0x1a, DeviceType::DDR4}, {0x1b, DeviceType::LPDDR_SDRAM}, |
| 183 | {0x1c, DeviceType::LPDDR2_SDRAM}, {0x1d, DeviceType::LPDDR3_SDRAM}, |
| 184 | {0x1e, DeviceType::LPDDR4_SDRAM}, {0x1f, DeviceType::Logical}, |
Mansi Joshi | 7ece93a | 2021-07-19 15:07:52 +0530 | [diff] [blame] | 185 | {0x20, DeviceType::HBM}, {0x21, DeviceType::HBM2}, |
| 186 | {0x22, DeviceType::DDR5}, {0x23, DeviceType::LPDDR5_SDRAM}}; |
Cheng C Yang | 8c3fab6 | 2019-12-19 00:51:06 +0800 | [diff] [blame] | 187 | |
| 188 | const std::array<std::string, 16> detailTable{ |
| 189 | "Reserved", "Other", "Unknown", "Fast-paged", |
| 190 | "Static column", "Pseudo-static", "RAMBUS", "Synchronous", |
| 191 | "CMOS", "EDO", "Window DRAM", "Cache DRAM", |
| 192 | "Non-volatile", "Registered", "Unbuffered", "LRDIMM"}; |
| 193 | |
| 194 | } // namespace smbios |
| 195 | |
| 196 | } // namespace phosphor |