Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 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 |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 18 | #include "smbios_mdrv2.hpp" |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 19 | |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 20 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
Jie Yang | 41654fc | 2021-09-07 20:26:32 -0700 | [diff] [blame] | 21 | #include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 22 | #include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp> |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 23 | #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 24 | #include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 25 | #include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp> |
Jonathan Doman | 563570d | 2021-05-24 10:52:43 -0700 | [diff] [blame] | 26 | #include <xyz/openbmc_project/Inventory/Item/server.hpp> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 27 | |
| 28 | namespace phosphor |
| 29 | { |
| 30 | |
| 31 | namespace smbios |
| 32 | { |
| 33 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 34 | using rev = |
| 35 | sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision; |
| 36 | using asset = |
| 37 | sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset; |
Jie Yang | 3172039 | 2021-07-22 21:45:45 -0700 | [diff] [blame] | 38 | using location = |
| 39 | sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::LocationCode; |
Jie Yang | 41654fc | 2021-09-07 20:26:32 -0700 | [diff] [blame] | 40 | using connector = |
| 41 | sdbusplus::xyz::openbmc_project::Inventory::Connector::server::Slot; |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 42 | using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu; |
Jonathan Doman | 563570d | 2021-05-24 10:52:43 -0700 | [diff] [blame] | 43 | using Item = sdbusplus::xyz::openbmc_project::Inventory::server::Item; |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 44 | using association = |
| 45 | sdbusplus::xyz::openbmc_project::Association::server::Definitions; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 46 | |
| 47 | // Definition follow smbios spec DSP0134 3.0.0 |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 48 | static const std::map<uint8_t, const char*> familyTable = { |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 49 | {0x1, "Other"}, |
| 50 | {0x2, "Unknown"}, |
| 51 | {0x10, "Pentium II Xeon processor"}, |
| 52 | {0xa1, "Quad-Core Intel Xeon processor 3200 Series"}, |
| 53 | {0xa2, "Dual-Core Intel Xeon processor 3000 Series"}, |
| 54 | {0xa3, "Quad-Core Intel Xeon processor 5300 Series"}, |
| 55 | {0xa4, "Dual-Core Intel Xeon processor 5100 Series"}, |
| 56 | {0xa5, "Dual-Core Intel Xeon processor 5000 Series"}, |
| 57 | {0xa6, "Dual-Core Intel Xeon processor LV"}, |
| 58 | {0xa7, "Dual-Core Intel Xeon processor ULV"}, |
| 59 | {0xa8, "Dual-Core Intel Xeon processor 7100 Series"}, |
| 60 | {0xa9, "Quad-Core Intel Xeon processor 5400 Series"}, |
| 61 | {0xaa, "Quad-Core Intel Xeon processor"}, |
| 62 | {0xab, "Dual-Core Intel Xeon processor 5200 Series"}, |
| 63 | {0xac, "Dual-Core Intel Xeon processor 7200 Series"}, |
| 64 | {0xad, "Quad-Core Intel Xeon processor 7300 Series"}, |
| 65 | {0xae, "Quad-Core Intel Xeon processor 7400 Series"}, |
| 66 | {0xaf, "Multi-Core Intel Xeon processor 7400 Series"}, |
| 67 | {0xb0, "Pentium III Xeon processor"}, |
| 68 | {0xb3, "Intel Xeon processor"}, |
| 69 | {0xb5, "Intel Xeon processor MP"}, |
| 70 | {0xd6, "Multi-Core Intel Xeon processor"}, |
| 71 | {0xd7, "Dual-Core Intel Xeon processor 3xxx Series"}, |
| 72 | {0xd8, "Quad-Core Intel Xeon processor 3xxx Series"}, |
| 73 | {0xd9, "VIA Nano Processor Family"}, |
| 74 | {0xda, "Dual-Core Intel Xeon processor 5xxx Series"}, |
| 75 | {0xdb, "Quad-Core Intel Xeon processor 5xxx Series"}, |
| 76 | {0xdd, "Dual-Core Intel Xeon processor 7xxx Series"}, |
| 77 | {0xde, "Quad-Core Intel Xeon processor 7xxx Series"}, |
| 78 | {0xdf, "Multi-Core Intel Xeon processor 7xxx Series"}, |
Charles Boyer | 800bb70 | 2021-08-31 17:09:19 -0500 | [diff] [blame] | 79 | {0xe0, "Multi-Core Intel Xeon processor 3400 Series"}, |
| 80 | {0xfe, "Processor Family 2 Indicator"} |
| 81 | |
| 82 | }; |
| 83 | |
| 84 | // Definition follow smbios spec DSP0134 3.1.1 |
| 85 | static const std::map<uint16_t, const char*> family2Table = { |
| 86 | {0x100, "ARMv7"}, {0x101, "ARMv8"}, {0x118, "ARM"}, {0x119, "StrongARM"} |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 87 | |
| 88 | }; |
| 89 | |
| 90 | // Definition follow smbios spec DSP0134 3.0.0 |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 91 | static const std::array<std::optional<processor::Capability>, 16> |
| 92 | characteristicsTable{std::nullopt, |
| 93 | std::nullopt, |
| 94 | processor::Capability::Capable64bit, |
| 95 | processor::Capability::MultiCore, |
| 96 | processor::Capability::HardwareThread, |
| 97 | processor::Capability::ExecuteProtection, |
| 98 | processor::Capability::EnhancedVirtualization, |
| 99 | processor::Capability::PowerPerformanceControl, |
| 100 | std::nullopt, |
| 101 | std::nullopt, |
| 102 | std::nullopt, |
| 103 | std::nullopt, |
| 104 | std::nullopt, |
| 105 | std::nullopt, |
| 106 | std::nullopt, |
| 107 | std::nullopt}; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 108 | |
Jie Yang | 41654fc | 2021-09-07 20:26:32 -0700 | [diff] [blame] | 109 | class Cpu : |
| 110 | sdbusplus::server::object_t<processor, asset, location, connector, rev, |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 111 | Item, association> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 112 | { |
| 113 | public: |
| 114 | Cpu() = delete; |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 115 | Cpu(const Cpu&) = delete; |
| 116 | Cpu& operator=(const Cpu&) = delete; |
| 117 | Cpu(Cpu&&) = delete; |
| 118 | Cpu& operator=(Cpu&&) = delete; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 119 | ~Cpu() = default; |
| 120 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 121 | Cpu(sdbusplus::bus::bus& bus, const std::string& objPath, |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 122 | const uint8_t& cpuId, uint8_t* smbiosTableStorage, |
| 123 | const std::string& motherboard) : |
Jie Yang | 41654fc | 2021-09-07 20:26:32 -0700 | [diff] [blame] | 124 | sdbusplus::server::object_t<processor, asset, location, connector, rev, |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 125 | Item, association>(bus, objPath.c_str()), |
| 126 | cpuNum(cpuId), storage(smbiosTableStorage), motherboardPath(motherboard) |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 127 | { |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 128 | infoUpdate(); |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 129 | } |
| 130 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 131 | void infoUpdate(void); |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 132 | |
| 133 | private: |
| 134 | uint8_t cpuNum; |
| 135 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 136 | uint8_t* storage; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 137 | |
Jie Yang | e7cf319 | 2021-08-20 11:21:43 -0700 | [diff] [blame] | 138 | std::string motherboardPath; |
| 139 | |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 140 | struct ProcessorInfo |
| 141 | { |
| 142 | uint8_t type; |
| 143 | uint8_t length; |
| 144 | uint16_t handle; |
| 145 | uint8_t socketDesignation; |
| 146 | uint8_t processorType; |
| 147 | uint8_t family; |
| 148 | uint8_t manufacturer; |
| 149 | uint64_t id; |
| 150 | uint8_t version; |
| 151 | uint8_t voltage; |
| 152 | uint16_t exClock; |
| 153 | uint16_t maxSpeed; |
| 154 | uint16_t currSpeed; |
| 155 | uint8_t status; |
| 156 | uint8_t upgrade; |
| 157 | uint16_t l1Handle; |
| 158 | uint16_t l2Handle; |
| 159 | uint16_t l3Handle; |
| 160 | uint8_t serialNum; |
| 161 | uint8_t assetTag; |
| 162 | uint8_t partNum; |
| 163 | uint8_t coreCount; |
| 164 | uint8_t coreEnable; |
| 165 | uint8_t threadCount; |
| 166 | uint16_t characteristics; |
| 167 | uint16_t family2; |
| 168 | uint16_t coreCount2; |
| 169 | uint16_t coreEnable2; |
| 170 | uint16_t threadCount2; |
| 171 | } __attribute__((packed)); |
| 172 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 173 | void socket(const uint8_t positionNum, const uint8_t structLen, |
| 174 | uint8_t* dataIn); |
Charles Boyer | 800bb70 | 2021-08-31 17:09:19 -0500 | [diff] [blame] | 175 | void family(const uint8_t family, const uint16_t family2); |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 176 | void manufacturer(const uint8_t positionNum, const uint8_t structLen, |
| 177 | uint8_t* dataIn); |
Charles Boyer | e643169 | 2021-08-31 16:47:47 -0500 | [diff] [blame] | 178 | void serialNumber(const uint8_t positionNum, const uint8_t structLen, |
| 179 | uint8_t* dataIn); |
| 180 | void partNumber(const uint8_t positionNum, const uint8_t structLen, |
| 181 | uint8_t* dataIn); |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 182 | void version(const uint8_t positionNum, const uint8_t structLen, |
| 183 | uint8_t* dataIn); |
| 184 | void characteristics(const uint16_t value); |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | } // namespace smbios |
| 188 | |
| 189 | } // namespace phosphor |