sysclk: finish minimal code

This commit is contained in:
souldbminersmwc
2026-01-04 19:27:27 -05:00
parent 33c49aac86
commit 4ee57e3d01
5 changed files with 86 additions and 65 deletions

View File

@@ -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

View File

@@ -27,7 +27,9 @@
#define TESLA_INIT_IMPL
#include <tesla.hpp>
#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<FatalGui>(
"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<FatalGui>(
"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<FatalGui>(
"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.",

View File

@@ -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;
}

View File

@@ -24,6 +24,9 @@
#include <cstring>
#include <vector>
#include <notification.h>
#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<NamedValue> 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<NamedValue> 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<NamedValue> 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,

View File

@@ -37,6 +37,7 @@
#include "notification.h"
#include <display_refresh_rate.h>
#include <cstring>
#include <cstdio>
#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) {}