From 063abb3e2348392c4cbcdb93aa9871565702fcdf Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 28 Aug 2021 17:55:03 +0300 Subject: [PATCH] hos: Fix compilation --- bootloader/hos/hos.c | 14 +++++---- bootloader/hos/hos.h | 2 +- bootloader/hos/secmon_exo.c | 62 +++++++++++++++++-------------------- bootloader/hos/secmon_exo.h | 4 +-- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 73880d8..8329f1b 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -691,7 +691,7 @@ static void _free_launch_components(launch_ctxt_t *ctxt) free(ctxt->kip1_patches); } -static bool _get_fs_exfat_compatible(link_t *info, bool *fs_is_510) +static bool _get_fs_exfat_compatible(link_t *info, u32 *hos_revision) { u32 fs_ids_cnt; u32 sha_buf[32 / sizeof(u32)]; @@ -711,9 +711,11 @@ static bool _get_fs_exfat_compatible(link_t *info, bool *fs_is_510) { if (!memcmp(sha_buf, kip_ids[fs_idx].hash, 8)) { - // Check if it's 5.1.0. - if ((fs_idx & ~1) == 16) - *fs_is_510 = true; + // HOS Api special handling. + if ((fs_idx & ~1) == 16) // Check if it's 5.1.0. + *hos_revision = 1; + else if ((fs_idx & ~1) == 34) // Check if it's 10.2.0. + *hos_revision = 2; // Check if FAT32-only. if (!(fs_idx & 1)) @@ -827,7 +829,7 @@ int hos_launch(ini_sec_t *cfg) config_kip1patch(&ctxt, "nogc"); } - gfx_puts("Loaded config, pkg1 and keyblob\n"); + gfx_printf("Loaded config and pkg1\n%s mode\n", ctxt.stock ? "Stock" : "CFW"); // Check if secmon is exosphere. if (ctxt.secmon) @@ -1005,7 +1007,7 @@ int hos_launch(ini_sec_t *cfg) // Check if FS is compatible with exFAT and if 5.1.0. if (!ctxt.stock && (sd_fs.fs_type == FS_EXFAT || kb == KB_FIRMWARE_VERSION_500)) { - bool exfat_compat = _get_fs_exfat_compatible(&kip1_info, &ctxt.exo_ctx.fs_is_510); + bool exfat_compat = _get_fs_exfat_compatible(&kip1_info, &ctxt.exo_ctx.hos_revision); if (sd_fs.fs_type == FS_EXFAT && !exfat_compat) { diff --git a/bootloader/hos/hos.h b/bootloader/hos/hos.h index 7658bc5..a7f9dbb 100644 --- a/bootloader/hos/hos.h +++ b/bootloader/hos/hos.h @@ -49,7 +49,7 @@ typedef struct _exo_ctxt_t { - bool fs_is_510; + u32 hos_revision; bool no_user_exceptions; bool user_pmu; bool *usb3_force; diff --git a/bootloader/hos/secmon_exo.c b/bootloader/hos/secmon_exo.c index c49b8ed..f4aa9f9 100644 --- a/bootloader/hos/secmon_exo.c +++ b/bootloader/hos/secmon_exo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 CTCaer + * Copyright (c) 2018-2021 CTCaer * Copyright (c) 2019 Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it @@ -149,7 +149,7 @@ typedef struct _atm_fatal_error_ctx #define EXO_FW_VER(mj, mn, rv) (((mj) << 24) | ((mn) << 16) | ((rv) << 8)) -void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base, bool exo_new) +void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base) { u32 exo_fw_no = 0; u32 exo_flags = 0; @@ -175,39 +175,33 @@ void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base, bool exo_new) exo_fw_no++; // Feed old exosphere target versioning to new. - if (exo_new) + switch (exo_fw_no) { - switch (exo_fw_no) - { - case 1 ... 4: - case 6: - exo_fw_no = EXO_FW_VER(exo_fw_no, 0, 0); - break; - case 5: - if (!ctxt->exo_ctx.fs_is_510) - exo_fw_no = EXO_FW_VER(5, 0, 0); - else - exo_fw_no = EXO_FW_VER(5, 1, 0); - break; - case 7: - exo_fw_no = EXO_FW_VER(6, 2, 0); - break; - case 8 ... 9: - exo_fw_no = EXO_FW_VER(exo_fw_no - 1, 0, 0); - break; - case 10: - exo_fw_no = EXO_FW_VER(8, 1, 0); - break; - case 11: - exo_fw_no = EXO_FW_VER(9, 0, 0); - break; - case 12: - exo_fw_no = EXO_FW_VER(9, 1, 0); - break; - case 13 ... 15: - exo_fw_no = EXO_FW_VER(exo_fw_no - 3, 0, 0); - break; - } + case 1 ... 4: + case 6: + exo_fw_no = EXO_FW_VER(exo_fw_no, 0, 0); + break; + case 5: + exo_fw_no = EXO_FW_VER(5, ctxt->exo_ctx.hos_revision, 0); + break; + case 7: + exo_fw_no = EXO_FW_VER(6, 2, 0); + break; + case 8 ... 9: + exo_fw_no = EXO_FW_VER(exo_fw_no - 1, 0, 0); + break; + case 10: + exo_fw_no = EXO_FW_VER(8, 1, 0); + break; + case 11: + exo_fw_no = EXO_FW_VER(9, 0, 0); + break; + case 12: + exo_fw_no = EXO_FW_VER(9, 1, 0); + break; + case 13 ... 15: + exo_fw_no = EXO_FW_VER(exo_fw_no - 3, ctxt->exo_ctx.hos_revision, 0); + break; } // Parse exosphere.ini. diff --git a/bootloader/hos/secmon_exo.h b/bootloader/hos/secmon_exo.h index ea20125..78f4192 100644 --- a/bootloader/hos/secmon_exo.h +++ b/bootloader/hos/secmon_exo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 CTCaer + * Copyright (c) 2018-2021 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -19,7 +19,7 @@ #include -void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base, bool exo_new); +void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base); void secmon_exo_check_panic(); #endif