blob: e4f4d7630df6b933919fc4e9aeed9005e451cef6 [file] [log] [blame]
Zhikui Ren18a5ab92020-09-01 21:35:20 -07001/*
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 Doman5b285892021-03-03 13:10:58 -080020#include <sdbusplus/server/object.hpp>
Zhikui Ren18a5ab92020-09-01 21:35:20 -070021#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
Jonathan Doman5b285892021-03-03 13:10:58 -080022#include <xyz/openbmc_project/Inventory/Decorator/UniqueIdentifier/server.hpp>
Zhikui Ren18a5ab92020-09-01 21:35:20 -070023
Zhikui Ren18a5ab92020-09-01 21:35:20 -070024namespace cpu_info
25{
26static constexpr char const* cpuInfoObject = "xyz.openbmc_project.CPUInfo";
27static constexpr char const* cpuInfoPath = "/xyz/openbmc_project/CPUInfo";
28static constexpr char const* cpuInfoInterface = "xyz.openbmc_project.CPUInfo";
Jonathan Doman94c94bf2020-10-05 23:25:45 -070029static constexpr const char* cpuPath =
30 "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu";
Zhikui Ren18a5ab92020-09-01 21:35:20 -070031
Zhikui Ren6d3ad582020-09-11 21:25:59 -070032static constexpr const int configCheckInterval = 10;
33static constexpr const int peciCheckInterval = 60;
Zhikui Ren18a5ab92020-09-01 21:35:20 -070034
35/** \ todo add cpu interface to CPUInfo and consolidate with smbios service
36 * using processor =
37 sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu;
38*/
Zhikui Ren18a5ab92020-09-01 21:35:20 -070039
Jonathan Doman5b285892021-03-03 13:10:58 -080040using UniqueIdentifierBase =
41 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
42 Decorator::server::UniqueIdentifier>;
43
44struct CPUInfo : public UniqueIdentifierBase
Zhikui Ren18a5ab92020-09-01 21:35:20 -070045{
Patrick Williams77b9c472022-07-22 19:26:57 -050046 CPUInfo(sdbusplus::bus_t& bus, const size_t cpuId,
Jonathan Doman5b285892021-03-03 13:10:58 -080047 const uint8_t peciAddress, const uint8_t i2cBusNum,
48 const uint8_t i2cSlaveAddress) :
49 // use defer_emit for UniqueIdentifier iface so that ObjectMapper
50 // doesn't find it until we have a valid PPIN
51 UniqueIdentifierBase(bus, (cpuPath + std::to_string(cpuId - 1)).c_str(),
52 action::defer_emit),
53 id(cpuId), peciAddr(peciAddress), i2cBus(i2cBusNum),
54 i2cDevice(i2cSlaveAddress)
Zhikui Ren18a5ab92020-09-01 21:35:20 -070055 {}
56
Zhikui Ren6d3ad582020-09-11 21:25:59 -070057 uint8_t id;
58 uint8_t peciAddr;
59 uint8_t i2cBus;
60 uint8_t i2cDevice;
Jonathan Doman2285be42021-03-08 14:54:12 -080061 std::string sSpec;
Zhikui Ren18a5ab92020-09-01 21:35:20 -070062};
63
64} // namespace cpu_info