Revert "loader: format code"

This reverts commit d5bf7b0432.
This commit is contained in:
souldbminersmwc
2025-12-11 16:12:40 -05:00
parent d5bf7b0432
commit cd531d163e
3 changed files with 513 additions and 588 deletions

View File

@@ -14,106 +14,86 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "../mtc_timing_value.hpp"
#include "../oc_common.hpp" #include "../oc_common.hpp"
#include "../mtc_timing_value.hpp"
#include "timing_tables.hpp" #include "timing_tables.hpp"
namespace ams::ldr::oc::pcv::mariko namespace ams::ldr::oc::pcv::mariko {
{
s32 FixEinput(s32 val) s32 FixEinput(s32 val) {
{
if (auto patch = FindEinput()) { if (auto patch = FindEinput()) {
return patch->correct; return patch->correct;
} }
return val; return val;
} }
u32 GetRext() u32 GetRext() {
{
if (auto r = FindRext()) { if (auto r = FindRext()) {
return r->correct; return r->correct;
} }
return 0x1A; return 0x1A;
} }
/* TODO: This function is quite uggly, refactor! */ /* TODO: This function is quite uggly, refactor! */
void CalculateMiscTimings() void CalculateMiscTimings() {
{
tW2P = 0x2d; tW2P = 0x2d;
rdv = 0x39 + C.mem_burst_read_latency; rdv = 0x39 + C.mem_burst_read_latency;
einput_duration = 0x1C; einput_duration = 0x1C;
quse_width = 0x8; quse_width = 0x8;
for (u32 i = 0; i < g_misc_table_size; i++) { for (u32 i = 0; i < g_misc_table_size; i++) {
const auto &e = g_misc_table[i]; const auto& e = g_misc_table[i];
if (C.marikoEmcMaxClock >= e.min_freq) { if (C.marikoEmcMaxClock >= e.min_freq) {
rdv += e.rdv_inc; rdv += e.rdv_inc;
if (e.einput) if (e.einput) einput_duration = e.einput;
einput_duration = e.einput; if (e.quse_width) quse_width = e.quse_width;
if (e.quse_width)
quse_width = e.quse_width;
} }
} }
if (WL >= 16) if (WL >= 16) tW2P += 6;
tW2P += 6; if (WL >= 18) tW2P += 8;
if (WL >= 18)
tW2P += 8;
s32 einput_calc = s32 einput_calc = quse_width - (0.010182 * (C.marikoEmcMaxClock / 1000.0) - 0.0879) + 0.5;
quse_width - (0.010182 * (C.marikoEmcMaxClock / 1000.0) - 0.0879) + 0.5;
einput = FixEinput(einput_calc); einput = FixEinput(einput_calc);
rext = GetRext(); rext = GetRext();
} }
void CalculateIbdly() void CalculateIbdly() {
{ /* Ibdly is so inconsistent, I am using the most common value and then checking with a lookup table. */
/* Ibdly is so inconsistent, I am using the most common value and then
* checking with a lookup table. */
ibdly = 0x1000001D + C.mem_burst_read_latency; ibdly = 0x1000001D + C.mem_burst_read_latency;
if (auto patch = FindIbdlyPatch()) { if (auto patch = FindIbdlyPatch()) {
ibdly += patch->adjust; ibdly += patch->adjust;
} }
} }
void CalculateObdly() void CalculateObdly() {
{
obdly = 0x10000002 + C.mem_burst_write_latency; obdly = 0x10000002 + C.mem_burst_write_latency;
if (auto patch = FindObdlyPatch()) { if (auto patch = FindObdlyPatch()) {
obdly += patch->adjust; obdly += patch->adjust;
} }
} }
void CalculateTWTPDEN() void CalculateTWTPDEN() {
{ tWTPDEN = tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6;
tWTPDEN = if (C.marikoEmcMaxClock >= 2'233'000 && C.marikoEmcMaxClock < 2'533'000) tWTPDEN++;
tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6; if (C.marikoEmcMaxClock >= 2'433'000 && C.marikoEmcMaxClock < 2'800'000) tWTPDEN--;
if (C.marikoEmcMaxClock >= 2'233'000 && C.marikoEmcMaxClock < 2'533'000) }
tWTPDEN++;
if (C.marikoEmcMaxClock >= 2'433'000 && C.marikoEmcMaxClock < 2'800'000)
tWTPDEN--;
}
void CalculateTR2W() void CalculateTR2W() {
{ tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE + FLOOR(tRPST) + 9.0);
tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE +
FLOOR(tRPST) + 9.0);
if (auto patch = FindTR2WPatch()) { if (auto patch = FindTR2WPatch()) {
tR2W += patch->adjust; tR2W += patch->adjust;
} }
} }
void CalculateTW2R() void CalculateTW2R() {
{
tW2R = WL + (BL / 2) - 6 + CEIL(tWTR / tCK_avg); tW2R = WL + (BL / 2) - 6 + CEIL(tWTR / tCK_avg);
const FreqTW2R *t = FindTW2R(); const FreqTW2R* t = FindTW2R();
if (!t) if (!t) return;
return;
tW2R += t->adjust; tW2R += t->adjust;
@@ -124,23 +104,19 @@ void CalculateTW2R()
if (t->max_val) { if (t->max_val) {
tW2R = MIN(tW2R, t->max_val); tW2R = MIN(tW2R, t->max_val);
} }
} }
void CalculateQuse() void CalculateQuse() {
{ quse = ROUND(0.002266 * (C.marikoEmcMaxClock / 1000.0) + 31.88) + C.mem_burst_read_latency;
quse = ROUND(0.002266 * (C.marikoEmcMaxClock / 1000.0) + 31.88) +
C.mem_burst_read_latency;
if (auto patch = FindQusePatch()) { if (auto patch = FindQusePatch()) {
quse += patch->adjust; quse += patch->adjust;
} }
} }
void CalculateQrst() void CalculateQrst() {
{
qrst = 0x00070000; qrst = 0x00070000;
u32 qrst_calc = ROUND(22.1 - (C.marikoEmcMaxClock / 1000000.0) * 8.0) + u32 qrst_calc = ROUND(22.1 - (C.marikoEmcMaxClock / 1000000.0) * 8.0) + C.mem_burst_read_latency;
C.mem_burst_read_latency;
u32 qrst_low = MAX(static_cast<u32>(0), qrst_calc); u32 qrst_low = MAX(static_cast<u32>(0), qrst_calc);
if (C.marikoEmcMaxClock >= 2'533'000) { if (C.marikoEmcMaxClock >= 2'533'000) {
@@ -154,55 +130,44 @@ void CalculateQrst()
if (auto patch = FindQrstPatch()) { if (auto patch = FindQrstPatch()) {
qrst = INCREMENT_LOW_BYTES_BY(qrst, patch->adjust); qrst = INCREMENT_LOW_BYTES_BY(qrst, patch->adjust);
} }
} }
void CalculateQsafe() void CalculateQsafe() {
{ qsafe = ROUND((C.marikoEmcMaxClock / 1000.0) / 138.0 + 37.4) + C.mem_burst_read_latency;
qsafe = ROUND((C.marikoEmcMaxClock / 1000.0) / 138.0 + 37.4) +
C.mem_burst_read_latency;
if (auto patch = FindQsafePatch()) { if (auto patch = FindQsafePatch()) {
qsafe += patch->adjust; qsafe += patch->adjust;
} }
} }
void CalculateQpop() void CalculateQpop() {
{ qpop = FLOOR(((C.marikoEmcMaxClock / 1000.0) - 2133 + 167) / 200.0) + 0x2D + C.mem_burst_read_latency;
qpop = FLOOR(((C.marikoEmcMaxClock / 1000.0) - 2133 + 167) / 200.0) + 0x2D +
C.mem_burst_read_latency;
if (C.marikoEmcMaxClock >= 3'133'000) if (C.marikoEmcMaxClock >= 3'133'000) qpop++;
qpop++; }
}
void CalculatePdex2rw() void CalculatePdex2rw() {
{
double freq_mhz = C.marikoEmcMaxClock / 1000.0; double freq_mhz = C.marikoEmcMaxClock / 1000.0;
double pdex_local = (0.011 * freq_mhz) - 1.443; double pdex_local = (0.011 * freq_mhz) - 1.443;
pdex2rw = static_cast<u32>(ROUND(pdex_local)); pdex2rw = static_cast<u32>(ROUND(pdex_local));
if (pdex2rw < 22) if (pdex2rw < 22) pdex2rw = 22;
pdex2rw = 22; if (pdex2rw > 33) pdex2rw = 33;
if (pdex2rw > 33)
pdex2rw = 33;
if (auto patch = FindPdex2rwPatch()) { if (auto patch = FindPdex2rwPatch()) {
pdex2rw += patch->adjust; pdex2rw += patch->adjust;
} }
} }
void CalculateCke2pden() void CalculateCke2pden() {
{ cke2pden = (static_cast<double>((C.marikoEmcMaxClock / 1000.0) * 0.00875) - 0.65);
cke2pden =
(static_cast<double>((C.marikoEmcMaxClock / 1000.0) * 0.00875) - 0.65);
if (auto patch = FindCke2pdenPatch()) { if (auto patch = FindCke2pdenPatch()) {
cke2pden += patch->adjust; cke2pden += patch->adjust;
} }
} }
void CalculateTimings() void CalculateTimings() {
{
CalculateMiscTimings(); CalculateMiscTimings();
CalculateIbdly(); CalculateIbdly();
CalculateObdly(); CalculateObdly();
@@ -215,6 +180,6 @@ void CalculateTimings()
CalculateQpop(); CalculateQpop();
CalculatePdex2rw(); CalculatePdex2rw();
CalculateCke2pden(); CalculateCke2pden();
} }
} // namespace ams::ldr::oc::pcv::mariko }

View File

@@ -17,363 +17,324 @@
#include "../mtc_timing_value.hpp" #include "../mtc_timing_value.hpp"
#include "timing_tables.hpp" #include "timing_tables.hpp"
namespace ams::ldr::oc::pcv::mariko namespace ams::ldr::oc::pcv::mariko {
{
const MiscTimings g_misc_table[] = { const MiscTimings g_misc_table[] = {
{ 1'866'000, 1, 0x20, 0x9, 0 }, {1'866'000, 1, 0x20, 0x9, 0},
{ 2'133'000, 1, 0x24, 0xA, 0 }, {2'133'000, 1, 0x24, 0xA, 0},
{ 2'166'000, 1, 0, 0, 0 }, {2'166'000, 1, 0, 0, 0},
{ 2'233'000, 0, 0x25, 0, 0 }, {2'233'000, 0, 0x25, 0, 0},
{ 2'300'000, 0, 0x26, 0xB, 0 }, {2'300'000, 0, 0x26, 0xB, 0},
{ 2'333'000, 0, 0x27, 0, 0 }, {2'333'000, 0, 0x27, 0, 0},
{ 2'366'000, 1, 0x26, 0xA, 0 }, {2'366'000, 1, 0x26, 0xA, 0},
{ 2'433'000, 0, 0x27, 0, 0 }, {2'433'000, 0, 0x27, 0, 0},
{ 2'466'000, 0, 0x2A, 0, 0 }, {2'466'000, 0, 0x2A, 0, 0},
{ 2'500'000, 0, 0x28, 0xB, 0 }, {2'500'000, 0, 0x28, 0xB, 0},
{ 2'533'000, 0, 0x29, 0, -2 }, {2'533'000, 0, 0x29, 0, -2},
{ 2'566'000, 1, 0, 0, 0 }, {2'566'000, 1, 0, 0, 0},
{ 2'633'000, 0, 0x2A, 0, 0 }, {2'633'000, 0, 0x2A, 0, 0},
{ 2'700'000, 0, 0x2B, 0xC, 0 }, {2'700'000, 0, 0x2B, 0xC, 0},
{ 2'733'000, 0, 0x2C, 0, 0 }, {2'733'000, 0, 0x2C, 0, 0},
{ 2'766'000, 1, 0x2B, 0xB, 0 }, {2'766'000, 1, 0x2B, 0xB, 0},
{ 2'833'000, 0, 0x2C, 0, -2 }, {2'833'000, 0, 0x2C, 0, -2},
{ 2'866'000, 0, 0, 0, -2 }, {2'866'000, 0, 0, 0, -2},
{ 2'900'000, 0, 0, 0, -2 }, {2'900'000, 0, 0, 0, -2},
{ 2'933'000, 0, 0x2E, 0xC, 0 }, {2'933'000, 0, 0x2E, 0xC, 0},
{ 2'966'000, 1, 0, 0, 0 }, {2'966'000, 1, 0, 0, 0},
{ 3'033'000, 0, 0x2F, 0, 0 }, {3'033'000, 0, 0x2F, 0, 0},
{ 3'133'000, 1, 0x31, 0xD, 0 }, {3'133'000, 1, 0x31, 0xD, 0},
}; };
const u32 g_misc_table_size = sizeof(g_misc_table) / sizeof(g_misc_table[0]); const u32 g_misc_table_size = sizeof(g_misc_table) / sizeof(g_misc_table[0]);
const ReplacePatch g_einput_patches[] = { { 2'133'000, 0x16 }, const ReplacePatch g_einput_patches[] = {
{ 2'166'000, 0x17 }, { 2'200'000, 0x17 }, { 2'233'000, 0x16 }, {2'133'000, 0x16}, {2'166'000, 0x17}, {2'200'000, 0x17},
{ 2'266'000, 0x16 }, { 2'300'000, 0x15 }, { 2'333'000, 0x14 }, {2'233'000, 0x16}, {2'266'000, 0x16}, {2'300'000, 0x15},
{ 2'366'000, 0x16 }, { 2'400'000, 0x16 }, { 2'433'000, 0x15 }, {2'333'000, 0x14}, {2'366'000, 0x16}, {2'400'000, 0x16},
{ 2'466'000, 0x15 }, { 2'500'000, 0x14 }, { 2'533'000, 0x13 }, {2'433'000, 0x15}, {2'466'000, 0x15}, {2'500'000, 0x14},
{ 2'566'000, 0x14 }, { 2'600'000, 0x14 }, { 2'633'000, 0x13 }, {2'533'000, 0x13}, {2'566'000, 0x14}, {2'600'000, 0x14},
{ 2'666'000, 0x13 }, { 2'700'000, 0x12 }, { 2'733'000, 0x11 }, {2'633'000, 0x13}, {2'666'000, 0x13}, {2'700'000, 0x12},
{ 2'766'000, 0x13 }, { 2'800'000, 0x13 }, { 2'833'000, 0x12 }, {2'733'000, 0x11}, {2'766'000, 0x13}, {2'800'000, 0x13},
{ 2'866'000, 0x12 }, { 2'900'000, 0x12 }, { 2'933'000, 0x10 }, {2'833'000, 0x12}, {2'866'000, 0x12}, {2'900'000, 0x12},
{ 2'966'000, 0x11 }, { 3'000'000, 0x11 }, { 3'033'000, 0x10 }, {2'933'000, 0x10}, {2'966'000, 0x11}, {3'000'000, 0x11},
{ 3'066'000, 0x10 }, { 3'100'000, 0x10 }, { 3'133'000, 0x0F } }; {3'033'000, 0x10}, {3'066'000, 0x10}, {3'100'000, 0x10},
{3'133'000, 0x0F}
};
const u32 g_einput_patches_size = const u32 g_einput_patches_size = sizeof(g_einput_patches) / sizeof(g_einput_patches[0]);
sizeof(g_einput_patches) / sizeof(g_einput_patches[0]);
const ReplacePatch *FindEinput() const ReplacePatch *FindEinput() {
{
for (u32 i = 0; i < g_einput_patches_size; i++) for (u32 i = 0; i < g_einput_patches_size; i++)
if (g_einput_patches[i].freq == C.marikoEmcMaxClock) if (g_einput_patches[i].freq == C.marikoEmcMaxClock)
return &g_einput_patches[i]; return &g_einput_patches[i];
return nullptr; return nullptr;
} }
const ReplacePatch g_rext_table[] = { const ReplacePatch g_rext_table[] = {
{ 2'133'000, 0x1A }, {2'133'000, 0x1A}, {2'166'000, 0x19}, {2'200'000, 0x19},
{ 2'166'000, 0x19 }, {2'233'000, 0x19}, {2'266'000, 0x1A}, {2'300'000, 0x1B},
{ 2'200'000, 0x19 }, {2'333'000, 0x1B}, {2'366'000, 0x1B}, {2'400'000, 0x1B},
{ 2'233'000, 0x19 }, {2'433'000, 0x1B}, {2'466'000, 0x1B}, {2'500'000, 0x1A},
{ 2'266'000, 0x1A }, {2'533'000, 0x1C}, {2'566'000, 0x1B}, {2'600'000, 0x17},
{ 2'300'000, 0x1B }, {2'633'000, 0x1B}, {2'666'000, 0x1B}, {2'700'000, 0x1C},
{ 2'333'000, 0x1B }, {2'733'000, 0x1C}, {2'766'000, 0x1D}, {2'800'000, 0x1D},
{ 2'366'000, 0x1B }, {2'833'000, 0x1D}, {2'866'000, 0x1D}, {2'900'000, 0x1D},
{ 2'400'000, 0x1B }, {2'933'000, 0x1C}, {2'966'000, 0x1D}, {3'000'000, 0x1D},
{ 2'433'000, 0x1B }, {3'033'000, 0x1D}, {3'066'000, 0x1D}, {3'100'000, 0x1D},
{ 2'466'000, 0x1B }, {3'133'000, 0x1D},
{ 2'500'000, 0x1A }, };
{ 2'533'000, 0x1C },
{ 2'566'000, 0x1B },
{ 2'600'000, 0x17 },
{ 2'633'000, 0x1B },
{ 2'666'000, 0x1B },
{ 2'700'000, 0x1C },
{ 2'733'000, 0x1C },
{ 2'766'000, 0x1D },
{ 2'800'000, 0x1D },
{ 2'833'000, 0x1D },
{ 2'866'000, 0x1D },
{ 2'900'000, 0x1D },
{ 2'933'000, 0x1C },
{ 2'966'000, 0x1D },
{ 3'000'000, 0x1D },
{ 3'033'000, 0x1D },
{ 3'066'000, 0x1D },
{ 3'100'000, 0x1D },
{ 3'133'000, 0x1D },
};
const u32 g_rext_table_size = sizeof(g_rext_table) / sizeof(g_rext_table[0]); const u32 g_rext_table_size = sizeof(g_rext_table) / sizeof(g_rext_table[0]);
const ReplacePatch *FindRext() const ReplacePatch *FindRext() {
{
for (u32 i = 0; i < g_rext_table_size; i++) for (u32 i = 0; i < g_rext_table_size; i++)
if (g_rext_table[i].freq == C.marikoEmcMaxClock) if (g_rext_table[i].freq == C.marikoEmcMaxClock)
return &g_rext_table[i]; return &g_rext_table[i];
return nullptr; return nullptr;
} }
const FreqTW2R g_tw2r_table[] = { const FreqTW2R g_tw2r_table[] = {
{ 2'300'000, 0x2B, 0xFFFFFFFF, 0 }, {2'300'000, 0x2B, 0xFFFFFFFF, 0},
{ 2'400'000, 0, 0x2B, 0 }, {2'400'000, 0, 0x2B, 0},
{ 2'500'000, 0x2C, 0xFFFFFFFF, -1 }, {2'500'000, 0x2C, 0xFFFFFFFF, -1},
{ 2'566'000, 0x2D, 0xFFFFFFFF, -1 }, {2'566'000, 0x2D, 0xFFFFFFFF, -1},
{ 2'700'000, 0x2E, 0xFFFFFFFF, -1 }, {2'700'000, 0x2E, 0xFFFFFFFF, -1},
{ 2'800'000, 0x2F, 0xFFFFFFFF, -1 }, {2'800'000, 0x2F, 0xFFFFFFFF, -1},
{ 2'900'000, 0x30, 0xFFFFFFFF, -1 }, {2'900'000, 0x30, 0xFFFFFFFF, -1},
{ 3'000'000, 0x31, 0xFFFFFFFF, -1 }, {3'000'000, 0x31, 0xFFFFFFFF, -1},
{ 3'100'000, 0x32, 0xFFFFFFFF, -1 }, {3'100'000, 0x32, 0xFFFFFFFF, -1},
{ 0xFFFFFFFF, 0, 0x33, 0 }, {0xFFFFFFFF, 0, 0x33, 0},
}; };
const u32 g_tw2r_table_size = sizeof(g_tw2r_table) / sizeof(g_tw2r_table[0]); const u32 g_tw2r_table_size = sizeof(g_tw2r_table) / sizeof(g_tw2r_table[0]);
const FreqTW2R *FindTW2R() const FreqTW2R *FindTW2R() {
{
for (u32 i = 0; i < g_tw2r_table_size; i++) for (u32 i = 0; i < g_tw2r_table_size; i++)
if (C.marikoEmcMaxClock <= g_tw2r_table[i].max_freq) if (C.marikoEmcMaxClock <= g_tw2r_table[i].max_freq)
return &g_tw2r_table[i]; return &g_tw2r_table[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_ibdly_patches[] = { const AdjustPatch g_ibdly_patches[] = {
{ 2'133'000, -2 }, {2'133'000, -2},
{ 2'166'000, -1 }, {2'166'000, -1},
{ 2'200'000, -1 }, {2'200'000, -1},
{ 2'233'000, -1 }, {2'233'000, -1},
{ 2'266'000, -1 }, {2'266'000, -1},
{ 2'300'000, -2 }, {2'300'000, -2},
{ 2'333'000, -2 }, {2'333'000, -2},
{ 2'500'000, -1 }, {2'500'000, -1},
{ 2'533'000, -2 }, {2'533'000, -2},
{ 2'566'000, -1 }, {2'566'000, -1},
{ 2'633'000, -1 }, {2'633'000, -1},
{ 2'666'000, -1 }, {2'666'000, -1},
{ 2'700'000, -2 }, {2'700'000, -2},
{ 2'733'000, -2 }, {2'733'000, -2},
{ 2'833'000, -9 }, {2'833'000, -9},
{ 2'933'000, -1 }, {2'933'000, -1},
}; };
const u32 g_ibdly_table_size = const u32 g_ibdly_table_size = sizeof(g_ibdly_patches) / sizeof(g_ibdly_patches[0]);
sizeof(g_ibdly_patches) / sizeof(g_ibdly_patches[0]);
const AdjustPatch *FindIbdlyPatch() const AdjustPatch *FindIbdlyPatch() {
{
for (u32 i = 0; i < g_ibdly_table_size; i++) for (u32 i = 0; i < g_ibdly_table_size; i++)
if (g_ibdly_patches[i].freq == C.marikoEmcMaxClock) if (g_ibdly_patches[i].freq == C.marikoEmcMaxClock)
return &g_ibdly_patches[i]; return &g_ibdly_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_obdly_patches[] = { const AdjustPatch g_obdly_patches[] = {
{ 2'533'000, -2 }, {2'533'000, -2},
{ 2'566'000, -2 }, {2'566'000, -2},
{ 2'600'000, -2 }, {2'600'000, -2},
{ 2'633'000, -2 }, {2'633'000, -2},
{ 2'666'000, -2 }, {2'666'000, -2},
{ 2'700'000, -2 }, {2'700'000, -2},
{ 2'733'000, -2 }, {2'733'000, -2},
{ 2'766'000, -2 }, {2'766'000, -2},
{ 2'800'000, -2 }, {2'800'000, -2},
{ 2'833'000, -4 }, {2'833'000, -4},
{ 2'866'000, -2 }, {2'866'000, -2},
{ 2'900'000, -4 }, {2'900'000, -4},
{ 2'933'000, -2 }, {2'933'000, -2},
{ 2'966'000, -2 }, {2'966'000, -2},
{ 3'000'000, -2 }, {3'000'000, -2},
{ 3'033'000, -2 }, {3'033'000, -2},
{ 3'066'000, -2 }, {3'066'000, -2},
{ 3'100'000, -2 }, {3'100'000, -2},
{ 3'133'000, -2 }, {3'133'000, -2},
}; };
const u32 g_obdly_table_size = const u32 g_obdly_table_size = sizeof(g_obdly_patches) / sizeof(g_obdly_patches[0]);
sizeof(g_obdly_patches) / sizeof(g_obdly_patches[0]);
const AdjustPatch *FindObdlyPatch() const AdjustPatch *FindObdlyPatch() {
{
for (u32 i = 0; i < g_obdly_table_size; i++) for (u32 i = 0; i < g_obdly_table_size; i++)
if (g_obdly_patches[i].freq == C.marikoEmcMaxClock) if (g_obdly_patches[i].freq == C.marikoEmcMaxClock)
return &g_obdly_patches[i]; return &g_obdly_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_tr2w_patches[] = { const AdjustPatch g_tr2w_patches[] = {
{ 2'500'000, 1 }, {2'500'000, 1},
{ 2'533'000, 1 }, {2'533'000, 1},
{ 2'566'000, 1 }, {2'566'000, 1},
{ 2'866'000, -1 }, {2'866'000, -1},
{ 3'100'000, 1 }, {3'100'000, 1},
{ 3'133'000, 1 }, {3'133'000, 1},
}; };
const u32 g_tr2w_table_size = const u32 g_tr2w_table_size = sizeof(g_tr2w_patches) / sizeof(g_tr2w_patches[0]);
sizeof(g_tr2w_patches) / sizeof(g_tr2w_patches[0]);
const AdjustPatch *FindTR2WPatch() const AdjustPatch *FindTR2WPatch() {
{
for (u32 i = 0; i < g_tr2w_table_size; i++) for (u32 i = 0; i < g_tr2w_table_size; i++)
if (g_tr2w_patches[i].freq == C.marikoEmcMaxClock) if (g_tr2w_patches[i].freq == C.marikoEmcMaxClock)
return &g_tr2w_patches[i]; return &g_tr2w_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_quse_patches[] = { const AdjustPatch g_quse_patches[] = {
{ 2'133'000, -1 }, {2'133'000, -1},
{ 2'300'000, -1 }, {2'300'000, -1},
{ 2'333'000, -1 }, {2'333'000, -1},
{ 2'366'000, +1 }, {2'366'000, +1},
{ 2'400'000, +1 }, {2'400'000, +1},
{ 2'433'000, +1 }, {2'433'000, +1},
{ 2'466'000, +1 }, {2'466'000, +1},
{ 2'500'000, -1 }, {2'500'000, -1},
{ 2'533'000, -1 }, {2'533'000, -1},
{ 2'700'000, -1 }, {2'700'000, -1},
{ 2'733'000, -1 }, {2'733'000, -1},
{ 2'766'000, +1 }, {2'766'000, +1},
{ 2'800'000, +1 }, {2'800'000, +1},
{ 2'833'000, +1 }, {2'833'000, +1},
{ 2'866'000, +1 }, {2'866'000, +1},
{ 2'900'000, +1 }, {2'900'000, +1},
{ 2'933'000, -1 }, {2'933'000, -1},
}; };
const u32 g_quse_table_size = const u32 g_quse_table_size = sizeof(g_quse_patches) / sizeof(g_quse_patches[0]);
sizeof(g_quse_patches) / sizeof(g_quse_patches[0]);
const AdjustPatch *FindQusePatch() const AdjustPatch *FindQusePatch() {
{
for (u32 i = 0; i < g_quse_table_size; i++) for (u32 i = 0; i < g_quse_table_size; i++)
if (g_quse_patches[i].freq == C.marikoEmcMaxClock) if (g_quse_patches[i].freq == C.marikoEmcMaxClock)
return &g_quse_patches[i]; return &g_quse_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_qrst_patches[] = { const AdjustPatch g_qrst_patches[] = {
{ 2'166'000, 1 }, {2'166'000, 1},
{ 2'200'000, 1 }, {2'200'000, 1},
{ 2'233'000, 1 }, {2'233'000, 1},
{ 2'266'000, 1 }, {2'266'000, 1},
{ 2'366'000, 2 }, {2'366'000, 2},
{ 2'400'000, 2 }, {2'400'000, 2},
{ 2'433'000, 1 }, {2'433'000, 1},
{ 2'466'000, 2 }, {2'466'000, 2},
{ 2'500'000, 1 }, {2'500'000, 1},
{ 2'533'000, -1 }, {2'533'000, -1},
{ 2'700'000, -1 }, {2'700'000, -1},
{ 2'733'000, -1 }, {2'733'000, -1},
{ 2'766'000, 1 }, {2'766'000, 1},
{ 2'800'000, 4 }, {2'800'000, 4},
{ 2'833'000, 1 }, {2'833'000, 1},
{ 2'866'000, 1 }, {2'866'000, 1},
{ 2'900'000, 1 }, {2'900'000, 1},
{ 2'933'000, -1 }, {2'933'000, -1},
{ 2'966'000, 1 }, {2'966'000, 1},
{ 3'100'000, 1 }, {3'100'000, 1},
{ 3'166'000, 1 }, {3'166'000, 1},
{ 3'200'000, 1 }, {3'200'000, 1},
}; };
const u32 g_qrst_table_size = const u32 g_qrst_table_size = sizeof(g_qrst_patches) / sizeof(g_qrst_patches[0]);
sizeof(g_qrst_patches) / sizeof(g_qrst_patches[0]);
const AdjustPatch *FindQrstPatch() const AdjustPatch *FindQrstPatch() {
{
for (u32 i = 0; i < g_qrst_table_size; i++) for (u32 i = 0; i < g_qrst_table_size; i++)
if (g_qrst_patches[i].freq == C.marikoEmcMaxClock) if (g_qrst_patches[i].freq == C.marikoEmcMaxClock)
return &g_qrst_patches[i]; return &g_qrst_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_qsafe_patches[] = { const AdjustPatch g_qsafe_patches[] = {
{ 2'166'000, 1 }, {2'166'000, 1},
{ 2'200'000, 1 }, {2'200'000, 1},
{ 2'500'000, -1 }, {2'500'000, -1},
{ 2'533'000, -1 }, {2'533'000, -1},
{ 2'666'000, -1 }, {2'666'000, -1},
{ 2'700'000, -1 }, {2'700'000, -1},
{ 2'733'000, -1 }, {2'733'000, -1},
{ 2'800'000, -1 }, {2'800'000, -1},
{ 2'833'000, -1 }, {2'833'000, -1},
{ 2'866'000, -1 }, {2'866'000, -1},
{ 2'900'000, -1 }, {2'900'000, -1},
{ 2'933'000, -2 }, {2'933'000, -2},
{ 2'966'000, -1 }, {2'966'000, -1},
{ 3'000'000, -1 }, {3'000'000, -1},
{ 3'033'000, -1 }, {3'033'000, -1},
{ 3'066'000, -2 }, {3'066'000, -2},
{ 3'100'000, -2 }, {3'100'000, -2},
{ 3'166'000, -1 }, {3'166'000, -1},
{ 3'200'000, -1 }, {3'200'000, -1},
}; };
const u32 g_qsafe_table_size = const u32 g_qsafe_table_size = sizeof(g_qsafe_patches) / sizeof(g_qsafe_patches[0]);
sizeof(g_qsafe_patches) / sizeof(g_qsafe_patches[0]);
const AdjustPatch *FindQsafePatch() const AdjustPatch *FindQsafePatch() {
{
for (u32 i = 0; i < g_qsafe_table_size; i++) for (u32 i = 0; i < g_qsafe_table_size; i++)
if (g_qsafe_patches[i].freq == C.marikoEmcMaxClock) if (g_qsafe_patches[i].freq == C.marikoEmcMaxClock)
return &g_qsafe_patches[i]; return &g_qsafe_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_pdex2rw_patches[] = { const AdjustPatch g_pdex2rw_patches[] = {
{ 2'166'000, 1 }, {2'166'000, 1},
{ 2'300'000, 1 }, {2'300'000, 1},
{ 2'333'000, 1 }, {2'333'000, 1},
{ 2'433'000, 1 }, {2'433'000, 1},
{ 2'533'000, 0 }, {2'533'000, 0},
{ 2'633'000, -1 }, {2'633'000, -1},
{ 2'666'000, -1 }, {2'666'000, -1},
{ 2'733'000, -1 }, {2'733'000, -1},
{ 2'766'000, -1 }, {2'766'000, -1},
{ 2'800'000, -1 }, {2'800'000, -1},
{ 2'833'000, -1 }, {2'833'000, -1},
{ 2'933'000, -1 }, {2'933'000, -1},
{ 3'066'000, 1 }, {3'066'000, 1},
}; };
const u32 g_pdex2rw_table_size = const u32 g_pdex2rw_table_size = sizeof(g_pdex2rw_patches) / sizeof(g_pdex2rw_patches[0]);
sizeof(g_pdex2rw_patches) / sizeof(g_pdex2rw_patches[0]);
const AdjustPatch *FindPdex2rwPatch() const AdjustPatch *FindPdex2rwPatch() {
{
for (u32 i = 0; i < g_pdex2rw_table_size; i++) for (u32 i = 0; i < g_pdex2rw_table_size; i++)
if (g_pdex2rw_patches[i].freq == C.marikoEmcMaxClock) if (g_pdex2rw_patches[i].freq == C.marikoEmcMaxClock)
return &g_pdex2rw_patches[i]; return &g_pdex2rw_patches[i];
return nullptr; return nullptr;
} }
const AdjustPatch g_cke2pden_patches[] = { const AdjustPatch g_cke2pden_patches[] = {
{ 2'133'000, 1 }, {2'133'000, 1},
{ 2'166'000, 1 }, {2'166'000, 1},
{ 2'266'000, 1 }, {2'266'000, 1},
{ 2'300'000, 1 }, {2'300'000, 1},
{ 2'366'000, 1 }, {2'366'000, 1},
{ 2'400'000, 1 }, {2'400'000, 1},
{ 2'500'000, 1 }, {2'500'000, 1},
{ 2'633'000, 1 }, {2'633'000, 1},
{ 2'733'000, 1 }, {2'733'000, 1},
{ 2'833'000, 1 }, {2'833'000, 1},
{ 2'866'000, 1 }, {2'866'000, 1},
{ 2'966'000, 1 }, {2'966'000, 1},
{ 3'066'000, 1 }, {3'066'000, 1},
{ 3'100'000, 1 }, {3'100'000, 1},
}; };
const u32 g_cke2pden_table_size = const u32 g_cke2pden_table_size = sizeof(g_cke2pden_patches) / sizeof(g_cke2pden_patches[0]);
sizeof(g_cke2pden_patches) / sizeof(g_cke2pden_patches[0]);
const AdjustPatch *FindCke2pdenPatch() const AdjustPatch *FindCke2pdenPatch() {
{
for (u32 i = 0; i < g_cke2pden_table_size; i++) for (u32 i = 0; i < g_cke2pden_table_size; i++)
if (g_cke2pden_patches[i].freq == C.marikoEmcMaxClock) if (g_cke2pden_patches[i].freq == C.marikoEmcMaxClock)
return &g_cke2pden_patches[i]; return &g_cke2pden_patches[i];
return nullptr; return nullptr;
} }
} // namespace ams::ldr::oc::pcv::mariko }

View File

@@ -17,79 +17,78 @@
#pragma once #pragma once
#include "../mtc_timing_value.hpp" #include "../mtc_timing_value.hpp"
namespace ams::ldr::oc::pcv::mariko namespace ams::ldr::oc::pcv::mariko {
{
struct ReplacePatch { struct ReplacePatch {
u32 freq; u32 freq;
u32 correct; u32 correct;
}; };
extern const ReplacePatch g_einput_patches[]; extern const ReplacePatch g_einput_patches[];
extern const u32 g_einput_patches_size; extern const u32 g_einput_patches_size;
const ReplacePatch *FindEinput(); const ReplacePatch *FindEinput();
extern const ReplacePatch g_rext_table[]; extern const ReplacePatch g_rext_table[];
extern const u32 g_rext_table_size; extern const u32 g_rext_table_size;
const ReplacePatch *FindRext(); const ReplacePatch *FindRext();
struct AdjustPatch { struct AdjustPatch {
u32 freq; u32 freq;
s32 adjust; s32 adjust;
}; };
extern const AdjustPatch g_ibdly_patches[]; extern const AdjustPatch g_ibdly_patches[];
extern const u32 g_ibdly_table_size; extern const u32 g_ibdly_table_size;
const AdjustPatch *FindIbdlyPatch(); const AdjustPatch *FindIbdlyPatch();
extern const AdjustPatch g_obdly_patches[]; extern const AdjustPatch g_obdly_patches[];
extern const u32 g_obdly_table_size; extern const u32 g_obdly_table_size;
const AdjustPatch *FindObdlyPatch(); const AdjustPatch *FindObdlyPatch();
extern const AdjustPatch g_tr2w_patches[]; extern const AdjustPatch g_tr2w_patches[];
extern const u32 g_tr2w_table_size; extern const u32 g_tr2w_table_size;
const AdjustPatch *FindTR2WPatch(); const AdjustPatch *FindTR2WPatch();
extern const AdjustPatch g_quse_patches[]; extern const AdjustPatch g_quse_patches[];
extern const u32 g_quse_table_size; extern const u32 g_quse_table_size;
const AdjustPatch *FindQusePatch(); const AdjustPatch *FindQusePatch();
extern const AdjustPatch g_qrst_patches[]; extern const AdjustPatch g_qrst_patches[];
extern const u32 q_qrst_table_size; extern const u32 q_qrst_table_size;
const AdjustPatch *FindQrstPatch(); const AdjustPatch *FindQrstPatch();
extern const AdjustPatch g_qsafe_patches[]; extern const AdjustPatch g_qsafe_patches[];
extern const u32 g_qsafe_table_size; extern const u32 g_qsafe_table_size;
const AdjustPatch *FindQsafePatch(); const AdjustPatch *FindQsafePatch();
extern const AdjustPatch g_pdex2rw_patches[]; extern const AdjustPatch g_pdex2rw_patches[];
extern const u32 g_pdex2rw_table_size; extern const u32 g_pdex2rw_table_size;
const AdjustPatch *FindPdex2rwPatch(); const AdjustPatch *FindPdex2rwPatch();
extern const AdjustPatch g_cke2pden_patches[]; extern const AdjustPatch g_cke2pden_patches[];
extern const u32 g_cke2pden_table_size; extern const u32 g_cke2pden_table_size;
const AdjustPatch *FindCke2pdenPatch(); const AdjustPatch *FindCke2pdenPatch();
struct MiscTimings { struct MiscTimings {
u32 min_freq; u32 min_freq;
u32 rdv_inc; u32 rdv_inc;
u32 einput; u32 einput;
u32 quse_width; u32 quse_width;
s32 obdly_delta; s32 obdly_delta;
}; };
extern const MiscTimings g_misc_table[]; extern const MiscTimings g_misc_table[];
extern const u32 g_misc_table_size; extern const u32 g_misc_table_size;
struct FreqTW2R { struct FreqTW2R {
u32 max_freq; u32 max_freq;
u32 min_val; u32 min_val;
u32 max_val; u32 max_val;
s32 adjust; s32 adjust;
}; };
extern const FreqTW2R g_tw2r_table[]; extern const FreqTW2R g_tw2r_table[];
extern const u32 g_tw2r_table_size; extern const u32 g_tw2r_table_size;
const FreqTW2R *FindTW2R(); const FreqTW2R *FindTW2R();
} // namespace ams::ldr::oc::pcv::mariko }