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