From dcf8e764416cc4db005ab03b1eef79a68a47cae4 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Thu, 27 Nov 2025 12:28:19 +0200 Subject: [PATCH] loader/hekate/nyx: utilize the new rsvd cfg --- bootloader/main.c | 23 ++++++++++++++--------- loader/loader.c | 16 +++++++++++----- nyx/nyx_gui/nyx.c | 9 ++++++--- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/bootloader/main.c b/bootloader/main.c index a69afb89..0d1aa60c 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -38,10 +38,11 @@ hekate_config h_cfg; boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg; const volatile ipl_ver_meta_t __attribute__((section ("._ipl_version"))) ipl_ver = { - .magic = BL_MAGIC, - .version = (BL_VER_MJ + '0') | ((BL_VER_MN + '0') << 8) | ((BL_VER_HF + '0') << 16) | ((BL_VER_RL) << 24), - .rsvd0 = 0, - .rsvd1 = 0 + .magic = BL_MAGIC, + .version = (BL_VER_MJ + '0') | ((BL_VER_MN + '0') << 8) | ((BL_VER_HF + '0') << 16) | ((BL_VER_RL) << 24), + .rcfg.rsvd_flags = 0, + .rcfg.bclk_t210 = BPMP_CLK_LOWER_BOOST, + .rcfg.bclk_t210b01 = BPMP_CLK_DEFAULT_BOOST }; volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR; @@ -656,11 +657,15 @@ static void _nyx_load_run() // Set hekate version used to boot Nyx. nyx_str->version = ipl_ver.version - 0x303030; // Convert ASCII to numbers. - // Set SD card initialization info. - nyx_str->info.magic = NYX_NEW_INFO; - nyx_str->info.sd_init = sd_get_mode(); + // Set [new] info validation magic. + nyx_str->info.magic = NYX_NEW_INFO; + nyx_str->info_ex.magic = NYX_NEW_INFO; - // Set SD card error info. + // Set [new] reserved flags. + nyx_str->info_ex.rsvd_flags = ipl_ver.rcfg.rsvd_flags; + + // Set [new] SD card initialization and error info. + nyx_str->info.sd_init = sd_get_mode(); u16 *sd_errors = sd_get_error_count(); for (u32 i = 0; i < 3; i++) nyx_str->info.sd_errors[i] = sd_errors[i]; @@ -1491,7 +1496,7 @@ void ipl_main() display_init(); // Overclock BPMP. - bpmp_clk_rate_set(h_cfg.t210b01 ? BPMP_CLK_DEFAULT_BOOST : BPMP_CLK_LOWER_BOOST); + bpmp_clk_rate_set(h_cfg.t210b01 ? ipl_ver.rcfg.bclk_t210b01 : ipl_ver.rcfg.bclk_t210); // Mount SD Card. h_cfg.errors |= !sd_mount() ? ERR_SD_BOOT_EN : 0; diff --git a/loader/loader.c b/loader/loader.c index 03bc63e8..303bc67a 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -22,19 +22,22 @@ #include #include +#include #include #include // 0x4003D000: Safe for panic preserving, 0x40038000: Safe for debugging needs. -#define IPL_RELOC_TOP 0x40038000 +#define IPL_RELOC_TOP 0x40038000 #define IPL_PATCHED_RELOC_SZ 0x94 +#define IPL_VERSION_RCFG_OFF 0x120 boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg; const volatile ipl_ver_meta_t __attribute__((section ("._ipl_version"))) ipl_ver = { - .magic = BL_MAGIC, - .version = (BL_VER_MJ + '0') | ((BL_VER_MN + '0') << 8) | ((BL_VER_HF + '0') << 16) | ((BL_VER_RL) << 24), - .rsvd0 = 0, - .rsvd1 = 0 + .magic = BL_MAGIC, + .version = (BL_VER_MJ + '0') | ((BL_VER_MN + '0') << 8) | ((BL_VER_HF + '0') << 16) | ((BL_VER_RL) << 24), + .rcfg.rsvd_flags = 0, + .rcfg.bclk_t210 = BPMP_CLK_LOWER_BOOST, + .rcfg.bclk_t210b01 = BPMP_CLK_DEFAULT_BOOST }; const char __attribute__((section ("._octopus"))) octopus[] = @@ -104,6 +107,9 @@ void loader_main() // Copy over boot configuration storage. memcpy((u8 *)(IPL_LOAD_ADDR + IPL_PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t)); + // Copy new reserved configuration. + memcpy((u8 *)(IPL_LOAD_ADDR + IPL_VERSION_RCFG_OFF), (rsvd_cfg_t *)&ipl_ver.rcfg, sizeof(rsvd_cfg_t)); + // Chainload into uncompressed payload. void (*ipl_ptr)() = (void *)IPL_LOAD_ADDR; (*ipl_ptr)(); diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index b1434358..94731074 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -36,8 +36,6 @@ hekate_config h_cfg; const volatile ipl_ver_meta_t __attribute__((section ("._ipl_version"))) ipl_ver = { .magic = NYX_MAGIC, .version = (NYX_VER_MJ + '0') | ((NYX_VER_MN + '0') << 8) | ((NYX_VER_HF + '0') << 16) | ((NYX_VER_RL) << 24), - .rsvd0 = 0, - .rsvd1 = 0 }; volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR; @@ -441,8 +439,13 @@ void nyx_init_load_res() nyx_str->info.sd_errors[i] = 0; } + // Reset new extended info if magic not correct. + if (nyx_str->info_ex.magic != NYX_NEW_INFO) + nyx_str->info_ex.rsvd_flags = 0; + // Clear info magic. - nyx_str->info.magic = 0; + nyx_str->info.magic = 0; + nyx_str->info_ex.magic = 0; // Set display id from previous initialization. display_set_decoded_panel_id(nyx_str->info.panel_id);