- [Sys-clk-OC] Partial rewrite, general performance & stability improvement

- [ReverseNX-RT] Notify user if profile is synced with sys-clk
This commit is contained in:
KazushiM
2021-12-16 23:04:44 +08:00
parent 12aab58198
commit e6b608fa43
15 changed files with 348 additions and 457 deletions

Binary file not shown.

View File

@@ -247,7 +247,7 @@ namespace pcv {
// If so, read/query max77812 pmic via i2c for voltage info in hekate and get DRAM reg on PHASE31.
// max77812 document: https://datasheets.maximintegrated.com/en/ds/MAX77812.pdf
// TODO: investigate why frequencies lower than 1331 MHz cannot be set
// Mariko have 3 mtc tables (204/1331/1600 MHz), only these 3 frequencies could be set.
constexpr u32 EmcFreqOffsets[][30] = {
{ 0xD7C60, 0xD7C68, 0xD7C70, 0xD7C78, 0xD7C80, 0xD7C88, 0xD7C90, 0xD7C98, 0xD7CA0, 0xD7CA8, 0xE1800, 0xEEFA0, 0xF2478, 0xFE284, 0x10A304, 0x10D7DC, 0x110A40, 0x113CA4, 0x116F08, 0x11A16C, 0x11D3D0, 0x120634, 0x123898, 0x126AFC, 0x129D60, 0x12CFC4, 0x130228, 0x13BFE0, 0x140D00, 0x140D50, },
{ 0xE1810, 0xE6530, 0xE6580, 0xE6AB0, 0xE6AB8, 0xE6AC0, 0xE6AC8, 0xE6AD0, 0xE6AD8, 0xE6AE0, 0xE6AE8, 0xE6AF0, 0xE6AF8, 0xF0650, 0xFDDF0, 0x1012C8, 0x10D0D4, 0x119154, 0x11C62C, 0x11F890, 0x122AF4, 0x125D58, 0x128FBC, 0x12C220, 0x12F484, 0x1326E8, 0x13594C, 0x138BB0, 0x13BE14, 0x13F078, },
@@ -663,27 +663,7 @@ namespace pcv {
/* Unlock the second sub-partition for retail Mariko, and double the bandwidth (~60GB/s)
* https://github.com/CTCaer/hekate/blob/01b6e645b3cb69ddf28cc9eff40c4b35bf03dbd4/bdk/mem/sdram.h#L30
*
* Sub-partition related parameters in sdram_params:
* EMC_ADR_CFG, MC_EMEM_ADR_CFG:
* |- Number of populated DRAM devices, 0x0: one, 0x1: two
* EMC_MRW1, EMC_MRW2, EMC_MR3, EMC_MRW6, EMC_MRW8, EMC_MRW9,
* EMC_MRW10, EMC_MRW12, EMC_MRW13, EMC_MRW14, EMC_MRW15,
* EMC_ZCAL_MRW_CMD, EMC_ZCAL_INIT_DEV1:
* |- BIT 31:30: DEV_SELECTN, 0x0: both, 0x2: dev0, 0x1: dev1
* |- EMC_MRW4 is not used (BIT 31:30: 0b11)
* EMC_DEV_SELECT:
* |- Same as DEV_SELECTN
* EMC_PMACRO_TX_PWRD4, EMC_PMACRO_TX_PWRD5 ?
* MC_EMEM_ADR_CFG_DEV0, MC_EMEM_ADR_CFG_DEV1:
* |- BIT 19:16: DEVSIZE(density), 8 = 1GB, 7 = 512MB (ineffective?)
* |- BIT 9:8 : BANKWIDTH, 2 / 3 : W2 / W3, W3(default)
* |- BIT 2:0 : COLWIDTH, 1 - 5 : W8 - W12, W9(default)
* MC_EMEM_ARB_TIMING_R2R, MC_EMEM_ARB_DA_TURNS:
* |- With 2 DRAM devices on, timing should be adjusted.
*
* With all these above changed, 2 sub-partitions seem to be on
* But RAM density is off (before: 2x1GB+2x1GB, after: 4x1GB + 4x1GB)
* and it fails before splash screen in ams fusee
* Sub-partitions are defined as ranks, so there is no other way than replacing DRAM chips.
*/
}

View File

@@ -7,22 +7,35 @@ index 3e35c18..6b42bc5 100644
*.nro
+*.DS_Store
diff --git a/Overlay/Makefile b/Overlay/Makefile
index f881ed9..88fca31 100644
--- a/Overlay/Makefile
+++ b/Overlay/Makefile
@@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
APP_TITLE := ReverseNX-RT
-APP_VERSION := 1.0.1
+APP_VERSION := 1.0.1-OC
TARGET := ReverseNX-RT-ovl
BUILD := build
diff --git a/Overlay/libs/Atmosphere-libs b/Overlay/libs/Atmosphere-libs
index 2d522dc..bc08912 160000
index 2d522dc..c4d0335 160000
--- a/Overlay/libs/Atmosphere-libs
+++ b/Overlay/libs/Atmosphere-libs
@@ -1 +1 @@
-Subproject commit 2d522dc6a12b2eb5eb3f103a8c5b5126ca301b1a
+Subproject commit bc08912dd31bb172467add8e24b4f0adac431939
+Subproject commit c4d0335b79da7207b49abf1988f45b0168b692f0-dirty
diff --git a/Overlay/libs/libtesla b/Overlay/libs/libtesla
index 6628524..a5ce77d 160000
index 6628524..640629f 160000
--- a/Overlay/libs/libtesla
+++ b/Overlay/libs/libtesla
@@ -1 +1 @@
-Subproject commit 66285245361a02e5480c7bb7dac9ef6449ae6181
+Subproject commit a5ce77d14f144a24c21684128ae79ef1e808734c
+Subproject commit 640629f49f9e8997ef0769b21b26f4fc177c736f
diff --git a/Overlay/source/main.cpp b/Overlay/source/main.cpp
index cec060c..7b7d8b1 100644
index cec060c..1a6080e 100644
--- a/Overlay/source/main.cpp
+++ b/Overlay/source/main.cpp
@@ -2,8 +2,12 @@
@@ -38,15 +51,24 @@ index cec060c..7b7d8b1 100644
bool PluginRunning = false;
bool closed = false;
Handle debug;
@@ -17,6 +21,7 @@ bool dmntcht = false;
@@ -17,9 +21,16 @@ bool dmntcht = false;
bool SaltySD = false;
bool bak = false;
bool plugin = false;
+bool sysclkComm = false;
+uint8_t sysclkSyncInfoShowTick = 0;
+constexpr uint8_t sysclkSyncChecksPerSec = 10;
+constexpr uint8_t sysclkSyncFramesPerCheck = 60 / sysclkSyncChecksPerSec;
+constexpr uint8_t sysclkSyncInfoShowInitTick = 3 * sysclkSyncFramesPerCheck;
+uint8_t sysclkSyncRetry = 0;
char DockedChar[32];
char SystemChar[32];
char PluginChar[36];
@@ -54,6 +59,29 @@ bool isServiceRunning(const char *serviceName) {
+char SysclkChar[36];
bool CheckPort () {
Handle saltysd;
@@ -54,6 +65,29 @@ bool isServiceRunning(const char *serviceName) {
}
}
@@ -76,7 +98,15 @@ index cec060c..7b7d8b1 100644
class GuiTest : public tsl::Gui {
public:
GuiTest(u8 arg1, u8 arg2, bool arg3) { }
@@ -95,9 +123,10 @@ class GuiTest : public tsl::Gui {
@@ -88,6 +122,7 @@ public:
else {
renderer->drawString(SystemChar, false, x, y+40, 20, renderer->a(0xFFFF));
renderer->drawString(DockedChar, false, x, y+60, 20, renderer->a(0xFFFF));
+ renderer->drawString(SysclkChar, false, x, y+80, 20, renderer->a(0xFFFF));
}
}
}), 100);
@@ -95,9 +130,10 @@ public:
if (MAGIC == 0x06BA7E39) {
auto *clickableListItem = new tsl::elm::ListItem("Change system control");
clickableListItem->setClickListener([](u64 keys) {
@@ -88,7 +118,7 @@ index cec060c..7b7d8b1 100644
if (dmntcht == true) {
dmntchtWriteCheatProcessMemory(def_address, &def, 0x1);
dmntchtReadCheatProcessMemory(def_address, &def, 0x1);
@@ -120,9 +149,10 @@ class GuiTest : public tsl::Gui {
@@ -120,9 +156,10 @@ public:
auto *clickableListItem2 = new tsl::elm::ListItem("Change mode");
clickableListItem2->setClickListener([](u64 keys) {
@@ -100,7 +130,7 @@ index cec060c..7b7d8b1 100644
if (dmntcht == true) {
dmntchtWriteCheatProcessMemory(docked_address, &isDocked, 0x1);
dmntchtReadCheatProcessMemory(docked_address, &isDocked, 0x1);
@@ -145,7 +175,7 @@ class GuiTest : public tsl::Gui {
@@ -145,7 +182,7 @@ public:
else if (SaltySD == true && plugin == true && check == false) {
auto *clickableListItem = new tsl::elm::ListItem("(De)activate plugin");
clickableListItem->setClickListener([](u64 keys) {
@@ -109,46 +139,93 @@ index cec060c..7b7d8b1 100644
if (bak == false) {
rename("sdmc:/SaltySD/plugins/ReverseNX-RT.elf", "sdmc:/SaltySD/plugins/ReverseNX-RT.elf.bak");
bak = true;
@@ -185,6 +215,38 @@ class GuiTest : public tsl::Gui {
@@ -185,6 +222,40 @@ public:
svcReadDebugProcessMemory(&isDocked, debug, docked_address, 0x1);
svcCloseHandle(debug);
}
+ if (sysclkComm && isDockedChanged && def == false && bak == false)
+ {
+ uint8_t sysclkConfArr[9];
+ u64 currentTID = GetCurrentApplicationId();
+ if (currentTID != PROCESS_MANAGEMENT_QLAUNCH_TID)
+ {
+ for(int i = 0; i < 8; i++) // TID to hex
+ sysclkConfArr[i] = currentTID >> 8*(7-i);
+ sysclkConfArr[8] = isDocked + 1;
+
+ FILE* sysclkConf = fopen("/config/sys-clk/ReverseNX-RT.conf", "wb+");
+ fwrite(sysclkConfArr, sizeof(sysclkConfArr), 1, sysclkConf);
+ fclose(sysclkConf);
+ if (sysclkConf)
+ {
+ uint8_t ctrlState = isDocked + 1;
+ fwrite(&currentTID, 1, sizeof(currentTID), sysclkConf);
+ fwrite(&ctrlState, 1, sizeof(ctrlState), sysclkConf);
+ fclose(sysclkConf);
+ sysclkSyncInfoShowTick = sysclkSyncInfoShowInitTick;
+ }
+ }
+ isDockedChanged = false;
+ }
+ if (sysclkComm && defChanged && def == true && bak == false) // change from force mode to system-controlled mode
+ {
+ uint8_t sysclkConfArr[9];
+ u64 currentTID = GetCurrentApplicationId();
+ if (currentTID != PROCESS_MANAGEMENT_QLAUNCH_TID)
+ {
+ for(int i = 0; i < 8; i++) // TID to hex
+ sysclkConfArr[i] = currentTID >> 8*(7-i);
+ sysclkConfArr[8] = 3;
+
+ FILE* sysclkConf = fopen("/config/sys-clk/ReverseNX-RT.conf", "wb+");
+ fwrite(sysclkConfArr, sizeof(sysclkConfArr), 1, sysclkConf);
+ fclose(sysclkConf);
+ if (sysclkConf)
+ {
+ uint8_t ctrlState = 3; // ReverseNX_RTResetToDefault
+ fwrite(&currentTID, 1, sizeof(currentTID), sysclkConf);
+ fwrite(&ctrlState, 1, sizeof(ctrlState), sysclkConf);
+ fclose(sysclkConf);
+ sysclkSyncInfoShowTick = sysclkSyncInfoShowInitTick;
+ }
+ }
+ defChanged = false;
+ }
i = 0;
}
else i++;
@@ -202,7 +264,7 @@ class GuiTest : public tsl::Gui {
@@ -198,11 +269,51 @@ public:
if (bak == false) sprintf(PluginChar, "ReverseNX-RT plugin is activated.");
else sprintf(PluginChar, "ReverseNX-RT plugin is deactivated.");
-
+
+ if (sysclkComm)
+ {
+ if (sysclkSyncInfoShowTick == sysclkSyncInfoShowInitTick)
+ {
+ if (sysclkSyncRetry >= sysclkSyncInfoShowInitTick)
+ {
+ sprintf(SysclkChar, "Sys-clk Profile Sync: Error!");
+ }
+ else if (i % sysclkSyncFramesPerCheck == 0)
+ {
+ /* Check if conf file is detected by sys-clk */
+ FILE* sysclkConf = fopen("/config/sys-clk/ReverseNX-RT.conf", "r");
+ if (sysclkConf)
+ {
+ fclose(sysclkConf);
+ sprintf(SysclkChar, "Sys-clk Profile Sync: Pending...");
+ sysclkSyncRetry++;
+ }
+ else
+ {
+ sprintf(SysclkChar, "Sys-clk Profile Sync: Success!");
+ sysclkSyncRetry = 0;
+ sysclkSyncInfoShowTick--;
+ }
+ }
+ }
+ else if (sysclkSyncInfoShowTick)
+ {
+ if (i % sysclkSyncFramesPerCheck == 0)
+ sysclkSyncInfoShowTick--;
+ }
+ else
+ {
+ sprintf(SysclkChar, "Sys-clk Profile Sync: ON");
+ }
+ }
+ else
+ {
+ sprintf(SysclkChar, "Sys-clk Profile Sync: OFF");
+ }
}
// Called once every frame to handle inputs not handled by other UI elements
@@ -157,7 +234,7 @@ index cec060c..7b7d8b1 100644
return false; // Return true here to singal the inputs have been consumed
}
};
@@ -213,6 +275,7 @@ class OverlayTest : public tsl::Overlay {
@@ -213,6 +324,7 @@ public:
virtual void initServices() override {
smInitialize();
fsdevMountSdmc();
@@ -165,22 +242,42 @@ index cec060c..7b7d8b1 100644
SaltySD = CheckPort();
if (SaltySD == false) return;
@@ -234,6 +297,14 @@ class OverlayTest : public tsl::Overlay {
@@ -234,6 +346,19 @@ public:
else return;
}
+ // Check if sys-clk exist
+ temp = fopen("/atmosphere/contents/00FF0000636C6BFF/flags/boot2.flag", "r");
+ temp = fopen("sdmc:/atmosphere/contents/00FF0000636C6BFF/exefs.nsp", "r");
+ if (temp != NULL)
+ {
+ sysclkComm = true;
+ fclose(temp);
+ temp = fopen("sdmc:/config/sys-clk/ReverseNX_sync.flag", "r");
+ if (temp)
+ {
+ sysclkComm = true;
+ fclose(temp);
+ }
+ }
+
if (R_FAILED(pmdmntGetApplicationProcessId(&PID))) remove("sdmc:/SaltySD/ReverseNX-RT.hex");
else {
check = true;
@@ -284,6 +355,7 @@ class OverlayTest : public tsl::Overlay {
@@ -278,12 +403,22 @@ public:
if (def == true) sprintf(SystemChar, "Controlled by system: Yes");
else sprintf(SystemChar, "Controlled by system: No");
+
+ if (sysclkComm)
+ {
+ sprintf(SysclkChar, "Sys-clk Profile Sync: ON");
+ }
+ else
+ {
+ sprintf(SysclkChar, "Sys-clk Profile Sync: OFF");
+ }
} // Called at the start to initialize all services necessary for this Overlay
virtual void exitServices() override {
dmntchtExit();
if (dmntcht == false) svcCloseHandle(debug);

View File

@@ -82,7 +82,7 @@ To protect the battery from excessive strain, clocks requested from config may b
|:-------:|:--------:|:--------------:|:-------------------:|:------:|
| **MEM** | - | - | - | - |
| **CPU** | - | - | - | - |
| **GPU** | 1344 | 1344 | - | - |
| **GPU** | 1267 | - | - | - |
## Installation

View File

@@ -42,23 +42,37 @@ typedef enum
typedef struct
{
uint8_t enabled;
uint8_t enabled;
uint64_t applicationId;
SysClkProfile profile;
SysClkProfile realProfile;
uint32_t freqs[SysClkModule_EnumMax];
uint32_t overrideFreqs[SysClkModule_EnumMax];
uint32_t temps[SysClkThermalSensor_EnumMax];
uint32_t perfConfId;
} SysClkContext;
typedef enum
{
ReverseNX_SystemDefault = 0,
ReverseNX_NotFound = 0,
ReverseNX_NotValid = 0,
ReverseNX_Handheld,
ReverseNX_Docked,
ReverseNX_RTResetToDefault,
} ReverseNXMode;
typedef struct
{
bool systemCoreBoostCPU;
bool systemCoreBoostCPUReset;
bool systemCoreCheckStuck;
bool systemCoreBoostCPU;
bool systemCoreCheckStuck;
ReverseNXMode reverseNXToolMode;
ReverseNXMode reverseNXRTMode;
uint64_t tickWaitTimeMs;
uint8_t systemCoreBoostThreshold;
// int16_t systemCoreStuckCount;
uint32_t maxMEMFreq;
} SysClkOcExtra;
typedef struct
@@ -69,8 +83,7 @@ typedef struct
};
} SysClkTitleProfileList;
#define SYSCLK_GPU_HANDHELD_MAX_HZ 460800000
#define SYSCLK_GPU_UNOFFICIAL_CHARGER_MAX_HZ 768000000
#define SYSCLK_GPU_HANDHELD_MAX_HZ 1267200000
extern uint32_t sysclk_g_freq_table_mem_hz[];
extern uint32_t sysclk_g_freq_table_cpu_hz[];

View File

@@ -208,12 +208,6 @@ void StatusTab::updateWarningForProfile(SysClkProfile profile, bool animated)
this->warningLabel->setText("\uE140 Maximum GPU frequency is " + formatFreq(SYSCLK_GPU_HANDHELD_MAX_HZ) + " because you're in handheld mode.");
break;
case SysClkProfile_HandheldChargingUSB:
if (this->warningLabel->isHidden())
this->warningLabel->show([](){});
this->warningLabel->setText("\uE140 Maximum GPU frequency is " + formatFreq(SYSCLK_GPU_UNOFFICIAL_CHARGER_MAX_HZ) + " because you're using an unofficial charger type.");
break;
default:
if (!this->warningLabel->isHidden())
this->warningLabel->hide([](){}, animated);

View File

@@ -8,7 +8,6 @@
* --------------------------------------------------------------------------
*/
#define FORCE_ALL_HANDHELD_MODES_TO_USE_DOCK_CLOCK
#include <nxExt.h>
#include "errors.h"
#include "clock_manager.h"
@@ -46,6 +45,7 @@ ClockManager::ClockManager()
this->context = new SysClkContext;
this->context->applicationId = 0;
this->context->profile = SysClkProfile_Handheld;
this->context->realProfile = SysClkProfile_Handheld;
this->context->enabled = false;
for(unsigned int i = 0; i < SysClkModule_EnumMax; i++)
{
@@ -60,8 +60,10 @@ ClockManager::ClockManager()
this->oc = new SysClkOcExtra;
this->oc->systemCoreBoostCPU = false;
this->oc->systemCoreCheckStuck = false;
this->oc->tickWaitTimeMs = 500;
this->oc->systemCoreBoostThreshold = 100;
this->oc->reverseNXToolMode = ReverseNX_NotFound;
this->oc->reverseNXRTMode = ReverseNX_NotFound;
this->oc->tickWaitTimeMs = 0;
this->oc->maxMEMFreq = 1600'000'000;
// this->oc->systemCoreStuckCount = 0;
}
@@ -75,98 +77,18 @@ ClockManager::~ClockManager()
bool ClockManager::IsCpuBoostMode()
{
std::uint32_t confId = this->context->perfConfId;
if(confId == 0x92220009 || confId == 0x9222000A)
return true;
else
return false;
return (confId == 0x92220009 || confId == 0x9222000A);
}
SysClkProfile ClockManager::ReverseNXProfile(bool ForceDock)
bool ClockManager::IsReverseNXEnabled()
{
RealProfile = Clocks::GetCurrentProfile();
switch(RealProfile)
{
case SysClkProfile_HandheldChargingOfficial:
#ifdef FORCE_ALL_HANDHELD_MODES_TO_USE_DOCK_CLOCK
case SysClkProfile_HandheldChargingUSB:
case SysClkProfile_HandheldCharging:
case SysClkProfile_Handheld:
#endif
if (ForceDock)
return SysClkProfile_Docked;
else
return RealProfile;
case SysClkProfile_Docked:
if (ForceDock)
return SysClkProfile_Docked;
else
return FileUtils::IsDownclockDockEnabled() ? SysClkProfile_HandheldChargingOfficial : SysClkProfile_Docked;
default:
return RealProfile;
}
return (this->oc->reverseNXRTMode || this->oc->reverseNXToolMode);
}
void ClockManager::checkReverseNXTool()
bool ClockManager::IsReverseNXDocked()
{
char ReverseNXToolAsm[] = "_ZN2nn2oe18GetPerformanceModeEv.asm64"; // Checking one asm64 file is enough
char ReverseNXToolAsmPath[128];
uint8_t flag = 0;
snprintf(ReverseNXToolAsmPath, sizeof ReverseNXToolAsmPath, "/SaltySD/patches/%s", ReverseNXToolAsm);
FILE *readReverseNXToolAsm;
readReverseNXToolAsm = fopen(ReverseNXToolAsmPath, "rb");
// Enforce mode globally: Enabled
if(readReverseNXToolAsm != NULL)
{
checkReverseNXToolAsm(readReverseNXToolAsm, &flag);
switch(flag)
{
case 1:
FileUtils::LogLine("[mgr] ReverseNX-Tool patches detected: Enforce Handheld globally");
this->context->profile = ReverseNXProfile(false);
isDockedReverseNX = false;
isEnabledReverseNX = true;
isEnabledReverseNXTool = true;
break;
case 2:
FileUtils::LogLine("[mgr] ReverseNX-Tool patches detected: Enforce Docked globally");
this->context->profile = ReverseNXProfile(true);
isDockedReverseNX = true;
isEnabledReverseNX = true;
isEnabledReverseNXTool = true;
break;
}
}
else
{
snprintf(ReverseNXToolAsmPath, sizeof ReverseNXToolAsmPath, "/SaltySD/patches/%016lX/%s", this->context->applicationId, ReverseNXToolAsm);
readReverseNXToolAsm = fopen(ReverseNXToolAsmPath, "rb");
// Found game-specific setting
if(readReverseNXToolAsm != NULL)
{
checkReverseNXToolAsm(readReverseNXToolAsm, &flag);
switch(flag)
{
case 1:
FileUtils::LogLine("[mgr] ReverseNX-Tool patches detected: Force Handheld in %016lX", this->context->applicationId);
this->context->profile = ReverseNXProfile(false);
isDockedReverseNX = false;
isEnabledReverseNX = true;
isEnabledReverseNXTool = true;
break;
case 2:
FileUtils::LogLine("[mgr] ReverseNX-Tool patches detected: Force Docked in %016lX", this->context->applicationId);
this->context->profile = ReverseNXProfile(true);
isDockedReverseNX = true;
isEnabledReverseNX = true;
isEnabledReverseNXTool = true;
break;
default:
isEnabledReverseNXTool = false;
}
}
}
return (this->oc->reverseNXRTMode == ReverseNX_Docked
|| this->oc->reverseNXToolMode == ReverseNX_Docked);
}
void ClockManager::SetRunning(bool running)
@@ -186,16 +108,16 @@ uint32_t ClockManager::GetHz(SysClkModule module)
/* Temp override setting */
hz = this->context->overrideFreqs[module];
/* Per-Game setting */
if (!hz)
hz = this->config->GetAutoClockHz(this->context->applicationId, module, this->context->profile);
/* Global setting */
if (!hz)
hz = this->config->GetAutoClockHz(0xA111111111111111, module, this->context->profile);
/* Adjust hz if ReverseNX is enabled */
if (!hz && isEnabledReverseNX)
/* Per-Game setting */
if (!hz)
hz = this->config->GetAutoClockHz(this->context->applicationId, module, this->context->profile);
/* Return pre-set hz if ReverseNX is enabled, downclock is disabled when realProfile == Docked */
if (!hz && IsReverseNXEnabled())
{
switch(module)
{
@@ -203,15 +125,13 @@ uint32_t ClockManager::GetHz(SysClkModule module)
hz = 1020'000'000;
break;
case SysClkModule_GPU:
if (!isDockedReverseNX && ((FileUtils::IsDownclockDockEnabled() && RealProfile == SysClkProfile_Docked)
|| RealProfile != SysClkProfile_Docked))
if (!IsReverseNXDocked() && this->context->realProfile != SysClkProfile_Docked)
hz = 460'800'000;
else
hz = 768'000'000;
break;
case SysClkModule_MEM:
if (!isDockedReverseNX && ((FileUtils::IsDownclockDockEnabled() && RealProfile == SysClkProfile_Docked)
|| RealProfile != SysClkProfile_Docked))
if (!IsReverseNXDocked() && this->context->realProfile != SysClkProfile_Docked)
hz = 1331'200'000;
else
hz = 1600'000'000;
@@ -223,20 +143,25 @@ uint32_t ClockManager::GetHz(SysClkModule module)
if (hz)
{
hz = Clocks::GetNearestHz(module, isEnabledReverseNX ? RealProfile : this->context->profile, hz);
/* Considering realProfile frequency limit */
hz = Clocks::GetNearestHz(module, this->context->realProfile, hz);
/* Ignore if MEM Max Hz > 1600 MHz */
if (module == SysClkModule_MEM && hz == 1600'000'000 && this->context->freqs[module] >= hz)
if (module == SysClkModule_MEM && hz == 1600'000'000)
{
return 0;
/* Return maxMemFreq */
if (this->context->freqs[module] > this->oc->maxMEMFreq)
this->oc->maxMEMFreq = this->context->freqs[module];
return this->oc->maxMEMFreq;
}
}
if (module == SysClkModule_CPU)
{
if (this->oc->systemCoreBoostCPU && hz < MAX_CPU)
return MAX_CPU;
if (this->oc->systemCoreBoostCPU && hz < CPU_BOOST_FREQ)
return CPU_BOOST_FREQ;
else if (!hz)
/* Prevent crash when hz = 0 in SetHz(0), trigger RefreshContext() and Tick() */
return 1020'000'000;
}
@@ -255,14 +180,12 @@ void ClockManager::Tick()
if (hz && hz != this->context->freqs[module])
{
if (IsCpuBoostMode())
// Skip setting CPU or GPU clocks in CpuBoostMode if CPU <= 1963.5MHz or GPU >= 76.8MHz
if (IsCpuBoostMode() && ((module == SysClkModule_CPU && hz <= CPU_BOOST_FREQ) || module == SysClkModule_GPU))
{
// Skip setting CPU or GPU clocks in CpuBoostMode if CPU <= 1963.5MHz or GPU >= 76.8MHz
if ((module == SysClkModule_CPU && hz <= MAX_CPU) || module == SysClkModule_GPU)
{
continue;
}
continue;
}
FileUtils::LogLine("[mgr] %s clock set : %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10);
Clocks::SetHz((SysClkModule)module, hz);
this->context->freqs[module] = hz;
@@ -275,36 +198,37 @@ void ClockManager::WaitForNextTick()
{
/* Self-check system core (#3) usage via idleticks at intervals (Not enabled at higher CPU freq or without charger) */
this->oc->tickWaitTimeMs = this->GetConfig()->GetConfigValue(SysClkConfigValue_PollingIntervalMs);
uint64_t tickWaitTimeNs = this->oc->tickWaitTimeMs * 1000000ULL;
if ( this->context->enabled
&& this->context->profile != SysClkProfile_Handheld
&& this->context->freqs[SysClkModule_CPU] <= MAX_CPU)
if ( FileUtils::IsBoostEnabled()
&& this->context->realProfile != SysClkProfile_Handheld
&& this->context->enabled
&& this->context->freqs[SysClkModule_CPU] <= CPU_BOOST_FREQ)
{
uint64_t systemCoreIdleTickPrev = 0, systemCoreIdleTickNext = 0;
svcGetInfo(&systemCoreIdleTickPrev, InfoType_IdleTickCount, INVALID_HANDLE, 3);
svcSleepThread(this->oc->tickWaitTimeMs * 1000000ULL);
svcSleepThread(tickWaitTimeNs);
svcGetInfo(&systemCoreIdleTickNext, InfoType_IdleTickCount, INVALID_HANDLE, 3);
/* Convert idletick to load% */
/* Convert idletick to free% */
/* If CPU core usage is 0%, then idletick = 19'200'000 per sec */
uint64_t systemCoreIdleTick = systemCoreIdleTickNext - systemCoreIdleTickPrev;
uint64_t freeIdleTick = 19'200 * this->oc->tickWaitTimeMs;
uint8_t freePerc = systemCoreIdleTick / (freeIdleTick / 100);
bool systemCoreBoostCPU_PrevState = this->oc->systemCoreBoostCPU;
switch (this->context->profile)
uint8_t systemCoreBoostFreeThreshold = 5;
switch (this->context->realProfile)
{
case SysClkProfile_HandheldChargingOfficial:
case SysClkProfile_Docked:
this->oc->systemCoreBoostThreshold = systemCoreBoostCPU_PrevState ? 6 : 10;
systemCoreBoostFreeThreshold = 10;
break;
default: // Unofficial charger
this->oc->systemCoreBoostThreshold = systemCoreBoostCPU_PrevState ? 3 : 5;
default:
break;
}
this->oc->systemCoreBoostCPU = (freePerc <= this->oc->systemCoreBoostThreshold);
bool systemCoreBoostCPU_PrevState = this->oc->systemCoreBoostCPU;
this->oc->systemCoreBoostCPU = (freePerc <= systemCoreBoostFreeThreshold);
if (systemCoreBoostCPU_PrevState && !this->oc->systemCoreBoostCPU)
{
@@ -312,12 +236,12 @@ void ClockManager::WaitForNextTick()
}
else if (!systemCoreBoostCPU_PrevState && this->oc->systemCoreBoostCPU)
{
Clocks::SetHz(SysClkModule_CPU, MAX_CPU);
Clocks::SetHz(SysClkModule_CPU, CPU_BOOST_FREQ);
}
}
else
{
svcSleepThread(this->oc->tickWaitTimeMs * 1000000ULL);
svcSleepThread(tickWaitTimeNs);
}
/* Signal that systemCore is not busy */
@@ -334,7 +258,7 @@ void ClockManager::WaitForNextTick()
{
svcSleepThread(clkMgr->oc->tickWaitTimeMs * 1000000ULL);
if (clkMgr->context->freqs[SysClkModule_CPU] >= clkMgr->MAX_CPU)
if (clkMgr->context->freqs[SysClkModule_CPU] >= clkMgr->CPU_BOOST_FREQ)
continue;
// Core #0,1,2 will check if Core#3 is stuck (threshold count = 2*3 = 6)
@@ -343,7 +267,7 @@ void ClockManager::WaitForNextTick()
{
// Signal that current core will take over to boost CPU and wait some time to recheck
clkMgr->oc->systemCoreStuckCount = -6;
Clocks::SetHz(SysClkModule_CPU, clkMgr->MAX_CPU);
Clocks::SetHz(SysClkModule_CPU, clkMgr->CPU_BOOST_FREQ);
}
}
}*/
@@ -370,61 +294,107 @@ void ClockManager::WaitForNextTick()
threadClose(&this->t_CheckSystemCoreStuck_2);
}*/
void ClockManager::checkReverseNXToolAsm(FILE* readFile, uint8_t* flag)
SysClkProfile ClockManager::ReverseNXProfileHandler()
{
// Magic Value
uint8_t Docked[0x10] = {0xE0, 0x03, 0x00, 0x32, 0xC0, 0x03, 0x5F, 0xD6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t Handheld[0x10] = {0x00, 0x00, 0xA0, 0x52, 0xC0, 0x03, 0x5F, 0xD6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t filebuffer[0x10] = {0};
fread(&filebuffer, 1, 16, readFile);
uint8_t cmpresult = 0;
cmpresult = memcmp(filebuffer, Docked, sizeof(Docked));
if (cmpresult != 0)
if (!IsReverseNXEnabled())
{
cmpresult = memcmp(filebuffer, Handheld, sizeof(Handheld));
if (cmpresult != 0)
*flag = 0; // Set to default
else
*flag = 1; // Handheld
return this->context->realProfile;
}
else
*flag = 2; // Docked
fclose(readFile);
if (IsReverseNXDocked())
{
return SysClkProfile_Docked;
}
if (// !IsReversedNXDocked() &&
this->context->realProfile == SysClkProfile_Docked)
{
return SysClkProfile_HandheldChargingOfficial;
}
return this->context->realProfile;
}
void ClockManager::checkReverseNXRT(bool recheckReverseNX, uint8_t* flag)
ReverseNXMode ClockManager::ReverseNXFileHandler(bool checkTool, const char* filePath)
{
FILE* readReverseNXRTConf = fopen(FILE_REVERSENX_RT_CONF_PATH, "rb");
if (readReverseNXRTConf != NULL)
FILE *readFile;
readFile = fopen(filePath, "rb");
if (!readFile)
{
uint8_t ReverseNXRTConfArr[9];
fread(ReverseNXRTConfArr, 9, 1, readReverseNXRTConf);
fclose(readReverseNXRTConf);
remove(FILE_REVERSENX_RT_CONF_PATH);
uint8_t currentTid[8];
for(int i = 0; i < 8; i++)
currentTid[i] = this->context->applicationId >> 8*(7-i);
uint8_t cmpresult = memcmp(currentTid, ReverseNXRTConfArr, sizeof(currentTid));
if (cmpresult == 0)
*flag = ReverseNXRTConfArr[8]; // 1: Handheld, 2: Docked, 3: Reset
else
*flag = 0; // 0: Not applicable
return ReverseNX_NotFound;
}
else if (recheckReverseNX)
*flag = prevReverseNXRT; // Use previous state when profile changes
else
*flag = 0;
if (checkTool)
{
uint64_t magicDocked = 0xD65F03C0320003E0;
uint64_t magicHandheld = 0xD65F03C052A00000;
uint64_t readBuffer = 0;
fread(&readBuffer, 1, sizeof(readBuffer), readFile);
fclose(readFile);
if (!memcmp(&readBuffer, &magicDocked, sizeof(readBuffer)))
return ReverseNX_Docked;
if (!memcmp(&readBuffer, &magicHandheld, sizeof(readBuffer)))
return ReverseNX_Handheld;
}
else // checkRT
{
uint64_t tidBuffer = 0;
uint8_t ctrlBuffer = 0;
fread(&tidBuffer, 1, sizeof(tidBuffer), readFile);
fread(&ctrlBuffer, 1, sizeof(ctrlBuffer), readFile);
fclose(readFile);
remove(filePath);
if (!memcmp(&this->context->applicationId, &tidBuffer, sizeof(tidBuffer)))
{
/* If user toggles -RT overlay, mode set by -Tool remains invalid until the game restarts */
this->oc->reverseNXToolMode = ReverseNX_NotValid;
ReverseNXMode getMode = static_cast<ReverseNXMode>(ctrlBuffer);
this->oc->reverseNXRTMode = getMode;
return getMode;
}
}
return ReverseNX_NotValid;
}
void ClockManager::CheckReverseNXTool()
{
bool shouldCheckReverseNXTool = FileUtils::IsReverseNXSyncEnabled() && FileUtils::ExistReverseNXTool();
if (!shouldCheckReverseNXTool)
return;
ReverseNXMode getMode = ReverseNX_NotValid;
if (this->context->applicationId != PROCESS_MANAGEMENT_QLAUNCH_TID)
{
const char asmFileName[] = "_ZN2nn2oe18GetPerformanceModeEv.asm64"; // Checking one asm64 file is enough
char asmFilePath[128];
/* Check global override */
snprintf(asmFilePath, sizeof(asmFilePath), "/SaltySD/patches/%s", asmFileName);
getMode = ReverseNXFileHandler(true, asmFilePath);
if (!getMode)
{
/* Check per-game override */
snprintf(asmFilePath, sizeof(asmFilePath), "/SaltySD/patches/%016lX/%s", this->context->applicationId, asmFileName);
getMode = ReverseNXFileHandler(true, asmFilePath);
}
}
this->oc->reverseNXToolMode = getMode;
}
bool ClockManager::RefreshContext()
{
bool hasChanged = false;
bool shouldAdjustProfile = false;
bool enabled = this->GetConfig()->Enabled();
if(enabled != this->context->enabled)
@@ -438,81 +408,42 @@ bool ClockManager::RefreshContext()
if (applicationId != this->context->applicationId)
{
FileUtils::LogLine("[mgr] TitleID change: %016lX", applicationId);
prevReverseNXRT = 0; // Reset ReverseNX-RT previous state when Title ID changes
this->context->applicationId = applicationId;
hasChanged = true;
shouldAdjustProfile = true;
if (FileUtils::IsReverseNXSyncEnabled() && (FileUtils::IsReverseNXToolExist() || recheckReverseNX))
{
// A new game starts or the real profile changes, then we need to check if ReverseNXTool patches are applied
isEnabledReverseNX = false;
// Check if ReverseNXTool patches are applied
if (applicationId != PROCESS_MANAGEMENT_QLAUNCH_TID)
this->checkReverseNXTool();
}
/* Clear ReverseNX-RT state and recheck -Tool patches*/
this->oc->reverseNXRTMode = ReverseNX_SystemDefault;
CheckReverseNXTool();
}
if (FileUtils::IsReverseNXSyncEnabled() && (!tickCheckReverseNXRT || recheckReverseNX))
{
uint8_t flag = 0;
checkReverseNXRT(recheckReverseNX, &flag);
switch(flag)
{
case 1:
FileUtils::LogLine("[mgr] ReverseNX-RT detected: Enforce Handheld Mode");
this->context->profile = ReverseNXProfile(false);
prevReverseNXRT = flag;
isEnabledReverseNX = true;
isDockedReverseNX = false;
hasChanged = true;
break;
case 2:
FileUtils::LogLine("[mgr] ReverseNX-RT detected: Enforce Docked Mode");
this->context->profile = ReverseNXProfile(true);
prevReverseNXRT = flag;
isEnabledReverseNX = true;
isDockedReverseNX = true;
hasChanged = true;
break;
case 3:
FileUtils::LogLine("[mgr] ReverseNX-RT disabled: Reset to System-controlled Mode and recheck ReverseNX-Tool");
RealProfile = Clocks::GetCurrentProfile();
this->context->profile = RealProfile;
prevReverseNXRT = 0;
isEnabledReverseNX = false;
isDockedReverseNX = false;
hasChanged = true;
if (this->context->applicationId != PROCESS_MANAGEMENT_QLAUNCH_TID)
this->checkReverseNXTool();
break;
case 0:
if (recheckReverseNX && isEnabledReverseNXTool && this->context->applicationId != PROCESS_MANAGEMENT_QLAUNCH_TID)
this->checkReverseNXTool();
break;
}
tickCheckReverseNXRT = (std::uint32_t)( 1'000 / this->oc->tickWaitTimeMs ) + 1;
}
tickCheckReverseNXRT--;
if (recheckReverseNX)
recheckReverseNX = false;
SysClkProfile profile = Clocks::GetCurrentProfile();
if (profile != this->context->profile && !isEnabledReverseNX)
if (profile != this->context->realProfile)
{
FileUtils::LogLine("[mgr] Profile change: %s", Clocks::GetProfileName(profile, true));
this->context->profile = profile;
this->context->realProfile = profile;
hasChanged = true;
shouldAdjustProfile = true;
}
if (profile != RealProfile && isEnabledReverseNX)
/* Check ReverseNX-RT once per tick */
{
FileUtils::LogLine("[mgr] Profile change: %s, recheck ReverseNX", Clocks::GetProfileName(profile, true));
this->context->profile = profile;
RealProfile = profile;
hasChanged = true;
recheckReverseNX = true;
ReverseNXMode getMode = ReverseNXFileHandler(false, FILE_REVERSENX_RT_CONF_PATH);
if (getMode)
{
this->oc->reverseNXRTMode = getMode;
shouldAdjustProfile = true;
}
if (getMode == ReverseNX_RTResetToDefault)
{
this->oc->reverseNXRTMode = ReverseNX_SystemDefault;
}
if (shouldAdjustProfile)
{
this->context->profile = ReverseNXProfileHandler();
}
}
/* Update PerformanceConfigurationId */

View File

@@ -20,7 +20,6 @@
class ClockManager
{
public:
const std::uint32_t MAX_CPU = 1963500000;
static ClockManager* GetInstance();
static void Initialize();
@@ -47,23 +46,18 @@ class ClockManager
std::uint64_t lastTempLogNs;
std::uint64_t lastCsvWriteNs;
bool recheckReverseNX = false;
bool isEnabledReverseNX = false;
bool isEnabledReverseNXTool = false;
bool isDockedReverseNX = false;
uint16_t tickCheckReverseNXRT = 0;
uint8_t prevReverseNXRT = 0;
SysClkProfile RealProfile;
SysClkOcExtra *oc;
const uint32_t CPU_BOOST_FREQ = 1963'500'000;
bool IsCpuBoostMode();
SysClkProfile ReverseNXProfile(bool);
void checkReverseNXTool();
bool IsReverseNXEnabled();
bool IsReverseNXDocked();
void checkReverseNXToolAsm(FILE*, uint8_t*);
void checkReverseNXRT(bool, uint8_t*);
SysClkOcExtra *oc;
uint32_t GetHz(SysClkModule);
SysClkProfile ReverseNXProfileHandler();
ReverseNXMode ReverseNXFileHandler(bool, const char*);
void CheckReverseNXTool();
// Thread t_CheckSystemCoreStuck_0, t_CheckSystemCoreStuck_1, t_CheckSystemCoreStuck_2;

View File

@@ -12,8 +12,6 @@
#include "clocks.h"
#include "errors.h"
bool Clocks::isMariko = false;
void Clocks::GetList(SysClkModule module, std::uint32_t **outClocks)
{
switch(module)
@@ -37,6 +35,19 @@ void Clocks::Initialize()
{
Result rc = 0;
// Check if it's Mariko
u64 hardware_type = 0;
splInitialize();
splGetConfig(SplConfigItem_HardwareType, &hardware_type);
splExit();
switch (hardware_type) {
case 0: //Icosa
case 1: //Copper
ERROR_THROW("[!] Erista is not supported!");
return;
}
if(hosversionAtLeast(8,0,0))
{
rc = clkrstInitialize();
@@ -290,11 +301,7 @@ std::uint32_t Clocks::GetMaxAllowedHz(SysClkModule module, SysClkProfile profile
{
if(profile < SysClkProfile_HandheldCharging)
{
return isMariko ? 1344000000 : SYSCLK_GPU_HANDHELD_MAX_HZ;
}
else if(profile <= SysClkProfile_HandheldChargingUSB)
{
return isMariko ? 1344000000 : SYSCLK_GPU_UNOFFICIAL_CHARGER_MAX_HZ;
return SYSCLK_GPU_HANDHELD_MAX_HZ;
}
}
@@ -303,92 +310,6 @@ std::uint32_t Clocks::GetMaxAllowedHz(SysClkModule module, SysClkProfile profile
std::uint32_t Clocks::GetNearestHz(SysClkModule module, std::uint32_t inHz)
{
// Hardcoded values to return, or the frequency will ramp up to max as dvfs table is not correct
if(module == SysClkModule_MEM)
{
switch(inHz)
{
// From Hekate Minerva module
case 1331000000:
return 1331200000;
case 1795000000:
return 1795200000;
case 1862000000:
return 1862400000;
case 1894000000:
return 1894400000;
case 1932000000:
return 1932800000;
case 1996000000:
return 1996800000;
case 2099000000:
return 2099200000;
case 2131000000:
return 2131200000;
default:
return inHz;
}
}
if(module == SysClkModule_CPU)
{
switch(inHz)
{
case 1963000000:
return 1963500000;
default:
return inHz;
}
}
if(module == SysClkModule_GPU)
{
switch(inHz)
{
case 76000000:
return 76800000;
case 153000000:
return 153600000;
case 230000000:
return 230400000;
case 307000000:
return 307200000;
case 460000000:
return 460800000;
case 537000000:
return 537600000;
case 614000000:
return 614400000;
case 691000000:
return 691200000;
case 844000000:
return 844800000;
case 921000000:
return 921600000;
case 998000000:
return 998400000;
case 1075000000:
return 1075200000;
case 1228000000:
return 1228800000;
case 1267000000:
return 1267200000;
case 1305000000:
return 1305600000;
case 1382000000:
return 1382400000;
case 1420000000:
return 1420800000;
case 1459000000:
return 1459200000;
case 1497000000:
return 1497600000;
default:
return inHz;
}
}
return inHz;
std::uint32_t *clockTable = NULL;
GetList(module, &clockTable);
@@ -398,16 +319,19 @@ std::uint32_t Clocks::GetNearestHz(SysClkModule module, std::uint32_t inHz)
}
int i = 0;
while(clockTable[i + 1])
while(clockTable[i])
{
if (inHz <= (clockTable[i] + clockTable[i + 1]) / 2)
// if (inHz <= (clockTable[i] + clockTable[i + 1]) / 2)
if ((inHz / 1000'000) == (clockTable[i] / 1000'000))
{
break;
return clockTable[i];
}
i++;
}
return clockTable[i];
/* Freq not found in the table, return inHz regardlessly */
return inHz;
}
std::uint32_t Clocks::GetTemperatureMilli(SysClkThermalSensor sensor)

View File

@@ -16,7 +16,6 @@
class Clocks
{
public:
static bool isMariko;
static void Exit();
static void Initialize();
static void ResetToStock(unsigned int module = SysClkModule_EnumMax);

View File

@@ -19,7 +19,6 @@ static LockableMutex g_csv_mutex;
static std::atomic_bool g_has_initialized = false;
static bool g_log_enabled = false;
static bool g_boost_enabled = false;
static bool g_downclock_dock_enabled = false;
static bool g_reversenx_tool_exist = false;
static bool g_reversenx_sync_enabled = false;
static std::uint64_t g_last_flag_check = 0;
@@ -136,42 +135,11 @@ void FileUtils::RefreshFlags(bool force)
void FileUtils::InitCheckFlags()
{
// Check if it's Mariko
u64 hardware_type = 0;
splInitialize();
splGetConfig(SplConfigItem_HardwareType, &hardware_type);
splExit();
switch(hardware_type) {
case 0: //Icosa
case 1: //Copper
break;
case 2: //Hoag
case 3: //Iowa
case 4: //Calcio
case 5: //Aula
Clocks::isMariko = true;
break;
default:
break;
}
FILE *file;
// Only Enable Boost for Mariko
if (Clocks::isMariko)
{
file = fopen(FILE_BOOST_FLAG_PATH, "r");
if (file)
{
g_boost_enabled = true;
fclose(file);
}
}
file = fopen(FILE_DOWNCLOCK_DOCK_FLAG_PATH, "r");
file = fopen(FILE_BOOST_FLAG_PATH, "r");
if (file)
{
g_downclock_dock_enabled = true;
g_boost_enabled = true;
fclose(file);
}
@@ -195,12 +163,7 @@ bool FileUtils::IsBoostEnabled()
return g_boost_enabled;
}
bool FileUtils::IsDownclockDockEnabled()
{
return g_downclock_dock_enabled;
}
bool FileUtils::IsReverseNXToolExist()
bool FileUtils::ExistReverseNXTool()
{
return g_reversenx_tool_exist;
}
@@ -242,12 +205,11 @@ Result FileUtils::Initialize()
if (R_SUCCEEDED(rc))
{
FileUtils::RefreshFlags(true);
FileUtils::InitCheckFlags();
g_has_initialized = true;
FileUtils::LogLine("=== " TARGET " " TARGET_VERSION " ===");
}
FileUtils::InitCheckFlags();
return rc;
}

View File

@@ -23,8 +23,6 @@
#define FILE_LOG_FLAG_PATH FILE_CONFIG_DIR "/log.flag"
#define FILE_LOG_FILE_PATH FILE_CONFIG_DIR "/log.txt"
#define FILE_BOOST_FLAG_PATH FILE_CONFIG_DIR "/boost.flag"
#define FILE_BOOST_START_FLAG_PATH FILE_CONFIG_DIR "/boost_start.flag"
#define FILE_DOWNCLOCK_DOCK_FLAG_PATH FILE_CONFIG_DIR "/downclock_dock.flag"
#define FILE_SALTYNX_PATH "/atmosphere/contents/0000000000534C56/flags/boot2.flag" // Just check for SaltyNX boot flag
#define FILE_REVERSENX_SYNC_FLAG_PATH FILE_CONFIG_DIR "/ReverseNX_sync.flag"
#define FILE_REVERSENX_RT_CONF_PATH FILE_CONFIG_DIR "/ReverseNX-RT.conf"
@@ -37,9 +35,8 @@ class FileUtils
static bool IsInitialized();
static bool IsLogEnabled();
static bool IsBoostEnabled();
static bool IsDownclockDockEnabled();
static bool IsReverseNXSyncEnabled();
static bool IsReverseNXToolExist();
static bool ExistReverseNXTool();
static void InitializeAsync();
static void LogLine(const char *format, ...);
static void WriteContextToCsv(const SysClkContext* context);