remove constexpr
This commit is contained in:
@@ -73,8 +73,8 @@ Result MemVoltHandler(u32* ptr) {
|
||||
}
|
||||
|
||||
void SafetyCheck() {
|
||||
// if (C.custRev != CUST_REV) // causes more issues than help
|
||||
// CRASH("Triggered");
|
||||
if (C.custRev != CUST_REV)
|
||||
CRASH("Triggered");
|
||||
|
||||
struct sValidator {
|
||||
volatile u32 value;
|
||||
|
||||
@@ -52,16 +52,15 @@ namespace ams::ldr::oc::pcv {
|
||||
constexpr u32 CpuVoltOfficial = 1120;
|
||||
constexpr u32 CpuVminOfficial = 620;
|
||||
|
||||
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");
|
||||
static const u32 cpuVoltagePatchValues[] = { 850, 38, 1120, 1000, 100, 1000, 0 };
|
||||
static const s32 cpuVoltagePatchOffsets[] = { -2, -1, 5, 6, 7, 8, 9 };
|
||||
static_assert(sizeof(cpuVoltagePatchValues) == sizeof(cpuVoltagePatchOffsets), "Invalid CpuVoltagePatch size");
|
||||
|
||||
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");
|
||||
|
||||
static constexpr u32 AllowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000 };
|
||||
static const u32 cpuVoltageSecondaryPatchValues[] = { 800, 1120, 0, 800, 1120, 0, 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950 };
|
||||
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, };
|
||||
|
||||
constexpr cvb_entry_t GpuCvbTableDefault[] = {
|
||||
// GPUB01_NA_CVB_TABLE
|
||||
@@ -89,9 +88,9 @@ namespace ams::ldr::oc::pcv {
|
||||
constexpr u32 GpuClkPllLimit = 2'600'000;
|
||||
constexpr int GpuVminOfficial = 610;
|
||||
|
||||
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");
|
||||
static const u32 gpuDVFSPattern[] = { 1050, 1000, 100, 1000, 10, };
|
||||
static const 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 {
|
||||
u32 speedo;
|
||||
@@ -103,7 +102,7 @@ namespace ams::ldr::oc::pcv {
|
||||
u32 offset;
|
||||
};
|
||||
|
||||
static constexpr SpeedoVminTable Table[] {
|
||||
static const SpeedoVminTable vminTable[] {
|
||||
{1560, 590},
|
||||
{1583, 570},
|
||||
{1620, 565},
|
||||
@@ -114,7 +113,7 @@ namespace ams::ldr::oc::pcv {
|
||||
{0xFFFFFFFF, 530},
|
||||
};
|
||||
|
||||
static constexpr RamVminOffsetTable RamOffset[] {
|
||||
static const RamVminOffsetTable ramOffset[] {
|
||||
{2400000, 5},
|
||||
{2533000, 10},
|
||||
{2666000, 15},
|
||||
@@ -136,15 +135,24 @@ namespace ams::ldr::oc::pcv {
|
||||
* #31 |30 29|28 27 26 25 24 23|22 21|20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 |4 3 2 1 0
|
||||
* 0 | 1 1 | 1 0 0 1 0 1| 0 1| 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 |0 1 0 1 1
|
||||
*/
|
||||
|
||||
inline constexpr u32 asm_pattern[] = {0x52820000, 0x72A001C0};
|
||||
inline auto asm_compare_no_rd = [](u32 ins1, u32 ins2)
|
||||
{ return ((ins1 ^ ins2) >> 5) == 0; };
|
||||
inline auto asm_get_rd = [](u32 ins)
|
||||
{ return ins & ((1 << 5) - 1); };
|
||||
inline auto asm_set_rd = [](u32 ins, u8 rd)
|
||||
{ return (ins & 0xFFFFFFE0) | (rd & 0x1F); };
|
||||
inline auto asm_set_imm16 = [](u32 ins, u16 imm)
|
||||
{ return (ins & 0xFFE0001F) | ((imm & 0xFFFF) << 5); };
|
||||
|
||||
inline auto asm_compare_no_rd = [](u32 ins1, u32 ins2) {
|
||||
return ((ins1 ^ ins2) >> 5) == 0;
|
||||
};
|
||||
|
||||
inline auto asm_get_rd = [](u32 ins) {
|
||||
return ins & ((1 << 5) - 1);
|
||||
};
|
||||
|
||||
inline auto asm_set_rd = [](u32 ins, u8 rd) {
|
||||
return (ins & 0xFFFFFFE0) | (rd & 0x1F);
|
||||
};
|
||||
|
||||
inline auto asm_set_imm16 = [](u32 ins, u16 imm) {
|
||||
return (ins & 0xFFE0001F) | ((imm & 0xFFFF) << 5);
|
||||
};
|
||||
|
||||
inline bool GpuMaxClockPatternFn(u32 *ptr32) {
|
||||
return asm_compare_no_rd(*ptr32, asm_pattern[0]);
|
||||
@@ -194,8 +202,6 @@ namespace ams::ldr::oc::pcv {
|
||||
|
||||
constexpr int GpuVminOfficial = 810;
|
||||
|
||||
constexpr int GpuVmaxOfficial = 1200; /* No point in patching this but here's the info if one needs it */
|
||||
|
||||
constexpr u32 CpuVoltOfficial = 1235;
|
||||
|
||||
constexpr u32 CpuVoltL4T = 1235'000;
|
||||
@@ -208,8 +214,6 @@ namespace ams::ldr::oc::pcv {
|
||||
}
|
||||
|
||||
constexpr u32 GpuClkPllLimit = 921'600'000;
|
||||
constexpr u32 GpuClkPllMax = 1300'000'000; /* No point in patching this but here's the info if one needs it */
|
||||
constexpr u32 GpuClkPllLimit2 = 2'600'000; /* No point in patching this but here's the info if one needs it */
|
||||
|
||||
/* GPU Max Clock asm Pattern:
|
||||
*
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
u32 GetGpuVminVoltage() {
|
||||
for (auto e : Table) {
|
||||
for (auto e : vminTable) {
|
||||
if (C.gpuSpeedo <= e.speedo) {
|
||||
return e.voltage;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
const u32 ramScale = (((C.marikoEmcMaxClock / 1000) - 2133) / 33) * 5 + vmin;
|
||||
|
||||
for (auto r : RamOffset) {
|
||||
for (auto r : ramOffset) {
|
||||
if (C.marikoEmcMaxClock < r.maxClock) {
|
||||
return ramScale + r.offset;
|
||||
}
|
||||
@@ -66,8 +66,8 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
Result GpuVoltDVFS(u32 *ptr) {
|
||||
/* Check for valid pattern. */
|
||||
for (size_t i = 0; i < std::size(GpuDVFSPattern); ++i) {
|
||||
if (*(ptr + i + 1) != GpuDVFSPattern[i]) {
|
||||
for (size_t i = 0; i < std::size(gpuDVFSPattern); ++i) {
|
||||
if (*(ptr + i + 1) != gpuDVFSPattern[i]) {
|
||||
R_THROW(ldr::ResultInvalidGpuDvfs());
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
}
|
||||
|
||||
Result GpuVoltThermals(u32 *ptr) {
|
||||
u32 vmin = std::memcmp(ptr - 3, GpuVoltThermalPattern, sizeof(GpuVoltThermalPattern));
|
||||
u32 vmin = std::memcmp(ptr - 3, gpuVoltThermalPattern, sizeof(gpuVoltThermalPattern));
|
||||
if (vmin) {
|
||||
R_THROW(ldr::ResultInvalidGpuDvfs());
|
||||
}
|
||||
@@ -118,9 +118,9 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
}
|
||||
|
||||
u32 CapCpuClock() {
|
||||
u32 cpuCap = AllowedCpuMaxFrequencies[0];
|
||||
u32 cpuCap = allowedCpuMaxFrequencies[0];
|
||||
|
||||
for (u32 freq : AllowedCpuMaxFrequencies) {
|
||||
for (u32 freq : allowedCpuMaxFrequencies) {
|
||||
if (C.marikoCpuMaxClock >= freq) {
|
||||
cpuCap = freq;
|
||||
} else {
|
||||
@@ -157,7 +157,7 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
};
|
||||
|
||||
/* Check first pattern. */
|
||||
if (MatchesPattern(ptr, CpuVoltagePatchOffsets, CpuVoltagePatchValues)) {
|
||||
if (MatchesPattern(ptr, cpuVoltagePatchOffsets, cpuVoltagePatchValues)) {
|
||||
if (C.marikoCpuLowVmin) {
|
||||
PATCH_OFFSET(ptr, C.marikoCpuLowVmin);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
}
|
||||
|
||||
/* Check alternative pattern. */
|
||||
if (MatchesPattern(ptr, CpuVoltageSecondaryPatchOffsets, CpuVoltageSecondaryPatchValues)) {
|
||||
if (MatchesPattern(ptr, cpuVoltageSecondaryPatchOffsets, cpuVoltageSecondaryPatchValues)) {
|
||||
if (C.marikoCpuLowVmin) {
|
||||
PATCH_OFFSET(ptr, C.marikoCpuLowVmin);
|
||||
PATCH_OFFSET(ptr + 3, C.marikoCpuLowVmin);
|
||||
|
||||
Reference in New Issue
Block a user