From da7be67dafc90c84529304cfef57dfa5f9291017 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Nov 2020 15:49:45 -0500 Subject: ipc_helpers: Remove usage of the global system instance Resolves numerous deprecation warnings throughout the codebase due to inclusion of this header. Now building core should be significantly less noisy (and also relying on less global state). This also uncovered quite a few modules that were relying on indirect includes, which have also been fixed. --- src/core/hle/service/aoc/aoc_u.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 8e79f707b..e58b2c518 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -6,6 +6,7 @@ #include #include #include "common/logging/log.h" +#include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/nca_metadata.h" -- cgit v1.2.3 From 6f8a06bac58790d20dae3c1adb4de3b441f07b30 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Nov 2020 07:53:10 -0500 Subject: patch_manager: Remove usages of the global system instance With this, only 19 usages of the global system instance remain within the core library. We're almost there. --- src/core/hle/service/aoc/aoc_u.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index e58b2c518..173b36da4 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -164,7 +164,8 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); const auto title_id = system.CurrentProcess()->GetTitleID(); - FileSys::PatchManager pm{title_id}; + const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), + system.GetContentProvider()}; const auto res = pm.GetControlMetadata(); if (res.first == nullptr) { -- cgit v1.2.3 From 1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 26 Nov 2020 15:19:08 -0500 Subject: service: Eliminate usages of the global system instance Completely removes all usages of the global system instance within the services code by passing in the using system instance to the services. --- src/core/hle/service/aoc/aoc_u.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 173b36da4..6abac3f78 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -48,8 +48,8 @@ static std::vector AccumulateAOCTitleIDs(Core::System& system) { return add_on_content; } -AOC_U::AOC_U(Core::System& system) - : ServiceFramework("aoc:u"), add_on_content(AccumulateAOCTitleIDs(system)), system(system) { +AOC_U::AOC_U(Core::System& system_) + : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "CountAddOnContentByApplicationId"}, -- cgit v1.2.3 From 0eb6c6cd836028a94260321e460871c228deee50 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 4 Dec 2020 01:41:21 -0500 Subject: file_sys: Consolidate common Title ID operations --- src/core/hle/service/aoc/aoc_u.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 6abac3f78..17ba21496 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -7,6 +7,7 @@ #include #include "common/logging/log.h" #include "core/core.h" +#include "core/file_sys/common_funcs.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/nca_metadata.h" @@ -23,11 +24,8 @@ namespace Service::AOC { -constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; -constexpr u64 DLC_BASE_TO_AOC_ID = 0x1000; - static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) { - return (title_id & DLC_BASE_TITLE_ID_MASK) == base; + return FileSys::GetBaseTitleID(title_id) == base; } static std::vector AccumulateAOCTitleIDs(Core::System& system) { @@ -123,11 +121,11 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { const auto& disabled = Settings::values.disabled_addons[current]; if (std::find(disabled.begin(), disabled.end(), "DLC") == disabled.end()) { for (u64 content_id : add_on_content) { - if ((content_id & DLC_BASE_TITLE_ID_MASK) != current) { + if (FileSys::GetBaseTitleID(content_id) != current) { continue; } - out.push_back(static_cast(content_id & 0x7FF)); + out.push_back(static_cast(FileSys::GetAOCID(content_id))); } } @@ -169,7 +167,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) { const auto res = pm.GetControlMetadata(); if (res.first == nullptr) { - rb.Push(title_id + DLC_BASE_TO_AOC_ID); + rb.Push(FileSys::GetAOCBaseTitleID(title_id)); return; } -- cgit v1.2.3 From 009bdb3558a1b4c0b08d532b61fc2b34076cc824 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Tue, 8 Dec 2020 09:10:31 -0500 Subject: aoc_u: Stub Create(Permanent)EcPurchasedEventManager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Used by Pokémon Café Mix - Used by DOOM: Eternal --- src/core/hle/service/aoc/aoc_u.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 6abac3f78..4e668d062 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -48,6 +48,24 @@ static std::vector AccumulateAOCTitleIDs(Core::System& system) { return add_on_content; } +class IPurchaseEventManager final : public ServiceFramework { +public: + explicit IPurchaseEventManager(Core::System& system_) + : ServiceFramework{system_, "IPurchaseEventManager"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SetDefaultDeliveryTarget"}, + {1, nullptr, "SetDeliveryTarget"}, + {2, nullptr, "GetPurchasedEventReadableHandle"}, + {3, nullptr, "PopPurchasedProductInfo"}, + {4, nullptr, "PopPurchasedProductInfoWithUid"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + AOC_U::AOC_U(Core::System& system_) : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)} { // clang-format off @@ -62,8 +80,8 @@ AOC_U::AOC_U(Core::System& system_) {7, &AOC_U::PrepareAddOnContent, "PrepareAddOnContent"}, {8, &AOC_U::GetAddOnContentListChangedEvent, "GetAddOnContentListChangedEvent"}, {9, nullptr, "GetAddOnContentLostErrorCode"}, - {100, nullptr, "CreateEcPurchasedEventManager"}, - {101, nullptr, "CreatePermanentEcPurchasedEventManager"}, + {100, &AOC_U::CreateEcPurchasedEventManager, "CreateEcPurchasedEventManager"}, + {101, &AOC_U::CreatePermanentEcPurchasedEventManager, "CreatePermanentEcPurchasedEventManager"}, }; // clang-format on @@ -201,6 +219,22 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(aoc_change_event.readable); } +void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_AOC, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(system); +} + +void AOC_U::CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_AOC, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(system); +} + void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { std::make_shared(system)->InstallAsService(service_manager); } -- cgit v1.2.3 From a9cfe06aaf3fbaf7e16c31f80a75115a07f0af80 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Tue, 8 Dec 2020 10:55:44 -0500 Subject: IPurchaseEventManager: Stub Set(Default)DeliveryTarget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Used by Pokémon Café Mix - Used by DOOM: Eternal --- src/core/hle/service/aoc/aoc_u.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 4e668d062..6223e8fb2 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -54,8 +54,8 @@ public: : ServiceFramework{system_, "IPurchaseEventManager"} { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "SetDefaultDeliveryTarget"}, - {1, nullptr, "SetDeliveryTarget"}, + {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, + {1, &IPurchaseEventManager::SetDeliveryTarget, "SetDeliveryTarget"}, {2, nullptr, "GetPurchasedEventReadableHandle"}, {3, nullptr, "PopPurchasedProductInfo"}, {4, nullptr, "PopPurchasedProductInfoWithUid"}, @@ -64,6 +64,31 @@ public: RegisterHandlers(functions); } + +private: + void SetDefaultDeliveryTarget(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + + const auto unknown_1 = rp.Pop(); + [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer(); + + LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } + + void SetDeliveryTarget(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + + const auto unknown_1 = rp.Pop(); + [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer(); + + LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } }; AOC_U::AOC_U(Core::System& system_) -- cgit v1.2.3 From deff708cbea0409ba6487b3c7a326a436d821924 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Tue, 8 Dec 2020 10:56:13 -0500 Subject: IPurchaseEventManager: Implement GetPurchasedEventReadableHandle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Used by Pokémon Café Mix - Used by DOOM: Eternal --- src/core/hle/service/aoc/aoc_u.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service/aoc/aoc_u.cpp') diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 6223e8fb2..9c404db96 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -56,13 +56,16 @@ public: static const FunctionInfo functions[] = { {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, {1, &IPurchaseEventManager::SetDeliveryTarget, "SetDeliveryTarget"}, - {2, nullptr, "GetPurchasedEventReadableHandle"}, + {2, &IPurchaseEventManager::GetPurchasedEventReadableHandle, "GetPurchasedEventReadableHandle"}, {3, nullptr, "PopPurchasedProductInfo"}, {4, nullptr, "PopPurchasedProductInfoWithUid"}, }; // clang-format on RegisterHandlers(functions); + + purchased_event = Kernel::WritableEvent::CreateEventPair( + system.Kernel(), "IPurchaseEventManager:PurchasedEvent"); } private: @@ -89,6 +92,16 @@ private: IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } + + void GetPurchasedEventReadableHandle(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_AOC, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushCopyObjects(purchased_event.readable); + } + + Kernel::EventPair purchased_event; }; AOC_U::AOC_U(Core::System& system_) -- cgit v1.2.3