From d93fdc8a6ca246928fde7b76b41fc9aae487e31a Mon Sep 17 00:00:00 2001 From: Leystryku Date: Sun, 18 Feb 2024 05:02:35 +0100 Subject: service: Add proper GetCacheStorageMax implementation to IApplicationFunctions --- .../hle/service/am/service/application_functions.cpp | 20 +++++++++++++++----- .../hle/service/am/service/application_functions.h | 2 +- src/core/hle/service/filesystem/fsp/fsp_srv.cpp | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index ac3b0066e..eee9428ce 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -17,6 +17,7 @@ #include "core/hle/service/filesystem/save_data_controller.h" #include "core/hle/service/ns/ns.h" #include "core/hle/service/sm/sm.h" +#include "core/hle/service/glue/glue_manager.h" namespace Service::AM { @@ -267,14 +268,23 @@ Result IApplicationFunctions::GetSaveDataSizeMax(Out out_max_normal_size, R_SUCCEED(); } -Result IApplicationFunctions::GetCacheStorageMax(Out out_max_normal_size, +Result IApplicationFunctions::GetCacheStorageMax(Out out_cache_storage_index_max, Out out_max_journal_size) { - LOG_WARNING(Service_AM, "(STUBBED) called"); + LOG_DEBUG(Service_AM, "called"); - *out_max_normal_size = 0xFFFFFF; - *out_max_journal_size = 0xFFFFFF; + const auto title_id = m_applet->program_id; - R_SUCCEED(); + std::vector nacp; + const auto result = system.GetARPManager().GetControlProperty(&nacp, title_id); + + if (R_SUCCEEDED(result)) { + const auto rawnacp = reinterpret_cast(nacp.data()); + + *out_cache_storage_index_max = static_cast(rawnacp->cache_storage_max_index); + *out_max_journal_size = static_cast(rawnacp->cache_storage_data_and_journal_max_size); + } + + R_SUCCEED(); } Result IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(s64 unused) { diff --git a/src/core/hle/service/am/service/application_functions.h b/src/core/hle/service/am/service/application_functions.h index c86f0d8ac..10025a152 100644 --- a/src/core/hle/service/am/service/application_functions.h +++ b/src/core/hle/service/am/service/application_functions.h @@ -40,7 +40,7 @@ private: Result CreateCacheStorage(Out out_target_media, Out out_required_size, u16 index, u64 normal_size, u64 journal_size); Result GetSaveDataSizeMax(Out out_max_normal_size, Out out_max_journal_size); - Result GetCacheStorageMax(Out out_max_normal_size, Out out_max_journal_size); + Result GetCacheStorageMax(Out out_cache_storage_index_max, Out out_max_journal_size); Result BeginBlockingHomeButtonShortAndLongPressed(s64 unused); Result EndBlockingHomeButtonShortAndLongPressed(); Result BeginBlockingHomeButton(s64 timeout_ns); diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp index e1238527e..2d49f30c8 100644 --- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp @@ -762,4 +762,4 @@ void FSP_SRV::OpenMultiCommitManager(HLERequestContext& ctx) { rb.PushIpcInterface(std::make_shared(system)); } -} // namespace Service::FileSystem \ No newline at end of file +} // namespace Service::FileSystem -- cgit v1.2.3