/*
* Copyright (c) Souldbminer, Lightos and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#include
#include
#include "actmon.hpp"
#include "bpmp_mmu.hpp"
#include "freq.hpp"
#include "libc_platform.hpp"
#include "regs.hpp"
#include "sensors.hpp"
#include
namespace {
HocClkBpmpSharedInfo &SharedInfo() {
return *reinterpret_cast(WorkRamStart);
}
} // namespace
void MainLoop(HocClkBpmpSharedInfo &info) {
for (;;) {
if (info.exitRequested) {
break;
}
const u32 temp1 = MMIO32(SocthermBase + SocthermSensorTemp1);
const u32 temp2 = MMIO32(SocthermBase + SocthermSensorTemp2);
info.tempCpu = TranslateSocthermTemp(static_cast(temp1 >> 16));
info.tempGpu = TranslateSocthermTemp(static_cast(temp1));
info.tempMem = TranslateSocthermTemp(static_cast(temp2 >> 16));
info.tempPllx = TranslateSocthermTemp(static_cast(temp2));
freq::Update(info);
actmon::Update(info);
msleep(250);
}
/* Deinit MMU otherwise sleep will fatal. */
bpmpMmu::Disable();
info.magic = 0x0;
for (;;)
;
}
extern "C" void main() {
bpmpMmu::Enable();
InitializeLibc();
printf("[hoc-bpmpfw]: Starting bpmpfw\n");
HocClkBpmpSharedInfo &info = SharedInfo();
memset(&info, 0, sizeof(info));
info.status = 0;
actmon::Init();
info.magic = HOCCLK_BPMP_MAGIC; // written last
/* If the main loop exits then it is a panic or invalid state */
MainLoop(info);
printf("[hoc-bpmpfw]: PANIC\n");
/* Clear the magic so sysmodule knows of a panic */
info.magic = 0x0;
/* Give a panic code */
info.status = ~0;
for(;;)
;
}