blob: 5c8ca86722d1fd6d6b00962c15f5f4104dfbbff3 [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>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080023
24namespace phosphor
25{
26
27namespace smbios
28{
29
Zhikui Ren18a5ab92020-09-01 21:35:20 -070030using rev =
31 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision;
32using asset =
33 sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset;
34using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080035
36// Definition follow smbios spec DSP0134 3.0.0
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080037static const std::map<uint8_t, const char*> familyTable = {
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080038 {0x1, "Other"},
39 {0x2, "Unknown"},
40 {0x10, "Pentium II Xeon processor"},
41 {0xa1, "Quad-Core Intel Xeon processor 3200 Series"},
42 {0xa2, "Dual-Core Intel Xeon processor 3000 Series"},
43 {0xa3, "Quad-Core Intel Xeon processor 5300 Series"},
44 {0xa4, "Dual-Core Intel Xeon processor 5100 Series"},
45 {0xa5, "Dual-Core Intel Xeon processor 5000 Series"},
46 {0xa6, "Dual-Core Intel Xeon processor LV"},
47 {0xa7, "Dual-Core Intel Xeon processor ULV"},
48 {0xa8, "Dual-Core Intel Xeon processor 7100 Series"},
49 {0xa9, "Quad-Core Intel Xeon processor 5400 Series"},
50 {0xaa, "Quad-Core Intel Xeon processor"},
51 {0xab, "Dual-Core Intel Xeon processor 5200 Series"},
52 {0xac, "Dual-Core Intel Xeon processor 7200 Series"},
53 {0xad, "Quad-Core Intel Xeon processor 7300 Series"},
54 {0xae, "Quad-Core Intel Xeon processor 7400 Series"},
55 {0xaf, "Multi-Core Intel Xeon processor 7400 Series"},
56 {0xb0, "Pentium III Xeon processor"},
57 {0xb3, "Intel Xeon processor"},
58 {0xb5, "Intel Xeon processor MP"},
59 {0xd6, "Multi-Core Intel Xeon processor"},
60 {0xd7, "Dual-Core Intel Xeon processor 3xxx Series"},
61 {0xd8, "Quad-Core Intel Xeon processor 3xxx Series"},
62 {0xd9, "VIA Nano Processor Family"},
63 {0xda, "Dual-Core Intel Xeon processor 5xxx Series"},
64 {0xdb, "Quad-Core Intel Xeon processor 5xxx Series"},
65 {0xdd, "Dual-Core Intel Xeon processor 7xxx Series"},
66 {0xde, "Quad-Core Intel Xeon processor 7xxx Series"},
67 {0xdf, "Multi-Core Intel Xeon processor 7xxx Series"},
68 {0xe0, "Multi-Core Intel Xeon processor 3400 Series"}
69
70};
71
72// Definition follow smbios spec DSP0134 3.0.0
Zhikui Ren18a5ab92020-09-01 21:35:20 -070073static const std::array<std::optional<processor::Capability>, 16>
74 characteristicsTable{std::nullopt,
75 std::nullopt,
76 processor::Capability::Capable64bit,
77 processor::Capability::MultiCore,
78 processor::Capability::HardwareThread,
79 processor::Capability::ExecuteProtection,
80 processor::Capability::EnhancedVirtualization,
81 processor::Capability::PowerPerformanceControl,
82 std::nullopt,
83 std::nullopt,
84 std::nullopt,
85 std::nullopt,
86 std::nullopt,
87 std::nullopt,
88 std::nullopt,
89 std::nullopt};
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080090
Zhikui Ren18a5ab92020-09-01 21:35:20 -070091class Cpu : sdbusplus::server::object_t<processor, asset, rev>
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080092{
93 public:
94 Cpu() = delete;
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080095 Cpu(const Cpu&) = delete;
96 Cpu& operator=(const Cpu&) = delete;
97 Cpu(Cpu&&) = delete;
98 Cpu& operator=(Cpu&&) = delete;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +080099 ~Cpu() = default;
100
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800101 Cpu(sdbusplus::bus::bus& bus, const std::string& objPath,
102 const uint8_t& cpuId, uint8_t* smbiosTableStorage) :
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700103 sdbusplus::server::object_t<processor, asset, rev>(bus,
104 objPath.c_str()),
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800105 cpuNum(cpuId), storage(smbiosTableStorage)
106 {
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700107 infoUpdate();
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800108 }
109
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700110 void infoUpdate(void);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800111
112 private:
113 uint8_t cpuNum;
114
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +0800115 uint8_t* storage;
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800116
117 struct ProcessorInfo
118 {
119 uint8_t type;
120 uint8_t length;
121 uint16_t handle;
122 uint8_t socketDesignation;
123 uint8_t processorType;
124 uint8_t family;
125 uint8_t manufacturer;
126 uint64_t id;
127 uint8_t version;
128 uint8_t voltage;
129 uint16_t exClock;
130 uint16_t maxSpeed;
131 uint16_t currSpeed;
132 uint8_t status;
133 uint8_t upgrade;
134 uint16_t l1Handle;
135 uint16_t l2Handle;
136 uint16_t l3Handle;
137 uint8_t serialNum;
138 uint8_t assetTag;
139 uint8_t partNum;
140 uint8_t coreCount;
141 uint8_t coreEnable;
142 uint8_t threadCount;
143 uint16_t characteristics;
144 uint16_t family2;
145 uint16_t coreCount2;
146 uint16_t coreEnable2;
147 uint16_t threadCount2;
148 } __attribute__((packed));
149
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700150 void socket(const uint8_t positionNum, const uint8_t structLen,
151 uint8_t* dataIn);
152 void family(const uint8_t value);
153 void manufacturer(const uint8_t positionNum, const uint8_t structLen,
154 uint8_t* dataIn);
155 void version(const uint8_t positionNum, const uint8_t structLen,
156 uint8_t* dataIn);
157 void characteristics(const uint16_t value);
Cheng C Yang43c6a1d2019-12-19 00:48:34 +0800158};
159
160} // namespace smbios
161
162} // namespace phosphor