blob: 9f1eb4866d048d6537cf890b2a23eec32a360bb3 [file] [log] [blame]
Cheng C Yang8c3fab62019-12-19 00:51:06 +08001/*
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 Ren18a5ab92020-09-01 21:35:20 -070018#include "smbios_mdrv2.hpp"
Cheng C Yang8c3fab62019-12-19 00:51:06 +080019
Jie Yang41654fc2021-09-07 20:26:32 -070020#include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080021#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
Jie Yang31720392021-07-22 21:45:45 -070022#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080023#include <xyz/openbmc_project/Inventory/Item/Dimm/server.hpp>
Joshi-Mansi33c948a2021-03-20 00:58:50 +053024#include <xyz/openbmc_project/Inventory/Item/server.hpp>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080025
26namespace phosphor
27{
28
29namespace smbios
30{
31
32using DeviceType =
33 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm::DeviceType;
34
Zhikui Ren18a5ab92020-09-01 21:35:20 -070035class Dimm :
36 sdbusplus::server::object::object<
37 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm>,
38 sdbusplus::server::object::object<
Joshi-Mansi33c948a2021-03-20 00:58:50 +053039 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset>,
40 sdbusplus::server::object::object<
Jie Yang31720392021-07-22 21:45:45 -070041 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::
42 LocationCode>,
43 sdbusplus::server::object::object<
Jie Yang41654fc2021-09-07 20:26:32 -070044 sdbusplus::xyz::openbmc_project::Inventory::Connector::server::Slot>,
45 sdbusplus::server::object::object<
Joshi-Mansi33c948a2021-03-20 00:58:50 +053046 sdbusplus::xyz::openbmc_project::Inventory::server::Item>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080047{
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()),
Joshi-Mansi33c948a2021-03-20 00:58:50 +053065 sdbusplus::server::object::object<
Jie Yang31720392021-07-22 21:45:45 -070066 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::
67 LocationCode>(bus, objPath.c_str()),
68 sdbusplus::server::object::object<
Jie Yang41654fc2021-09-07 20:26:32 -070069 sdbusplus::xyz::openbmc_project::Inventory::Connector::server::
70 Slot>(bus, objPath.c_str()),
71 sdbusplus::server::object::object<
Joshi-Mansi33c948a2021-03-20 00:58:50 +053072 sdbusplus::xyz::openbmc_project::Inventory::server::Item>(
73 bus, objPath.c_str()),
Cheng C Yang8c3fab62019-12-19 00:51:06 +080074 dimmNum(dimmId), storage(smbiosTableStorage)
75 {
76 memoryInfoUpdate();
77 }
78
79 void memoryInfoUpdate(void);
80
81 uint16_t memoryDataWidth(uint16_t value) override;
Jason M. Billse7770992021-05-14 13:24:33 -070082 size_t memorySizeInKB(size_t value) override;
Cheng C Yang8c3fab62019-12-19 00:51:06 +080083 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;
Joshi-Mansi33c948a2021-03-20 00:58:50 +053088 bool present(bool value) override;
Cheng C Yang8c3fab62019-12-19 00:51:06 +080089 std::string serialNumber(std::string value) override;
90 std::string partNumber(std::string value) override;
Jie Yang31720392021-07-22 21:45:45 -070091 std::string locationCode(std::string value) override;
Cheng C Yang8c3fab62019-12-19 00:51:06 +080092 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);
Jason M. Billse7770992021-05-14 13:24:33 -0700101 void dimmSizeExt(const size_t size);
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800102 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);
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800112};
113
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700114struct 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;
Jason M. Billse7770992021-05-14 13:24:33 -0700136 size_t extendedSize;
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700137 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
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800154const 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},
Mansi Joshi7ece93a2021-07-19 15:07:52 +0530169 {0x20, DeviceType::HBM}, {0x21, DeviceType::HBM2},
170 {0x22, DeviceType::DDR5}, {0x23, DeviceType::LPDDR5_SDRAM}};
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800171
172const 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