From 52874f9113425e958463b04f7153716bb01745df Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 21 Mar 2020 22:10:06 +0200 Subject: [PATCH] minerva: More protections --- bootloader/mem/minerva.c | 5 ++++- bootloader/utils/util.h | 2 +- nyx/nyx_gui/mem/minerva.c | 4 +++- nyx/nyx_gui/utils/util.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bootloader/mem/minerva.c b/bootloader/mem/minerva.c index d2c966e..84efee0 100644 --- a/bootloader/mem/minerva.c +++ b/bootloader/mem/minerva.c @@ -34,18 +34,21 @@ u32 minerva_init() minerva_cfg = NULL; mtc_config_t *mtc_cfg = (mtc_config_t *)&nyx_str->mtc_cfg; + memset(mtc_cfg, 0, sizeof(mtc_config_t)); // Set table to nyx storage. mtc_cfg->mtc_table = (emc_table_t *)&nyx_str->mtc_table; mtc_cfg->sdram_id = (fuse_read_odm(4) >> 3) & 0x1F; mtc_cfg->init_done = MTC_NEW_MAGIC; // Initialize mtc table. - + u32 ep_addr = ianos_loader(false, "bootloader/sys/libsys_minerva.bso", DRAM_LIB, (void *)mtc_cfg); // Ensure that Minerva is new. if (mtc_cfg->init_done == MTC_INIT_MAGIC) minerva_cfg = (void *)ep_addr; + else + mtc_cfg->init_done = 0; if (!minerva_cfg) return 1; diff --git a/bootloader/utils/util.h b/bootloader/utils/util.h index cdddc85..c50b1c3 100644 --- a/bootloader/utils/util.h +++ b/bootloader/utils/util.h @@ -57,7 +57,7 @@ typedef struct _nyx_storage_t u8 rsvd[0x800000 - sizeof(nyx_info_t)]; nyx_info_t info; mtc_config_t mtc_cfg; - emc_table_t mtc_table; + emc_table_t mtc_table[10]; } nyx_storage_t; u32 get_tmr_us(); diff --git a/nyx/nyx_gui/mem/minerva.c b/nyx/nyx_gui/mem/minerva.c index 143c89e..a797435 100644 --- a/nyx/nyx_gui/mem/minerva.c +++ b/nyx/nyx_gui/mem/minerva.c @@ -36,7 +36,7 @@ u32 minerva_init() mtc_config_t *mtc_cfg = (mtc_config_t *)&nyx_str->mtc_cfg; // Set table to nyx storage. - mtc_cfg->mtc_table = (emc_table_t *)&nyx_str->mtc_table; + mtc_cfg->mtc_table = (emc_table_t *)nyx_str->mtc_table; // Check if Minerva is already initialized. if (mtc_cfg->init_done == MTC_INIT_MAGIC) @@ -60,6 +60,8 @@ u32 minerva_init() // Ensure that Minerva is new. if (mtc_tmp.init_done == MTC_INIT_MAGIC) minerva_cfg = (void *)ep_addr; + else + mtc_cfg->init_done = 0; // Copy Minerva context to Nyx storage. if (minerva_cfg) diff --git a/nyx/nyx_gui/utils/util.h b/nyx/nyx_gui/utils/util.h index cdddc85..c50b1c3 100644 --- a/nyx/nyx_gui/utils/util.h +++ b/nyx/nyx_gui/utils/util.h @@ -57,7 +57,7 @@ typedef struct _nyx_storage_t u8 rsvd[0x800000 - sizeof(nyx_info_t)]; nyx_info_t info; mtc_config_t mtc_cfg; - emc_table_t mtc_table; + emc_table_t mtc_table[10]; } nyx_storage_t; u32 get_tmr_us();