mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-13 22:54:24 -04:00
fusee_cpp: implement tsec_keygen firmware execution
This commit is contained in:
parent
80999988d4
commit
51cf28339b
11 changed files with 270 additions and 53 deletions
|
@ -14,13 +14,40 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <exosphere.hpp>
|
||||
#include "fusee_secondary_archive.hpp"
|
||||
#include "fusee_setup_horizon.hpp"
|
||||
#include "fusee_fatal.hpp"
|
||||
|
||||
namespace ams::nxboot {
|
||||
|
||||
namespace {
|
||||
|
||||
void DeriveAllKeys(const fuse::SocType soc_type) {
|
||||
/* If on erista, run the TSEC keygen firmware. */
|
||||
if (soc_type == fuse::SocType_Erista) {
|
||||
clkrst::SetBpmpClockRate(clkrst::BpmpClockRate_408MHz);
|
||||
|
||||
if (!tsec::RunTsecFirmware(GetSecondaryArchive().tsec_keygen, sizeof(GetSecondaryArchive().tsec_keygen))) {
|
||||
ShowFatalError("Failed to run tsec_keygen firmware!\n");
|
||||
}
|
||||
|
||||
clkrst::SetBpmpClockRate(clkrst::BpmpClockRate_576MHz);
|
||||
}
|
||||
|
||||
ShowFatalError("DeriveAllKeys not fully implemented\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SetupAndStartHorizon() {
|
||||
/* TODO */
|
||||
/* Get soc/hardware type. */
|
||||
const auto soc_type = fuse::GetSocType();
|
||||
const auto hw_type = fuse::GetHardwareType();
|
||||
|
||||
/* Derive all keys. */
|
||||
DeriveAllKeys(soc_type);
|
||||
|
||||
AMS_UNUSED(hw_type);
|
||||
ShowFatalError("SetupAndStartHorizon not fully implemented\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
namespace ams::nxboot {
|
||||
|
||||
void DoMemoryTrainingErista();
|
||||
void DoMemoryTrainingMariko();
|
||||
void DoMemoryTrainingErista(int index);
|
||||
void DoMemoryTrainingMariko(int index);
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -56,21 +56,23 @@ namespace ams::nxboot {
|
|||
/* DramId_MarikoAulaSamsung1y8gbX */ 0x0D,
|
||||
};
|
||||
|
||||
int GetMemoryTrainingTableIndex() {
|
||||
if (const auto dram_id = fuse::GetDramId(); dram_id < util::size(MemoryTrainingTableIndices) && MemoryTrainingTableIndices[dram_id] != MemoryTrainingTableIndex_Invalid) {
|
||||
return static_cast<int>(MemoryTrainingTableIndices[dram_id]);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DoMemoryTraining() {
|
||||
if (fuse::GetSocType() == fuse::SocType_Erista) {
|
||||
DoMemoryTrainingErista();
|
||||
} else {
|
||||
DoMemoryTrainingMariko();
|
||||
}
|
||||
}
|
||||
const auto index = GetMemoryTrainingTableIndex();
|
||||
|
||||
int GetMemoryTrainingTableIndex() {
|
||||
if (const auto dram_id = fuse::GetDramId(); dram_id < util::size(MemoryTrainingTableIndices) && MemoryTrainingTableIndices[dram_id] != MemoryTrainingTableIndex_Invalid) {
|
||||
return static_cast<int>(MemoryTrainingTableIndices[dram_id]);
|
||||
if (fuse::GetSocType() == fuse::SocType_Erista) {
|
||||
DoMemoryTrainingErista(index);
|
||||
} else {
|
||||
return -1;
|
||||
DoMemoryTrainingMariko(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,4 @@ namespace ams::nxboot {
|
|||
|
||||
void DoMemoryTraining();
|
||||
|
||||
int GetMemoryTrainingTableIndex();
|
||||
|
||||
}
|
||||
|
|
|
@ -72,8 +72,7 @@ namespace ams::nxboot {
|
|||
|
||||
using EmcDvfsTimingTable = erista::EmcDvfsTimingTable;
|
||||
|
||||
EmcDvfsTimingTable *GetEmcDvfsTimingTables() {
|
||||
const auto index = GetMemoryTrainingTableIndex();
|
||||
EmcDvfsTimingTable *GetEmcDvfsTimingTables(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
case 3:
|
||||
|
@ -2830,11 +2829,11 @@ namespace ams::nxboot {
|
|||
|
||||
}
|
||||
|
||||
void DoMemoryTrainingErista() {
|
||||
void DoMemoryTrainingErista(int index) {
|
||||
/* Get timing tables. */
|
||||
auto *timing_tables = GetEmcDvfsTimingTables();
|
||||
auto *src_timing = timing_tables + 0;
|
||||
auto *dst_timing = timing_tables + 1;
|
||||
auto *timing_tables = GetEmcDvfsTimingTables(index);
|
||||
auto *src_timing = timing_tables + 0;
|
||||
auto *dst_timing = timing_tables + 1;
|
||||
|
||||
/* Check timing tables. */
|
||||
if (src_timing->rate_khz != 204000 || dst_timing->rate_khz != 1600000) {
|
||||
|
|
|
@ -27,9 +27,7 @@ namespace ams::nxboot {
|
|||
|
||||
using EmcDvfsTimingTable = mariko::EmcDvfsTimingTable;
|
||||
|
||||
EmcDvfsTimingTable *GetEmcDvfsTimingTables() {
|
||||
const auto index = GetMemoryTrainingTableIndex();
|
||||
|
||||
EmcDvfsTimingTable *GetEmcDvfsTimingTables(int index) {
|
||||
/* Get the compressed table. */
|
||||
u8 *cmp_table;
|
||||
size_t cmp_table_size;
|
||||
|
@ -65,9 +63,9 @@ namespace ams::nxboot {
|
|||
|
||||
}
|
||||
|
||||
void DoMemoryTrainingMariko() {
|
||||
void DoMemoryTrainingMariko(int index) {
|
||||
/* Get timing tables. */
|
||||
auto *timing_tables = GetEmcDvfsTimingTables();
|
||||
auto *timing_tables = GetEmcDvfsTimingTables(index);
|
||||
auto *src_timing_tables = timing_tables + 0;
|
||||
auto *dst_timing_tables = timing_tables + 1;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue