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