fix namespace overusage
This commit is contained in:
1 parent
1741e27116
commit
8fc18ee3e8
41 files changed
+438
-440
No files matched your search
@@ -192,7 +192,7 @@ namespace board {
|
|||||||
|
|
||||||
Result bpmpfwRc = bpmp::StartBpmfwExecution();
|
Result bpmpfwRc = bpmp::StartBpmfwExecution();
|
||||||
if (R_FAILED(bpmpfwRc)) {
|
if (R_FAILED(bpmpfwRc)) {
|
||||||
fileUtils::LogLine("[bpmp] StartBpmfwExecution failed: 0x%x", bpmpfwRc);
|
file::utils::LogLine("[bpmp] StartBpmfwExecution failed: 0x%x", bpmpfwRc);
|
||||||
}
|
}
|
||||||
bpmp::StartSleepMonitorThread();
|
bpmp::StartSleepMonitorThread();
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ namespace board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define MMIO32(addr) (*reinterpret_cast<volatile u32 *>(addr))
|
#define MMIO32(addr) (*reinterpret_cast<volatile u32 *>(addr))
|
||||||
NX_NORETURN void panic(u32 c) {
|
NX_NORETURN void Panic(u32 c) {
|
||||||
SmcReadWriteRegister(0x7000EC40 /* PMC_BASE + APBDEV_PMC_SCRATCH200 */, ~0, c);
|
SmcReadWriteRegister(0x7000EC40 /* PMC_BASE + APBDEV_PMC_SCRATCH200 */, ~0, c);
|
||||||
|
|
||||||
/* Write timer magic */
|
/* Write timer magic */
|
||||||
@@ -287,7 +287,7 @@ namespace board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u8 GetDramID() {
|
u8 GetDramID() {
|
||||||
return soc::mrr::IdentifyDramId();
|
return soc::IdentifyDramId();
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 GetFuseDramId() {
|
u8 GetFuseDramId() {
|
||||||
@@ -301,7 +301,7 @@ namespace board {
|
|||||||
svcCallSecureMonitor(&args);
|
svcCallSecureMonitor(&args);
|
||||||
|
|
||||||
if (args.X[1] == (MC_REGISTER_BASE + MC_EMEM_CFG_0)) { // if param 1 is identical read failed
|
if (args.X[1] == (MC_REGISTER_BASE + MC_EMEM_CFG_0)) { // if param 1 is identical read failed
|
||||||
notification::writeNotification("Horizon OC\nSecmon read failed!\n This may be a hardware issue!");
|
hos::WriteNotification("Horizon OC\nSecmon read failed!\n This may be a hardware issue!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,6 @@ namespace board {
|
|||||||
bool IsDram8GB();
|
bool IsDram8GB();
|
||||||
void SetDisplayRefreshDockedState(bool docked);
|
void SetDisplayRefreshDockedState(bool docked);
|
||||||
FuseData *GetFuseData();
|
FuseData *GetFuseData();
|
||||||
NX_NORETURN void panic(u32 c);
|
NX_NORETURN void Panic(u32 c);
|
||||||
|
|
||||||
} // namespace board
|
} // namespace board
|
||||||
@@ -82,10 +82,10 @@ namespace board {
|
|||||||
|
|
||||||
void HandleCpuUv() {
|
void HandleCpuUv() {
|
||||||
if (board::GetSocType() == HocClkSocType_Erista)
|
if (board::GetSocType() == HocClkSocType_Erista)
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); // Erista tbreak is always 1581MHz
|
board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); // Erista tbreak is always 1581MHz
|
||||||
else
|
else
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow), file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
||||||
board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
board::CalculateTbreak(file::config::GetConfigValue(KipConfigValue_tableConf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHz(HocClkModule module, u32 hz) {
|
void SetHz(HocClkModule module, u32 hz) {
|
||||||
@@ -130,11 +130,11 @@ namespace board {
|
|||||||
PcvSetHz(GetPcvModule(module), pcvHz);
|
PcvSetHz(GetPcvModule(module), pcvHz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv) && module == HocClkModule_CPU) {
|
if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv) && module == HocClkModule_CPU) {
|
||||||
HandleCpuUv();
|
HandleCpuUv();
|
||||||
}
|
}
|
||||||
if (useGm20b) {
|
if (useGm20b) {
|
||||||
if (gm20b::setClock(hz / 1000)) {
|
if (soc::SetClock(hz / 1000)) {
|
||||||
currentInjectedHz = hz;
|
currentInjectedHz = hz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace board {
|
|||||||
|
|
||||||
s32 PollDramMr4TempMilli() {
|
s32 PollDramMr4TempMilli() {
|
||||||
u8 mr4 = 0;
|
u8 mr4 = 0;
|
||||||
if (!soc::mrr::ReadRamMr4(&mr4))
|
if (!soc::ReadRamMr4(&mr4))
|
||||||
return 0; /* stock exosphere */
|
return 0; /* stock exosphere */
|
||||||
|
|
||||||
/* TODO: verify this table manually*/
|
/* TODO: verify this table manually*/
|
||||||
@@ -132,7 +132,7 @@ namespace board {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HocClkThermalSensor_BQ24193: {
|
case HocClkThermalSensor_BQ24193: {
|
||||||
millis = bq24193::getBQTemp();
|
millis = tsensor::GetBqTemp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HocClkThermalSensor_AO: {
|
case HocClkThermalSensor_AO: {
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ namespace board {
|
|||||||
|
|
||||||
bool ValidateHandle(Handle handle) {
|
bool ValidateHandle(Handle handle) {
|
||||||
if (handle == INVALID_HANDLE) {
|
if (handle == INVALID_HANDLE) {
|
||||||
fileUtils::LogLine("Invalid handle!");
|
file::utils::LogLine("Invalid handle!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ namespace board {
|
|||||||
|
|
||||||
if (R_FAILED(resultProcessMemory) || !address) {
|
if (R_FAILED(resultProcessMemory) || !address) {
|
||||||
svcCloseHandle(handle);
|
svcCloseHandle(handle);
|
||||||
fileUtils::LogLine("[dvfs] Failed to get process data. %u", R_DESCRIPTION(resultProcessMemory));
|
file::utils::LogLine("[dvfs] Failed to get process data. %u", R_DESCRIPTION(resultProcessMemory));
|
||||||
handle = INVALID_HANDLE;
|
handle = INVALID_HANDLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -359,11 +359,11 @@ namespace board {
|
|||||||
|
|
||||||
// Print info AFTER we exit the handle to avoid hangs
|
// Print info AFTER we exit the handle to avoid hangs
|
||||||
for (int i = 0; i < (int)std::size(cpuVoltTable); ++i) {
|
for (int i = 0; i < (int)std::size(cpuVoltTable); ++i) {
|
||||||
fileUtils::LogLine("[dvfs] cpu volt %d: %u mV", i, cpuVoltTable[i]);
|
file::utils::LogLine("[dvfs] cpu volt %d: %u mV", i, cpuVoltTable[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)std::size(voltData.voltTableStock); ++i) {
|
for (int i = 0; i < (int)std::size(voltData.voltTableStock); ++i) {
|
||||||
fileUtils::LogLine("[dvfs] gpu volt %d: %u mV", i, voltData.voltTableStock[0][i]);
|
file::utils::LogLine("[dvfs] gpu volt %d: %u mV", i, voltData.voltTableStock[0][i]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ namespace board {
|
|||||||
|
|
||||||
ASSERT_RESULT_OK(WriteGpuVoltTable(table), "WriteGpuVoltTable");
|
ASSERT_RESULT_OK(WriteGpuVoltTable(table), "WriteGpuVoltTable");
|
||||||
voltData.ramVmin = vmin;
|
voltData.ramVmin = vmin;
|
||||||
fileUtils::LogLine("[dvfs] voltage set to %u mV", vmin);
|
file::utils::LogLine("[dvfs] voltage set to %u mV", vmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetGpuFreqIndex(u32 hz) {
|
u32 GetGpuFreqIndex(u32 hz) {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace bpmp {
|
|||||||
const u32 cmd = HocClkBpmpCmd_RequestShutdown;
|
const u32 cmd = HocClkBpmpCmd_RequestShutdown;
|
||||||
Result rc = SmcCopyToIram(WorkRamPhysBase + offsetof(HocClkBpmpSharedInfo, cmd), &cmd, sizeof(cmd));
|
Result rc = SmcCopyToIram(WorkRamPhysBase + offsetof(HocClkBpmpSharedInfo, cmd), &cmd, sizeof(cmd));
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fileUtils::LogLine("[bpmp] RequestBpmpExitAndWait: SmcCopyToIram failed: 0x%x", rc);
|
file::utils::LogLine("[bpmp] RequestBpmpExitAndWait: SmcCopyToIram failed: 0x%x", rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +145,8 @@ namespace bpmp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[bpmp] RequestBpmpExitAndWait: BPMP timeout (cannot sleep)");
|
file::utils::LogLine("[bpmp] RequestBpmpExitAndWait: BPMP timeout (cannot sleep)");
|
||||||
board::panic(board::CpuPanic);
|
board::Panic(board::CpuPanic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnableBpmpSmmu() {
|
void EnableBpmpSmmu() {
|
||||||
@@ -200,7 +200,7 @@ namespace bpmp {
|
|||||||
|
|
||||||
void SendBpmpCommand(HocClkBpmpCmd cmd, u32 arg1 = 0, u32 arg2 = 0, u32 arg3 = 0, u32 arg4 = 0) {
|
void SendBpmpCommand(HocClkBpmpCmd cmd, u32 arg1 = 0, u32 arg2 = 0, u32 arg3 = 0, u32 arg4 = 0) {
|
||||||
if (!WaitForBpmpReady()) {
|
if (!WaitForBpmpReady()) {
|
||||||
fileUtils::LogLine("[bpmp] SendBpmpCommand: BPMP never signaled ready (cmd=%u)", static_cast<u32>(cmd));
|
file::utils::LogLine("[bpmp] SendBpmpCommand: BPMP never signaled ready (cmd=%u)", static_cast<u32>(cmd));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ namespace bpmp {
|
|||||||
|
|
||||||
const Result rc = SmcCopyToIram(WorkRamPhysBase + offsetof(HocClkBpmpSharedInfo, cmd), &req, sizeof(req));
|
const Result rc = SmcCopyToIram(WorkRamPhysBase + offsetof(HocClkBpmpSharedInfo, cmd), &req, sizeof(req));
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fileUtils::LogLine("[bpmp] SendBpmpCommand: SmcCopyToIram failed: 0x%x (cmd=%u)", rc, static_cast<u32>(cmd));
|
file::utils::LogLine("[bpmp] SendBpmpCommand: SmcCopyToIram failed: 0x%x (cmd=%u)", rc, static_cast<u32>(cmd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ namespace bpmp {
|
|||||||
|
|
||||||
Result wrc = StartBpmfwExecution();
|
Result wrc = StartBpmfwExecution();
|
||||||
if (R_FAILED(wrc)) {
|
if (R_FAILED(wrc)) {
|
||||||
fileUtils::LogLine("[bpmp] restart after wake failed: 0x%x", wrc);
|
file::utils::LogLine("[bpmp] restart after wake failed: 0x%x", wrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_isAwake = true;
|
s_isAwake = true;
|
||||||
@@ -279,19 +279,19 @@ namespace bpmp {
|
|||||||
|
|
||||||
Result StartBpmfwExecution() {
|
Result StartBpmfwExecution() {
|
||||||
if (!IsPatchedExosphere()) {
|
if (!IsPatchedExosphere()) {
|
||||||
fileUtils::LogLine("[bpmp] Cannot start without patched exosphere");
|
file::utils::LogLine("[bpmp] Cannot start without patched exosphere");
|
||||||
return (Result)1;
|
return (Result)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t fw_size = bpmpfw_bin_size;
|
const size_t fw_size = bpmpfw_bin_size;
|
||||||
if (fw_size == 0 || fw_size > FwStagingSize) {
|
if (fw_size == 0 || fw_size > FwStagingSize) {
|
||||||
fileUtils::LogLine("[bpmp] StartBpmfwExecution: bpmpfw of %zu bytes is invalid (should not happen)!", fw_size);
|
file::utils::LogLine("[bpmp] StartBpmfwExecution: bpmpfw of %zu bytes is invalid (should not happen)!", fw_size);
|
||||||
return (Result)1;
|
return (Result)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memcpy(s_fwStageBuf, bpmpfw_bin, fw_size);
|
std::memcpy(s_fwStageBuf, bpmpfw_bin, fw_size);
|
||||||
|
|
||||||
fileUtils::LogLine("[bpmp] StartBpmfwExecution: loading %zu bytes at 0x%llx",
|
file::utils::LogLine("[bpmp] StartBpmfwExecution: loading %zu bytes at 0x%llx",
|
||||||
fw_size, static_cast<unsigned long long>(FwIramPhysBase));
|
fw_size, static_cast<unsigned long long>(FwIramPhysBase));
|
||||||
|
|
||||||
/* Disable the SMMU so DRAM can be accessed */
|
/* Disable the SMMU so DRAM can be accessed */
|
||||||
@@ -329,7 +329,7 @@ namespace bpmp {
|
|||||||
|
|
||||||
Result copy_rc = SmcCopyToIram(FwIramPhysBase + ofs, s_fwStageBuf + ofs, static_cast<u32>(chunk));
|
Result copy_rc = SmcCopyToIram(FwIramPhysBase + ofs, s_fwStageBuf + ofs, static_cast<u32>(chunk));
|
||||||
if (R_FAILED(copy_rc)) {
|
if (R_FAILED(copy_rc)) {
|
||||||
fileUtils::LogLine("[bpmp] SmcCopyToIram failed at +0x%zx: 0x%x", ofs, copy_rc);
|
file::utils::LogLine("[bpmp] SmcCopyToIram failed at +0x%zx: 0x%x", ofs, copy_rc);
|
||||||
return copy_rc;
|
return copy_rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,26 +340,26 @@ namespace bpmp {
|
|||||||
/* Clear the halt written by bootloader. */
|
/* Clear the halt written by bootloader. */
|
||||||
SmcReadWriteRegister(FlowCtlrPhysBase + FlowCtlrHaltCopEvents, 0xFFFFFFFF, FlowModeNone);
|
SmcReadWriteRegister(FlowCtlrPhysBase + FlowCtlrHaltCopEvents, 0xFFFFFFFF, FlowModeNone);
|
||||||
|
|
||||||
SendBpmpCommand(HocClkBpmpCmd_SetUartEnabled, fileUtils::IsUartEnabled() ? 1u : 0u);
|
SendBpmpCommand(HocClkBpmpCmd_SetUartEnabled, file::utils::IsUartEnabled() ? 1u : 0u);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartSleepMonitorThread() {
|
void StartSleepMonitorThread() {
|
||||||
if (!IsPatchedExosphere()) {
|
if (!IsPatchedExosphere()) {
|
||||||
fileUtils::LogLine("[bpmp] Cant start BPMP without exosphere patch");
|
file::utils::LogLine("[bpmp] Cant start BPMP without exosphere patch");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rc = pscmInitialize();
|
Result rc = pscmInitialize();
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fileUtils::LogLine("[bpmp] pscmInitialize failed: 0x%x", rc);
|
file::utils::LogLine("[bpmp] pscmInitialize failed: 0x%x", rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = pscmGetPmModule(&s_pscModule, PscModuleId, pscDependencies, sizeof(pscDependencies) / sizeof(u32), true);
|
rc = pscmGetPmModule(&s_pscModule, PscModuleId, pscDependencies, sizeof(pscDependencies) / sizeof(u32), true);
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fileUtils::LogLine("[bpmp] pscmGetPmModule failed: 0x%x", rc);
|
file::utils::LogLine("[bpmp] pscmGetPmModule failed: 0x%x", rc);
|
||||||
pscmExit();
|
pscmExit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -367,7 +367,7 @@ namespace bpmp {
|
|||||||
|
|
||||||
rc = threadCreate(&s_pscThread, PscThreadFunc, nullptr, NULL, 0x1000, 0x10, 3);
|
rc = threadCreate(&s_pscThread, PscThreadFunc, nullptr, NULL, 0x1000, 0x10, 3);
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fileUtils::LogLine("[bpmp] failed to create psc thread: 0x%x", rc);
|
file::utils::LogLine("[bpmp] failed to create psc thread: 0x%x", rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
threadStart(&s_pscThread);
|
threadStart(&s_pscThread);
|
||||||
|
|||||||
@@ -22,11 +22,9 @@
|
|||||||
|
|
||||||
// I *think* HOS changes this in some ways, so look into it more
|
// I *think* HOS changes this in some ways, so look into it more
|
||||||
|
|
||||||
namespace AulaDisplay {
|
namespace display {
|
||||||
#define MMIO_REG32(base, off) *(vu32 *)((base) + (off))
|
#define MMIO_REG32(base, off) *(vu32 *)((base) + (off))
|
||||||
#define DSI(off) MMIO_REG32(board::dsiVirtAddr, (off) << 2u)
|
#define DSI(off) MMIO_REG32(board::dsiVirtAddr, (off) << 2u)
|
||||||
#define DSI_WR_DATA 0xA
|
|
||||||
#define DSI_TRIGGER 0x13
|
|
||||||
|
|
||||||
void _display_dsi_send_cmd(u8 cmd, u32 param, u32 wait) {
|
void _display_dsi_send_cmd(u8 cmd, u32 param, u32 wait) {
|
||||||
DSI(DSI_WR_DATA) = (param << 8) | cmd;
|
DSI(DSI_WR_DATA) = (param << 8) | cmd;
|
||||||
@@ -43,4 +41,4 @@ namespace AulaDisplay {
|
|||||||
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM, MIPI_DCS_PRIV_SM_SET_COLOR_MODE | (mode << 8), 0);
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM, MIPI_DCS_PRIV_SM_SET_COLOR_MODE | (mode << 8), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace AulaDisplay
|
} // namespace display
|
||||||
@@ -18,6 +18,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../board/board.hpp"
|
#include "../board/board.hpp"
|
||||||
|
|
||||||
namespace AulaDisplay {
|
namespace display {
|
||||||
void SetDisplayColorMode(AulaColorMode mode);
|
void SetDisplayColorMode(AulaColorMode mode);
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
namespace config {
|
namespace file::config {
|
||||||
|
|
||||||
uint64_t configValues[HocClkConfigValue_EnumMax];
|
uint64_t configValues[HocClkConfigValue_EnumMax];
|
||||||
|
|
||||||
@@ -122,14 +122,14 @@ namespace config {
|
|||||||
std::uint64_t input = strtoul(value, NULL, 0);
|
std::uint64_t input = strtoul(value, NULL, 0);
|
||||||
if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) {
|
if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) {
|
||||||
input = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
input = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
||||||
fileUtils::LogLine("[cfg] Invalid value for key '%s': using default %llu", key, input);
|
file::utils::LogLine("[cfg] Invalid value for key '%s': using default %llu", key, input);
|
||||||
}
|
}
|
||||||
configValues[kval] = input;
|
configValues[kval] = input;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] Skipping key '%s' in settings: Unrecognized config value", key);
|
file::utils::LogLine("[cfg] Skipping key '%s' in settings: Unrecognized config value", key);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,14 +147,14 @@ namespace config {
|
|||||||
std::uint64_t input = strtoul(value, NULL, 0);
|
std::uint64_t input = strtoul(value, NULL, 0);
|
||||||
if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) {
|
if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) {
|
||||||
input = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
input = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
||||||
fileUtils::LogLine("[cfg] Invalid value for key '%s': using default %llu", key, input);
|
file::utils::LogLine("[cfg] Invalid value for key '%s': using default %llu", key, input);
|
||||||
}
|
}
|
||||||
configValues[kval] = input;
|
configValues[kval] = input;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] Skipping key '%s' in kip: Unrecognized config value", key);
|
file::utils::LogLine("[cfg] Skipping key '%s' in kip: Unrecognized config value", key);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,26 +216,26 @@ namespace config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadSettings() {
|
void LoadSettings() {
|
||||||
fileUtils::LogLine("[cfg] Reading %s", gSettingsPath.c_str());
|
file::utils::LogLine("[cfg] Reading %s", gSettingsPath.c_str());
|
||||||
gSettingsMtime = CheckFileMtime(gSettingsPath.c_str());
|
gSettingsMtime = CheckFileMtime(gSettingsPath.c_str());
|
||||||
if (!gSettingsMtime) {
|
if (!gSettingsMtime) {
|
||||||
fileUtils::LogLine("[cfg] Settings file not found, using defaults");
|
file::utils::LogLine("[cfg] Settings file not found, using defaults");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ini_browse(&BrowseSettingsIni, nullptr, gSettingsPath.c_str())) {
|
if (!ini_browse(&BrowseSettingsIni, nullptr, gSettingsPath.c_str())) {
|
||||||
fileUtils::LogLine("[cfg] Error loading settings file");
|
file::utils::LogLine("[cfg] Error loading settings file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadKip() {
|
void LoadKip() {
|
||||||
fileUtils::LogLine("[cfg] Reading %s", gKipPath.c_str());
|
file::utils::LogLine("[cfg] Reading %s", gKipPath.c_str());
|
||||||
gKipMtime = CheckFileMtime(gKipPath.c_str());
|
gKipMtime = CheckFileMtime(gKipPath.c_str());
|
||||||
if (!gKipMtime) {
|
if (!gKipMtime) {
|
||||||
fileUtils::LogLine("[cfg] KIP config file not found, using defaults");
|
file::utils::LogLine("[cfg] KIP config file not found, using defaults");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ini_browse(&BrowseKipIni, nullptr, gKipPath.c_str())) {
|
if (!ini_browse(&BrowseKipIni, nullptr, gKipPath.c_str())) {
|
||||||
fileUtils::LogLine("[cfg] Error loading KIP config file");
|
file::utils::LogLine("[cfg] Error loading KIP config file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ namespace config {
|
|||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(path, &st) == 0) {
|
if (stat(path, &st) == 0) {
|
||||||
fileUtils::LogLine("[cfg] Loading profile %s", path);
|
file::utils::LogLine("[cfg] Loading profile %s", path);
|
||||||
ini_browse(&BrowseProfileIni, (void *)(uintptr_t)tid, path);
|
ini_browse(&BrowseProfileIni, (void *)(uintptr_t)tid, path);
|
||||||
gProfileMtimes[tid] = st.st_mtime;
|
gProfileMtimes[tid] = st.st_mtime;
|
||||||
} else {
|
} else {
|
||||||
@@ -341,7 +341,7 @@ namespace config {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileUtils::LogLine("[cfg] Skipping unrecognized key '%s'", key);
|
file::utils::LogLine("[cfg] Skipping unrecognized key '%s'", key);
|
||||||
} else {
|
} else {
|
||||||
std::uint64_t tid = strtoul(section, NULL, 16);
|
std::uint64_t tid = strtoul(section, NULL, 16);
|
||||||
if (tid && strlen(section) == 16) {
|
if (tid && strlen(section) == 16) {
|
||||||
@@ -357,28 +357,28 @@ namespace config {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] Migrating legacy config.ini");
|
file::utils::LogLine("[cfg] Migrating legacy config.ini");
|
||||||
fileUtils::LogLine("[cfg] Legacy path: %s", gLegacyPath.c_str());
|
file::utils::LogLine("[cfg] Legacy path: %s", gLegacyPath.c_str());
|
||||||
fileUtils::LogLine("[cfg] Settings path: %s", gSettingsPath.c_str());
|
file::utils::LogLine("[cfg] Settings path: %s", gSettingsPath.c_str());
|
||||||
fileUtils::LogLine("[cfg] Profiles dir: %s", gProfilesDir.c_str());
|
file::utils::LogLine("[cfg] Profiles dir: %s", gProfilesDir.c_str());
|
||||||
|
|
||||||
MigrationData data;
|
MigrationData data;
|
||||||
fileUtils::LogLine("[cfg] Parsing legacy config.ini...");
|
file::utils::LogLine("[cfg] Parsing legacy config.ini...");
|
||||||
ini_browse(&MigrationBrowseFunc, &data, gLegacyPath.c_str());
|
ini_browse(&MigrationBrowseFunc, &data, gLegacyPath.c_str());
|
||||||
fileUtils::LogLine("[cfg] Found %zu settings keys, %zu KIP keys, %zu profile entries",
|
file::utils::LogLine("[cfg] Found %zu settings keys, %zu KIP keys, %zu profile entries",
|
||||||
data.settingsKeys.size(), data.kipKeys.size(), data.profileEntries.size());
|
data.settingsKeys.size(), data.kipKeys.size(), data.profileEntries.size());
|
||||||
|
|
||||||
if (!data.settingsKeys.empty()) {
|
if (!data.settingsKeys.empty()) {
|
||||||
fileUtils::LogLine("[cfg] Creating kip directory: %s", FILE_KIP_DIR);
|
file::utils::LogLine("[cfg] Creating kip directory: %s", FILE_KIP_DIR);
|
||||||
mkdir(FILE_KIP_DIR, 0777);
|
mkdir(FILE_KIP_DIR, 0777);
|
||||||
fileUtils::LogLine("[cfg] Writing %zu settings to %s", data.settingsKeys.size(), gSettingsPath.c_str());
|
file::utils::LogLine("[cfg] Writing %zu settings to %s", data.settingsKeys.size(), gSettingsPath.c_str());
|
||||||
|
|
||||||
std::vector<std::string> sKeys;
|
std::vector<std::string> sKeys;
|
||||||
std::vector<std::string> sVals;
|
std::vector<std::string> sVals;
|
||||||
sKeys.reserve(data.settingsKeys.size());
|
sKeys.reserve(data.settingsKeys.size());
|
||||||
sVals.reserve(data.settingsKeys.size());
|
sVals.reserve(data.settingsKeys.size());
|
||||||
for (const auto &entry : data.settingsKeys) {
|
for (const auto &entry : data.settingsKeys) {
|
||||||
fileUtils::LogLine("[cfg] %s = %s", entry.first.c_str(), entry.second.c_str());
|
file::utils::LogLine("[cfg] %s = %s", entry.first.c_str(), entry.second.c_str());
|
||||||
sKeys.push_back(entry.first);
|
sKeys.push_back(entry.first);
|
||||||
sVals.push_back(entry.second);
|
sVals.push_back(entry.second);
|
||||||
}
|
}
|
||||||
@@ -395,23 +395,23 @@ namespace config {
|
|||||||
valPtrs.push_back(NULL);
|
valPtrs.push_back(NULL);
|
||||||
|
|
||||||
if (!ini_putsection(CONFIG_VAL_SECTION, keyPtrs.data(), valPtrs.data(), gSettingsPath.c_str())) {
|
if (!ini_putsection(CONFIG_VAL_SECTION, keyPtrs.data(), valPtrs.data(), gSettingsPath.c_str())) {
|
||||||
fileUtils::LogLine("[cfg] FAILED to write settings section");
|
file::utils::LogLine("[cfg] FAILED to write settings section");
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[cfg] Settings migration done");
|
file::utils::LogLine("[cfg] Settings migration done");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[cfg] No settings keys to migrate");
|
file::utils::LogLine("[cfg] No settings keys to migrate");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.kipKeys.empty()) {
|
if (!data.kipKeys.empty()) {
|
||||||
fileUtils::LogLine("[cfg] Writing %zu KIP keys to %s", data.kipKeys.size(), gKipPath.c_str());
|
file::utils::LogLine("[cfg] Writing %zu KIP keys to %s", data.kipKeys.size(), gKipPath.c_str());
|
||||||
|
|
||||||
std::vector<std::string> kKeys;
|
std::vector<std::string> kKeys;
|
||||||
std::vector<std::string> kVals;
|
std::vector<std::string> kVals;
|
||||||
kKeys.reserve(data.kipKeys.size());
|
kKeys.reserve(data.kipKeys.size());
|
||||||
kVals.reserve(data.kipKeys.size());
|
kVals.reserve(data.kipKeys.size());
|
||||||
for (const auto &entry : data.kipKeys) {
|
for (const auto &entry : data.kipKeys) {
|
||||||
fileUtils::LogLine("[cfg] %s = %s", entry.first.c_str(), entry.second.c_str());
|
file::utils::LogLine("[cfg] %s = %s", entry.first.c_str(), entry.second.c_str());
|
||||||
kKeys.push_back(entry.first);
|
kKeys.push_back(entry.first);
|
||||||
kVals.push_back(entry.second);
|
kVals.push_back(entry.second);
|
||||||
}
|
}
|
||||||
@@ -428,9 +428,9 @@ namespace config {
|
|||||||
kValPtrs.push_back(NULL);
|
kValPtrs.push_back(NULL);
|
||||||
|
|
||||||
if (!ini_putsection(CONFIG_VAL_SECTION, kKeyPtrs.data(), kValPtrs.data(), gKipPath.c_str())) {
|
if (!ini_putsection(CONFIG_VAL_SECTION, kKeyPtrs.data(), kValPtrs.data(), gKipPath.c_str())) {
|
||||||
fileUtils::LogLine("[cfg] FAILED to write KIP section");
|
file::utils::LogLine("[cfg] FAILED to write KIP section");
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[cfg] KIP migration done");
|
file::utils::LogLine("[cfg] KIP migration done");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &entry : data.kipKeys) {
|
for (const auto &entry : data.kipKeys) {
|
||||||
@@ -448,10 +448,10 @@ namespace config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[cfg] No KIP keys to migrate");
|
file::utils::LogLine("[cfg] No KIP keys to migrate");
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] Creating profiles directory: %s", FILE_PROFILES_DIR);
|
file::utils::LogLine("[cfg] Creating profiles directory: %s", FILE_PROFILES_DIR);
|
||||||
mkdir(FILE_PROFILES_DIR, 0777);
|
mkdir(FILE_PROFILES_DIR, 0777);
|
||||||
|
|
||||||
std::map<std::uint64_t, std::vector<std::pair<std::string, std::string>>> profileBuckets;
|
std::map<std::uint64_t, std::vector<std::pair<std::string, std::string>>> profileBuckets;
|
||||||
@@ -459,20 +459,20 @@ namespace config {
|
|||||||
profileBuckets[entry.first].push_back(entry.second);
|
profileBuckets[entry.first].push_back(entry.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] Writing %zu profiles (%zu TIDs)", data.profileEntries.size(), profileBuckets.size());
|
file::utils::LogLine("[cfg] Writing %zu profiles (%zu TIDs)", data.profileEntries.size(), profileBuckets.size());
|
||||||
for (const auto &bucket : profileBuckets) {
|
for (const auto &bucket : profileBuckets) {
|
||||||
char filename[32];
|
char filename[32];
|
||||||
snprintf(filename, sizeof(filename), "%016lX.ini", bucket.first);
|
snprintf(filename, sizeof(filename), "%016lX.ini", bucket.first);
|
||||||
std::string profilePath = gProfilesDir + "/" + filename;
|
std::string profilePath = gProfilesDir + "/" + filename;
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] TID=%016lX %zu keys -> %s", bucket.first, bucket.second.size(), profilePath.c_str());
|
file::utils::LogLine("[cfg] TID=%016lX %zu keys -> %s", bucket.first, bucket.second.size(), profilePath.c_str());
|
||||||
|
|
||||||
std::vector<std::string> pKeys;
|
std::vector<std::string> pKeys;
|
||||||
std::vector<std::string> pVals;
|
std::vector<std::string> pVals;
|
||||||
pKeys.reserve(bucket.second.size());
|
pKeys.reserve(bucket.second.size());
|
||||||
pVals.reserve(bucket.second.size());
|
pVals.reserve(bucket.second.size());
|
||||||
for (const auto &kv : bucket.second) {
|
for (const auto &kv : bucket.second) {
|
||||||
fileUtils::LogLine("[cfg] %s = %s", kv.first.c_str(), kv.second.c_str());
|
file::utils::LogLine("[cfg] %s = %s", kv.first.c_str(), kv.second.c_str());
|
||||||
pKeys.push_back(kv.first);
|
pKeys.push_back(kv.first);
|
||||||
pVals.push_back(kv.second);
|
pVals.push_back(kv.second);
|
||||||
}
|
}
|
||||||
@@ -489,17 +489,17 @@ namespace config {
|
|||||||
valPtrs.push_back(NULL);
|
valPtrs.push_back(NULL);
|
||||||
|
|
||||||
if (!ini_putsection(CONFIG_VAL_SECTION, keyPtrs.data(), valPtrs.data(), profilePath.c_str())) {
|
if (!ini_putsection(CONFIG_VAL_SECTION, keyPtrs.data(), valPtrs.data(), profilePath.c_str())) {
|
||||||
fileUtils::LogLine("[cfg] FAILED to write profile for TID %016lX", bucket.first);
|
file::utils::LogLine("[cfg] FAILED to write profile for TID %016lX", bucket.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileUtils::LogLine("[cfg] Profiles migration done");
|
file::utils::LogLine("[cfg] Profiles migration done");
|
||||||
|
|
||||||
fileUtils::LogLine("[cfg] Renaming legacy config to config.ini.migrated");
|
file::utils::LogLine("[cfg] Renaming legacy config to config.ini.migrated");
|
||||||
if (rename(gLegacyPath.c_str(), (gLegacyPath + ".migrated").c_str()) != 0) {
|
if (rename(gLegacyPath.c_str(), (gLegacyPath + ".migrated").c_str()) != 0) {
|
||||||
fileUtils::LogLine("[cfg] WARNING: Failed to rename legacy config file");
|
file::utils::LogLine("[cfg] WARNING: Failed to rename legacy config file");
|
||||||
}
|
}
|
||||||
gMigrationHappened = true;
|
gMigrationHappened = true;
|
||||||
fileUtils::LogLine("[cfg] Migration complete");
|
file::utils::LogLine("[cfg] Migration complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -570,7 +570,7 @@ namespace config {
|
|||||||
auto it = gProfileMtimes.find(HOCCLK_GLOBAL_PROFILE_TID);
|
auto it = gProfileMtimes.find(HOCCLK_GLOBAL_PROFILE_TID);
|
||||||
time_t known = (it != gProfileMtimes.end()) ? it->second : 0;
|
time_t known = (it != gProfileMtimes.end()) ? it->second : 0;
|
||||||
if (CheckFileMtime(profilePath) != known) {
|
if (CheckFileMtime(profilePath) != known) {
|
||||||
fileUtils::LogLine("[cfg] Global profile changed on disk, dropping cache");
|
file::utils::LogLine("[cfg] Global profile changed on disk, dropping cache");
|
||||||
DropGlobalProfile();
|
DropGlobalProfile();
|
||||||
profilesChanged = true;
|
profilesChanged = true;
|
||||||
}
|
}
|
||||||
@@ -580,7 +580,7 @@ namespace config {
|
|||||||
auto it = gProfileMtimes.find(gCurrentGameTid);
|
auto it = gProfileMtimes.find(gCurrentGameTid);
|
||||||
time_t known = (it != gProfileMtimes.end()) ? it->second : 0;
|
time_t known = (it != gProfileMtimes.end()) ? it->second : 0;
|
||||||
if (CheckFileMtime(profilePath) != known) {
|
if (CheckFileMtime(profilePath) != known) {
|
||||||
fileUtils::LogLine("[cfg] Profile %016lX changed on disk, dropping cache", gCurrentGameTid);
|
file::utils::LogLine("[cfg] Profile %016lX changed on disk, dropping cache", gCurrentGameTid);
|
||||||
EvictCurrentGame();
|
EvictCurrentGame();
|
||||||
profilesChanged = true;
|
profilesChanged = true;
|
||||||
}
|
}
|
||||||
@@ -676,7 +676,7 @@ namespace config {
|
|||||||
if (keys.empty()) {
|
if (keys.empty()) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(profilePath, &st) == 0 && remove(profilePath) != 0) {
|
if (stat(profilePath, &st) == 0 && remove(profilePath) != 0) {
|
||||||
fileUtils::LogLine("[cfg] Failed to remove empty profile %s", profilePath);
|
file::utils::LogLine("[cfg] Failed to remove empty profile %s", profilePath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (!ini_putsection(CONFIG_VAL_SECTION, keyPointers.data(), valuePointers.data(), profilePath)) {
|
} else if (!ini_putsection(CONFIG_VAL_SECTION, keyPointers.data(), valuePointers.data(), profilePath)) {
|
||||||
@@ -829,9 +829,9 @@ namespace config {
|
|||||||
if (immediate) {
|
if (immediate) {
|
||||||
for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) {
|
for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) {
|
||||||
if (hocclkValidConfigValue((HocClkConfigValue)kval, configValues->values[kval])) {
|
if (hocclkValidConfigValue((HocClkConfigValue)kval, configValues->values[kval])) {
|
||||||
config::configValues[kval] = configValues->values[kval];
|
file::config::configValues[kval] = configValues->values[kval];
|
||||||
} else {
|
} else {
|
||||||
config::configValues[kval] = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
file::config::configValues[kval] = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetProfileDirty(true);
|
SetProfileDirty(true);
|
||||||
@@ -842,7 +842,7 @@ namespace config {
|
|||||||
|
|
||||||
bool ResetConfigValue(HocClkConfigValue kval) {
|
bool ResetConfigValue(HocClkConfigValue kval) {
|
||||||
if (!HOCCLK_ENUM_VALID(HocClkConfigValue, kval)) {
|
if (!HOCCLK_ENUM_VALID(HocClkConfigValue, kval)) {
|
||||||
fileUtils::LogLine("[cfg] Invalid HocClkConfigValue: %u", kval);
|
file::utils::LogLine("[cfg] Invalid HocClkConfigValue: %u", kval);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -869,12 +869,12 @@ namespace config {
|
|||||||
const char *targetPath = hocclkIsKipConfigValue(kval) ? gKipPath.c_str() : gSettingsPath.c_str();
|
const char *targetPath = hocclkIsKipConfigValue(kval) ? gKipPath.c_str() : gSettingsPath.c_str();
|
||||||
|
|
||||||
if (!ini_putsection(CONFIG_VAL_SECTION, iniKeys.data(), valuePointers.data(), targetPath)) {
|
if (!ini_putsection(CONFIG_VAL_SECTION, iniKeys.data(), valuePointers.data(), targetPath)) {
|
||||||
fileUtils::LogLine("[cfg] Failed to reset config value %u in INI", kval);
|
file::utils::LogLine("[cfg] Failed to reset config value %u in INI", kval);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
configValues[kval] = defaultValue;
|
configValues[kval] = defaultValue;
|
||||||
fileUtils::LogLine("[cfg] Reset config value %u to default: %llu", kval, defaultValue);
|
file::utils::LogLine("[cfg] Reset config value %u to default: %llu", kval, defaultValue);
|
||||||
SetProfileDirty(true);
|
SetProfileDirty(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -923,4 +923,4 @@ namespace config {
|
|||||||
ini_puts(section, key, NULL, gSettingsPath.c_str());
|
ini_puts(section, key, NULL, gSettingsPath.c_str());
|
||||||
ini_puts(section, key, NULL, gKipPath.c_str());
|
ini_puts(section, key, NULL, gKipPath.c_str());
|
||||||
}
|
}
|
||||||
} // namespace config
|
} // namespace file::config
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#define CONFIG_VAL_SECTION "values"
|
#define CONFIG_VAL_SECTION "values"
|
||||||
|
|
||||||
namespace config {
|
namespace file::config {
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Exit();
|
void Exit();
|
||||||
@@ -65,4 +65,4 @@ namespace config {
|
|||||||
|
|
||||||
extern uint64_t configValues[HocClkConfigValue_EnumMax];
|
extern uint64_t configValues[HocClkConfigValue_EnumMax];
|
||||||
|
|
||||||
} // namespace config
|
} // namespace file::config
|
||||||
@@ -30,13 +30,13 @@
|
|||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "file_utils.hpp"
|
#include "file_utils.hpp"
|
||||||
|
|
||||||
namespace errors {
|
namespace file::utils {
|
||||||
void ThrowException(const char *format, ...) {
|
void ThrowException(const char *format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
fileUtils::LogLine(format, args);
|
LogLine(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||||
// throw std::runtime_error(msg);
|
// throw std::runtime_error(msg);
|
||||||
}
|
}
|
||||||
} // namespace errors
|
} // namespace file::utils
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#define ERROR_THROW(format, ...) errors::ThrowException(format "\n in %s:%u", ##__VA_ARGS__, __FILE__, __LINE__)
|
#define ERROR_THROW(format, ...) file::utils::ThrowException(format "\n in %s:%u", ##__VA_ARGS__, __FILE__, __LINE__)
|
||||||
#define ERROR_RESULT_THROW(rc, format, ...) ERROR_THROW(format "\n RC: [0x%x] %04d-%04d", ##__VA_ARGS__, rc, R_MODULE(rc), R_DESCRIPTION(rc))
|
#define ERROR_RESULT_THROW(rc, format, ...) ERROR_THROW(format "\n RC: [0x%x] %04d-%04d", ##__VA_ARGS__, rc, R_MODULE(rc), R_DESCRIPTION(rc))
|
||||||
#define ASSERT_RESULT_OK(rc, format, ...) \
|
#define ASSERT_RESULT_OK(rc, format, ...) \
|
||||||
if (R_FAILED(rc)) { \
|
if (R_FAILED(rc)) { \
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
ERROR_THROW("No such %s: %u", #n, v); \
|
ERROR_THROW("No such %s: %u", #n, v); \
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace errors {
|
namespace file::utils {
|
||||||
|
|
||||||
void ThrowException(const char *format, ...);
|
void ThrowException(const char *format, ...);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
extern "C" void __libnx_init_time(void);
|
extern "C" void __libnx_init_time(void);
|
||||||
|
|
||||||
namespace fileUtils {
|
namespace file::utils {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -234,4 +234,4 @@ namespace fileUtils {
|
|||||||
fsExit();
|
fsExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fileUtils
|
} // namespace file::utils
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
#define FILE_PROFILES_DIR FILE_CONFIG_DIR "/profiles"
|
#define FILE_PROFILES_DIR FILE_CONFIG_DIR "/profiles"
|
||||||
#define FILE_LEGACY_CONFIG_PATH FILE_CONFIG_DIR "/config.ini"
|
#define FILE_LEGACY_CONFIG_PATH FILE_CONFIG_DIR "/config.ini"
|
||||||
|
|
||||||
namespace fileUtils {
|
namespace file::utils {
|
||||||
|
|
||||||
void Exit();
|
void Exit();
|
||||||
Result Initialize();
|
Result Initialize();
|
||||||
@@ -56,4 +56,4 @@ namespace fileUtils {
|
|||||||
void LogLine(const char *format, ...);
|
void LogLine(const char *format, ...);
|
||||||
void WriteContextToCsv(const HocClkContext *context);
|
void WriteContextToCsv(const HocClkContext *context);
|
||||||
|
|
||||||
} // namespace fileUtils
|
} // namespace file::utils
|
||||||
@@ -22,22 +22,22 @@
|
|||||||
#include "../mapping/mem_map.hpp"
|
#include "../mapping/mem_map.hpp"
|
||||||
#include "kip.hpp"
|
#include "kip.hpp"
|
||||||
|
|
||||||
namespace kip {
|
namespace file::kip {
|
||||||
|
|
||||||
bool kipAvailable = false;
|
bool kipAvailable = false;
|
||||||
void SetKipData() {
|
void SetKipData() {
|
||||||
// TODO: figure out if this REALLY causes issues (i doubt it)
|
// TODO: figure out if this REALLY causes issues (i doubt it)
|
||||||
// if(board::GetSocType() == HocClkSocType_Mariko) {
|
// if(board::GetSocType() == HocClkSocType_Mariko) {
|
||||||
// if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) {
|
// if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, file::config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) {
|
||||||
// fileUtils::LogLine("[clock_manager] Failed set i2c vddq");
|
// file::utils::LogLine("[clock_manager] Failed set i2c vddq");
|
||||||
// notification::writeNotification("Horizon OC\nFailed to write I2C\nwhile setting vddq");
|
// hos::WriteNotification("Horizon OC\nFailed to write I2C\nwhile setting vddq");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
CustomizeTable table;
|
CustomizeTable table;
|
||||||
FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "r+b");
|
FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "r+b");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
notification::writeNotification("Horizon OC\nKip opening failed");
|
hos::WriteNotification("Horizon OC\nKip opening failed");
|
||||||
kipAvailable = false;
|
kipAvailable = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -45,8 +45,8 @@ namespace kip {
|
|||||||
|
|
||||||
if (!cust_read_table_f(fp, &table)) {
|
if (!cust_read_table_f(fp, &table)) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fileUtils::LogLine("[kip] Failed to read KIP file");
|
file::utils::LogLine("[kip] Failed to read KIP file");
|
||||||
notification::writeNotification("Horizon OC\nKip read failed");
|
hos::WriteNotification("Horizon OC\nKip read failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,121 +54,121 @@ namespace kip {
|
|||||||
u32 kipVersion = cust_get_kip_version(&table);
|
u32 kipVersion = cust_get_kip_version(&table);
|
||||||
if (custRev < CUST_REV || kipVersion < KIP_VERSION) {
|
if (custRev < CUST_REV || kipVersion < KIP_VERSION) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
notification::writeNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC");
|
hos::WriteNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC");
|
||||||
fileUtils::LogLine("Cust revision: %u", custRev);
|
file::utils::LogLine("Cust revision: %u", custRev);
|
||||||
fileUtils::LogLine("Kip version: %u", kipVersion);
|
file::utils::LogLine("Kip version: %u", kipVersion);
|
||||||
return;
|
return;
|
||||||
} else if (custRev > CUST_REV || kipVersion > KIP_VERSION) {
|
} else if (custRev > CUST_REV || kipVersion > KIP_VERSION) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
notification::writeNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC");
|
hos::WriteNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC");
|
||||||
fileUtils::LogLine("Cust revision: %u", custRev);
|
file::utils::LogLine("Cust revision: %u", custRev);
|
||||||
fileUtils::LogLine("Kip version: %u", kipVersion);
|
file::utils::LogLine("Kip version: %u", kipVersion);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CUST_WRITE_FIELD_BATCH(&table, mtcConf, config::GetConfigValue(KipConfigValue_mtcConf));
|
// CUST_WRITE_FIELD_BATCH(&table, mtcConf, file::config::GetConfigValue(KipConfigValue_mtcConf));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, hpMode, config::GetConfigValue(KipConfigValue_hpMode));
|
CUST_WRITE_FIELD_BATCH(&table, hpMode, file::config::GetConfigValue(KipConfigValue_hpMode));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, commonEmcMemVolt, config::GetConfigValue(KipConfigValue_commonEmcMemVolt));
|
CUST_WRITE_FIELD_BATCH(&table, commonEmcMemVolt, file::config::GetConfigValue(KipConfigValue_commonEmcMemVolt));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaEmcMaxClock, config::GetConfigValue(KipConfigValue_eristaEmcMaxClock));
|
CUST_WRITE_FIELD_BATCH(&table, eristaEmcMaxClock, file::config::GetConfigValue(KipConfigValue_eristaEmcMaxClock));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoEmcMaxClock, config::GetConfigValue(KipConfigValue_marikoEmcMaxClock));
|
CUST_WRITE_FIELD_BATCH(&table, marikoEmcMaxClock, file::config::GetConfigValue(KipConfigValue_marikoEmcMaxClock));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoEmcVddqVolt, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt));
|
CUST_WRITE_FIELD_BATCH(&table, marikoEmcVddqVolt, file::config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, emcDvbShift, config::GetConfigValue(KipConfigValue_emcDvbShift));
|
CUST_WRITE_FIELD_BATCH(&table, emcDvbShift, file::config::GetConfigValue(KipConfigValue_emcDvbShift));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoSocVmax, config::GetConfigValue(KipConfigValue_marikoSocVmax));
|
CUST_WRITE_FIELD_BATCH(&table, marikoSocVmax, file::config::GetConfigValue(KipConfigValue_marikoSocVmax));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t1_tRCD, config::GetConfigValue(KipConfigValue_t1_tRCD));
|
CUST_WRITE_FIELD_BATCH(&table, t1_tRCD, file::config::GetConfigValue(KipConfigValue_t1_tRCD));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t2_tRP, config::GetConfigValue(KipConfigValue_t2_tRP));
|
CUST_WRITE_FIELD_BATCH(&table, t2_tRP, file::config::GetConfigValue(KipConfigValue_t2_tRP));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t3_tRAS, config::GetConfigValue(KipConfigValue_t3_tRAS));
|
CUST_WRITE_FIELD_BATCH(&table, t3_tRAS, file::config::GetConfigValue(KipConfigValue_t3_tRAS));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t4_tRRD, config::GetConfigValue(KipConfigValue_t4_tRRD));
|
CUST_WRITE_FIELD_BATCH(&table, t4_tRRD, file::config::GetConfigValue(KipConfigValue_t4_tRRD));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t5_tRFC, config::GetConfigValue(KipConfigValue_t5_tRFC));
|
CUST_WRITE_FIELD_BATCH(&table, t5_tRFC, file::config::GetConfigValue(KipConfigValue_t5_tRFC));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t6_tRTW, config::GetConfigValue(KipConfigValue_t6_tRTW));
|
CUST_WRITE_FIELD_BATCH(&table, t6_tRTW, file::config::GetConfigValue(KipConfigValue_t6_tRTW));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t7_tWTR, config::GetConfigValue(KipConfigValue_t7_tWTR));
|
CUST_WRITE_FIELD_BATCH(&table, t7_tWTR, file::config::GetConfigValue(KipConfigValue_t7_tWTR));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t8_tREFI, config::GetConfigValue(KipConfigValue_t8_tREFI));
|
CUST_WRITE_FIELD_BATCH(&table, t8_tREFI, file::config::GetConfigValue(KipConfigValue_t8_tREFI));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, stepMode, config::GetConfigValue(KipConfigValue_stepMode));
|
CUST_WRITE_FIELD_BATCH(&table, stepMode, file::config::GetConfigValue(KipConfigValue_stepMode));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, timingEmcTbreak, config::GetConfigValue(KipConfigValue_timingEmcTbreak));
|
CUST_WRITE_FIELD_BATCH(&table, timingEmcTbreak, file::config::GetConfigValue(KipConfigValue_timingEmcTbreak));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t1_tRCD, config::GetConfigValue(KipConfigValue_low_t1_tRCD));
|
CUST_WRITE_FIELD_BATCH(&table, low_t1_tRCD, file::config::GetConfigValue(KipConfigValue_low_t1_tRCD));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t2_tRP, config::GetConfigValue(KipConfigValue_low_t2_tRP));
|
CUST_WRITE_FIELD_BATCH(&table, low_t2_tRP, file::config::GetConfigValue(KipConfigValue_low_t2_tRP));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t3_tRAS, config::GetConfigValue(KipConfigValue_low_t3_tRAS));
|
CUST_WRITE_FIELD_BATCH(&table, low_t3_tRAS, file::config::GetConfigValue(KipConfigValue_low_t3_tRAS));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t4_tRRD, config::GetConfigValue(KipConfigValue_low_t4_tRRD));
|
CUST_WRITE_FIELD_BATCH(&table, low_t4_tRRD, file::config::GetConfigValue(KipConfigValue_low_t4_tRRD));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t5_tRFC, config::GetConfigValue(KipConfigValue_low_t5_tRFC));
|
CUST_WRITE_FIELD_BATCH(&table, low_t5_tRFC, file::config::GetConfigValue(KipConfigValue_low_t5_tRFC));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t6_tRTW, config::GetConfigValue(KipConfigValue_low_t6_tRTW));
|
CUST_WRITE_FIELD_BATCH(&table, low_t6_tRTW, file::config::GetConfigValue(KipConfigValue_low_t6_tRTW));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t7_tWTR, config::GetConfigValue(KipConfigValue_low_t7_tWTR));
|
CUST_WRITE_FIELD_BATCH(&table, low_t7_tWTR, file::config::GetConfigValue(KipConfigValue_low_t7_tWTR));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, low_t8_tREFI, config::GetConfigValue(KipConfigValue_low_t8_tREFI));
|
CUST_WRITE_FIELD_BATCH(&table, low_t8_tREFI, file::config::GetConfigValue(KipConfigValue_low_t8_tREFI));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, readLatency1333, config::GetConfigValue(KipConfigValue_read_latency_1333));
|
CUST_WRITE_FIELD_BATCH(&table, readLatency1333, file::config::GetConfigValue(KipConfigValue_read_latency_1333));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, readLatency1600, config::GetConfigValue(KipConfigValue_read_latency_1600));
|
CUST_WRITE_FIELD_BATCH(&table, readLatency1600, file::config::GetConfigValue(KipConfigValue_read_latency_1600));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, readLatency1866, config::GetConfigValue(KipConfigValue_read_latency_1866));
|
CUST_WRITE_FIELD_BATCH(&table, readLatency1866, file::config::GetConfigValue(KipConfigValue_read_latency_1866));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, readLatency2133, config::GetConfigValue(KipConfigValue_read_latency_2133));
|
CUST_WRITE_FIELD_BATCH(&table, readLatency2133, file::config::GetConfigValue(KipConfigValue_read_latency_2133));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, writeLatency1333, config::GetConfigValue(KipConfigValue_write_latency_1333));
|
CUST_WRITE_FIELD_BATCH(&table, writeLatency1333, file::config::GetConfigValue(KipConfigValue_write_latency_1333));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, writeLatency1600, config::GetConfigValue(KipConfigValue_write_latency_1600));
|
CUST_WRITE_FIELD_BATCH(&table, writeLatency1600, file::config::GetConfigValue(KipConfigValue_write_latency_1600));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, writeLatency1866, config::GetConfigValue(KipConfigValue_write_latency_1866));
|
CUST_WRITE_FIELD_BATCH(&table, writeLatency1866, file::config::GetConfigValue(KipConfigValue_write_latency_1866));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, writeLatency2133, config::GetConfigValue(KipConfigValue_write_latency_2133));
|
CUST_WRITE_FIELD_BATCH(&table, writeLatency2133, file::config::GetConfigValue(KipConfigValue_write_latency_2133));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaCpuUV, config::GetConfigValue(KipConfigValue_eristaCpuUV));
|
CUST_WRITE_FIELD_BATCH(&table, eristaCpuUV, file::config::GetConfigValue(KipConfigValue_eristaCpuUV));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaCpuVmin, config::GetConfigValue(KipConfigValue_eristaCpuVmin));
|
CUST_WRITE_FIELD_BATCH(&table, eristaCpuVmin, file::config::GetConfigValue(KipConfigValue_eristaCpuVmin));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaCpuMaxVolt, config::GetConfigValue(KipConfigValue_eristaCpuMaxVolt));
|
CUST_WRITE_FIELD_BATCH(&table, eristaCpuMaxVolt, file::config::GetConfigValue(KipConfigValue_eristaCpuMaxVolt));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaCpuUnlock, config::GetConfigValue(KipConfigValue_eristaCpuUnlock));
|
CUST_WRITE_FIELD_BATCH(&table, eristaCpuUnlock, file::config::GetConfigValue(KipConfigValue_eristaCpuUnlock));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuUVLow, config::GetConfigValue(KipConfigValue_marikoCpuUVLow));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuUVLow, file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuUVHigh, config::GetConfigValue(KipConfigValue_marikoCpuUVHigh));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuUVHigh, file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, tableConf, config::GetConfigValue(KipConfigValue_tableConf));
|
CUST_WRITE_FIELD_BATCH(&table, tableConf, file::config::GetConfigValue(KipConfigValue_tableConf));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuLowVmin, config::GetConfigValue(KipConfigValue_marikoCpuLowVmin));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuLowVmin, file::config::GetConfigValue(KipConfigValue_marikoCpuLowVmin));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuHighVmin, config::GetConfigValue(KipConfigValue_marikoCpuHighVmin));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuHighVmin, file::config::GetConfigValue(KipConfigValue_marikoCpuHighVmin));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxVolt, config::GetConfigValue(KipConfigValue_marikoCpuMaxVolt));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxVolt, file::config::GetConfigValue(KipConfigValue_marikoCpuMaxVolt));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxClock, config::GetConfigValue(KipConfigValue_marikoCpuMaxClock));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxClock, file::config::GetConfigValue(KipConfigValue_marikoCpuMaxClock));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaCpuBoostClock, config::GetConfigValue(KipConfigValue_eristaCpuBoostClock));
|
CUST_WRITE_FIELD_BATCH(&table, eristaCpuBoostClock, file::config::GetConfigValue(KipConfigValue_eristaCpuBoostClock));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoCpuBoostClock, config::GetConfigValue(KipConfigValue_marikoCpuBoostClock));
|
CUST_WRITE_FIELD_BATCH(&table, marikoCpuBoostClock, file::config::GetConfigValue(KipConfigValue_marikoCpuBoostClock));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaGpuUV, config::GetConfigValue(KipConfigValue_eristaGpuUV));
|
CUST_WRITE_FIELD_BATCH(&table, eristaGpuUV, file::config::GetConfigValue(KipConfigValue_eristaGpuUV));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, eristaGpuVmin, config::GetConfigValue(KipConfigValue_eristaGpuVmin));
|
CUST_WRITE_FIELD_BATCH(&table, eristaGpuVmin, file::config::GetConfigValue(KipConfigValue_eristaGpuVmin));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuUV, config::GetConfigValue(KipConfigValue_marikoGpuUV));
|
CUST_WRITE_FIELD_BATCH(&table, marikoGpuUV, file::config::GetConfigValue(KipConfigValue_marikoGpuUV));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmin, config::GetConfigValue(KipConfigValue_marikoGpuVmin));
|
CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmin, file::config::GetConfigValue(KipConfigValue_marikoGpuVmin));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmax, config::GetConfigValue(KipConfigValue_marikoGpuVmax));
|
CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmax, file::config::GetConfigValue(KipConfigValue_marikoGpuVmax));
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, commonGpuVoltOffset, config::GetConfigValue(KipConfigValue_commonGpuVoltOffset));
|
CUST_WRITE_FIELD_BATCH(&table, commonGpuVoltOffset, file::config::GetConfigValue(KipConfigValue_commonGpuVoltOffset));
|
||||||
|
|
||||||
for (int i = 0; i < 25; i++) {
|
for (int i = 0; i < 25; i++) {
|
||||||
table.marikoGpuVoltArray[i] = config::GetConfigValue((HocClkConfigValue)(KipConfigValue_g_volt_76800 + i));
|
table.marikoGpuVoltArray[i] = file::config::GetConfigValue((HocClkConfigValue)(KipConfigValue_g_volt_76800 + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 27; i++) {
|
for (int i = 0; i < 27; i++) {
|
||||||
table.eristaGpuVoltArray[i] = config::GetConfigValue((HocClkConfigValue)(KipConfigValue_g_volt_e_76800 + i));
|
table.eristaGpuVoltArray[i] = file::config::GetConfigValue((HocClkConfigValue)(KipConfigValue_g_volt_e_76800 + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 28; ++i) {
|
for (size_t i = 0; i < 28; ++i) {
|
||||||
table.marikoSocVoltArray[i] = config::GetConfigValue((HocClkConfigValue) (KipConfigValue_g_soc_volt_1866000 + i));
|
table.marikoSocVoltArray[i] = file::config::GetConfigValue((HocClkConfigValue) (KipConfigValue_g_soc_volt_1866000 + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t6_tRTW_fine_tune, config::GetConfigValue(KipConfigValue_t6_tRTW_fine_tune));
|
CUST_WRITE_FIELD_BATCH(&table, t6_tRTW_fine_tune, file::config::GetConfigValue(KipConfigValue_t6_tRTW_fine_tune));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, t7_tWTR_fine_tune, config::GetConfigValue(KipConfigValue_t7_tWTR_fine_tune));
|
CUST_WRITE_FIELD_BATCH(&table, t7_tWTR_fine_tune, file::config::GetConfigValue(KipConfigValue_t7_tWTR_fine_tune));
|
||||||
CUST_WRITE_FIELD_BATCH(&table, pcvLogVerbosity, config::GetConfigValue(KipConfigValue_PcvDebugVerbosity));
|
CUST_WRITE_FIELD_BATCH(&table, pcvLogVerbosity, file::config::GetConfigValue(KipConfigValue_PcvDebugVerbosity));
|
||||||
|
|
||||||
if (!cust_write_table_f(fp, &table)) {
|
if (!cust_write_table_f(fp, &table)) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fileUtils::LogLine("[kip] Failed to write KIP file");
|
file::utils::LogLine("[kip] Failed to write KIP file");
|
||||||
notification::writeNotification("Horizon OC\nKip write failed");
|
hos::WriteNotification("Horizon OC\nKip write failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
HocClkConfigValueList configValues;
|
HocClkConfigValueList configValues;
|
||||||
config::GetConfigValues(&configValues);
|
file::config::GetConfigValues(&configValues);
|
||||||
|
|
||||||
configValues.values[KipCrc32] = (u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
configValues.values[KipCrc32] = (u64)util::ChecksumFile("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
||||||
|
|
||||||
if (config::SetConfigValues(&configValues, true)) {
|
if (file::config::SetConfigValues(&configValues, true)) {
|
||||||
fileUtils::LogLine("[kip] KIP data set. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32],
|
file::utils::LogLine("[kip] KIP data set. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32],
|
||||||
configValues.values[KipConfigValue_custRev]);
|
configValues.values[KipConfigValue_custRev]);
|
||||||
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
||||||
fileUtils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
file::utils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[kip] Warning: Failed to set config values from KIP");
|
file::utils::LogLine("[kip] Warning: Failed to set config values from KIP");
|
||||||
notification::writeNotification("Horizon OC\nKip config set failed");
|
hos::WriteNotification("Horizon OC\nKip config set failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +185,8 @@ namespace kip {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
notification::writeNotification("Kip is not loaded!");
|
hos::WriteNotification("Kip is not loaded!");
|
||||||
fileUtils::LogLine("Kip was not loaded!");
|
file::utils::LogLine("Kip was not loaded!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,26 +196,26 @@ namespace kip {
|
|||||||
FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "rb");
|
FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "rb");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
notification::writeNotification("Horizon OC\nKip opening failed");
|
hos::WriteNotification("Horizon OC\nKip opening failed");
|
||||||
kipAvailable = false;
|
kipAvailable = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
kipAvailable = true;
|
kipAvailable = true;
|
||||||
|
|
||||||
HocClkConfigValueList configValues;
|
HocClkConfigValueList configValues;
|
||||||
config::GetConfigValues(&configValues);
|
file::config::GetConfigValues(&configValues);
|
||||||
|
|
||||||
CustomizeTable table;
|
CustomizeTable table;
|
||||||
if (!cust_read_table_f(fp, &table)) {
|
if (!cust_read_table_f(fp, &table)) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fileUtils::LogLine("[kip] Failed to read KIP file for GetKipData");
|
file::utils::LogLine("[kip] Failed to read KIP file for GetKipData");
|
||||||
notification::writeNotification("Horizon OC\nKip read failed");
|
hos::WriteNotification("Horizon OC\nKip read failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
// if(cust_get_cust_rev(&table) != CUST_REV) {
|
// if(cust_get_cust_rev(&table) != CUST_REV) {
|
||||||
// notification::writeNotification("Horizon OC\nKip version mismatch\nPlease reinstall Horizon OC");
|
// hos::WriteNotification("Horizon OC\nKip version mismatch\nPlease reinstall Horizon OC");
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -223,47 +223,47 @@ namespace kip {
|
|||||||
/* I hate this. */
|
/* I hate this. */
|
||||||
/* Don't fetch frequency if it's already set or we would overwrite it. */
|
/* Don't fetch frequency if it's already set or we would overwrite it. */
|
||||||
/* This technically only applies to Mariko *for now*. */
|
/* This technically only applies to Mariko *for now*. */
|
||||||
if (clockManager::patchedEmcMaxClock == 0) {
|
if (mgr::patchedEmcMaxClock == 0) {
|
||||||
if (board::GetSocType() == HocClkSocType_Mariko) {
|
if (board::GetSocType() == HocClkSocType_Mariko) {
|
||||||
clockManager::patchedEmcMaxClock = cust_get_mariko_emc_max(&table);
|
mgr::patchedEmcMaxClock = cust_get_mariko_emc_max(&table);
|
||||||
} else {
|
} else {
|
||||||
clockManager::patchedEmcMaxClock = cust_get_erista_emc_max(&table);
|
mgr::patchedEmcMaxClock = cust_get_erista_emc_max(&table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip") != config::GetConfigValue(KipCrc32) &&
|
if ((u64)util::ChecksumFile("sdmc:/atmosphere/kips/hoc.kip") != file::config::GetConfigValue(KipCrc32) &&
|
||||||
!config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) {
|
!file::config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) {
|
||||||
MigrateKipData(cust_get_cust_rev(&table), cust_get_kip_version(&table));
|
MigrateKipData(cust_get_cust_rev(&table), cust_get_kip_version(&table));
|
||||||
SetKipData();
|
SetKipData();
|
||||||
clockManager::gContext.rebootRequired = true;
|
mgr::gContext.rebootRequired = true;
|
||||||
notification::writeNotification("Horizon OC\nKIP has been updated\nPlease reboot your console to use Horizon OC");
|
hos::WriteNotification("Horizon OC\nKIP has been updated\nPlease reboot your console to use Horizon OC");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (config::GetConfigValue(HocClkConfigValue_IsFirstLoad) == true) {
|
if (file::config::GetConfigValue(HocClkConfigValue_IsFirstLoad) == true) {
|
||||||
configValues.values[HocClkConfigValue_IsFirstLoad] = (u64) false;
|
configValues.values[HocClkConfigValue_IsFirstLoad] = (u64) false;
|
||||||
notification::writeNotification("Horizon OC has been installed");
|
hos::WriteNotification("Horizon OC has been installed");
|
||||||
}
|
}
|
||||||
|
|
||||||
configValues.values[KipCrc32] = (u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
configValues.values[KipCrc32] = (u64)util::ChecksumFile("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
||||||
// configValues.values[KipConfigValue_mtcConf] = cust_get_mtc_conf(&table);
|
// configValues.values[KipConfigValue_mtcConf] = cust_get_mtc_conf(&table);
|
||||||
clockManager::gContext.custRev = cust_get_cust_rev(&table);
|
mgr::gContext.custRev = cust_get_cust_rev(&table);
|
||||||
|
|
||||||
u32 custRev = cust_get_cust_rev(&table);
|
u32 custRev = cust_get_cust_rev(&table);
|
||||||
u32 kipVersion = cust_get_kip_version(&table);
|
u32 kipVersion = cust_get_kip_version(&table);
|
||||||
if (custRev < CUST_REV || kipVersion < KIP_VERSION) {
|
if (custRev < CUST_REV || kipVersion < KIP_VERSION) {
|
||||||
notification::writeNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC");
|
hos::WriteNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC");
|
||||||
fileUtils::LogLine("Cust revision: %u", custRev);
|
file::utils::LogLine("Cust revision: %u", custRev);
|
||||||
fileUtils::LogLine("Kip version: %u", kipVersion);
|
file::utils::LogLine("Kip version: %u", kipVersion);
|
||||||
return;
|
return;
|
||||||
} else if (custRev > CUST_REV || kipVersion > KIP_VERSION) {
|
} else if (custRev > CUST_REV || kipVersion > KIP_VERSION) {
|
||||||
notification::writeNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC");
|
hos::WriteNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC");
|
||||||
fileUtils::LogLine("Cust revision: %u", custRev);
|
file::utils::LogLine("Cust revision: %u", custRev);
|
||||||
fileUtils::LogLine("Kip version: %u", kipVersion);
|
file::utils::LogLine("Kip version: %u", kipVersion);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clockManager::gContext.isKipLoaded = IsKipLoaded();
|
mgr::gContext.isKipLoaded = IsKipLoaded();
|
||||||
clockManager::gContext.kipVersion = kipVersion;
|
mgr::gContext.kipVersion = kipVersion;
|
||||||
configValues.values[KipConfigValue_custRev] = cust_get_cust_rev(&table);
|
configValues.values[KipConfigValue_custRev] = cust_get_cust_rev(&table);
|
||||||
configValues.values[KipConfigValue_KipVersion] = cust_get_kip_version(&table); // Run this after the check so we can do migration process
|
configValues.values[KipConfigValue_KipVersion] = cust_get_kip_version(&table); // Run this after the check so we can do migration process
|
||||||
configValues.values[KipConfigValue_hpMode] = cust_get_hp_mode(&table);
|
configValues.values[KipConfigValue_hpMode] = cust_get_hp_mode(&table);
|
||||||
@@ -345,25 +345,25 @@ namespace kip {
|
|||||||
configValues.values[KipConfigValue_PcvDebugVerbosity] = cust_get_log_verbosity(&table);
|
configValues.values[KipConfigValue_PcvDebugVerbosity] = cust_get_log_verbosity(&table);
|
||||||
|
|
||||||
if (sizeof(HocClkConfigValueList) <= sizeof(configValues)) {
|
if (sizeof(HocClkConfigValueList) <= sizeof(configValues)) {
|
||||||
if (config::SetConfigValues(&configValues, true)) {
|
if (file::config::SetConfigValues(&configValues, true)) {
|
||||||
fileUtils::LogLine("[kip] KIP loaded. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32],
|
file::utils::LogLine("[kip] KIP loaded. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32],
|
||||||
configValues.values[KipConfigValue_custRev]);
|
configValues.values[KipConfigValue_custRev]);
|
||||||
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
||||||
fileUtils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
file::utils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[kip] Warning: Failed to set config values from KIP");
|
file::utils::LogLine("[kip] Warning: Failed to set config values from KIP");
|
||||||
notification::writeNotification("Horizon OC\nKip config set failed");
|
hos::WriteNotification("Horizon OC\nKip config set failed");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileUtils::LogLine("[kip] Error: Config value list buffer size mismatch");
|
file::utils::LogLine("[kip] Error: Config value list buffer size mismatch");
|
||||||
notification::writeNotification("Horizon OC\nConfig Buffer Mismatch");
|
hos::WriteNotification("Horizon OC\nConfig Buffer Mismatch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MigrateKipData(u32 custRev, u32 version) {
|
void MigrateKipData(u32 custRev, u32 version) {
|
||||||
HocClkConfigValueList configValues;
|
HocClkConfigValueList configValues;
|
||||||
config::GetConfigValues(&configValues);
|
file::config::GetConfigValues(&configValues);
|
||||||
u32 previousVersion = configValues.values[KipConfigValue_KipVersion];
|
u32 previousVersion = configValues.values[KipConfigValue_KipVersion];
|
||||||
if (previousVersion < 240 && version >= 240) {
|
if (previousVersion < 240 && version >= 240) {
|
||||||
// <2.4.0 -> 2.4.0 migration
|
// <2.4.0 -> 2.4.0 migration
|
||||||
@@ -377,15 +377,15 @@ namespace kip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete handheld TDP config entries
|
// delete handheld TDP config entries
|
||||||
config::DeleteKey(CONFIG_VAL_SECTION, "handheld_tdp");
|
file::config::DeleteKey(CONFIG_VAL_SECTION, "handheld_tdp");
|
||||||
config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit");
|
file::config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit");
|
||||||
config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit_l");
|
file::config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit_l");
|
||||||
}
|
}
|
||||||
if(previousVersion < 300 && version >= 300) {
|
if(previousVersion < 300 && version >= 300) {
|
||||||
configValues.values[KipConfigValue_g_volt_1574400] = 2000;
|
configValues.values[KipConfigValue_g_volt_1574400] = 2000;
|
||||||
}
|
}
|
||||||
config::SetConfigValues(&configValues, true);
|
file::config::SetConfigValues(&configValues, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace kip
|
} // namespace file::kip
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "file_utils.hpp"
|
#include "file_utils.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace kip {
|
namespace file::kip {
|
||||||
extern bool kipAvailable;
|
extern bool kipAvailable;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -825,4 +825,4 @@ namespace kip {
|
|||||||
void MigrateKipData(u32 custRev, u32 version);
|
void MigrateKipData(u32 custRev, u32 version);
|
||||||
void SetKipData();
|
void SetKipData();
|
||||||
void GetKipData();
|
void GetKipData();
|
||||||
} // namespace kip
|
} // namespace file::kip
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "process_management.hpp"
|
#include "process_management.hpp"
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
namespace integrations {
|
namespace hos {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ namespace integrations {
|
|||||||
if (!gSharedMemoryUsed)
|
if (!gSharedMemoryUsed)
|
||||||
return 254;
|
return 254;
|
||||||
|
|
||||||
u64 tid = processManagement::GetCurrentApplicationId();
|
u64 tid = GetCurrentApplicationId();
|
||||||
if (tid == 0)
|
if (tid == 0)
|
||||||
return 254;
|
return 254;
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ namespace integrations {
|
|||||||
if (!gSharedMemoryUsed)
|
if (!gSharedMemoryUsed)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u64 tid = processManagement::GetCurrentApplicationId();
|
u64 tid = GetCurrentApplicationId();
|
||||||
if (tid == 0)
|
if (tid == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -151,4 +151,4 @@ namespace integrations {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace integrations
|
} // namespace hos
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
namespace integrations {
|
namespace hos {
|
||||||
|
|
||||||
struct NxFpsSharedBlock {
|
struct NxFpsSharedBlock {
|
||||||
uint32_t MAGIC;
|
uint32_t MAGIC;
|
||||||
@@ -66,4 +66,4 @@ namespace integrations {
|
|||||||
u8 GetSaltyNXFPS();
|
u8 GetSaltyNXFPS();
|
||||||
u16 GetSaltyNXResolutionHeight();
|
u16 GetSaltyNXResolutionHeight();
|
||||||
|
|
||||||
} // namespace integrations
|
} // namespace hos
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "../file/file_utils.hpp"
|
#include "../file/file_utils.hpp"
|
||||||
|
|
||||||
namespace lang {
|
namespace hos {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr const char *UltrahandConfigPath = "sdmc:/config/ultrahand/config.ini";
|
constexpr const char *UltrahandConfigPath = "sdmc:/config/ultrahand/config.ini";
|
||||||
@@ -138,4 +138,4 @@ namespace lang {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace lang
|
} // namespace hos
|
||||||
@@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace lang {
|
namespace hos {
|
||||||
|
|
||||||
// Translates text using Ultrahand's language setting and
|
// Translates text using Ultrahand's language setting and
|
||||||
// /config/horizon-oc/lang/<lang>.json (same format as the overlay).
|
// /config/horizon-oc/lang/<lang>.json (same format as the overlay).
|
||||||
// Returns the original text when no translation is available.
|
// Returns the original text when no translation is available.
|
||||||
std::string Translate(const std::string &text);
|
std::string Translate(const std::string &text);
|
||||||
|
|
||||||
} // namespace lang
|
} // namespace hos
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
#include "lang.hpp"
|
#include "lang.hpp"
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
|
||||||
namespace notification {
|
namespace hos {
|
||||||
void writeNotification(const std::string &message) {
|
void WriteNotification(const std::string &message) {
|
||||||
static const char *flagPath = "sdmc:/config/ultrahand/flags/NOTIFICATIONS.flag";
|
static const char *flagPath = "sdmc:/config/ultrahand/flags/NOTIFICATIONS.flag";
|
||||||
|
|
||||||
FILE *flagFile = fopen(flagPath, "r");
|
FILE *flagFile = fopen(flagPath, "r");
|
||||||
@@ -28,7 +28,7 @@ namespace notification {
|
|||||||
}
|
}
|
||||||
fclose(flagFile);
|
fclose(flagFile);
|
||||||
|
|
||||||
const std::string translated = lang::Translate(message);
|
const std::string translated = Translate(message);
|
||||||
|
|
||||||
std::string filename = "hoc-" + std::to_string(std::time(nullptr)) + ".notify";
|
std::string filename = "hoc-" + std::to_string(std::time(nullptr)) + ".notify";
|
||||||
std::string fullPath = "sdmc:/config/ultrahand/notifications/" + filename;
|
std::string fullPath = "sdmc:/config/ultrahand/notifications/" + filename;
|
||||||
@@ -42,4 +42,4 @@ namespace notification {
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace notification
|
} // namespace hos
|
||||||
@@ -20,6 +20,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <string>
|
#include <string>
|
||||||
namespace notification {
|
namespace hos {
|
||||||
void writeNotification(const std::string &message);
|
void WriteNotification(const std::string &message);
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
#include "process_management.hpp"
|
#include "process_management.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace processManagement {
|
namespace hos {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr u64 Qlaunch = 0x0100000000001000ULL;
|
constexpr u64 Qlaunch = 0x0100000000001000ULL;
|
||||||
@@ -39,7 +39,7 @@ namespace processManagement {
|
|||||||
Service pdmqryClone;
|
Service pdmqryClone;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Initialize() {
|
void InitializeProcessManagement() {
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
|
|
||||||
rc = pmdmntInitialize();
|
rc = pmdmntInitialize();
|
||||||
@@ -67,7 +67,7 @@ namespace processManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ty to Masa for this function!
|
// Ty to Masa for this function!
|
||||||
Result isApplicationOutOfFocus(bool *outOfFocus) {
|
Result IsApplicationOutOfFocus(bool *outOfFocus) {
|
||||||
static s32 last_total_entries = 0;
|
static s32 last_total_entries = 0;
|
||||||
static bool isOutOfFocus = false;
|
static bool isOutOfFocus = false;
|
||||||
s32 total_entries = 0;
|
s32 total_entries = 0;
|
||||||
@@ -158,10 +158,10 @@ namespace processManagement {
|
|||||||
return tid;
|
return tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Exit() {
|
void ExitProcessManagement() {
|
||||||
pmdmntExit();
|
pmdmntExit();
|
||||||
pminfoExit();
|
pminfoExit();
|
||||||
pdmqryExit();
|
pdmqryExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace processManagement
|
} // namespace hos
|
||||||
@@ -27,12 +27,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
namespace processManagement {
|
namespace hos {
|
||||||
|
|
||||||
void Initialize();
|
void InitializeProcessManagement();
|
||||||
void WaitForQLaunch();
|
void WaitForQLaunch();
|
||||||
u64 GetCurrentApplicationId();
|
u64 GetCurrentApplicationId();
|
||||||
Result isApplicationOutOfFocus(bool *outOfFocus);
|
Result IsApplicationOutOfFocus(bool *outOfFocus);
|
||||||
void Exit();
|
void ExitProcessManagement();
|
||||||
|
|
||||||
} // namespace processManagement
|
} // namespace hos
|
||||||
@@ -61,44 +61,44 @@ namespace ipcService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result GetCurrentContext(HocClkContext *out_ctx) {
|
Result GetCurrentContext(HocClkContext *out_ctx) {
|
||||||
*out_ctx = clockManager::GetCurrentContext();
|
*out_ctx = mgr::GetCurrentContext();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ExitHandler() {
|
Result ExitHandler() {
|
||||||
clockManager::SetRunning(false);
|
mgr::SetRunning(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetProfileCount(std::uint64_t *tid, std::uint8_t *out_count) {
|
Result GetProfileCount(std::uint64_t *tid, std::uint8_t *out_count) {
|
||||||
if (!config::HasProfilesLoaded()) {
|
if (!file::config::HasProfilesLoaded()) {
|
||||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||||
}
|
}
|
||||||
*out_count = config::GetProfileCount(*tid);
|
*out_count = file::config::GetProfileCount(*tid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetProfiles(std::uint64_t *tid, HocClkTitleProfileList *out_profiles) {
|
Result GetProfiles(std::uint64_t *tid, HocClkTitleProfileList *out_profiles) {
|
||||||
if (!config::HasProfilesLoaded()) {
|
if (!file::config::HasProfilesLoaded()) {
|
||||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||||
}
|
}
|
||||||
config::GetProfiles(*tid, out_profiles);
|
file::config::GetProfiles(*tid, out_profiles);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result SetProfiles(HocClkIpc_SetProfiles_Args *args) {
|
Result SetProfiles(HocClkIpc_SetProfiles_Args *args) {
|
||||||
if (!config::HasProfilesLoaded()) {
|
if (!file::config::HasProfilesLoaded()) {
|
||||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||||
}
|
}
|
||||||
HocClkTitleProfileList profiles = args->profiles;
|
HocClkTitleProfileList profiles = args->profiles;
|
||||||
if (!config::SetProfiles(args->tid, &profiles, true)) {
|
if (!file::config::SetProfiles(args->tid, &profiles, true)) {
|
||||||
return HOCCLK_ERROR(ConfigSaveFailed);
|
return HOCCLK_ERROR(ConfigSaveFailed);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result SetEnabled(std::uint8_t *enabled) {
|
Result SetEnabled(std::uint8_t *enabled) {
|
||||||
config::SetEnabled(*enabled);
|
file::config::SetEnabled(*enabled);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,24 +106,24 @@ namespace ipcService {
|
|||||||
if (!HOCCLK_ENUM_VALID(HocClkModule, args->module)) {
|
if (!HOCCLK_ENUM_VALID(HocClkModule, args->module)) {
|
||||||
return HOCCLK_ERROR(Generic);
|
return HOCCLK_ERROR(Generic);
|
||||||
}
|
}
|
||||||
config::SetOverrideHz(args->module, args->hz);
|
file::config::SetOverrideHz(args->module, args->hz);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetConfigValuesHandler(HocClkConfigValueList *out_configValues) {
|
Result GetConfigValuesHandler(HocClkConfigValueList *out_configValues) {
|
||||||
if (!config::HasProfilesLoaded()) {
|
if (!file::config::HasProfilesLoaded()) {
|
||||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||||
}
|
}
|
||||||
config::GetConfigValues(out_configValues);
|
file::config::GetConfigValues(out_configValues);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result SetConfigValuesHandler(HocClkConfigValueList *configValues) {
|
Result SetConfigValuesHandler(HocClkConfigValueList *configValues) {
|
||||||
if (!config::HasProfilesLoaded()) {
|
if (!file::config::HasProfilesLoaded()) {
|
||||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||||
}
|
}
|
||||||
HocClkConfigValueList copy = *configValues;
|
HocClkConfigValueList copy = *configValues;
|
||||||
if (!config::SetConfigValues(©, true)) {
|
if (!file::config::SetConfigValues(©, true)) {
|
||||||
return HOCCLK_ERROR(ConfigSaveFailed);
|
return HOCCLK_ERROR(ConfigSaveFailed);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -136,12 +136,12 @@ namespace ipcService {
|
|||||||
if (args->maxCount != size / sizeof(*out_list)) {
|
if (args->maxCount != size / sizeof(*out_list)) {
|
||||||
return HOCCLK_ERROR(Generic);
|
return HOCCLK_ERROR(Generic);
|
||||||
}
|
}
|
||||||
clockManager::GetFreqList(args->module, out_list, args->maxCount, out_count);
|
mgr::GetFreqList(args->module, out_list, args->maxCount, out_count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result RequestGpuVoltage(HocClkIpc_RequestGpuVoltage_Args *args) {
|
Result RequestGpuVoltage(HocClkIpc_RequestGpuVoltage_Args *args) {
|
||||||
clockManager::ApplyGpuFreqVoltRequest(args->voltage, args->hz);
|
mgr::ApplyGpuFreqVoltRequest(args->voltage, args->hz);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ namespace ipcService {
|
|||||||
|
|
||||||
case HocClkIpcCmd_SetKipData:
|
case HocClkIpcCmd_SetKipData:
|
||||||
if (r->data.size >= 0) {
|
if (r->data.size >= 0) {
|
||||||
kip::SetKipData();
|
file::kip::SetKipData();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -260,7 +260,7 @@ namespace ipcService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rc != KERNELRESULT(ConnectionClosed)) {
|
if (rc != KERNELRESULT(ConnectionClosed)) {
|
||||||
fileUtils::LogLine("[ipc] ipcServerProcess: [0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc));
|
file::utils::LogLine("[ipc] ipcServerProcess: [0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,44 +120,44 @@ void __appExit(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
Result rc = fileUtils::Initialize();
|
Result rc = file::utils::Initialize();
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fatalThrow(rc);
|
fatalThrow(rc);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
config::Initialize();
|
file::config::Initialize();
|
||||||
config::Refresh(); // Get config from file
|
file::config::Refresh(); // Get config from file
|
||||||
|
|
||||||
board::Initialize();
|
board::Initialize();
|
||||||
processManagement::Initialize();
|
hos::InitializeProcessManagement();
|
||||||
|
|
||||||
processManagement::WaitForQLaunch();
|
hos::WaitForQLaunch();
|
||||||
|
|
||||||
clockManager::Initialize();
|
mgr::Initialize();
|
||||||
ipcService::Initialize();
|
ipcService::Initialize();
|
||||||
|
|
||||||
clockManager::SetRunning(true);
|
mgr::SetRunning(true);
|
||||||
config::SetEnabled(true);
|
file::config::SetEnabled(true);
|
||||||
ipcService::SetRunning(true);
|
ipcService::SetRunning(true);
|
||||||
// TemperaturePoint *table;
|
// TemperaturePoint *table;
|
||||||
// ReadConfigFile(&table);
|
// ReadConfigFile(&table);
|
||||||
// InitFanController(table);
|
// InitFanController(table);
|
||||||
// StartFanControllerThread();
|
// StartFanControllerThread();
|
||||||
|
|
||||||
while (clockManager::Running()) {
|
while (mgr::Running()) {
|
||||||
clockManager::Tick();
|
mgr::Tick();
|
||||||
clockManager::WaitForNextTick();
|
mgr::WaitForNextTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcService::SetRunning(false);
|
ipcService::SetRunning(false);
|
||||||
ipcService::Exit();
|
ipcService::Exit();
|
||||||
clockManager::Exit();
|
mgr::Exit();
|
||||||
processManagement::Exit();
|
hos::ExitProcessManagement();
|
||||||
board::Exit();
|
board::Exit();
|
||||||
config::Exit();
|
file::config::Exit();
|
||||||
fileUtils::LogLine("Exiting hoc-clk");
|
file::utils::LogLine("Exiting hoc-clk");
|
||||||
svcSleepThread(1000000ULL);
|
svcSleepThread(1000000ULL);
|
||||||
fileUtils::Exit();
|
file::utils::Exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size) {
|
|||||||
Result MapAddress(u64 &va, const u64 &physAddr, const char *name) {
|
Result MapAddress(u64 &va, const u64 &physAddr, const char *name) {
|
||||||
Result mapResult = QueryMemoryMapping(&va, physAddr, 0x1000);
|
Result mapResult = QueryMemoryMapping(&va, physAddr, 0x1000);
|
||||||
if (R_FAILED(mapResult)) {
|
if (R_FAILED(mapResult)) {
|
||||||
fileUtils::LogLine("Failed to map %s! %u", name, R_DESCRIPTION(mapResult));
|
file::utils::LogLine("Failed to map %s! %u", name, R_DESCRIPTION(mapResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapResult;
|
return mapResult;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0))
|
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0))
|
||||||
|
|
||||||
namespace clockManager {
|
namespace mgr {
|
||||||
|
|
||||||
bool gRunning = false;
|
bool gRunning = false;
|
||||||
LockableMutex gContextMutex;
|
LockableMutex gContextMutex;
|
||||||
@@ -74,7 +74,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t GetMaxAllowedHz(HocClkModule module, HocClkProfile profile) {
|
std::uint32_t GetMaxAllowedHz(HocClkModule module, HocClkProfile profile) {
|
||||||
if (config::GetConfigValue(HocClkConfigValue_UncappedClocks)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_UncappedClocks)) {
|
||||||
return ~0; // Integer limit, uncapped clocks ON
|
return ~0; // Integer limit, uncapped clocks ON
|
||||||
} else {
|
} else {
|
||||||
if (module == HocClkModule_GPU) {
|
if (module == HocClkModule_GPU) {
|
||||||
@@ -84,7 +84,7 @@ namespace clockManager {
|
|||||||
return 460800000;
|
return 460800000;
|
||||||
case HocClkSocType_Mariko:
|
case HocClkSocType_Mariko:
|
||||||
if (board::GetConsoleType() == HocClkConsoleType_Hoag) {
|
if (board::GetConsoleType() == HocClkConsoleType_Hoag) {
|
||||||
switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
switch (file::config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
||||||
case 0 ... 2:
|
case 0 ... 2:
|
||||||
return 614400000;
|
return 614400000;
|
||||||
case 3 ... 4:
|
case 3 ... 4:
|
||||||
@@ -93,7 +93,7 @@ namespace clockManager {
|
|||||||
return 614400000;
|
return 614400000;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
switch (file::config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
||||||
case 0:
|
case 0:
|
||||||
return 614400000;
|
return 614400000;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -116,7 +116,7 @@ namespace clockManager {
|
|||||||
case HocClkSocType_Erista:
|
case HocClkSocType_Erista:
|
||||||
return 768000000;
|
return 768000000;
|
||||||
case HocClkSocType_Mariko:
|
case HocClkSocType_Mariko:
|
||||||
switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
switch (file::config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
||||||
case 0:
|
case 0:
|
||||||
return 844800000;
|
return 844800000;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -165,19 +165,19 @@ namespace clockManager {
|
|||||||
|
|
||||||
void ResetToStockClocks() {
|
void ResetToStockClocks() {
|
||||||
board::ResetToStockCpu();
|
board::ResetToStockCpu();
|
||||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||||
if (board::GetSocType() == HocClkSocType_Erista)
|
if (board::GetSocType() == HocClkSocType_Erista)
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||||
else
|
else
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow), file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
||||||
board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
board::CalculateTbreak(file::config::GetConfigValue(KipConfigValue_tableConf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
board::ResetToStockGpu();
|
board::ResetToStockGpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigIntervalTimeout(HocClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t *lastLogNs) {
|
bool ConfigIntervalTimeout(HocClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t *lastLogNs) {
|
||||||
std::uint64_t logInterval = config::GetConfigValue(intervalMsConfigValue) * 1000000ULL;
|
std::uint64_t logInterval = file::config::GetConfigValue(intervalMsConfigValue) * 1000000ULL;
|
||||||
bool shouldLog = logInterval && ((ns - *lastLogNs) > logInterval);
|
bool shouldLog = logInterval && ((ns - *lastLogNs) > logInterval);
|
||||||
|
|
||||||
if (shouldLog) {
|
if (shouldLog) {
|
||||||
@@ -193,14 +193,14 @@ namespace clockManager {
|
|||||||
std::uint32_t freqs[HOCCLK_FREQ_LIST_MAX];
|
std::uint32_t freqs[HOCCLK_FREQ_LIST_MAX];
|
||||||
std::uint32_t count;
|
std::uint32_t count;
|
||||||
|
|
||||||
fileUtils::LogLine("[mgr] %s freq list refresh", board::GetModuleName(module, true));
|
file::utils::LogLine("[mgr] %s freq list refresh", board::GetModuleName(module, true));
|
||||||
board::GetFreqList(module, &freqs[0], HOCCLK_FREQ_LIST_MAX, &count);
|
board::GetFreqList(module, &freqs[0], HOCCLK_FREQ_LIST_MAX, &count);
|
||||||
|
|
||||||
std::uint32_t *hz = &gFreqTable[module].list[0];
|
std::uint32_t *hz = &gFreqTable[module].list[0];
|
||||||
gFreqTable[module].count = 0;
|
gFreqTable[module].count = 0;
|
||||||
|
|
||||||
if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Mariko &&
|
if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Mariko &&
|
||||||
config::GetConfigValue(HocClkConfigValue_MarikoMiddleFreqs)) {
|
file::config::GetConfigValue(HocClkConfigValue_MarikoMiddleFreqs)) {
|
||||||
constexpr u32 kStep = 38400000;
|
constexpr u32 kStep = 38400000;
|
||||||
constexpr u32 kPcvStep = 76800000;
|
constexpr u32 kPcvStep = 76800000;
|
||||||
u32 kMax = ~0;
|
u32 kMax = ~0;
|
||||||
@@ -282,7 +282,7 @@ namespace clockManager {
|
|||||||
bool skip = false;
|
bool skip = false;
|
||||||
for (auto &entry : eristaGpuVoltMap) {
|
for (auto &entry : eristaGpuVoltMap) {
|
||||||
if (entry.hz == freqs[i]) {
|
if (entry.hz == freqs[i]) {
|
||||||
if (config::GetConfigValue(entry.kval) == 2000) {
|
if (file::config::GetConfigValue(entry.kval) == 2000) {
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -293,7 +293,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
*hz = freqs[i];
|
*hz = freqs[i];
|
||||||
fileUtils::LogLine("[mgr] %02u - %u - %u.%u MHz", gFreqTable[module].count, *hz, *hz / 1000000, *hz / 100000 - *hz / 1000000 * 10);
|
file::utils::LogLine("[mgr] %02u - %u - %u.%u MHz", gFreqTable[module].count, *hz, *hz / 1000000, *hz / 100000 - *hz / 1000000 * 10);
|
||||||
|
|
||||||
gFreqTable[module].count++;
|
gFreqTable[module].count++;
|
||||||
hz++;
|
hz++;
|
||||||
@@ -303,8 +303,8 @@ namespace clockManager {
|
|||||||
constexpr u64 EmcClkOSLimitHz = 1600000ULL * 1000; // 1600 MHz
|
constexpr u64 EmcClkOSLimitHz = 1600000ULL * 1000; // 1600 MHz
|
||||||
const u64 maxHz = patchedEmcMaxClock * 1000;
|
const u64 maxHz = patchedEmcMaxClock * 1000;
|
||||||
if (module == HocClkModule_MEM && board::GetSocType() == HocClkSocType_Mariko &&
|
if (module == HocClkModule_MEM && board::GetSocType() == HocClkSocType_Mariko &&
|
||||||
kip::kipAvailable && maxHz >= EmcClkOSLimitHz &&
|
file::kip::kipAvailable && maxHz >= EmcClkOSLimitHz &&
|
||||||
config::GetConfigValue(KipConfigValue_stepMode) == 4 /* 33 MHz */) {
|
file::config::GetConfigValue(KipConfigValue_stepMode) == 4 /* 33 MHz */) {
|
||||||
|
|
||||||
/* Drop the clkrst entries above the OS limit */
|
/* Drop the clkrst entries above the OS limit */
|
||||||
u32 kept = 0;
|
u32 kept = 0;
|
||||||
@@ -340,12 +340,12 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUtils::LogLine("[mgr] count = %u", gFreqTable[module].count);
|
file::utils::LogLine("[mgr] count = %u", gFreqTable[module].count);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleSafetyFeatures(bool isBoost) {
|
bool HandleSafetyFeatures(bool isBoost) {
|
||||||
if (((tmp451TempSoc() / 1000) > (int)config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) &&
|
if (((tmp451TempSoc() / 1000) > (int)file::config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) &&
|
||||||
config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) {
|
file::config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) {
|
||||||
ResetToStockClocks();
|
ResetToStockClocks();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -359,19 +359,19 @@ namespace clockManager {
|
|||||||
if (++tick > 10) {
|
if (++tick > 10) {
|
||||||
tick = 0;
|
tick = 0;
|
||||||
|
|
||||||
if (config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)) {
|
||||||
I2c_Bq24193_SetFastChargeCurrentLimit(config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent));
|
I2c_Bq24193_SetFastChargeCurrentLimit(file::config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config::GetConfigValue(HocClkConfigValue_InputCurrentLimit)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_InputCurrentLimit)) {
|
||||||
I2c_Bq24193_SetInputCurrentLimit(config::GetConfigValue(HocClkConfigValue_InputCurrentLimit));
|
I2c_Bq24193_SetInputCurrentLimit(file::config::GetConfigValue(HocClkConfigValue_InputCurrentLimit));
|
||||||
}
|
}
|
||||||
|
|
||||||
I2c_BuckConverter_SetMvOut(&I2c_Display, config::GetConfigValue(HocClkConfigValue_DisplayVoltage));
|
I2c_BuckConverter_SetMvOut(&I2c_Display, file::config::GetConfigValue(HocClkConfigValue_DisplayVoltage));
|
||||||
|
|
||||||
if (board::GetConsoleType() == HocClkConsoleType_Aula)
|
if (board::GetConsoleType() == HocClkConsoleType_Aula)
|
||||||
AulaDisplay::SetDisplayColorMode((AulaColorMode)config::GetConfigValue(HocClkConfigValue_AulaDisplayColorPreset));
|
display::SetDisplayColorMode((AulaColorMode)file::config::GetConfigValue(HocClkConfigValue_AulaDisplayColorPreset));
|
||||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||||
board::HandleCpuUv();
|
board::HandleCpuUv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,9 +392,9 @@ namespace clockManager {
|
|||||||
u32 GetNearestOverrideHz(HocClkModule module) {
|
u32 GetNearestOverrideHz(HocClkModule module) {
|
||||||
u32 targetHz = gContext.overrideFreqs[module];
|
u32 targetHz = gContext.overrideFreqs[module];
|
||||||
if (!targetHz) {
|
if (!targetHz) {
|
||||||
targetHz = config::GetAutoClockHz(gContext.applicationId, module, gContext.profile, false);
|
targetHz = file::config::GetAutoClockHz(gContext.applicationId, module, gContext.profile, false);
|
||||||
if (!targetHz) {
|
if (!targetHz) {
|
||||||
targetHz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, module, gContext.profile, false);
|
targetHz = file::config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, module, gContext.profile, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ namespace clockManager {
|
|||||||
/* Apply nothing with disabled voltage. */
|
/* Apply nothing with disabled voltage. */
|
||||||
constexpr u32 DisabledVoltage = 2000;
|
constexpr u32 DisabledVoltage = 2000;
|
||||||
if (voltage == DisabledVoltage) {
|
if (voltage == DisabledVoltage) {
|
||||||
notification::writeNotification("Horizon OC\nDeactivated frequency.\nReboot to apply.");
|
hos::WriteNotification("Horizon OC\nDeactivated frequency.\nReboot to apply.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ApplyGpuDvfs(u32 targetHz) {
|
void ApplyGpuDvfs(u32 targetHz) {
|
||||||
s32 dvfsOffset = config::GetConfigValue(HocClkConfigValue_DVFSOffset);
|
s32 dvfsOffset = file::config::GetConfigValue(HocClkConfigValue_DVFSOffset);
|
||||||
dvfsOffset = std::max(dvfsOffset, -80);
|
dvfsOffset = std::max(dvfsOffset, -80);
|
||||||
u32 vmin = board::GetMinimumGpuVmin(targetHz / 1000000, board::GetGpuSpeedoBracket());
|
u32 vmin = board::GetMinimumGpuVmin(targetHz / 1000000, board::GetGpuSpeedoBracket());
|
||||||
|
|
||||||
@@ -450,7 +450,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DVFSReset() {
|
void DVFSReset() {
|
||||||
if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
board::PcvHijackGpuVolts(0); // Reset to vMin
|
board::PcvHijackGpuVolts(0); // Reset to vMin
|
||||||
|
|
||||||
u32 targetHz = GetNearestOverrideHz(HocClkModule_GPU);
|
u32 targetHz = GetNearestOverrideHz(HocClkModule_GPU);
|
||||||
@@ -464,15 +464,15 @@ namespace clockManager {
|
|||||||
void HandleFreqReset(HocClkModule module, bool isBoost, bool didHijackPcv) {
|
void HandleFreqReset(HocClkModule module, bool isBoost, bool didHijackPcv) {
|
||||||
switch (module) {
|
switch (module) {
|
||||||
case HocClkModule_CPU:
|
case HocClkModule_CPU:
|
||||||
if (!(isBoost || (config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost)))
|
if (!(isBoost || (file::config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost)))
|
||||||
board::ResetToStockCpu();
|
board::ResetToStockCpu();
|
||||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||||
if (board::GetSocType() == HocClkSocType_Erista)
|
if (board::GetSocType() == HocClkSocType_Erista)
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||||
else
|
else
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow),
|
board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow),
|
||||||
config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
||||||
board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
board::CalculateTbreak(file::config::GetConfigValue(KipConfigValue_tableConf)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HocClkModule_GPU:
|
case HocClkModule_GPU:
|
||||||
@@ -486,7 +486,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HocClkModule_Display:
|
case HocClkModule_Display:
|
||||||
if (config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate)) {
|
||||||
board::ResetToStockDisplay();
|
board::ResetToStockDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -505,7 +505,7 @@ namespace clockManager {
|
|||||||
u32 nearestFreq = GetCurrentNearestFrequency(HocClkModule_MEM);
|
u32 nearestFreq = GetCurrentNearestFrequency(HocClkModule_MEM);
|
||||||
|
|
||||||
if (targetRamHz != nearestFreq) {
|
if (targetRamHz != nearestFreq) {
|
||||||
if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
ApplyGpuDvfs(targetRamHz);
|
ApplyGpuDvfs(targetRamHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ namespace clockManager {
|
|||||||
static bool prepareBoostExit = false;
|
static bool prepareBoostExit = false;
|
||||||
|
|
||||||
bool didHijackPcv = false;
|
bool didHijackPcv = false;
|
||||||
bool skipCpuDueToBoost = isBoost && !config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode);
|
bool skipCpuDueToBoost = isBoost && !file::config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode);
|
||||||
if (skipCpuDueToBoost) {
|
if (skipCpuDueToBoost) {
|
||||||
board::SetHz(HocClkModule_CPU, board::GetHz(HocClkModule_CPU));
|
board::SetHz(HocClkModule_CPU, board::GetHz(HocClkModule_CPU));
|
||||||
prepareBoostExit = true;
|
prepareBoostExit = true;
|
||||||
@@ -545,22 +545,22 @@ namespace clockManager {
|
|||||||
returnRaw = false;
|
returnRaw = false;
|
||||||
targetHz = gContext.overrideFreqs[module];
|
targetHz = gContext.overrideFreqs[module];
|
||||||
if (!targetHz) {
|
if (!targetHz) {
|
||||||
targetHz = config::GetAutoClockHz(gContext.applicationId, (HocClkModule)module, gContext.profile, returnRaw);
|
targetHz = file::config::GetAutoClockHz(gContext.applicationId, (HocClkModule)module, gContext.profile, returnRaw);
|
||||||
if (!targetHz)
|
if (!targetHz)
|
||||||
targetHz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, (HocClkModule)module, gContext.profile, returnRaw);
|
targetHz = file::config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, (HocClkModule)module, gContext.profile, returnRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module == HocClkModule_Governor) {
|
if (module == HocClkModule_Governor) {
|
||||||
governor::HandleGovernor(targetHz);
|
mgr::HandleGovernor(targetHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool noCPU = governor::isCpuGovernorEnabled;
|
bool noCPU = mgr::isCpuGovernorEnabled;
|
||||||
bool noGPU = governor::isGpuGovernorEnabled;
|
bool noGPU = mgr::isGpuGovernorEnabled;
|
||||||
bool noDisp = governor::isVRREnabled;
|
bool noDisp = mgr::isVRREnabled;
|
||||||
if (noDisp && module == HocClkModule_Display)
|
if (noDisp && module == HocClkModule_Display)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (module == HocClkModule_Display && config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate) && !noDisp) {
|
if (module == HocClkModule_Display && file::config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate) && !noDisp) {
|
||||||
if (targetHz) {
|
if (targetHz) {
|
||||||
board::SetHz(HocClkModule_Display, targetHz);
|
board::SetHz(HocClkModule_Display, targetHz);
|
||||||
gContext.freqs[HocClkModule_Display] = targetHz;
|
gContext.freqs[HocClkModule_Display] = targetHz;
|
||||||
@@ -584,11 +584,11 @@ namespace clockManager {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
u32 autoCpuOcHz = 0;
|
u32 autoCpuOcHz = 0;
|
||||||
if (module == HocClkModule_CPU && config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock) && !isBoost &&
|
if (module == HocClkModule_CPU && file::config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock) && !isBoost &&
|
||||||
!governor::isCpuGovernorEnabled && (board::GetSocType() == HocClkSocType_Mariko)) {
|
!mgr::isCpuGovernorEnabled && (board::GetSocType() == HocClkSocType_Mariko)) {
|
||||||
u32 threshold = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000;
|
u32 threshold = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000;
|
||||||
if (ramTargetHz >= threshold)
|
if (ramTargetHz >= threshold)
|
||||||
autoCpuOcHz = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000;
|
autoCpuOcHz = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetHz || autoCpuOcHz) {
|
if (targetHz || autoCpuOcHz) {
|
||||||
@@ -599,12 +599,12 @@ namespace clockManager {
|
|||||||
nearestHz = GetNearestHz(HocClkModule_CPU, autoCpuOcHz, maxHz);
|
nearestHz = GetNearestHz(HocClkModule_CPU, autoCpuOcHz, maxHz);
|
||||||
|
|
||||||
if (nearestHz != gContext.freqs[module]) {
|
if (nearestHz != gContext.freqs[module]) {
|
||||||
fileUtils::LogLine("[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)", board::GetModuleName((HocClkModule)module, true),
|
file::utils::LogLine("[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)", board::GetModuleName((HocClkModule)module, true),
|
||||||
nearestHz / 1000000, nearestHz / 100000 - nearestHz / 1000000 * 10, targetHz / 1000000,
|
nearestHz / 1000000, nearestHz / 100000 - nearestHz / 1000000 * 10, targetHz / 1000000,
|
||||||
targetHz / 100000 - targetHz / 1000000 * 10);
|
targetHz / 100000 - targetHz / 1000000 * 10);
|
||||||
|
|
||||||
// The logic MUST be done in this order otherwise you WILL get crashes
|
// The logic MUST be done in this order otherwise you WILL get crashes
|
||||||
if (module == HocClkModule_MEM && targetHz > oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (module == HocClkModule_MEM && targetHz > oldHz && file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
ApplyGpuDvfs(targetHz);
|
ApplyGpuDvfs(targetHz);
|
||||||
}
|
}
|
||||||
board::SetHz((HocClkModule)module, nearestHz);
|
board::SetHz((HocClkModule)module, nearestHz);
|
||||||
@@ -614,11 +614,11 @@ namespace clockManager {
|
|||||||
gContext.stable.freqs[module] = nearestHz;
|
gContext.stable.freqs[module] = nearestHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module == HocClkModule_MEM && targetHz < oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (module == HocClkModule_MEM && targetHz < oldHz && file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
ApplyGpuDvfs(targetHz);
|
ApplyGpuDvfs(targetHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module == HocClkModule_MEM && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack)
|
if (module == HocClkModule_MEM && file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack)
|
||||||
didHijackPcv = false;
|
didHijackPcv = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -636,16 +636,16 @@ namespace clockManager {
|
|||||||
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
|
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
|
||||||
ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration");
|
ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration");
|
||||||
|
|
||||||
std::uint64_t applicationId = processManagement::GetCurrentApplicationId();
|
std::uint64_t applicationId = hos::GetCurrentApplicationId();
|
||||||
if (applicationId != gContext.applicationId) {
|
if (applicationId != gContext.applicationId) {
|
||||||
fileUtils::LogLine("[mgr] TitleID change: %016lX", applicationId);
|
file::utils::LogLine("[mgr] TitleID change: %016lX", applicationId);
|
||||||
gContext.applicationId = applicationId;
|
gContext.applicationId = applicationId;
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HocClkProfile profile = board::GetProfile();
|
HocClkProfile profile = board::GetProfile();
|
||||||
if (profile != gContext.profile) {
|
if (profile != gContext.profile) {
|
||||||
fileUtils::LogLine("[mgr] Profile change: %s", board::GetProfileName(profile, true));
|
file::utils::LogLine("[mgr] Profile change: %s", board::GetProfileName(profile, true));
|
||||||
gContext.profile = profile;
|
gContext.profile = profile;
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
@@ -653,7 +653,7 @@ namespace clockManager {
|
|||||||
// restore clocks to stock values on app or profile change
|
// restore clocks to stock values on app or profile change
|
||||||
if (hasChanged) {
|
if (hasChanged) {
|
||||||
board::ResetToStock();
|
board::ResetToStock();
|
||||||
if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
board::PcvHijackGpuVolts(0);
|
board::PcvHijackGpuVolts(0);
|
||||||
board::ResetToStockGpu();
|
board::ResetToStockGpu();
|
||||||
}
|
}
|
||||||
@@ -664,7 +664,7 @@ namespace clockManager {
|
|||||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||||
hz = board::GetHz((HocClkModule)module);
|
hz = board::GetHz((HocClkModule)module);
|
||||||
if (hz != 0 && hz != gContext.freqs[module]) {
|
if (hz != 0 && hz != gContext.freqs[module]) {
|
||||||
fileUtils::LogLine("[mgr] %s clock change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000,
|
file::utils::LogLine("[mgr] %s clock change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000,
|
||||||
hz / 100000 - hz / 1000000 * 10);
|
hz / 100000 - hz / 1000000 * 10);
|
||||||
gContext.freqs[module] = hz;
|
gContext.freqs[module] = hz;
|
||||||
|
|
||||||
@@ -674,10 +674,10 @@ namespace clockManager {
|
|||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
hz = config::GetOverrideHz((HocClkModule)module);
|
hz = file::config::GetOverrideHz((HocClkModule)module);
|
||||||
if (hz != gContext.overrideFreqs[module]) {
|
if (hz != gContext.overrideFreqs[module]) {
|
||||||
if (hz) {
|
if (hz) {
|
||||||
fileUtils::LogLine("[mgr] %s override change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000,
|
file::utils::LogLine("[mgr] %s override change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000,
|
||||||
hz / 100000 - hz / 1000000 * 10);
|
hz / 100000 - hz / 1000000 * 10);
|
||||||
}
|
}
|
||||||
gContext.overrideFreqs[module] = hz;
|
gContext.overrideFreqs[module] = hz;
|
||||||
@@ -697,7 +697,7 @@ namespace clockManager {
|
|||||||
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
||||||
millis = board::GetTemperatureMilli((HocClkThermalSensor)sensor);
|
millis = board::GetTemperatureMilli((HocClkThermalSensor)sensor);
|
||||||
if (shouldLogTemp) {
|
if (shouldLogTemp) {
|
||||||
fileUtils::LogLine("[mgr] %s temp: %u.%u °C", board::GetThermalSensorName((HocClkThermalSensor)sensor, true), millis / 1000,
|
file::utils::LogLine("[mgr] %s temp: %u.%u °C", board::GetThermalSensorName((HocClkThermalSensor)sensor, true), millis / 1000,
|
||||||
(millis - millis / 1000 * 1000) / 100);
|
(millis - millis / 1000 * 1000) / 100);
|
||||||
}
|
}
|
||||||
gContext.temps[sensor] = millis;
|
gContext.temps[sensor] = millis;
|
||||||
@@ -713,7 +713,7 @@ namespace clockManager {
|
|||||||
for (unsigned int sensor = 0; sensor < HocClkPowerSensor_EnumMax; sensor++) {
|
for (unsigned int sensor = 0; sensor < HocClkPowerSensor_EnumMax; sensor++) {
|
||||||
mw = board::GetPowerMw((HocClkPowerSensor)sensor);
|
mw = board::GetPowerMw((HocClkPowerSensor)sensor);
|
||||||
if (shouldLogPower) {
|
if (shouldLogPower) {
|
||||||
fileUtils::LogLine("[mgr] Power %s: %d mW", board::GetPowerSensorName((HocClkPowerSensor)sensor, false), mw);
|
file::utils::LogLine("[mgr] Power %s: %d mW", board::GetPowerSensorName((HocClkPowerSensor)sensor, false), mw);
|
||||||
}
|
}
|
||||||
gContext.power[sensor] = mw;
|
gContext.power[sensor] = mw;
|
||||||
|
|
||||||
@@ -728,7 +728,7 @@ namespace clockManager {
|
|||||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||||
realHz = board::GetRealHz((HocClkModule)module);
|
realHz = board::GetRealHz((HocClkModule)module);
|
||||||
if (shouldLogFreq) {
|
if (shouldLogFreq) {
|
||||||
fileUtils::LogLine("[mgr] %s real freq: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), realHz / 1000000,
|
file::utils::LogLine("[mgr] %s real freq: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), realHz / 1000000,
|
||||||
realHz / 100000 - realHz / 1000000 * 10);
|
realHz / 100000 - realHz / 1000000 * 10);
|
||||||
}
|
}
|
||||||
gContext.realFreqs[module] = realHz;
|
gContext.realFreqs[module] = realHz;
|
||||||
@@ -756,27 +756,27 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigIntervalTimeout(HocClkConfigValue_CsvWriteIntervalMs, ns, &gLastCsvWriteNs)) {
|
if (ConfigIntervalTimeout(HocClkConfigValue_CsvWriteIntervalMs, ns, &gLastCsvWriteNs)) {
|
||||||
fileUtils::WriteContextToCsv(&gContext);
|
file::utils::WriteContextToCsv(&gContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this->context->maxDisplayFreq = board::GetHighestDockedDisplayRate();
|
// this->context->maxDisplayFreq = board::GetHighestDockedDisplayRate();
|
||||||
u32 targetHz = gContext.overrideFreqs[HocClkModule_Display];
|
u32 targetHz = gContext.overrideFreqs[HocClkModule_Display];
|
||||||
if (!targetHz) {
|
if (!targetHz) {
|
||||||
targetHz = config::GetAutoClockHz(gContext.applicationId, HocClkModule_Display, gContext.profile, true);
|
targetHz = file::config::GetAutoClockHz(gContext.applicationId, HocClkModule_Display, gContext.profile, true);
|
||||||
if (!targetHz)
|
if (!targetHz)
|
||||||
targetHz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Display, gContext.profile, true);
|
targetHz = file::config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Display, gContext.profile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (board::GetConsoleType() != HocClkConsoleType_Hoag)
|
if (board::GetConsoleType() != HocClkConsoleType_Hoag)
|
||||||
board::SetDisplayRefreshDockedState(gContext.profile == HocClkProfile_Docked);
|
board::SetDisplayRefreshDockedState(gContext.profile == HocClkProfile_Docked);
|
||||||
|
|
||||||
if (gContext.isSaltyNXInstalled)
|
if (gContext.isSaltyNXInstalled)
|
||||||
gContext.fps = integrations::GetSaltyNXFPS();
|
gContext.fps = hos::GetSaltyNXFPS();
|
||||||
else
|
else
|
||||||
gContext.fps = 254; // N/A
|
gContext.fps = 254; // N/A
|
||||||
|
|
||||||
if (gContext.isSaltyNXInstalled)
|
if (gContext.isSaltyNXInstalled)
|
||||||
gContext.resolutionHeight = integrations::GetSaltyNXResolutionHeight();
|
gContext.resolutionHeight = hos::GetSaltyNXResolutionHeight();
|
||||||
else
|
else
|
||||||
gContext.resolutionHeight = 0; // N/A
|
gContext.resolutionHeight = 0; // N/A
|
||||||
|
|
||||||
@@ -790,7 +790,7 @@ namespace clockManager {
|
|||||||
|
|
||||||
/* Load the KIP customize table before building the freq tables: the MEM freq-list
|
/* Load the KIP customize table before building the freq tables: the MEM freq-list
|
||||||
synthesis in RefreshFreqTableRow reads marikoEmcMaxClock / stepMode from it. */
|
synthesis in RefreshFreqTableRow reads marikoEmcMaxClock / stepMode from it. */
|
||||||
kip::GetKipData();
|
file::kip::GetKipData();
|
||||||
|
|
||||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||||
gContext.freqs[module] = 0;
|
gContext.freqs[module] = 0;
|
||||||
@@ -824,23 +824,23 @@ namespace clockManager {
|
|||||||
gContext.dramID = board::GetDramID();
|
gContext.dramID = board::GetDramID();
|
||||||
gContext.isDram8GB = board::IsDram8GB();
|
gContext.isDram8GB = board::IsDram8GB();
|
||||||
gContext.consoleType = board::GetConsoleType();
|
gContext.consoleType = board::GetConsoleType();
|
||||||
gContext.isFirstLoad = config::GetConfigValue(HocClkConfigValue_IsFirstLoad);
|
gContext.isFirstLoad = file::config::GetConfigValue(HocClkConfigValue_IsFirstLoad);
|
||||||
|
|
||||||
board::SetGpuSchedulingMode((GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling),
|
board::SetGpuSchedulingMode((GpuSchedulingMode)file::config::GetConfigValue(HocClkConfigValue_GPUScheduling),
|
||||||
(GpuSchedulingOverrideMethod)config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod));
|
(GpuSchedulingOverrideMethod)file::config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod));
|
||||||
gContext.gpuSchedulingMode = (GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling);
|
gContext.gpuSchedulingMode = (GpuSchedulingMode)file::config::GetConfigValue(HocClkConfigValue_GPUScheduling);
|
||||||
|
|
||||||
gContext.isSysDockInstalled = integrations::GetSysDockState();
|
gContext.isSysDockInstalled = hos::GetSysDockState();
|
||||||
gContext.isSaltyNXInstalled = integrations::GetSaltyNXState();
|
gContext.isSaltyNXInstalled = hos::GetSaltyNXState();
|
||||||
if (gContext.isSaltyNXInstalled) {
|
if (gContext.isSaltyNXInstalled) {
|
||||||
integrations::LoadSaltyNX();
|
hos::LoadSaltyNX();
|
||||||
}
|
}
|
||||||
|
|
||||||
governor::startThreads();
|
mgr::StartThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Exit() {
|
void Exit() {
|
||||||
governor::exitThreads();
|
mgr::ExitThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
HocClkContext GetCurrentContext() {
|
HocClkContext GetCurrentContext() {
|
||||||
@@ -875,7 +875,7 @@ namespace clockManager {
|
|||||||
HandleMiscFeatures();
|
HandleMiscFeatures();
|
||||||
|
|
||||||
// GPU clock should always be the same unless PCV has overwriten our change, so reset it
|
// GPU clock should always be the same unless PCV has overwriten our change, so reset it
|
||||||
if ((RefreshContext() || config::Refresh() || (board::GetRealHz(HocClkModule_GPU) != gContext.freqs[HocClkModule_GPU])) &&
|
if ((RefreshContext() || file::config::Refresh() || (board::GetRealHz(HocClkModule_GPU) != gContext.freqs[HocClkModule_GPU])) &&
|
||||||
!shouldSkipClockSet) {
|
!shouldSkipClockSet) {
|
||||||
SetClocks(isBoost);
|
SetClocks(isBoost);
|
||||||
}
|
}
|
||||||
@@ -888,8 +888,8 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (board::GetHz(HocClkModule_MEM) > 665000000)
|
if (board::GetHz(HocClkModule_MEM) > 665000000)
|
||||||
svcSleepThread(config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
svcSleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
||||||
else
|
else
|
||||||
svcSleepThread(5000 * 1000000ULL); // 5 seconds in sleep mode
|
svcSleepThread(5000 * 1000000ULL); // 5 seconds in sleep mode
|
||||||
}
|
}
|
||||||
} // namespace clockManager
|
} // namespace mgr
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "../util/lockable_mutex.h"
|
#include "../util/lockable_mutex.h"
|
||||||
|
|
||||||
namespace clockManager {
|
namespace mgr {
|
||||||
|
|
||||||
struct FreqTable {
|
struct FreqTable {
|
||||||
std::uint32_t count;
|
std::uint32_t count;
|
||||||
@@ -68,4 +68,4 @@ namespace clockManager {
|
|||||||
|
|
||||||
void Tick();
|
void Tick();
|
||||||
void WaitForNextTick();
|
void WaitForNextTick();
|
||||||
} // namespace clockManager
|
} // namespace mgr
|
||||||
@@ -19,25 +19,25 @@
|
|||||||
#include "governor.hpp"
|
#include "governor.hpp"
|
||||||
#include <hocclk/clock_manager.h>
|
#include <hocclk/clock_manager.h>
|
||||||
|
|
||||||
namespace governor {
|
namespace mgr {
|
||||||
|
|
||||||
#define DOWN_HOLD_TICKS_DEFAULT 10 // 50 ms at 5ms poll – how long to hold while ramping down
|
#define DOWN_HOLD_TICKS_DEFAULT 10 // 50 ms at 5ms poll – how long to hold while ramping down
|
||||||
#define STEP_UTIL_DEFAULT 900 // multiplier for step calculations (max freq at 90% load)
|
#define STEP_UTIL_DEFAULT 900 // multiplier for step calculations (max freq at 90% load)
|
||||||
|
|
||||||
u64 GovernorPollNs() {
|
u64 GovernorPollNs() {
|
||||||
u64 ms = config::GetConfigValue(HocClkConfigValue_GovernorPollRateMs);
|
u64 ms = file::config::GetConfigValue(HocClkConfigValue_GovernorPollRateMs);
|
||||||
if (ms < 1 || ms > 50)
|
if (ms < 1 || ms > 50)
|
||||||
ms = 5;
|
ms = 5;
|
||||||
return ms * 1'000'000ULL;
|
return ms * 1'000'000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GovernorDownHoldTicks() {
|
u32 GovernorDownHoldTicks() {
|
||||||
u64 ticks = config::GetConfigValue(HocClkConfigValue_GovernorDownHoldTicks);
|
u64 ticks = file::config::GetConfigValue(HocClkConfigValue_GovernorDownHoldTicks);
|
||||||
return (ticks <= 100) ? (u32)ticks : DOWN_HOLD_TICKS_DEFAULT;
|
return (ticks <= 100) ? (u32)ticks : DOWN_HOLD_TICKS_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GovernorStepUtil() {
|
u32 GovernorStepUtil() {
|
||||||
u64 step = config::GetConfigValue(HocClkConfigValue_GovernorStepUtil);
|
u64 step = file::config::GetConfigValue(HocClkConfigValue_GovernorStepUtil);
|
||||||
if (step < 100 || step > 1500)
|
if (step < 100 || step > 1500)
|
||||||
step = STEP_UTIL_DEFAULT;
|
step = STEP_UTIL_DEFAULT;
|
||||||
return (u32)step;
|
return (u32)step;
|
||||||
@@ -55,11 +55,11 @@ namespace governor {
|
|||||||
Thread governorTHREAD;
|
Thread governorTHREAD;
|
||||||
|
|
||||||
void HandleGovernor(uint32_t targetHz) {
|
void HandleGovernor(uint32_t targetHz) {
|
||||||
u32 tempTargetHz = clockManager::gContext.overrideFreqs[HocClkModule_Governor];
|
u32 tempTargetHz = mgr::gContext.overrideFreqs[HocClkModule_Governor];
|
||||||
if (!tempTargetHz) {
|
if (!tempTargetHz) {
|
||||||
tempTargetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Governor, clockManager::gContext.profile, true);
|
tempTargetHz = file::config::GetAutoClockHz(mgr::gContext.applicationId, HocClkModule_Governor, mgr::gContext.profile, true);
|
||||||
if (!tempTargetHz)
|
if (!tempTargetHz)
|
||||||
tempTargetHz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Governor, clockManager::gContext.profile, true);
|
tempTargetHz = file::config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Governor, mgr::gContext.profile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto resolve = [](u8 app, u8 temp) -> u8 {
|
auto resolve = [](u8 app, u8 temp) -> u8 {
|
||||||
@@ -91,7 +91,7 @@ namespace governor {
|
|||||||
|
|
||||||
if (newCpuGovernorState != lastCpuGovernorState || newGpuGovernorState != lastGpuGovernorState ||
|
if (newCpuGovernorState != lastCpuGovernorState || newGpuGovernorState != lastGpuGovernorState ||
|
||||||
newVrrGovernorState != lastVrrGovernorState) {
|
newVrrGovernorState != lastVrrGovernorState) {
|
||||||
fileUtils::LogLine("[mgr] Governor state changed: CPU %s, GPU %s, VRR %s", newCpuGovernorState ? "enabled" : "disabled",
|
file::utils::LogLine("[mgr] Governor state changed: CPU %s, GPU %s, VRR %s", newCpuGovernorState ? "enabled" : "disabled",
|
||||||
newGpuGovernorState ? "enabled" : "disabled", newVrrGovernorState ? "enabled" : "disabled");
|
newGpuGovernorState ? "enabled" : "disabled", newVrrGovernorState ? "enabled" : "disabled");
|
||||||
lastCpuGovernorState = newCpuGovernorState;
|
lastCpuGovernorState = newCpuGovernorState;
|
||||||
lastGpuGovernorState = newGpuGovernorState;
|
lastGpuGovernorState = newGpuGovernorState;
|
||||||
@@ -104,7 +104,7 @@ namespace governor {
|
|||||||
return (u32)(std::min(hz, static_cast<u64>(tableMaxHz)));
|
return (u32)(std::min(hz, static_cast<u64>(tableMaxHz)));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TableIndexForHz(const clockManager::FreqTable &table, u32 targetHz) {
|
u32 TableIndexForHz(const mgr::FreqTable &table, u32 targetHz) {
|
||||||
for (u32 i = 0; i < table.count; i++)
|
for (u32 i = 0; i < table.count; i++)
|
||||||
if (table.list[i] >= targetHz)
|
if (table.list[i] >= targetHz)
|
||||||
return i;
|
return i;
|
||||||
@@ -112,11 +112,11 @@ namespace governor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u32 ResolveTargetHz(HocClkModule module) {
|
u32 ResolveTargetHz(HocClkModule module) {
|
||||||
u32 hz = clockManager::gContext.overrideFreqs[module];
|
u32 hz = mgr::gContext.overrideFreqs[module];
|
||||||
if (!hz)
|
if (!hz)
|
||||||
hz = config::GetAutoClockHz(clockManager::gContext.applicationId, module, clockManager::gContext.profile, false);
|
hz = file::config::GetAutoClockHz(mgr::gContext.applicationId, module, mgr::gContext.profile, false);
|
||||||
if (!hz)
|
if (!hz)
|
||||||
hz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, module, clockManager::gContext.profile, false);
|
hz = file::config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, module, mgr::gContext.profile, false);
|
||||||
return hz;
|
return hz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ namespace governor {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
const u64 pollNs = GovernorPollNs();
|
const u64 pollNs = GovernorPollNs();
|
||||||
|
|
||||||
if (!clockManager::gRunning) {
|
if (!mgr::gRunning) {
|
||||||
cpuDownHoldRemaining = 0;
|
cpuDownHoldRemaining = 0;
|
||||||
cpuLastHz = 0;
|
cpuLastHz = 0;
|
||||||
gpuDownHoldRemaining = 0;
|
gpuDownHoldRemaining = 0;
|
||||||
@@ -155,14 +155,14 @@ namespace governor {
|
|||||||
} else {
|
} else {
|
||||||
isCpuGovernorInBoostMode = false;
|
isCpuGovernorInBoostMode = false;
|
||||||
|
|
||||||
auto &table = clockManager::gFreqTable[HocClkModule_CPU];
|
auto &table = mgr::gFreqTable[HocClkModule_CPU];
|
||||||
std::scoped_lock lock{ clockManager::gContextMutex };
|
std::scoped_lock lock{ mgr::gContextMutex };
|
||||||
|
|
||||||
u32 cpuLoad = board::GetPartLoad(HocClkPartLoad_CPUMax);
|
u32 cpuLoad = board::GetPartLoad(HocClkPartLoad_CPUMax);
|
||||||
u32 tableMaxHz = table.list[table.count - 1];
|
u32 tableMaxHz = table.list[table.count - 1];
|
||||||
u32 desiredHz = SchedutilTargetHz(cpuLoad, tableMaxHz);
|
u32 desiredHz = SchedutilTargetHz(cpuLoad, tableMaxHz);
|
||||||
u32 targetHz = ResolveTargetHz(HocClkModule_CPU);
|
u32 targetHz = ResolveTargetHz(HocClkModule_CPU);
|
||||||
u32 maxHz = clockManager::GetMaxAllowedHz(HocClkModule_CPU, clockManager::gContext.profile);
|
u32 maxHz = mgr::GetMaxAllowedHz(HocClkModule_CPU, mgr::gContext.profile);
|
||||||
|
|
||||||
if (targetHz && desiredHz > targetHz)
|
if (targetHz && desiredHz > targetHz)
|
||||||
desiredHz = targetHz;
|
desiredHz = targetHz;
|
||||||
@@ -181,12 +181,12 @@ namespace governor {
|
|||||||
cpuDownHoldRemaining--;
|
cpuDownHoldRemaining--;
|
||||||
|
|
||||||
if (++cpuTick > 50) {
|
if (++cpuTick > 50) {
|
||||||
minHz = config::GetConfigValue(HocClkConfigValue_CpuGovernorMinimumFreq);
|
minHz = file::config::GetConfigValue(HocClkConfigValue_CpuGovernorMinimumFreq);
|
||||||
if (config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock)) {
|
if (file::config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock)) {
|
||||||
u32 ramHz = clockManager::gContext.freqs[HocClkModule_MEM];
|
u32 ramHz = mgr::gContext.freqs[HocClkModule_MEM];
|
||||||
u32 threshold = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000;
|
u32 threshold = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000;
|
||||||
if (ramHz >= threshold) {
|
if (ramHz >= threshold) {
|
||||||
u32 overrideHz = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000;
|
u32 overrideHz = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000;
|
||||||
if (overrideHz > minHz)
|
if (overrideHz > minHz)
|
||||||
minHz = overrideHz;
|
minHz = overrideHz;
|
||||||
}
|
}
|
||||||
@@ -197,10 +197,10 @@ namespace governor {
|
|||||||
if (newHz < minHz)
|
if (newHz < minHz)
|
||||||
newHz = minHz;
|
newHz = minHz;
|
||||||
|
|
||||||
if ((!goingDown || (cpuDownHoldRemaining == 0)) && clockManager::IsAssignableHz(HocClkModule_CPU, newHz)) {
|
if ((!goingDown || (cpuDownHoldRemaining == 0)) && mgr::IsAssignableHz(HocClkModule_CPU, newHz)) {
|
||||||
board::SetHz(HocClkModule_CPU, newHz);
|
board::SetHz(HocClkModule_CPU, newHz);
|
||||||
clockManager::gContext.freqs[HocClkModule_CPU] = newHz;
|
mgr::gContext.freqs[HocClkModule_CPU] = newHz;
|
||||||
clockManager::gContext.stable.freqs[HocClkModule_CPU] = newHz;
|
mgr::gContext.stable.freqs[HocClkModule_CPU] = newHz;
|
||||||
cpuLastHz = newHz;
|
cpuLastHz = newHz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,14 +211,14 @@ namespace governor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isGpuGovernorEnabled) {
|
if (isGpuGovernorEnabled) {
|
||||||
auto &table = clockManager::gFreqTable[HocClkModule_GPU];
|
auto &table = mgr::gFreqTable[HocClkModule_GPU];
|
||||||
std::scoped_lock lock{ clockManager::gContextMutex };
|
std::scoped_lock lock{ mgr::gContextMutex };
|
||||||
|
|
||||||
u32 gpuLoad = board::GetPartLoad(HocClkPartLoad_GPU);
|
u32 gpuLoad = board::GetPartLoad(HocClkPartLoad_GPU);
|
||||||
u32 tableMaxHz = table.list[table.count - 1];
|
u32 tableMaxHz = table.list[table.count - 1];
|
||||||
u32 desiredHz = SchedutilTargetHz(gpuLoad, tableMaxHz);
|
u32 desiredHz = SchedutilTargetHz(gpuLoad, tableMaxHz);
|
||||||
u32 targetHz = ResolveTargetHz(HocClkModule_GPU);
|
u32 targetHz = ResolveTargetHz(HocClkModule_GPU);
|
||||||
u32 maxHz = clockManager::GetMaxAllowedHz(HocClkModule_GPU, clockManager::gContext.profile);
|
u32 maxHz = mgr::GetMaxAllowedHz(HocClkModule_GPU, mgr::gContext.profile);
|
||||||
|
|
||||||
if (targetHz && desiredHz > targetHz)
|
if (targetHz && desiredHz > targetHz)
|
||||||
desiredHz = targetHz;
|
desiredHz = targetHz;
|
||||||
@@ -236,10 +236,10 @@ namespace governor {
|
|||||||
if (gpuDownHoldRemaining > 0)
|
if (gpuDownHoldRemaining > 0)
|
||||||
gpuDownHoldRemaining--;
|
gpuDownHoldRemaining--;
|
||||||
|
|
||||||
if ((!goingDown || (gpuDownHoldRemaining == 0)) && clockManager::IsAssignableHz(HocClkModule_GPU, newHz)) {
|
if ((!goingDown || (gpuDownHoldRemaining == 0)) && mgr::IsAssignableHz(HocClkModule_GPU, newHz)) {
|
||||||
board::SetHz(HocClkModule_GPU, newHz);
|
board::SetHz(HocClkModule_GPU, newHz);
|
||||||
clockManager::gContext.freqs[HocClkModule_GPU] = newHz;
|
mgr::gContext.freqs[HocClkModule_GPU] = newHz;
|
||||||
clockManager::gContext.stable.freqs[HocClkModule_GPU] = newHz;
|
mgr::gContext.stable.freqs[HocClkModule_GPU] = newHz;
|
||||||
gpuLastHz = newHz;
|
gpuLastHz = newHz;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -247,13 +247,13 @@ namespace governor {
|
|||||||
gpuLastHz = 0;
|
gpuLastHz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVRREnabled && clockManager::gContext.profile != HocClkProfile_Docked && clockManager::gContext.isSaltyNXInstalled) {
|
if (isVRREnabled && mgr::gContext.profile != HocClkProfile_Docked && mgr::gContext.isSaltyNXInstalled) {
|
||||||
bool skipVrr = false;
|
bool skipVrr = false;
|
||||||
|
|
||||||
if (++vrrFocusTick > 100) {
|
if (++vrrFocusTick > 100) {
|
||||||
vrrFocusTick = 0;
|
vrrFocusTick = 0;
|
||||||
bool isApplicationOutOfFocus = false;
|
bool isApplicationOutOfFocus = false;
|
||||||
Result rc = processManagement::isApplicationOutOfFocus(&isApplicationOutOfFocus);
|
Result rc = hos::IsApplicationOutOfFocus(&isApplicationOutOfFocus);
|
||||||
if (R_FAILED(rc) || isApplicationOutOfFocus) {
|
if (R_FAILED(rc) || isApplicationOutOfFocus) {
|
||||||
board::ResetToStockDisplay();
|
board::ResetToStockDisplay();
|
||||||
skipVrr = true;
|
skipVrr = true;
|
||||||
@@ -261,18 +261,18 @@ namespace governor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!skipVrr) {
|
if (!skipVrr) {
|
||||||
u8 fps = integrations::GetSaltyNXFPS();
|
u8 fps = hos::GetSaltyNXFPS();
|
||||||
|
|
||||||
if (fps != 254) {
|
if (fps != 254) {
|
||||||
std::scoped_lock lock{ clockManager::gContextMutex };
|
std::scoped_lock lock{ mgr::gContextMutex };
|
||||||
|
|
||||||
u32 targetHz = clockManager::gContext.overrideFreqs[HocClkModule_Display];
|
u32 targetHz = mgr::gContext.overrideFreqs[HocClkModule_Display];
|
||||||
if (!targetHz) {
|
if (!targetHz) {
|
||||||
targetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Display,
|
targetHz = file::config::GetAutoClockHz(mgr::gContext.applicationId, HocClkModule_Display,
|
||||||
clockManager::gContext.profile, false);
|
mgr::gContext.profile, false);
|
||||||
if (!targetHz)
|
if (!targetHz)
|
||||||
targetHz =
|
targetHz =
|
||||||
config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Display, clockManager::gContext.profile, false);
|
file::config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Display, mgr::gContext.profile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 maxDisplay = targetHz ? (u8)targetHz : 60;
|
u8 maxDisplay = targetHz ? (u8)targetHz : 60;
|
||||||
@@ -281,19 +281,19 @@ namespace governor {
|
|||||||
if (maxDisplay != minDisplay) {
|
if (maxDisplay != minDisplay) {
|
||||||
if (fps >= minDisplay && fps <= maxDisplay) {
|
if (fps >= minDisplay && fps <= maxDisplay) {
|
||||||
board::SetHz(HocClkModule_Display, fps);
|
board::SetHz(HocClkModule_Display, fps);
|
||||||
clockManager::gContext.freqs[HocClkModule_Display] = fps;
|
mgr::gContext.freqs[HocClkModule_Display] = fps;
|
||||||
clockManager::gContext.realFreqs[HocClkModule_Display] = fps;
|
mgr::gContext.realFreqs[HocClkModule_Display] = fps;
|
||||||
clockManager::gContext.stable.freqs[HocClkModule_Display] = fps;
|
mgr::gContext.stable.freqs[HocClkModule_Display] = fps;
|
||||||
clockManager::gContext.stable.realFreqs[HocClkModule_Display] = fps;
|
mgr::gContext.stable.realFreqs[HocClkModule_Display] = fps;
|
||||||
} else {
|
} else {
|
||||||
for (u32 i = 0; i < 10; i++) {
|
for (u32 i = 0; i < 10; i++) {
|
||||||
u32 compareHz = fps * i;
|
u32 compareHz = fps * i;
|
||||||
if (compareHz >= minDisplay && compareHz <= maxDisplay) {
|
if (compareHz >= minDisplay && compareHz <= maxDisplay) {
|
||||||
board::SetHz(HocClkModule_Display, compareHz);
|
board::SetHz(HocClkModule_Display, compareHz);
|
||||||
clockManager::gContext.freqs[HocClkModule_Display] = compareHz;
|
mgr::gContext.freqs[HocClkModule_Display] = compareHz;
|
||||||
clockManager::gContext.realFreqs[HocClkModule_Display] = compareHz;
|
mgr::gContext.realFreqs[HocClkModule_Display] = compareHz;
|
||||||
clockManager::gContext.stable.freqs[HocClkModule_Display] = compareHz;
|
mgr::gContext.stable.freqs[HocClkModule_Display] = compareHz;
|
||||||
clockManager::gContext.stable.realFreqs[HocClkModule_Display] = compareHz;
|
mgr::gContext.stable.realFreqs[HocClkModule_Display] = compareHz;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,12 +313,12 @@ namespace governor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startThreads() {
|
void StartThreads() {
|
||||||
threadCreate(&governorTHREAD, GovernorThread, nullptr, NULL, 0x2000, 0x3F, -2);
|
threadCreate(&governorTHREAD, GovernorThread, nullptr, NULL, 0x2000, 0x3F, -2);
|
||||||
threadStart(&governorTHREAD);
|
threadStart(&governorTHREAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exitThreads() {
|
void ExitThreads() {
|
||||||
threadClose(&governorTHREAD);
|
threadClose(&governorTHREAD);
|
||||||
}
|
}
|
||||||
} // namespace governor
|
} // namespace mgr
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "clock_manager.hpp"
|
#include "clock_manager.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace governor {
|
namespace mgr {
|
||||||
extern bool isCpuGovernorInBoostMode;
|
extern bool isCpuGovernorInBoostMode;
|
||||||
extern bool isVRREnabled;
|
extern bool isVRREnabled;
|
||||||
extern bool isGpuGovernorEnabled;
|
extern bool isGpuGovernorEnabled;
|
||||||
@@ -36,7 +36,7 @@ namespace governor {
|
|||||||
extern bool lastGpuGovernorState;
|
extern bool lastGpuGovernorState;
|
||||||
extern bool lastCpuGovernorState;
|
extern bool lastCpuGovernorState;
|
||||||
extern bool lastVrrGovernorState;
|
extern bool lastVrrGovernorState;
|
||||||
void startThreads();
|
void StartThreads();
|
||||||
void exitThreads();
|
void ExitThreads();
|
||||||
void HandleGovernor(uint32_t targetHz);
|
void HandleGovernor(uint32_t targetHz);
|
||||||
} // namespace governor
|
} // namespace mgr
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace soc::mrr {
|
namespace soc {
|
||||||
constexpr u64 EmcPhysBase = 0x7001B000;
|
constexpr u64 EmcPhysBase = 0x7001B000;
|
||||||
constexpr u64 Emc0PhysBase = 0x7001E000;
|
constexpr u64 Emc0PhysBase = 0x7001E000;
|
||||||
constexpr u64 Emc1PhysBase = 0x7001F000;
|
constexpr u64 Emc1PhysBase = 0x7001F000;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
|
||||||
namespace soc::mrr {
|
namespace soc {
|
||||||
typedef enum RealDramModule {
|
typedef enum RealDramModule {
|
||||||
/* Erista */
|
/* Erista */
|
||||||
DRAM_HBMGCH = 0,
|
DRAM_HBMGCH = 0,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "gm20b.hpp"
|
#include "gm20b.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace gm20b {
|
namespace soc {
|
||||||
u64 gpu_base = 0;
|
u64 gpu_base = 0;
|
||||||
#define GPU_PA 0x57000000
|
#define GPU_PA 0x57000000
|
||||||
#define GPU_SIZE 0x1000000
|
#define GPU_SIZE 0x1000000
|
||||||
@@ -123,7 +123,7 @@ namespace gm20b {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setClock(u32 khz) {
|
bool SetClock(u32 khz) {
|
||||||
if (!gpu_base)
|
if (!gpu_base)
|
||||||
QueryMemoryMapping(&gpu_base, GPU_PA, GPU_SIZE);
|
QueryMemoryMapping(&gpu_base, GPU_PA, GPU_SIZE);
|
||||||
|
|
||||||
@@ -146,4 +146,4 @@ namespace gm20b {
|
|||||||
|
|
||||||
return _gpu_pllg_slide(new_divn);
|
return _gpu_pllg_slide(new_divn);
|
||||||
}
|
}
|
||||||
} // namespace gm20b
|
} // namespace soc
|
||||||
@@ -19,6 +19,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <../board/board.hpp>
|
#include <../board/board.hpp>
|
||||||
|
|
||||||
namespace gm20b {
|
namespace soc {
|
||||||
bool setClock(u32 khz);
|
bool SetClock(u32 khz);
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ namespace tsensor {
|
|||||||
SetBit(CFG_TAG_EN_POS, &r);
|
SetBit(CFG_TAG_EN_POS, &r);
|
||||||
ClearBit(CFG_DISABLE_CLK_POS, &r);
|
ClearBit(CFG_DISABLE_CLK_POS, &r);
|
||||||
WritePmcReg(r, PMC_AOTAG_CFG);
|
WritePmcReg(r, PMC_AOTAG_CFG);
|
||||||
fileUtils::LogLine("[aotag] Init complete!");
|
file::utils::LogLine("[aotag] Init complete!");
|
||||||
wasInit = true;
|
wasInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
#include "bq24193.hpp"
|
#include "bq24193.hpp"
|
||||||
|
|
||||||
namespace bq24193 {
|
namespace tsensor {
|
||||||
static u8 bq24193_get_reg(u8 reg) {
|
static u8 bq24193_get_reg(u8 reg) {
|
||||||
u8 out;
|
u8 out;
|
||||||
I2cRead_OutU8(I2cDevice_Bq24193, reg, &out);
|
I2cRead_OutU8(I2cDevice_Bq24193, reg, &out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
u8 getBQTemp() {
|
u8 GetBqTemp() {
|
||||||
u8 regVal = bq24193_get_reg(BQ24193_FaultReg);
|
u8 regVal = bq24193_get_reg(BQ24193_FaultReg);
|
||||||
return regVal & BQ24193_FAULT_THERM_MASK;
|
return regVal & BQ24193_FAULT_THERM_MASK;
|
||||||
}
|
}
|
||||||
} // namespace bq24193
|
} // namespace tsensor
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "../i2c/i2cDrv.h"
|
#include "../i2c/i2cDrv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace bq24193 {
|
namespace tsensor {
|
||||||
#define BQ24193_I2C_ADDR 0x6B
|
#define BQ24193_I2C_ADDR 0x6B
|
||||||
|
|
||||||
// REG 0 masks.
|
// REG 0 masks.
|
||||||
@@ -126,5 +126,5 @@ namespace bq24193 {
|
|||||||
BQ24193_Temp_Cold = 5,
|
BQ24193_Temp_Cold = 5,
|
||||||
BQ24193_Temp_Hot = 6,
|
BQ24193_Temp_Hot = 6,
|
||||||
};
|
};
|
||||||
u8 getBQTemp();
|
u8 GetBqTemp();
|
||||||
} // namespace bq24193
|
} // namespace tsensor
|
||||||
@@ -491,7 +491,7 @@ namespace tsensor {
|
|||||||
|
|
||||||
StartSensors();
|
StartSensors();
|
||||||
|
|
||||||
fileUtils::LogLine("[Soctherm] Finished init.");
|
file::utils::LogLine("[Soctherm] Finished init.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tsensor
|
} // namespace tsensor
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#include <crc32.h>
|
#include <crc32.h>
|
||||||
|
|
||||||
namespace crc32 {
|
namespace util {
|
||||||
uint32_t crc32(const uint8_t *data, size_t length) {
|
uint32_t Crc32(const uint8_t *data, size_t length) {
|
||||||
uint32_t crc = 0xFFFFFFFF;
|
uint32_t crc = 0xFFFFFFFF;
|
||||||
|
|
||||||
for (size_t i = 0; i < length; i++) {
|
for (size_t i = 0; i < length; i++) {
|
||||||
@@ -30,7 +30,7 @@ namespace crc32 {
|
|||||||
return ~crc;
|
return ~crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t checksum_file(const char *filename) {
|
uint32_t ChecksumFile(const char *filename) {
|
||||||
FILE *file = fopen(filename, "rb");
|
FILE *file = fopen(filename, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
perror("[crc32] Error opening file");
|
perror("[crc32] Error opening file");
|
||||||
@@ -53,4 +53,4 @@ namespace crc32 {
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
return ~crc;
|
return ~crc;
|
||||||
}
|
}
|
||||||
} // namespace crc32
|
} // namespace util
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
namespace crc32 {
|
namespace util {
|
||||||
uint32_t crc32(const uint8_t *data, size_t length);
|
uint32_t Crc32(const uint8_t *data, size_t length);
|
||||||
uint32_t checksum_file(const char *filename);
|
uint32_t ChecksumFile(const char *filename);
|
||||||
} // namespace crc32
|
} // namespace util
|
||||||
Reference in new issue
Block a user