From 8fc18ee3e820f1e3fab64d7dcdb76fb8dc2ca6cb Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Fri, 11 Sep 2026 13:11:04 +0200 Subject: [PATCH] fix namespace overusage --- Source/hoc-clk/sysmodule/src/board/board.cpp | 8 +- Source/hoc-clk/sysmodule/src/board/board.hpp | 2 +- .../sysmodule/src/board/board_freq.cpp | 10 +- .../sysmodule/src/board/board_sensor.cpp | 4 +- .../sysmodule/src/board/board_volt.cpp | 10 +- Source/hoc-clk/sysmodule/src/bpmp/bpmp.cpp | 30 +-- Source/hoc-clk/sysmodule/src/display/aula.cpp | 6 +- Source/hoc-clk/sysmodule/src/display/aula.hpp | 2 +- Source/hoc-clk/sysmodule/src/file/config.cpp | 96 +++---- Source/hoc-clk/sysmodule/src/file/config.hpp | 4 +- Source/hoc-clk/sysmodule/src/file/errors.cpp | 6 +- Source/hoc-clk/sysmodule/src/file/errors.hpp | 4 +- .../hoc-clk/sysmodule/src/file/file_utils.cpp | 4 +- .../hoc-clk/sysmodule/src/file/file_utils.hpp | 4 +- Source/hoc-clk/sysmodule/src/file/kip.cpp | 240 +++++++++--------- Source/hoc-clk/sysmodule/src/file/kip.hpp | 4 +- .../sysmodule/src/hos/integrations.cpp | 8 +- .../sysmodule/src/hos/integrations.hpp | 4 +- Source/hoc-clk/sysmodule/src/hos/lang.cpp | 4 +- Source/hoc-clk/sysmodule/src/hos/lang.hpp | 4 +- .../sysmodule/src/hos/notification.cpp | 8 +- .../hoc-clk/sysmodule/src/hos/notification.h | 4 +- .../sysmodule/src/hos/process_management.cpp | 10 +- .../sysmodule/src/hos/process_management.hpp | 10 +- .../hoc-clk/sysmodule/src/ipc/ipc_service.cpp | 36 +-- Source/hoc-clk/sysmodule/src/main.cpp | 32 +-- .../hoc-clk/sysmodule/src/mapping/mem_map.cpp | 2 +- .../sysmodule/src/mgr/clock_manager.cpp | 166 ++++++------ .../sysmodule/src/mgr/clock_manager.hpp | 4 +- Source/hoc-clk/sysmodule/src/mgr/governor.cpp | 98 +++---- Source/hoc-clk/sysmodule/src/mgr/governor.hpp | 8 +- Source/hoc-clk/sysmodule/src/soc/dram_mrr.cpp | 2 +- Source/hoc-clk/sysmodule/src/soc/dram_mrr.hpp | 2 +- Source/hoc-clk/sysmodule/src/soc/gm20b.cpp | 6 +- Source/hoc-clk/sysmodule/src/soc/gm20b.hpp | 4 +- .../hoc-clk/sysmodule/src/tsensor/aotag.cpp | 2 +- .../hoc-clk/sysmodule/src/tsensor/bq24193.cpp | 6 +- .../hoc-clk/sysmodule/src/tsensor/bq24193.hpp | 6 +- .../sysmodule/src/tsensor/soctherm.cpp | 2 +- Source/hoc-clk/sysmodule/src/util/crc32.cpp | 8 +- Source/hoc-clk/sysmodule/src/util/crc32.h | 8 +- 41 files changed, 438 insertions(+), 440 deletions(-) diff --git a/Source/hoc-clk/sysmodule/src/board/board.cpp b/Source/hoc-clk/sysmodule/src/board/board.cpp index 503c282b..2030a615 100644 --- a/Source/hoc-clk/sysmodule/src/board/board.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board.cpp @@ -192,7 +192,7 @@ namespace board { Result bpmpfwRc = bpmp::StartBpmfwExecution(); if (R_FAILED(bpmpfwRc)) { - fileUtils::LogLine("[bpmp] StartBpmfwExecution failed: 0x%x", bpmpfwRc); + file::utils::LogLine("[bpmp] StartBpmfwExecution failed: 0x%x", bpmpfwRc); } bpmp::StartSleepMonitorThread(); @@ -255,7 +255,7 @@ namespace board { } #define MMIO32(addr) (*reinterpret_cast(addr)) - NX_NORETURN void panic(u32 c) { + NX_NORETURN void Panic(u32 c) { SmcReadWriteRegister(0x7000EC40 /* PMC_BASE + APBDEV_PMC_SCRATCH200 */, ~0, c); /* Write timer magic */ @@ -287,7 +287,7 @@ namespace board { } u8 GetDramID() { - return soc::mrr::IdentifyDramId(); + return soc::IdentifyDramId(); } u8 GetFuseDramId() { @@ -301,7 +301,7 @@ namespace board { svcCallSecureMonitor(&args); 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; } diff --git a/Source/hoc-clk/sysmodule/src/board/board.hpp b/Source/hoc-clk/sysmodule/src/board/board.hpp index 9f9cf356..178ba09e 100644 --- a/Source/hoc-clk/sysmodule/src/board/board.hpp +++ b/Source/hoc-clk/sysmodule/src/board/board.hpp @@ -62,6 +62,6 @@ namespace board { bool IsDram8GB(); void SetDisplayRefreshDockedState(bool docked); FuseData *GetFuseData(); - NX_NORETURN void panic(u32 c); + NX_NORETURN void Panic(u32 c); } // namespace board diff --git a/Source/hoc-clk/sysmodule/src/board/board_freq.cpp b/Source/hoc-clk/sysmodule/src/board/board_freq.cpp index 458419cc..c700eb72 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_freq.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_freq.cpp @@ -82,10 +82,10 @@ namespace board { void HandleCpuUv() { 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 - board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), - board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf))); + board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow), file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), + board::CalculateTbreak(file::config::GetConfigValue(KipConfigValue_tableConf))); } void SetHz(HocClkModule module, u32 hz) { @@ -130,11 +130,11 @@ namespace board { PcvSetHz(GetPcvModule(module), pcvHz); } } - if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv) && module == HocClkModule_CPU) { + if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv) && module == HocClkModule_CPU) { HandleCpuUv(); } if (useGm20b) { - if (gm20b::setClock(hz / 1000)) { + if (soc::SetClock(hz / 1000)) { currentInjectedHz = hz; } } diff --git a/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp b/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp index ba1a7ae8..4c383e7f 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp @@ -55,7 +55,7 @@ namespace board { s32 PollDramMr4TempMilli() { u8 mr4 = 0; - if (!soc::mrr::ReadRamMr4(&mr4)) + if (!soc::ReadRamMr4(&mr4)) return 0; /* stock exosphere */ /* TODO: verify this table manually*/ @@ -132,7 +132,7 @@ namespace board { break; } case HocClkThermalSensor_BQ24193: { - millis = bq24193::getBQTemp(); + millis = tsensor::GetBqTemp(); break; } case HocClkThermalSensor_AO: { diff --git a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp index af43b344..21d0e3e1 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp @@ -283,7 +283,7 @@ namespace board { bool ValidateHandle(Handle handle) { if (handle == INVALID_HANDLE) { - fileUtils::LogLine("Invalid handle!"); + file::utils::LogLine("Invalid handle!"); return false; } @@ -319,7 +319,7 @@ namespace board { if (R_FAILED(resultProcessMemory) || !address) { 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; return; } @@ -359,11 +359,11 @@ namespace board { // Print info AFTER we exit the handle to avoid hangs 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) { - 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; } @@ -412,7 +412,7 @@ namespace board { ASSERT_RESULT_OK(WriteGpuVoltTable(table), "WriteGpuVoltTable"); 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) { diff --git a/Source/hoc-clk/sysmodule/src/bpmp/bpmp.cpp b/Source/hoc-clk/sysmodule/src/bpmp/bpmp.cpp index ee5e8d6e..d28d3351 100644 --- a/Source/hoc-clk/sysmodule/src/bpmp/bpmp.cpp +++ b/Source/hoc-clk/sysmodule/src/bpmp/bpmp.cpp @@ -128,7 +128,7 @@ namespace bpmp { const u32 cmd = HocClkBpmpCmd_RequestShutdown; Result rc = SmcCopyToIram(WorkRamPhysBase + offsetof(HocClkBpmpSharedInfo, cmd), &cmd, sizeof(cmd)); if (R_FAILED(rc)) { - fileUtils::LogLine("[bpmp] RequestBpmpExitAndWait: SmcCopyToIram failed: 0x%x", rc); + file::utils::LogLine("[bpmp] RequestBpmpExitAndWait: SmcCopyToIram failed: 0x%x", rc); return; } @@ -145,8 +145,8 @@ namespace bpmp { } } - fileUtils::LogLine("[bpmp] RequestBpmpExitAndWait: BPMP timeout (cannot sleep)"); - board::panic(board::CpuPanic); + file::utils::LogLine("[bpmp] RequestBpmpExitAndWait: BPMP timeout (cannot sleep)"); + board::Panic(board::CpuPanic); } void EnableBpmpSmmu() { @@ -200,7 +200,7 @@ namespace bpmp { void SendBpmpCommand(HocClkBpmpCmd cmd, u32 arg1 = 0, u32 arg2 = 0, u32 arg3 = 0, u32 arg4 = 0) { if (!WaitForBpmpReady()) { - fileUtils::LogLine("[bpmp] SendBpmpCommand: BPMP never signaled ready (cmd=%u)", static_cast(cmd)); + file::utils::LogLine("[bpmp] SendBpmpCommand: BPMP never signaled ready (cmd=%u)", static_cast(cmd)); return; } @@ -216,7 +216,7 @@ namespace bpmp { const Result rc = SmcCopyToIram(WorkRamPhysBase + offsetof(HocClkBpmpSharedInfo, cmd), &req, sizeof(req)); if (R_FAILED(rc)) { - fileUtils::LogLine("[bpmp] SendBpmpCommand: SmcCopyToIram failed: 0x%x (cmd=%u)", rc, static_cast(cmd)); + file::utils::LogLine("[bpmp] SendBpmpCommand: SmcCopyToIram failed: 0x%x (cmd=%u)", rc, static_cast(cmd)); } } @@ -261,7 +261,7 @@ namespace bpmp { Result wrc = StartBpmfwExecution(); 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; @@ -279,19 +279,19 @@ namespace bpmp { Result StartBpmfwExecution() { if (!IsPatchedExosphere()) { - fileUtils::LogLine("[bpmp] Cannot start without patched exosphere"); + file::utils::LogLine("[bpmp] Cannot start without patched exosphere"); return (Result)1; } const size_t fw_size = bpmpfw_bin_size; 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; } 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(FwIramPhysBase)); /* 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(chunk)); 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; } } @@ -340,26 +340,26 @@ namespace bpmp { /* Clear the halt written by bootloader. */ SmcReadWriteRegister(FlowCtlrPhysBase + FlowCtlrHaltCopEvents, 0xFFFFFFFF, FlowModeNone); - SendBpmpCommand(HocClkBpmpCmd_SetUartEnabled, fileUtils::IsUartEnabled() ? 1u : 0u); + SendBpmpCommand(HocClkBpmpCmd_SetUartEnabled, file::utils::IsUartEnabled() ? 1u : 0u); return 0; } void StartSleepMonitorThread() { if (!IsPatchedExosphere()) { - fileUtils::LogLine("[bpmp] Cant start BPMP without exosphere patch"); + file::utils::LogLine("[bpmp] Cant start BPMP without exosphere patch"); return; } Result rc = pscmInitialize(); if (R_FAILED(rc)) { - fileUtils::LogLine("[bpmp] pscmInitialize failed: 0x%x", rc); + file::utils::LogLine("[bpmp] pscmInitialize failed: 0x%x", rc); return; } rc = pscmGetPmModule(&s_pscModule, PscModuleId, pscDependencies, sizeof(pscDependencies) / sizeof(u32), true); if (R_FAILED(rc)) { - fileUtils::LogLine("[bpmp] pscmGetPmModule failed: 0x%x", rc); + file::utils::LogLine("[bpmp] pscmGetPmModule failed: 0x%x", rc); pscmExit(); return; } @@ -367,7 +367,7 @@ namespace bpmp { rc = threadCreate(&s_pscThread, PscThreadFunc, nullptr, NULL, 0x1000, 0x10, 3); 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; } threadStart(&s_pscThread); diff --git a/Source/hoc-clk/sysmodule/src/display/aula.cpp b/Source/hoc-clk/sysmodule/src/display/aula.cpp index 7a6297da..bb8e4eca 100644 --- a/Source/hoc-clk/sysmodule/src/display/aula.cpp +++ b/Source/hoc-clk/sysmodule/src/display/aula.cpp @@ -22,11 +22,9 @@ // 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 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) { 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); } -} // namespace AulaDisplay \ No newline at end of file +} // namespace display \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/display/aula.hpp b/Source/hoc-clk/sysmodule/src/display/aula.hpp index 14537fd7..e42b2626 100644 --- a/Source/hoc-clk/sysmodule/src/display/aula.hpp +++ b/Source/hoc-clk/sysmodule/src/display/aula.hpp @@ -18,6 +18,6 @@ #pragma once #include "../board/board.hpp" -namespace AulaDisplay { +namespace display { void SetDisplayColorMode(AulaColorMode mode); } \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/file/config.cpp b/Source/hoc-clk/sysmodule/src/file/config.cpp index d46089b4..92eb9053 100644 --- a/Source/hoc-clk/sysmodule/src/file/config.cpp +++ b/Source/hoc-clk/sysmodule/src/file/config.cpp @@ -49,7 +49,7 @@ #include #include -namespace config { +namespace file::config { uint64_t configValues[HocClkConfigValue_EnumMax]; @@ -122,14 +122,14 @@ namespace config { std::uint64_t input = strtoul(value, NULL, 0); if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) { 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; 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; } @@ -147,14 +147,14 @@ namespace config { std::uint64_t input = strtoul(value, NULL, 0); if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) { 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; 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; } @@ -216,26 +216,26 @@ namespace config { } void LoadSettings() { - fileUtils::LogLine("[cfg] Reading %s", gSettingsPath.c_str()); + file::utils::LogLine("[cfg] Reading %s", gSettingsPath.c_str()); gSettingsMtime = CheckFileMtime(gSettingsPath.c_str()); if (!gSettingsMtime) { - fileUtils::LogLine("[cfg] Settings file not found, using defaults"); + file::utils::LogLine("[cfg] Settings file not found, using defaults"); return; } 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() { - fileUtils::LogLine("[cfg] Reading %s", gKipPath.c_str()); + file::utils::LogLine("[cfg] Reading %s", gKipPath.c_str()); gKipMtime = CheckFileMtime(gKipPath.c_str()); if (!gKipMtime) { - fileUtils::LogLine("[cfg] KIP config file not found, using defaults"); + file::utils::LogLine("[cfg] KIP config file not found, using defaults"); return; } 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; 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); gProfileMtimes[tid] = st.st_mtime; } else { @@ -341,7 +341,7 @@ namespace config { return 1; } } - fileUtils::LogLine("[cfg] Skipping unrecognized key '%s'", key); + file::utils::LogLine("[cfg] Skipping unrecognized key '%s'", key); } else { std::uint64_t tid = strtoul(section, NULL, 16); if (tid && strlen(section) == 16) { @@ -357,28 +357,28 @@ namespace config { return; } - fileUtils::LogLine("[cfg] Migrating legacy config.ini"); - fileUtils::LogLine("[cfg] Legacy path: %s", gLegacyPath.c_str()); - fileUtils::LogLine("[cfg] Settings path: %s", gSettingsPath.c_str()); - fileUtils::LogLine("[cfg] Profiles dir: %s", gProfilesDir.c_str()); + file::utils::LogLine("[cfg] Migrating legacy config.ini"); + file::utils::LogLine("[cfg] Legacy path: %s", gLegacyPath.c_str()); + file::utils::LogLine("[cfg] Settings path: %s", gSettingsPath.c_str()); + file::utils::LogLine("[cfg] Profiles dir: %s", gProfilesDir.c_str()); MigrationData data; - fileUtils::LogLine("[cfg] Parsing legacy config.ini..."); + file::utils::LogLine("[cfg] Parsing legacy config.ini..."); 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()); 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); - 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 sKeys; std::vector sVals; sKeys.reserve(data.settingsKeys.size()); sVals.reserve(data.settingsKeys.size()); 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); sVals.push_back(entry.second); } @@ -395,23 +395,23 @@ namespace config { valPtrs.push_back(NULL); 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 { - fileUtils::LogLine("[cfg] Settings migration done"); + file::utils::LogLine("[cfg] Settings migration done"); } } else { - fileUtils::LogLine("[cfg] No settings keys to migrate"); + file::utils::LogLine("[cfg] No settings keys to migrate"); } 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 kKeys; std::vector kVals; kKeys.reserve(data.kipKeys.size()); kVals.reserve(data.kipKeys.size()); 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); kVals.push_back(entry.second); } @@ -428,9 +428,9 @@ namespace config { kValPtrs.push_back(NULL); 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 { - fileUtils::LogLine("[cfg] KIP migration done"); + file::utils::LogLine("[cfg] KIP migration done"); } for (const auto &entry : data.kipKeys) { @@ -448,10 +448,10 @@ namespace config { } } } 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); std::map>> profileBuckets; @@ -459,20 +459,20 @@ namespace config { 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) { char filename[32]; snprintf(filename, sizeof(filename), "%016lX.ini", bucket.first); 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 pKeys; std::vector pVals; pKeys.reserve(bucket.second.size()); pVals.reserve(bucket.second.size()); 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); pVals.push_back(kv.second); } @@ -489,17 +489,17 @@ namespace config { valPtrs.push_back(NULL); 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) { - fileUtils::LogLine("[cfg] WARNING: Failed to rename legacy config file"); + file::utils::LogLine("[cfg] WARNING: Failed to rename legacy config file"); } gMigrationHappened = true; - fileUtils::LogLine("[cfg] Migration complete"); + file::utils::LogLine("[cfg] Migration complete"); } } // namespace @@ -570,7 +570,7 @@ namespace config { auto it = gProfileMtimes.find(HOCCLK_GLOBAL_PROFILE_TID); time_t known = (it != gProfileMtimes.end()) ? it->second : 0; 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(); profilesChanged = true; } @@ -580,7 +580,7 @@ namespace config { auto it = gProfileMtimes.find(gCurrentGameTid); time_t known = (it != gProfileMtimes.end()) ? it->second : 0; 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(); profilesChanged = true; } @@ -676,7 +676,7 @@ namespace config { if (keys.empty()) { struct stat st; 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; } } else if (!ini_putsection(CONFIG_VAL_SECTION, keyPointers.data(), valuePointers.data(), profilePath)) { @@ -829,9 +829,9 @@ namespace config { if (immediate) { for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) { if (hocclkValidConfigValue((HocClkConfigValue)kval, configValues->values[kval])) { - config::configValues[kval] = configValues->values[kval]; + file::config::configValues[kval] = configValues->values[kval]; } else { - config::configValues[kval] = hocclkDefaultConfigValue((HocClkConfigValue)kval); + file::config::configValues[kval] = hocclkDefaultConfigValue((HocClkConfigValue)kval); } } SetProfileDirty(true); @@ -842,7 +842,7 @@ namespace config { bool ResetConfigValue(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; } @@ -869,12 +869,12 @@ namespace config { const char *targetPath = hocclkIsKipConfigValue(kval) ? gKipPath.c_str() : gSettingsPath.c_str(); 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; } 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); return true; @@ -923,4 +923,4 @@ namespace config { ini_puts(section, key, NULL, gSettingsPath.c_str()); ini_puts(section, key, NULL, gKipPath.c_str()); } -} // namespace config +} // namespace file::config diff --git a/Source/hoc-clk/sysmodule/src/file/config.hpp b/Source/hoc-clk/sysmodule/src/file/config.hpp index 3ea6fc5d..b23ed167 100644 --- a/Source/hoc-clk/sysmodule/src/file/config.hpp +++ b/Source/hoc-clk/sysmodule/src/file/config.hpp @@ -33,7 +33,7 @@ #define CONFIG_VAL_SECTION "values" -namespace config { +namespace file::config { void Initialize(); void Exit(); @@ -65,4 +65,4 @@ namespace config { extern uint64_t configValues[HocClkConfigValue_EnumMax]; -} // namespace config +} // namespace file::config diff --git a/Source/hoc-clk/sysmodule/src/file/errors.cpp b/Source/hoc-clk/sysmodule/src/file/errors.cpp index 14625cdd..b01171a9 100644 --- a/Source/hoc-clk/sysmodule/src/file/errors.cpp +++ b/Source/hoc-clk/sysmodule/src/file/errors.cpp @@ -30,13 +30,13 @@ #include "errors.hpp" #include "file_utils.hpp" -namespace errors { +namespace file::utils { void ThrowException(const char *format, ...) { va_list args; va_start(args, format); - fileUtils::LogLine(format, args); + LogLine(format, args); va_end(args); diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen)); // throw std::runtime_error(msg); } -} // namespace errors +} // namespace file::utils diff --git a/Source/hoc-clk/sysmodule/src/file/errors.hpp b/Source/hoc-clk/sysmodule/src/file/errors.hpp index ff9d5c7b..6814c4a4 100644 --- a/Source/hoc-clk/sysmodule/src/file/errors.hpp +++ b/Source/hoc-clk/sysmodule/src/file/errors.hpp @@ -29,7 +29,7 @@ #include #include -#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 ASSERT_RESULT_OK(rc, format, ...) \ if (R_FAILED(rc)) { \ @@ -40,7 +40,7 @@ ERROR_THROW("No such %s: %u", #n, v); \ } -namespace errors { +namespace file::utils { void ThrowException(const char *format, ...); diff --git a/Source/hoc-clk/sysmodule/src/file/file_utils.cpp b/Source/hoc-clk/sysmodule/src/file/file_utils.cpp index 169eb87b..9d049d7b 100644 --- a/Source/hoc-clk/sysmodule/src/file/file_utils.cpp +++ b/Source/hoc-clk/sysmodule/src/file/file_utils.cpp @@ -35,7 +35,7 @@ extern "C" void __libnx_init_time(void); -namespace fileUtils { +namespace file::utils { namespace { @@ -234,4 +234,4 @@ namespace fileUtils { fsExit(); } -} // namespace fileUtils +} // namespace file::utils diff --git a/Source/hoc-clk/sysmodule/src/file/file_utils.hpp b/Source/hoc-clk/sysmodule/src/file/file_utils.hpp index 954f8889..1ffc5c27 100644 --- a/Source/hoc-clk/sysmodule/src/file/file_utils.hpp +++ b/Source/hoc-clk/sysmodule/src/file/file_utils.hpp @@ -45,7 +45,7 @@ #define FILE_PROFILES_DIR FILE_CONFIG_DIR "/profiles" #define FILE_LEGACY_CONFIG_PATH FILE_CONFIG_DIR "/config.ini" -namespace fileUtils { +namespace file::utils { void Exit(); Result Initialize(); @@ -56,4 +56,4 @@ namespace fileUtils { void LogLine(const char *format, ...); void WriteContextToCsv(const HocClkContext *context); -} // namespace fileUtils +} // namespace file::utils diff --git a/Source/hoc-clk/sysmodule/src/file/kip.cpp b/Source/hoc-clk/sysmodule/src/file/kip.cpp index e1e63d5a..83e21af4 100644 --- a/Source/hoc-clk/sysmodule/src/file/kip.cpp +++ b/Source/hoc-clk/sysmodule/src/file/kip.cpp @@ -22,22 +22,22 @@ #include "../mapping/mem_map.hpp" #include "kip.hpp" -namespace kip { +namespace file::kip { bool kipAvailable = false; void SetKipData() { // TODO: figure out if this REALLY causes issues (i doubt it) // if(board::GetSocType() == HocClkSocType_Mariko) { - // if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) { - // fileUtils::LogLine("[clock_manager] Failed set i2c vddq"); - // notification::writeNotification("Horizon OC\nFailed to write I2C\nwhile setting vddq"); + // if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, file::config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) { + // file::utils::LogLine("[clock_manager] Failed set i2c vddq"); + // hos::WriteNotification("Horizon OC\nFailed to write I2C\nwhile setting vddq"); // } // } CustomizeTable table; FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "r+b"); if (fp == NULL) { - notification::writeNotification("Horizon OC\nKip opening failed"); + hos::WriteNotification("Horizon OC\nKip opening failed"); kipAvailable = false; return; } @@ -45,8 +45,8 @@ namespace kip { if (!cust_read_table_f(fp, &table)) { fclose(fp); - fileUtils::LogLine("[kip] Failed to read KIP file"); - notification::writeNotification("Horizon OC\nKip read failed"); + file::utils::LogLine("[kip] Failed to read KIP file"); + hos::WriteNotification("Horizon OC\nKip read failed"); return; } @@ -54,121 +54,121 @@ namespace kip { u32 kipVersion = cust_get_kip_version(&table); if (custRev < CUST_REV || kipVersion < KIP_VERSION) { fclose(fp); - notification::writeNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC"); - fileUtils::LogLine("Cust revision: %u", custRev); - fileUtils::LogLine("Kip version: %u", kipVersion); + hos::WriteNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC"); + file::utils::LogLine("Cust revision: %u", custRev); + file::utils::LogLine("Kip version: %u", kipVersion); return; } else if (custRev > CUST_REV || kipVersion > KIP_VERSION) { fclose(fp); - notification::writeNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC"); - fileUtils::LogLine("Cust revision: %u", custRev); - fileUtils::LogLine("Kip version: %u", kipVersion); + hos::WriteNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC"); + file::utils::LogLine("Cust revision: %u", custRev); + file::utils::LogLine("Kip version: %u", kipVersion); return; } - // CUST_WRITE_FIELD_BATCH(&table, mtcConf, config::GetConfigValue(KipConfigValue_mtcConf)); - CUST_WRITE_FIELD_BATCH(&table, hpMode, config::GetConfigValue(KipConfigValue_hpMode)); + // CUST_WRITE_FIELD_BATCH(&table, mtcConf, file::config::GetConfigValue(KipConfigValue_mtcConf)); + 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, eristaEmcMaxClock, config::GetConfigValue(KipConfigValue_eristaEmcMaxClock)); - CUST_WRITE_FIELD_BATCH(&table, marikoEmcMaxClock, config::GetConfigValue(KipConfigValue_marikoEmcMaxClock)); - CUST_WRITE_FIELD_BATCH(&table, marikoEmcVddqVolt, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt)); - CUST_WRITE_FIELD_BATCH(&table, emcDvbShift, config::GetConfigValue(KipConfigValue_emcDvbShift)); - CUST_WRITE_FIELD_BATCH(&table, marikoSocVmax, config::GetConfigValue(KipConfigValue_marikoSocVmax)); + CUST_WRITE_FIELD_BATCH(&table, commonEmcMemVolt, file::config::GetConfigValue(KipConfigValue_commonEmcMemVolt)); + CUST_WRITE_FIELD_BATCH(&table, eristaEmcMaxClock, file::config::GetConfigValue(KipConfigValue_eristaEmcMaxClock)); + CUST_WRITE_FIELD_BATCH(&table, marikoEmcMaxClock, file::config::GetConfigValue(KipConfigValue_marikoEmcMaxClock)); + CUST_WRITE_FIELD_BATCH(&table, marikoEmcVddqVolt, file::config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt)); + CUST_WRITE_FIELD_BATCH(&table, emcDvbShift, file::config::GetConfigValue(KipConfigValue_emcDvbShift)); + 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, t2_tRP, config::GetConfigValue(KipConfigValue_t2_tRP)); - CUST_WRITE_FIELD_BATCH(&table, t3_tRAS, config::GetConfigValue(KipConfigValue_t3_tRAS)); - CUST_WRITE_FIELD_BATCH(&table, t4_tRRD, config::GetConfigValue(KipConfigValue_t4_tRRD)); - CUST_WRITE_FIELD_BATCH(&table, t5_tRFC, config::GetConfigValue(KipConfigValue_t5_tRFC)); - CUST_WRITE_FIELD_BATCH(&table, t6_tRTW, config::GetConfigValue(KipConfigValue_t6_tRTW)); - CUST_WRITE_FIELD_BATCH(&table, t7_tWTR, config::GetConfigValue(KipConfigValue_t7_tWTR)); - CUST_WRITE_FIELD_BATCH(&table, t8_tREFI, config::GetConfigValue(KipConfigValue_t8_tREFI)); - CUST_WRITE_FIELD_BATCH(&table, stepMode, config::GetConfigValue(KipConfigValue_stepMode)); + CUST_WRITE_FIELD_BATCH(&table, t1_tRCD, file::config::GetConfigValue(KipConfigValue_t1_tRCD)); + CUST_WRITE_FIELD_BATCH(&table, t2_tRP, file::config::GetConfigValue(KipConfigValue_t2_tRP)); + CUST_WRITE_FIELD_BATCH(&table, t3_tRAS, file::config::GetConfigValue(KipConfigValue_t3_tRAS)); + CUST_WRITE_FIELD_BATCH(&table, t4_tRRD, file::config::GetConfigValue(KipConfigValue_t4_tRRD)); + CUST_WRITE_FIELD_BATCH(&table, t5_tRFC, file::config::GetConfigValue(KipConfigValue_t5_tRFC)); + CUST_WRITE_FIELD_BATCH(&table, t6_tRTW, file::config::GetConfigValue(KipConfigValue_t6_tRTW)); + CUST_WRITE_FIELD_BATCH(&table, t7_tWTR, file::config::GetConfigValue(KipConfigValue_t7_tWTR)); + CUST_WRITE_FIELD_BATCH(&table, t8_tREFI, file::config::GetConfigValue(KipConfigValue_t8_tREFI)); + 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, low_t1_tRCD, 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_t3_tRAS, 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_t5_tRFC, 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_t7_tWTR, 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, timingEmcTbreak, file::config::GetConfigValue(KipConfigValue_timingEmcTbreak)); + CUST_WRITE_FIELD_BATCH(&table, low_t1_tRCD, file::config::GetConfigValue(KipConfigValue_low_t1_tRCD)); + CUST_WRITE_FIELD_BATCH(&table, low_t2_tRP, file::config::GetConfigValue(KipConfigValue_low_t2_tRP)); + CUST_WRITE_FIELD_BATCH(&table, low_t3_tRAS, file::config::GetConfigValue(KipConfigValue_low_t3_tRAS)); + CUST_WRITE_FIELD_BATCH(&table, low_t4_tRRD, file::config::GetConfigValue(KipConfigValue_low_t4_tRRD)); + CUST_WRITE_FIELD_BATCH(&table, low_t5_tRFC, file::config::GetConfigValue(KipConfigValue_low_t5_tRFC)); + CUST_WRITE_FIELD_BATCH(&table, low_t6_tRTW, file::config::GetConfigValue(KipConfigValue_low_t6_tRTW)); + CUST_WRITE_FIELD_BATCH(&table, low_t7_tWTR, file::config::GetConfigValue(KipConfigValue_low_t7_tWTR)); + 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, readLatency1600, config::GetConfigValue(KipConfigValue_read_latency_1600)); - CUST_WRITE_FIELD_BATCH(&table, readLatency1866, config::GetConfigValue(KipConfigValue_read_latency_1866)); - CUST_WRITE_FIELD_BATCH(&table, readLatency2133, config::GetConfigValue(KipConfigValue_read_latency_2133)); + CUST_WRITE_FIELD_BATCH(&table, readLatency1333, file::config::GetConfigValue(KipConfigValue_read_latency_1333)); + CUST_WRITE_FIELD_BATCH(&table, readLatency1600, file::config::GetConfigValue(KipConfigValue_read_latency_1600)); + CUST_WRITE_FIELD_BATCH(&table, readLatency1866, file::config::GetConfigValue(KipConfigValue_read_latency_1866)); + 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, writeLatency1600, config::GetConfigValue(KipConfigValue_write_latency_1600)); - CUST_WRITE_FIELD_BATCH(&table, writeLatency1866, config::GetConfigValue(KipConfigValue_write_latency_1866)); - CUST_WRITE_FIELD_BATCH(&table, writeLatency2133, config::GetConfigValue(KipConfigValue_write_latency_2133)); + CUST_WRITE_FIELD_BATCH(&table, writeLatency1333, file::config::GetConfigValue(KipConfigValue_write_latency_1333)); + CUST_WRITE_FIELD_BATCH(&table, writeLatency1600, file::config::GetConfigValue(KipConfigValue_write_latency_1600)); + CUST_WRITE_FIELD_BATCH(&table, writeLatency1866, file::config::GetConfigValue(KipConfigValue_write_latency_1866)); + 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, eristaCpuVmin, config::GetConfigValue(KipConfigValue_eristaCpuVmin)); - CUST_WRITE_FIELD_BATCH(&table, eristaCpuMaxVolt, config::GetConfigValue(KipConfigValue_eristaCpuMaxVolt)); - CUST_WRITE_FIELD_BATCH(&table, eristaCpuUnlock, config::GetConfigValue(KipConfigValue_eristaCpuUnlock)); + CUST_WRITE_FIELD_BATCH(&table, eristaCpuUV, file::config::GetConfigValue(KipConfigValue_eristaCpuUV)); + CUST_WRITE_FIELD_BATCH(&table, eristaCpuVmin, file::config::GetConfigValue(KipConfigValue_eristaCpuVmin)); + CUST_WRITE_FIELD_BATCH(&table, eristaCpuMaxVolt, file::config::GetConfigValue(KipConfigValue_eristaCpuMaxVolt)); + 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, marikoCpuUVHigh, config::GetConfigValue(KipConfigValue_marikoCpuUVHigh)); - CUST_WRITE_FIELD_BATCH(&table, tableConf, config::GetConfigValue(KipConfigValue_tableConf)); - CUST_WRITE_FIELD_BATCH(&table, marikoCpuLowVmin, config::GetConfigValue(KipConfigValue_marikoCpuLowVmin)); - CUST_WRITE_FIELD_BATCH(&table, marikoCpuHighVmin, config::GetConfigValue(KipConfigValue_marikoCpuHighVmin)); - CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxVolt, config::GetConfigValue(KipConfigValue_marikoCpuMaxVolt)); - CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxClock, config::GetConfigValue(KipConfigValue_marikoCpuMaxClock)); + CUST_WRITE_FIELD_BATCH(&table, marikoCpuUVLow, file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow)); + CUST_WRITE_FIELD_BATCH(&table, marikoCpuUVHigh, file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh)); + CUST_WRITE_FIELD_BATCH(&table, tableConf, file::config::GetConfigValue(KipConfigValue_tableConf)); + CUST_WRITE_FIELD_BATCH(&table, marikoCpuLowVmin, file::config::GetConfigValue(KipConfigValue_marikoCpuLowVmin)); + CUST_WRITE_FIELD_BATCH(&table, marikoCpuHighVmin, file::config::GetConfigValue(KipConfigValue_marikoCpuHighVmin)); + CUST_WRITE_FIELD_BATCH(&table, marikoCpuMaxVolt, file::config::GetConfigValue(KipConfigValue_marikoCpuMaxVolt)); + 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, marikoCpuBoostClock, config::GetConfigValue(KipConfigValue_marikoCpuBoostClock)); + CUST_WRITE_FIELD_BATCH(&table, eristaCpuBoostClock, file::config::GetConfigValue(KipConfigValue_eristaCpuBoostClock)); + 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, eristaGpuVmin, config::GetConfigValue(KipConfigValue_eristaGpuVmin)); + CUST_WRITE_FIELD_BATCH(&table, eristaGpuUV, file::config::GetConfigValue(KipConfigValue_eristaGpuUV)); + 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, marikoGpuVmin, config::GetConfigValue(KipConfigValue_marikoGpuVmin)); - CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmax, config::GetConfigValue(KipConfigValue_marikoGpuVmax)); + CUST_WRITE_FIELD_BATCH(&table, marikoGpuUV, file::config::GetConfigValue(KipConfigValue_marikoGpuUV)); + CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmin, file::config::GetConfigValue(KipConfigValue_marikoGpuVmin)); + 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++) { - 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++) { - 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) { - 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, t7_tWTR_fine_tune, config::GetConfigValue(KipConfigValue_t7_tWTR_fine_tune)); - CUST_WRITE_FIELD_BATCH(&table, pcvLogVerbosity, config::GetConfigValue(KipConfigValue_PcvDebugVerbosity)); + 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, file::config::GetConfigValue(KipConfigValue_t7_tWTR_fine_tune)); + CUST_WRITE_FIELD_BATCH(&table, pcvLogVerbosity, file::config::GetConfigValue(KipConfigValue_PcvDebugVerbosity)); if (!cust_write_table_f(fp, &table)) { fclose(fp); - fileUtils::LogLine("[kip] Failed to write KIP file"); - notification::writeNotification("Horizon OC\nKip write failed"); + file::utils::LogLine("[kip] Failed to write KIP file"); + hos::WriteNotification("Horizon OC\nKip write failed"); return; } fclose(fp); 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)) { - fileUtils::LogLine("[kip] KIP data set. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32], + if (file::config::SetConfigValues(&configValues, true)) { + file::utils::LogLine("[kip] KIP data set. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32], configValues.values[KipConfigValue_custRev]); 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 { - fileUtils::LogLine("[kip] Warning: Failed to set config values from KIP"); - notification::writeNotification("Horizon OC\nKip config set failed"); + file::utils::LogLine("[kip] Warning: Failed to set config values from KIP"); + hos::WriteNotification("Horizon OC\nKip config set failed"); } } @@ -185,8 +185,8 @@ namespace kip { return true; } - notification::writeNotification("Kip is not loaded!"); - fileUtils::LogLine("Kip was not loaded!"); + hos::WriteNotification("Kip is not loaded!"); + file::utils::LogLine("Kip was not loaded!"); return false; } @@ -196,26 +196,26 @@ namespace kip { FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "rb"); if (fp == NULL) { - notification::writeNotification("Horizon OC\nKip opening failed"); + hos::WriteNotification("Horizon OC\nKip opening failed"); kipAvailable = false; return; } kipAvailable = true; HocClkConfigValueList configValues; - config::GetConfigValues(&configValues); + file::config::GetConfigValues(&configValues); CustomizeTable table; if (!cust_read_table_f(fp, &table)) { fclose(fp); - fileUtils::LogLine("[kip] Failed to read KIP file for GetKipData"); - notification::writeNotification("Horizon OC\nKip read failed"); + file::utils::LogLine("[kip] Failed to read KIP file for GetKipData"); + hos::WriteNotification("Horizon OC\nKip read failed"); return; } fclose(fp); // 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; // } @@ -223,47 +223,47 @@ namespace kip { /* I hate this. */ /* Don't fetch frequency if it's already set or we would overwrite it. */ /* This technically only applies to Mariko *for now*. */ - if (clockManager::patchedEmcMaxClock == 0) { + if (mgr::patchedEmcMaxClock == 0) { if (board::GetSocType() == HocClkSocType_Mariko) { - clockManager::patchedEmcMaxClock = cust_get_mariko_emc_max(&table); + mgr::patchedEmcMaxClock = cust_get_mariko_emc_max(&table); } 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) && - !config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) { + if ((u64)util::ChecksumFile("sdmc:/atmosphere/kips/hoc.kip") != file::config::GetConfigValue(KipCrc32) && + !file::config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) { MigrateKipData(cust_get_cust_rev(&table), cust_get_kip_version(&table)); SetKipData(); - clockManager::gContext.rebootRequired = true; - notification::writeNotification("Horizon OC\nKIP has been updated\nPlease reboot your console to use Horizon OC"); + mgr::gContext.rebootRequired = true; + hos::WriteNotification("Horizon OC\nKIP has been updated\nPlease reboot your console to use Horizon OC"); return; } - if (config::GetConfigValue(HocClkConfigValue_IsFirstLoad) == true) { + if (file::config::GetConfigValue(HocClkConfigValue_IsFirstLoad) == true) { 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); - clockManager::gContext.custRev = cust_get_cust_rev(&table); + mgr::gContext.custRev = cust_get_cust_rev(&table); u32 custRev = cust_get_cust_rev(&table); u32 kipVersion = cust_get_kip_version(&table); if (custRev < CUST_REV || kipVersion < KIP_VERSION) { - notification::writeNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC"); - fileUtils::LogLine("Cust revision: %u", custRev); - fileUtils::LogLine("Kip version: %u", kipVersion); + hos::WriteNotification("Horizon OC\nOutdated kip detected!\nPlease update Horizon OC"); + file::utils::LogLine("Cust revision: %u", custRev); + file::utils::LogLine("Kip version: %u", kipVersion); return; } else if (custRev > CUST_REV || kipVersion > KIP_VERSION) { - notification::writeNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC"); - fileUtils::LogLine("Cust revision: %u", custRev); - fileUtils::LogLine("Kip version: %u", kipVersion); + hos::WriteNotification("Horizon OC\nOutdated sysmodule detected!\nPlease update Horizon OC"); + file::utils::LogLine("Cust revision: %u", custRev); + file::utils::LogLine("Kip version: %u", kipVersion); return; } - clockManager::gContext.isKipLoaded = IsKipLoaded(); - clockManager::gContext.kipVersion = kipVersion; + mgr::gContext.isKipLoaded = IsKipLoaded(); + mgr::gContext.kipVersion = kipVersion; 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_hpMode] = cust_get_hp_mode(&table); @@ -345,25 +345,25 @@ namespace kip { configValues.values[KipConfigValue_PcvDebugVerbosity] = cust_get_log_verbosity(&table); if (sizeof(HocClkConfigValueList) <= sizeof(configValues)) { - if (config::SetConfigValues(&configValues, true)) { - fileUtils::LogLine("[kip] KIP loaded. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32], + if (file::config::SetConfigValues(&configValues, true)) { + file::utils::LogLine("[kip] KIP loaded. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32], configValues.values[KipConfigValue_custRev]); 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 { - fileUtils::LogLine("[kip] Warning: Failed to set config values from KIP"); - notification::writeNotification("Horizon OC\nKip config set failed"); + file::utils::LogLine("[kip] Warning: Failed to set config values from KIP"); + hos::WriteNotification("Horizon OC\nKip config set failed"); } } else { - fileUtils::LogLine("[kip] Error: Config value list buffer size mismatch"); - notification::writeNotification("Horizon OC\nConfig Buffer Mismatch"); + file::utils::LogLine("[kip] Error: Config value list buffer size mismatch"); + hos::WriteNotification("Horizon OC\nConfig Buffer Mismatch"); } } void MigrateKipData(u32 custRev, u32 version) { HocClkConfigValueList configValues; - config::GetConfigValues(&configValues); + file::config::GetConfigValues(&configValues); u32 previousVersion = configValues.values[KipConfigValue_KipVersion]; if (previousVersion < 240 && version >= 240) { // <2.4.0 -> 2.4.0 migration @@ -377,15 +377,15 @@ namespace kip { } // delete handheld TDP config entries - config::DeleteKey(CONFIG_VAL_SECTION, "handheld_tdp"); - config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit"); - config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit_l"); + file::config::DeleteKey(CONFIG_VAL_SECTION, "handheld_tdp"); + file::config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit"); + file::config::DeleteKey(CONFIG_VAL_SECTION, "tdp_limit_l"); } if(previousVersion < 300 && version >= 300) { configValues.values[KipConfigValue_g_volt_1574400] = 2000; } - config::SetConfigValues(&configValues, true); + file::config::SetConfigValues(&configValues, true); } -} // namespace kip +} // namespace file::kip diff --git a/Source/hoc-clk/sysmodule/src/file/kip.hpp b/Source/hoc-clk/sysmodule/src/file/kip.hpp index 5c022144..9c692cfe 100644 --- a/Source/hoc-clk/sysmodule/src/file/kip.hpp +++ b/Source/hoc-clk/sysmodule/src/file/kip.hpp @@ -28,7 +28,7 @@ #include "file_utils.hpp" -namespace kip { +namespace file::kip { extern bool kipAvailable; typedef struct { @@ -825,4 +825,4 @@ namespace kip { void MigrateKipData(u32 custRev, u32 version); void SetKipData(); void GetKipData(); -} // namespace kip \ No newline at end of file +} // namespace file::kip \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/hos/integrations.cpp b/Source/hoc-clk/sysmodule/src/hos/integrations.cpp index e566c3d0..2398d44b 100644 --- a/Source/hoc-clk/sysmodule/src/hos/integrations.cpp +++ b/Source/hoc-clk/sysmodule/src/hos/integrations.cpp @@ -21,7 +21,7 @@ #include "process_management.hpp" #include -namespace integrations { +namespace hos { namespace { @@ -98,7 +98,7 @@ namespace integrations { if (!gSharedMemoryUsed) return 254; - u64 tid = processManagement::GetCurrentApplicationId(); + u64 tid = GetCurrentApplicationId(); if (tid == 0) return 254; @@ -119,7 +119,7 @@ namespace integrations { if (!gSharedMemoryUsed) return 0; - u64 tid = processManagement::GetCurrentApplicationId(); + u64 tid = GetCurrentApplicationId(); if (tid == 0) return 0; @@ -151,4 +151,4 @@ namespace integrations { return 0; } -} // namespace integrations +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/hos/integrations.hpp b/Source/hoc-clk/sysmodule/src/hos/integrations.hpp index 1e808c85..8d9fee3a 100644 --- a/Source/hoc-clk/sysmodule/src/hos/integrations.hpp +++ b/Source/hoc-clk/sysmodule/src/hos/integrations.hpp @@ -20,7 +20,7 @@ #include #include -namespace integrations { +namespace hos { struct NxFpsSharedBlock { uint32_t MAGIC; @@ -66,4 +66,4 @@ namespace integrations { u8 GetSaltyNXFPS(); u16 GetSaltyNXResolutionHeight(); -} // namespace integrations +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/hos/lang.cpp b/Source/hoc-clk/sysmodule/src/hos/lang.cpp index 6d959c01..3c2b07ac 100644 --- a/Source/hoc-clk/sysmodule/src/hos/lang.cpp +++ b/Source/hoc-clk/sysmodule/src/hos/lang.cpp @@ -24,7 +24,7 @@ #include "../file/file_utils.hpp" -namespace lang { +namespace hos { namespace { constexpr const char *UltrahandConfigPath = "sdmc:/config/ultrahand/config.ini"; @@ -138,4 +138,4 @@ namespace lang { return text; } -} // namespace lang +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/hos/lang.hpp b/Source/hoc-clk/sysmodule/src/hos/lang.hpp index 7b03635b..59a12b17 100644 --- a/Source/hoc-clk/sysmodule/src/hos/lang.hpp +++ b/Source/hoc-clk/sysmodule/src/hos/lang.hpp @@ -19,11 +19,11 @@ #include -namespace lang { +namespace hos { // Translates text using Ultrahand's language setting and // /config/horizon-oc/lang/.json (same format as the overlay). // Returns the original text when no translation is available. std::string Translate(const std::string &text); -} // namespace lang +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/hos/notification.cpp b/Source/hoc-clk/sysmodule/src/hos/notification.cpp index 333b0604..c5a2f9fa 100644 --- a/Source/hoc-clk/sysmodule/src/hos/notification.cpp +++ b/Source/hoc-clk/sysmodule/src/hos/notification.cpp @@ -18,8 +18,8 @@ #include "lang.hpp" #include "notification.h" -namespace notification { - void writeNotification(const std::string &message) { +namespace hos { + void WriteNotification(const std::string &message) { static const char *flagPath = "sdmc:/config/ultrahand/flags/NOTIFICATIONS.flag"; FILE *flagFile = fopen(flagPath, "r"); @@ -28,7 +28,7 @@ namespace notification { } 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 fullPath = "sdmc:/config/ultrahand/notifications/" + filename; @@ -42,4 +42,4 @@ namespace notification { fclose(file); } } -} // namespace notification +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/hos/notification.h b/Source/hoc-clk/sysmodule/src/hos/notification.h index 105d1512..ead5028a 100644 --- a/Source/hoc-clk/sysmodule/src/hos/notification.h +++ b/Source/hoc-clk/sysmodule/src/hos/notification.h @@ -20,6 +20,6 @@ #include #include #include -namespace notification { - void writeNotification(const std::string &message); +namespace hos { + void WriteNotification(const std::string &message); } diff --git a/Source/hoc-clk/sysmodule/src/hos/process_management.cpp b/Source/hoc-clk/sysmodule/src/hos/process_management.cpp index 1c2869fd..7c9e4654 100644 --- a/Source/hoc-clk/sysmodule/src/hos/process_management.cpp +++ b/Source/hoc-clk/sysmodule/src/hos/process_management.cpp @@ -31,7 +31,7 @@ #include "process_management.hpp" -namespace processManagement { +namespace hos { namespace { constexpr u64 Qlaunch = 0x0100000000001000ULL; @@ -39,7 +39,7 @@ namespace processManagement { Service pdmqryClone; } // namespace - void Initialize() { + void InitializeProcessManagement() { Result rc = 0; rc = pmdmntInitialize(); @@ -67,7 +67,7 @@ namespace processManagement { } // Ty to Masa for this function! - Result isApplicationOutOfFocus(bool *outOfFocus) { + Result IsApplicationOutOfFocus(bool *outOfFocus) { static s32 last_total_entries = 0; static bool isOutOfFocus = false; s32 total_entries = 0; @@ -158,10 +158,10 @@ namespace processManagement { return tid; } - void Exit() { + void ExitProcessManagement() { pmdmntExit(); pminfoExit(); pdmqryExit(); } -} // namespace processManagement +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/hos/process_management.hpp b/Source/hoc-clk/sysmodule/src/hos/process_management.hpp index 6714e067..47cdafc4 100644 --- a/Source/hoc-clk/sysmodule/src/hos/process_management.hpp +++ b/Source/hoc-clk/sysmodule/src/hos/process_management.hpp @@ -27,12 +27,12 @@ #pragma once #include -namespace processManagement { +namespace hos { - void Initialize(); + void InitializeProcessManagement(); void WaitForQLaunch(); u64 GetCurrentApplicationId(); - Result isApplicationOutOfFocus(bool *outOfFocus); - void Exit(); + Result IsApplicationOutOfFocus(bool *outOfFocus); + void ExitProcessManagement(); -} // namespace processManagement +} // namespace hos diff --git a/Source/hoc-clk/sysmodule/src/ipc/ipc_service.cpp b/Source/hoc-clk/sysmodule/src/ipc/ipc_service.cpp index f1e01d9b..81247151 100644 --- a/Source/hoc-clk/sysmodule/src/ipc/ipc_service.cpp +++ b/Source/hoc-clk/sysmodule/src/ipc/ipc_service.cpp @@ -61,44 +61,44 @@ namespace ipcService { } Result GetCurrentContext(HocClkContext *out_ctx) { - *out_ctx = clockManager::GetCurrentContext(); + *out_ctx = mgr::GetCurrentContext(); return 0; } Result ExitHandler() { - clockManager::SetRunning(false); + mgr::SetRunning(false); return 0; } Result GetProfileCount(std::uint64_t *tid, std::uint8_t *out_count) { - if (!config::HasProfilesLoaded()) { + if (!file::config::HasProfilesLoaded()) { return HOCCLK_ERROR(ConfigNotLoaded); } - *out_count = config::GetProfileCount(*tid); + *out_count = file::config::GetProfileCount(*tid); return 0; } Result GetProfiles(std::uint64_t *tid, HocClkTitleProfileList *out_profiles) { - if (!config::HasProfilesLoaded()) { + if (!file::config::HasProfilesLoaded()) { return HOCCLK_ERROR(ConfigNotLoaded); } - config::GetProfiles(*tid, out_profiles); + file::config::GetProfiles(*tid, out_profiles); return 0; } Result SetProfiles(HocClkIpc_SetProfiles_Args *args) { - if (!config::HasProfilesLoaded()) { + if (!file::config::HasProfilesLoaded()) { return HOCCLK_ERROR(ConfigNotLoaded); } HocClkTitleProfileList profiles = args->profiles; - if (!config::SetProfiles(args->tid, &profiles, true)) { + if (!file::config::SetProfiles(args->tid, &profiles, true)) { return HOCCLK_ERROR(ConfigSaveFailed); } return 0; } Result SetEnabled(std::uint8_t *enabled) { - config::SetEnabled(*enabled); + file::config::SetEnabled(*enabled); return 0; } @@ -106,24 +106,24 @@ namespace ipcService { if (!HOCCLK_ENUM_VALID(HocClkModule, args->module)) { return HOCCLK_ERROR(Generic); } - config::SetOverrideHz(args->module, args->hz); + file::config::SetOverrideHz(args->module, args->hz); return 0; } Result GetConfigValuesHandler(HocClkConfigValueList *out_configValues) { - if (!config::HasProfilesLoaded()) { + if (!file::config::HasProfilesLoaded()) { return HOCCLK_ERROR(ConfigNotLoaded); } - config::GetConfigValues(out_configValues); + file::config::GetConfigValues(out_configValues); return 0; } Result SetConfigValuesHandler(HocClkConfigValueList *configValues) { - if (!config::HasProfilesLoaded()) { + if (!file::config::HasProfilesLoaded()) { return HOCCLK_ERROR(ConfigNotLoaded); } HocClkConfigValueList copy = *configValues; - if (!config::SetConfigValues(©, true)) { + if (!file::config::SetConfigValues(©, true)) { return HOCCLK_ERROR(ConfigSaveFailed); } return 0; @@ -136,12 +136,12 @@ namespace ipcService { if (args->maxCount != size / sizeof(*out_list)) { 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; } Result RequestGpuVoltage(HocClkIpc_RequestGpuVoltage_Args *args) { - clockManager::ApplyGpuFreqVoltRequest(args->voltage, args->hz); + mgr::ApplyGpuFreqVoltRequest(args->voltage, args->hz); return 0; } @@ -235,7 +235,7 @@ namespace ipcService { case HocClkIpcCmd_SetKipData: if (r->data.size >= 0) { - kip::SetKipData(); + file::kip::SetKipData(); return 0; } break; @@ -260,7 +260,7 @@ namespace ipcService { return; } 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)); } } } diff --git a/Source/hoc-clk/sysmodule/src/main.cpp b/Source/hoc-clk/sysmodule/src/main.cpp index f7c5b0c1..2a785506 100644 --- a/Source/hoc-clk/sysmodule/src/main.cpp +++ b/Source/hoc-clk/sysmodule/src/main.cpp @@ -120,44 +120,44 @@ void __appExit(void) { } int main(int argc, char **argv) { - Result rc = fileUtils::Initialize(); + Result rc = file::utils::Initialize(); if (R_FAILED(rc)) { fatalThrow(rc); return 1; } - config::Initialize(); - config::Refresh(); // Get config from file + file::config::Initialize(); + file::config::Refresh(); // Get config from file board::Initialize(); - processManagement::Initialize(); + hos::InitializeProcessManagement(); - processManagement::WaitForQLaunch(); + hos::WaitForQLaunch(); - clockManager::Initialize(); + mgr::Initialize(); ipcService::Initialize(); - clockManager::SetRunning(true); - config::SetEnabled(true); + mgr::SetRunning(true); + file::config::SetEnabled(true); ipcService::SetRunning(true); // TemperaturePoint *table; // ReadConfigFile(&table); // InitFanController(table); // StartFanControllerThread(); - while (clockManager::Running()) { - clockManager::Tick(); - clockManager::WaitForNextTick(); + while (mgr::Running()) { + mgr::Tick(); + mgr::WaitForNextTick(); } ipcService::SetRunning(false); ipcService::Exit(); - clockManager::Exit(); - processManagement::Exit(); + mgr::Exit(); + hos::ExitProcessManagement(); board::Exit(); - config::Exit(); - fileUtils::LogLine("Exiting hoc-clk"); + file::config::Exit(); + file::utils::LogLine("Exiting hoc-clk"); svcSleepThread(1000000ULL); - fileUtils::Exit(); + file::utils::Exit(); return 0; } diff --git a/Source/hoc-clk/sysmodule/src/mapping/mem_map.cpp b/Source/hoc-clk/sysmodule/src/mapping/mem_map.cpp index f0d52b4d..4f849aa7 100644 --- a/Source/hoc-clk/sysmodule/src/mapping/mem_map.cpp +++ b/Source/hoc-clk/sysmodule/src/mapping/mem_map.cpp @@ -31,7 +31,7 @@ Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size) { Result MapAddress(u64 &va, const u64 &physAddr, const char *name) { Result mapResult = QueryMemoryMapping(&va, physAddr, 0x1000); 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; diff --git a/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp b/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp index 487d1f11..5d705099 100644 --- a/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp +++ b/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp @@ -48,7 +48,7 @@ #define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0)) -namespace clockManager { +namespace mgr { bool gRunning = false; LockableMutex gContextMutex; @@ -74,7 +74,7 @@ namespace clockManager { } 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 } else { if (module == HocClkModule_GPU) { @@ -84,7 +84,7 @@ namespace clockManager { return 460800000; case HocClkSocType_Mariko: if (board::GetConsoleType() == HocClkConsoleType_Hoag) { - switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) { + switch (file::config::GetConfigValue(KipConfigValue_marikoGpuUV)) { case 0 ... 2: return 614400000; case 3 ... 4: @@ -93,7 +93,7 @@ namespace clockManager { return 614400000; } } else { - switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) { + switch (file::config::GetConfigValue(KipConfigValue_marikoGpuUV)) { case 0: return 614400000; case 1: @@ -116,7 +116,7 @@ namespace clockManager { case HocClkSocType_Erista: return 768000000; case HocClkSocType_Mariko: - switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) { + switch (file::config::GetConfigValue(KipConfigValue_marikoGpuUV)) { case 0: return 844800000; case 1: @@ -165,19 +165,19 @@ namespace clockManager { void ResetToStockClocks() { board::ResetToStockCpu(); - if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) { + if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) { if (board::GetSocType() == HocClkSocType_Erista) - board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); + board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); else - board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), - board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf))); + board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow), file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), + board::CalculateTbreak(file::config::GetConfigValue(KipConfigValue_tableConf))); } board::ResetToStockGpu(); } 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); if (shouldLog) { @@ -193,14 +193,14 @@ namespace clockManager { std::uint32_t freqs[HOCCLK_FREQ_LIST_MAX]; 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); std::uint32_t *hz = &gFreqTable[module].list[0]; gFreqTable[module].count = 0; if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Mariko && - config::GetConfigValue(HocClkConfigValue_MarikoMiddleFreqs)) { + file::config::GetConfigValue(HocClkConfigValue_MarikoMiddleFreqs)) { constexpr u32 kStep = 38400000; constexpr u32 kPcvStep = 76800000; u32 kMax = ~0; @@ -282,7 +282,7 @@ namespace clockManager { bool skip = false; for (auto &entry : eristaGpuVoltMap) { if (entry.hz == freqs[i]) { - if (config::GetConfigValue(entry.kval) == 2000) { + if (file::config::GetConfigValue(entry.kval) == 2000) { skip = true; } break; @@ -293,7 +293,7 @@ namespace clockManager { } *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++; hz++; @@ -303,8 +303,8 @@ namespace clockManager { constexpr u64 EmcClkOSLimitHz = 1600000ULL * 1000; // 1600 MHz const u64 maxHz = patchedEmcMaxClock * 1000; if (module == HocClkModule_MEM && board::GetSocType() == HocClkSocType_Mariko && - kip::kipAvailable && maxHz >= EmcClkOSLimitHz && - config::GetConfigValue(KipConfigValue_stepMode) == 4 /* 33 MHz */) { + file::kip::kipAvailable && maxHz >= EmcClkOSLimitHz && + file::config::GetConfigValue(KipConfigValue_stepMode) == 4 /* 33 MHz */) { /* Drop the clkrst entries above the OS limit */ 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) { - if (((tmp451TempSoc() / 1000) > (int)config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) && - config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) { + if (((tmp451TempSoc() / 1000) > (int)file::config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) && + file::config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) { ResetToStockClocks(); return true; } @@ -359,19 +359,19 @@ namespace clockManager { if (++tick > 10) { tick = 0; - if (config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)) { - I2c_Bq24193_SetFastChargeCurrentLimit(config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)); + if (file::config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)) { + I2c_Bq24193_SetFastChargeCurrentLimit(file::config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)); } - if (config::GetConfigValue(HocClkConfigValue_InputCurrentLimit)) { - I2c_Bq24193_SetInputCurrentLimit(config::GetConfigValue(HocClkConfigValue_InputCurrentLimit)); + if (file::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) - AulaDisplay::SetDisplayColorMode((AulaColorMode)config::GetConfigValue(HocClkConfigValue_AulaDisplayColorPreset)); - if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) { + display::SetDisplayColorMode((AulaColorMode)file::config::GetConfigValue(HocClkConfigValue_AulaDisplayColorPreset)); + if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) { board::HandleCpuUv(); } } @@ -392,9 +392,9 @@ namespace clockManager { u32 GetNearestOverrideHz(HocClkModule module) { u32 targetHz = gContext.overrideFreqs[module]; if (!targetHz) { - targetHz = config::GetAutoClockHz(gContext.applicationId, module, gContext.profile, false); + targetHz = file::config::GetAutoClockHz(gContext.applicationId, module, gContext.profile, false); 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. */ constexpr u32 DisabledVoltage = 2000; if (voltage == DisabledVoltage) { - notification::writeNotification("Horizon OC\nDeactivated frequency.\nReboot to apply."); + hos::WriteNotification("Horizon OC\nDeactivated frequency.\nReboot to apply."); return; } @@ -426,7 +426,7 @@ namespace clockManager { } void ApplyGpuDvfs(u32 targetHz) { - s32 dvfsOffset = config::GetConfigValue(HocClkConfigValue_DVFSOffset); + s32 dvfsOffset = file::config::GetConfigValue(HocClkConfigValue_DVFSOffset); dvfsOffset = std::max(dvfsOffset, -80); u32 vmin = board::GetMinimumGpuVmin(targetHz / 1000000, board::GetGpuSpeedoBracket()); @@ -450,7 +450,7 @@ namespace clockManager { } void DVFSReset() { - if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) { + if (file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) { board::PcvHijackGpuVolts(0); // Reset to vMin u32 targetHz = GetNearestOverrideHz(HocClkModule_GPU); @@ -464,15 +464,15 @@ namespace clockManager { void HandleFreqReset(HocClkModule module, bool isBoost, bool didHijackPcv) { switch (module) { case HocClkModule_CPU: - if (!(isBoost || (config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost))) + if (!(isBoost || (file::config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost))) board::ResetToStockCpu(); - if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) { + if (file::config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) { if (board::GetSocType() == HocClkSocType_Erista) - board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); + board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); else - board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), - config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), - board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf))); + board::SetDfllTunings(file::config::GetConfigValue(KipConfigValue_marikoCpuUVLow), + file::config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), + board::CalculateTbreak(file::config::GetConfigValue(KipConfigValue_tableConf))); } break; case HocClkModule_GPU: @@ -486,7 +486,7 @@ namespace clockManager { } break; case HocClkModule_Display: - if (config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate)) { + if (file::config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate)) { board::ResetToStockDisplay(); } break; @@ -505,7 +505,7 @@ namespace clockManager { u32 nearestFreq = GetCurrentNearestFrequency(HocClkModule_MEM); if (targetRamHz != nearestFreq) { - if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) { + if (file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) { ApplyGpuDvfs(targetRamHz); } @@ -520,7 +520,7 @@ namespace clockManager { static bool prepareBoostExit = false; bool didHijackPcv = false; - bool skipCpuDueToBoost = isBoost && !config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode); + bool skipCpuDueToBoost = isBoost && !file::config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode); if (skipCpuDueToBoost) { board::SetHz(HocClkModule_CPU, board::GetHz(HocClkModule_CPU)); prepareBoostExit = true; @@ -545,22 +545,22 @@ namespace clockManager { returnRaw = false; targetHz = gContext.overrideFreqs[module]; 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) - 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) { - governor::HandleGovernor(targetHz); + mgr::HandleGovernor(targetHz); } - bool noCPU = governor::isCpuGovernorEnabled; - bool noGPU = governor::isGpuGovernorEnabled; - bool noDisp = governor::isVRREnabled; + bool noCPU = mgr::isCpuGovernorEnabled; + bool noGPU = mgr::isGpuGovernorEnabled; + bool noDisp = mgr::isVRREnabled; if (noDisp && module == HocClkModule_Display) continue; - if (module == HocClkModule_Display && config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate) && !noDisp) { + if (module == HocClkModule_Display && file::config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate) && !noDisp) { if (targetHz) { board::SetHz(HocClkModule_Display, targetHz); gContext.freqs[HocClkModule_Display] = targetHz; @@ -584,11 +584,11 @@ namespace clockManager { continue; u32 autoCpuOcHz = 0; - if (module == HocClkModule_CPU && config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock) && !isBoost && - !governor::isCpuGovernorEnabled && (board::GetSocType() == HocClkSocType_Mariko)) { - u32 threshold = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000; + if (module == HocClkModule_CPU && file::config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock) && !isBoost && + !mgr::isCpuGovernorEnabled && (board::GetSocType() == HocClkSocType_Mariko)) { + u32 threshold = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000; if (ramTargetHz >= threshold) - autoCpuOcHz = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000; + autoCpuOcHz = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000; } if (targetHz || autoCpuOcHz) { @@ -599,12 +599,12 @@ namespace clockManager { nearestHz = GetNearestHz(HocClkModule_CPU, autoCpuOcHz, maxHz); 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, targetHz / 100000 - targetHz / 1000000 * 10); // 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); } board::SetHz((HocClkModule)module, nearestHz); @@ -614,11 +614,11 @@ namespace clockManager { 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); } - if (module == HocClkModule_MEM && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) + if (module == HocClkModule_MEM && file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) didHijackPcv = false; } } else { @@ -636,16 +636,16 @@ namespace clockManager { Result rc = apmExtGetCurrentPerformanceConfiguration(&mode); ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration"); - std::uint64_t applicationId = processManagement::GetCurrentApplicationId(); + std::uint64_t applicationId = hos::GetCurrentApplicationId(); if (applicationId != gContext.applicationId) { - fileUtils::LogLine("[mgr] TitleID change: %016lX", applicationId); + file::utils::LogLine("[mgr] TitleID change: %016lX", applicationId); gContext.applicationId = applicationId; hasChanged = true; } HocClkProfile profile = board::GetProfile(); 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; hasChanged = true; } @@ -653,7 +653,7 @@ namespace clockManager { // restore clocks to stock values on app or profile change if (hasChanged) { board::ResetToStock(); - if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) { + if (file::config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) { board::PcvHijackGpuVolts(0); board::ResetToStockGpu(); } @@ -664,7 +664,7 @@ namespace clockManager { for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) { hz = board::GetHz((HocClkModule)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); gContext.freqs[module] = hz; @@ -674,10 +674,10 @@ namespace clockManager { hasChanged = true; } - hz = config::GetOverrideHz((HocClkModule)module); + hz = file::config::GetOverrideHz((HocClkModule)module); if (hz != gContext.overrideFreqs[module]) { 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); } gContext.overrideFreqs[module] = hz; @@ -697,7 +697,7 @@ namespace clockManager { for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) { millis = board::GetTemperatureMilli((HocClkThermalSensor)sensor); 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); } gContext.temps[sensor] = millis; @@ -713,7 +713,7 @@ namespace clockManager { for (unsigned int sensor = 0; sensor < HocClkPowerSensor_EnumMax; sensor++) { mw = board::GetPowerMw((HocClkPowerSensor)sensor); 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; @@ -728,7 +728,7 @@ namespace clockManager { for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) { realHz = board::GetRealHz((HocClkModule)module); 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); } gContext.realFreqs[module] = realHz; @@ -756,27 +756,27 @@ namespace clockManager { } if (ConfigIntervalTimeout(HocClkConfigValue_CsvWriteIntervalMs, ns, &gLastCsvWriteNs)) { - fileUtils::WriteContextToCsv(&gContext); + file::utils::WriteContextToCsv(&gContext); } // this->context->maxDisplayFreq = board::GetHighestDockedDisplayRate(); u32 targetHz = gContext.overrideFreqs[HocClkModule_Display]; 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) - 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) board::SetDisplayRefreshDockedState(gContext.profile == HocClkProfile_Docked); if (gContext.isSaltyNXInstalled) - gContext.fps = integrations::GetSaltyNXFPS(); + gContext.fps = hos::GetSaltyNXFPS(); else gContext.fps = 254; // N/A if (gContext.isSaltyNXInstalled) - gContext.resolutionHeight = integrations::GetSaltyNXResolutionHeight(); + gContext.resolutionHeight = hos::GetSaltyNXResolutionHeight(); else 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 synthesis in RefreshFreqTableRow reads marikoEmcMaxClock / stepMode from it. */ - kip::GetKipData(); + file::kip::GetKipData(); for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) { gContext.freqs[module] = 0; @@ -824,23 +824,23 @@ namespace clockManager { gContext.dramID = board::GetDramID(); gContext.isDram8GB = board::IsDram8GB(); gContext.consoleType = board::GetConsoleType(); - gContext.isFirstLoad = config::GetConfigValue(HocClkConfigValue_IsFirstLoad); + gContext.isFirstLoad = file::config::GetConfigValue(HocClkConfigValue_IsFirstLoad); - board::SetGpuSchedulingMode((GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling), - (GpuSchedulingOverrideMethod)config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod)); - gContext.gpuSchedulingMode = (GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling); + board::SetGpuSchedulingMode((GpuSchedulingMode)file::config::GetConfigValue(HocClkConfigValue_GPUScheduling), + (GpuSchedulingOverrideMethod)file::config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod)); + gContext.gpuSchedulingMode = (GpuSchedulingMode)file::config::GetConfigValue(HocClkConfigValue_GPUScheduling); - gContext.isSysDockInstalled = integrations::GetSysDockState(); - gContext.isSaltyNXInstalled = integrations::GetSaltyNXState(); + gContext.isSysDockInstalled = hos::GetSysDockState(); + gContext.isSaltyNXInstalled = hos::GetSaltyNXState(); if (gContext.isSaltyNXInstalled) { - integrations::LoadSaltyNX(); + hos::LoadSaltyNX(); } - governor::startThreads(); + mgr::StartThreads(); } void Exit() { - governor::exitThreads(); + mgr::ExitThreads(); } HocClkContext GetCurrentContext() { @@ -875,7 +875,7 @@ namespace clockManager { HandleMiscFeatures(); // 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) { SetClocks(isBoost); } @@ -888,8 +888,8 @@ namespace clockManager { } if (board::GetHz(HocClkModule_MEM) > 665000000) - svcSleepThread(config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL); + svcSleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL); else svcSleepThread(5000 * 1000000ULL); // 5 seconds in sleep mode } -} // namespace clockManager +} // namespace mgr diff --git a/Source/hoc-clk/sysmodule/src/mgr/clock_manager.hpp b/Source/hoc-clk/sysmodule/src/mgr/clock_manager.hpp index 7dccdc8e..1a6741b3 100644 --- a/Source/hoc-clk/sysmodule/src/mgr/clock_manager.hpp +++ b/Source/hoc-clk/sysmodule/src/mgr/clock_manager.hpp @@ -31,7 +31,7 @@ #include "../util/lockable_mutex.h" -namespace clockManager { +namespace mgr { struct FreqTable { std::uint32_t count; @@ -68,4 +68,4 @@ namespace clockManager { void Tick(); void WaitForNextTick(); -} // namespace clockManager +} // namespace mgr diff --git a/Source/hoc-clk/sysmodule/src/mgr/governor.cpp b/Source/hoc-clk/sysmodule/src/mgr/governor.cpp index c8a73399..8ab39d21 100644 --- a/Source/hoc-clk/sysmodule/src/mgr/governor.cpp +++ b/Source/hoc-clk/sysmodule/src/mgr/governor.cpp @@ -19,25 +19,25 @@ #include "governor.hpp" #include -namespace governor { +namespace mgr { #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) u64 GovernorPollNs() { - u64 ms = config::GetConfigValue(HocClkConfigValue_GovernorPollRateMs); + u64 ms = file::config::GetConfigValue(HocClkConfigValue_GovernorPollRateMs); if (ms < 1 || ms > 50) ms = 5; return ms * 1'000'000ULL; } u32 GovernorDownHoldTicks() { - u64 ticks = config::GetConfigValue(HocClkConfigValue_GovernorDownHoldTicks); + u64 ticks = file::config::GetConfigValue(HocClkConfigValue_GovernorDownHoldTicks); return (ticks <= 100) ? (u32)ticks : DOWN_HOLD_TICKS_DEFAULT; } u32 GovernorStepUtil() { - u64 step = config::GetConfigValue(HocClkConfigValue_GovernorStepUtil); + u64 step = file::config::GetConfigValue(HocClkConfigValue_GovernorStepUtil); if (step < 100 || step > 1500) step = STEP_UTIL_DEFAULT; return (u32)step; @@ -55,11 +55,11 @@ namespace governor { Thread governorTHREAD; void HandleGovernor(uint32_t targetHz) { - u32 tempTargetHz = clockManager::gContext.overrideFreqs[HocClkModule_Governor]; + u32 tempTargetHz = mgr::gContext.overrideFreqs[HocClkModule_Governor]; 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) - 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 { @@ -91,7 +91,7 @@ namespace governor { if (newCpuGovernorState != lastCpuGovernorState || newGpuGovernorState != lastGpuGovernorState || 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"); lastCpuGovernorState = newCpuGovernorState; lastGpuGovernorState = newGpuGovernorState; @@ -104,7 +104,7 @@ namespace governor { return (u32)(std::min(hz, static_cast(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++) if (table.list[i] >= targetHz) return i; @@ -112,11 +112,11 @@ namespace governor { } u32 ResolveTargetHz(HocClkModule module) { - u32 hz = clockManager::gContext.overrideFreqs[module]; + u32 hz = mgr::gContext.overrideFreqs[module]; 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) - 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; } @@ -135,7 +135,7 @@ namespace governor { for (;;) { const u64 pollNs = GovernorPollNs(); - if (!clockManager::gRunning) { + if (!mgr::gRunning) { cpuDownHoldRemaining = 0; cpuLastHz = 0; gpuDownHoldRemaining = 0; @@ -155,14 +155,14 @@ namespace governor { } else { isCpuGovernorInBoostMode = false; - auto &table = clockManager::gFreqTable[HocClkModule_CPU]; - std::scoped_lock lock{ clockManager::gContextMutex }; + auto &table = mgr::gFreqTable[HocClkModule_CPU]; + std::scoped_lock lock{ mgr::gContextMutex }; u32 cpuLoad = board::GetPartLoad(HocClkPartLoad_CPUMax); u32 tableMaxHz = table.list[table.count - 1]; u32 desiredHz = SchedutilTargetHz(cpuLoad, tableMaxHz); 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) desiredHz = targetHz; @@ -181,12 +181,12 @@ namespace governor { cpuDownHoldRemaining--; if (++cpuTick > 50) { - minHz = config::GetConfigValue(HocClkConfigValue_CpuGovernorMinimumFreq); - if (config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock)) { - u32 ramHz = clockManager::gContext.freqs[HocClkModule_MEM]; - u32 threshold = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000; + minHz = file::config::GetConfigValue(HocClkConfigValue_CpuGovernorMinimumFreq); + if (file::config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock)) { + u32 ramHz = mgr::gContext.freqs[HocClkModule_MEM]; + u32 threshold = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000; if (ramHz >= threshold) { - u32 overrideHz = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000; + u32 overrideHz = (u32)file::config::GetConfigValue(HocClkConfigValue_AutoRamCpuCpuOCFreq) * 1000; if (overrideHz > minHz) minHz = overrideHz; } @@ -197,10 +197,10 @@ namespace governor { if (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); - clockManager::gContext.freqs[HocClkModule_CPU] = newHz; - clockManager::gContext.stable.freqs[HocClkModule_CPU] = newHz; + mgr::gContext.freqs[HocClkModule_CPU] = newHz; + mgr::gContext.stable.freqs[HocClkModule_CPU] = newHz; cpuLastHz = newHz; } } @@ -211,14 +211,14 @@ namespace governor { } if (isGpuGovernorEnabled) { - auto &table = clockManager::gFreqTable[HocClkModule_GPU]; - std::scoped_lock lock{ clockManager::gContextMutex }; + auto &table = mgr::gFreqTable[HocClkModule_GPU]; + std::scoped_lock lock{ mgr::gContextMutex }; u32 gpuLoad = board::GetPartLoad(HocClkPartLoad_GPU); u32 tableMaxHz = table.list[table.count - 1]; u32 desiredHz = SchedutilTargetHz(gpuLoad, tableMaxHz); 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) desiredHz = targetHz; @@ -236,10 +236,10 @@ namespace governor { if (gpuDownHoldRemaining > 0) gpuDownHoldRemaining--; - if ((!goingDown || (gpuDownHoldRemaining == 0)) && clockManager::IsAssignableHz(HocClkModule_GPU, newHz)) { + if ((!goingDown || (gpuDownHoldRemaining == 0)) && mgr::IsAssignableHz(HocClkModule_GPU, newHz)) { board::SetHz(HocClkModule_GPU, newHz); - clockManager::gContext.freqs[HocClkModule_GPU] = newHz; - clockManager::gContext.stable.freqs[HocClkModule_GPU] = newHz; + mgr::gContext.freqs[HocClkModule_GPU] = newHz; + mgr::gContext.stable.freqs[HocClkModule_GPU] = newHz; gpuLastHz = newHz; } } else { @@ -247,13 +247,13 @@ namespace governor { 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; if (++vrrFocusTick > 100) { vrrFocusTick = 0; bool isApplicationOutOfFocus = false; - Result rc = processManagement::isApplicationOutOfFocus(&isApplicationOutOfFocus); + Result rc = hos::IsApplicationOutOfFocus(&isApplicationOutOfFocus); if (R_FAILED(rc) || isApplicationOutOfFocus) { board::ResetToStockDisplay(); skipVrr = true; @@ -261,18 +261,18 @@ namespace governor { } if (!skipVrr) { - u8 fps = integrations::GetSaltyNXFPS(); + u8 fps = hos::GetSaltyNXFPS(); 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) { - targetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Display, - clockManager::gContext.profile, false); + targetHz = file::config::GetAutoClockHz(mgr::gContext.applicationId, HocClkModule_Display, + mgr::gContext.profile, false); if (!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; @@ -281,19 +281,19 @@ namespace governor { if (maxDisplay != minDisplay) { if (fps >= minDisplay && fps <= maxDisplay) { board::SetHz(HocClkModule_Display, fps); - clockManager::gContext.freqs[HocClkModule_Display] = fps; - clockManager::gContext.realFreqs[HocClkModule_Display] = fps; - clockManager::gContext.stable.freqs[HocClkModule_Display] = fps; - clockManager::gContext.stable.realFreqs[HocClkModule_Display] = fps; + mgr::gContext.freqs[HocClkModule_Display] = fps; + mgr::gContext.realFreqs[HocClkModule_Display] = fps; + mgr::gContext.stable.freqs[HocClkModule_Display] = fps; + mgr::gContext.stable.realFreqs[HocClkModule_Display] = fps; } else { for (u32 i = 0; i < 10; i++) { u32 compareHz = fps * i; if (compareHz >= minDisplay && compareHz <= maxDisplay) { board::SetHz(HocClkModule_Display, compareHz); - clockManager::gContext.freqs[HocClkModule_Display] = compareHz; - clockManager::gContext.realFreqs[HocClkModule_Display] = compareHz; - clockManager::gContext.stable.freqs[HocClkModule_Display] = compareHz; - clockManager::gContext.stable.realFreqs[HocClkModule_Display] = compareHz; + mgr::gContext.freqs[HocClkModule_Display] = compareHz; + mgr::gContext.realFreqs[HocClkModule_Display] = compareHz; + mgr::gContext.stable.freqs[HocClkModule_Display] = compareHz; + mgr::gContext.stable.realFreqs[HocClkModule_Display] = compareHz; break; } } @@ -313,12 +313,12 @@ namespace governor { } } - void startThreads() { + void StartThreads() { threadCreate(&governorTHREAD, GovernorThread, nullptr, NULL, 0x2000, 0x3F, -2); threadStart(&governorTHREAD); } - void exitThreads() { + void ExitThreads() { threadClose(&governorTHREAD); } -} // namespace governor +} // namespace mgr diff --git a/Source/hoc-clk/sysmodule/src/mgr/governor.hpp b/Source/hoc-clk/sysmodule/src/mgr/governor.hpp index d9f2cb43..a5989a0c 100644 --- a/Source/hoc-clk/sysmodule/src/mgr/governor.hpp +++ b/Source/hoc-clk/sysmodule/src/mgr/governor.hpp @@ -28,7 +28,7 @@ #include "clock_manager.hpp" -namespace governor { +namespace mgr { extern bool isCpuGovernorInBoostMode; extern bool isVRREnabled; extern bool isGpuGovernorEnabled; @@ -36,7 +36,7 @@ namespace governor { extern bool lastGpuGovernorState; extern bool lastCpuGovernorState; extern bool lastVrrGovernorState; - void startThreads(); - void exitThreads(); + void StartThreads(); + void ExitThreads(); void HandleGovernor(uint32_t targetHz); -} // namespace governor \ No newline at end of file +} // namespace mgr \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/soc/dram_mrr.cpp b/Source/hoc-clk/sysmodule/src/soc/dram_mrr.cpp index 74c20a5f..2fd1ad8f 100644 --- a/Source/hoc-clk/sysmodule/src/soc/dram_mrr.cpp +++ b/Source/hoc-clk/sysmodule/src/soc/dram_mrr.cpp @@ -24,7 +24,7 @@ #include #include -namespace soc::mrr { +namespace soc { constexpr u64 EmcPhysBase = 0x7001B000; constexpr u64 Emc0PhysBase = 0x7001E000; constexpr u64 Emc1PhysBase = 0x7001F000; diff --git a/Source/hoc-clk/sysmodule/src/soc/dram_mrr.hpp b/Source/hoc-clk/sysmodule/src/soc/dram_mrr.hpp index c37f540a..a148477e 100644 --- a/Source/hoc-clk/sysmodule/src/soc/dram_mrr.hpp +++ b/Source/hoc-clk/sysmodule/src/soc/dram_mrr.hpp @@ -18,7 +18,7 @@ */ #include -namespace soc::mrr { +namespace soc { typedef enum RealDramModule { /* Erista */ DRAM_HBMGCH = 0, diff --git a/Source/hoc-clk/sysmodule/src/soc/gm20b.cpp b/Source/hoc-clk/sysmodule/src/soc/gm20b.cpp index 9bf3a7e5..e394ae13 100644 --- a/Source/hoc-clk/sysmodule/src/soc/gm20b.cpp +++ b/Source/hoc-clk/sysmodule/src/soc/gm20b.cpp @@ -21,7 +21,7 @@ #include "gm20b.hpp" -namespace gm20b { +namespace soc { u64 gpu_base = 0; #define GPU_PA 0x57000000 #define GPU_SIZE 0x1000000 @@ -123,7 +123,7 @@ namespace gm20b { return success; } - bool setClock(u32 khz) { + bool SetClock(u32 khz) { if (!gpu_base) QueryMemoryMapping(&gpu_base, GPU_PA, GPU_SIZE); @@ -146,4 +146,4 @@ namespace gm20b { return _gpu_pllg_slide(new_divn); } -} // namespace gm20b \ No newline at end of file +} // namespace soc \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/soc/gm20b.hpp b/Source/hoc-clk/sysmodule/src/soc/gm20b.hpp index ec7726cc..9ebfb4be 100644 --- a/Source/hoc-clk/sysmodule/src/soc/gm20b.hpp +++ b/Source/hoc-clk/sysmodule/src/soc/gm20b.hpp @@ -19,6 +19,6 @@ #pragma once #include <../board/board.hpp> -namespace gm20b { - bool setClock(u32 khz); +namespace soc { + bool SetClock(u32 khz); } \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/tsensor/aotag.cpp b/Source/hoc-clk/sysmodule/src/tsensor/aotag.cpp index 87aa66b2..ce6e6d94 100644 --- a/Source/hoc-clk/sysmodule/src/tsensor/aotag.cpp +++ b/Source/hoc-clk/sysmodule/src/tsensor/aotag.cpp @@ -206,7 +206,7 @@ namespace tsensor { SetBit(CFG_TAG_EN_POS, &r); ClearBit(CFG_DISABLE_CLK_POS, &r); WritePmcReg(r, PMC_AOTAG_CFG); - fileUtils::LogLine("[aotag] Init complete!"); + file::utils::LogLine("[aotag] Init complete!"); wasInit = true; } diff --git a/Source/hoc-clk/sysmodule/src/tsensor/bq24193.cpp b/Source/hoc-clk/sysmodule/src/tsensor/bq24193.cpp index 3cfad2e1..80cddc94 100644 --- a/Source/hoc-clk/sysmodule/src/tsensor/bq24193.cpp +++ b/Source/hoc-clk/sysmodule/src/tsensor/bq24193.cpp @@ -19,14 +19,14 @@ #include "bq24193.hpp" -namespace bq24193 { +namespace tsensor { static u8 bq24193_get_reg(u8 reg) { u8 out; I2cRead_OutU8(I2cDevice_Bq24193, reg, &out); return out; } - u8 getBQTemp() { + u8 GetBqTemp() { u8 regVal = bq24193_get_reg(BQ24193_FaultReg); return regVal & BQ24193_FAULT_THERM_MASK; } -} // namespace bq24193 +} // namespace tsensor diff --git a/Source/hoc-clk/sysmodule/src/tsensor/bq24193.hpp b/Source/hoc-clk/sysmodule/src/tsensor/bq24193.hpp index 2eac97a6..23b41fa7 100644 --- a/Source/hoc-clk/sysmodule/src/tsensor/bq24193.hpp +++ b/Source/hoc-clk/sysmodule/src/tsensor/bq24193.hpp @@ -23,7 +23,7 @@ #include "../i2c/i2cDrv.h" -namespace bq24193 { +namespace tsensor { #define BQ24193_I2C_ADDR 0x6B // REG 0 masks. @@ -126,5 +126,5 @@ namespace bq24193 { BQ24193_Temp_Cold = 5, BQ24193_Temp_Hot = 6, }; - u8 getBQTemp(); -} // namespace bq24193 + u8 GetBqTemp(); +} // namespace tsensor diff --git a/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp b/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp index af56a833..6d5b7961 100644 --- a/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp +++ b/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp @@ -491,7 +491,7 @@ namespace tsensor { StartSensors(); - fileUtils::LogLine("[Soctherm] Finished init."); + file::utils::LogLine("[Soctherm] Finished init."); } } // namespace tsensor diff --git a/Source/hoc-clk/sysmodule/src/util/crc32.cpp b/Source/hoc-clk/sysmodule/src/util/crc32.cpp index 7588192f..7fcd5666 100644 --- a/Source/hoc-clk/sysmodule/src/util/crc32.cpp +++ b/Source/hoc-clk/sysmodule/src/util/crc32.cpp @@ -17,8 +17,8 @@ #include -namespace crc32 { - uint32_t crc32(const uint8_t *data, size_t length) { +namespace util { + uint32_t Crc32(const uint8_t *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; i++) { @@ -30,7 +30,7 @@ namespace crc32 { return ~crc; } - uint32_t checksum_file(const char *filename) { + uint32_t ChecksumFile(const char *filename) { FILE *file = fopen(filename, "rb"); if (!file) { perror("[crc32] Error opening file"); @@ -53,4 +53,4 @@ namespace crc32 { fclose(file); return ~crc; } -} // namespace crc32 +} // namespace util diff --git a/Source/hoc-clk/sysmodule/src/util/crc32.h b/Source/hoc-clk/sysmodule/src/util/crc32.h index 05e1bc70..779185c9 100644 --- a/Source/hoc-clk/sysmodule/src/util/crc32.h +++ b/Source/hoc-clk/sysmodule/src/util/crc32.h @@ -18,7 +18,7 @@ #pragma once #include #include -namespace crc32 { - uint32_t crc32(const uint8_t *data, size_t length); - uint32_t checksum_file(const char *filename); -} // namespace crc32 +namespace util { + uint32_t Crc32(const uint8_t *data, size_t length); + uint32_t ChecksumFile(const char *filename); +} // namespace util