cpu fixes, deprecate auto

This commit is contained in:
Lightos1
2026-01-02 19:29:10 +01:00
parent ca72c1fc5e
commit c5e3a27bbb
4 changed files with 42 additions and 50 deletions

View File

@@ -35,7 +35,7 @@ enum MtcConfig: u32 {
}; };
enum TableConfig: u32 { enum TableConfig: u32 {
AUTO_DEPRECATED = 0, AUTO_DEPRECATED = 0, /* Auto is not supported yet. */
DEFAULT_TABLE = 1, DEFAULT_TABLE = 1,
TBREAK_1581 = 2, TBREAK_1581 = 2,
TBREAK_1683 = 3, TBREAK_1683 = 3,

View File

@@ -168,7 +168,7 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
if (isMariko) if (isMariko)
mariko::Patch(mapped_nso, nso_size); mariko::Patch(mapped_nso, nso_size);
else else
erista::Patch(mapped_nso, nso_size); mariko::Patch(mapped_nso, nso_size);
#endif #endif
} }

View File

@@ -5,8 +5,6 @@
* *
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* Copyright (c) 2025 Lightos_
*
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation. * version 2, as published by the Free Software Foundation.
@@ -58,9 +56,7 @@ namespace ams::ldr::oc::pcv {
static const s32 cpuVoltagePatchOffsets[] = { -2, -1, 5, 6, 7, 8, 9 }; static const s32 cpuVoltagePatchOffsets[] = { -2, -1, 5, 6, 7, 8, 9 };
static_assert(sizeof(cpuVoltagePatchValues) == sizeof(cpuVoltagePatchOffsets), "Invalid cpuVoltagePatch size"); static_assert(sizeof(cpuVoltagePatchValues) == sizeof(cpuVoltagePatchOffsets), "Invalid cpuVoltagePatch size");
static const u32 cpuVoltageSecondaryPatchValues[] = { 800, 1120, 0, 800, 1120, 0, 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950 }; static const u32 cpuVoltThermalData[] = { 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950, 1227, 0 };
static const s32 cpuVoltageSecondaryPatchOffsets[] = { -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
static_assert(sizeof(cpuVoltageSecondaryPatchValues) == sizeof(cpuVoltageSecondaryPatchOffsets), "Invalid secondary cpuVoltagePatch size");
static const u32 allowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, }; static const u32 allowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, };
@@ -336,13 +332,7 @@ namespace ams::ldr::oc::pcv {
} }
u32 cpu_max_volt = isMariko ? C.marikoCpuMaxVolt : C.eristaCpuMaxVolt; u32 cpu_max_volt = isMariko ? C.marikoCpuMaxVolt : C.eristaCpuMaxVolt;
u32 cpu_freq_threshold = 1020'000; u32 cpu_freq_threshold = 2091'000;
if (isMariko) {
cpu_freq_threshold = 2193'000;
} else {
cpu_freq_threshold = 2091'000;
}
size_t default_entry_count = GetDvfsTableEntryCount(default_table); size_t default_entry_count = GetDvfsTableEntryCount(default_table);
size_t default_table_size = default_entry_count * sizeof(cvb_entry_t); size_t default_table_size = default_entry_count * sizeof(cvb_entry_t);

View File

