blob: 395d52800f1feb3aab42121315e9723911cf701b [file] [log] [blame]
Cheng C Yang43c6a1d2019-12-19 00:48:34 +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 Yang43c6a1d2019-12-19 00:48:34 +080019
Jie Yang41654fc2021-09-07 20:26:32 -070020#include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +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>
Zhikui Ren18a5ab92020-09-01 21:35:20 -070023#include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080024#include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp>
Jonathan Doman563570d2021-05-24 10:52:43 -070025#include <xyz/openbmc_project/Inventory/Item/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080026
27namespace phosphor
28{
29
30namespace smbios
31{
32
Zhikui Ren18a5ab92020-09-01 21:35:20 -070033using rev =
34 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision;
35using asset =
36 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset;
Jie Yang31720392021-07-22 21:45:45 -070037using location =
38 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::LocationCode;
Jie Yang41654fc2021-09-07 20:26:32 -070039using connector =
40 sdbusplus::xyz::openbmc_project::Inventory::Connector::server::Slot;
Zhikui Ren18a5ab92020-09-01 21:35:20 -070041using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu;
Jonathan Doman563570d2021-05-24 10:52:43 -070042using Item = sdbusplus::xyz::openbmc_project::Inventory::server::Item;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080043
44// Definition follow smbios spec DSP0134 3.0.0
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080045static const std::map<uint8_t, const char*> familyTable = {
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080046 {0x1, "Other"},
47 {0x2, "Unknown"},
48 {0x10, "Pentium II Xeon processor"},
49 {0xa1, "Quad-Core Intel Xeon processor 3200 Series"},
50 {0xa2, "Dual-Core Intel Xeon processor 3000 Series"},
51 {0xa3, "Quad-Core Intel Xeon processor 5300 Series"},
52 {0xa4, "Dual-Core Intel Xeon processor 5100 Series"},
53 {0xa5, "Dual-Core Intel Xeon processor 5000 Series"},
54 {0xa6, "Dual-Core Intel Xeon processor LV"},
55 {0xa7, "Dual-Core Intel Xeon processor ULV"},
56 {0xa8, "Dual-Core Intel Xeon processor 7100 Series"},
57 {0xa9, "Quad-Core Intel Xeon processor 5400 Series"},
58 {0xaa, "Quad-Core Intel Xeon processor"},
59 {0xab, "Dual-Core Intel Xeon processor 5200 Series"},
60 {0xac, "Dual-Core Intel Xeon processor 7200 Series"},
61 {0xad, "Quad-Core Intel Xeon processor 7300 Series"},
62 {0xae, "Quad-Core Intel Xeon processor 7400 Series"},
63 {0xaf, "Multi-Core Intel Xeon processor 7400 Series"},
64 {0xb0, "Pentium III Xeon processor"},
65 {0xb3, "Intel Xeon processor"},
66 {0xb5, "Intel Xeon processor MP"},
67 {0xd6, "Multi-Core Intel Xeon processor"},
68 {0xd7, "Dual-Core Intel Xeon processor 3xxx Series"},
69 {0xd8, "Quad-Core Intel Xeon processor 3xxx Series"},
70 {0xd9, "VIA Nano Processor Family"},
71 {0xda, "Dual-Core Intel Xeon processor 5xxx Series"},
72 {0xdb, "Quad-Core Intel Xeon processor 5xxx Series"},
73 {0xdd, "Dual-Core Intel Xeon processor 7xxx Series"},
74 {0xde, "Quad-Core Intel Xeon processor 7xxx Series"},
75 {0xdf, "Multi-Core Intel Xeon processor 7xxx Series"},
76 {0xe0, "Multi-Core Intel Xeon processor 3400 Series"}
77
78};
79
80// Definition follow smbios spec DSP0134 3.0.0
Zhikui Ren18a5ab92020-09-01 21:35:20 -070081static const std::array<std::optional<processor::Capability>, 16>
82 characteristicsTable{std::nullopt,
83 std::nullopt,
84 processor::Capability::Capable64bit,
85 processor::Capability::MultiCore,
86 processor::Capability::HardwareThread,
87 processor::Capability::ExecuteProtection,
88 processor::Capability::EnhancedVirtualization,
89 processor::Capability::PowerPerformanceControl,
90 std::nullopt,
91 std::nullopt,
92 std::nullopt,
93 std::nullopt,
94 std::nullopt,
95 std::nullopt,
96 std::nullopt,
97 std::nullopt};
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080098
Jie Yang41654fc2021-09-07 20:26:32 -070099class Cpu :
100 sdbusplus::server::object_t<processor, asset, location, connector, rev,
101 Item>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800102{
103 public:
104 Cpu() = delete;
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800105 Cpu(const Cpu&) = delete;
106 Cpu& operator=(const Cpu&) = delete;
107 Cpu(Cpu&&) = delete;
108 Cpu& operator=(Cpu&&) = delete;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800109 ~Cpu() = default;
110
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800111 Cpu(sdbusplus::bus::bus& bus, const std::string& objPath,
112 const uint8_t& cpuId, uint8_t* smbiosTableStorage) :
Jie Yang41654fc2021-09-07 20:26:32 -0700113 sdbusplus::server::object_t<processor, asset, location, connector, rev,
114 Item>(bus, objPath.c_str()),
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800115 cpuNum(cpuId), storage(smbiosTableStorage)
116 {
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700117 infoUpdate();
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800118 }
119
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700120 void infoUpdate(void);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800121
122 private:
123 uint8_t cpuNum;
124
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800125 uint8_t* storage;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800126
127 struct ProcessorInfo
128 {
129 uint8_t type;
130 uint8_t length;
131 uint16_t handle;
132 uint8_t socketDesignation;
133 uint8_t processorType;
134 uint8_t family;
135 uint8_t manufacturer;
136 uint64_t id;
137 uint8_t version;
138 uint8_t voltage;
139 uint16_t exClock;
140 uint16_t maxSpeed;
141 uint16_t currSpeed;
142 uint8_t status;
143 uint8_t upgrade;
144 uint16_t l1Handle;
145 uint16_t l2Handle;
146 uint16_t l3Handle;
147 uint8_t serialNum;
148 uint8_t assetTag;
149 uint8_t partNum;
150 uint8_t coreCount;
151 uint8_t coreEnable;
152 uint8_t threadCount;
153 uint16_t characteristics;
154 uint16_t family2;
155 uint16_t coreCount2;
156 uint16_t coreEnable2;
157 uint16_t threadCount2;
158 } __attribute__((packed));
159
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700160 void socket(const uint8_t positionNum, const uint8_t structLen,
161 uint8_t* dataIn);
162 void family(const uint8_t value);
163 void manufacturer(const uint8_t positionNum, const uint8_t structLen,
164 uint8_t* dataIn);
Charles Boyere6431692021-08-31 16:47:47 -0500165 void serialNumber(const uint8_t positionNum, const uint8_t structLen,
166 uint8_t* dataIn);
167 void partNumber(const uint8_t positionNum, const uint8_t structLen,
168 uint8_t* dataIn);
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700169 void version(const uint8_t positionNum, const uint8_t structLen,
170 uint8_t* dataIn);
171 void characteristics(const uint16_t value);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800172};
173
174} // namespace smbios
175
176} // namespace phosphor