diff options
| author | 2024-02-17 12:00:15 -0500 | |
|---|---|---|
| committer | 2024-02-18 10:32:21 -0500 | |
| commit | 04887953ff98ad4c10bcbffd13dc44480fa48592 (patch) | |
| tree | e2a82f896b03907028915da909efda07246ad6c1 /src | |
| parent | ns: move IFactoryResetInterface (diff) | |
| download | yuzu-04887953ff98ad4c10bcbffd13dc44480fa48592.tar.gz yuzu-04887953ff98ad4c10bcbffd13dc44480fa48592.tar.xz yuzu-04887953ff98ad4c10bcbffd13dc44480fa48592.zip | |
ns: rewrite IContentManagementInterface
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/ns/content_management_interface.cpp | 72 | ||||
| -rw-r--r-- | src/core/hle/service/ns/content_management_interface.h | 25 | ||||
| -rw-r--r-- | src/core/hle/service/ns/ns.cpp | 43 | ||||
| -rw-r--r-- | src/core/hle/service/ns/ns.h | 10 | ||||
| -rw-r--r-- | src/core/hle/service/ns/ns_types.h | 14 |
6 files changed, 114 insertions, 52 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 405dd5ab1..d5206eeae 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -743,6 +743,8 @@ add_library(core STATIC | |||
| 743 | hle/service/ns/account_proxy_interface.h | 743 | hle/service/ns/account_proxy_interface.h |
| 744 | hle/service/ns/application_version_interface.cpp | 744 | hle/service/ns/application_version_interface.cpp |
| 745 | hle/service/ns/application_version_interface.h | 745 | hle/service/ns/application_version_interface.h |
| 746 | hle/service/ns/content_management_interface.cpp | ||
| 747 | hle/service/ns/content_management_interface.h | ||
| 746 | hle/service/ns/ecommerce_interface.cpp | 748 | hle/service/ns/ecommerce_interface.cpp |
| 747 | hle/service/ns/ecommerce_interface.h | 749 | hle/service/ns/ecommerce_interface.h |
| 748 | hle/service/ns/factory_reset_interface.cpp | 750 | hle/service/ns/factory_reset_interface.cpp |
diff --git a/src/core/hle/service/ns/content_management_interface.cpp b/src/core/hle/service/ns/content_management_interface.cpp new file mode 100644 index 000000000..69bb3f6e4 --- /dev/null +++ b/src/core/hle/service/ns/content_management_interface.cpp | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/common_funcs.h" | ||
| 5 | #include "core/core.h" | ||
| 6 | #include "core/hle/service/cmif_serialization.h" | ||
| 7 | #include "core/hle/service/filesystem/filesystem.h" | ||
| 8 | #include "core/hle/service/ns/content_management_interface.h" | ||
| 9 | #include "core/hle/service/ns/ns_types.h" | ||
| 10 | |||
| 11 | namespace Service::NS { | ||
| 12 | |||
| 13 | IContentManagementInterface::IContentManagementInterface(Core::System& system_) | ||
| 14 | : ServiceFramework{system_, "IContentManagementInterface"} { | ||
| 15 | // clang-format off | ||
| 16 | static const FunctionInfo functions[] = { | ||
| 17 | {11, D<&IContentManagementInterface::CalculateApplicationOccupiedSize>, "CalculateApplicationOccupiedSize"}, | ||
| 18 | {43, D<&IContentManagementInterface::CheckSdCardMountStatus>, "CheckSdCardMountStatus"}, | ||
| 19 | {47, D<&IContentManagementInterface::GetTotalSpaceSize>, "GetTotalSpaceSize"}, | ||
| 20 | {48, D<&IContentManagementInterface::GetFreeSpaceSize>, "GetFreeSpaceSize"}, | ||
| 21 | {600, nullptr, "CountApplicationContentMeta"}, | ||
| 22 | {601, nullptr, "ListApplicationContentMetaStatus"}, | ||
| 23 | {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"}, | ||
| 24 | {607, nullptr, "IsAnyApplicationRunning"}, | ||
| 25 | }; | ||
| 26 | // clang-format on | ||
| 27 | |||
| 28 | RegisterHandlers(functions); | ||
| 29 | } | ||
| 30 | |||
| 31 | IContentManagementInterface::~IContentManagementInterface() = default; | ||
| 32 | |||
| 33 | Result IContentManagementInterface::CalculateApplicationOccupiedSize( | ||
| 34 | Out<ApplicationOccupiedSize> out_size, u64 application_id) { | ||
| 35 | LOG_WARNING(Service_NS, "(STUBBED) called, application_id={:016X}", application_id); | ||
| 36 | |||
| 37 | using namespace Common::Literals; | ||
| 38 | |||
| 39 | constexpr ApplicationOccupiedSizeEntity stub_entity{ | ||
| 40 | .storage_id = FileSys::StorageId::SdCard, | ||
| 41 | .app_size = 8_GiB, | ||
| 42 | .patch_size = 2_GiB, | ||
| 43 | .aoc_size = 12_MiB, | ||
| 44 | }; | ||
| 45 | |||
| 46 | for (auto& entity : out_size->entities) { | ||
| 47 | entity = stub_entity; | ||
| 48 | } | ||
| 49 | |||
| 50 | R_SUCCEED(); | ||
| 51 | } | ||
| 52 | |||
| 53 | Result IContentManagementInterface::CheckSdCardMountStatus() { | ||
| 54 | LOG_WARNING(Service_NS, "(STUBBED) called"); | ||
| 55 | R_SUCCEED(); | ||
| 56 | } | ||
| 57 | |||
| 58 | Result IContentManagementInterface::GetTotalSpaceSize(Out<s64> out_total_space_size, | ||
| 59 | FileSys::StorageId storage_id) { | ||
| 60 | LOG_INFO(Service_NS, "(STUBBED) called, storage_id={}", storage_id); | ||
| 61 | *out_total_space_size = system.GetFileSystemController().GetTotalSpaceSize(storage_id); | ||
| 62 | R_SUCCEED(); | ||
| 63 | } | ||
| 64 | |||
| 65 | Result IContentManagementInterface::GetFreeSpaceSize(Out<s64> out_free_space_size, | ||
| 66 | FileSys::StorageId storage_id) { | ||
| 67 | LOG_INFO(Service_NS, "(STUBBED) called, storage_id={}", storage_id); | ||
| 68 | *out_free_space_size = system.GetFileSystemController().GetFreeSpaceSize(storage_id); | ||
| 69 | R_SUCCEED(); | ||
| 70 | } | ||
| 71 | |||
| 72 | } // namespace Service::NS | ||
diff --git a/src/core/hle/service/ns/content_management_interface.h b/src/core/hle/service/ns/content_management_interface.h new file mode 100644 index 000000000..b2242be2b --- /dev/null +++ b/src/core/hle/service/ns/content_management_interface.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/ns/ns_types.h" | ||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | namespace Service::NS { | ||
| 11 | |||
| 12 | class IContentManagementInterface final : public ServiceFramework<IContentManagementInterface> { | ||
| 13 | public: | ||
| 14 | explicit IContentManagementInterface(Core::System& system_); | ||
| 15 | ~IContentManagementInterface() override; | ||
| 16 | |||
| 17 | private: | ||
| 18 | Result CalculateApplicationOccupiedSize(Out<ApplicationOccupiedSize> out_size, | ||
| 19 | u64 application_id); | ||
| 20 | Result CheckSdCardMountStatus(); | ||
| 21 | Result GetTotalSpaceSize(Out<s64> out_total_space_size, FileSys::StorageId storage_id); | ||
| 22 | Result GetFreeSpaceSize(Out<s64> out_free_space_size, FileSys::StorageId storage_id); | ||
| 23 | }; | ||
| 24 | |||
| 25 | } // namespace Service::NS | ||
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 5188699ad..e8b13213d 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "core/hle/service/ipc_helpers.h" | 13 | #include "core/hle/service/ipc_helpers.h" |
| 14 | #include "core/hle/service/ns/account_proxy_interface.h" | 14 | #include "core/hle/service/ns/account_proxy_interface.h" |
| 15 | #include "core/hle/service/ns/application_version_interface.h" | 15 | #include "core/hle/service/ns/application_version_interface.h" |
| 16 | #include "core/hle/service/ns/content_management_interface.h" | ||
| 16 | #include "core/hle/service/ns/ecommerce_interface.h" | 17 | #include "core/hle/service/ns/ecommerce_interface.h" |
| 17 | #include "core/hle/service/ns/factory_reset_interface.h" | 18 | #include "core/hle/service/ns/factory_reset_interface.h" |
| 18 | #include "core/hle/service/ns/language.h" | 19 | #include "core/hle/service/ns/language.h" |
| @@ -464,48 +465,6 @@ Result IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode( | |||
| 464 | return ResultSuccess; | 465 | return ResultSuccess; |
| 465 | } | 466 | } |
| 466 | 467 | ||
| 467 | IContentManagementInterface::IContentManagementInterface(Core::System& system_) | ||
| 468 | : ServiceFramework{system_, "IContentManagementInterface"} { | ||
| 469 | // clang-format off | ||
| 470 | static const FunctionInfo functions[] = { | ||
| 471 | {11, nullptr, "CalculateApplicationOccupiedSize"}, | ||
| 472 | {43, nullptr, "CheckSdCardMountStatus"}, | ||
| 473 | {47, &IContentManagementInterface::GetTotalSpaceSize, "GetTotalSpaceSize"}, | ||
| 474 | {48, &IContentManagementInterface::GetFreeSpaceSize, "GetFreeSpaceSize"}, | ||
| 475 | {600, nullptr, "CountApplicationContentMeta"}, | ||
| 476 | {601, nullptr, "ListApplicationContentMetaStatus"}, | ||
| 477 | {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"}, | ||
| 478 | {607, nullptr, "IsAnyApplicationRunning"}, | ||
| 479 | }; | ||
| 480 | // clang-format on | ||
| 481 | |||
| 482 | RegisterHandlers(functions); | ||
| 483 | } | ||
| 484 | |||
| 485 | IContentManagementInterface::~IContentManagementInterface() = default; | ||
| 486 | |||
| 487 | void IContentManagementInterface::GetTotalSpaceSize(HLERequestContext& ctx) { | ||
| 488 | IPC::RequestParser rp{ctx}; | ||
| 489 | const auto storage{rp.PopEnum<FileSys::StorageId>()}; | ||
| 490 | |||
| 491 | LOG_INFO(Service_Capture, "called, storage={}", storage); | ||
| 492 | |||
| 493 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 494 | rb.Push(ResultSuccess); | ||
| 495 | rb.Push<u64>(system.GetFileSystemController().GetTotalSpaceSize(storage)); | ||
| 496 | } | ||
| 497 | |||
| 498 | void IContentManagementInterface::GetFreeSpaceSize(HLERequestContext& ctx) { | ||
| 499 | IPC::RequestParser rp{ctx}; | ||
| 500 | const auto storage{rp.PopEnum<FileSys::StorageId>()}; | ||
| 501 | |||
| 502 | LOG_INFO(Service_Capture, "called, storage={}", storage); | ||
| 503 | |||
| 504 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 505 | rb.Push(ResultSuccess); | ||
| 506 | rb.Push<u64>(system.GetFileSystemController().GetFreeSpaceSize(storage)); | ||
| 507 | } | ||
| 508 | |||
| 509 | IDocumentInterface::IDocumentInterface(Core::System& system_) | 468 | IDocumentInterface::IDocumentInterface(Core::System& system_) |
| 510 | : ServiceFramework{system_, "IDocumentInterface"} { | 469 | : ServiceFramework{system_, "IDocumentInterface"} { |
| 511 | // clang-format off | 470 | // clang-format off |
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h index 853896b48..27ccda38d 100644 --- a/src/core/hle/service/ns/ns.h +++ b/src/core/hle/service/ns/ns.h | |||
| @@ -32,16 +32,6 @@ private: | |||
| 32 | void ConvertApplicationLanguageToLanguageCode(HLERequestContext& ctx); | 32 | void ConvertApplicationLanguageToLanguageCode(HLERequestContext& ctx); |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | class IContentManagementInterface final : public ServiceFramework<IContentManagementInterface> { | ||
| 36 | public: | ||
| 37 | explicit IContentManagementInterface(Core::System& system_); | ||
| 38 | ~IContentManagementInterface() override; | ||
| 39 | |||
| 40 | private: | ||
| 41 | void GetTotalSpaceSize(HLERequestContext& ctx); | ||
| 42 | void GetFreeSpaceSize(HLERequestContext& ctx); | ||
| 43 | }; | ||
| 44 | |||
| 45 | class IDocumentInterface final : public ServiceFramework<IDocumentInterface> { | 35 | class IDocumentInterface final : public ServiceFramework<IDocumentInterface> { |
| 46 | public: | 36 | public: |
| 47 | explicit IDocumentInterface(Core::System& system_); | 37 | explicit IDocumentInterface(Core::System& system_); |
diff --git a/src/core/hle/service/ns/ns_types.h b/src/core/hle/service/ns/ns_types.h index 1b97ac816..b39181856 100644 --- a/src/core/hle/service/ns/ns_types.h +++ b/src/core/hle/service/ns/ns_types.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_funcs.h" | 6 | #include "common/common_funcs.h" |
| 7 | #include "core/file_sys/romfs_factory.h" | ||
| 7 | 8 | ||
| 8 | namespace Service::NS { | 9 | namespace Service::NS { |
| 9 | 10 | ||
| @@ -59,4 +60,17 @@ struct ApplicationViewWithPromotionInfo { | |||
| 59 | PromotionInfo promotion; ///< \ref NsPromotionInfo | 60 | PromotionInfo promotion; ///< \ref NsPromotionInfo |
| 60 | }; | 61 | }; |
| 61 | 62 | ||
| 63 | struct ApplicationOccupiedSizeEntity { | ||
| 64 | FileSys::StorageId storage_id; | ||
| 65 | u64 app_size; | ||
| 66 | u64 patch_size; | ||
| 67 | u64 aoc_size; | ||
| 68 | }; | ||
| 69 | static_assert(sizeof(ApplicationOccupiedSizeEntity) == 0x20, | ||
| 70 | "ApplicationOccupiedSizeEntity has incorrect size."); | ||
| 71 | |||
| 72 | struct ApplicationOccupiedSize { | ||
| 73 | std::array<ApplicationOccupiedSizeEntity, 4> entities; | ||
| 74 | }; | ||
| 75 | |||
| 62 | } // namespace Service::NS | 76 | } // namespace Service::NS |