1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-10 06:01:52 +00:00

fusee_cpp: move mtc code/used-tables to nv memory (needed for mariko downtrain fix)

This commit is contained in:
Michael Scire 2021-09-01 18:25:36 -07:00 committed by SciresM
parent 40e2d4bbe6
commit 598edc0a46
4 changed files with 25 additions and 24 deletions

View file

@ -23,21 +23,17 @@ SECTIONS {
BYTE(0x00); BYTE(0x00);
} }
.ovl_mtc_erista { .ovl_mtc_erista {
KEEP(*(.text._ZN3ams6nxboot22DoMemoryTrainingEristaEi)) fusee_mtc_erista.o(SORT(.rodata*));
fusee_mtc_erista.o(.text*); fusee_mtc_erista.o(SORT(.data*));
fusee_mtc_erista.o(.rodata*); fusee_mtc_erista.o(SORT(.bss*));
fusee_mtc_erista.o(.data*);
fusee_mtc_erista.o(.bss*);
FILL(0x00000000) FILL(0x00000000)
. = ORIGIN(ovl) + LENGTH(ovl) - 1; . = ORIGIN(ovl) + LENGTH(ovl) - 1;
BYTE(0x00); BYTE(0x00);
} }
.ovl_mtc_mariko { .ovl_mtc_mariko {
KEEP(*(.text._ZN3ams6nxboot22DoMemoryTrainingMarikoEi)) fusee_mtc_mariko.o(SORT(.rodata*));
fusee_mtc_mariko.o(.text*); fusee_mtc_mariko.o(SORT(.data*));
fusee_mtc_mariko.o(.rodata*); fusee_mtc_mariko.o(SORT(.bss*));
fusee_mtc_mariko.o(.data*);
fusee_mtc_mariko.o(.bss*);
FILL(0x00000000) FILL(0x00000000)
. = ORIGIN(ovl) + LENGTH(ovl) - 1; . = ORIGIN(ovl) + LENGTH(ovl) - 1;
BYTE(0x00); BYTE(0x00);

View file

@ -17,11 +17,13 @@
namespace ams::nxboot { namespace ams::nxboot {
void DoMemoryTrainingErista(int index); void DoMemoryTrainingErista(int index, void *mtc_tables_buffer);
void DoMemoryTrainingMariko(int index); void DoMemoryTrainingMariko(int index, void *mtc_tables_buffer);
namespace { namespace {
alignas(4) constinit u8 g_mtc_tables_buffer[0x26C0];
constexpr const u8 MemoryTrainingTableIndex_Invalid = std::numeric_limits<u8>::max(); constexpr const u8 MemoryTrainingTableIndex_Invalid = std::numeric_limits<u8>::max();
constexpr const u8 MemoryTrainingTableIndices[] = { constexpr const u8 MemoryTrainingTableIndices[] = {
@ -70,9 +72,9 @@ namespace ams::nxboot {
const auto index = GetMemoryTrainingTableIndex(); const auto index = GetMemoryTrainingTableIndex();
if (fuse::GetSocType() == fuse::SocType_Erista) { if (fuse::GetSocType() == fuse::SocType_Erista) {
DoMemoryTrainingErista(index); DoMemoryTrainingErista(index, g_mtc_tables_buffer);
} else { } else {
DoMemoryTrainingMariko(index); DoMemoryTrainingMariko(index, g_mtc_tables_buffer);
} }
} }

View file

@ -72,15 +72,18 @@ namespace ams::nxboot {
using EmcDvfsTimingTable = erista::EmcDvfsTimingTable; using EmcDvfsTimingTable = erista::EmcDvfsTimingTable;
EmcDvfsTimingTable *GetEmcDvfsTimingTables(int index) { EmcDvfsTimingTable *GetEmcDvfsTimingTables(int index, void *mtc_tables_buffer) {
switch (index) { switch (index) {
case 0: case 0:
case 3: case 3:
return reinterpret_cast<EmcDvfsTimingTable *>(T210SdevEmcDvfsTableS4gb01); std::memcpy(mtc_tables_buffer, T210SdevEmcDvfsTableS4gb01, sizeof(T210SdevEmcDvfsTableS4gb01));
return reinterpret_cast<EmcDvfsTimingTable *>(mtc_tables_buffer);
case 1: case 1:
return reinterpret_cast<EmcDvfsTimingTable *>(T210SdevEmcDvfsTableS6gb01); std::memcpy(mtc_tables_buffer, T210SdevEmcDvfsTableS6gb01, sizeof(T210SdevEmcDvfsTableS6gb01));
return reinterpret_cast<EmcDvfsTimingTable *>(mtc_tables_buffer);
case 2: case 2:
return reinterpret_cast<EmcDvfsTimingTable *>(T210SdevEmcDvfsTableH4gb01); std::memcpy(mtc_tables_buffer, T210SdevEmcDvfsTableH4gb01, sizeof(T210SdevEmcDvfsTableH4gb01));
return reinterpret_cast<EmcDvfsTimingTable *>(mtc_tables_buffer);
default: default:
ShowFatalError("Unknown EmcDvfsTimingTableIndex: %d\n", index); ShowFatalError("Unknown EmcDvfsTimingTableIndex: %d\n", index);
} }
@ -2829,9 +2832,9 @@ namespace ams::nxboot {
} }
void DoMemoryTrainingErista(int index) { void DoMemoryTrainingErista(int index, void *mtc_tables_buffer) {
/* Get timing tables. */ /* Get timing tables. */
auto *timing_tables = GetEmcDvfsTimingTables(index); auto *timing_tables = GetEmcDvfsTimingTables(index, mtc_tables_buffer);
auto *src_timing = timing_tables + 0; auto *src_timing = timing_tables + 0;
auto *dst_timing = timing_tables + 1; auto *dst_timing = timing_tables + 1;

View file

@ -27,7 +27,7 @@ namespace ams::nxboot {
using EmcDvfsTimingTable = mariko::EmcDvfsTimingTable; using EmcDvfsTimingTable = mariko::EmcDvfsTimingTable;
EmcDvfsTimingTable *GetEmcDvfsTimingTables(int index) { EmcDvfsTimingTable *GetEmcDvfsTimingTables(int index, void *mtc_tables_buffer) {
/* Get the compressed table. */ /* Get the compressed table. */
u8 *cmp_table; u8 *cmp_table;
size_t cmp_table_size; size_t cmp_table_size;
@ -55,7 +55,7 @@ namespace ams::nxboot {
} }
/* Uncompress the table. */ /* Uncompress the table. */
EmcDvfsTimingTable *out_tables = reinterpret_cast<EmcDvfsTimingTable *>(0x40040000 - 2 * sizeof(EmcDvfsTimingTable)); EmcDvfsTimingTable *out_tables = reinterpret_cast<EmcDvfsTimingTable *>(mtc_tables_buffer);
Uncompress(out_tables, 2 * sizeof(EmcDvfsTimingTable), cmp_table, cmp_table_size); Uncompress(out_tables, 2 * sizeof(EmcDvfsTimingTable), cmp_table, cmp_table_size);
return out_tables; return out_tables;
@ -63,9 +63,9 @@ namespace ams::nxboot {
} }
void DoMemoryTrainingMariko(int index) { void DoMemoryTrainingMariko(int index, void *mtc_tables_buffer) {
/* Get timing tables. */ /* Get timing tables. */
auto *timing_tables = GetEmcDvfsTimingTables(index); auto *timing_tables = GetEmcDvfsTimingTables(index, mtc_tables_buffer);
auto *src_timing_tables = timing_tables + 0; auto *src_timing_tables = timing_tables + 0;
auto *dst_timing_tables = timing_tables + 1; auto *dst_timing_tables = timing_tables + 1;