From 4ee57e3d01993ff709543b2b1a788b70b76e2c74 Mon Sep 17 00:00:00 2001 From: souldbminersmwc Date: Sun, 4 Jan 2026 19:27:27 -0500 Subject: [PATCH] sysclk: finish minimal code --- Source/sys-clk/overlay/Makefile | 2 +- Source/sys-clk/overlay/src/main.cpp | 10 ++- .../overlay/src/ui/gui/base_menu_gui.h | 5 +- .../sys-clk/overlay/src/ui/gui/misc_gui.cpp | 80 ++++++++----------- .../sys-clk/sysmodule/src/clock_manager.cpp | 54 ++++++++++--- 5 files changed, 86 insertions(+), 65 deletions(-) diff --git a/Source/sys-clk/overlay/Makefile b/Source/sys-clk/overlay/Makefile index d233aea5..34981ef5 100644 --- a/Source/sys-clk/overlay/Makefile +++ b/Source/sys-clk/overlay/Makefile @@ -44,7 +44,7 @@ TARGET_VERSION := $(APP_VERSION) #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -DEFINES := -DDISABLE_IPC -DTARGET="\"$(TARGET)\"" -DTARGET_VERSION="\"$(TARGET_VERSION)\"" +DEFINES := -DDISABLE_IPC -DTARGET="\"$(TARGET)\"" -DTARGET_VERSION="\"$(TARGET_VERSION)\"" -DIS_MINIMAL="\"$(IS_MINIMAL)\"" ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE diff --git a/Source/sys-clk/overlay/src/main.cpp b/Source/sys-clk/overlay/src/main.cpp index 60f39028..8e65ec4c 100644 --- a/Source/sys-clk/overlay/src/main.cpp +++ b/Source/sys-clk/overlay/src/main.cpp @@ -27,7 +27,9 @@ #define TESLA_INIT_IMPL #include - +#ifdef IS_MINIMAL +#warning "Minimal compilation" +#endif #include "ui/gui/fatal_gui.h" #include "ui/gui/main_gui.h" #include "rgltr_services.h" // for extern Service g_rgltrSrv, etc. @@ -57,7 +59,7 @@ class AppOverlay : public tsl::Overlay if(!sysclkIpcRunning()) { return initially( - "sys-clk is not running.\n\n" + "hoc-clk is not running.\n\n" "\n" "Please make sure it is correctly\n\n" "installed and enabled.", @@ -68,7 +70,7 @@ class AppOverlay : public tsl::Overlay if(R_FAILED(sysclkIpcInitialize()) || R_FAILED(sysclkIpcGetAPIVersion(&apiVersion))) { return initially( - "Could not connect to sys-clk.\n\n" + "Could not connect to hoc-clk.\n\n" "\n" "Please make sure it is correctly\n\n" "installed and enabled.", @@ -80,7 +82,7 @@ class AppOverlay : public tsl::Overlay { return initially( "Overlay not compatible with\n\n" - "the running sys-clk version.\n\n" + "the running hoc-clk version.\n\n" "\n" "Please make sure everything is\n\n" "installed and up to date.", diff --git a/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.h b/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.h index 3e65d2c8..d3f9591c 100644 --- a/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.h +++ b/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.h @@ -43,11 +43,10 @@ class BaseMenuGui : public BaseGui bool g_isMariko = false; bool g_isAula = false; bool g_isHoag = false; - SetSysProductModel HWmodel; + SetSysProductModel HWmodel = SetSysProductModel_Invalid; bool IsAula() { if (!g_hardwareModelCached) { - SetSysProductModel HWmodel = SetSysProductModel_Invalid; setsysGetProductModel(&HWmodel); g_hardwareModelCached = true; } @@ -56,7 +55,6 @@ class BaseMenuGui : public BaseGui } bool IsHoag() { if (!g_hardwareModelCached) { - SetSysProductModel HWmodel = SetSysProductModel_Invalid; setsysGetProductModel(&HWmodel); g_hardwareModelCached = true; } @@ -65,7 +63,6 @@ class BaseMenuGui : public BaseGui } bool IsMariko() { if (!g_hardwareModelCached) { - SetSysProductModel HWmodel = SetSysProductModel_Invalid; setsysGetProductModel(&HWmodel); g_hardwareModelCached = true; } diff --git a/Source/sys-clk/overlay/src/ui/gui/misc_gui.cpp b/Source/sys-clk/overlay/src/ui/gui/misc_gui.cpp index 30cc9175..f76db97c 100644 --- a/Source/sys-clk/overlay/src/ui/gui/misc_gui.cpp +++ b/Source/sys-clk/overlay/src/ui/gui/misc_gui.cpp @@ -24,6 +24,9 @@ #include #include #include +#ifdef IS_MINIMAL +#warning "Minimal compilation" +#endif class RamSubmenuGui; class RamTimingsSubmenuGui; @@ -264,7 +267,9 @@ void MiscGui::listUI() addConfigToggle(HocClkConfigValue_UncappedClocks, nullptr); addConfigToggle(HocClkConfigValue_OverwriteBoostMode, nullptr); - addConfigToggle(HocClkConfigValue_FixCpuVoltBug, nullptr); + #ifndef IS_MINIMAL + addConfigToggle(HocClkConfigValue_FixCpuVoltBug, nullptr); + #endif addConfigToggle(HocClkConfigValue_ThermalThrottle, nullptr); addConfigToggle(HocClkConfigValue_HandheldTDP, nullptr); @@ -311,23 +316,6 @@ void MiscGui::listUI() } this->listElement->addItem(new tsl::elm::CategoryHeader("KIP")); - addConfigToggle(HocClkConfigValue_KipEditing, nullptr); - - std::vector kipNameLabels = { - NamedValue("hoc.kip", 0), - NamedValue("loader.kip", 1) - }; - - addConfigButton( - HocClkConfigValue_KipFileName, - "KIP File Name", - ValueRange(0, 1, 1, "", 0), - "KIP File Name", - &thresholdsDisabled, - {}, - kipNameLabels, - false - ); tsl::elm::ListItem* saveBtn = new tsl::elm::ListItem("Save KIP Settings"); saveBtn->setClickListener([](u64 keys) { @@ -373,34 +361,35 @@ void MiscGui::listUI() }); this->listElement->addItem(gpuSubmenu); - this->listElement->addItem(new tsl::elm::CategoryHeader("Experimental")); + #ifndef IS_MINIMAL + this->listElement->addItem(new tsl::elm::CategoryHeader("Experimental")); + std::vector chargerCurrents = { + NamedValue("Disabled", 0), + NamedValue("1024mA", 1024), + NamedValue("1280mA", 1280), + NamedValue("1536mA", 1536), + NamedValue("1792mA", 1792), + NamedValue("2048mA", 2048), + NamedValue("2304mA", 2304), + NamedValue("2560mA", 2560), + NamedValue("2816mA", 2816), + NamedValue("3072mA", 3072), + }; - std::vector chargerCurrents = { - NamedValue("Disabled", 0), - NamedValue("1024mA", 1024), - NamedValue("1280mA", 1280), - NamedValue("1536mA", 1536), - NamedValue("1792mA", 1792), - NamedValue("2048mA", 2048), - NamedValue("2304mA", 2304), - NamedValue("2560mA", 2560), - NamedValue("2816mA", 2816), - NamedValue("3072mA", 3072), - }; + ValueThresholds chargerThresholds(2048, 2560); - ValueThresholds chargerThresholds(2048, 2560); - - addConfigButton( - HorizonOCConfigValue_BatteryChargeCurrent, - "Charge Current Override", - ValueRange(0, 0, 1, "", 0), - "Charge Current Override", - &chargerThresholds, - {}, - chargerCurrents, - false - ); - addConfigToggle(HorizonOCConfigValue_OverwriteRefreshRate, nullptr); + addConfigButton( + HorizonOCConfigValue_BatteryChargeCurrent, + "Charge Current Override", + ValueRange(0, 0, 1, "", 0), + "Charge Current Override", + &chargerThresholds, + {}, + chargerCurrents, + false + ); + addConfigToggle(HorizonOCConfigValue_OverwriteRefreshRate, nullptr); + #endif } @@ -717,8 +706,9 @@ protected: &thresholdsDisabled, {}, {}, - true + false ); + addConfigToggle(KipConfigValue_eristaCpuUnlock, "CPU Unlock"); addConfigButton( KipConfigValue_eristaCpuVmin, diff --git a/Source/sys-clk/sysmodule/src/clock_manager.cpp b/Source/sys-clk/sysmodule/src/clock_manager.cpp index 35e94c75..70590429 100644 --- a/Source/sys-clk/sysmodule/src/clock_manager.cpp +++ b/Source/sys-clk/sysmodule/src/clock_manager.cpp @@ -37,6 +37,7 @@ #include "notification.h" #include #include +#include #define HOSPPC_HAS_BOOST (hosversionAtLeast(7,0,0)) bool isGovernorEnabled = false; // to avoid thread messes @@ -46,6 +47,8 @@ ClockManager *ClockManager::instance = NULL; Thread governorTHREAD; u32 initialConfigValues[SysClkConfigValue_EnumMax]; // initial config. used for safety checks bool writeBootConfigValues = true; // do we write the initial config values? + +bool kipAvailable = false; ClockManager *ClockManager::GetInstance() { return instance; @@ -88,8 +91,7 @@ ClockManager::ClockManager() this->rnxSync = new ReverseNXSync; memset(&initialConfigValues, 0, sizeof(initialConfigValues)); - if(this->config->GetConfigValue(HocClkConfigValue_KipEditing)) - this->GetKipData(); + this->GetKipData(); threadCreate( &governorTHREAD, ClockManager::GovernorThread, @@ -692,8 +694,19 @@ void ClockManager::SetKipData() { // } // } CustomizeTable table; + FILE* fp; + fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "r"); - if (!cust_read_and_cache(this->config->GetConfigValue(HocClkConfigValue_KipFileName) ? "sdmc:/atmosphere/kips/loader.kip" : "sdmc:/atmosphere/kips/hoc.kip", &table)) { + if (fp == NULL) { + writeNotification("Horizon OC\nKip opening failed"); + kipAvailable = false; + return; + } else { + kipAvailable = true; + fclose(fp); + } + + if (!cust_read_and_cache("sdmc:/atmosphere/kips/hoc.kip", &table)) { FileUtils::LogLine("[clock_manager] Failed to read KIP file"); writeNotification("Horizon OC\nKip read failed"); return; @@ -755,7 +768,7 @@ void ClockManager::SetKipData() { table.eristaGpuVoltArray[i] = this->config->GetConfigValue((SysClkConfigValue)(KipConfigValue_g_volt_e_76800 + i)); } - if (!cust_write_table(this->config->GetConfigValue(HocClkConfigValue_KipFileName) ? "sdmc:/atmosphere/kips/loader.kip" : "sdmc:/atmosphere/kips/hoc.kip", &table)) { + if (!cust_write_table("sdmc:/atmosphere/kips/hoc.kip", &table)) { FileUtils::LogLine("[clock_manager] Failed to write KIP file"); writeNotification("Horizon OC\nKip write failed"); } @@ -764,13 +777,26 @@ void ClockManager::SetKipData() { // I know this is very hacky, but the config system in the sysmodule doesn't really support writing void ClockManager::GetKipData() { + FILE* fp; if(this->config->Refresh()) { + + fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "r"); + + if (fp == NULL) { + writeNotification("Horizon OC\nKip opening failed"); + kipAvailable = false; + return; + } else { + kipAvailable = true; + fclose(fp); + } + SysClkConfigValueList configValues; this->config->GetConfigValues(&configValues); CustomizeTable table; - if (!cust_read_and_cache(this->config->GetConfigValue(HocClkConfigValue_KipFileName) ? "sdmc:/atmosphere/kips/loader.kip" : "sdmc:/atmosphere/kips/hoc.kip", &table)) { + if (!cust_read_and_cache("sdmc:/atmosphere/kips/hoc.kip", &table)) { FileUtils::LogLine("[clock_manager] Failed to read KIP file for GetKipData"); writeNotification("Horizon OC\nKip read failed"); return; @@ -907,13 +933,21 @@ void ClockManager::GetKipData() { } void ClockManager::UpdateRamTimings() { - if(!this->config->GetConfigValue(HocClkConfigValue_KipEditing)) - return; + FILE* fp; + fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "r"); + if (fp == NULL) { + writeNotification("Horizon OC\nKip opening failed"); + kipAvailable = false; + return; + } else { + kipAvailable = true; + fclose(fp); + } CustomizeTable table; - if (!cust_read_and_cache(this->config->GetConfigValue(HocClkConfigValue_KipFileName) ? "sdmc:/atmosphere/kips/loader.kip" : "sdmc:/atmosphere/kips/hoc.kip", &table)) { - FileUtils::LogLine("[clock_manager] Failed to read KIP file for GetKipData"); + if (!cust_read_and_cache("sdmc:/atmosphere/kips/hoc.kip", &table)) { + FileUtils::LogLine("[clock_manager] Failed to read KIP file for UpdateRamTimings"); writeNotification("Horizon OC\nKip read failed"); return; } @@ -992,5 +1026,3 @@ void ClockManager::calculateGpuVmin (void) this->config->SetConfigValues(&configValues, true); } } - -void ClockManager::CalculatePMICLimit(void) {} \ No newline at end of file