From 2b93bbd9ee174863dbf5c611c0d9d159fe9e6e31 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 3 Dec 2020 12:48:06 -0800 Subject: [PATCH] git subrepo pull emummc subrepo: subdir: "emummc" merged: "5eed18eb" upstream: origin: "https://github.com/m4xw/emuMMC" branch: "develop" commit: "5eed18eb" git-subrepo: version: "0.4.1" origin: "???" commit: "???" --- emummc/.gitrepo | 4 ++-- emummc/README.md | 2 +- emummc/source/FS/FS_offsets.c | 1 + emummc/source/FS/FS_offsets.h | 1 + emummc/source/FS/FS_structs.h | 2 +- emummc/source/FS/offsets/100.h | 1 + emummc/source/FS/offsets/1000.h | 1 + emummc/source/FS/offsets/1000_exfat.h | 1 + emummc/source/FS/offsets/1020.h | 1 + emummc/source/FS/offsets/1020_exfat.h | 1 + emummc/source/FS/offsets/1100.h | 1 + emummc/source/FS/offsets/1100_exfat.h | 1 + emummc/source/FS/offsets/200.h | 1 + emummc/source/FS/offsets/200_exfat.h | 1 + emummc/source/FS/offsets/210.h | 1 + emummc/source/FS/offsets/210_exfat.h | 1 + emummc/source/FS/offsets/300.h | 1 + emummc/source/FS/offsets/300_exfat.h | 1 + emummc/source/FS/offsets/301.h | 1 + emummc/source/FS/offsets/301_exfat.h | 1 + emummc/source/FS/offsets/400.h | 1 + emummc/source/FS/offsets/400_exfat.h | 1 + emummc/source/FS/offsets/410.h | 3 ++- emummc/source/FS/offsets/410_exfat.h | 1 + emummc/source/FS/offsets/500.h | 1 + emummc/source/FS/offsets/500_exfat.h | 1 + emummc/source/FS/offsets/510.h | 1 + emummc/source/FS/offsets/510_exfat.h | 1 + emummc/source/FS/offsets/600.h | 1 + emummc/source/FS/offsets/600_exfat.h | 1 + emummc/source/FS/offsets/700.h | 1 + emummc/source/FS/offsets/700_exfat.h | 1 + emummc/source/FS/offsets/800.h | 1 + emummc/source/FS/offsets/800_exfat.h | 1 + emummc/source/FS/offsets/810.h | 1 + emummc/source/FS/offsets/810_exfat.h | 1 + emummc/source/FS/offsets/900.h | 1 + emummc/source/FS/offsets/900_exfat.h | 1 + emummc/source/FS/offsets/910.h | 1 + emummc/source/FS/offsets/910_exfat.h | 1 + emummc/source/emuMMC/emummc.c | 31 ++++++++++++++++++++++++--- emummc/source/emuMMC/emummc.h | 1 + emummc/source/emuMMC/emummc_ctx.h | 2 +- emummc/source/main.c | 7 ++++-- 44 files changed, 77 insertions(+), 11 deletions(-) diff --git a/emummc/.gitrepo b/emummc/.gitrepo index 00015acf5..73225cc1e 100644 --- a/emummc/.gitrepo +++ b/emummc/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/m4xw/emuMMC branch = develop - commit = 6fd752dad13c02d482a5d89c24f4e8ce8b9d8f56 - parent = 4f1a4e74992aa84b8ab84bccacc720e2d5823791 + commit = 5eed18eb527bbaa63aee5323c26de5b0cca6d28e + parent = 021b29d2dbc8ed0469bc822393e58c9f0d174d57 method = rebase cmdver = 0.4.1 diff --git a/emummc/README.md b/emummc/README.md index 726d8f430..a767aec34 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 - 10.0.0** +**1.0.0 - 11.0.0** ## Features * Arbitrary SDMMC backend selection diff --git a/emummc/source/FS/FS_offsets.c b/emummc/source/FS/FS_offsets.c index 59f4e42fb..86dc12d6c 100644 --- a/emummc/source/FS/FS_offsets.c +++ b/emummc/source/FS/FS_offsets.c @@ -71,6 +71,7 @@ static const fs_offsets_t GET_OFFSET_STRUCT_NAME(vers) = { \ .nand_mutex = FS_OFFSET##vers##_NAND_MUTEX, \ .active_partition = FS_OFFSET##vers##_ACTIVE_PARTITION, \ .sdmmc_das_handle = FS_OFFSET##vers##_SDMMC_DAS_HANDLE, \ + .sdmmc_accessor_controller_open = FS_OFFSET##vers##_SDMMC_WRAPPER_CONTROLLER_OPEN, \ .sdmmc_accessor_controller_close = FS_OFFSET##vers##_SDMMC_WRAPPER_CONTROLLER_CLOSE, \ .sd_das_init = FS_OFFSET##vers##_SD_DAS_INIT, \ .nintendo_paths = FS_OFFSET##vers##_NINTENDO_PATHS, \ diff --git a/emummc/source/FS/FS_offsets.h b/emummc/source/FS/FS_offsets.h index 9a41997b7..8507d85d3 100644 --- a/emummc/source/FS/FS_offsets.h +++ b/emummc/source/FS/FS_offsets.h @@ -41,6 +41,7 @@ typedef struct { // Misc funcs uintptr_t lock_mutex; uintptr_t unlock_mutex; + uintptr_t sdmmc_accessor_controller_open; uintptr_t sdmmc_accessor_controller_close; // Misc data uintptr_t sd_mutex; diff --git a/emummc/source/FS/FS_structs.h b/emummc/source/FS/FS_structs.h index 2dc14b600..81db84f85 100644 --- a/emummc/source/FS/FS_structs.h +++ b/emummc/source/FS/FS_structs.h @@ -35,7 +35,7 @@ typedef struct sdmmc_accessor_vt void *dtor; void *map_device_addr_space; void *unmap_device_addr_space; - void *controller_open; + uint64_t (*sdmmc_accessor_controller_open)(void *); uint64_t (*sdmmc_accessor_controller_close)(void *); uint64_t (*read_write)(void *, uint64_t, uint64_t, void *, uint64_t, uint64_t); // More not included because we don't use it. diff --git a/emummc/source/FS/offsets/100.h b/emummc/source/FS/offsets/100.h index 779601580..0f94f19f4 100644 --- a/emummc/source/FS/offsets/100.h +++ b/emummc/source/FS/offsets/100.h @@ -34,6 +34,7 @@ #define FS_OFFSET_100_LOCK_MUTEX 0x2884 #define FS_OFFSET_100_UNLOCK_MUTEX 0x28F0 +#define FS_OFFSET_100_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_100_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x6A8AC // Misc Data diff --git a/emummc/source/FS/offsets/1000.h b/emummc/source/FS/offsets/1000.h index 3c2dc673c..1471eb938 100644 --- a/emummc/source/FS/offsets/1000.h +++ b/emummc/source/FS/offsets/1000.h @@ -34,6 +34,7 @@ #define FS_OFFSET_1000_LOCK_MUTEX 0x28910 #define FS_OFFSET_1000_UNLOCK_MUTEX 0x28960 +#define FS_OFFSET_1000_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_1000_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1422E0 // Misc Data diff --git a/emummc/source/FS/offsets/1000_exfat.h b/emummc/source/FS/offsets/1000_exfat.h index cc3c212e7..6dcfe6a02 100644 --- a/emummc/source/FS/offsets/1000_exfat.h +++ b/emummc/source/FS/offsets/1000_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_1000_EXFAT_LOCK_MUTEX 0x28910 #define FS_OFFSET_1000_EXFAT_UNLOCK_MUTEX 0x28960 +#define FS_OFFSET_1000_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_1000_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1422E0 // Misc Data diff --git a/emummc/source/FS/offsets/1020.h b/emummc/source/FS/offsets/1020.h index 2d43be5cd..65d5b48c8 100644 --- a/emummc/source/FS/offsets/1020.h +++ b/emummc/source/FS/offsets/1020.h @@ -34,6 +34,7 @@ #define FS_OFFSET_1020_LOCK_MUTEX 0x28910 #define FS_OFFSET_1020_UNLOCK_MUTEX 0x28960 +#define FS_OFFSET_1020_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_1020_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x142740 // Misc Data diff --git a/emummc/source/FS/offsets/1020_exfat.h b/emummc/source/FS/offsets/1020_exfat.h index 0ed6a8fcf..34c03d9a4 100644 --- a/emummc/source/FS/offsets/1020_exfat.h +++ b/emummc/source/FS/offsets/1020_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_1020_EXFAT_LOCK_MUTEX 0x28910 #define FS_OFFSET_1020_EXFAT_UNLOCK_MUTEX 0x28960 +#define FS_OFFSET_1020_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_1020_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x142740 // Misc Data diff --git a/emummc/source/FS/offsets/1100.h b/emummc/source/FS/offsets/1100.h index a2a1bcf83..164ec37d6 100644 --- a/emummc/source/FS/offsets/1100.h +++ b/emummc/source/FS/offsets/1100.h @@ -34,6 +34,7 @@ #define FS_OFFSET_1100_LOCK_MUTEX 0x28FF0 #define FS_OFFSET_1100_UNLOCK_MUTEX 0x29040 +#define FS_OFFSET_1100_SDMMC_WRAPPER_CONTROLLER_OPEN 0x14B840 #define FS_OFFSET_1100_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x14B8F0 // Misc Data diff --git a/emummc/source/FS/offsets/1100_exfat.h b/emummc/source/FS/offsets/1100_exfat.h index 6f0c474bc..ecc705660 100644 --- a/emummc/source/FS/offsets/1100_exfat.h +++ b/emummc/source/FS/offsets/1100_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_1100_EXFAT_LOCK_MUTEX 0x28FF0 #define FS_OFFSET_1100_EXFAT_UNLOCK_MUTEX 0x29040 +#define FS_OFFSET_1100_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0x14B840 #define FS_OFFSET_1100_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x14B8F0 // Misc Data diff --git a/emummc/source/FS/offsets/200.h b/emummc/source/FS/offsets/200.h index ef46d75e2..589e25c33 100644 --- a/emummc/source/FS/offsets/200.h +++ b/emummc/source/FS/offsets/200.h @@ -34,6 +34,7 @@ #define FS_OFFSET_200_LOCK_MUTEX 0x3264 #define FS_OFFSET_200_UNLOCK_MUTEX 0x32D0 +#define FS_OFFSET_200_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_200_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x733F4 // Misc Data diff --git a/emummc/source/FS/offsets/200_exfat.h b/emummc/source/FS/offsets/200_exfat.h index 20fb2c51b..946d4fbd9 100644 --- a/emummc/source/FS/offsets/200_exfat.h +++ b/emummc/source/FS/offsets/200_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_200_EXFAT_LOCK_MUTEX 0x3264 #define FS_OFFSET_200_EXFAT_UNLOCK_MUTEX 0x32D0 +#define FS_OFFSET_200_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_200_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x733F4 // Misc Data diff --git a/emummc/source/FS/offsets/210.h b/emummc/source/FS/offsets/210.h index bb7c0640d..20369f11c 100644 --- a/emummc/source/FS/offsets/210.h +++ b/emummc/source/FS/offsets/210.h @@ -34,6 +34,7 @@ #define FS_OFFSET_210_LOCK_MUTEX 0x3264 #define FS_OFFSET_210_UNLOCK_MUTEX 0x32D0 +#define FS_OFFSET_210_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_210_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x737D4 // Misc Data diff --git a/emummc/source/FS/offsets/210_exfat.h b/emummc/source/FS/offsets/210_exfat.h index 444881ec0..844338bc3 100644 --- a/emummc/source/FS/offsets/210_exfat.h +++ b/emummc/source/FS/offsets/210_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_210_EXFAT_LOCK_MUTEX 0x3264 #define FS_OFFSET_210_EXFAT_UNLOCK_MUTEX 0x32D0 +#define FS_OFFSET_210_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_210_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x737D4 // Misc Data diff --git a/emummc/source/FS/offsets/300.h b/emummc/source/FS/offsets/300.h index 02bd67aa0..9908a215b 100644 --- a/emummc/source/FS/offsets/300.h +++ b/emummc/source/FS/offsets/300.h @@ -34,6 +34,7 @@ #define FS_OFFSET_300_LOCK_MUTEX 0x35CC #define FS_OFFSET_300_UNLOCK_MUTEX 0x3638 +#define FS_OFFSET_300_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_300_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A270 // Misc Data diff --git a/emummc/source/FS/offsets/300_exfat.h b/emummc/source/FS/offsets/300_exfat.h index 6c1843800..d230f52b6 100644 --- a/emummc/source/FS/offsets/300_exfat.h +++ b/emummc/source/FS/offsets/300_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_300_EXFAT_LOCK_MUTEX 0x35CC #define FS_OFFSET_300_EXFAT_UNLOCK_MUTEX 0x3638 +#define FS_OFFSET_300_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_300_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A270 // Misc Data diff --git a/emummc/source/FS/offsets/301.h b/emummc/source/FS/offsets/301.h index 57b24dd37..8dca17315 100644 --- a/emummc/source/FS/offsets/301.h +++ b/emummc/source/FS/offsets/301.h @@ -34,6 +34,7 @@ #define FS_OFFSET_301_LOCK_MUTEX 0x3638 #define FS_OFFSET_301_UNLOCK_MUTEX 0x36A4 +#define FS_OFFSET_301_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_301_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A32C // Misc Data diff --git a/emummc/source/FS/offsets/301_exfat.h b/emummc/source/FS/offsets/301_exfat.h index 1b37509b1..72f0f4499 100644 --- a/emummc/source/FS/offsets/301_exfat.h +++ b/emummc/source/FS/offsets/301_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_301_EXFAT_LOCK_MUTEX 0x3638 #define FS_OFFSET_301_EXFAT_UNLOCK_MUTEX 0x36A4 +#define FS_OFFSET_301_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_301_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A32C // Misc Data diff --git a/emummc/source/FS/offsets/400.h b/emummc/source/FS/offsets/400.h index 416931323..fcd5ca927 100644 --- a/emummc/source/FS/offsets/400.h +++ b/emummc/source/FS/offsets/400.h @@ -34,6 +34,7 @@ #define FS_OFFSET_400_LOCK_MUTEX 0x39A0 #define FS_OFFSET_400_UNLOCK_MUTEX 0x3A0C +#define FS_OFFSET_400_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_400_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DB48 // Misc Data diff --git a/emummc/source/FS/offsets/400_exfat.h b/emummc/source/FS/offsets/400_exfat.h index 611351cc0..da1ac97dd 100644 --- a/emummc/source/FS/offsets/400_exfat.h +++ b/emummc/source/FS/offsets/400_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_400_EXFAT_LOCK_MUTEX 0x39A0 #define FS_OFFSET_400_EXFAT_UNLOCK_MUTEX 0x3A0C +#define FS_OFFSET_400_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_400_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DB48 // Misc Data diff --git a/emummc/source/FS/offsets/410.h b/emummc/source/FS/offsets/410.h index 5b3bf5f0c..4d068e713 100644 --- a/emummc/source/FS/offsets/410.h +++ b/emummc/source/FS/offsets/410.h @@ -34,7 +34,8 @@ #define FS_OFFSET_410_LOCK_MUTEX 0x39A0 #define FS_OFFSET_410_UNLOCK_MUTEX 0x3A0C -#define FS_OFFSET_410_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DBAC +#define FS_OFFSET_410_SDMMC_WRAPPER_CONTROLLER_OPEN 0 +#define FS_OFFSET_410_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DBAC // Misc Data #define FS_OFFSET_410_SD_MUTEX 0xE80268 diff --git a/emummc/source/FS/offsets/410_exfat.h b/emummc/source/FS/offsets/410_exfat.h index ffaa100cc..cf66c23d0 100644 --- a/emummc/source/FS/offsets/410_exfat.h +++ b/emummc/source/FS/offsets/410_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_410_EXFAT_LOCK_MUTEX 0x39A0 #define FS_OFFSET_410_EXFAT_UNLOCK_MUTEX 0x3A0C +#define FS_OFFSET_410_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_410_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DBAC // Misc Data diff --git a/emummc/source/FS/offsets/500.h b/emummc/source/FS/offsets/500.h index f23e69a18..630a3317d 100644 --- a/emummc/source/FS/offsets/500.h +++ b/emummc/source/FS/offsets/500.h @@ -34,6 +34,7 @@ #define FS_OFFSET_500_LOCK_MUTEX 0x4080 #define FS_OFFSET_500_UNLOCK_MUTEX 0x40D0 +#define FS_OFFSET_500_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_500_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9380 // Misc Data diff --git a/emummc/source/FS/offsets/500_exfat.h b/emummc/source/FS/offsets/500_exfat.h index 6b597465c..df239f048 100644 --- a/emummc/source/FS/offsets/500_exfat.h +++ b/emummc/source/FS/offsets/500_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_500_EXFAT_LOCK_MUTEX 0x4080 #define FS_OFFSET_500_EXFAT_UNLOCK_MUTEX 0x40D0 +#define FS_OFFSET_500_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_500_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9380 // Misc Data diff --git a/emummc/source/FS/offsets/510.h b/emummc/source/FS/offsets/510.h index 065ad4569..e867f190b 100644 --- a/emummc/source/FS/offsets/510.h +++ b/emummc/source/FS/offsets/510.h @@ -34,6 +34,7 @@ #define FS_OFFSET_510_LOCK_MUTEX 0x4080 #define FS_OFFSET_510_UNLOCK_MUTEX 0x40D0 +#define FS_OFFSET_510_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_510_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9750 // Misc Data diff --git a/emummc/source/FS/offsets/510_exfat.h b/emummc/source/FS/offsets/510_exfat.h index fec783ca3..8ce184f2a 100644 --- a/emummc/source/FS/offsets/510_exfat.h +++ b/emummc/source/FS/offsets/510_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_510_EXFAT_LOCK_MUTEX 0x4080 #define FS_OFFSET_510_EXFAT_UNLOCK_MUTEX 0x40D0 +#define FS_OFFSET_510_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_510_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9750 // Misc Data diff --git a/emummc/source/FS/offsets/600.h b/emummc/source/FS/offsets/600.h index 79baa1c34..a0835a0df 100644 --- a/emummc/source/FS/offsets/600.h +++ b/emummc/source/FS/offsets/600.h @@ -34,6 +34,7 @@ #define FS_OFFSET_600_LOCK_MUTEX 0x1412C0 #define FS_OFFSET_600_UNLOCK_MUTEX 0x141310 +#define FS_OFFSET_600_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_600_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x148500 // Misc Data diff --git a/emummc/source/FS/offsets/600_exfat.h b/emummc/source/FS/offsets/600_exfat.h index 1d0cfdd7c..0600b0163 100644 --- a/emummc/source/FS/offsets/600_exfat.h +++ b/emummc/source/FS/offsets/600_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_600_EXFAT_LOCK_MUTEX 0x14C9C0 #define FS_OFFSET_600_EXFAT_UNLOCK_MUTEX 0x14CA10 +#define FS_OFFSET_600_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_600_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x153C00 // Misc Data diff --git a/emummc/source/FS/offsets/700.h b/emummc/source/FS/offsets/700.h index 112bd3eea..9281cb905 100644 --- a/emummc/source/FS/offsets/700.h +++ b/emummc/source/FS/offsets/700.h @@ -34,6 +34,7 @@ #define FS_OFFSET_700_LOCK_MUTEX 0x148A90 #define FS_OFFSET_700_UNLOCK_MUTEX 0x148AE0 +#define FS_OFFSET_700_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_700_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x14FD50 // Misc Data diff --git a/emummc/source/FS/offsets/700_exfat.h b/emummc/source/FS/offsets/700_exfat.h index d948dd791..4f1ef1308 100644 --- a/emummc/source/FS/offsets/700_exfat.h +++ b/emummc/source/FS/offsets/700_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_700_EXFAT_LOCK_MUTEX 0x154040 #define FS_OFFSET_700_EXFAT_UNLOCK_MUTEX 0x154090 +#define FS_OFFSET_700_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_700_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x15B300 // Misc Data diff --git a/emummc/source/FS/offsets/800.h b/emummc/source/FS/offsets/800.h index 2af796c80..2eef520cf 100644 --- a/emummc/source/FS/offsets/800.h +++ b/emummc/source/FS/offsets/800.h @@ -34,6 +34,7 @@ #define FS_OFFSET_800_LOCK_MUTEX 0x14B6D0 #define FS_OFFSET_800_UNLOCK_MUTEX 0x14B720 +#define FS_OFFSET_800_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_800_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1529E0 // Misc Data diff --git a/emummc/source/FS/offsets/800_exfat.h b/emummc/source/FS/offsets/800_exfat.h index 97499d95d..786c40e5b 100644 --- a/emummc/source/FS/offsets/800_exfat.h +++ b/emummc/source/FS/offsets/800_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_800_EXFAT_LOCK_MUTEX 0x156C80 #define FS_OFFSET_800_EXFAT_UNLOCK_MUTEX 0x156CD0 +#define FS_OFFSET_800_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_800_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x15DF90 // Misc Data diff --git a/emummc/source/FS/offsets/810.h b/emummc/source/FS/offsets/810.h index e2f9c9b02..7a6dd2855 100644 --- a/emummc/source/FS/offsets/810.h +++ b/emummc/source/FS/offsets/810.h @@ -34,6 +34,7 @@ #define FS_OFFSET_810_LOCK_MUTEX 0x14B6D0 #define FS_OFFSET_810_UNLOCK_MUTEX 0x14B720 +#define FS_OFFSET_810_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_810_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1529E0 // Misc Data diff --git a/emummc/source/FS/offsets/810_exfat.h b/emummc/source/FS/offsets/810_exfat.h index 772e87de1..47c425ff0 100644 --- a/emummc/source/FS/offsets/810_exfat.h +++ b/emummc/source/FS/offsets/810_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_810_EXFAT_LOCK_MUTEX 0x156C80 #define FS_OFFSET_810_EXFAT_UNLOCK_MUTEX 0x156CD0 +#define FS_OFFSET_810_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_810_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x15DF90 // Misc Data diff --git a/emummc/source/FS/offsets/900.h b/emummc/source/FS/offsets/900.h index 7b66546c6..c390ec828 100644 --- a/emummc/source/FS/offsets/900.h +++ b/emummc/source/FS/offsets/900.h @@ -34,6 +34,7 @@ #define FS_OFFSET_900_LOCK_MUTEX 0x25280 #define FS_OFFSET_900_UNLOCK_MUTEX 0x252D0 +#define FS_OFFSET_900_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_900_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137740 // Misc Data diff --git a/emummc/source/FS/offsets/900_exfat.h b/emummc/source/FS/offsets/900_exfat.h index 8a55f0a73..184d7d090 100644 --- a/emummc/source/FS/offsets/900_exfat.h +++ b/emummc/source/FS/offsets/900_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_900_EXFAT_LOCK_MUTEX 0x25280 #define FS_OFFSET_900_EXFAT_UNLOCK_MUTEX 0x252D0 +#define FS_OFFSET_900_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_900_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137740 // Misc Data diff --git a/emummc/source/FS/offsets/910.h b/emummc/source/FS/offsets/910.h index f57a9aa15..65aded2de 100644 --- a/emummc/source/FS/offsets/910.h +++ b/emummc/source/FS/offsets/910.h @@ -34,6 +34,7 @@ #define FS_OFFSET_910_LOCK_MUTEX 0x25280 #define FS_OFFSET_910_UNLOCK_MUTEX 0x252D0 +#define FS_OFFSET_910_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_910_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137750 // Misc Data diff --git a/emummc/source/FS/offsets/910_exfat.h b/emummc/source/FS/offsets/910_exfat.h index 9b31301bc..fd59d1bad 100644 --- a/emummc/source/FS/offsets/910_exfat.h +++ b/emummc/source/FS/offsets/910_exfat.h @@ -34,6 +34,7 @@ #define FS_OFFSET_910_EXFAT_LOCK_MUTEX 0x25280 #define FS_OFFSET_910_EXFAT_UNLOCK_MUTEX 0x252D0 +#define FS_OFFSET_910_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0 #define FS_OFFSET_910_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137750 // Misc Data diff --git a/emummc/source/emuMMC/emummc.c b/emummc/source/emuMMC/emummc.c index 237ebf116..49f1ca540 100644 --- a/emummc/source/emuMMC/emummc.c +++ b/emummc/source/emuMMC/emummc.c @@ -271,7 +271,7 @@ int sdmmc_nand_get_active_partition_index() static uint64_t emummc_read_write_inner(void *buf, unsigned int sector, unsigned int num_sectors, bool is_write) { - if ((emuMMC_ctx.EMMC_Type == emuMMC_SD)) + if ((emuMMC_ctx.EMMC_Type == emuMMC_SD_Raw)) { // raw partition sector offset: emuMMC_ctx.EMMC_StoragePartitionOffset. sector += emuMMC_ctx.EMMC_StoragePartitionOffset; @@ -318,6 +318,31 @@ static uint64_t emummc_read_write_inner(void *buf, unsigned int sector, unsigned return res; } +// Controller open wrapper +uint64_t sdmmc_wrapper_controller_open(int mmc_id) +{ + uint64_t result; + sdmmc_accessor_t *_this; + _this = sdmmc_accessor_get(mmc_id); + + if (_this != NULL) + { + // Lock eMMC xfer while SD card is being initialized by FS. + if (_this == sdmmc_accessor_get(FS_SDMMC_SD)) + mutex_lock_handler(FS_SDMMC_EMMC); // Recursive Mutex, handler will lock SD as well if custom_driver + + result = _this->vtab->sdmmc_accessor_controller_open(_this); + + // Unlock eMMC. + if (_this == sdmmc_accessor_get(FS_SDMMC_SD)) + mutex_unlock_handler(FS_SDMMC_EMMC); + + return result; + } + + fatal_abort(Fatal_OpenAccessor); +} + // Controller close wrapper uint64_t sdmmc_wrapper_controller_close(int mmc_id) { @@ -389,7 +414,7 @@ uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned in if (first_sd_read) { first_sd_read = false; - if (emuMMC_ctx.EMMC_Type == emuMMC_SD) + if (emuMMC_ctx.EMMC_Type == emuMMC_SD_Raw) { // Because some SD cards have issues with emuMMC's driver // we currently swap to FS's driver after first SD read @@ -400,7 +425,7 @@ uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned in } } - // Call hekates driver. + // Call hekate's driver. if (sdmmc_storage_read(&sd_storage, sector, num_sectors, buf)) { mutex_unlock_handler(mmc_id); diff --git a/emummc/source/emuMMC/emummc.h b/emummc/source/emuMMC/emummc.h index 0acee8e4c..bab3dae44 100644 --- a/emummc/source/emuMMC/emummc.h +++ b/emummc/source/emuMMC/emummc.h @@ -52,6 +52,7 @@ void mutex_lock_handler(int mmc_id); void mutex_unlock_handler(int mmc_id); // Hooks +uint64_t sdmmc_wrapper_controller_open(int mmc_id); uint64_t sdmmc_wrapper_controller_close(int mmc_id); uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned int sector, unsigned int num_sectors); uint64_t sdmmc_wrapper_write(int mmc_id, unsigned int sector, unsigned int num_sectors, void *buf, uint64_t bufSize); diff --git a/emummc/source/emuMMC/emummc_ctx.h b/emummc/source/emuMMC/emummc_ctx.h index 2663f528d..9bee3fd09 100644 --- a/emummc/source/emuMMC/emummc_ctx.h +++ b/emummc/source/emuMMC/emummc_ctx.h @@ -30,7 +30,7 @@ enum emuMMC_Type emuMMC_EMMC = 0, // SD Device raw - emuMMC_SD, + emuMMC_SD_Raw, // SD Device File emuMMC_SD_File, diff --git a/emummc/source/main.c b/emummc/source/main.c index 0e6a9dae4..a06101a9e 100644 --- a/emummc/source/main.c +++ b/emummc/source/main.c @@ -92,7 +92,7 @@ volatile __attribute__((aligned(0x1000))) emuMMC_ctx_t emuMMC_ctx = { .fs_ver = FS_VER_MAX, // SD Default Metadata - .SD_Type = emuMMC_SD, + .SD_Type = emuMMC_SD_Raw, .SD_StoragePartitionOffset = 0, // EMMC Default Metadata @@ -285,6 +285,9 @@ void setup_hooks(void) INJECT_HOOK(fs_offsets->sdmmc_wrapper_read, sdmmc_wrapper_read); // sdmmc_wrapper_write hook INJECT_HOOK(fs_offsets->sdmmc_wrapper_write, sdmmc_wrapper_write); + // sdmmc_wrapper_controller_open hook + if (fs_offsets->sdmmc_accessor_controller_open) + INJECT_HOOK(fs_offsets->sdmmc_accessor_controller_open, sdmmc_wrapper_controller_open); // sdmmc_wrapper_controller_close hook INJECT_HOOK(fs_offsets->sdmmc_accessor_controller_close, sdmmc_wrapper_controller_close); @@ -346,7 +349,7 @@ static void load_emummc_ctx(void) emuMMC_ctx.id = config.base_cfg.id; emuMMC_ctx.EMMC_Type = (enum emuMMC_Type)config.base_cfg.type; emuMMC_ctx.fs_ver = (enum FS_VER)config.base_cfg.fs_version; - if (emuMMC_ctx.EMMC_Type == emuMMC_SD) + if (emuMMC_ctx.EMMC_Type == emuMMC_SD_Raw) { emuMMC_ctx.EMMC_StoragePartitionOffset = config.partition_cfg.start_sector; }