blob: d4871fbb616407ae3fbb6b602b4fe0e173dc93f2 [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
20#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
Zhikui Ren18a5ab92020-09-01 21:35:20 -070021#include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080022#include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp>
Jonathan Doman563570d2021-05-24 10:52:43 -070023#include <xyz/openbmc_project/Inventory/Item/server.hpp>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080024
25namespace phosphor
26{
27
28namespace smbios
29{
30
Zhikui Ren18a5ab92020-09-01 21:35:20 -070031using rev =
32 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision;
33using asset =
34 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset;
35using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu;
Jonathan Doman563570d2021-05-24 10:52:43 -070036using Item = sdbusplus::xyz::openbmc_project::Inventory::server::Item;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080037
38// Definition follow smbios spec DSP0134 3.0.0
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080039static const std::map<uint8_t, const char*> familyTable = {
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080040 {0x1, "Other"},
41 {0x2, "Unknown"},
42 {0x10, "Pentium II Xeon processor"},
43 {0xa1, "Quad-Core Intel Xeon processor 3200 Series"},
44 {0xa2, "Dual-Core Intel Xeon processor 3000 Series"},
45 {0xa3, "Quad-Core Intel Xeon processor 5300 Series"},
46 {0xa4, "Dual-Core Intel Xeon processor 5100 Series"},
47 {0xa5, "Dual-Core Intel Xeon processor 5000 Series"},
48 {0xa6, "Dual-Core Intel Xeon processor LV"},
49 {0xa7, "Dual-Core Intel Xeon processor ULV"},
50 {0xa8, "Dual-Core Intel Xeon processor 7100 Series"},
51 {0xa9, "Quad-Core Intel Xeon processor 5400 Series"},
52 {0xaa, "Quad-Core Intel Xeon processor"},
53 {0xab, "Dual-Core Intel Xeon processor 5200 Series"},
54 {0xac, "Dual-Core Intel Xeon processor 7200 Series"},
55 {0xad, "Quad-Core Intel Xeon processor 7300 Series"},
56 {0xae, "Quad-Core Intel Xeon processor 7400 Series"},
57 {0xaf, "Multi-Core Intel Xeon processor 7400 Series"},
58 {0xb0, "Pentium III Xeon processor"},
59 {0xb3, "Intel Xeon processor"},
60 {0xb5, "Intel Xeon processor MP"},
61 {0xd6, "Multi-Core Intel Xeon processor"},
62 {0xd7, "Dual-Core Intel Xeon processor 3xxx Series"},
63 {0xd8, "Quad-Core Intel Xeon processor 3xxx Series"},
64 {0xd9, "VIA Nano Processor Family"},
65 {0xda, "Dual-Core Intel Xeon processor 5xxx Series"},
66 {0xdb, "Quad-Core Intel Xeon processor 5xxx Series"},
67 {0xdd, "Dual-Core Intel Xeon processor 7xxx Series"},
68 {0xde, "Quad-Core Intel Xeon processor 7xxx Series"},
69 {0xdf, "Multi-Core Intel Xeon processor 7xxx Series"},
70 {0xe0, "Multi-Core Intel Xeon processor 3400 Series"}
71
72};
73
74// Definition follow smbios spec DSP0134 3.0.0
Zhikui Ren18a5ab92020-09-01 21:35:20 -070075static const std::array<std::optional<processor::Capability>, 16>
76 characteristicsTable{std::nullopt,
77 std::nullopt,
78 processor::Capability::Capable64bit,
79 processor::Capability::MultiCore,
80 processor::Capability::HardwareThread,
81 processor::Capability::ExecuteProtection,
82 processor::Capability::EnhancedVirtualization,
83 processor::Capability::PowerPerformanceControl,
84 std::nullopt,
85 std::nullopt,
86 std::nullopt,
87 std::nullopt,
88 std::nullopt,
89 std::nullopt,
90 std::nullopt,
91 std::nullopt};
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080092
Jonathan Doman563570d2021-05-24 10:52:43 -070093class Cpu : sdbusplus::server::object_t<processor, asset, rev, Item>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080094{
95 public:
96 Cpu() = delete;
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080097 Cpu(const Cpu&) = delete;
98 Cpu& operator=(const Cpu&) = delete;
99 Cpu(Cpu&&) = delete;
100 Cpu& operator=(Cpu&&) = delete;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800101 ~Cpu() = default;
102
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800103 Cpu(sdbusplus::bus::bus& bus, const std::string& objPath,
104 const uint8_t& cpuId, uint8_t* smbiosTableStorage) :
Jonathan Doman563570d2021-05-24 10:52:43 -0700105 sdbusplus::server::object_t<processor, asset, rev, Item>(
106 bus, objPath.c_str()),
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800107 cpuNum(cpuId), storage(smbiosTableStorage)
108 {
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700109 infoUpdate();
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800110 }
111
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700112 void infoUpdate(void);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800113
114 private:
115 uint8_t cpuNum;
116
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800117 uint8_t* storage;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800118
119 struct ProcessorInfo
120 {
121 uint8_t type;
122 uint8_t length;
123 uint16_t handle;
124 uint8_t socketDesignation;
125 uint8_t processorType;
126 uint8_t family;
127 uint8_t manufacturer;
128 uint64_t id;
129 uint8_t version;
130 uint8_t voltage;
131 uint16_t exClock;
132 uint16_t maxSpeed;
133 uint16_t currSpeed;
134 uint8_t status;
135 uint8_t upgrade;
136 uint16_t l1Handle;
137 uint16_t l2Handle;
138 uint16_t l3Handle;
139 uint8_t serialNum;
140 uint8_t assetTag;
141 uint8_t partNum;
142 uint8_t coreCount;
143 uint8_t coreEnable;
144 uint8_t threadCount;
145 uint16_t characteristics;
146 uint16_t family2;
147 uint16_t coreCount2;
148 uint16_t coreEnable2;
149 uint16_t threadCount2;
150 } __attribute__((packed));
151
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700152 void socket(const uint8_t positionNum, const uint8_t structLen,
153 uint8_t* dataIn);
154 void family(const uint8_t value);
155 void manufacturer(const uint8_t positionNum, const uint8_t structLen,
156 uint8_t* dataIn);
Charles Boyere6431692021-08-31 16:47:47 -0500157 void serialNumber(const uint8_t positionNum, const uint8_t structLen,
158 uint8_t* dataIn);
159 void partNumber(const uint8_t positionNum, const uint8_t structLen,
160 uint8_t* dataIn);
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700161 void version(const uint8_t positionNum, const uint8_t structLen,
162 uint8_t* dataIn);
163 void characteristics(const uint16_t value);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800164};
165
166} // namespace smbios
167
168} // namespace phosphor