blob: 26579a6497defa88b56c074de1fd797e5f0cb899 [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 Yange7cf3192021-08-20 11:21:43 -070020#include <xyz/openbmc_project/Association/Definitions/server.hpp>
Jie Yang41654fc2021-09-07 20:26:32 -070021#include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080022#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
Jie Yang31720392021-07-22 21:45:45 -070023#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
Zhikui Ren18a5ab92020-09-01 21:35:20 -070024#include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080025#include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp>
Jonathan Doman563570d2021-05-24 10:52:43 -070026#include <xyz/openbmc_project/Inventory/Item/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080027
28namespace phosphor
29{
30
31namespace smbios
32{
33
Zhikui Ren18a5ab92020-09-01 21:35:20 -070034using rev =
Jason M. Bills33ae81f2023-04-26 09:06:08 -070035 sdbusplus::server::xyz::openbmc_project::inventory::decorator::Revision;
Zhikui Ren18a5ab92020-09-01 21:35:20 -070036using asset =
Jason M. Bills33ae81f2023-04-26 09:06:08 -070037 sdbusplus::server::xyz::openbmc_project::inventory::decorator::Asset;
Jie Yang31720392021-07-22 21:45:45 -070038using location =
Jason M. Bills33ae81f2023-04-26 09:06:08 -070039 sdbusplus::server::xyz::openbmc_project::inventory::decorator::LocationCode;
Jie Yang41654fc2021-09-07 20:26:32 -070040using connector =
Jason M. Bills33ae81f2023-04-26 09:06:08 -070041 sdbusplus::server::xyz::openbmc_project::inventory::connector::Slot;
42using processor = sdbusplus::server::xyz::openbmc_project::inventory::item::Cpu;
43using Item = sdbusplus::server::xyz::openbmc_project::inventory::Item;
Jie Yange7cf3192021-08-20 11:21:43 -070044using association =
Jason M. Bills33ae81f2023-04-26 09:06:08 -070045 sdbusplus::server::xyz::openbmc_project::association::Definitions;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080046
Josh Lehan6076d2c2023-09-19 21:05:12 -070047// This table is up to date as of SMBIOS spec DSP0134 3.7.0
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080048static const std::map<uint8_t, const char*> familyTable = {
Josh Lehan6076d2c2023-09-19 21:05:12 -070049 {0x01, "Other"},
50 {0x02, "Unknown"},
51 {0x03, "8086"},
52 {0x04, "80286"},
53 {0x05, "Intel 386 processor"},
54 {0x06, "Intel 486 processor"},
55 {0x07, "8087"},
56 {0x08, "80287"},
57 {0x09, "80387"},
58 {0x0a, "80487"},
59 {0x0b, "Intel Pentium processor"},
60 {0x0c, "Pentium Pro processor"},
61 {0x0d, "Pentium II processor"},
62 {0x0e, "Pentium processor with MMX technology"},
63 {0x0f, "Intel Celeron processor"},
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080064 {0x10, "Pentium II Xeon processor"},
Josh Lehan6076d2c2023-09-19 21:05:12 -070065 {0x11, "Pentium III processor"},
66 {0x12, "M1 Family"},
67 {0x13, "M2 Family"},
68 {0x14, "Intel Celeron M processor"},
69 {0x15, "Intel Pentium 4 HT processor"},
70 {0x16, "Intel Processor"},
71 {0x18, "AMD Duron Processor Family"},
72 {0x19, "K5 Family"},
73 {0x1a, "K6 Family"},
74 {0x1b, "K6-2"},
75 {0x1c, "K6-3"},
76 {0x1d, "AMD Athlon Processor Family"},
77 {0x1e, "AMD29000 Family"},
78 {0x1f, "K6-2+"},
79 {0x20, "Power PC Family"},
80 {0x21, "Power PC 601"},
81 {0x22, "Power PC 603"},
82 {0x23, "Power PC 603+"},
83 {0x24, "Power PC 604"},
84 {0x25, "Power PC 620"},
85 {0x26, "Power PC x704"},
86 {0x27, "Power PC 750"},
87 {0x28, "Intel Core Duo processor"},
88 {0x29, "Intel Core Duo mobile processor"},
89 {0x2a, "Intel Core Solo mobile processor"},
Jayaprakash Mutyala79a7f6c2023-04-04 05:58:44 +000090 {0x2b, "Intel Atom processor"},
91 {0x2c, "Intel Core M processor"},
92 {0x2d, "Intel Core m3 processor"},
93 {0x2e, "Intel Core m5 processor"},
94 {0x2f, "Intel Core m7 processor"},
Josh Lehan6076d2c2023-09-19 21:05:12 -070095 {0x30, "Alpha Family"},
96 {0x31, "Alpha 21064"},
97 {0x32, "Alpha 21066"},
98 {0x33, "Alpha 21164"},
99 {0x34, "Alpha 21164PC"},
100 {0x35, "Alpha 21164a"},
101 {0x36, "Alpha 21264"},
102 {0x37, "Alpha 21364"},
103 {0x38, "AMD Turion II Ultra Dual-Core Mobile M Processor Family"},
104 {0x39, "AMD Turion II Dual-Core Mobile M Processor Family"},
105 {0x3a, "AMD Athlon II Dual-Core M Processor Family"},
106 {0x3b, "AMD Opteron 6100 Series Processor"},
107 {0x3c, "AMD Opteron 4100 Series Processor"},
108 {0x3d, "AMD Opteron 6200 Series Processor"},
109 {0x3e, "AMD Opteron 4200 Series Processor"},
110 {0x3f, "AMD FX Series Processor"},
111 {0x40, "MIPS Family"},
112 {0x41, "MIPS R4000"},
113 {0x42, "MIPS R4200"},
114 {0x43, "MIPS R4400"},
115 {0x44, "MIPS R4600"},
116 {0x45, "MIPS R10000"},
117 {0x46, "AMD C-Series Processor"},
118 {0x47, "AMD E-Series Processor"},
119 {0x48, "AMD A-Series Processor"},
120 {0x49, "AMD G-Series Processor"},
121 {0x4a, "AMD Z-Series Processor"},
122 {0x4b, "AMD R-Series Processor"},
123 {0x4c, "AMD Opteron 4300 Series Processor"},
124 {0x4d, "AMD Opteron 6300 Series Processor"},
125 {0x4e, "AMD Opteron 3300 Series Processor"},
126 {0x4f, "AMD FirePro Series Processor"},
127 {0x50, "SPARC Family"},
128 {0x51, "SuperSPARC"},
129 {0x52, "microSPARC II"},
130 {0x53, "microSPARC IIep"},
131 {0x54, "UltraSPARC"},
132 {0x55, "UltraSPARC II"},
133 {0x56, "UltraSPARC Iii"},
134 {0x57, "UltraSPARC III"},
135 {0x58, "UltraSPARC IIIi"},
136 {0x60, "68040 Family"},
137 {0x61, "68xxx"},
138 {0x62, "68000"},
139 {0x63, "68010"},
140 {0x64, "68020"},
141 {0x65, "68030"},
142 {0x66, "AMD Athlon X4 Quad-Core Processor Family"},
143 {0x67, "AMD Opteron X1000 Series Processor"},
144 {0x68, "AMD Opteron X2000 Series APU"},
145 {0x69, "AMD Opteron A-Series Processor"},
146 {0x6a, "AMD Opteron X3000 Series APU"},
147 {0x6b, "AMD Zen Processor Family"},
148 {0x70, "Hobbit Family"},
149 {0x78, "Crusoe TM5000 Family"},
150 {0x79, "Crusoe TM3000 Family"},
151 {0x7a, "Efficeon TM8000 Family"},
152 {0x80, "Weitek"},
153 {0x82, "Itanium processor"},
154 {0x83, "AMD Athlon 64 Processor Family"},
155 {0x84, "AMD Opteron Processor Family"},
156 {0x85, "AMD Sempron Processor Family"},
157 {0x86, "AMD Turion 64 Mobile Technology"},
158 {0x87, "Dual-Core AMD Opteron Processor Family"},
159 {0x88, "AMD Athlon 64 X2 Dual-Core Processor Family"},
160 {0x89, "AMD Turion 64 X2 Mobile Technology"},
161 {0x8a, "Quad-Core AMD Opteron Processor Family"},
162 {0x8b, "Third-Generation AMD Opteron Processor Family"},
163 {0x8c, "AMD Phenom FX Quad-Core Processor Family"},
164 {0x8d, "AMD Phenom X4 Quad-Core Processor Family"},
165 {0x8e, "AMD Phenom X2 Dual-Core Processor Family"},
166 {0x8f, "AMD Athlon X2 Dual-Core Processor Family"},
167 {0x90, "PA-RISC Family"},
168 {0x91, "PA-RISC 8500"},
169 {0x92, "PA-RISC 8000"},
170 {0x93, "PA-RISC 7300LC"},
171 {0x94, "PA-RISC 7200"},
172 {0x95, "PA-RISC 7100LC"},
173 {0x96, "PA-RISC 7100"},
174 {0xa0, "V30 Family"},
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800175 {0xa1, "Quad-Core Intel Xeon processor 3200 Series"},
176 {0xa2, "Dual-Core Intel Xeon processor 3000 Series"},
177 {0xa3, "Quad-Core Intel Xeon processor 5300 Series"},
178 {0xa4, "Dual-Core Intel Xeon processor 5100 Series"},
179 {0xa5, "Dual-Core Intel Xeon processor 5000 Series"},
180 {0xa6, "Dual-Core Intel Xeon processor LV"},
181 {0xa7, "Dual-Core Intel Xeon processor ULV"},
182 {0xa8, "Dual-Core Intel Xeon processor 7100 Series"},
183 {0xa9, "Quad-Core Intel Xeon processor 5400 Series"},
184 {0xaa, "Quad-Core Intel Xeon processor"},
185 {0xab, "Dual-Core Intel Xeon processor 5200 Series"},
186 {0xac, "Dual-Core Intel Xeon processor 7200 Series"},
187 {0xad, "Quad-Core Intel Xeon processor 7300 Series"},
188 {0xae, "Quad-Core Intel Xeon processor 7400 Series"},
189 {0xaf, "Multi-Core Intel Xeon processor 7400 Series"},
190 {0xb0, "Pentium III Xeon processor"},
Josh Lehan6076d2c2023-09-19 21:05:12 -0700191 {0xb1, "Pentium III Processor with Intel SpeedStep Technology"},
192 {0xb2, "Pentium 4 Processor"},
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800193 {0xb3, "Intel Xeon processor"},
Josh Lehan6076d2c2023-09-19 21:05:12 -0700194 {0xb4, "AS400 Family"},
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800195 {0xb5, "Intel Xeon processor MP"},
Josh Lehan6076d2c2023-09-19 21:05:12 -0700196 {0xb6, "AMD Athlon XP Processor Family"},
197 {0xb7, "AMD Athlon MP Processor Family"},
198 {0xb8, "Intel Itanium 2 processor"},
199 {0xb9, "Intel Pentium M processor"},
200 {0xba, "Intel Celeron D processor"},
201 {0xbb, "Intel Pentium D processor"},
202 {0xbc, "Intel Pentium Processor Extreme Edition"},
203 {0xbd, "Intel Core Solo Processor"},
204 {0xbf, "Intel Core 2 Duo Processor"},
205 {0xc0, "Intel Core 2 Solo processor"},
206 {0xc1, "Intel Core 2 Extreme processor"},
207 {0xc2, "Intel Core 2 Quad processor"},
208 {0xc3, "Intel Core 2 Extreme mobile processor"},
209 {0xc4, "Intel Core 2 Duo mobile processor"},
210 {0xc5, "Intel Core 2 Solo mobile processor"},
211 {0xc6, "Intel Core i7 processor"},
212 {0xc7, "Dual-Core Intel Celeron processor"},
213 {0xc8, "IBM390 Family"},
214 {0xc9, "G4"},
215 {0xca, "G5"},
216 {0xcb, "ESA/390 G6"},
217 {0xcc, "z/Architecture base"},
218 {0xcd, "Intel Core i5 processor"},
219 {0xce, "Intel Core i3 processor"},
220 {0xcf, "Intel Core i9 processor"},
221 {0xd2, "VIA C7-M Processor Family"},
222 {0xd3, "VIA C7-D Processor Family"},
223 {0xd4, "VIA C7 Processor Family"},
224 {0xd5, "VIA Eden Processor Family"},
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800225 {0xd6, "Multi-Core Intel Xeon processor"},
226 {0xd7, "Dual-Core Intel Xeon processor 3xxx Series"},
227 {0xd8, "Quad-Core Intel Xeon processor 3xxx Series"},
228 {0xd9, "VIA Nano Processor Family"},
229 {0xda, "Dual-Core Intel Xeon processor 5xxx Series"},
230 {0xdb, "Quad-Core Intel Xeon processor 5xxx Series"},
231 {0xdd, "Dual-Core Intel Xeon processor 7xxx Series"},
232 {0xde, "Quad-Core Intel Xeon processor 7xxx Series"},
233 {0xdf, "Multi-Core Intel Xeon processor 7xxx Series"},
Charles Boyer800bb702021-08-31 17:09:19 -0500234 {0xe0, "Multi-Core Intel Xeon processor 3400 Series"},
Josh Lehan6076d2c2023-09-19 21:05:12 -0700235 {0xe4, "AMD Opteron 3000 Series Processor"},
236 {0xe5, "AMD Sempron II Processor"},
237 {0xe6, "Embedded AMD Opteron Quad-Core Processor Family"},
238 {0xe7, "AMD Phenom Triple-Core Processor Family"},
239 {0xe8, "AMD Turion Ultra Dual-Core Mobile Processor Family"},
240 {0xe9, "AMD Turion Dual-Core Mobile Processor Family"},
241 {0xea, "AMD Athlon Dual-Core Processor Family"},
242 {0xeb, "AMD Sempron SI Processor Family"},
243 {0xec, "AMD Phenom II Processor Family"},
244 {0xed, "AMD Athlon II Processor Family"},
245 {0xee, "Six-core AMD Opteron Processor Family"},
246 {0xef, "AMD Sempron M Processor Family"},
247 {0xfa, "i860"},
248 {0xfb, "i960"},
249 {0xfe, "Processor Family 2 Indicator"}};
Charles Boyer800bb702021-08-31 17:09:19 -0500250
Josh Lehan6076d2c2023-09-19 21:05:12 -0700251// This table is up to date as of SMBIOS spec DSP0134 3.7.0
Charles Boyer800bb702021-08-31 17:09:19 -0500252static const std::map<uint16_t, const char*> family2Table = {
Josh Lehan6076d2c2023-09-19 21:05:12 -0700253 {0x100, "ARMv7"},
254 {0x101, "ARMv8"},
255 {0x102, "ARMv9"},
256 {0x104, "SH-3"},
257 {0x105, "SH-4"},
258 {0x118, "ARM"},
259 {0x119, "StrongARM"},
260 {0x12c, "6x86"},
261 {0x12d, "MediaGX"},
262 {0x12e, "MII"},
263 {0x140, "WinChip"},
264 {0x15e, "DSP"},
265 {0x1f4, "Video Processor"},
266 {0x200, "RISC-V RV32"},
267 {0x201, "RISC-V RV64"},
268 {0x202, "RISC-V RV128"},
269 {0x258, "LoongArch"},
270 {0x259, "Loongson 1 Processor Family"},
271 {0x25a, "Loongson 2 Processor Family"},
272 {0x25b, "Loongson 3 Processor Family"},
273 {0x25c, "Loongson 2K Processor Family"},
274 {0x25d, "Loongson 3A Processor Family"},
275 {0x25e, "Loongson 3B Processor Family"},
276 {0x25f, "Loongson 3C Processor Family"},
277 {0x260, "Loongson 3D Processor Family"},
278 {0x261, "Loongson 3E Processor Family"},
279 {0x262, "Dual-Core Loongson 2K Processor 2xxx Series"},
280 {0x26c, "Quad-Core Loongson 3A Processor 5xxx Series"},
281 {0x26d, "Multi-Core Loongson 3A Processor 5xxx Series"},
282 {0x26e, "Quad-Core Loongson 3B Processor 5xxx Series"},
283 {0x26f, "Multi-Core Loongson 3B Processor 5xxx Series"},
284 {0x270, "Multi-Core Loongson 3C Processor 5xxx Series"},
285 {0x271, "Multi-Core Loongson 3D Processor 5xxx Series"}};
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800286
287// Definition follow smbios spec DSP0134 3.0.0
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700288static const std::array<std::optional<processor::Capability>, 16>
289 characteristicsTable{std::nullopt,
290 std::nullopt,
291 processor::Capability::Capable64bit,
292 processor::Capability::MultiCore,
293 processor::Capability::HardwareThread,
294 processor::Capability::ExecuteProtection,
295 processor::Capability::EnhancedVirtualization,
296 processor::Capability::PowerPerformanceControl,
297 std::nullopt,
298 std::nullopt,
299 std::nullopt,
300 std::nullopt,
301 std::nullopt,
302 std::nullopt,
303 std::nullopt,
304 std::nullopt};
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800305
Jie Yang41654fc2021-09-07 20:26:32 -0700306class Cpu :
307 sdbusplus::server::object_t<processor, asset, location, connector, rev,
Jie Yange7cf3192021-08-20 11:21:43 -0700308 Item, association>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800309{
310 public:
311 Cpu() = delete;
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800312 Cpu(const Cpu&) = delete;
313 Cpu& operator=(const Cpu&) = delete;
314 Cpu(Cpu&&) = delete;
315 Cpu& operator=(Cpu&&) = delete;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800316 ~Cpu() = default;
317
Patrick Williams77b9c472022-07-22 19:26:57 -0500318 Cpu(sdbusplus::bus_t& bus, const std::string& objPath, const uint8_t& cpuId,
319 uint8_t* smbiosTableStorage, const std::string& motherboard) :
Jie Yang41654fc2021-09-07 20:26:32 -0700320 sdbusplus::server::object_t<processor, asset, location, connector, rev,
Jie Yange7cf3192021-08-20 11:21:43 -0700321 Item, association>(bus, objPath.c_str()),
322 cpuNum(cpuId), storage(smbiosTableStorage), motherboardPath(motherboard)
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800323 {
Brandon Kim5a122a62023-05-04 04:25:03 +0000324 infoUpdate(smbiosTableStorage, motherboard);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800325 }
326
Brandon Kim5a122a62023-05-04 04:25:03 +0000327 void infoUpdate(uint8_t* smbiosTableStorage,
328 const std::string& motherboard);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800329
330 private:
331 uint8_t cpuNum;
332
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800333 uint8_t* storage;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800334
Jie Yange7cf3192021-08-20 11:21:43 -0700335 std::string motherboardPath;
336
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800337 struct ProcessorInfo
338 {
339 uint8_t type;
340 uint8_t length;
341 uint16_t handle;
342 uint8_t socketDesignation;
343 uint8_t processorType;
344 uint8_t family;
345 uint8_t manufacturer;
346 uint64_t id;
347 uint8_t version;
348 uint8_t voltage;
349 uint16_t exClock;
350 uint16_t maxSpeed;
351 uint16_t currSpeed;
352 uint8_t status;
353 uint8_t upgrade;
354 uint16_t l1Handle;
355 uint16_t l2Handle;
356 uint16_t l3Handle;
357 uint8_t serialNum;
358 uint8_t assetTag;
359 uint8_t partNum;
360 uint8_t coreCount;
361 uint8_t coreEnable;
362 uint8_t threadCount;
363 uint16_t characteristics;
364 uint16_t family2;
365 uint16_t coreCount2;
366 uint16_t coreEnable2;
367 uint16_t threadCount2;
368 } __attribute__((packed));
369
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700370 void socket(const uint8_t positionNum, const uint8_t structLen,
371 uint8_t* dataIn);
Charles Boyer800bb702021-08-31 17:09:19 -0500372 void family(const uint8_t family, const uint16_t family2);
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700373 void manufacturer(const uint8_t positionNum, const uint8_t structLen,
374 uint8_t* dataIn);
Charles Boyere6431692021-08-31 16:47:47 -0500375 void serialNumber(const uint8_t positionNum, const uint8_t structLen,
376 uint8_t* dataIn);
377 void partNumber(const uint8_t positionNum, const uint8_t structLen,
378 uint8_t* dataIn);
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700379 void version(const uint8_t positionNum, const uint8_t structLen,
380 uint8_t* dataIn);
381 void characteristics(const uint16_t value);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800382};
383
384} // namespace smbios
385
386} // namespace phosphor