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