Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2020 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 | |
| 19 | #include <sdbusplus/asio/object_server.hpp> |
Jonathan Doman | 5b28589 | 2021-03-03 13:10:58 -0800 | [diff] [blame] | 20 | #include <sdbusplus/server/object.hpp> |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 21 | #include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp> |
Jonathan Doman | 5b28589 | 2021-03-03 13:10:58 -0800 | [diff] [blame] | 22 | #include <xyz/openbmc_project/Inventory/Decorator/UniqueIdentifier/server.hpp> |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 23 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 24 | namespace cpu_info |
| 25 | { |
Patrick Williams | c39d3df | 2023-05-10 07:51:14 -0500 | [diff] [blame] | 26 | static constexpr const char* cpuInfoObject = "xyz.openbmc_project.CPUInfo"; |
| 27 | static constexpr const char* cpuInfoPath = "/xyz/openbmc_project/CPUInfo"; |
| 28 | static constexpr const char* cpuInfoInterface = "xyz.openbmc_project.CPUInfo"; |
Jonathan Doman | 94c94bf | 2020-10-05 23:25:45 -0700 | [diff] [blame] | 29 | static constexpr const char* cpuPath = |
| 30 | "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu"; |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 31 | |
Zhikui Ren | 6d3ad58 | 2020-09-11 21:25:59 -0700 | [diff] [blame] | 32 | static constexpr const int configCheckInterval = 10; |
| 33 | static constexpr const int peciCheckInterval = 60; |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 34 | |
Jonathan Doman | 4e1cf09 | 2024-03-08 19:57:56 -0800 | [diff] [blame] | 35 | using UniqueIdentifier = |
Jason M. Bills | 33ae81f | 2023-04-26 09:06:08 -0700 | [diff] [blame] | 36 | sdbusplus::server::object_t<sdbusplus::server::xyz::openbmc_project:: |
| 37 | inventory::decorator::UniqueIdentifier>; |
Jonathan Doman | 5b28589 | 2021-03-03 13:10:58 -0800 | [diff] [blame] | 38 | |
Jonathan Doman | 4e1cf09 | 2024-03-08 19:57:56 -0800 | [diff] [blame] | 39 | struct CPUInfo |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 40 | { |
Jonathan Doman | 4e1cf09 | 2024-03-08 19:57:56 -0800 | [diff] [blame] | 41 | CPUInfo(const size_t cpuId, const uint8_t peciAddress, |
| 42 | const uint8_t i2cBusNum, const uint8_t i2cSlaveAddress) : |
Patrick Williams | 1d73dcc | 2024-08-16 15:21:42 -0400 | [diff] [blame] | 43 | id(cpuId), peciAddr(peciAddress), i2cBus(i2cBusNum), |
| 44 | i2cDevice(i2cSlaveAddress) |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 45 | {} |
| 46 | |
Jonathan Doman | 4e1cf09 | 2024-03-08 19:57:56 -0800 | [diff] [blame] | 47 | void publishUUID(sdbusplus::bus_t& bus, const std::string& uuid) |
| 48 | { |
| 49 | uuidInterface.emplace(bus, (cpuPath + std::to_string(id - 1)).c_str(), |
| 50 | UniqueIdentifier::action::defer_emit); |
| 51 | uuidInterface->uniqueIdentifier(uuid); |
| 52 | uuidInterface->emit_added(); |
| 53 | } |
| 54 | |
| 55 | std::optional<UniqueIdentifier> uuidInterface; |
| 56 | |
Zhikui Ren | 6d3ad58 | 2020-09-11 21:25:59 -0700 | [diff] [blame] | 57 | uint8_t id; |
| 58 | uint8_t peciAddr; |
| 59 | uint8_t i2cBus; |
| 60 | uint8_t i2cDevice; |
Jonathan Doman | 2285be4 | 2021-03-08 14:54:12 -0800 | [diff] [blame] | 61 | std::string sSpec; |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | } // namespace cpu_info |