Improve formating
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace ams::ldr::hoc::pcv {
|
namespace ams::ldr::hoc::pcv {
|
||||||
|
|
||||||
Result MemFreqPllmLimit(u32* ptr) {
|
Result MemFreqPllmLimit(u32* ptr) {
|
||||||
clk_pll_param* entry = reinterpret_cast<clk_pll_param *>(ptr);
|
clk_pll_param* entry = reinterpret_cast<clk_pll_param *>(ptr);
|
||||||
R_UNLESS(entry->freq == entry->vco_max, ldr::ResultInvalidMemPllmEntry());
|
R_UNLESS(entry->freq == entry->vco_max, ldr::ResultInvalidMemPllmEntry());
|
||||||
|
|
||||||
@@ -31,9 +31,9 @@ Result MemFreqPllmLimit(u32* ptr) {
|
|||||||
entry->freq = max_clk;
|
entry->freq = max_clk;
|
||||||
entry->vco_max = max_clk;
|
entry->vco_max = max_clk;
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result MemVoltHandler(u32* ptr) {
|
Result MemVoltHandler(u32* ptr) {
|
||||||
// ptr value might be default_uv or max_uv
|
// ptr value might be default_uv or max_uv
|
||||||
regulator* entries[2] = {
|
regulator* entries[2] = {
|
||||||
reinterpret_cast<regulator *>(reinterpret_cast<u8 *>(ptr) - offsetof(regulator, type_1.default_uv)),
|
reinterpret_cast<regulator *>(reinterpret_cast<u8 *>(ptr) - offsetof(regulator, type_1.default_uv)),
|
||||||
@@ -54,25 +54,28 @@ Result MemVoltHandler(u32* ptr) {
|
|||||||
|
|
||||||
regulator* entry = nullptr;
|
regulator* entry = nullptr;
|
||||||
for (auto& i : entries) {
|
for (auto& i : entries) {
|
||||||
if (R_SUCCEEDED(validator(i)))
|
if (R_SUCCEEDED(validator(i))) {
|
||||||
entry = i;
|
entry = i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
R_UNLESS(entry, ldr::ResultInvalidRegulatorEntry());
|
R_UNLESS(entry, ldr::ResultInvalidRegulatorEntry());
|
||||||
|
|
||||||
u32 emc_uv = C.commonEmcMemVolt;
|
u32 emc_uv = C.commonEmcMemVolt;
|
||||||
if (!emc_uv)
|
if (!emc_uv) {
|
||||||
R_SKIP();
|
R_SKIP();
|
||||||
|
}
|
||||||
|
|
||||||
if (emc_uv % uv_step)
|
if (emc_uv % uv_step) {
|
||||||
emc_uv = emc_uv / uv_step * uv_step; // rounding
|
emc_uv = emc_uv / uv_step * uv_step; // rounding
|
||||||
|
}
|
||||||
|
|
||||||
PATCH_OFFSET(ptr, emc_uv);
|
PATCH_OFFSET(ptr, emc_uv);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SafetyCheck() {
|
void SafetyCheck() {
|
||||||
// if (C.custRev != CUST_REV)
|
// if (C.custRev != CUST_REV)
|
||||||
// CRASH("Triggered");
|
// CRASH("Triggered");
|
||||||
|
|
||||||
@@ -94,6 +97,7 @@ void SafetyCheck() {
|
|||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 eristaCpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaCpuDvfsTable)->freq);
|
u32 eristaCpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaCpuDvfsTable)->freq);
|
||||||
u32 marikoCpuDvfsMaxFreq;
|
u32 marikoCpuDvfsMaxFreq;
|
||||||
if (C.marikoCpuUVHigh) {
|
if (C.marikoCpuUVHigh) {
|
||||||
@@ -106,8 +110,7 @@ void SafetyCheck() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
u32 eristaGpuDvfsMaxFreq;
|
u32 eristaGpuDvfsMaxFreq;
|
||||||
switch (C.eristaGpuUV)
|
switch (C.eristaGpuUV) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTable)->freq);
|
eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTable)->freq);
|
||||||
break;
|
break;
|
||||||
@@ -155,12 +158,13 @@ void SafetyCheck() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (auto& i : validators) {
|
for (auto& i : validators) {
|
||||||
if (R_FAILED(i.check()))
|
if (R_FAILED(i.check())) {
|
||||||
CRASH("Validation FAIL");
|
CRASH("Validation FAIL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||||
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
||||||
SafetyCheck();
|
SafetyCheck();
|
||||||
bool isMariko = (spl::GetSocType() == spl::SocType_Mariko);
|
bool isMariko = (spl::GetSocType() == spl::SocType_Mariko);
|
||||||
@@ -169,6 +173,6 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
else
|
else
|
||||||
erista::Patch(mapped_nso, nso_size);
|
erista::Patch(mapped_nso, nso_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace ams::ldr::hoc::pcv {
|
namespace ams::ldr::hoc::pcv {
|
||||||
|
|
||||||
typedef struct cvb_coefficients {
|
typedef struct cvb_coefficients {
|
||||||
s32 c0 = 0;
|
s32 c0 = 0;
|
||||||
@@ -135,9 +135,10 @@
|
|||||||
auto is_empty = [](NT* entry) {
|
auto is_empty = [](NT* entry) {
|
||||||
uint8_t* m = reinterpret_cast<uint8_t *>(entry);
|
uint8_t* m = reinterpret_cast<uint8_t *>(entry);
|
||||||
for (size_t i = 0; i < sizeof(NT); i++) {
|
for (size_t i = 0; i < sizeof(NT); i++) {
|
||||||
if (*(m + i))
|
if (*(m + i)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,4 +166,4 @@
|
|||||||
return table + index;
|
return table + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,16 @@
|
|||||||
|
|
||||||
namespace ams::ldr::hoc::ptm {
|
namespace ams::ldr::hoc::ptm {
|
||||||
|
|
||||||
Result CpuPtmBoost(perf_conf_entry* entry) {
|
Result CpuPtmBoost(perf_conf_entry* entry) {
|
||||||
|
|
||||||
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
||||||
bool isMariko = (spl::GetSocType() == spl::SocType_Mariko);
|
bool isMariko = (spl::GetSocType() == spl::SocType_Mariko);
|
||||||
#else
|
#else
|
||||||
bool isMariko = true;
|
bool isMariko = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!C.eristaCpuBoostClock || !C.marikoCpuBoostClock)
|
if (!C.eristaCpuBoostClock || !C.marikoCpuBoostClock) {
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
u32 cpuPtmBoostNew = isMariko ? C.marikoCpuBoostClock * 1000 : C.eristaCpuBoostClock * 1000;
|
u32 cpuPtmBoostNew = isMariko ? C.marikoCpuBoostClock * 1000 : C.eristaCpuBoostClock * 1000;
|
||||||
|
|
||||||
@@ -37,35 +37,31 @@ Result CpuPtmBoost(perf_conf_entry* entry) {
|
|||||||
PATCH_OFFSET(&(entry->cpu_freq_2), cpuPtmBoostNew);
|
PATCH_OFFSET(&(entry->cpu_freq_2), cpuPtmBoostNew);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result MemPtm(perf_conf_entry* entry) {
|
Result MemPtm(perf_conf_entry* entry) {
|
||||||
PATCH_OFFSET(&(entry->emc_freq_1), memPtmLimit);
|
PATCH_OFFSET(&(entry->emc_freq_1), memPtmLimit);
|
||||||
PATCH_OFFSET(&(entry->emc_freq_2), memPtmLimit);
|
PATCH_OFFSET(&(entry->emc_freq_2), memPtmLimit);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PtmEntryIsValid(perf_conf_entry* entry) {
|
bool PtmEntryIsValid(perf_conf_entry* entry) {
|
||||||
return (entry->cpu_freq_1 == entry->cpu_freq_2 &&
|
return (entry->cpu_freq_1 == entry->cpu_freq_2 && entry->gpu_freq_1 == entry->gpu_freq_2 && entry->emc_freq_1 == entry->emc_freq_2);
|
||||||
entry->gpu_freq_1 == entry->gpu_freq_2 &&
|
}
|
||||||
entry->emc_freq_1 == entry->emc_freq_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PtmTablePatternFn(u32* ptr) {
|
bool PtmTablePatternFn(u32* ptr) {
|
||||||
perf_conf_entry* entry = reinterpret_cast<perf_conf_entry *>(ptr);
|
perf_conf_entry* entry = reinterpret_cast<perf_conf_entry *>(ptr);
|
||||||
if (!PtmEntryIsValid(entry))
|
if (!PtmEntryIsValid(entry)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return entry->cpu_freq_1 == cpuPtmDefault;
|
return entry->cpu_freq_1 == cpuPtmDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||||
perf_conf_entry* confTable = nullptr;
|
perf_conf_entry* confTable = nullptr;
|
||||||
for (uintptr_t ptr = mapped_nso;
|
for (uintptr_t ptr = mapped_nso; ptr <= mapped_nso + nso_size - sizeof(perf_conf_entry) * entryCnt; ptr += sizeof(u32)) {
|
||||||
ptr <= mapped_nso + nso_size - sizeof(perf_conf_entry) * entryCnt;
|
|
||||||
ptr += sizeof(u32))
|
|
||||||
{
|
|
||||||
u32* ptr32 = reinterpret_cast<u32 *>(ptr);
|
u32* ptr32 = reinterpret_cast<u32 *>(ptr);
|
||||||
if (PtmTablePatternFn(ptr32)) {
|
if (PtmTablePatternFn(ptr32)) {
|
||||||
confTable = reinterpret_cast<perf_conf_entry *>(ptr);
|
confTable = reinterpret_cast<perf_conf_entry *>(ptr);
|
||||||
@@ -86,9 +82,8 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
bool isMariko = true;
|
bool isMariko = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
for (u32 i = 0; i < entryCnt; i++) {
|
for (u32 i = 0; i < entryCnt; i++) {
|
||||||
perf_conf_entry* entry = confTable + i;
|
perf_conf_entry *entry = confTable + i;
|
||||||
|
|
||||||
if (!PtmEntryIsValid(entry)) {
|
if (!PtmEntryIsValid(entry)) {
|
||||||
LOGGING("@%p", &entry);
|
LOGGING("@%p", &entry);
|
||||||
@@ -130,6 +125,6 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
if (R_FAILED(memPtmPatch.CheckResult()))
|
if (R_FAILED(memPtmPatch.CheckResult()))
|
||||||
CRASH(memPtmPatch.description);
|
CRASH(memPtmPatch.description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace ams::ldr::hoc::ptm {
|
namespace ams::ldr::hoc::ptm {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 conf_id;
|
u32 conf_id;
|
||||||
u32 cpu_freq_1; // min-max pair?
|
u32 cpu_freq_1; // min-max pair?
|
||||||
u32 cpu_freq_2;
|
u32 cpu_freq_2;
|
||||||
@@ -31,17 +31,17 @@ typedef struct {
|
|||||||
u32 emc_freq_1;
|
u32 emc_freq_1;
|
||||||
u32 emc_freq_2;
|
u32 emc_freq_2;
|
||||||
u32 padding;
|
u32 padding;
|
||||||
} perf_conf_entry;
|
} perf_conf_entry;
|
||||||
|
|
||||||
constexpr u32 entryCnt = 16;
|
constexpr u32 entryCnt = 16;
|
||||||
constexpr u32 cpuPtmDefault = 1020'000'000;
|
constexpr u32 cpuPtmDefault = 1020'000'000;
|
||||||
constexpr u32 cpuPtmDevOC = 1224'000'000;
|
constexpr u32 cpuPtmDevOC = 1224'000'000;
|
||||||
constexpr u32 cpuPtmBoost = 1785'000'000;
|
constexpr u32 cpuPtmBoost = 1785'000'000;
|
||||||
|
|
||||||
constexpr u32 memPtmLimit = 1600'000'000;
|
constexpr u32 memPtmLimit = 1600'000'000;
|
||||||
constexpr u32 memPtmAlt = 1331'200'000;
|
constexpr u32 memPtmAlt = 1331'200'000;
|
||||||
constexpr u32 memPtmClamp = 1065'600'000;
|
constexpr u32 memPtmClamp = 1065'600'000;
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user