M module-apps/application-settings/windows/advanced/CPUModeTestWindow.cpp => module-apps/application-settings/windows/advanced/CPUModeTestWindow.cpp +10 -7
@@ 132,23 132,26 @@ namespace gui
permanentFreqSpinner = new gui::TextSpinnerBox(permanentFreqBody, {"OFF", "ON"}, Boundaries::Continuous);
permanentFreqSpinner->setMinimumSize(100, 30);
- auto ret = application->async_call<sys::IsCpuPernament, sys::IsCpuPernamentResponse>(service::name::system_manager);
+ auto ret =
+ application->async_call<sys::IsCpuPernament, sys::IsCpuPernamentResponse>(service::name::system_manager);
application->sync(ret);
- permanentFreqSpinner->setCurrentValue( ret.getResult().pernament ? "ON" : "OFF");
+ permanentFreqSpinner->setCurrentValue(ret.getResult().pernament ? "ON" : "OFF");
permanentFreqBody->inputCallback = [&](Item &item, const InputEvent &event) {
auto ret = permanentFreqSpinner->onInput(event);
if (ret) {
if (permanentFreqSpinner->getCurrentValue() == "ON") {
application->bus.sendUnicastSync(std::make_shared<sys::HoldCpuFrequencyPermanentlyMessage>(
- magic_enum::enum_cast<bsp::CpuFrequencyMHz>(
- std::stoi(currentFreqSpinner->getCurrentValue()))
- .value()),
- service::name::system_manager, 5000);
+ magic_enum::enum_cast<bsp::CpuFrequencyMHz>(
+ std::stoi(currentFreqSpinner->getCurrentValue()))
+ .value()),
+ service::name::system_manager,
+ 5000);
}
else {
application->bus.sendUnicastSync(std::make_shared<sys::ReleaseCpuPermanentFrequencyMessage>(),
- service::name::system_manager, 5000);
+ service::name::system_manager,
+ 5000);
}
}
A module-bsp/board/linux/battery_charger/battery_charger.cpp => module-bsp/board/linux/battery_charger/battery_charger.cpp +16 -0
@@ 0,0 1,16 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "battery_charger/battery_charger.hpp"
+
+namespace bsp::battery_charger
+{
+ int getAvgCurrent()
+ {
+ return 0;
+ }
+ int getCurrentMeasurement()
+ {
+ return 0;
+ }
+} // namespace bsp::battery_charger
M module-bsp/board/rt1051/bellpx/bsp/lpm/PowerProfile.cpp => module-bsp/board/rt1051/bellpx/bsp/lpm/PowerProfile.cpp +1 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <bsp/lpm/PowerProfile.hpp>
@@ 15,7 15,6 @@ namespace bsp
bellPowerProfile.maxBelowThresholdInRowCount = 1;
bellPowerProfile.maxAboveThresholdCount = 2;
bellPowerProfile.minimalFrequency = CpuFrequencyMHz::Level_0;
- bellPowerProfile.frequencyIncreaseIntermediateStep = true;
return bellPowerProfile;
}
M module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp => module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp +6 -4
@@ 23,7 23,7 @@ namespace bsp
RT1051LPM::RT1051LPM()
{
- driverSEMC = drivers::DriverSEMC::Create(drivers::name::ExternalRAM);
+ driverSEMC = drivers::DriverSEMC::Create(drivers::name::ExternalRAM);
gpio_1 = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::POWER_SWITCH_HOLD_GPIO),
DriverGPIOParams{});
gpio_2 = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::DCDC_INVERTER_MODE_GPIO),
@@ 74,8 74,10 @@ namespace bsp
return 0;
}
- enum class Change {
- Up, Down
+ enum class Change
+ {
+ Up,
+ Down
};
CpuFrequencyMHz RT1051LPM::onChangeUp(CpuFrequencyMHz freq, bsp::CpuFrequencyMHz newFrequency)
@@ 123,7 125,7 @@ namespace bsp
void RT1051LPM::SetCpuFrequency(bsp::CpuFrequencyMHz freq)
{
- if ( currentFrequency == freq ) {
+ if (currentFrequency == freq) {
return;
}
Change change = currentFrequency < freq ? Change::Up : Change::Down;
M module-bsp/drivers/semc/DriverSEMC.hpp => module-bsp/drivers/semc/DriverSEMC.hpp +3 -2
@@ 8,8 8,9 @@
namespace drivers
{
- namespace name {
- constexpr auto ExternalRAM = "ExternalRAM";
+ namespace name
+ {
+ constexpr auto ExternalRAM = "ExternalRAM";
}
class DriverSEMC : public devices::Device
M module-sys/SystemManager/CpuPackPrinter.cpp => module-sys/SystemManager/CpuPackPrinter.cpp +13 -18
@@ 22,19 22,17 @@ namespace sys::cpu::stats
void PackPrinter::printSysUsage(struct task_prof_data *data, size_t size)
{
- MsgPack procEnd = MsgPack::object({{"id",uint8_t(PackID::ProcEnd)}});
+ MsgPack procEnd = MsgPack::object({{"id", uint8_t(PackID::ProcEnd)}});
vTaskSuspendAll();
{
for (size_t i = 0; i < size; ++i) {
if (data[i].exec_time == 0 && data[i].switches == 0) {
continue;
}
- MsgPack obj = MsgPack::object{
- {"name", SystemManagerCommon::ServiceProcessor(i)},
- {"tcb", uint16_t(data[i].task_TCB_id)},
- {"time", data[i].exec_time},
- {"id", uint8_t(PackID::Proc)}
- };
+ MsgPack obj = MsgPack::object{{"name", SystemManagerCommon::ServiceProcessor(i)},
+ {"tcb", uint16_t(data[i].task_TCB_id)},
+ {"time", data[i].exec_time},
+ {"id", uint8_t(PackID::Proc)}};
LOG_PRINTF("\n%c%s\n", 2, obj.dump().c_str());
}
@@ 50,21 48,18 @@ namespace sys::cpu::stats
{"name", ret.data.name},
{"reason", ret.data.reason},
{"requested", uint32_t(ret.data.frequency)},
- {"avgA" , int32_t(bsp::battery_charger::getAvgCurrent())},
- {"nowA" , int32_t(bsp::battery_charger::getCurrentMeasurement())},
- {"ts", static_cast<uint64_t>(utils::time::getCurrentTimestamp().getTime())}
- };
- LOG_PRINTF("\n%c%s\n",2, obj.dump().c_str());
+ {"avgA", int32_t(bsp::battery_charger::getAvgCurrent())},
+ {"nowA", int32_t(bsp::battery_charger::getCurrentMeasurement())},
+ {"ts", static_cast<uint64_t>(utils::time::getCurrentTimestamp().getTime())}};
+ LOG_PRINTF("\n%c%s\n", 2, obj.dump().c_str());
}
-
void PackPrinter::printPowerConsumption()
{
MsgPack obj = MsgPack::object{{"id", uint8_t(PackID::Power)},
- {"avgA" , int32_t(bsp::battery_charger::getAvgCurrent())},
- {"nowA" , int32_t(bsp::battery_charger::getCurrentMeasurement())},
- {"ts", static_cast<uint64_t>(utils::time::getCurrentTimestamp().getTime())}
- };
- LOG_PRINTF("\n%c%s\n",2, obj.dump().c_str());
+ {"avgA", int32_t(bsp::battery_charger::getAvgCurrent())},
+ {"nowA", int32_t(bsp::battery_charger::getCurrentMeasurement())},
+ {"ts", static_cast<uint64_t>(utils::time::getCurrentTimestamp().getTime())}};
+ LOG_PRINTF("\n%c%s\n", 2, obj.dump().c_str());
}
} // namespace sys::cpu::stats
M module-sys/SystemManager/CpuSentinel.cpp => module-sys/SystemManager/CpuSentinel.cpp +3 -1
@@ 3,6 3,7 @@
#include <SystemManager/CpuSentinel.hpp>
#include "system/messages/RequestCpuFrequencyMessage.hpp"
+#include "system/messages/HoldCpuFrequency.hpp"
#include "system/Constants.hpp"
#include <Timers/TimerFactory.hpp>
#include <memory>
@@ 28,7 29,8 @@ namespace sys
void CpuSentinel::HoldMinimumFrequency(bsp::CpuFrequencyMHz frequencyToHold)
{
if (currentFrequencyToHold != frequencyToHold) {
- auto msg = std::make_shared<sys::HoldCpuFrequencyMessage>(GetName(), frequencyToHold, xTaskGetCurrentTaskHandle());
+ auto msg =
+ std::make_shared<sys::HoldCpuFrequencyMessage>(GetName(), frequencyToHold, xTaskGetCurrentTaskHandle());
owner->bus.sendUnicast(std::move(msg), service::name::system_manager);
currentFrequencyToHold = frequencyToHold;
currentReason = std::string("up: ") + owner->getCurrentProcessing() + std::string(" req: ") +
M module-sys/SystemManager/CpuStatistics.cpp => module-sys/SystemManager/CpuStatistics.cpp +4 -3
@@ 21,11 21,12 @@ namespace sys
#if PROF_ON
data_size = prof_pool_get_data().size;
data = new task_prof_data[data_size];
-#endif
+ printer = std::make_unique<cpu::stats::PackPrinter>();
+#else
// to change printer change assignment
// printer = std::make_unique<cpu::stats::LogPrinter>();
- printer = std::make_unique<cpu::stats::PackPrinter>();
- // printer = std::make_unique<cpu::stats::NullPrinter>();
+ printer = std::make_unique<cpu::stats::NullPrinter>();
+#endif
}
CpuStatistics::~CpuStatistics()
M module-sys/SystemManager/PowerManager.cpp => module-sys/SystemManager/PowerManager.cpp +10 -13
@@ 39,7 39,6 @@ namespace sys
totalTicksCount += ticks;
}
-
PowerManager::PowerManager(CpuStatistics &stats) : powerProfile{bsp::getPowerProfile()}, cpuStatistics(stats)
{
driverSEMC = drivers::DriverSEMC::Create(drivers::name::ExternalRAM);
@@ 90,16 89,17 @@ namespace sys
[[nodiscard]] cpu::UpdateResult PowerManager::UpdateCpuFrequency()
{
- uint32_t cpuLoad = cpuStatistics.GetPercentageCpuLoad();
+ uint32_t cpuLoad = cpuStatistics.GetPercentageCpuLoad();
cpu::UpdateResult result;
- cpu::AlgorithmData data {cpuLoad,lowPowerControl->GetCurrentFrequencyLevel(), cpuGovernor->GetMinimumFrequencyRequested()};
+ cpu::AlgorithmData data{
+ cpuLoad, lowPowerControl->GetCurrentFrequencyLevel(), cpuGovernor->GetMinimumFrequencyRequested()};
auto _ = gsl::finally([&result, this, data] {
result.frequencySet = lowPowerControl->GetCurrentFrequencyLevel();
- result.changed = result.frequencySet > data.curentFrequency ? sys::cpu::UpdateResult::Result::UpScaled
+ result.changed = result.frequencySet > data.curentFrequency ? sys::cpu::UpdateResult::Result::UpScaled
: result.frequencySet < data.curentFrequency ? sys::cpu::UpdateResult::Result::Downscaled
- : sys::cpu::UpdateResult::Result::NoChange;
- result.data = data.sentinel;
+ : sys::cpu::UpdateResult::Result::NoChange;
+ result.data = data.sentinel;
});
auto algorithms = {
@@ 139,9 139,6 @@ namespace sys
void PowerManager::SetCpuFrequencyRequest(const std::string &sentinelName, bsp::CpuFrequencyMHz request)
{
cpuGovernor->SetCpuFrequencyRequest(sentinelName, request);
- // TODO:
- // - move other UpdateCpuFrequency usages too
- // - if it's ok to trigger algorithms on leave?
auto ret = UpdateCpuFrequency();
cpuStatistics.TrackChange(ret);
}
@@ 149,7 146,6 @@ namespace sys
void PowerManager::ResetCpuFrequencyRequest(const std::string &sentinelName)
{
cpuGovernor->ResetCpuFrequencyRequest(sentinelName);
- // TODO - same as above
auto ret = UpdateCpuFrequency();
cpuStatistics.TrackChange(ret);
}
@@ 161,7 157,8 @@ namespace sys
void PowerManager::SetPernamentFrequency(bsp::CpuFrequencyMHz freq)
{
- cpuAlgorithms->emplace(sys::cpu::AlgoID::FrequencyHold, std::make_unique<sys::cpu::FrequencyHold>(freq,powerProfile));
+ cpuAlgorithms->emplace(sys::cpu::AlgoID::FrequencyHold,
+ std::make_unique<sys::cpu::FrequencyHold>(freq, powerProfile));
}
void PowerManager::ResetPernamentFrequency()
@@ 171,8 168,8 @@ namespace sys
void PowerManager::SetCpuFrequency(bsp::CpuFrequencyMHz freq)
{
- UpdateCpuFrequencyMonitor(lowPowerControl->GetCurrentFrequencyLevel());
- while ( lowPowerControl->GetCurrentFrequencyLevel() != freq ) {
+ UpdateCpuFrequencyMonitor(lowPowerControl->GetCurrentFrequencyLevel());
+ while (lowPowerControl->GetCurrentFrequencyLevel() != freq) {
lowPowerControl->SetCpuFrequency(freq);
cpuGovernor->InformSentinelsAboutCpuFrequencyChange(freq);
}
M module-sys/SystemManager/SystemManagerCommon.cpp => module-sys/SystemManager/SystemManagerCommon.cpp +5 -5
@@ 24,6 24,7 @@
#include <system/messages/DeviceRegistrationMessage.hpp>
#include <system/messages/SentinelRegistrationMessage.hpp>
#include <system/messages/RequestCpuFrequencyMessage.hpp>
+#include <system/messages/HoldCpuFrequency.hpp>
#include <time/ScopedTime.hpp>
#include "Timers/TimerFactory.hpp"
#include <service-appmgr/StartupType.hpp>
@@ 84,7 85,8 @@ namespace sys
}
SystemManagerCommon::SystemManagerCommon(std::vector<std::unique_ptr<BaseServiceCreator>> &&creators)
- : Service(service::name::system_manager, "", systemManagerStack, ServicePriority::Low), systemServiceCreators{std::move(creators)}
+ : Service(service::name::system_manager, "", systemManagerStack, ServicePriority::Low), systemServiceCreators{
+ std::move(creators)}
{
// Specify list of channels which System Manager is registered to
bus.channels = {BusChannel::SystemManagerRequests};
@@ 190,7 192,6 @@ namespace sys
// Power off request (pending)
PowerOff();
- // TODO these were globals = never cleared, is it needed now?
powerManager.reset();
cpuStatistics.reset();
deviceManager.reset();
@@ 632,7 633,7 @@ namespace sys
connect(typeid(sys::HoldCpuFrequencyMessage), [this](sys::Message *message) -> sys::MessagePointer {
auto msg = static_cast<sys::HoldCpuFrequencyMessage *>(message);
powerManager->SetCpuFrequencyRequest(msg->getName(), msg->getRequest());
- if ( msg->getHandle() != nullptr ) {
+ if (msg->getHandle() != nullptr) {
xTaskNotifyGive(msg->getHandle());
}
return sys::MessageNone{};
@@ 688,8 689,7 @@ namespace sys
deviceManager->RegisterNewDevice(powerManager->getExternalRamDevice());
cpuSentinel = std::make_shared<sys::CpuSentinel>(
- service::name::system_manager
- , this, [this](bsp::CpuFrequencyMHz newFrequency) {
+ service::name::system_manager, this, [this](bsp::CpuFrequencyMHz newFrequency) {
UpdateResourcesAfterCpuFrequencyChange(newFrequency);
});
powerManager->RegisterNewSentinel(cpuSentinel);
M module-sys/SystemManager/cpu/AlgorithmFactory.cpp => module-sys/SystemManager/cpu/AlgorithmFactory.cpp +8 -8
@@ 5,22 5,22 @@
#include "SystemManager/cpu/algorithm/FrequencyHold.hpp"
#include <memory>
-namespace sys::cpu {
+namespace sys::cpu
+{
- AlgorithmFactory::PutResult AlgorithmFactory::emplace(sys::cpu::AlgoID id, std::unique_ptr<Algorithm>&&algorithm)
+ AlgorithmFactory::PutResult AlgorithmFactory::emplace(sys::cpu::AlgoID id, std::unique_ptr<Algorithm> &&algorithm)
{
- if ( algorithms.find(id) != std::end(algorithms)) {
+ if (algorithms.find(id) != std::end(algorithms)) {
algorithms[id] = std::move(algorithm);
- return PutResult::Replaced;
- }
+ return PutResult::Replaced;
+ }
algorithms.emplace(id, std::move(algorithm));
return PutResult::Added;
}
-
- Algorithm* AlgorithmFactory::get(sys::cpu::AlgoID id)
+ Algorithm *AlgorithmFactory::get(sys::cpu::AlgoID id)
{
- if ( auto el = algorithms.find(id); el != std::end(algorithms)) {
+ if (auto el = algorithms.find(id); el != std::end(algorithms)) {
return el->second.get();
}
return nullptr;
M module-sys/SystemManager/cpu/AlgorithmFactory.hpp => module-sys/SystemManager/cpu/AlgorithmFactory.hpp +7 -6
@@ 7,20 7,21 @@
#include <map>
#include <memory>
-
-namespace sys::cpu {
+namespace sys::cpu
+{
class AlgorithmFactory
{
std::map<sys::cpu::AlgoID, std::unique_ptr<Algorithm>> algorithms;
public:
- Algorithm* get(sys::cpu::AlgoID);
- enum class PutResult {
+ Algorithm *get(sys::cpu::AlgoID);
+ enum class PutResult
+ {
Added,
Replaced,
};
- PutResult emplace(sys::cpu::AlgoID id, std::unique_ptr<Algorithm>&&algorithm);
+ PutResult emplace(sys::cpu::AlgoID id, std::unique_ptr<Algorithm> &&algorithm);
void remove(sys::cpu::AlgoID id);
};
-};
+}; // namespace sys::cpu
M module-sys/SystemManager/cpu/algorithm/AlgorithmID.hpp => module-sys/SystemManager/cpu/algorithm/AlgorithmID.hpp +1 -1
@@ 1,7 1,7 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#pragma once
+#pragma once
namespace sys::cpu
{
M module-sys/SystemManager/cpu/algorithm/FrequencyHold.cpp => module-sys/SystemManager/cpu/algorithm/FrequencyHold.cpp +2 -2
@@ 10,8 10,8 @@ namespace sys::cpu
: toHold(toHold), profile(profile)
{}
- bsp::CpuFrequencyMHz FrequencyHold::calculateImplementation(const AlgorithmData&data)
+ bsp::CpuFrequencyMHz FrequencyHold::calculateImplementation(const AlgorithmData &data)
{
return std::max(toHold, profile.minimalFrequency);
}
-};
+}; // namespace sys::cpu
M module-sys/SystemManager/cpu/algorithm/FrequencyHold.hpp => module-sys/SystemManager/cpu/algorithm/FrequencyHold.hpp +9 -7
@@ 8,11 8,13 @@
namespace sys::cpu
{
- class FrequencyHold : public Algorithm {
- bsp::CpuFrequencyMHz toHold;
- const bsp::PowerProfile &profile;
- [[nodiscard]] bsp::CpuFrequencyMHz calculateImplementation(const AlgorithmData& data) override;
- public:
- explicit FrequencyHold(bsp::CpuFrequencyMHz toHold, const bsp::PowerProfile &profile);
+ class FrequencyHold : public Algorithm
+ {
+ bsp::CpuFrequencyMHz toHold;
+ const bsp::PowerProfile &profile;
+ [[nodiscard]] bsp::CpuFrequencyMHz calculateImplementation(const AlgorithmData &data) override;
+
+ public:
+ explicit FrequencyHold(bsp::CpuFrequencyMHz toHold, const bsp::PowerProfile &profile);
};
-}
+} // namespace sys::cpu
M module-sys/SystemManager/cpu/algorithm/FrequencyStepping.cpp => module-sys/SystemManager/cpu/algorithm/FrequencyStepping.cpp +6 -7
@@ 32,18 32,17 @@ namespace sys::cpu
return freq;
}
- bsp::CpuFrequencyMHz FrequencyStepping::calculateImplementation(const AlgorithmData&data)
+ bsp::CpuFrequencyMHz FrequencyStepping::calculateImplementation(const AlgorithmData &data)
{
- auto load = data.CPUload;
- auto startFrequency = data.curentFrequency;
- const auto min = cpuGovernor.GetMinimumFrequencyRequested();
+ const auto load = data.CPUload;
+ const auto startFrequency = data.curentFrequency;
+ const auto min = cpuGovernor.GetMinimumFrequencyRequested();
if (load > powerProfile.frequencyShiftUpperThreshold && startFrequency < bsp::CpuFrequencyMHz::Level_6) {
aboveThresholdCounter++;
belowThresholdCounter = 0;
}
- else if (load < powerProfile.frequencyShiftLowerThreshold &&
- startFrequency > powerProfile.minimalFrequency) {
+ else if (load < powerProfile.frequencyShiftLowerThreshold && startFrequency > powerProfile.minimalFrequency) {
belowThresholdCounter++;
aboveThresholdCounter = 0;
}
@@ 83,4 82,4 @@ namespace sys::cpu
aboveThresholdCounter = 0;
belowThresholdCounter = 0;
}
-}
+} // namespace sys::cpu
M module-sys/SystemManager/cpu/algorithm/FrequencyStepping.hpp => module-sys/SystemManager/cpu/algorithm/FrequencyStepping.hpp +15 -12
@@ 6,21 6,24 @@
#include "Algorithm.hpp"
#include "lpm/PowerProfile.hpp"
-namespace sys {
+namespace sys
+{
class CpuGovernor;
}
namespace sys::cpu
{
- class FrequencyStepping : public Algorithm {
- const bsp::PowerProfile &powerProfile;
- CpuGovernor &cpuGovernor;
- unsigned int aboveThresholdCounter = 0;
- unsigned int belowThresholdCounter = 0;
- bool isFrequencyLoweringInProgress = true;
- public:
- FrequencyStepping(const bsp::PowerProfile&powerProfile, CpuGovernor &cpuGovernor);
- [[nodiscard]] bsp::CpuFrequencyMHz calculateImplementation(const AlgorithmData&data) override;
- void resetImplementation() override;
+ class FrequencyStepping : public Algorithm
+ {
+ const bsp::PowerProfile &powerProfile;
+ CpuGovernor &cpuGovernor;
+ unsigned int aboveThresholdCounter = 0;
+ unsigned int belowThresholdCounter = 0;
+ bool isFrequencyLoweringInProgress = true;
+
+ public:
+ FrequencyStepping(const bsp::PowerProfile &powerProfile, CpuGovernor &cpuGovernor);
+ [[nodiscard]] bsp::CpuFrequencyMHz calculateImplementation(const AlgorithmData &data) override;
+ void resetImplementation() override;
};
-}
+} // namespace sys::cpu
M module-sys/SystemManager/cpu/algorithm/ImmediateUpscale.cpp => module-sys/SystemManager/cpu/algorithm/ImmediateUpscale.cpp +4 -4
@@ 5,10 5,10 @@
namespace sys::cpu
{
- bsp::CpuFrequencyMHz ImmediateUpscale::calculateImplementation(const AlgorithmData&data)
+ bsp::CpuFrequencyMHz ImmediateUpscale::calculateImplementation(const AlgorithmData &data)
{
- auto now = data.sentinel.frequency;
- auto was = data.curentFrequency;
- return std::max(now,was);
+ const auto now = data.sentinel.frequency;
+ const auto was = data.curentFrequency;
+ return std::max(now, was);
}
} // namespace sys::cpu
M module-sys/SystemManager/cpu/algorithm/ImmediateUpscale.hpp => module-sys/SystemManager/cpu/algorithm/ImmediateUpscale.hpp +5 -4
@@ 10,8 10,9 @@
namespace sys::cpu
{
- class ImmediateUpscale : public Algorithm {
- public:
- bsp::CpuFrequencyMHz calculateImplementation(const AlgorithmData&data) override;
+ class ImmediateUpscale : public Algorithm
+ {
+ public:
+ bsp::CpuFrequencyMHz calculateImplementation(const AlgorithmData &data) override;
};
-}
+} // namespace sys::cpu
M module-sys/SystemManager/include/SystemManager/CpuGovernor.hpp => module-sys/SystemManager/include/SystemManager/CpuGovernor.hpp +2 -4
@@ 40,10 40,8 @@ namespace sys
[[nodiscard]] auto GetNumberOfRegisteredSentinels() const noexcept -> uint32_t;
void PrintAllSentinels() const noexcept;
- void SetCpuFrequencyRequest(const std::string& sentinelName,
- bsp::CpuFrequencyMHz request
- );
- void ResetCpuFrequencyRequest(const std::string& sentinelName);
+ void SetCpuFrequencyRequest(const std::string &sentinelName, bsp::CpuFrequencyMHz request);
+ void ResetCpuFrequencyRequest(const std::string &sentinelName);
[[nodiscard]] auto GetMinimumFrequencyRequested() const noexcept -> sentinel::View;
void InformSentinelsAboutCpuFrequencyChange(bsp::CpuFrequencyMHz newFrequency) const noexcept;
M module-sys/SystemManager/include/SystemManager/CpuPrinter.hpp => module-sys/SystemManager/include/SystemManager/CpuPrinter.hpp +3 -2
@@ 17,7 17,7 @@ namespace sys::cpu
public:
virtual void printSysUsage(struct task_prof_data *data, size_t size) = 0;
virtual void printCPUChange(const cpu::UpdateResult &ret) = 0;
- virtual void printPowerConsumption() = 0;
+ virtual void printPowerConsumption() = 0;
};
class NullPrinter : public Printer
@@ 26,7 26,8 @@ namespace sys::cpu
{}
void printCPUChange(const cpu::UpdateResult &ret)
{}
- void printPowerConsumption() {}
+ void printPowerConsumption()
+ {}
};
class LogPrinter : public Printer
M module-sys/SystemManager/include/SystemManager/CpuSentinel.hpp => module-sys/SystemManager/include/SystemManager/CpuSentinel.hpp +0 -2
@@ 29,8 29,6 @@ namespace sys
void HoldMinimumFrequency(bsp::CpuFrequencyMHz frequencyToHold);
void ReleaseMinimumFrequency();
- // TODO actually sentinel provides api here so i.e. in case of irq is useless
- void HoldFrequencyPermanently(bsp::CpuFrequencyMHz frequencyToHold);
[[nodiscard]] auto GetFrequency() const noexcept -> bsp::CpuFrequencyMHz;
void CpuFrequencyHasChanged(bsp::CpuFrequencyMHz newFrequency);
M module-sys/SystemManager/include/SystemManager/PowerManager.hpp => module-sys/SystemManager/include/SystemManager/PowerManager.hpp +2 -2
@@ 39,7 39,7 @@ namespace sys
class PowerManager
{
public:
- explicit PowerManager(CpuStatistics& stats);
+ explicit PowerManager(CpuStatistics &stats);
~PowerManager();
int32_t PowerOff();
@@ 84,7 84,7 @@ namespace sys
const bsp::PowerProfile powerProfile;
std::unique_ptr<sys::cpu::AlgorithmFactory> cpuAlgorithms;
- CpuStatistics& cpuStatistics;
+ CpuStatistics &cpuStatistics;
};
} // namespace sys
M module-sys/SystemManager/include/SystemManager/SentinelView.hpp => module-sys/SystemManager/include/SystemManager/SentinelView.hpp +1 -2
@@ 24,5 24,4 @@ namespace sys
std::string reason;
};
}; // namespace sentinel
-}
-
+} // namespace sys
M module-sys/SystemManager/include/SystemManager/SysCpuUpdateResult.hpp => module-sys/SystemManager/include/SystemManager/SysCpuUpdateResult.hpp +3 -2
@@ 10,12 10,13 @@ namespace sys::cpu
{
struct UpdateResult
{
- enum class Result {
+ enum class Result
+ {
UpScaled, /// frequency risen
Downscaled, /// frequency downscaled
NoChange /// nothing to do
};
- Result changed = Result::NoChange;
+ Result changed = Result::NoChange;
bsp::CpuFrequencyMHz frequencySet = bsp::CpuFrequencyMHz::Level_0;
sentinel::View data{};
AlgoID id = AlgoID::None;
A module-sys/common/include/system/messages/HoldCpuFrequency.hpp => module-sys/common/include/system/messages/HoldCpuFrequency.hpp +55 -0
@@ 0,0 1,55 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include <Service/Message.hpp>
+#include <bsp/common.hpp>
+
+namespace sys
+{
+ class HoldCpuFrequencyMessage : public sys::DataMessage
+ {
+ public:
+ HoldCpuFrequencyMessage(std::string sentinelName, bsp::CpuFrequencyMHz request, TaskHandle_t handle)
+ : sys::DataMessage(MessageType::SystemManagerCpuFrequency), sentinelName(std::move(sentinelName)),
+ frequencyRequested(request), handle(handle)
+ {}
+
+ [[nodiscard]] auto getRequest() const noexcept
+ {
+ return frequencyRequested;
+ };
+
+ [[nodiscard]] auto getName() const
+ {
+ return sentinelName;
+ };
+
+ [[nodiscard]] TaskHandle_t getHandle() const
+ {
+ return handle;
+ }
+
+ private:
+ std::string sentinelName;
+ bsp::CpuFrequencyMHz frequencyRequested = bsp::CpuFrequencyMHz::Level_0;
+ TaskHandle_t handle;
+ };
+
+ class ReleaseCpuFrequencyMessage : public sys::DataMessage
+ {
+ public:
+ explicit ReleaseCpuFrequencyMessage(std::string sentinelName)
+ : sys::DataMessage(MessageType::SystemManagerCpuFrequency), sentinelName(std::move(sentinelName))
+ {}
+
+ [[nodiscard]] auto getName() const
+ {
+ return sentinelName;
+ };
+
+ private:
+ std::string sentinelName;
+ };
+} // namespace sys
M module-sys/common/include/system/messages/RequestCpuFrequencyMessage.hpp => module-sys/common/include/system/messages/RequestCpuFrequencyMessage.hpp +1 -51
@@ 3,64 3,16 @@
#pragma once
-#include "FreeRTOS.h"
-#include "task.h"
#include <Service/Message.hpp>
#include <bsp/common.hpp>
namespace sys
{
- /// TODO move data to struct...
- class HoldCpuFrequencyMessage : public sys::DataMessage
- {
- public:
- HoldCpuFrequencyMessage(std::string sentinelName, bsp::CpuFrequencyMHz request, TaskHandle_t handle)
- : sys::DataMessage(MessageType::SystemManagerCpuFrequency), sentinelName(std::move(sentinelName)),
- frequencyRequested(request), handle(handle)
- {}
-
- [[nodiscard]] auto getRequest() const noexcept
- {
- return frequencyRequested;
- };
-
- [[nodiscard]] auto getName() const
- {
- return sentinelName;
- };
-
- [[nodiscard]] TaskHandle_t getHandle() const
- {
- return handle;
- }
-
- private:
- std::string sentinelName;
- bsp::CpuFrequencyMHz frequencyRequested = bsp::CpuFrequencyMHz::Level_0;
- TaskHandle_t handle;
- };
-
- class ReleaseCpuFrequencyMessage : public sys::DataMessage
- {
- public:
- explicit ReleaseCpuFrequencyMessage(std::string sentinelName)
- : sys::DataMessage(MessageType::SystemManagerCpuFrequency), sentinelName(std::move(sentinelName))
- {}
-
- [[nodiscard]] auto getName() const
- {
- return sentinelName;
- };
-
- private:
- std::string sentinelName;
- };
-
struct IsCpuPernament : public sys::DataMessage
{
public:
- explicit IsCpuPernament()
+ explicit IsCpuPernament()
{}
};
@@ 72,8 24,6 @@ namespace sys
const bool pernament = false;
};
-
-
struct HoldCpuFrequencyPermanentlyMessage : public sys::DataMessage
{
public: