blob: ec1e32c567844d428a53b4449d70d04d20a26da3 [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
20#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
Jie Yang31720392021-07-22 21:45:45 -070021#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080022#include <xyz/openbmc_project/Inventory/Item/Dimm/server.hpp>
Joshi-Mansi33c948a2021-03-20 00:58:50 +053023#include <xyz/openbmc_project/Inventory/Item/server.hpp>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080024
25namespace phosphor
26{
27
28namespace smbios
29{
30
31using DeviceType =
32 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm::DeviceType;
33
Zhikui Ren18a5ab92020-09-01 21:35:20 -070034class Dimm :
35 sdbusplus::server::object::object<
36 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm>,
37 sdbusplus::server::object::object<
Joshi-Mansi33c948a2021-03-20 00:58:50 +053038 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset>,
39 sdbusplus::server::object::object<
Jie Yang31720392021-07-22 21:45:45 -070040 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::
41 LocationCode>,
42 sdbusplus::server::object::object<
Joshi-Mansi33c948a2021-03-20 00:58:50 +053043 sdbusplus::xyz::openbmc_project::Inventory::server::Item>
Cheng C Yang8c3fab62019-12-19 00:51:06 +080044{
45 public:
46 Dimm() = delete;
47 ~Dimm() = default;
48 Dimm(const Dimm&) = delete;
49 Dimm& operator=(const Dimm&) = delete;
50 Dimm(Dimm&&) = default;
51 Dimm& operator=(Dimm&&) = default;
52
53 Dimm(sdbusplus::bus::bus& bus, const std::string& objPath,
54 const uint8_t& dimmId, uint8_t* smbiosTableStorage) :
55
56 sdbusplus::server::object::object<
57 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm>(
58 bus, objPath.c_str()),
59 sdbusplus::server::object::object<
60 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::
61 Asset>(bus, objPath.c_str()),
Joshi-Mansi33c948a2021-03-20 00:58:50 +053062 sdbusplus::server::object::object<
Jie Yang31720392021-07-22 21:45:45 -070063 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::
64 LocationCode>(bus, objPath.c_str()),
65 sdbusplus::server::object::object<
Joshi-Mansi33c948a2021-03-20 00:58:50 +053066 sdbusplus::xyz::openbmc_project::Inventory::server::Item>(
67 bus, objPath.c_str()),
Cheng C Yang8c3fab62019-12-19 00:51:06 +080068 dimmNum(dimmId), storage(smbiosTableStorage)
69 {
70 memoryInfoUpdate();
71 }
72
73 void memoryInfoUpdate(void);
74
75 uint16_t memoryDataWidth(uint16_t value) override;
Jason M. Billse7770992021-05-14 13:24:33 -070076 size_t memorySizeInKB(size_t value) override;
Cheng C Yang8c3fab62019-12-19 00:51:06 +080077 std::string memoryDeviceLocator(std::string value) override;
78 DeviceType memoryType(DeviceType value) override;
79 std::string memoryTypeDetail(std::string value) override;
80 uint16_t maxMemorySpeedInMhz(uint16_t value) override;
81 std::string manufacturer(std::string value) override;
Joshi-Mansi33c948a2021-03-20 00:58:50 +053082 bool present(bool value) override;
Cheng C Yang8c3fab62019-12-19 00:51:06 +080083 std::string serialNumber(std::string value) override;
84 std::string partNumber(std::string value) override;
Jie Yang31720392021-07-22 21:45:45 -070085 std::string locationCode(std::string value) override;
Cheng C Yang8c3fab62019-12-19 00:51:06 +080086 uint8_t memoryAttributes(uint8_t value) override;
87 uint16_t memoryConfiguredSpeedInMhz(uint16_t value) override;
88
89 private:
90 uint8_t dimmNum;
91
92 uint8_t* storage;
93
94 void dimmSize(const uint16_t size);
Jason M. Billse7770992021-05-14 13:24:33 -070095 void dimmSizeExt(const size_t size);
Cheng C Yang8c3fab62019-12-19 00:51:06 +080096 void dimmDeviceLocator(const uint8_t positionNum, const uint8_t structLen,
97 uint8_t* dataIn);
98 void dimmType(const uint8_t type);
99 void dimmTypeDetail(const uint16_t detail);
100 void dimmManufacturer(const uint8_t positionNum, const uint8_t structLen,
101 uint8_t* dataIn);
102 void dimmSerialNum(const uint8_t positionNum, const uint8_t structLen,
103 uint8_t* dataIn);
104 void dimmPartNum(const uint8_t positionNum, const uint8_t structLen,
105 uint8_t* dataIn);
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800106};
107
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700108struct MemoryInfo
109{
110 uint8_t type;
111 uint8_t length;
112 uint16_t handle;
113 uint16_t phyArrayHandle;
114 uint16_t errInfoHandle;
115 uint16_t totalWidth;
116 uint16_t dataWidth;
117 uint16_t size;
118 uint8_t formFactor;
119 uint8_t deviceSet;
120 uint8_t deviceLocator;
121 uint8_t bankLocator;
122 uint8_t memoryType;
123 uint16_t typeDetail;
124 uint16_t speed;
125 uint8_t manufacturer;
126 uint8_t serialNum;
127 uint8_t assetTag;
128 uint8_t partNum;
129 uint8_t attributes;
Jason M. Billse7770992021-05-14 13:24:33 -0700130 size_t extendedSize;
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700131 uint16_t confClockSpeed;
132 uint16_t minimumVoltage;
133 uint16_t maximumVoltage;
134 uint16_t configuredVoltage;
135 uint8_t memoryTechnology;
136 uint16_t memoryOperatingModeCap;
137 uint8_t firwareVersion;
138 uint16_t modelManufId;
139 uint16_t modelProdId;
140 uint16_t memSubConManufId;
141 uint16_t memSubConProdId;
142 uint64_t nvSize;
143 uint64_t volatileSize;
144 uint64_t cacheSize;
145 uint64_t logicalSize;
146} __attribute__((packed));
147
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800148const std::map<uint8_t, DeviceType> dimmTypeTable = {
149 {0x1, DeviceType::Other}, {0x2, DeviceType::Unknown},
150 {0x3, DeviceType::DRAM}, {0x4, DeviceType::EDRAM},
151 {0x5, DeviceType::VRAM}, {0x6, DeviceType::SRAM},
152 {0x7, DeviceType::RAM}, {0x8, DeviceType::ROM},
153 {0x9, DeviceType::FLASH}, {0xa, DeviceType::EEPROM},
154 {0xb, DeviceType::FEPROM}, {0xc, DeviceType::EPROM},
155 {0xd, DeviceType::CDRAM}, {0xe, DeviceType::ThreeDRAM},
156 {0xf, DeviceType::SDRAM}, {0x10, DeviceType::DDR_SGRAM},
157 {0x11, DeviceType::RDRAM}, {0x12, DeviceType::DDR},
158 {0x13, DeviceType::DDR2}, {0x14, DeviceType::DDR2_SDRAM_FB_DIMM},
159 {0x18, DeviceType::DDR3}, {0x19, DeviceType::FBD2},
160 {0x1a, DeviceType::DDR4}, {0x1b, DeviceType::LPDDR_SDRAM},
161 {0x1c, DeviceType::LPDDR2_SDRAM}, {0x1d, DeviceType::LPDDR3_SDRAM},
162 {0x1e, DeviceType::LPDDR4_SDRAM}, {0x1f, DeviceType::Logical},
Mansi Joshi7ece93a2021-07-19 15:07:52 +0530163 {0x20, DeviceType::HBM}, {0x21, DeviceType::HBM2},
164 {0x22, DeviceType::DDR5}, {0x23, DeviceType::LPDDR5_SDRAM}};
Cheng C Yang8c3fab62019-12-19 00:51:06 +0800165
166const std::array<std::string, 16> detailTable{
167 "Reserved", "Other", "Unknown", "Fast-paged",
168 "Static column", "Pseudo-static", "RAMBUS", "Synchronous",
169 "CMOS", "EDO", "Window DRAM", "Cache DRAM",
170 "Non-volatile", "Registered", "Unbuffered", "LRDIMM"};
171
172} // namespace smbios
173
174} // namespace phosphor