From 4e8121ee5ef34df8467b7d22e816a1013e90a657 Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Wed, 17 Dec 2025 22:25:47 +0100 Subject: [PATCH] change contexpr stuff, won't make a difference anyway --- .../stratosphere/loader/source/oc/pcv/pcv.hpp | 91 ++++++------------- .../loader/source/oc/pcv/pcv_mariko.cpp | 39 ++++++++ 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp index 9347551d..de1faa75 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp @@ -52,28 +52,15 @@ namespace ams::ldr::oc::pcv { constexpr u32 CpuVoltOfficial = 1120; constexpr u32 CpuVminOfficial = 620; - constexpr u32 CpuVoltagePatchValues[] = { 850, 38, 1120, 1000, 100, 1000, 0 }; - constexpr s32 CpuVoltagePatchOffsets[] = { -2, -1, 5, 6, 7, 8, 9 }; + static constexpr u32 CpuVoltagePatchValues[] = { 850, 38, 1120, 1000, 100, 1000, 0 }; + static constexpr s32 CpuVoltagePatchOffsets[] = { -2, -1, 5, 6, 7, 8, 9 }; static_assert(sizeof(CpuVoltagePatchValues) == sizeof(CpuVoltagePatchOffsets), "Invalid CpuVoltagePatch size"); - constexpr u32 CpuVoltageSecondaryPatchValues[] = { 800, 1120, 0, 800, 1120, 0, 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950 }; - constexpr s32 CpuVoltageSecondaryPatchOffsets[] = { -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + static constexpr u32 CpuVoltageSecondaryPatchValues[] = { 800, 1120, 0, 800, 1120, 0, 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950 }; + static constexpr 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"); - constexpr u32 CapCpuClock() { - constexpr u32 AllowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, }; - - u32 cpuCap = AllowedCpuMaxFrequencies[0]; - - for (u32 freq : AllowedCpuMaxFrequencies) { - if (C.marikoCpuMaxClock >= freq) { - cpuCap = freq; - } else { - break; - } - } - return cpuCap; - } + static constexpr u32 AllowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, }; constexpr cvb_entry_t GpuCvbTableDefault[] = { // GPUB01_NA_CVB_TABLE @@ -101,8 +88,8 @@ namespace ams::ldr::oc::pcv { constexpr u32 GpuClkPllLimit = 2'600'000; constexpr int GpuVminOfficial = 610; - constexpr u32 GpuDVFSPattern[] = { 1050, 1000, 100, 1000, 10, }; - constexpr u32 GpuVoltThermalPattern[] = { 800, 1120, 0, 610, 1120, 20000, 610, 1120, 30000, 610, 1120, 50000, 610, 1120, 70000, 610, 1120, 90000, }; + static constexpr u32 GpuDVFSPattern[] = { 1050, 1000, 100, 1000, 10, }; + static constexpr u32 GpuVoltThermalPattern[] = { 800, 1120, 0, 610, 1120, 20000, 610, 1120, 30000, 610, 1120, 50000, 610, 1120, 70000, 610, 1120, 90000, }; static_assert(sizeof(GpuVoltThermalPattern) == 72, "Invalid GpuVoltThermalPattern"); struct SpeedoVminTable { @@ -115,52 +102,26 @@ namespace ams::ldr::oc::pcv { u32 offset; }; - constexpr u32 GetGpuVminVoltage() { - constexpr SpeedoVminTable Table[] { - {1560, 590}, - {1583, 570}, - {1620, 565}, - {1670, 560}, - {1694, 555}, - {1731, 550}, - {1750, 540}, - {0xFFFFFFFF, 530}, - }; + static constexpr SpeedoVminTable Table[] { + {1560, 590}, + {1583, 570}, + {1620, 565}, + {1670, 560}, + {1694, 555}, + {1731, 550}, + {1750, 540}, + {0xFFFFFFFF, 530}, + }; - for (auto e : Table) { - if (C.gpuSpeedo <= e.speedo) { - return e.voltage; - } - } - - return 530; - } - - constexpr u32 GetRamVminAdjustment(u32 vmin) { - if (C.marikoEmcMaxClock < 2133000) { - return vmin; - } - - const u32 ramScale = (((C.marikoEmcMaxClock / 1000) - 2133) / 33) * 5 + vmin; - - constexpr RamVminOffsetTable RamOffset[] { - {2400000, 5}, - {2533000, 10}, - {2666000, 15}, - {2800000, 20}, - {2933000, 25}, - {3200000, 30}, - {0xFFFFFFFF, 35}, - }; - - for (auto r : RamOffset) { - if (C.marikoEmcMaxClock < r.maxClock) { - return ramScale + r.offset; - } - } - - return ramScale; - } + static constexpr RamVminOffsetTable RamOffset[] { + {2400000, 5}, + {2533000, 10}, + {2666000, 15}, + {2800000, 20}, + {2933000, 25}, + {3200000, 30}, + {0xFFFFFFFF, 35}, + }; /* GPU Max Clock asm Pattern: * diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp index 998fa80e..dc37f55a 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp @@ -24,6 +24,32 @@ namespace ams::ldr::oc::pcv::mariko { + u32 GetGpuVminVoltage() { + for (auto e : Table) { + if (C.gpuSpeedo <= e.speedo) { + return e.voltage; + } + } + + return 530; + } + + u32 GetRamVminAdjustment(u32 vmin) { + if (C.marikoEmcMaxClock < 2133000) { + return vmin; + } + + const u32 ramScale = (((C.marikoEmcMaxClock / 1000) - 2133) / 33) * 5 + vmin; + + for (auto r : RamOffset) { + if (C.marikoEmcMaxClock < r.maxClock) { + return ramScale + r.offset; + } + } + + return ramScale; + } + /* Note: EOS (probably?) has a bug in this function that always results in high vmin, this is fixed here. */ u32 GetAutoVoltage() { u32 voltage = GetGpuVminVoltage(); @@ -91,6 +117,19 @@ namespace ams::ldr::oc::pcv::mariko { R_SUCCEED(); } + u32 CapCpuClock() { + u32 cpuCap = AllowedCpuMaxFrequencies[0]; + + for (u32 freq : AllowedCpuMaxFrequencies) { + if (C.marikoCpuMaxClock >= freq) { + cpuCap = freq; + } else { + break; + } + } + return cpuCap; + } + Result CpuFreqVdd(u32 *ptr) { dvfs_rail *entry = reinterpret_cast(reinterpret_cast(ptr) - offsetof(dvfs_rail, freq));