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