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 | |
| 20 | #include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp> |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 21 | #include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 22 | #include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 23 | |
| 24 | namespace phosphor |
| 25 | { |
| 26 | |
| 27 | namespace smbios |
| 28 | { |
| 29 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 30 | using rev = |
| 31 | sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision; |
| 32 | using asset = |
| 33 | sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset; |
| 34 | using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 35 | |
| 36 | // Definition follow smbios spec DSP0134 3.0.0 |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 37 | static const std::map<uint8_t, const char*> familyTable = { |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 38 | {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 Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 73 | static 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 Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 90 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 91 | class Cpu : sdbusplus::server::object_t<processor, asset, rev> |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 92 | { |
| 93 | public: |
| 94 | Cpu() = delete; |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 95 | Cpu(const Cpu&) = delete; |
| 96 | Cpu& operator=(const Cpu&) = delete; |
| 97 | Cpu(Cpu&&) = delete; |
| 98 | Cpu& operator=(Cpu&&) = delete; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 99 | ~Cpu() = default; |
| 100 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 101 | Cpu(sdbusplus::bus::bus& bus, const std::string& objPath, |
| 102 | const uint8_t& cpuId, uint8_t* smbiosTableStorage) : |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 103 | sdbusplus::server::object_t<processor, asset, rev>(bus, |
| 104 | objPath.c_str()), |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 105 | cpuNum(cpuId), storage(smbiosTableStorage) |
| 106 | { |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 107 | infoUpdate(); |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 108 | } |
| 109 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 110 | void infoUpdate(void); |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 111 | |
| 112 | private: |
| 113 | uint8_t cpuNum; |
| 114 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 115 | uint8_t* storage; |
Cheng C Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 116 | |
| 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 Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 150 | 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 Yang | 43c6a1d | 2019-12-19 00:48:34 +0800 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | } // namespace smbios |
| 161 | |
| 162 | } // namespace phosphor |