From 8f0ee258ac65cd24ce1bb77aef38902bfc3ee1cd Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 25 Jun 2020 21:59:59 -0700 Subject: [PATCH] sysupdater: begin implementing api --- .../ams/impl/ams_system_thread_definitions.hpp | 9 +++++---- .../stratosphere/ncm/ncm_content_meta_utils.hpp | 5 ++++- .../fssystem/fssystem_file_system_proxy_api.cpp | 12 ++++++------ .../source/ncm/ncm_content_meta_utils.cpp | 12 +++++++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp b/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp index 82da25ee..3db6c394 100644 --- a/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp +++ b/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp @@ -57,10 +57,11 @@ namespace ams::impl { AMS_DEFINE_SYSTEM_THREAD(-1, boot, Main); /* Mitm. */ - AMS_DEFINE_SYSTEM_THREAD(-7, mitm, InitializeThread); - AMS_DEFINE_SYSTEM_THREAD(-1, mitm_sf, QueryServerProcessThread); - AMS_DEFINE_SYSTEM_THREAD(16, mitm_fs, RomFileSystemInitializeThread); - AMS_DEFINE_SYSTEM_THREAD(21, mitm, DebugThrowThread); + AMS_DEFINE_SYSTEM_THREAD(-7, mitm, InitializeThread); + AMS_DEFINE_SYSTEM_THREAD(-1, mitm_sf, QueryServerProcessThread); + AMS_DEFINE_SYSTEM_THREAD(16, mitm_fs, RomFileSystemInitializeThread); + AMS_DEFINE_SYSTEM_THREAD(21, mitm, DebugThrowThread); + AMS_DEFINE_SYSTEM_THREAD(21, mitm_sysupdater, IpcServer); /* boot2. */ AMS_DEFINE_SYSTEM_THREAD(20, boot2, Main); diff --git a/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp b/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp index 72ffbfe6..572f744f 100644 --- a/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp +++ b/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp @@ -23,8 +23,11 @@ namespace ams::ncm { - Result ReadContentMetaPath(AutoBuffer *out, const char *path); + using MountContentMetaFunction = Result (*)(const char *mount_name, const char *path); + Result ReadContentMetaPath(AutoBuffer *out, const char *path); Result ReadVariationContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const Path &path, FirmwareVariationId firmware_variation_id); + void SetMountContentMetaFunction(MountContentMetaFunction func); + } diff --git a/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp b/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp index 31011c0c..8bc1dd43 100644 --- a/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp +++ b/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp @@ -24,12 +24,12 @@ namespace ams::fssystem { /* Official FS has a 4.5 MB exp heap, a 6 MB buffer pool, an 8 MB device buffer manager heap, and a 14 MB buffer manager heap. */ /* We don't need so much memory for ams.mitm (as we're servicing a much more limited context). */ - /* We'll give ourselves a 2.5 MB exp heap, a 2 MB buffer pool, a 2 MB device buffer manager heap, and a 2 MB buffer manager heap. */ - /* These numbers match signed-system-partition safe FS. */ - constexpr size_t ExpHeapSize = 2_MB + 512_KB; - constexpr size_t BufferPoolSize = 2_MB; - constexpr size_t DeviceBufferSize = 2_MB; - constexpr size_t BufferManagerHeapSize = 2_MB; + /* We'll give ourselves a 1.5 MB exp heap, a 1 MB buffer pool, a 1 MB device buffer manager heap, and a 1 MB buffer manager heap. */ + /* These numbers are 1 MB less than signed-system-partition safe FS in all pools. */ + constexpr size_t ExpHeapSize = 1_MB + 512_KB; + constexpr size_t BufferPoolSize = 1_MB; + constexpr size_t DeviceBufferSize = 1_MB; + constexpr size_t BufferManagerHeapSize = 1_MB; constexpr size_t MaxCacheCount = 1024; constexpr size_t BlockSize = 16_KB; diff --git a/libstratosphere/source/ncm/ncm_content_meta_utils.cpp b/libstratosphere/source/ncm/ncm_content_meta_utils.cpp index e4c77ad7..05b6c78f 100644 --- a/libstratosphere/source/ncm/ncm_content_meta_utils.cpp +++ b/libstratosphere/source/ncm/ncm_content_meta_utils.cpp @@ -26,12 +26,18 @@ namespace ams::ncm { return impl::PathView(name).HasSuffix(".cnmt"); } + Result MountContentMetaByRemoteFileSystemProxy(const char *mount_name, const char *path) { + return fs::MountContent(mount_name, path, fs::ContentType_Meta); + } + + constinit MountContentMetaFunction g_mount_content_meta_func = MountContentMetaByRemoteFileSystemProxy; + } Result ReadContentMetaPath(AutoBuffer *out, const char *path) { /* Mount the content. */ auto mount_name = impl::CreateUniqueMountName(); - R_TRY(fs::MountContent(mount_name.str, path, fs::ContentType_Meta)); + R_TRY(g_mount_content_meta_func(mount_name.str, path)); ON_SCOPE_EXIT { fs::Unmount(mount_name.str); }; /* Open the root directory. */ @@ -156,4 +162,8 @@ namespace ams::ncm { return ResultSuccess(); } + void SetMountContentMetaFunction(MountContentMetaFunction func) { + g_mount_content_meta_func = func; + } + }