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