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