ldr: slightly clean up MemFreqMtcTable
This commit is contained in:
@@ -681,7 +681,7 @@ namespace ams::ldr::hoc::pcv::mariko {
|
|||||||
|
|
||||||
Result MtcValidateAllTables(MarikoMtcTable *tableStart, const u32 *validationList, u32 tableCount) {
|
Result MtcValidateAllTables(MarikoMtcTable *tableStart, const u32 *validationList, u32 tableCount) {
|
||||||
for (u32 i = 0; i < tableCount; ++i) {
|
for (u32 i = 0; i < tableCount; ++i) {
|
||||||
R_UNLESS(R_SUCCEEDED(VerifyMtcTable(&tableStart[i], validationList[i])), ldr::ResultInvalidMtcTable());
|
R_TRY(VerifyMtcTable(&tableStart[i], validationList[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
@@ -703,9 +703,9 @@ namespace ams::ldr::hoc::pcv::mariko {
|
|||||||
return MtcTableIndex_Invalid;
|
return MtcTableIndex_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
NORETURN void AbortInvalidDramId() {
|
NORETURN void AbortInvalidMtc(const char *crashMsg) {
|
||||||
panic::SmcError(panic::Emc);
|
panic::SmcError(panic::Emc);
|
||||||
CRASH("Invalid dram id\n");
|
CRASH(crashMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetMtcOffset(MtcTableIndex index) {
|
u32 GetMtcOffset(MtcTableIndex index) {
|
||||||
@@ -744,7 +744,7 @@ namespace ams::ldr::hoc::pcv::mariko {
|
|||||||
MtcTableIndex idx = GetMtcDramIndex(dramId);
|
MtcTableIndex idx = GetMtcDramIndex(dramId);
|
||||||
/* If for some reason this happens, there is no chance of recovering this. */
|
/* If for some reason this happens, there is no chance of recovering this. */
|
||||||
if (idx == MtcTableIndex_Invalid) {
|
if (idx == MtcTableIndex_Invalid) {
|
||||||
AbortInvalidDramId();
|
AbortInvalidMtc("Invalid dramId");
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
}();
|
}();
|
||||||
@@ -753,10 +753,10 @@ namespace ams::ldr::hoc::pcv::mariko {
|
|||||||
static const u32 mtcOffset = GetMtcOffset(mtcIndex);
|
static const u32 mtcOffset = GetMtcOffset(mtcIndex);
|
||||||
|
|
||||||
/* Offset from 1600MHz pointer to 204Mhz table start. */
|
/* Offset from 1600MHz pointer to 204Mhz table start. */
|
||||||
constexpr u32 StartAdjustment = offsetof(MarikoMtcTable, rate_khz) + sizeof(MarikoMtcTable) * 2;
|
constexpr u32 StartAdjustment = offsetof(MarikoMtcTable, rate_khz) + sizeof(MarikoMtcTable) * (mariko::MtcTableCountDefault - 1);
|
||||||
u8 *startPtr = reinterpret_cast<u8 *>(ptr) - StartAdjustment;
|
u8 *startPtr = reinterpret_cast<u8 *>(ptr) - StartAdjustment;
|
||||||
MarikoMtcTable *table = reinterpret_cast<MarikoMtcTable *>(startPtr + mtcOffset);
|
MarikoMtcTable *table = reinterpret_cast<MarikoMtcTable *>(startPtr + mtcOffset);
|
||||||
R_UNLESS(R_SUCCEEDED(MtcValidateAllTables(table, EmcListDefault, EmcListSizeDefault)), ldr::ResultInvalidMtcTable());
|
R_TRY(MtcValidateAllTables(table, EmcListDefault, EmcListSizeDefault));
|
||||||
|
|
||||||
if (C.marikoEmcMaxClock <= EmcClkOSLimit) {
|
if (C.marikoEmcMaxClock <= EmcClkOSLimit) {
|
||||||
R_SKIP();
|
R_SKIP();
|
||||||
@@ -766,13 +766,13 @@ namespace ams::ldr::hoc::pcv::mariko {
|
|||||||
table = reinterpret_cast<MarikoMtcTable *>(startPtr);
|
table = reinterpret_cast<MarikoMtcTable *>(startPtr);
|
||||||
|
|
||||||
if (R_FAILED(MtcValidateAllTables(table, EmcListDefault, EmcListSizeDefault))) {
|
if (R_FAILED(MtcValidateAllTables(table, EmcListDefault, EmcListSizeDefault))) {
|
||||||
panic::SmcError(panic::Emc);
|
AbortInvalidMtc("Failed mtc validation");
|
||||||
}
|
}
|
||||||
|
|
||||||
MtcExtendTables(table);
|
MtcExtendTables(table);
|
||||||
|
|
||||||
if (R_FAILED(MtcValidateAllTables(table, newEmcList.data(), newEmcList.size()))) {
|
if (R_FAILED(MtcValidateAllTables(table, newEmcList.data(), newEmcList.size()))) {
|
||||||
panic::SmcError(panic::Emc);
|
AbortInvalidMtc("Failed mtc validation");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i = mariko::MtcTableCountDefault; i < newEmcList.size(); ++i) {
|
for (u32 i = mariko::MtcTableCountDefault; i < newEmcList.size(); ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user