blob: ec0a4e910ac3c5edd2fa66a4e50beba5e28aa772 [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
18#include "smbios.hpp"
19
20#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
21#include <xyz/openbmc_project/Inventory/Item/Dimm/server.hpp>
22
23namespace phosphor
24{
25
26namespace smbios
27{
28
29using DeviceType =
30 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm::DeviceType;
31
32class 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>
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);
91
92 struct MemoryInfo
93 {
94 uint8_t type;
95 uint8_t length;
96 uint16_t handle;
97 uint16_t phyArrayHandle;
98 uint16_t errInfoHandle;
99 uint16_t totalWidth;
100 uint16_t dataWidth;
101 uint16_t size;
102 uint8_t formFactor;
103 uint8_t deviceSet;
104 uint8_t deviceLocator;
105 uint8_t bankLocator;
106 uint8_t memoryType;
107 uint16_t typeDetail;
108 uint16_t speed;
109 uint8_t manufacturer;
110 uint8_t serialNum;
111 uint8_t assetTag;
112 uint8_t partNum;
113 uint8_t attributes;
114 uint32_t extendedSize;
115 uint16_t confClockSpeed;
116 } __attribute__((packed));
117};
118
119const std::map<uint8_t, DeviceType> dimmTypeTable = {
120 {0x1, DeviceType::Other}, {0x2, DeviceType::Unknown},
121 {0x3, DeviceType::DRAM}, {0x4, DeviceType::EDRAM},
122 {0x5, DeviceType::VRAM}, {0x6, DeviceType::SRAM},
123 {0x7, DeviceType::RAM}, {0x8, DeviceType::ROM},
124 {0x9, DeviceType::FLASH}, {0xa, DeviceType::EEPROM},
125 {0xb, DeviceType::FEPROM}, {0xc, DeviceType::EPROM},
126 {0xd, DeviceType::CDRAM}, {0xe, DeviceType::ThreeDRAM},
127 {0xf, DeviceType::SDRAM}, {0x10, DeviceType::DDR_SGRAM},
128 {0x11, DeviceType::RDRAM}, {0x12, DeviceType::DDR},
129 {0x13, DeviceType::DDR2}, {0x14, DeviceType::DDR2_SDRAM_FB_DIMM},
130 {0x18, DeviceType::DDR3}, {0x19, DeviceType::FBD2},
131 {0x1a, DeviceType::DDR4}, {0x1b, DeviceType::LPDDR_SDRAM},
132 {0x1c, DeviceType::LPDDR2_SDRAM}, {0x1d, DeviceType::LPDDR3_SDRAM},
133 {0x1e, DeviceType::LPDDR4_SDRAM}, {0x1f, DeviceType::Logical},
134 {0x20, DeviceType::HBM}, {0x21, DeviceType::HBM2}};
135
136const std::array<std::string, 16> detailTable{
137 "Reserved", "Other", "Unknown", "Fast-paged",
138 "Static column", "Pseudo-static", "RAMBUS", "Synchronous",
139 "CMOS", "EDO", "Window DRAM", "Cache DRAM",
140 "Non-volatile", "Registered", "Unbuffered", "LRDIMM"};
141
142} // namespace smbios
143
144} // namespace phosphor