diff options
| author | 2019-06-24 19:17:13 -0400 | |
|---|---|---|
| committer | 2019-06-24 19:17:13 -0400 | |
| commit | 5f8d2a2044842a0d0674d178e7bb98be2ee65be2 (patch) | |
| tree | 6b7e462a839240ca305a22d82c9196af4609979f /src | |
| parent | registered_cache: Add getter to determine source slot in content provider union (diff) | |
| download | yuzu-5f8d2a2044842a0d0674d178e7bb98be2ee65be2.tar.gz yuzu-5f8d2a2044842a0d0674d178e7bb98be2ee65be2.tar.xz yuzu-5f8d2a2044842a0d0674d178e7bb98be2ee65be2.zip | |
glue: Add manager to keep track of application registry
Manages mapping between title IDs and application launch and control properties.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/glue/manager.cpp | 73 | ||||
| -rw-r--r-- | src/core/hle/service/glue/manager.h | 46 |
3 files changed, 121 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cdb3bf6ab..6a9a3c180 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -276,6 +276,8 @@ add_library(core STATIC | |||
| 276 | hle/service/friend/friend.h | 276 | hle/service/friend/friend.h |
| 277 | hle/service/friend/interface.cpp | 277 | hle/service/friend/interface.cpp |
| 278 | hle/service/friend/interface.h | 278 | hle/service/friend/interface.h |
| 279 | hle/service/glue/manager.cpp | ||
| 280 | hle/service/glue/manager.h | ||
| 279 | hle/service/grc/grc.cpp | 281 | hle/service/grc/grc.cpp |
| 280 | hle/service/grc/grc.h | 282 | hle/service/grc/grc.h |
| 281 | hle/service/hid/hid.cpp | 283 | hle/service/hid/hid.cpp |
diff --git a/src/core/hle/service/glue/manager.cpp b/src/core/hle/service/glue/manager.cpp new file mode 100644 index 000000000..0d5bb4d50 --- /dev/null +++ b/src/core/hle/service/glue/manager.cpp | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/service/glue/errors.h" | ||
| 6 | #include "core/hle/service/glue/manager.h" | ||
| 7 | |||
| 8 | namespace Service::Glue { | ||
| 9 | |||
| 10 | ARPManager::ARPManager() = default; | ||
| 11 | |||
| 12 | ARPManager::~ARPManager() = default; | ||
| 13 | |||
| 14 | ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const { | ||
| 15 | if (title_id == 0) { | ||
| 16 | return ERR_TITLE_ID_ZERO; | ||
| 17 | } | ||
| 18 | |||
| 19 | const auto iter = entries.find(title_id); | ||
| 20 | if (iter == entries.end()) { | ||
| 21 | return ERR_NONEXISTENT; | ||
| 22 | } | ||
| 23 | |||
| 24 | return MakeResult<ApplicationLaunchProperty>(iter->second.launch); | ||
| 25 | } | ||
| 26 | |||
| 27 | ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { | ||
| 28 | if (title_id == 0) { | ||
| 29 | return ERR_TITLE_ID_ZERO; | ||
| 30 | } | ||
| 31 | |||
| 32 | const auto iter = entries.find(title_id); | ||
| 33 | if (iter == entries.end()) { | ||
| 34 | return ERR_NONEXISTENT; | ||
| 35 | } | ||
| 36 | |||
| 37 | return MakeResult<std::vector<u8>>(iter->second.control); | ||
| 38 | } | ||
| 39 | |||
| 40 | ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, | ||
| 41 | std::vector<u8> control) { | ||
| 42 | if (title_id == 0) { | ||
| 43 | return ERR_TITLE_ID_ZERO; | ||
| 44 | } | ||
| 45 | |||
| 46 | const auto iter = entries.find(title_id); | ||
| 47 | if (iter != entries.end()) { | ||
| 48 | return ERR_ALREADY_ISSUED; | ||
| 49 | } | ||
| 50 | |||
| 51 | entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)}); | ||
| 52 | return RESULT_SUCCESS; | ||
| 53 | } | ||
| 54 | |||
| 55 | ResultCode ARPManager::Unregister(u64 title_id) { | ||
| 56 | if (title_id == 0) { | ||
| 57 | return ERR_TITLE_ID_ZERO; | ||
| 58 | } | ||
| 59 | |||
| 60 | const auto iter = entries.find(title_id); | ||
| 61 | if (iter == entries.end()) { | ||
| 62 | return ERR_NONEXISTENT; | ||
| 63 | } | ||
| 64 | |||
| 65 | entries.erase(iter); | ||
| 66 | return RESULT_SUCCESS; | ||
| 67 | } | ||
| 68 | |||
| 69 | void ARPManager::ResetAll() { | ||
| 70 | entries.clear(); | ||
| 71 | } | ||
| 72 | |||
| 73 | } // namespace Service::Glue | ||
diff --git a/src/core/hle/service/glue/manager.h b/src/core/hle/service/glue/manager.h new file mode 100644 index 000000000..561ebf4e0 --- /dev/null +++ b/src/core/hle/service/glue/manager.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/file_sys/control_metadata.h" | ||
| 8 | #include "core/file_sys/romfs_factory.h" | ||
| 9 | #include "core/hle/result.h" | ||
| 10 | |||
| 11 | namespace Service::Glue { | ||
| 12 | |||
| 13 | struct ApplicationLaunchProperty { | ||
| 14 | u64 title_id; | ||
| 15 | u32 version; | ||
| 16 | FileSys::StorageId base_game_storage_id; | ||
| 17 | FileSys::StorageId update_storage_id; | ||
| 18 | INSERT_PADDING_BYTES(0x2); | ||
| 19 | }; | ||
| 20 | static_assert(sizeof(ApplicationLaunchProperty) == 0x10, | ||
| 21 | "ApplicationLaunchProperty has incorrect size."); | ||
| 22 | |||
| 23 | class ARPManager { | ||
| 24 | public: | ||
| 25 | ARPManager(); | ||
| 26 | ~ARPManager(); | ||
| 27 | |||
| 28 | ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const; | ||
| 29 | ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const; | ||
| 30 | |||
| 31 | ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control); | ||
| 32 | |||
| 33 | ResultCode Unregister(u64 title_id); | ||
| 34 | |||
| 35 | void ResetAll(); | ||
| 36 | |||
| 37 | private: | ||
| 38 | struct MapEntry { | ||
| 39 | ApplicationLaunchProperty launch; | ||
| 40 | std::vector<u8> control; | ||
| 41 | }; | ||
| 42 | |||
| 43 | std::map<u64, MapEntry> entries; | ||
| 44 | }; | ||
| 45 | |||
| 46 | } // namespace Service::Glue | ||