118a5ab91SZhikui Ren /* 218a5ab91SZhikui Ren // Copyright (c) 2020 intel Corporation 318a5ab91SZhikui Ren // 418a5ab91SZhikui Ren // Licensed under the Apache License, Version 2.0 (the "License"); 518a5ab91SZhikui Ren // you may not use this file except in compliance with the License. 618a5ab91SZhikui Ren // You may obtain a copy of the License at 718a5ab91SZhikui Ren // 818a5ab91SZhikui Ren // http://www.apache.org/licenses/LICENSE-2.0 918a5ab91SZhikui Ren // 1018a5ab91SZhikui Ren // Unless required by applicable law or agreed to in writing, software 1118a5ab91SZhikui Ren // distributed under the License is distributed on an "AS IS" BASIS, 1218a5ab91SZhikui Ren // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1318a5ab91SZhikui Ren // See the License for the specific language governing permissions and 1418a5ab91SZhikui Ren // limitations under the License. 1518a5ab91SZhikui Ren */ 1618a5ab91SZhikui Ren 1718a5ab91SZhikui Ren #pragma once 1818a5ab91SZhikui Ren 1918a5ab91SZhikui Ren #include <sdbusplus/asio/object_server.hpp> 205b285892SJonathan Doman #include <sdbusplus/server/object.hpp> 2118a5ab91SZhikui Ren #include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp> 225b285892SJonathan Doman #include <xyz/openbmc_project/Inventory/Decorator/UniqueIdentifier/server.hpp> 2318a5ab91SZhikui Ren 2418a5ab91SZhikui Ren namespace cpu_info 2518a5ab91SZhikui Ren { 26c39d3dfcSPatrick Williams static constexpr const char* cpuInfoObject = "xyz.openbmc_project.CPUInfo"; 27c39d3dfcSPatrick Williams static constexpr const char* cpuInfoPath = "/xyz/openbmc_project/CPUInfo"; 28c39d3dfcSPatrick Williams static constexpr const char* cpuInfoInterface = "xyz.openbmc_project.CPUInfo"; 2994c94bfbSJonathan Doman static constexpr const char* cpuPath = 3094c94bfbSJonathan Doman "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu"; 3118a5ab91SZhikui Ren 326d3ad586SZhikui Ren static constexpr const int configCheckInterval = 10; 336d3ad586SZhikui Ren static constexpr const int peciCheckInterval = 60; 3418a5ab91SZhikui Ren 35*4e1cf099SJonathan Doman using UniqueIdentifier = 3633ae81feSJason M. Bills sdbusplus::server::object_t<sdbusplus::server::xyz::openbmc_project:: 3733ae81feSJason M. Bills inventory::decorator::UniqueIdentifier>; 385b285892SJonathan Doman 39*4e1cf099SJonathan Doman struct CPUInfo 4018a5ab91SZhikui Ren { CPUInfocpu_info::CPUInfo41*4e1cf099SJonathan Doman CPUInfo(const size_t cpuId, const uint8_t peciAddress, 42*4e1cf099SJonathan Doman const uint8_t i2cBusNum, const uint8_t i2cSlaveAddress) : 43*4e1cf099SJonathan Doman id(cpuId), 44*4e1cf099SJonathan Doman peciAddr(peciAddress), i2cBus(i2cBusNum), i2cDevice(i2cSlaveAddress) 4518a5ab91SZhikui Ren {} 4618a5ab91SZhikui Ren publishUUIDcpu_info::CPUInfo47*4e1cf099SJonathan Doman void publishUUID(sdbusplus::bus_t& bus, const std::string& uuid) 48*4e1cf099SJonathan Doman { 49*4e1cf099SJonathan Doman uuidInterface.emplace(bus, (cpuPath + std::to_string(id - 1)).c_str(), 50*4e1cf099SJonathan Doman UniqueIdentifier::action::defer_emit); 51*4e1cf099SJonathan Doman uuidInterface->uniqueIdentifier(uuid); 52*4e1cf099SJonathan Doman uuidInterface->emit_added(); 53*4e1cf099SJonathan Doman } 54*4e1cf099SJonathan Doman 55*4e1cf099SJonathan Doman std::optional<UniqueIdentifier> uuidInterface; 56*4e1cf099SJonathan Doman 576d3ad586SZhikui Ren uint8_t id; 586d3ad586SZhikui Ren uint8_t peciAddr; 596d3ad586SZhikui Ren uint8_t i2cBus; 606d3ad586SZhikui Ren uint8_t i2cDevice; 612285be4fSJonathan Doman std::string sSpec; 6218a5ab91SZhikui Ren }; 6318a5ab91SZhikui Ren 6418a5ab91SZhikui Ren } // namespace cpu_info 65