loader: patch cpu dfll data for slt
this will correct cpu voltage, and cpu freq drops from uv
This commit is contained in:
@@ -38,15 +38,16 @@ namespace ams::ldr {
|
||||
R_DEFINE_ERROR_RESULT(InvalidMtcTable, 1003);
|
||||
R_DEFINE_ERROR_RESULT(InvalidDvbTable, 1004);
|
||||
R_DEFINE_ERROR_RESULT(InvalidCpuFreqVddEntry, 1005);
|
||||
R_DEFINE_ERROR_RESULT(InvalidCpuDvfs, 1006);
|
||||
R_DEFINE_ERROR_RESULT(InvalidCpuMinVolt, 1007);
|
||||
R_DEFINE_ERROR_RESULT(InvalidGpuDvfs, 1008);
|
||||
R_DEFINE_ERROR_RESULT(InvalidGpuFreqMaxPattern, 1009);
|
||||
R_DEFINE_ERROR_RESULT(InvalidGpuPllEntry, 1010);
|
||||
R_DEFINE_ERROR_RESULT(InvalidRegulatorEntry, 1011);
|
||||
R_DEFINE_ERROR_RESULT(UninitializedPatcher, 1012);
|
||||
R_DEFINE_ERROR_RESULT(UnsuccessfulPatcher, 1013);
|
||||
R_DEFINE_ERROR_RESULT(SafetyCheckFailure, 1014);
|
||||
R_DEFINE_ERROR_RESULT(InvalidCpuVoltDfllEntry, 1006);
|
||||
R_DEFINE_ERROR_RESULT(InvalidCpuDvfs, 1007);
|
||||
R_DEFINE_ERROR_RESULT(InvalidCpuMinVolt, 1008);
|
||||
R_DEFINE_ERROR_RESULT(InvalidGpuDvfs, 1009);
|
||||
R_DEFINE_ERROR_RESULT(InvalidGpuFreqMaxPattern, 1010);
|
||||
R_DEFINE_ERROR_RESULT(InvalidGpuPllEntry, 1011);
|
||||
R_DEFINE_ERROR_RESULT(InvalidRegulatorEntry, 1012);
|
||||
R_DEFINE_ERROR_RESULT(UninitializedPatcher, 1013);
|
||||
R_DEFINE_ERROR_RESULT(UnsuccessfulPatcher, 1014);
|
||||
R_DEFINE_ERROR_RESULT(SafetyCheckFailure, 1015);
|
||||
}
|
||||
|
||||
namespace ams::ldr::oc {
|
||||
|
||||
@@ -34,6 +34,16 @@ typedef struct cvb_entry_t {
|
||||
} cvb_entry_t;
|
||||
static_assert(sizeof(cvb_entry_t) == 0x38);
|
||||
|
||||
typedef struct cvb_cpu_dfll_data {
|
||||
u32 tune0_low;
|
||||
u32 tune0_high;
|
||||
u32 tune1_low;
|
||||
u32 tune1_high;
|
||||
unsigned int tune_high_min_millivolts;
|
||||
unsigned int tune_high_margin_millivolts;
|
||||
unsigned long dvco_calibration_max;
|
||||
} cvb_cpu_dfll_data;
|
||||
|
||||
typedef struct emc_dvb_dvfs_table_t {
|
||||
u64 freq;
|
||||
s32 volt[4] = {0};
|
||||
|
||||
@@ -51,6 +51,28 @@ Result CpuVoltRange(u32* ptr) {
|
||||
R_THROW(ldr::ResultInvalidCpuMinVolt());
|
||||
}
|
||||
|
||||
Result CpuVoltDfll(u32* ptr) {
|
||||
cvb_cpu_dfll_data *entry = reinterpret_cast<cvb_cpu_dfll_data *>(ptr);
|
||||
|
||||
R_UNLESS(entry->tune0_low == 0x0000FFCF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune0_high == 0x00000000, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune1_low == 0x012207FF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune1_high == 0x03FFF7FF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
|
||||
if (C.marikoCpuUV) {
|
||||
if (C.marikoCpuUV == 1) {
|
||||
PATCH_OFFSET(&(entry->tune0_low), 0x0000FF90); //process_id 0
|
||||
} else if (C.marikoCpuUV == 2) {
|
||||
PATCH_OFFSET(&(entry->tune0_low), 0x0000FFA0); //process_id 1
|
||||
}
|
||||
PATCH_OFFSET(&(entry->tune0_high), 0x0000FFFF);
|
||||
PATCH_OFFSET(&(entry->tune1_low), 0x021107FF);
|
||||
PATCH_OFFSET(&(entry->tune1_high), 0x00000000);
|
||||
}
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result GpuFreqMaxAsm(u32* ptr32) {
|
||||
// Check if both two instructions match the pattern
|
||||
u32 ins1 = *ptr32, ins2 = *(ptr32 + 1);
|
||||
@@ -537,6 +559,7 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||
{ "CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit },
|
||||
{ "CPU Freq Table", CpuFreqCvbTable<true>, 1, nullptr, CpuCvbDefaultMaxFreq },
|
||||
{ "CPU Volt Limit", &CpuVoltRange, 13, nullptr, CpuVoltOfficial },
|
||||
{ "CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0x0000FFCF },
|
||||
{ "GPU Freq Table", GpuFreqCvbTable<true>, 1, nullptr, GpuCvbDefaultMaxFreq },
|
||||
{ "GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn },
|
||||
//{ "GPU Freq PLL", &GpuFreqPllLimit, 1, nullptr, GpuClkPllLimit },
|
||||
|
||||
@@ -313,9 +313,10 @@ var CustTable: Array<CustEntry> = [
|
||||
["Reduce CPU power draw",
|
||||
"Your CPU might not withstand undervolt and performance might drop",
|
||||
"<b>0</b> : Default Table",
|
||||
"<b>1</b> : Undervolt Level 1 (SLT)",],
|
||||
"<b>1</b> : Undervolt Level 1 (SLT - CPU process_id: 0)",
|
||||
"<b>2</b> : Undervolt Level 1 (SLT - CPU process_id: 1)",],
|
||||
0,
|
||||
[0,1],
|
||||
[0,2],
|
||||
1,
|
||||
),
|
||||
new CustEntry(
|
||||
|
||||
Reference in New Issue
Block a user