@@ -147,7 +147,6 @@ namespace ams::ldr::oc::pcv::mariko {
} }
Result CpuVoltDVFS(u32 *ptr) { Result CpuVoltDVFS(u32 *ptr) {
/* Check first pattern. */
if (MatchesPattern(ptr, cpuVoltagePatchOffsets, cpuVoltagePatchValues)) { if (MatchesPattern(ptr, cpuVoltagePatchOffsets, cpuVoltagePatchValues)) {
if (C.marikoCpuLowVmin) { if (C.marikoCpuLowVmin) {
PATCH_OFFSET(ptr, C.marikoCpuLowVmin); PATCH_OFFSET(ptr, C.marikoCpuLowVmin);
@@ -164,8 +163,14 @@ namespace ams::ldr::oc::pcv::mariko {
R_SUCCEED(); R_SUCCEED();
} }
/* Check alternative pattern. */ R_THROW(ldr::ResultInvalidCpuMinVolt());
if (MatchesPattern(ptr, cpuVoltageSecondaryPatchOffsets, cpuVoltageSecondaryPatchValues)) { }
Result CpuVoltThermals(u32 *ptr) {
if (std::memcmp(ptr, cpuVoltThermalData, sizeof(cpuVoltThermalData))) {
R_THROW(ldr::ResultInvalidCpuMinVolt());
}
if (C.marikoCpuLowVmin) { if (C.marikoCpuLowVmin) {
PATCH_OFFSET(ptr, C.marikoCpuLowVmin); PATCH_OFFSET(ptr, C.marikoCpuLowVmin);
PATCH_OFFSET(ptr + 3, C.marikoCpuLowVmin); PATCH_OFFSET(ptr + 3, C.marikoCpuLowVmin);
@@ -173,18 +178,14 @@ namespace ams::ldr::oc::pcv::mariko {
if (C.marikoCpuMaxVolt) { if (C.marikoCpuMaxVolt) {
PATCH_OFFSET(ptr - 2, C.marikoCpuMaxVolt); PATCH_OFFSET(ptr - 2, C.marikoCpuMaxVolt);
PATCH_OFFSET(ptr - 5, C.marikoCpuMaxVolt);
PATCH_OFFSET(ptr + 1, C.marikoCpuMaxVolt); PATCH_OFFSET(ptr + 1, C.marikoCpuMaxVolt);
PATCH_OFFSET(ptr + 4, C.marikoCpuMaxVolt); PATCH_OFFSET(ptr + 4, C.marikoCpuMaxVolt);
PATCH_OFFSET(ptr - 5, C.marikoCpuMaxVolt);
} }
R_SUCCEED(); R_SUCCEED();
} }
/* Both patterns fail. */
R_THROW(ldr::ResultInvalidCpuMinVolt());
}
Result CpuVoltDfll(u32 *ptr) { Result CpuVoltDfll(u32 *ptr) {
cvb_cpu_dfll_data *entry = reinterpret_cast<cvb_cpu_dfll_data *>(ptr); cvb_cpu_dfll_data *entry = reinterpret_cast<cvb_cpu_dfll_data *>(ptr);
@@ -1008,10 +1009,11 @@ namespace ams::ldr::oc::pcv::mariko {
PatcherEntry<u32> patches[] = { PatcherEntry<u32> patches[] = {
{"CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit}, {"CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit},
{"CPU Freq Table", CpuFreqCvbTable<true>, 1, nullptr, CpuCvbDefaultMaxFreq}, {"CPU Freq Table", CpuFreqCvbTable<true>, 1, nullptr, CpuCvbDefaultMaxFreq},
{"CPU Volt DVFS", &CpuVoltDVFS, 2, nullptr, CpuVminOfficial}, {"CPU Volt DVFS", &CpuVoltDVFS, 1, nullptr, CpuVminOfficial},
{"CPU Volt Thermals", &CpuVoltThermals, 1, nullptr, CpuVminOfficial},
{"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0x0000FFCF}, {"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0x0000FFCF},
{"GPU Volt DVFS", &GpuVoltDVFS, 1, nullptr, GpuVminOfficial}, {"GPU Volt DVFS", &GpuVoltDVFS, 1, nullptr, GpuVminOfficial},
{"Gpu Volt Thermals", &GpuVoltThermals, 1, nullptr, GpuVminOfficial}, {"GPU Volt Thermals", &GpuVoltThermals, 1, nullptr, GpuVminOfficial},
{"GPU Freq Table", GpuFreqCvbTable<true>, 1, nullptr, GpuCvbDefaultMaxFreq}, {"GPU Freq Table", GpuFreqCvbTable<true>, 1, nullptr, GpuCvbDefaultMaxFreq},
{"GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn}, {"GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn},
{"GPU PLL Max", &GpuFreqPllMax, 1, nullptr, GpuClkPllMax}, {"GPU PLL Max", &GpuFreqPllMax, 1, nullptr, GpuClkPllMax},