From dd04113f5d23fb52a7105948620d9a6f064b50e9 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 26 Oct 2021 01:08:37 -0700 Subject: [PATCH] emummc/fusee: support 13.1.0 FS --- emummc/README.md | 2 +- emummc/source/FS/FS_offsets.c | 8 +++ emummc/source/FS/FS_versions.h | 3 ++ emummc/source/FS/offsets/1310.h | 59 +++++++++++++++++++++ emummc/source/FS/offsets/1310_exfat.h | 59 +++++++++++++++++++++ fusee/program/source/fusee_stratosphere.cpp | 11 ++++ 6 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 emummc/source/FS/offsets/1310.h create mode 100644 emummc/source/FS/offsets/1310_exfat.h diff --git a/emummc/README.md b/emummc/README.md index b06b5a493..b9844b0a8 100644 --- a/emummc/README.md +++ b/emummc/README.md @@ -2,7 +2,7 @@ *A SDMMC driver replacement for Nintendo's Filesystem Services, by **m4xw*** ### Supported Horizon Versions -**1.0.0 - 13.0.0** +**1.0.0 - 13.1.0** ## Features * Arbitrary SDMMC backend selection diff --git a/emummc/source/FS/FS_offsets.c b/emummc/source/FS/FS_offsets.c index bc3519987..12fc947b4 100644 --- a/emummc/source/FS/FS_offsets.c +++ b/emummc/source/FS/FS_offsets.c @@ -57,6 +57,8 @@ #include "offsets/1203_exfat.h" #include "offsets/1300.h" #include "offsets/1300_exfat.h" +#include "offsets/1310.h" +#include "offsets/1310_exfat.h" #include "../utils/fatal.h" #define GET_OFFSET_STRUCT_NAME(vers) g_offsets##vers @@ -125,6 +127,8 @@ DEFINE_OFFSET_STRUCT(_1203); DEFINE_OFFSET_STRUCT(_1203_EXFAT); DEFINE_OFFSET_STRUCT(_1300); DEFINE_OFFSET_STRUCT(_1300_EXFAT); +DEFINE_OFFSET_STRUCT(_1310); +DEFINE_OFFSET_STRUCT(_1310_EXFAT); const fs_offsets_t *get_fs_offsets(enum FS_VER version) { switch (version) { @@ -210,6 +214,10 @@ const fs_offsets_t *get_fs_offsets(enum FS_VER version) { return &(GET_OFFSET_STRUCT_NAME(_1300)); case FS_VER_13_0_0_EXFAT: return &(GET_OFFSET_STRUCT_NAME(_1300_EXFAT)); + case FS_VER_13_1_0: + return &(GET_OFFSET_STRUCT_NAME(_1310)); + case FS_VER_13_1_0_EXFAT: + return &(GET_OFFSET_STRUCT_NAME(_1310_EXFAT)); default: fatal_abort(Fatal_UnknownVersion); } diff --git a/emummc/source/FS/FS_versions.h b/emummc/source/FS/FS_versions.h index 7436a0caf..8ea653888 100644 --- a/emummc/source/FS/FS_versions.h +++ b/emummc/source/FS/FS_versions.h @@ -83,6 +83,9 @@ enum FS_VER FS_VER_13_0_0, FS_VER_13_0_0_EXFAT, + FS_VER_13_1_0, + FS_VER_13_1_0_EXFAT, + FS_VER_MAX, }; diff --git a/emummc/source/FS/offsets/1310.h b/emummc/source/FS/offsets/1310.h new file mode 100644 index 000000000..5d4e05226 --- /dev/null +++ b/emummc/source/FS/offsets/1310.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 m4xw + * Copyright (c) 2019 Atmosphere-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef __FS_1310_H__ +#define __FS_1310_H__ + +// Accessor vtable getters +#define FS_OFFSET_1310_SDMMC_ACCESSOR_GC 0x158C20 +#define FS_OFFSET_1310_SDMMC_ACCESSOR_SD 0x15AA30 +#define FS_OFFSET_1310_SDMMC_ACCESSOR_NAND 0x159150 + +// Hooks +#define FS_OFFSET_1310_SDMMC_WRAPPER_READ 0x1545C0 +#define FS_OFFSET_1310_SDMMC_WRAPPER_WRITE 0x154680 +#define FS_OFFSET_1310_RTLD 0x688 +#define FS_OFFSET_1310_RTLD_DESTINATION ((uintptr_t)(INT64_C(-0x3C))) + +#define FS_OFFSET_1310_CLKRST_SET_MIN_V_CLK_RATE 0x1537C0 + +// Misc funcs +#define FS_OFFSET_1310_LOCK_MUTEX 0x29690 +#define FS_OFFSET_1310_UNLOCK_MUTEX 0x296E0 + +#define FS_OFFSET_1310_SDMMC_WRAPPER_CONTROLLER_OPEN 0x1544A0 +#define FS_OFFSET_1310_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x154530 + +// Misc Data +#define FS_OFFSET_1310_SD_MUTEX 0xE133E8 +#define FS_OFFSET_1310_NAND_MUTEX 0xE0E768 +#define FS_OFFSET_1310_ACTIVE_PARTITION 0xE0E7A8 +#define FS_OFFSET_1310_SDMMC_DAS_HANDLE 0xDF6E18 + +// NOPs +#define FS_OFFSET_1310_SD_DAS_INIT 0x27744 + +// Nintendo Paths +#define FS_OFFSET_1310_NINTENDO_PATHS \ +{ \ + {.opcode_reg = 3, .adrp_offset = 0x0006EBE0, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 3, .adrp_offset = 0x0007BEEC, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 4, .adrp_offset = 0x00082294, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 4, .adrp_offset = 0x0009422C, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \ +} + +#endif // __FS_1310_H__ diff --git a/emummc/source/FS/offsets/1310_exfat.h b/emummc/source/FS/offsets/1310_exfat.h new file mode 100644 index 000000000..33bdc24b8 --- /dev/null +++ b/emummc/source/FS/offsets/1310_exfat.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 m4xw + * Copyright (c) 2019 Atmosphere-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef __FS_1310_EXFAT_H__ +#define __FS_1310_EXFAT_H__ + +// Accessor vtable getters +#define FS_OFFSET_1310_EXFAT_SDMMC_ACCESSOR_GC 0x158C20 +#define FS_OFFSET_1310_EXFAT_SDMMC_ACCESSOR_SD 0x15AA30 +#define FS_OFFSET_1310_EXFAT_SDMMC_ACCESSOR_NAND 0x159150 + +// Hooks +#define FS_OFFSET_1310_EXFAT_SDMMC_WRAPPER_READ 0x1545C0 +#define FS_OFFSET_1310_EXFAT_SDMMC_WRAPPER_WRITE 0x154680 +#define FS_OFFSET_1310_EXFAT_RTLD 0x688 +#define FS_OFFSET_1310_EXFAT_RTLD_DESTINATION ((uintptr_t)(INT64_C(-0x3C))) + +#define FS_OFFSET_1310_EXFAT_CLKRST_SET_MIN_V_CLK_RATE 0x1537C0 + +// Misc funcs +#define FS_OFFSET_1310_EXFAT_LOCK_MUTEX 0x29690 +#define FS_OFFSET_1310_EXFAT_UNLOCK_MUTEX 0x296E0 + +#define FS_OFFSET_1310_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0x1544A0 +#define FS_OFFSET_1310_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x154530 + +// Misc Data +#define FS_OFFSET_1310_EXFAT_SD_MUTEX 0xE203E8 +#define FS_OFFSET_1310_EXFAT_NAND_MUTEX 0xE1B768 +#define FS_OFFSET_1310_EXFAT_ACTIVE_PARTITION 0xE1B7A8 +#define FS_OFFSET_1310_EXFAT_SDMMC_DAS_HANDLE 0xE03E18 + +// NOPs +#define FS_OFFSET_1310_EXFAT_SD_DAS_INIT 0x27744 + +// Nintendo Paths +#define FS_OFFSET_1310_EXFAT_NINTENDO_PATHS \ +{ \ + {.opcode_reg = 3, .adrp_offset = 0x0006EBE0, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 3, .adrp_offset = 0x0007BEEC, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 4, .adrp_offset = 0x00082294, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 4, .adrp_offset = 0x0009422C, .add_rel_offset = 0x00000004}, \ + {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \ +} + +#endif // __FS_1310_EXFAT_H__ diff --git a/fusee/program/source/fusee_stratosphere.cpp b/fusee/program/source/fusee_stratosphere.cpp index 158a12276..95fb007e9 100644 --- a/fusee/program/source/fusee_stratosphere.cpp +++ b/fusee/program/source/fusee_stratosphere.cpp @@ -150,6 +150,9 @@ namespace ams::nxboot { FsVersion_13_0_0, FsVersion_13_0_0_Exfat, + FsVersion_13_1_0, + FsVersion_13_1_0_Exfat, + FsVersion_Count, }; @@ -215,6 +218,9 @@ namespace ams::nxboot { { 0x7D, 0x20, 0x05, 0x47, 0x17, 0x8A, 0x83, 0x6A }, /* FsVersion_13_0_0 */ { 0x51, 0xEB, 0xFA, 0x9C, 0xCF, 0x66, 0xC0, 0x9E }, /* FsVersion_13_0_0_Exfat */ + + { 0x91, 0xBA, 0x65, 0xA2, 0x1C, 0x1D, 0x50, 0xAE }, /* FsVersion_13_1_0 */ + { 0x76, 0x38, 0x27, 0xEE, 0x9C, 0x20, 0x7E, 0x5B }, /* FsVersion_13_1_0_Exfat */ }; const InitialProcessBinaryHeader *FindInitialProcessBinary(const pkg2::Package2Header *header, const u8 *data, ams::TargetFirmware target_firmware) { @@ -603,6 +609,11 @@ namespace ams::nxboot { AddPatch(fs_meta, 0x159119, NogcPatch0, sizeof(NogcPatch0)); AddPatch(fs_meta, 0x1426D0, NogcPatch1, sizeof(NogcPatch1)); break; + case FsVersion_13_1_0: + case FsVersion_13_1_0_Exfat: + AddPatch(fs_meta, 0x1590B9, NogcPatch0, sizeof(NogcPatch0)); + AddPatch(fs_meta, 0x142670, NogcPatch1, sizeof(NogcPatch1)); + break; default: break; }