main.cpp (b5cc37cebec74f0bd2a8d378d5f911fc4fa3439e) | main.cpp (ce6a3f36cedc2f822fb446bc5094eaeab47eb4af) |
---|---|
1/** 2 * Copyright 2017 Google Inc. 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 --- 7 unchanged lines hidden (view full) --- 16 17#include "config.h" 18 19#include "build/buildjson.hpp" 20#include "conf.hpp" 21#include "interfaces.hpp" 22#include "pid/builder.hpp" 23#include "pid/buildjson.hpp" | 1/** 2 * Copyright 2017 Google Inc. 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 --- 7 unchanged lines hidden (view full) --- 16 17#include "config.h" 18 19#include "build/buildjson.hpp" 20#include "conf.hpp" 21#include "interfaces.hpp" 22#include "pid/builder.hpp" 23#include "pid/buildjson.hpp" |
24#include "pid/pidthread.hpp" | 24#include "pid/pidloop.hpp" |
25#include "pid/tuning.hpp" 26#include "pid/zone.hpp" 27#include "sensors/builder.hpp" 28#include "sensors/buildjson.hpp" 29#include "sensors/manager.hpp" | 25#include "pid/tuning.hpp" 26#include "pid/zone.hpp" 27#include "sensors/builder.hpp" 28#include "sensors/buildjson.hpp" 29#include "sensors/manager.hpp" |
30#include "threads/busthread.hpp" | |
31#include "util.hpp" 32 33#include <CLI/CLI.hpp> | 30#include "util.hpp" 31 32#include <CLI/CLI.hpp> |
33#include <boost/asio/io_context.hpp> 34#include <boost/asio/steady_timer.hpp> |
|
34#include <chrono> 35#include <iostream> | 35#include <chrono> 36#include <iostream> |
37#include <list> |
|
36#include <map> 37#include <memory> | 38#include <map> 39#include <memory> |
40#include <sdbusplus/asio/connection.hpp> |
|
38#include <sdbusplus/bus.hpp> 39#include <thread> 40#include <unordered_map> 41#include <utility> 42#include <vector> 43 44#if CONFIGURE_DBUS 45#include "dbus/dbusconfiguration.hpp" --- 72 unchanged lines hidden (view full) --- 118 /* 119 * All sensors are managed by one manager, but each zone has a pointer to 120 * it. 121 */ 122 123 auto& hostSensorBus = mgmr.getHostBus(); 124 auto& passiveListeningBus = mgmr.getPassiveBus(); 125 | 41#include <sdbusplus/bus.hpp> 42#include <thread> 43#include <unordered_map> 44#include <utility> 45#include <vector> 46 47#if CONFIGURE_DBUS 48#include "dbus/dbusconfiguration.hpp" --- 72 unchanged lines hidden (view full) --- 121 /* 122 * All sensors are managed by one manager, but each zone has a pointer to 123 * it. 124 */ 125 126 auto& hostSensorBus = mgmr.getHostBus(); 127 auto& passiveListeningBus = mgmr.getPassiveBus(); 128 |
126 std::cerr << "Starting threads\n"; | 129 boost::asio::io_context io; 130 sdbusplus::asio::connection passiveBus(io, passiveListeningBus.release()); |
127 | 131 |
128 /* TODO(venture): Ask SensorManager if we have any passive sensors. */ 129 struct ThreadParams p = {std::ref(passiveListeningBus), ""}; 130 std::thread l(busThread, std::ref(p)); | 132 sdbusplus::asio::connection hostBus(io, hostSensorBus.release()); 133 hostBus.request_name("xyz.openbmc_project.Hwmon.external"); |
131 | 134 |
132 /* TODO(venture): Ask SensorManager if we have any host sensors. */ 133 static constexpr auto hostBus = "xyz.openbmc_project.Hwmon.external"; 134 struct ThreadParams e = {std::ref(hostSensorBus), hostBus}; 135 std::thread te(busThread, std::ref(e)); | 135 sdbusplus::asio::connection modeBus(io, modeControlBus.release()); 136 modeBus.request_name("xyz.openbmc_project.State.FanCtrl"); |
136 | 137 |
137 static constexpr auto modeBus = "xyz.openbmc_project.State.FanCtrl"; 138 struct ThreadParams m = {std::ref(modeControlBus), modeBus}; 139 std::thread tm(busThread, std::ref(m)); | 138 std::list<boost::asio::steady_timer> timers; |
140 | 139 |
141 std::vector<std::thread> zoneThreads; 142 143 /* TODO(venture): This was designed to have one thread per zone, but really 144 * it could have one thread for all the zones and iterate through each 145 * sequentially as it goes -- and it'd probably be fast enough to do that, 146 * however, a system isn't likely going to have more than a couple zones. 147 * If it only has a couple zones, then this is fine. 148 */ | |
149 for (const auto& i : zones) 150 { | 140 for (const auto& i : zones) 141 { |
142 auto& timer = timers.emplace_back(io); |
|
151 std::cerr << "pushing zone" << std::endl; | 143 std::cerr << "pushing zone" << std::endl; |
152 zoneThreads.push_back(std::thread(pidControlThread, i.second.get())); | 144 pidControlLoop(i.second.get(), timer); |
153 } 154 | 145 } 146 |
155 l.join(); 156 te.join(); 157 tm.join(); 158 for (auto& t : zoneThreads) 159 { 160 t.join(); 161 } 162 | 147 io.run(); |
163 return rc; 164} | 148 return rc; 149} |