blob: 9e48184182c877ad7f097774d3dccab889321662 [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001/*
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
Andrew Jefferye73bd0a2023-01-25 10:39:57 +103017#include "IntelCPUSensor.hpp"
18#include "Utils.hpp"
19#include "VariantVisitors.hpp"
20
James Feist6714a252018-09-10 15:26:18 -070021#include <fcntl.h>
Oleksandr Shulzhenko77141ac2023-03-14 14:52:36 +010022#include <peci.h>
James Feist6714a252018-09-10 15:26:18 -070023
James Feist6714a252018-09-10 15:26:18 -070024#include <boost/algorithm/string/replace.hpp>
Patrick Venture96e97db2019-10-31 13:44:38 -070025#include <boost/container/flat_map.hpp>
James Feist6714a252018-09-10 15:26:18 -070026#include <boost/container/flat_set.hpp>
James Feist38fb5982020-05-28 10:09:54 -070027#include <sdbusplus/asio/connection.hpp>
28#include <sdbusplus/asio/object_server.hpp>
29#include <sdbusplus/bus/match.hpp>
30
31#include <array>
Jakub Nowackia38e5612023-03-08 12:27:01 +010032#include <cerrno>
James Feist24f02f22019-04-15 11:05:39 -070033#include <filesystem>
James Feist6714a252018-09-10 15:26:18 -070034#include <fstream>
Patrick Venture96e97db2019-10-31 13:44:38 -070035#include <functional>
36#include <memory>
James Feist6714a252018-09-10 15:26:18 -070037#include <regex>
Patrick Venture96e97db2019-10-31 13:44:38 -070038#include <sstream>
39#include <stdexcept>
40#include <string>
41#include <utility>
42#include <variant>
43#include <vector>
James Feist6714a252018-09-10 15:26:18 -070044
James Feistf87dc4c2018-12-05 14:39:51 -080045// clang-format off
46// this needs to be included last or we'll have build issues
47#include <linux/peci-ioctl.h>
Jae Hyun Yoo201c8d92019-02-27 15:41:56 -080048#if !defined(PECI_MBX_INDEX_DDR_DIMM_TEMP)
49#define PECI_MBX_INDEX_DDR_DIMM_TEMP MBX_INDEX_DDR_DIMM_TEMP
50#endif
James Feistf87dc4c2018-12-05 14:39:51 -080051// clang-format on
52
Ed Tanous8a57ec02020-10-09 12:46:52 -070053static constexpr bool debug = false;
James Feist6714a252018-09-10 15:26:18 -070054
Thu Nguyen255da6b2022-07-29 10:05:52 +070055boost::container::flat_map<std::string, std::shared_ptr<IntelCPUSensor>>
56 gCpuSensors;
James Feistc140e202019-11-14 15:23:51 -080057boost::container::flat_map<std::string,
58 std::shared_ptr<sdbusplus::asio::dbus_interface>>
59 inventoryIfaces;
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -080060
James Feist6714a252018-09-10 15:26:18 -070061enum State
62{
63 OFF, // host powered down
64 ON, // host powered on
65 READY // host powered on and mem test passed - fully ready
66};
67
68struct CPUConfig
69{
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -070070 CPUConfig(const uint64_t& bus, const uint64_t& addr,
71 const std::string& name, const State& state) :
72 bus(bus),
73 addr(addr), name(name), state(state)
James Feist38fb5982020-05-28 10:09:54 -070074 {}
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -070075 int bus;
James Feist6714a252018-09-10 15:26:18 -070076 int addr;
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -070077 std::string name;
James Feist6714a252018-09-10 15:26:18 -070078 State state;
79
80 bool operator<(const CPUConfig& rhs) const
81 {
Andrew Jeffery92b96292021-05-27 16:41:31 +093082 // NOLINTNEXTLINE
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -070083 return (name < rhs.name);
James Feist6714a252018-09-10 15:26:18 -070084 }
85};
86
Jae Hyun Yoo9c55e6a2018-10-26 10:09:01 -070087static constexpr const char* peciDev = "/dev/peci-";
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -080088static constexpr const char* peciDevPath = "/sys/bus/peci/devices/";
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070089static constexpr const unsigned int rankNumMax = 8;
James Feist6714a252018-09-10 15:26:18 -070090
James Feistcf3bce62019-01-08 10:07:19 -080091namespace fs = std::filesystem;
James Feist3eb82622019-02-08 13:10:22 -080092
Zev Weiss054aad82022-08-18 01:37:34 -070093static constexpr auto sensorTypes{std::to_array<const char*>({"XeonCPU"})};
Brandon Kim66558232021-11-09 16:53:08 -080094static constexpr auto hiddenProps{std::to_array<const char*>(
Thu Nguyen255da6b2022-07-29 10:05:52 +070095 {IntelCPUSensor::labelTcontrol, "Tthrottle", "Tjmax"})};
James Feist6714a252018-09-10 15:26:18 -070096
Jae Hyun Yood64262b2018-11-01 13:31:16 -070097void detectCpuAsync(
Ed Tanous9b4a20e2022-09-06 08:47:11 -070098 boost::asio::steady_timer& pingTimer,
Ed Tanous1f978632023-02-28 18:16:39 -080099 boost::asio::steady_timer& creationTimer, boost::asio::io_context& io,
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700100 sdbusplus::asio::object_server& objectServer,
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800101 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800102 boost::container::flat_set<CPUConfig>& cpuConfigs,
103 ManagedObjectType& sensorConfigs);
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700104
Zbigniew Kurzynski0eee0c12020-06-18 14:20:08 +0200105std::string createSensorName(const std::string& label, const std::string& item,
106 const int& cpuId)
107{
108 std::string sensorName = label;
Ed Tanous2049bd22022-07-09 07:20:26 -0700109 if (item != "input")
Zbigniew Kurzynski0eee0c12020-06-18 14:20:08 +0200110 {
111 sensorName += " " + item;
112 }
113 sensorName += " CPU" + std::to_string(cpuId);
114 // converting to Upper Camel case whole name
115 bool isWordEnd = true;
116 std::transform(sensorName.begin(), sensorName.end(), sensorName.begin(),
117 [&isWordEnd](int c) {
Ed Tanous2049bd22022-07-09 07:20:26 -0700118 if (std::isspace(c) != 0)
Ed Tanousbb679322022-05-16 16:10:00 -0700119 {
120 isWordEnd = true;
121 }
122 else
123 {
124 if (isWordEnd)
125 {
126 isWordEnd = false;
127 return std::toupper(c);
128 }
129 }
130 return c;
131 });
Zbigniew Kurzynski0eee0c12020-06-18 14:20:08 +0200132 return sensorName;
133}
134
Ed Tanous1f978632023-02-28 18:16:39 -0800135bool createSensors(boost::asio::io_context& io,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800136 sdbusplus::asio::object_server& objectServer,
137 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
138 boost::container::flat_set<CPUConfig>& cpuConfigs,
139 ManagedObjectType& sensorConfigs)
James Feist6714a252018-09-10 15:26:18 -0700140{
141 bool available = false;
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800142 for (const CPUConfig& cpu : cpuConfigs)
James Feist6714a252018-09-10 15:26:18 -0700143 {
144 if (cpu.state != State::OFF)
145 {
146 available = true;
Zev Weiss9702c9d2021-04-21 22:41:51 -0500147 std::shared_ptr<sdbusplus::asio::dbus_interface>& iface =
James Feistc140e202019-11-14 15:23:51 -0800148 inventoryIfaces[cpu.name];
149 if (iface != nullptr)
150 {
151 continue;
152 }
153 iface = objectServer.add_interface(
154 cpuInventoryPath + std::string("/") + cpu.name,
155 "xyz.openbmc_project.Inventory.Item");
156 iface->register_property("PrettyName", cpu.name);
157 iface->register_property("Present", true);
158 iface->initialize();
James Feist6714a252018-09-10 15:26:18 -0700159 }
160 }
161 if (!available)
162 {
Yoo, Jae Hyunf78d0a42018-10-10 11:03:11 -0700163 return false;
James Feist6714a252018-09-10 15:26:18 -0700164 }
165
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800166 if (sensorConfigs.empty())
James Feist6714a252018-09-10 15:26:18 -0700167 {
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800168 return false;
James Feist6714a252018-09-10 15:26:18 -0700169 }
170
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700171 std::vector<fs::path> hwmonNamePaths;
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800172 if (!findFiles(fs::path(peciDevPath),
173 R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
174 hwmonNamePaths, 6))
James Feist6714a252018-09-10 15:26:18 -0700175 {
176 std::cerr << "No CPU sensors in system\n";
Yoo, Jae Hyunf78d0a42018-10-10 11:03:11 -0700177 return true;
James Feist6714a252018-09-10 15:26:18 -0700178 }
179
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700180 boost::container::flat_set<std::string> scannedDirectories;
181 boost::container::flat_set<std::string> createdSensors;
182
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800183 for (const fs::path& hwmonNamePath : hwmonNamePaths)
James Feist6714a252018-09-10 15:26:18 -0700184 {
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700185 auto hwmonDirectory = hwmonNamePath.parent_path();
186
187 auto ret = scannedDirectories.insert(hwmonDirectory.string());
188 if (!ret.second)
James Feist6714a252018-09-10 15:26:18 -0700189 {
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700190 continue; // already searched this path
191 }
192
193 fs::path::iterator it = hwmonNamePath.begin();
194 std::advance(it, 6); // pick the 6th part for a PECI client device name
195 std::string deviceName = *it;
Ed Tanous8a57ec02020-10-09 12:46:52 -0700196 auto findHyphen = deviceName.find('-');
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700197 if (findHyphen == std::string::npos)
198 {
199 std::cerr << "found bad device " << deviceName << "\n";
James Feist6714a252018-09-10 15:26:18 -0700200 continue;
201 }
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700202 std::string busStr = deviceName.substr(0, findHyphen);
203 std::string addrStr = deviceName.substr(findHyphen + 1);
204
205 size_t bus = 0;
206 size_t addr = 0;
207 try
208 {
209 bus = std::stoi(busStr);
Ed Tanous8a57ec02020-10-09 12:46:52 -0700210 addr = std::stoi(addrStr, nullptr, 16);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700211 }
Patrick Williams26601e82021-10-06 12:43:25 -0500212 catch (const std::invalid_argument&)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700213 {
214 continue;
215 }
216
217 std::ifstream nameFile(hwmonNamePath);
218 if (!nameFile.good())
219 {
220 std::cerr << "Failure reading " << hwmonNamePath << "\n";
221 continue;
222 }
223 std::string hwmonName;
224 std::getline(nameFile, hwmonName);
James Feist6714a252018-09-10 15:26:18 -0700225 nameFile.close();
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800226 if (hwmonName.empty())
James Feist6714a252018-09-10 15:26:18 -0700227 {
228 // shouldn't have an empty name file
229 continue;
230 }
Ed Tanous8a57ec02020-10-09 12:46:52 -0700231 if (debug)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700232 {
233 std::cout << "Checking: " << hwmonNamePath << ": " << hwmonName
234 << "\n";
235 }
James Feist6714a252018-09-10 15:26:18 -0700236
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700237 std::string sensorType;
James Feist6714a252018-09-10 15:26:18 -0700238 const SensorData* sensorData = nullptr;
239 const std::string* interfacePath = nullptr;
Jae Hyun Yooffa07e22019-07-17 10:47:18 -0700240 const SensorBaseConfiguration* baseConfiguration = nullptr;
James Feist6714a252018-09-10 15:26:18 -0700241
Zev Weiss8908b3c2022-08-12 18:21:01 -0700242 for (const auto& [path, cfgData] : sensorConfigs)
James Feist6714a252018-09-10 15:26:18 -0700243 {
Zev Weiss8908b3c2022-08-12 18:21:01 -0700244 sensorData = &cfgData;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700245 for (const char* type : sensorTypes)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700246 {
Zev Weiss26fb1492022-08-17 15:33:46 -0700247 sensorType = type;
Zev Weiss054aad82022-08-18 01:37:34 -0700248 auto sensorBase =
249 sensorData->find(configInterfaceName(sensorType));
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700250 if (sensorBase != sensorData->end())
251 {
252 baseConfiguration = &(*sensorBase);
253 break;
254 }
255 }
256 if (baseConfiguration == nullptr)
257 {
258 std::cerr << "error finding base configuration for" << hwmonName
259 << "\n";
260 continue;
261 }
262 auto configurationBus = baseConfiguration->second.find("Bus");
263 auto configurationAddress =
264 baseConfiguration->second.find("Address");
265
266 if (configurationBus == baseConfiguration->second.end() ||
267 configurationAddress == baseConfiguration->second.end())
268 {
269 std::cerr << "error finding bus or address in configuration";
270 continue;
271 }
272
James Feist3eb82622019-02-08 13:10:22 -0800273 if (std::get<uint64_t>(configurationBus->second) != bus ||
274 std::get<uint64_t>(configurationAddress->second) != addr)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700275 {
276 continue;
277 }
278
Zev Weiss8908b3c2022-08-12 18:21:01 -0700279 interfacePath = &path.str;
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700280 break;
281 }
282 if (interfacePath == nullptr)
283 {
284 std::cerr << "failed to find match for " << hwmonName << "\n";
James Feist6714a252018-09-10 15:26:18 -0700285 continue;
286 }
287
288 auto findCpuId = baseConfiguration->second.find("CpuID");
289 if (findCpuId == baseConfiguration->second.end())
290 {
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700291 std::cerr << "could not determine CPU ID for " << hwmonName << "\n";
James Feist6714a252018-09-10 15:26:18 -0700292 continue;
293 }
Patrick Williams779c96a2023-05-10 07:50:42 -0500294 int cpuId = std::visit(VariantToUnsignedIntVisitor(),
295 findCpuId->second);
James Feist6714a252018-09-10 15:26:18 -0700296
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700297 auto directory = hwmonNamePath.parent_path();
James Feist6714a252018-09-10 15:26:18 -0700298 std::vector<fs::path> inputPaths;
Zbigniew Kurzynski8d8d8d72020-05-29 19:21:24 +0200299 if (!findFiles(directory, R"((temp|power)\d+_(input|average|cap)$)",
Zbigniew Kurzynski0a4c4802020-04-01 11:22:27 +0200300 inputPaths, 0))
James Feist6714a252018-09-10 15:26:18 -0700301 {
302 std::cerr << "No temperature sensors in system\n";
303 continue;
304 }
305
306 // iterate through all found temp sensors
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800307 for (const auto& inputPath : inputPaths)
James Feist6714a252018-09-10 15:26:18 -0700308 {
Zbigniew Kurzynski63f38662020-06-09 13:02:11 +0200309 auto fileParts = splitFileName(inputPath);
Zbigniew Kurzynski0a4c4802020-04-01 11:22:27 +0200310 if (!fileParts)
311 {
312 continue;
313 }
Zbigniew Kurzynskidbfd4662020-09-28 18:06:00 +0200314 auto& [type, nr, item] = *fileParts;
James Feist6714a252018-09-10 15:26:18 -0700315 auto inputPathStr = inputPath.string();
Patrick Williams779c96a2023-05-10 07:50:42 -0500316 auto labelPath = boost::replace_all_copy(inputPathStr, item,
317 "label");
James Feist6714a252018-09-10 15:26:18 -0700318 std::ifstream labelFile(labelPath);
319 if (!labelFile.good())
320 {
321 std::cerr << "Failure reading " << labelPath << "\n";
322 continue;
323 }
324 std::string label;
325 std::getline(labelFile, label);
326 labelFile.close();
Jae Hyun Yoo13f48882019-02-19 13:37:07 -0800327
Zbigniew Kurzynski0eee0c12020-06-18 14:20:08 +0200328 std::string sensorName = createSensorName(label, item, cpuId);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700329
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800330 auto findSensor = gCpuSensors.find(sensorName);
331 if (findSensor != gCpuSensors.end())
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700332 {
Ed Tanous8a57ec02020-10-09 12:46:52 -0700333 if (debug)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700334 {
335 std::cout << "Skipped: " << inputPath << ": " << sensorName
336 << " is already created\n";
337 }
338 continue;
339 }
340
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800341 // check hidden properties
342 bool show = true;
343 for (const char* prop : hiddenProps)
344 {
345 if (label == prop)
346 {
347 show = false;
348 break;
349 }
350 }
351
Vijay Khemka86dea2b2019-06-06 11:14:37 -0700352 /*
353 * Find if there is DtsCritOffset is configured in config file
354 * set it if configured or else set it to 0
355 */
356 double dtsOffset = 0;
357 if (label == "DTS")
358 {
359 auto findThrOffset =
360 baseConfiguration->second.find("DtsCritOffset");
361 if (findThrOffset != baseConfiguration->second.end())
362 {
363 dtsOffset = std::visit(VariantToDoubleVisitor(),
364 findThrOffset->second);
365 }
366 }
367
James Feist6714a252018-09-10 15:26:18 -0700368 std::vector<thresholds::Threshold> sensorThresholds;
Ed Tanous8a57ec02020-10-09 12:46:52 -0700369 std::string labelHead = label.substr(0, label.find(' '));
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700370 parseThresholdsFromConfig(*sensorData, sensorThresholds,
Yoo, Jae Hyun81a464c2018-10-09 16:38:58 -0700371 &labelHead);
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800372 if (sensorThresholds.empty())
James Feist6714a252018-09-10 15:26:18 -0700373 {
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700374 if (!parseThresholdsFromAttr(sensorThresholds, inputPathStr,
Thu Nguyen255da6b2022-07-29 10:05:52 +0700375 IntelCPUSensor::sensorScaleFactor,
Vijay Khemka86dea2b2019-06-06 11:14:37 -0700376 dtsOffset))
James Feist6714a252018-09-10 15:26:18 -0700377 {
Yoo, Jae Hyun81a464c2018-10-09 16:38:58 -0700378 std::cerr << "error populating thresholds for "
379 << sensorName << "\n";
James Feist6714a252018-09-10 15:26:18 -0700380 }
381 }
James Feistc140e202019-11-14 15:23:51 -0800382 auto& sensorPtr = gCpuSensors[sensorName];
383 // make sure destructor fires before creating a new one
384 sensorPtr = nullptr;
Thu Nguyen255da6b2022-07-29 10:05:52 +0700385 sensorPtr = std::make_shared<IntelCPUSensor>(
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700386 inputPathStr, sensorType, objectServer, dbusConnection, io,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800387 sensorName, std::move(sensorThresholds), *interfacePath, cpuId,
Vijay Khemka86dea2b2019-06-06 11:14:37 -0700388 show, dtsOffset);
Arun P. Mohanan04d05062021-10-29 20:30:26 +0530389 sensorPtr->setupRead();
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700390 createdSensors.insert(sensorName);
Ed Tanous8a57ec02020-10-09 12:46:52 -0700391 if (debug)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700392 {
James Feist6714a252018-09-10 15:26:18 -0700393 std::cout << "Mapped: " << inputPath << " to " << sensorName
394 << "\n";
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700395 }
James Feist6714a252018-09-10 15:26:18 -0700396 }
397 }
Yoo, Jae Hyunf78d0a42018-10-10 11:03:11 -0700398
Ed Tanous2049bd22022-07-09 07:20:26 -0700399 if (static_cast<unsigned int>(!createdSensors.empty()) != 0U)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700400 {
401 std::cout << "Sensor" << (createdSensors.size() == 1 ? " is" : "s are")
402 << " created\n";
403 }
Yoo, Jae Hyuna441f3c2018-10-09 16:43:03 -0700404
Yoo, Jae Hyunf78d0a42018-10-10 11:03:11 -0700405 return true;
James Feist6714a252018-09-10 15:26:18 -0700406}
407
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800408bool exportDevice(const CPUConfig& config)
James Feist6714a252018-09-10 15:26:18 -0700409{
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700410 std::ostringstream hex;
411 hex << std::hex << config.addr;
412 const std::string& addrHexStr = hex.str();
413 std::string busStr = std::to_string(config.bus);
414
415 std::string parameters = "peci-client 0x" + addrHexStr;
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800416 std::string devPath = peciDevPath;
417 std::string delDevice = devPath + "peci-" + busStr + "/delete_device";
418 std::string newDevice = devPath + "peci-" + busStr + "/new_device";
419 std::string newClient = devPath + busStr + "-" + addrHexStr + "/driver";
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700420
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800421 std::filesystem::path devicePath(newDevice);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700422 const std::string& dir = devicePath.parent_path().string();
James Feistcf3bce62019-01-08 10:07:19 -0800423 for (const auto& path : std::filesystem::directory_iterator(dir))
James Feist6714a252018-09-10 15:26:18 -0700424 {
James Feistcf3bce62019-01-08 10:07:19 -0800425 if (!std::filesystem::is_directory(path))
James Feist6714a252018-09-10 15:26:18 -0700426 {
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700427 continue;
James Feist6714a252018-09-10 15:26:18 -0700428 }
429
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700430 const std::string& directoryName = path.path().filename();
Zev Weiss6c106d62022-08-17 20:50:00 -0700431 if (directoryName.starts_with(busStr) &&
432 directoryName.ends_with(addrHexStr))
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700433 {
Ed Tanous8a57ec02020-10-09 12:46:52 -0700434 if (debug)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700435 {
436 std::cout << parameters << " on bus " << busStr
437 << " is already exported\n";
438 }
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800439
440 std::ofstream delDeviceFile(delDevice);
441 if (!delDeviceFile.good())
442 {
443 std::cerr << "Error opening " << delDevice << "\n";
444 return false;
445 }
446 delDeviceFile << parameters;
447 delDeviceFile.close();
448
449 break;
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700450 }
James Feist6714a252018-09-10 15:26:18 -0700451 }
452
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800453 std::ofstream deviceFile(newDevice);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700454 if (!deviceFile.good())
James Feist6714a252018-09-10 15:26:18 -0700455 {
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800456 std::cerr << "Error opening " << newDevice << "\n";
457 return false;
James Feist6714a252018-09-10 15:26:18 -0700458 }
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700459 deviceFile << parameters;
460 deviceFile.close();
461
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800462 if (!std::filesystem::exists(newClient))
463 {
464 std::cerr << "Error creating " << newClient << "\n";
465 return false;
466 }
467
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700468 std::cout << parameters << " on bus " << busStr << " is exported\n";
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800469
470 return true;
James Feist6714a252018-09-10 15:26:18 -0700471}
472
Ed Tanous9b4a20e2022-09-06 08:47:11 -0700473void detectCpu(boost::asio::steady_timer& pingTimer,
474 boost::asio::steady_timer& creationTimer,
Ed Tanous1f978632023-02-28 18:16:39 -0800475 boost::asio::io_context& io,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800476 sdbusplus::asio::object_server& objectServer,
477 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
478 boost::container::flat_set<CPUConfig>& cpuConfigs,
479 ManagedObjectType& sensorConfigs)
James Feist6714a252018-09-10 15:26:18 -0700480{
James Feist6714a252018-09-10 15:26:18 -0700481 size_t rescanDelaySeconds = 0;
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700482 static bool keepPinging = false;
Jae Hyun Yoo9c55e6a2018-10-26 10:09:01 -0700483
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800484 for (CPUConfig& config : cpuConfigs)
James Feist6714a252018-09-10 15:26:18 -0700485 {
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800486 if (config.state == State::READY)
487 {
488 continue;
489 }
490
Jae Hyun Yoo9c55e6a2018-10-26 10:09:01 -0700491 std::string peciDevPath = peciDev + std::to_string(config.bus);
Ed Tanous99c44092022-01-14 09:59:09 -0800492
493 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
Jae Hyun Yoo9c55e6a2018-10-26 10:09:01 -0700494 auto file = open(peciDevPath.c_str(), O_RDWR | O_CLOEXEC);
495 if (file < 0)
496 {
Jakub Nowackia38e5612023-03-08 12:27:01 +0100497 std::cerr << "unable to open " << peciDevPath << " "
498 << std::strerror(errno) << "\n";
499 detectCpuAsync(pingTimer, creationTimer, io, objectServer,
500 dbusConnection, cpuConfigs, sensorConfigs);
501 return;
Jae Hyun Yoo9c55e6a2018-10-26 10:09:01 -0700502 }
503
Oleksandr Shulzhenko77141ac2023-03-14 14:52:36 +0100504 peci_SetDevName(peciDevPath.data());
Ed Tanousa771f6a2022-01-14 09:36:51 -0800505 State newState = State::OFF;
Ed Tanous99c44092022-01-14 09:59:09 -0800506
507 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
Oleksandr Shulzhenko77141ac2023-03-14 14:52:36 +0100508 if (peci_Ping(config.addr) == PECI_CC_SUCCESS)
James Feist6714a252018-09-10 15:26:18 -0700509 {
510 bool dimmReady = false;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700511 for (unsigned int rank = 0; rank < rankNumMax; rank++)
James Feist6714a252018-09-10 15:26:18 -0700512 {
Oleksandr Shulzhenko77141ac2023-03-14 14:52:36 +0100513 std::array<uint8_t, 8> pkgConfig{};
514 uint8_t cc = 0;
Ed Tanous99c44092022-01-14 09:59:09 -0800515
516 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
Oleksandr Shulzhenko77141ac2023-03-14 14:52:36 +0100517 if (peci_RdPkgConfig(config.addr, PECI_MBX_INDEX_DDR_DIMM_TEMP,
518 rank, 4, &pkgConfig[0],
519 &cc) == PECI_CC_SUCCESS)
James Feist6714a252018-09-10 15:26:18 -0700520 {
Oleksandr Shulzhenko77141ac2023-03-14 14:52:36 +0100521 if ((pkgConfig[0] != 0U) || (pkgConfig[1] != 0U) ||
522 (pkgConfig[2] != 0U))
James Feist6714a252018-09-10 15:26:18 -0700523 {
524 dimmReady = true;
525 break;
526 }
527 }
528 else
529 {
530 break;
531 }
532 }
Yoo, Jae Hyuna441f3c2018-10-09 16:43:03 -0700533
James Feist6714a252018-09-10 15:26:18 -0700534 if (dimmReady)
535 {
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700536 newState = State::READY;
James Feist6714a252018-09-10 15:26:18 -0700537 }
538 else
539 {
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700540 newState = State::ON;
James Feist6714a252018-09-10 15:26:18 -0700541 }
542 }
James Feist6714a252018-09-10 15:26:18 -0700543
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700544 if (config.state != newState)
James Feist6714a252018-09-10 15:26:18 -0700545 {
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700546 if (newState != State::OFF)
James Feist6714a252018-09-10 15:26:18 -0700547 {
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700548 if (config.state == State::OFF)
549 {
Jae Hyun Yoo6d0f27b2021-01-27 15:52:16 -0800550 std::array<uint8_t, 8> pkgConfig{};
551 uint8_t cc = 0;
552
553 if (peci_RdPkgConfig(config.addr, PECI_MBX_INDEX_CPU_ID, 0,
554 4, &pkgConfig[0],
555 &cc) == PECI_CC_SUCCESS)
556 {
557 std::cout << config.name << " is detected\n";
558 if (!exportDevice(config))
559 {
560 newState = State::OFF;
561 }
562 }
563 else
564 {
565 newState = State::OFF;
566 }
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700567 }
James Feist6714a252018-09-10 15:26:18 -0700568
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700569 if (newState == State::ON)
570 {
571 rescanDelaySeconds = 3;
572 }
573 else if (newState == State::READY)
574 {
575 rescanDelaySeconds = 5;
576 std::cout << "DIMM(s) on " << config.name
577 << " is/are detected\n";
578 }
Yoo, Jae Hyunf78d0a42018-10-10 11:03:11 -0700579 }
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700580
581 config.state = newState;
Yoo, Jae Hyunf78d0a42018-10-10 11:03:11 -0700582 }
583
584 if (config.state != State::READY)
James Feist6714a252018-09-10 15:26:18 -0700585 {
586 keepPinging = true;
587 }
588
Ed Tanous8a57ec02020-10-09 12:46:52 -0700589 if (debug)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700590 {
591 std::cout << config.name << ", state: " << config.state << "\n";
592 }
James Feist6714a252018-09-10 15:26:18 -0700593 }
594
Ed Tanous2049bd22022-07-09 07:20:26 -0700595 if (rescanDelaySeconds != 0U)
James Feist6714a252018-09-10 15:26:18 -0700596 {
Ed Tanous83db50c2023-03-01 10:20:24 -0800597 creationTimer.expires_after(std::chrono::seconds(rescanDelaySeconds));
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700598 creationTimer.async_wait([&](const boost::system::error_code& ec) {
599 if (ec == boost::asio::error::operation_aborted)
600 {
601 return; // we're being canceled
602 }
603
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800604 if (!createSensors(io, objectServer, dbusConnection, cpuConfigs,
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700605 sensorConfigs) ||
606 keepPinging)
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700607 {
608 detectCpuAsync(pingTimer, creationTimer, io, objectServer,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800609 dbusConnection, cpuConfigs, sensorConfigs);
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700610 }
611 });
James Feist6714a252018-09-10 15:26:18 -0700612 }
Jae Hyun Yoo18ae22f2019-04-02 10:11:30 -0700613 else if (keepPinging)
James Feist6714a252018-09-10 15:26:18 -0700614 {
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800615 detectCpuAsync(pingTimer, creationTimer, io, objectServer,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800616 dbusConnection, cpuConfigs, sensorConfigs);
James Feist6714a252018-09-10 15:26:18 -0700617 }
618}
619
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700620void detectCpuAsync(
Ed Tanous9b4a20e2022-09-06 08:47:11 -0700621 boost::asio::steady_timer& pingTimer,
Ed Tanous1f978632023-02-28 18:16:39 -0800622 boost::asio::steady_timer& creationTimer, boost::asio::io_context& io,
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700623 sdbusplus::asio::object_server& objectServer,
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800624 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800625 boost::container::flat_set<CPUConfig>& cpuConfigs,
626 ManagedObjectType& sensorConfigs)
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700627{
Ed Tanous83db50c2023-03-01 10:20:24 -0800628 pingTimer.expires_after(std::chrono::seconds(1));
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700629 pingTimer.async_wait([&](const boost::system::error_code& ec) {
630 if (ec == boost::asio::error::operation_aborted)
631 {
632 return; // we're being canceled
633 }
634
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800635 detectCpu(pingTimer, creationTimer, io, objectServer, dbusConnection,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800636 cpuConfigs, sensorConfigs);
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700637 });
638}
639
James Feistc140e202019-11-14 15:23:51 -0800640bool getCpuConfig(const std::shared_ptr<sdbusplus::asio::connection>& systemBus,
641 boost::container::flat_set<CPUConfig>& cpuConfigs,
642 ManagedObjectType& sensorConfigs,
643 sdbusplus::asio::object_server& objectServer)
James Feist6714a252018-09-10 15:26:18 -0700644{
James Feist6714a252018-09-10 15:26:18 -0700645 bool useCache = false;
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800646 sensorConfigs.clear();
James Feist6714a252018-09-10 15:26:18 -0700647 // use new data the first time, then refresh
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700648 for (const char* type : sensorTypes)
James Feist6714a252018-09-10 15:26:18 -0700649 {
Zev Weiss26fb1492022-08-17 15:33:46 -0700650 if (!getSensorConfiguration(type, systemBus, sensorConfigs, useCache))
James Feist6714a252018-09-10 15:26:18 -0700651 {
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700652 return false;
James Feist6714a252018-09-10 15:26:18 -0700653 }
654 useCache = true;
655 }
656
Jae Hyun Yooffa07e22019-07-17 10:47:18 -0700657 // check PECI client addresses and names from CPU configuration
James Feist6714a252018-09-10 15:26:18 -0700658 // before starting ping operation
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700659 for (const char* type : sensorTypes)
James Feist6714a252018-09-10 15:26:18 -0700660 {
Zev Weiss8908b3c2022-08-12 18:21:01 -0700661 for (const auto& [path, cfgData] : sensorConfigs)
James Feist6714a252018-09-10 15:26:18 -0700662 {
Zev Weiss8908b3c2022-08-12 18:21:01 -0700663 for (const auto& [intf, cfg] : cfgData)
James Feist6714a252018-09-10 15:26:18 -0700664 {
Zev Weiss054aad82022-08-18 01:37:34 -0700665 if (intf != configInterfaceName(type))
James Feist6714a252018-09-10 15:26:18 -0700666 {
667 continue;
668 }
669
Zev Weiss8908b3c2022-08-12 18:21:01 -0700670 auto findName = cfg.find("Name");
671 if (findName == cfg.end())
James Feist6714a252018-09-10 15:26:18 -0700672 {
673 continue;
674 }
Patrick Williams779c96a2023-05-10 07:50:42 -0500675 std::string nameRaw = std::visit(VariantToStringVisitor(),
676 findName->second);
677 std::string name = std::regex_replace(nameRaw, illegalDbusRegex,
678 "_");
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700679
James Feistc140e202019-11-14 15:23:51 -0800680 auto present = std::optional<bool>();
681 // if we can't detect it via gpio, we set presence later
Zev Weiss8908b3c2022-08-12 18:21:01 -0700682 for (const auto& [suppIntf, suppCfg] : cfgData)
James Feist58295ad2019-05-30 15:01:41 -0700683 {
Zev Weiss8908b3c2022-08-12 18:21:01 -0700684 if (suppIntf.find("PresenceGpio") != std::string::npos)
James Feist58295ad2019-05-30 15:01:41 -0700685 {
Zev Weiss8908b3c2022-08-12 18:21:01 -0700686 present = cpuIsPresent(suppCfg);
Jae Hyun Yooffa07e22019-07-17 10:47:18 -0700687 break;
James Feist58295ad2019-05-30 15:01:41 -0700688 }
Jae Hyun Yooffa07e22019-07-17 10:47:18 -0700689 }
690
James Feistc140e202019-11-14 15:23:51 -0800691 if (inventoryIfaces.find(name) == inventoryIfaces.end() &&
692 present)
Jae Hyun Yooffa07e22019-07-17 10:47:18 -0700693 {
694 auto iface = objectServer.add_interface(
695 cpuInventoryPath + std::string("/") + name,
696 "xyz.openbmc_project.Inventory.Item");
697 iface->register_property("PrettyName", name);
James Feistc140e202019-11-14 15:23:51 -0800698 iface->register_property("Present", *present);
Jae Hyun Yooffa07e22019-07-17 10:47:18 -0700699 iface->initialize();
700 inventoryIfaces[name] = std::move(iface);
701 }
James Feist58295ad2019-05-30 15:01:41 -0700702
Zev Weiss8908b3c2022-08-12 18:21:01 -0700703 auto findBus = cfg.find("Bus");
704 if (findBus == cfg.end())
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700705 {
706 std::cerr << "Can't find 'Bus' setting in " << name << "\n";
707 continue;
708 }
Patrick Williams779c96a2023-05-10 07:50:42 -0500709 uint64_t bus = std::visit(VariantToUnsignedIntVisitor(),
710 findBus->second);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700711
Zev Weiss8908b3c2022-08-12 18:21:01 -0700712 auto findAddress = cfg.find("Address");
713 if (findAddress == cfg.end())
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700714 {
715 std::cerr << "Can't find 'Address' setting in " << name
716 << "\n";
717 continue;
718 }
James Feist3eb82622019-02-08 13:10:22 -0800719 uint64_t addr = std::visit(VariantToUnsignedIntVisitor(),
720 findAddress->second);
James Feist6714a252018-09-10 15:26:18 -0700721
Ed Tanous8a57ec02020-10-09 12:46:52 -0700722 if (debug)
James Feist6714a252018-09-10 15:26:18 -0700723 {
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700724 std::cout << "bus: " << bus << "\n";
James Feist6714a252018-09-10 15:26:18 -0700725 std::cout << "addr: " << addr << "\n";
726 std::cout << "name: " << name << "\n";
727 std::cout << "type: " << type << "\n";
James Feist6714a252018-09-10 15:26:18 -0700728 }
729
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800730 cpuConfigs.emplace(bus, addr, name, State::OFF);
James Feist6714a252018-09-10 15:26:18 -0700731 }
732 }
733 }
Yoo, Jae Hyuna441f3c2018-10-09 16:43:03 -0700734
Ed Tanous2049bd22022-07-09 07:20:26 -0700735 if (static_cast<unsigned int>(!cpuConfigs.empty()) != 0U)
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700736 {
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800737 std::cout << "CPU config" << (cpuConfigs.size() == 1 ? " is" : "s are")
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700738 << " parsed\n";
739 return true;
740 }
741
742 return false;
James Feist6714a252018-09-10 15:26:18 -0700743}
744
James Feistb6c0b912019-07-09 12:21:44 -0700745int main()
James Feist6714a252018-09-10 15:26:18 -0700746{
Ed Tanous1f978632023-02-28 18:16:39 -0800747 boost::asio::io_context io;
James Feist6714a252018-09-10 15:26:18 -0700748 auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800749 boost::container::flat_set<CPUConfig> cpuConfigs;
James Feist6714a252018-09-10 15:26:18 -0700750
Ed Tanous14ed5e92022-07-12 15:50:23 -0700751 sdbusplus::asio::object_server objectServer(systemBus, true);
752 objectServer.add_manager("/xyz/openbmc_project/sensors");
Ed Tanous9b4a20e2022-09-06 08:47:11 -0700753 boost::asio::steady_timer pingTimer(io);
754 boost::asio::steady_timer creationTimer(io);
755 boost::asio::steady_timer filterTimer(io);
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800756 ManagedObjectType sensorConfigs;
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700757
Ed Tanous83db50c2023-03-01 10:20:24 -0800758 filterTimer.expires_after(std::chrono::seconds(1));
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700759 filterTimer.async_wait([&](const boost::system::error_code& ec) {
760 if (ec == boost::asio::error::operation_aborted)
761 {
Jae Hyun Yood64262b2018-11-01 13:31:16 -0700762 return; // we're being canceled
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700763 }
764
James Feistc140e202019-11-14 15:23:51 -0800765 if (getCpuConfig(systemBus, cpuConfigs, sensorConfigs, objectServer))
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700766 {
Jae Hyun Yooe8b60d02019-01-14 15:27:13 -0800767 detectCpuAsync(pingTimer, creationTimer, io, objectServer,
Jae Hyun Yoo73ca5512019-02-28 21:20:17 -0800768 systemBus, cpuConfigs, sensorConfigs);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700769 }
770 });
771
Patrick Williams92f8f512022-07-22 19:26:55 -0500772 std::function<void(sdbusplus::message_t&)> eventHandler =
773 [&](sdbusplus::message_t& message) {
Ed Tanousbb679322022-05-16 16:10:00 -0700774 if (message.is_method_error())
775 {
776 std::cerr << "callback method error\n";
777 return;
778 }
779
780 if (debug)
781 {
782 std::cout << message.get_path() << " is changed\n";
783 }
784
785 // this implicitly cancels the timer
Ed Tanous83db50c2023-03-01 10:20:24 -0800786 filterTimer.expires_after(std::chrono::seconds(1));
Ed Tanousbb679322022-05-16 16:10:00 -0700787 filterTimer.async_wait([&](const boost::system::error_code& ec) {
788 if (ec == boost::asio::error::operation_aborted)
James Feist6714a252018-09-10 15:26:18 -0700789 {
Ed Tanousbb679322022-05-16 16:10:00 -0700790 return; // we're being canceled
James Feist6714a252018-09-10 15:26:18 -0700791 }
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700792
Ed Tanousbb679322022-05-16 16:10:00 -0700793 if (getCpuConfig(systemBus, cpuConfigs, sensorConfigs,
794 objectServer))
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700795 {
Ed Tanousbb679322022-05-16 16:10:00 -0700796 detectCpuAsync(pingTimer, creationTimer, io, objectServer,
797 systemBus, cpuConfigs, sensorConfigs);
Jae Hyun Yoo8d9886d2018-10-22 15:24:29 -0700798 }
Ed Tanousbb679322022-05-16 16:10:00 -0700799 });
800 };
James Feist6714a252018-09-10 15:26:18 -0700801
Zev Weiss214d9712022-08-12 12:54:31 -0700802 std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
803 setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler);
James Feist6714a252018-09-10 15:26:18 -0700804
Thu Nguyen255da6b2022-07-29 10:05:52 +0700805 systemBus->request_name("xyz.openbmc_project.IntelCPUSensor");
Bruce Lee1263c3d2021-06-04 15:16:33 +0800806
807 setupManufacturingModeMatch(*systemBus);
James Feist6714a252018-09-10 15:26:18 -0700808 io.run();
Zhikui Ren8685b172021-06-29 15:16:52 -0700809 return 0;
James Feist6714a252018-09-10 15:26:18 -0700810}